From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 20:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 43598@debbugs.gnu.org Cc: Lars Ingebrigtsen X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160098074120740 (code B ref -1); Thu, 24 Sep 2020 20:53:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Sep 2020 20:52:21 +0000 Received: from localhost ([127.0.0.1]:41923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYE0-0005OS-OD for submit@debbugs.gnu.org; Thu, 24 Sep 2020 16:52:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:48136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYDx-0005OJ-Do for submit@debbugs.gnu.org; Thu, 24 Sep 2020 16:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLYDx-0000Oh-4b for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:52:17 -0400 Received: from mail78c50.megamailservers.eu ([91.136.10.88]:59052 helo=mail70c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLYDu-00008U-Ie for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:52:16 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1600980729; bh=REyLP06U+y2uakEpIGEywOnO+Dn6PSP+/csd/f1MmHM=; h=From:Subject:Date:Cc:To:From; b=bRYOmn6Ci49tnvBZ+MmW1JfHGAjPb1mtOa7UmZ5igzTRGMvJcrZdH1f/dE159Eye8 zmGgLYupW8vt6g99JoxYuo3ue+kmvqUT4EiWpUdrOXxMN01bgTKVI91un+5dFy3zo5 1Tllw4eHaH6zaongTIxs4sxZ7D4/Qm8Zj45P5xjc= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08OKq7lP014751; Thu, 24 Sep 2020 20:52:09 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Message-Id: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> Date: Thu, 24 Sep 2020 22:52:06 +0200 X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F1E.5F6D06F9.001B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OKBZIhSB c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=Lz5n3o7qXXkDrfnKqmYA:9 a=QEXdDO2ut3YA:10 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.10.88; envelope-from=mattiase@acm.org; helo=mail70c50.megamailservers.eu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 16:52:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) The new replace-in-string function is welcome but needs a few tweaks = before we can call it done: 1. It doesn't quite work correctly with raw bytes: (replace-in-string "\377" "x" "a\377b") =3D> "axb" (replace-in-string "\377" "x" "a\377=C3=B8") =3D> "a\377=C3=B8" The easiest solution is to reimplement it in terms of = replace-regexp-in-string for now, and optimise it later (although I feel = a bit bad undoing Lars's pretty handiwork...) We have messy semantics here, because string-equal does not equate = "\377" and (string-to-multibyte "\377"), but string-match-p does... 2. It is documented always to return a new string, but that's a tad = over-generous nowadays; very few string functions do that. If we drop = that guarantee, we get some optimisation opportunities: - it can return the input string itself if no matches were found (a = fairly common case) - it can be marked pure, not just side-effect-free, so that the byte = compiler can constant-propagate through calls to it 3. The name is somewhat unfortunate since a function by that name in = XEmacs uses regexp matching. In fact, the new function probably broke prolog-mode because of that = (see prolog-replace-in-string). While we can fix prolog-mode, we can't easily fix code outside the Emacs = tree that may have similar problems. Perhaps we should rename it to string-replace, in line with the modern = naming convention discussed some time ago. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 21:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160098196322559 (code B ref 43598); Thu, 24 Sep 2020 21:13:02 +0000 Received: (at 43598) by debbugs.gnu.org; 24 Sep 2020 21:12:43 +0000 Received: from localhost ([127.0.0.1]:41944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYXi-0005rn-Ns for submit@debbugs.gnu.org; Thu, 24 Sep 2020 17:12:42 -0400 Received: from quimby.gnus.org ([95.216.78.240]:60104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYXf-0005rX-MO for 43598@debbugs.gnu.org; Thu, 24 Sep 2020 17:12:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r9q3xsfcs7tWcUJAqNMu3mGEIrL3rCjB+w+ZF/ZgPdo=; b=SxAC3z0qPlupNRR5wbp0Q1Sv3c sIWs9wDdn9h3Z9gJ9laV6oR0IPBE7XjMW0Wb593soJukQ3UawZpHmsS5Q9/xH2T3Xe7pMEJWR9JgG EfUezVN1wuXETv1rwo2eE9NBcBDshvOuk2Ps0OSlqUbtUBxqceYuR2h1RXXJG8mVyJrs=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLYXW-0002cW-NC; Thu, 24 Sep 2020 23:12:33 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEUaFBVQLzFpT0jX xreXdmX////FQDyEAAAAAWJLR0QF+G/pxwAAAAd0SU1FB+QJGBUIDuwwKKEAAAGiSURBVDjLtZJd csMgDIQR9gFYwgGMwgGawAHMz/3PVBE7DSR96EsZ2+PRNxLSrpT6j2MB/1tcJ5er+YzTmmqq20xo k0LXFmO9SzH9hGRtadamJca9em6B84EotNBq2GuM97WkVlo5U1BCKI6jHM6hlIazFBe2Hq2DAus5 8BM0yKkdpP7X+LyjZSvDhSMD3rt23hGsVDD9jsTkEfxTAGIDT7jGeIOxIP6ZkjfsBBejh3FGvxQj owX4mCzMutEoSpA2t3rX0nYZ4wqCDEDICu9ukDdkzfYpOwSAPg0hCcN8AC0OSTfycXOx5S4akemS fb0ZDu76MeqcgYrzpLldXP0Rt7cJEJZ8APeFsTENfYJgMF4i7bcDNDWNsu7q8khxN7WOGWuS52H8 ruQZgHgnvnKNuMQZJO/6MmQb30CVOfooLr0BFkW8LBHzL+B4Z5AkRh2Ap66WtD+A6L5Oui91e2bo NIJLE2Otl+Ux1G5/AbW8QEgDSLyJ4S6L7Zrr1G1fnlD6Ao39rqmIidhkcqPCABapS48dEVDLq1/X AalQyAjIuce+AVjaRzAHwlsjAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA5LTI0VDIxOjA4OjE0 KzAwOjAwxRhePgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOS0yNFQyMTowODoxNCswMDowMLRF 5oIAAAAASUVORK5CYII= X-Now-Playing: Juana Molina's _Un =?UTF-8?Q?D=C3=ADa=5F:?= "Un =?UTF-8?Q?D=C3=ADa?=" Date: Thu, 24 Sep 2020 23:12:29 +0200 In-Reply-To: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Thu, 24 Sep 2020 22:52:06 +0200") Message-ID: <87o8luubeq.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > The new replace-in-string function is welcome but needs a few tweaks > before we can call it done: > > 1. It doesn't quite work correctly with raw bytes: > > (replace-in-string "\377" "x" "a\377b") [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > The new replace-in-string function is welcome but needs a few tweaks > before we can call it done: > > 1. It doesn't quite work correctly with raw bytes: > > (replace-in-string "\377" "x" "a\377b") > =3D> "axb" > (replace-in-string "\377" "x" "a\377=C3=B8") > =3D> "a\377=C3=B8" > > The easiest solution is to reimplement it in terms of > replace-regexp-in-string for now, and optimise it later (although I > feel a bit bad undoing Lars's pretty handiwork...) The point of the function is to have something very lightweight, so if it's reimplemented on top of replace-regexp-in-string, there's not much point of the function. > We have messy semantics here, because string-equal does not equate > "\377" and (string-to-multibyte "\377"), but string-match-p does... Yes, I don't even know what the semantics should be. (string-replace "\377" "x" "a\377=C3=B8") =3D> "ax=C3=B8" would make sense, but what about (string-replace "\270" "x" "a\377=C3=B8") =3D> ? (\270 is the last byte in the =C3=B8.) Doing anything here wouldn't make much sense at all, which means... we could just throw up our hands and say "don't do that, then", which is approx. what string-equal does. > 2. It is documented always to return a new string, but that's a tad > over-generous nowadays; very few string functions do that. If we drop > that guarantee, we get some optimisation opportunities: > > - it can return the input string itself if no matches were found (a > fairly common case) > - it can be marked pure, not just side-effect-free, so that the byte > compiler can constant-propagate through calls to it Yup, good idea. > 3. The name is somewhat unfortunate since a function by that name in > XEmacs uses regexp matching. > In fact, the new function probably broke prolog-mode because of that > (see prolog-replace-in-string). > While we can fix prolog-mode, we can't easily fix code outside the > Emacs tree that may have similar problems. > > Perhaps we should rename it to string-replace, in line with the modern > naming convention discussed some time ago. string-replace seems like a good name. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 21:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160098238323286 (code B ref 43598); Thu, 24 Sep 2020 21:20:02 +0000 Received: (at 43598) by debbugs.gnu.org; 24 Sep 2020 21:19:43 +0000 Received: from localhost ([127.0.0.1]:41956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYeU-00063T-RT for submit@debbugs.gnu.org; Thu, 24 Sep 2020 17:19:43 -0400 Received: from quimby.gnus.org ([95.216.78.240]:60144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYeS-00063E-T6 for 43598@debbugs.gnu.org; Thu, 24 Sep 2020 17:19:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=g+z0rCreDakwVUnRm6sgAvJOMqrWw3mnOsp4dBpiH8I=; b=fRex5sxK4eTWu9eYgJge3UWkkX dEDaaPbI8OqrfzssCVBBTndLaycDNBNsuCQIQDjc37VehPr0XtRZXYlbSy7ZB7zSFegc2IG2ot03U IgT5HUefv9WTP934DP5AeHIIQ91jTqVYATi/YCt+C3O+YSq32i+705cAEG4FhGZ3pM5E=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLYeF-0002h4-CH; Thu, 24 Sep 2020 23:19:34 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEUaFBVQLzFpT0jX xreXdmX////FQDyEAAAAAWJLR0QF+G/pxwAAAAd0SU1FB+QJGBUIDuwwKKEAAAGiSURBVDjLtZJd csMgDIQR9gFYwgGMwgGawAHMz/3PVBE7DSR96EsZ2+PRNxLSrpT6j2MB/1tcJ5er+YzTmmqq20xo k0LXFmO9SzH9hGRtadamJca9em6B84EotNBq2GuM97WkVlo5U1BCKI6jHM6hlIazFBe2Hq2DAus5 8BM0yKkdpP7X+LyjZSvDhSMD3rt23hGsVDD9jsTkEfxTAGIDT7jGeIOxIP6ZkjfsBBejh3FGvxQj owX4mCzMutEoSpA2t3rX0nYZ4wqCDEDICu9ukDdkzfYpOwSAPg0hCcN8AC0OSTfycXOx5S4akemS fb0ZDu76MeqcgYrzpLldXP0Rt7cJEJZ8APeFsTENfYJgMF4i7bcDNDWNsu7q8khxN7WOGWuS52H8 ruQZgHgnvnKNuMQZJO/6MmQb30CVOfooLr0BFkW8LBHzL+B4Z5AkRh2Ap66WtD+A6L5Oui91e2bo NIJLE2Otl+Ux1G5/AbW8QEgDSLyJ4S6L7Zrr1G1fnlD6Ao39rqmIidhkcqPCABapS48dEVDLq1/X AalQyAjIuce+AVjaRzAHwlsjAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA5LTI0VDIxOjA4OjE0 KzAwOjAwxRhePgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOS0yNFQyMTowODoxNCswMDowMLRF 5oIAAAAASUVORK5CYII= X-Now-Playing: Juana Molina's _Un =?UTF-8?Q?D=C3=ADa=5F:?= "Lo Dejamos" Date: Thu, 24 Sep 2020 23:19:26 +0200 In-Reply-To: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Thu, 24 Sep 2020 22:52:06 +0200") Message-ID: <87k0wiub35.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: That is, we could just say "the results are undefined if the strings contain raw bytes". Well, rather, if both strings are raw bytes, or none of them are, then it's well-defined, but not otherwise. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) That is, we could just say "the results are undefined if the strings contain raw bytes". Well, rather, if both strings are raw bytes, or none of them are, then it's well-defined, but not otherwise. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 23:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16009895091589 (code B ref 43598); Thu, 24 Sep 2020 23:19:02 +0000 Received: (at 43598) by debbugs.gnu.org; 24 Sep 2020 23:18:29 +0000 Received: from localhost ([127.0.0.1]:42003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLaVR-0000PY-EE for submit@debbugs.gnu.org; Thu, 24 Sep 2020 19:18:29 -0400 Received: from quimby.gnus.org ([95.216.78.240]:60934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLaVP-0000PI-8b for 43598@debbugs.gnu.org; Thu, 24 Sep 2020 19:18:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=z6RRqiMkiklctSAXNupAvPkSO09moS5+gwej/3+ZjLk=; b=dnykMF4tNNqT2oE68noV0U8/3c ZvBgsybQwtFu+HF76RS/dqaSGx6IgcGhPWrlBcorl12kUEsVI+PRmZdWLom0F4n01DeGurWcVbF9C yxjagKJd1ikVRbRjQa9/ye+Zes+YXCcRw3IciY1vRLdxQsPlUh1FbGLbdKcdgT93zk0s=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLaVC-0003ha-V7; Fri, 25 Sep 2020 01:18:20 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87k0wiub35.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEVQSESUiWkXEBT/ //+WnfVkAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+QJGBcLJ4YrN2AAAAFrSURBVCjPRdHNSsNAEAfw yWJg2VOV5uKpeNI8RVtQJKdaMlJfoU8RF1vaHKX2PCko2/9TOrtJdUI+fpnJ7gwhoisy7Z6rI0BE Od24Pa/HCTNFx/NakTPzTfXNWUT2yPVt2XEXQdf8Uik2rwg0ypgdpN7U6CiGA9o/PAPYjCF/+EgL DMgvqIBdvhywBmxR/WdsIR406WEOXwpLlK1r65rcp7Ks5IV9vwC8tHlzB2p0OhSKUJ5JRqMcCJbO LhC+XlgbCKYzgcrDw1QBJwp9WcYMiZYdkSIYcaATXA8tIAyZLRTLN33sEFynsG9ti3PwaNxQdp6E U2NAC+sBXcmLli1mx9uIuB2tpp+r2IyOriPIyMDPe/CUDHZDhpc46dFVqcwkUOw2XrbDHXRVwmum SSigCJA4GenMP5rRPxSEasg2AW1BTxCjT3oGpjlS517CJNNtILFG7n2hKNNIgh2TC/0XGosebcIr lYJLHH4BMqP08Xvzha8AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjAtMDktMjRUMjM6MTE6MzkrMDA6 MDC7LXnCAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTA5LTI0VDIzOjExOjM5KzAwOjAwynDBfgAA AABJRU5ErkJggg== X-Now-Playing: David Bowie's _The Rise and Fall of Ziggy Stardust and the Spiders From Mars_: "Lady Stardust" Date: Fri, 25 Sep 2020 01:18:13 +0200 In-Reply-To: <87k0wiub35.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 24 Sep 2020 23:19:26 +0200") Message-ID: <87ft76u5l6.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > That is, we could just say "the results are undefined if the strings > contain raw bytes". Well, rather, if both strings are raw bytes, or > none of them are, then it's well-defined, but not otherwi [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > That is, we could just say "the results are undefined if the strings > contain raw bytes". Well, rather, if both strings are raw bytes, or > none of them are, then it's well-defined, but not otherwise. Or... OK, I've never actually looked at the strings this closely, I've just used the various accessors which hide all the complexity. So: "a\377=C3=B8" is a multibyte string with five bytes (the "raw byte" is = in the private plane). "a\377a" is a unibyte string with three bytes. So searching for "\377" (one-byte unibyte string) and (make-string 1 255) (two-byte multibyte string) should be well-defined in either combination here? "\377" is in both "a\377=C3=B8" and "a\377a". (make-string 1 255) is in neither "a\377=C3=B8", nor "a\377a". And: (eq (elt (make-string 1 255) 0) (elt "\377" 0)) =3D> t But, like, whatevs. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Sep 2020 23:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16009916984820 (code B ref 43598); Thu, 24 Sep 2020 23:55:01 +0000 Received: (at 43598) by debbugs.gnu.org; 24 Sep 2020 23:54:58 +0000 Received: from localhost ([127.0.0.1]:42015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLb4k-0001Fg-K6 for submit@debbugs.gnu.org; Thu, 24 Sep 2020 19:54:58 -0400 Received: from quimby.gnus.org ([95.216.78.240]:32936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLb4i-0001FR-NN for 43598@debbugs.gnu.org; Thu, 24 Sep 2020 19:54:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ghdvmWf2LfWLViloYSjoIOePb9sDVWYPHoWKAedEBm8=; b=UWoJWfyzl2VwFdU7DKV6W7e2G5 e4gpyW5y0+p/vO00IdRy/2oOR7zShYfSoIB9Qd9npXEmNH72jZ1m2RUtpEqT+FBwVGevsrhc740t2 f68i3zlZweKTqMvlrjb6E29R7nnyKObptOUwybIMUH+jYE9jhRPrgAj6ZL9bg4IKCxh0=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLb4Z-000406-Ly; Fri, 25 Sep 2020 01:54:50 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> X-Now-Playing: David Bowie's _Aladdin Sane_: "Time" Date: Fri, 25 Sep 2020 01:54:46 +0200 In-Reply-To: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Thu, 24 Sep 2020 22:52:06 +0200") Message-ID: <87blhuu3w9.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > The new replace-in-string function is welcome but needs a few tweaks > before we can call it done: > > 1. It doesn't quite work correctly with raw bytes: > > (replace-in-string "\377" "x" "a\377b") [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > The new replace-in-string function is welcome but needs a few tweaks > before we can call it done: > > 1. It doesn't quite work correctly with raw bytes: > > (replace-in-string "\377" "x" "a\377b") > =3D> "axb" > (replace-in-string "\377" "x" "a\377=C3=B8") > =3D> "a\377=C3=B8" I went ahead and checked in a new C-level function string-search, which should be an efficient way to search for strings in strings (using memmem, which Emacs has via Gnulib?), and this fixed these corner cases. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 09:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: mattiase@acm.org, 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160102570325004 (code B ref 43598); Fri, 25 Sep 2020 09:22:02 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 09:21:43 +0000 Received: from localhost ([127.0.0.1]:42640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLjvC-0006VE-U3 for submit@debbugs.gnu.org; Fri, 25 Sep 2020 05:21:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLjvB-0006Uz-2d for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 05:21:41 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51543) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLjv5-0000Z0-H9; Fri, 25 Sep 2020 05:21:35 -0400 Received: from [176.228.60.248] (port=4253 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLjv4-0007Vr-Sw; Fri, 25 Sep 2020 05:21:35 -0400 Date: Fri, 25 Sep 2020 12:21:45 +0300 Message-Id: <834knmtdna.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87ft76u5l6.fsf@gnus.org> (message from Lars Ingebrigtsen on Fri, 25 Sep 2020 01:18:13 +0200) References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87k0wiub35.fsf@gnus.org> <87ft76u5l6.fsf@gnus.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Lars Ingebrigtsen > Date: Fri, 25 Sep 2020 01:18:13 +0200 > Cc: 43598@debbugs.gnu.org > > So: "a\377ø" is a multibyte string with five bytes (the "raw byte" is in > the private plane). > > "a\377a" is a unibyte string with three bytes. > > So searching for "\377" (one-byte unibyte string) and (make-string 1 > 255) (two-byte multibyte string) should be well-defined in either > combination here? > > "\377" is in both "a\377ø" and "a\377a". > > (make-string 1 255) is in neither "a\377ø", nor "a\377a". > > And: > > (eq (elt (make-string 1 255) 0) (elt "\377" 0)) > => t Would it help to always convert the first argument of replace-in-string to a multibyte string, before replacing? From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 10:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: mattiase@acm.org, 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16010285725584 (code B ref 43598); Fri, 25 Sep 2020 10:10:02 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 10:09:32 +0000 Received: from localhost ([127.0.0.1]:42736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLkfQ-0001Rv-Cx for submit@debbugs.gnu.org; Fri, 25 Sep 2020 06:09:32 -0400 Received: from quimby.gnus.org ([95.216.78.240]:38330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLkfO-0001Ri-GO for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 06:09:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cIZyvwCUt7mD7bCK6MeD6ceos6mcCvH2zwloBfl90DI=; b=Px20JyekituNkSzEfk/Rj06uol fkWkf/DxpAdDYtC6xUpLK676hB3Vo9xu9WDnU0ugSr3DrfqXsNaGm/lN1uwmm8TcA6zB57Qy6HDo+ wxLa35Rd+XX0LKiqZyC4aB0AA2yiT7qJCyu11/cGd1ZqCQJ2MXJIyKVWh8KqxAdc+7qo=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLkfF-0000xx-HO; Fri, 25 Sep 2020 12:09:20 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87k0wiub35.fsf@gnus.org> <87ft76u5l6.fsf@gnus.org> <834knmtdna.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEXXnlrDt7BaLSqw RzEvJCgNCAx8eIRdVFX////3Dm9OAAAAAWJLR0QIht6VegAAAAd0SU1FB+QJGQklNdCRphsAAAG2 SURBVDjLldRLj5swEADgSSJlr8yqYs+1odzDqr22xGTuxJNcy6oL1w1y4r9f2xCFEPawI4Gl+TR+ YgAWQshEy7RGxEVUMhe5D4C1EPlrIVO8wn4AcO+NHEE1wCpAzohRDzzAUnrY6BtshwoPQlQBwMP+ NoYbP7tV6AGEL+ihDhU8gEu7pbzSBbH+O4ZVEMNMuGgCyB6WQjk4uwSdonEFmEKIzAPrjzGsUxLi R+ozfBzB2vBOCBsyQ2wDmFLv3rJulA8LAVClpuf2DnwJPGnWytCZJyXw5JqSuLwD3q9g6dtK8ySk r/A1U9j3wDOwmQc5wDSqHGI6UNvaQ2GtstYaIttl9gMAT39e6IAnZU2RiM4UJAx1tHIQO4hjpVQx PC5KCWjtpWldP9fo57EFnB3czSqehxy+zcPuy3CBd7+HD/ljDf6Efqcz4Jvv5yloDB9r+7C5HL7i 6t/j4Jnv6qA+gf5g76emgD+JWXBdaHicqSpsojW0ibbnu7zKOpkk7mr+xPeQIlKK/M1SJVnr7+wv EwBPtqkxbOqxacLVTK5wqfFFCMVUI4gJRP4fkgUodb9yDBFBH/8BdU85s9N4aKgAAAAldEVYdGRh dGU6Y3JlYXRlADIwMjAtMDktMjVUMDk6Mzc6NTMrMDA6MDD5GdWXAAAAJXRFWHRkYXRlOm1vZGlm eQAyMDIwLTA5LTI1VDA5OjM3OjUzKzAwOjAwiERtKwAAAABJRU5ErkJggg== X-Now-Playing: Thievery Corporation's _The Mirror Conspiracy_: "The Mirror Conspiracy" Date: Fri, 25 Sep 2020 12:09:16 +0200 In-Reply-To: <834knmtdna.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 25 Sep 2020 12:21:45 +0300") Message-ID: <877dsirwvn.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: > Would it help to always convert the first argument of > replace-in-string to a multibyte string, before replacing? Yes, but not when the third argument is a unibyte string. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Would it help to always convert the first argument of > replace-in-string to a multibyte string, before replacing? Yes, but not when the third argument is a unibyte string. I've now done the conversion in the new string-search C-level function, converting the search string both ways, depending on what the HAYSTACK string is. I'm not 100% sure that I'm doing the right thing here, though, but it seems to pass all the test cases I could come up with. I wrote it very late last night, though, so... :-/ -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 10:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160103054925601 (code B ref 43598); Fri, 25 Sep 2020 10:43:01 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 10:42:29 +0000 Received: from localhost ([127.0.0.1]:42789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLlBN-0006eq-1M for submit@debbugs.gnu.org; Fri, 25 Sep 2020 06:42:29 -0400 Received: from mail1458c50.megamailservers.eu ([91.136.14.58]:59296 helo=mail267c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLlBH-0006eW-KG for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 06:42:27 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601030536; bh=OoIWLt5kJkXQ6llnn3obcxfpnWqJMQpn+PsRW0qS2JA=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=W5DcUa5Pc0R/kdpuDS6MSkSSXr4v4zaXbP1RHmio27tt6WLAoHDe5FbRR5+EsTFFx GIGnHQtxHuMPohIyIwP6OaAnzzTwh83rEXQnw3FS/BYqvW/DtBZwWWA7yWahsmagig vtSSaCZ2XECqnmr4CamMAgzF+Ckz4+27RTPJyeAc= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail267c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08PAg7Ap023190; Fri, 25 Sep 2020 10:42:08 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_EB777C97-CDF8-48EF-A5E7-78C47B853B0E" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Date: Fri, 25 Sep 2020 12:42:06 +0200 In-Reply-To: <87blhuu3w9.fsf@gnus.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F26.5F6DC988.0044, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=Cf92G4jl c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=58POXaC9i2PCeO8P82MA:9 a=QEXdDO2ut3YA:10 a=AVAWrLMCqMzcJ98pz_gA:9 a=De_Ol2h6w80A:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 25 sep. 2020 kl. 01.54 skrev Lars Ingebrigtsen : > I went ahead and checked in a new C-level function string-search, which > should be an efficient way to search for strings in strings (using > memmem, which Emacs has via Gnulib?), and this fixed th [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.3 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_EB777C97-CDF8-48EF-A5E7-78C47B853B0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 25 sep. 2020 kl. 01.54 skrev Lars Ingebrigtsen : > I went ahead and checked in a new C-level function string-search, = which > should be an efficient way to search for strings in strings (using > memmem, which Emacs has via Gnulib?), and this fixed these corner = cases. Thank you! Here are some proposed tweaks (diff attached): 1. Check the range of the START-POS argument so that we don't crash. The permitted range is [0..N] where N is (length HAYSTACK), thus we = permit a start right after the last character but no further. We could also return nil in these cases but I think an error is more = useful. 2. Make the docs more precise about various things. 3. Slight simplification of the implementation logic to avoid testing = the same conditions multiple times. 4. More tests, especially for edge cases. Can't have too many! One test still fails: (string-search "=C3=B8" "\303\270") which should return nil but currently matches. I think it's wrong to convert the needle to unibyte (using = Fstring_as_unibyte) in this case, but I haven't decided what the best = solution would be. We should also consider the optimisations: - If SCHARS(needle)>SCHARS(haystack) then no match is possible. - If either needle or haystack is all-ASCII (all bytes in 0..127), then = we can use memmem without conversion. --Apple-Mail=_EB777C97-CDF8-48EF-A5E7-78C47B853B0E Content-Disposition: attachment; filename=string-search.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="string-search.diff" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/doc/lispref/strings.texi=20b/doc/lispref/strings.texi=0A= index=206eb3d6f310..0f157c39d6=20100644=0A---=20= a/doc/lispref/strings.texi=0A+++=20b/doc/lispref/strings.texi=0A@@=20= -660,8=20+660,10=20@@=20Text=20Comparison=0A=20Return=20the=20position=20= of=20the=20first=20instance=20of=20@var{needle}=20in=0A=20= @var{haystack},=20both=20of=20which=20are=20strings.=20=20If=20= @var{start-pos}=20is=0A=20non-@code{nil},=20start=20searching=20from=20= that=20position=20in=20@var{needle}.=0A+Return=20@code{nil}=20if=20no=20= match=20was=20found.=0A=20This=20function=20only=20considers=20the=20= characters=20in=20the=20strings=20when=20doing=0A-the=20comparison;=20= text=20properties=20are=20ignored.=0A+the=20comparison;=20text=20= properties=20are=20ignored.=20=20Matching=20is=20always=0A= +case-sensitive.=0A=20@end=20defun=0A=20=0A=20@defun=20compare-strings=20= string1=20start1=20end1=20string2=20start2=20end2=20&optional=20= ignore-case=0Adiff=20--git=20a/src/fns.c=20b/src/fns.c=0Aindex=20= 3927e4306e..2f64d95576=20100644=0A---=20a/src/fns.c=0A+++=20b/src/fns.c=0A= @@=20-5456,15=20+5456,18=20@@=20DEFUN=20("buffer-hash",=20Fbuffer_hash,=20= Sbuffer_hash,=200,=201,=200,=0A=20=0A=20DEFUN=20("string-search",=20= Fstring_search,=20Sstring_search,=202,=203,=200,=0A=20=20=20=20=20=20=20=20= doc:=20/*=20Search=20for=20the=20string=20NEEDLE=20in=20the=20string=20= HAYSTACK.=0A-The=20return=20value=20is=20the=20position=20of=20the=20= first=20instance=20of=20NEEDLE=20in=0A-HAYSTACK.=0A+The=20return=20value=20= is=20the=20position=20of=20the=20first=20occurrence=20of=20NEEDLE=20in=0A= +HAYSTACK,=20or=20nil=20if=20no=20match=20was=20found.=0A=20=0A=20The=20= optional=20START-POS=20argument=20says=20where=20to=20start=20searching=20= in=0A-HAYSTACK.=20=20If=20not=20given,=20start=20at=20the=20beginning.=20= */)=0A+HAYSTACK=20and=20defaults=20to=20zero=20(start=20at=20the=20= beginning).=0A+It=20must=20be=20between=20zero=20and=20the=20length=20of=20= HAYSTACK,=20inclusive.=0A+=0A+Case=20is=20always=20significant=20and=20= text=20properties=20are=20ignored.=20*/)=0A=20=20=20(register=20= Lisp_Object=20needle,=20Lisp_Object=20haystack,=20Lisp_Object=20= start_pos)=0A=20{=0A=20=20=20ptrdiff_t=20start_byte=20=3D=200,=20= haybytes;=0A-=20=20char=20*res=20=3D=20NULL,=20*haystart;=0A+=20=20char=20= *res,=20*haystart;=0A=20=0A=20=20=20CHECK_STRING=20(needle);=0A=20=20=20= CHECK_STRING=20(haystack);=0A@@=20-5472,7=20+5475,10=20@@=20DEFUN=20= ("string-search",=20Fstring_search,=20Sstring_search,=202,=203,=200,=0A=20= =20=20if=20(!NILP=20(start_pos))=0A=20=20=20=20=20{=0A=20=20=20=20=20=20=20= CHECK_FIXNUM=20(start_pos);=0A-=20=20=20=20=20=20start_byte=20=3D=20= string_char_to_byte=20(haystack,=20XFIXNUM=20(start_pos));=0A+=20=20=20=20= =20=20EMACS_INT=20start=20=3D=20XFIXNUM=20(start_pos);=0A+=20=20=20=20=20= =20if=20(start=20<=200=20||=20start=20>=20SCHARS=20(haystack))=0A+=20=20=20= =20=20=20=20=20xsignal1=20(Qargs_out_of_range,=20start_pos);=0A+=20=20=20= =20=20=20start_byte=20=3D=20string_char_to_byte=20(haystack,=20start);=0A= =20=20=20=20=20}=0A=20=0A=20=20=20haystart=20=3D=20SSDATA=20(haystack)=20= +=20start_byte;=0A@@=20-5481,13=20+5487,13=20@@=20DEFUN=20= ("string-search",=20Fstring_search,=20Sstring_search,=202,=203,=200,=0A=20= =20=20if=20(STRING_MULTIBYTE=20(haystack)=20=3D=3D=20STRING_MULTIBYTE=20= (needle))=0A=20=20=20=20=20res=20=3D=20memmem=20(haystart,=20haybytes,=0A= =20=09=09=20=20SSDATA=20(needle),=20SBYTES=20(needle));=0A-=20=20else=20= if=20(STRING_MULTIBYTE=20(haystack)=20&&=20!STRING_MULTIBYTE=20(needle))=0A= +=20=20else=20if=20(STRING_MULTIBYTE=20(haystack))=20=20/*=20unibyte=20= needle=20*/=0A=20=20=20=20=20{=0A=20=20=20=20=20=20=20Lisp_Object=20= multi_needle=20=3D=20string_to_multibyte=20(needle);=0A=20=20=20=20=20=20= =20res=20=3D=20memmem=20(haystart,=20haybytes,=0A=20=09=09=20=20=20=20= SSDATA=20(multi_needle),=20SBYTES=20(multi_needle));=0A=20=20=20=20=20}=0A= -=20=20else=20if=20(!STRING_MULTIBYTE=20(haystack)=20&&=20= STRING_MULTIBYTE=20(needle))=0A+=20=20else=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20/*=20unibyte=20haystack,=20= multibyte=20needle=20*/=0A=20=20=20=20=20{=0A=20=20=20=20=20=20=20= Lisp_Object=20uni_needle=20=3D=20Fstring_as_unibyte=20(needle);=0A=20=20=20= =20=20=20=20res=20=3D=20memmem=20(haystart,=20haybytes,=0Adiff=20--git=20= a/test/src/fns-tests.el=20b/test/src/fns-tests.el=0Aindex=20= 8c2b1300dc..323743d842=20100644=0A---=20a/test/src/fns-tests.el=0A+++=20= b/test/src/fns-tests.el=0A@@=20-907,6=20+907,12=20@@=20string-search=0A=20= =20=20(should=20(equal=20(string-search=20"foo"=20"foobarzot")=200))=0A=20= =20=20(should=20(not=20(string-search=20"fooz"=20"foobarzot")))=0A=20=20=20= (should=20(not=20(string-search=20"zot"=20"foobarzo")))=0A+=20=20(should=20= (equal=20(string-search=20"ab"=20"ab")=200))=0A+=20=20(should=20(equal=20= (string-search=20"ab\0"=20"ab")=20nil))=0A+=20=20(should=20(equal=20= (string-search=20"ab"=20"abababab"=203)=204))=0A+=20=20(should=20(equal=20= (string-search=20"ab"=20"ababac"=203)=20nil))=0A+=20=20(let=20= ((case-fold-search=20t))=0A+=20=20=20=20(should=20(equal=20= (string-search=20"ab"=20"AB")=20nil)))=0A=20=0A=20=20=20(should=20(equal=0A= =20=20=20=20=20=20=20=20=20=20=20=20(string-search=20(make-string=202=20= 130)=0A@@=20-923,4=20+929,26=20@@=20string-search=0A=20=20=20(should=20= (not=20(string-search=20(make-string=201=20255)=20"a\377=C3=B8")))=0A=20=20= =20(should=20(not=20(string-search=20(make-string=201=20255)=20= "a\377a")))=0A=20=0A-=20=20(should=20(equal=20(string-search=20"f=C3=B3o"=20= "zotf=C3=B3o")=203)))=0A+=20=20(should=20(equal=20(string-search=20= "f=C3=B3o"=20"zotf=C3=B3o")=203))=0A+=0A+=20=20(should=20(equal=20= (string-search=20(string-to-multibyte=20"\377")=20"ab\377c")=202))=0A+=20= =20(should=20(equal=20(string-search=20"\303"=20"a=C3=B8b")=20nil))=0A+=20= =20(should=20(equal=20(string-search=20"\270"=20"a=C3=B8b")=20nil))=0A+=20= =20;;=20This=20test=20currently=20fails,=20but=20it=20shouldn't!=0A+=20=20= ;;(should=20(equal=20(string-search=20"=C3=B8"=20"\303\270")=20nil))=0A+=0A= +=20=20(should-error=20(string-search=20"a"=20"abc"=20-1))=0A+=20=20= (should-error=20(string-search=20"a"=20"abc"=204))=0A+=20=20= (should-error=20(string-search=20"a"=20"abc"=20100000000000))=0A+=0A+=20=20= (should=20(equal=20(string-search=20"a"=20"aaa"=203)=20nil))=0A+=20=20= (should=20(equal=20(string-search=20"\0"=20"")=20nil))=0A+=0A+=20=20= (should=20(equal=20(string-search=20""=20"")=200))=0A+=20=20= (should-error=20(string-search=20""=20""=201))=0A+=20=20(should=20(equal=20= (string-search=20""=20"abc")=200))=0A+=20=20(should=20(equal=20= (string-search=20""=20"abc"=202)=202))=0A+=20=20(should=20(equal=20= (string-search=20""=20"abc"=203)=203))=0A+=20=20(should-error=20= (string-search=20""=20"abc"=204))=0A+=20=20(should-error=20= (string-search=20""=20"abc"=20-1))=0A+=20=20)=0A= --Apple-Mail=_EB777C97-CDF8-48EF-A5E7-78C47B853B0E-- From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 11:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16010322924371 (code B ref 43598); Fri, 25 Sep 2020 11:12:02 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 11:11:32 +0000 Received: from localhost ([127.0.0.1]:42843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLldU-00018R-7K for submit@debbugs.gnu.org; Fri, 25 Sep 2020 07:11:32 -0400 Received: from quimby.gnus.org ([95.216.78.240]:38878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLldS-00018E-Dz for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 07:11:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=SzVFm9vI58v86rSOTeFoWHVl6zqiDSjCxexlDkBJtb8=; b=Te0FbZrFC6tRncYDcqIhfoCPgL 668AsleUQJDTIL8OmiwCk7uMNcJm/mquKd/kaP+TsGpBgNr8aFX9NWIuiidVMlX2jmJYV2GPZAFfF q1dvYIHW0Gu/cmVgQN5lMa91VdB8BE5ticUafpwy8A9ae7EWqJVjdVlnFd8fbt6coaPo=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLldG-0001Yc-LI; Fri, 25 Sep 2020 13:11:24 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEXXnlrDt7BaLSqw RzEvJCgNCAx8eIRdVFX////3Dm9OAAAAAWJLR0QIht6VegAAAAd0SU1FB+QJGQklNdCRphsAAAG2 SURBVDjLldRLj5swEADgSSJlr8yqYs+1odzDqr22xGTuxJNcy6oL1w1y4r9f2xCFEPawI4Gl+TR+ YgAWQshEy7RGxEVUMhe5D4C1EPlrIVO8wn4AcO+NHEE1wCpAzohRDzzAUnrY6BtshwoPQlQBwMP+ NoYbP7tV6AGEL+ihDhU8gEu7pbzSBbH+O4ZVEMNMuGgCyB6WQjk4uwSdonEFmEKIzAPrjzGsUxLi R+ozfBzB2vBOCBsyQ2wDmFLv3rJulA8LAVClpuf2DnwJPGnWytCZJyXw5JqSuLwD3q9g6dtK8ySk r/A1U9j3wDOwmQc5wDSqHGI6UNvaQ2GtstYaIttl9gMAT39e6IAnZU2RiM4UJAx1tHIQO4hjpVQx PC5KCWjtpWldP9fo57EFnB3czSqehxy+zcPuy3CBd7+HD/ljDf6Efqcz4Jvv5yloDB9r+7C5HL7i 6t/j4Jnv6qA+gf5g76emgD+JWXBdaHicqSpsojW0ibbnu7zKOpkk7mr+xPeQIlKK/M1SJVnr7+wv EwBPtqkxbOqxacLVTK5wqfFFCMVUI4gJRP4fkgUodb9yDBFBH/8BdU85s9N4aKgAAAAldEVYdGRh dGU6Y3JlYXRlADIwMjAtMDktMjVUMDk6Mzc6NTMrMDA6MDD5GdWXAAAAJXRFWHRkYXRlOm1vZGlm eQAyMDIwLTA5LTI1VDA5OjM3OjUzKzAwOjAwiERtKwAAAABJRU5ErkJggg== X-Now-Playing: Thievery Corporation's _The Mirror Conspiracy_: "The Mirror Conspiracy" Date: Fri, 25 Sep 2020 13:11:15 +0200 In-Reply-To: <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Fri, 25 Sep 2020 12:42:06 +0200") Message-ID: <87lfgyqffw.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > 1. Check the range of the START-POS argument so that we don't crash. > The permitted range is [0..N] where N is (length HAYSTACK), thus we > permit a start right after the last character but no furt [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > 1. Check the range of the START-POS argument so that we don't crash. > The permitted range is [0..N] where N is (length HAYSTACK), thus we > permit a start right after the last character but no further. > We could also return nil in these cases but I think an error is more usef= ul. Good point. :-) > 2. Make the docs more precise about various things. > > 3. Slight simplification of the implementation logic to avoid testing > the same conditions multiple times. > > 4. More tests, especially for edge cases. Can't have too many! It all looks good to me; please apply. > One test still fails: > > (string-search "=C3=B8" "\303\270") > > which should return nil but currently matches. > I think it's wrong to convert the needle to unibyte (using > Fstring_as_unibyte) in this case, but I haven't decided what the best > solution would be. Yeah, that's the bit I was most unsure about, because it just didn't look quite correct to me, but I couldn't come up with the correct test case last night; thanks. > We should also consider the optimisations: > - If SCHARS(needle)>SCHARS(haystack) then no match is possible. Yup. > - If either needle or haystack is all-ASCII (all bytes in 0..127), > then we can use memmem without conversion. Right, so if the multibyteness differs, then do another check to see whether both strings are all-ASCII anyway, and do the comparison without conversion... Yes, makes sense to me. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 11:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16010329735541 (code B ref 43598); Fri, 25 Sep 2020 11:23:02 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 11:22:53 +0000 Received: from localhost ([127.0.0.1]:42871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLloS-0001RJ-RB for submit@debbugs.gnu.org; Fri, 25 Sep 2020 07:22:53 -0400 Received: from mail1456c50.megamailservers.eu ([91.136.14.56]:45568 helo=mail266c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLloQ-0001R0-9r for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 07:22:51 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601032963; bh=QqEPzbUbQtcSghktRdcrqw9ZdPKRCWlaK1vDoLaPvVE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=OUPRxjlm8Geldn9xFPy12TzkyxofGqwF/qZIGubOXhvuSy0QjOyZIRmc1t0JlsejU M2R/YPBOTyKV3Y1vTimLCO2ZtpM0v2YSgZ48J2hWAgkDbTXa+igss1C37ddgNB4PRp IlCR1DI8e77yRd75BVQXm3m2OvUXT2FhTQCq2G+c= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail266c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08PBMfTc021593; Fri, 25 Sep 2020 11:22:43 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: <87lfgyqffw.fsf@gnus.org> Date: Fri, 25 Sep 2020 13:22:41 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F23.5F6DD303.007F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=A5MSwJeG c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=BhJkVLQ1qYMa0PH8kg0A:9 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 25 sep. 2020 kl. 13.11 skrev Lars Ingebrigtsen : > It all looks good to me; please apply. Thanks, will do shortly. Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.3 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 25 sep. 2020 kl. 13.11 skrev Lars Ingebrigtsen : > It all looks good to me; please apply. Thanks, will do shortly. > Right, so if the multibyteness differs, then do another check to see > whether both strings are all-ASCII anyway, and do the comparison = without > conversion... Both strings don't need to be all-ASCII; one of them suffices. By the way, I added an argument check to replace-in-string to prevent it = from entering an infinite loop. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 11:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160103356914708 (code B ref 43598); Fri, 25 Sep 2020 11:33:02 +0000 Received: (at 43598) by debbugs.gnu.org; 25 Sep 2020 11:32:49 +0000 Received: from localhost ([127.0.0.1]:42891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLly5-0003pA-EC for submit@debbugs.gnu.org; Fri, 25 Sep 2020 07:32:49 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLly4-0003la-1H for 43598@debbugs.gnu.org; Fri, 25 Sep 2020 07:32:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CTd5HCpDmuOhYqPzDRWFKFsh4QF1LLVMGOH24mzjH1A=; b=elm8h769wvnhcpDqj7BA+oUW6g QXYNkpQUsCIsh/iDtuLk86T1S6MzGVkk99XWQWJJoFTYIteEXC1Ueh0r3SJNMqajLuCTrIWRDqfRU 6HT8hDJ8BRL/xiUuh6X9oUpSoLUHxYkwqVjWtwPptEJ4MYHX9xp7zDmEedvUIrKy9/ag=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLlxv-0001k5-Sv; Fri, 25 Sep 2020 13:32:42 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEXXnlrDt7BaLSqw RzEvJCgNCAx8eIRdVFX////3Dm9OAAAAAWJLR0QIht6VegAAAAd0SU1FB+QJGQklNdCRphsAAAG2 SURBVDjLldRLj5swEADgSSJlr8yqYs+1odzDqr22xGTuxJNcy6oL1w1y4r9f2xCFEPawI4Gl+TR+ YgAWQshEy7RGxEVUMhe5D4C1EPlrIVO8wn4AcO+NHEE1wCpAzohRDzzAUnrY6BtshwoPQlQBwMP+ NoYbP7tV6AGEL+ihDhU8gEu7pbzSBbH+O4ZVEMNMuGgCyB6WQjk4uwSdonEFmEKIzAPrjzGsUxLi R+ozfBzB2vBOCBsyQ2wDmFLv3rJulA8LAVClpuf2DnwJPGnWytCZJyXw5JqSuLwD3q9g6dtK8ySk r/A1U9j3wDOwmQc5wDSqHGI6UNvaQ2GtstYaIttl9gMAT39e6IAnZU2RiM4UJAx1tHIQO4hjpVQx PC5KCWjtpWldP9fo57EFnB3czSqehxy+zcPuy3CBd7+HD/ljDf6Efqcz4Jvv5yloDB9r+7C5HL7i 6t/j4Jnv6qA+gf5g76emgD+JWXBdaHicqSpsojW0ibbnu7zKOpkk7mr+xPeQIlKK/M1SJVnr7+wv EwBPtqkxbOqxacLVTK5wqfFFCMVUI4gJRP4fkgUodb9yDBFBH/8BdU85s9N4aKgAAAAldEVYdGRh dGU6Y3JlYXRlADIwMjAtMDktMjVUMDk6Mzc6NTMrMDA6MDD5GdWXAAAAJXRFWHRkYXRlOm1vZGlm eQAyMDIwLTA5LTI1VDA5OjM3OjUzKzAwOjAwiERtKwAAAABJRU5ErkJggg== X-Now-Playing: Thievery Corporation's _The Mirror Conspiracy_: "The Mirror Conspiracy" Date: Fri, 25 Sep 2020 13:32:38 +0200 In-Reply-To: <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Fri, 25 Sep 2020 13:22:41 +0200") Message-ID: <875z82qeg9.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: >> Right, so if the multibyteness differs, then do another check to see >> whether both strings are all-ASCII anyway, and do the comparison without >> conversion... > > Both strings don't need to be a [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: >> Right, so if the multibyteness differs, then do another check to see >> whether both strings are all-ASCII anyway, and do the comparison without >> conversion... > > Both strings don't need to be all-ASCII; one of them suffices. Hm, yes, that's true... and I guess a further micro-optimisation would be if NEEDLE is non-ASCII and HAYSTACK is all-ASCII, then there's no point in memmem-ing at all.=20 --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Sep 2020 22:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160115915517713 (code B ref 43598); Sat, 26 Sep 2020 22:26:01 +0000 Received: (at 43598) by debbugs.gnu.org; 26 Sep 2020 22:25:55 +0000 Received: from localhost ([127.0.0.1]:47990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIde-0004bd-NW for submit@debbugs.gnu.org; Sat, 26 Sep 2020 18:25:54 -0400 Received: from quimby.gnus.org ([95.216.78.240]:57242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIdc-0004bR-VP for 43598@debbugs.gnu.org; Sat, 26 Sep 2020 18:25:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uFLa/IEAOhCk3oTyIEDwf7IQ0Snqit0umPw9EEqCZ4g=; b=XFLkzVZQcoDdXMmh69ZXrX2q9j vX8jxc8cxrkJ8V9mnc0xLlWbbTSyQfopHTcdwfafbFv6CObKxE/N0ZF94BWBSGbegxol1pZt+SKkB ujbyy06351mWV4U3GbfNy4Vq1hBv7uyY8wyksBxUztLnoryKrri2f2pNa9whB74duar4=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMIdT-0003p7-6p; Sun, 27 Sep 2020 00:25:46 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> X-Now-Playing: Barbara Morgenstern's _Fan No 2 (2)_: "Mein Zeitbegriff" Date: Sun, 27 Sep 2020 00:25:41 +0200 In-Reply-To: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Thu, 24 Sep 2020 22:52:06 +0200") Message-ID: <87wo0gb2fu.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > 3. The name is somewhat unfortunate since a function by that name in > XEmacs uses regexp matching. [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > 3. The name is somewhat unfortunate since a function by that name in > XEmacs uses regexp matching. [...] > Perhaps we should rename it to string-replace, in line with the modern > naming convention discussed some time ago. Yup; now done. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Sep 2020 22:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160116029319419 (code B ref 43598); Sat, 26 Sep 2020 22:45:01 +0000 Received: (at 43598) by debbugs.gnu.org; 26 Sep 2020 22:44:53 +0000 Received: from localhost ([127.0.0.1]:48008 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIw0-000538-OC for submit@debbugs.gnu.org; Sat, 26 Sep 2020 18:44:52 -0400 Received: from quimby.gnus.org ([95.216.78.240]:57494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIvy-00052t-FC for 43598@debbugs.gnu.org; Sat, 26 Sep 2020 18:44:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Hd9MPi2O//dMHRFEOrz/0fQI/e2o9AB7cA5K2NvnONc=; b=KgRQ2+9EhAKh1CYezZKgKX4Ezl JCOKj88SDMhRny4lJ4Xzy0L5Bvcl+emL0j8J5xeYqJfP1n27xed3nGXLFXHA+uiTA+CJYAsMw+ENE ZlQQph1sbN6sibM3KFhobOG/hnIUJrNp83hQkY8MHEDTf7z3tVxWqhqVdDc19YAi5oMA=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMIvo-00040p-8l; Sun, 27 Sep 2020 00:44:44 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> X-Now-Playing: Thee Oh Sees's _Carrion Crawler-The Dream_: "Contraption-Soul Desert" Date: Sun, 27 Sep 2020 00:44:38 +0200 In-Reply-To: <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Fri, 25 Sep 2020 12:42:06 +0200") Message-ID: <87pn68b1k9.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > We should also consider the optimisations: > - If SCHARS(needle)>SCHARS(haystack) then no match is possible. I've now done this. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > We should also consider the optimisations: > - If SCHARS(needle)>SCHARS(haystack) then no match is possible. I've now done this. > - If either needle or haystack is all-ASCII (all bytes in 0..127), > then we can use memmem without conversion. I thought that surely there's be a function like that in Emacs, but I can't find it? Instead there's code like && (STRING_MULTIBYTE (string) ? (chars =3D=3D bytes) : string_ascii_p (string)) [...] /* Whether STRING only contains chars in the 0..127 range. */ static bool string_ascii_p (Lisp_Object string) { ptrdiff_t nbytes =3D SBYTES (string); for (ptrdiff_t i =3D 0; i < nbytes; i++) if (SREF (string, i) > 127) return false; return true; } and unsigned char *p =3D SDATA (name); while (*p && ASCII_CHAR_P (*p)) p++; sprinkled around the code base. Would it make sense to add a new utility function that does the right thing for both multibyte and unibyte strings? (The multibyte case is just chars =3D=3D bytes, but the unibyte case would be a loop.) --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 00:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16011650482200 (code B ref 43598); Sun, 27 Sep 2020 00:05:02 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 00:04:08 +0000 Received: from localhost ([127.0.0.1]:48059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMKAi-0000ZQ-2G for submit@debbugs.gnu.org; Sat, 26 Sep 2020 20:04:08 -0400 Received: from quimby.gnus.org ([95.216.78.240]:58164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMKAg-0000Yw-Iu for 43598@debbugs.gnu.org; Sat, 26 Sep 2020 20:04:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=i2aBwMtBpxtQpZ3Jg3MMoiSoR1OB58a6sEvGQ82KG0k=; b=DwrqsNtYiFaPPF+f80MNIpy8Hf e8skdb8sqZlDr3AWvI/xHpuqBc1Tq45FTg9CSqKq4biAyC0kWiZxZDSCAEdQZcmcxzjSMPuX+qUb7 owq0DiD2W3cJsKyJKAboQdVMnTJOLaPmRSTPcG63X43abPh75oyXEJQVfozB8kiO+yPI=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMKAW-0004rP-8B; Sun, 27 Sep 2020 02:04:00 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> X-Now-Playing: Bel Kanto's _White-out conditions_: "Agassiz" Date: Sun, 27 Sep 2020 02:03:53 +0200 In-Reply-To: <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Fri, 25 Sep 2020 13:22:41 +0200") Message-ID: <878scwaxw6.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > Both strings don't need to be all-ASCII; one of them suffices. I've now added that, and after that, everything fell into place for the multibyte-needle/unibyte-haystack case, too. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > Both strings don't need to be all-ASCII; one of them suffices. I've now added that, and after that, everything fell into place for the multibyte-needle/unibyte-haystack case, too. That can only match if the needle contains nothing but ASCII and eighth-bit chars, so I've altered it to return Qnil if there's any other chars, and then convert to unibyte and do memmem otherwise. *phew* Is that all cases covered now? --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 00:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16011668904948 (code B ref 43598); Sun, 27 Sep 2020 00:35:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 00:34:50 +0000 Received: from localhost ([127.0.0.1]:48070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMKeP-0001Hk-OJ for submit@debbugs.gnu.org; Sat, 26 Sep 2020 20:34:50 -0400 Received: from quimby.gnus.org ([95.216.78.240]:58444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMKeL-0001HV-Av for 43598@debbugs.gnu.org; Sat, 26 Sep 2020 20:34:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=T6dQ7Ez5hDh5sS9B0MXhx7ylwIWhtzkL5cObMO4Xw4I=; b=XNpskHoqgN/TfALVQUMfGTviiT 2DXCveOwynZ/TIGtfM3ReidGPUciYAdu0xhba3gdLWFGpNED+WSsjuZApsrZ3Qzs7DQninVG79Rgx m3l6tVhHTjPjyhOMrNdd1s/JOl6n2h9rOEzbcZMiveYyoXz1FPcJrU+wsBm/bS4F6/cY=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMKe5-000582-4T; Sun, 27 Sep 2020 02:34:39 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> X-Now-Playing: Oneohtrix Point Never's _Returnal_: "Stress Waves" Date: Sun, 27 Sep 2020 02:34:27 +0200 In-Reply-To: <878scwaxw6.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 27 Sep 2020 02:03:53 +0200") Message-ID: <87pn68vyzw.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > Is that all cases covered now? Well, I can't think of any more, but I said that before. :-/ Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Is that all cases covered now? Well, I can't think of any more, but I said that before. :-/ Anyway, we now have this slightly amusing situation: (string-search (string-to-multibyte "o\303\270") "o\303\270") => 0 (string-match (string-to-multibyte "o\303\270") "o\303\270") => 0 (equal (string-to-multibyte "o\303\270") "o\303\270") => nil But I guess we've lived with this for... decades? So that's probably OK. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 08:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160119632618124 (code B ref 43598); Sun, 27 Sep 2020 08:46:02 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 08:45:26 +0000 Received: from localhost ([127.0.0.1]:48271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMSJC-0004iG-Ia for submit@debbugs.gnu.org; Sun, 27 Sep 2020 04:45:26 -0400 Received: from mail1471c50.megamailservers.eu ([91.136.14.71]:60794 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMSJA-0004i0-GS for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 04:45:25 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601196318; bh=HBPbrYy84PkAwR6BlfS21X4B/rg7Imx/npru6+Inve8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=oqBOxEgM0eWheoJ7rzYNzx9v/yxy9D7a+A1BQTP0DKBLk74+NTdELkgX9WxRTLjfc gAIerH9XQs9jYuaMVMRGreFsN65eBHl+/rbC/d+Pqm1AEGaqr7Ojmo9BOeIVBFHJ06 coQEa+zjooI8lZtY5NrXFm+1zQBFvr38pqNPlcCc= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08R8jFbH019272; Sun, 27 Sep 2020 08:45:17 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: <87pn68vyzw.fsf@gnus.org> Date: Sun, 27 Sep 2020 10:45:15 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9DBF8B6C-2259-4C6E-AE3F-E0886255A540@acm.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <87pn68vyzw.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F15.5F70511E.0003, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=S52nP7kP c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=s5dJLfk0kW9WkiLDlYcA:9 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 27 sep. 2020 kl. 02.34 skrev Lars Ingebrigtsen : > (string-search (string-to-multibyte "o\303\270") "o\303\270") > =3D> 0 >=20 > (string-match (string-to-multibyte "o\303\270") "o\303\270") > =3D> 0 >=20 > (equal (string-to-multibyte "o\303\270") "o\303\270") > =3D> nil (compare-strings (string-to-multibyte "o\303\270") nil nil "o\303\270" = nil nil) =3D> t I'd say it's equal, string-equal, string-lessp and string-greaterp that = are odd and that we probably should fix if it can be done without making = them slower. Unless, of course, we can come up with an alternative = theory of operation that is satisfactory. > But I guess we've lived with this for... decades? So that's probably > OK. Yes, there is no hurry. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 11:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.1601205132656 (code B ref 43598); Sun, 27 Sep 2020 11:13:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 11:12:12 +0000 Received: from localhost ([127.0.0.1]:48487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMUbD-0000AV-Mt for submit@debbugs.gnu.org; Sun, 27 Sep 2020 07:12:11 -0400 Received: from mail209c50.megamailservers.eu ([91.136.10.219]:48318 helo=mail194c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMUbA-0000AM-RI for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 07:12:11 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601205126; bh=sOSnoJN1foc9fJ9vDpAqAdXPM5YCPE7UDiAe7pVqIEg=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=J5OSXrSg+Iyqj5so6cVqug6IJ58voJV8uv70BaiQSyc1TXp0isq7g7pS8OgQUw/uC kRvU+uJXKAJTOWkLWjrgfhmxoPyZ8SgBa6ThyoWzTuWuj1AClZgn0PCUJM/1FvnSJk IExDFjeMEIN3XjpeyQ7Om4+NagiOy35JzN0rSYno= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08RBC452032688; Sun, 27 Sep 2020 11:12:06 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Message-Id: <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> Content-Type: multipart/mixed; boundary="Apple-Mail=_35CDC5F5-ADF1-498A-9828-F919DD32CC45" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Date: Sun, 27 Sep 2020 13:12:04 +0200 In-Reply-To: <878scwaxw6.fsf@gnus.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F1E.5F707386.0090, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsozJleN c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=jxLGUkyOYAuTROCEy-IA:9 a=CjuIK1q_8ugA:10 a=kpjkWu5vo3jdgu-oXFwA:9 a=De_Ol2h6w80A:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_35CDC5F5-ADF1-498A-9828-F919DD32CC45 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 27 sep. 2020 kl. 02.03 skrev Lars Ingebrigtsen : > *phew* Not bad! This seems to work all right. Here are some minor optimisations: - Do the fast all-ASCII test (bytes =3D=3D chars) before iterating = through the bytes to check for non-ASCII chars. - Faster check for non-ASCII non-raw bytes (no need for the complex code = in string_char_advance). It is tempting to vectorise the all-ASCII loop. Maybe another day... The patch also adds some more test cases for completeness. --Apple-Mail=_35CDC5F5-ADF1-498A-9828-F919DD32CC45 Content-Disposition: attachment; filename=string-search-tweaks.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="string-search-tweaks.diff" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/src/fns.c=20b/src/fns.c=0Aindex=20= 0f76871154..f626fe11b2=20100644=0A---=20a/src/fns.c=0A+++=20b/src/fns.c=0A= @@=20-5457,16=20+5457,11=20@@=20DEFUN=20("buffer-hash",=20Fbuffer_hash,=20= Sbuffer_hash,=200,=201,=200,=0A=20static=20bool=0A=20string_ascii_p=20= (Lisp_Object=20string)=0A=20{=0A-=20=20if=20(STRING_MULTIBYTE=20= (string))=0A-=20=20=20=20return=20SBYTES=20(string)=20=3D=3D=20SCHARS=20= (string);=0A-=20=20else=0A-=20=20=20=20{=0A-=20=20=20=20=20=20ptrdiff_t=20= nbytes=20=3D=20SBYTES=20(string);=0A-=20=20=20=20=20=20for=20(ptrdiff_t=20= i=20=3D=200;=20i=20<=20nbytes;=20i++)=0A-=09if=20(SREF=20(string,=20i)=20= >=20127)=0A-=09=20=20return=20false;=0A-=20=20=20=20=20=20return=20true;=0A= -=20=20=20=20}=0A+=20=20ptrdiff_t=20nbytes=20=3D=20SBYTES=20(string);=0A= +=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20nbytes;=20i++)=0A+=20=20= =20=20if=20(SREF=20(string,=20i)=20>=20127)=0A+=20=20=20=20=20=20return=20= false;=0A+=20=20return=20true;=0A=20}=0A=20=0A=20DEFUN=20= ("string-search",=20Fstring_search,=20Sstring_search,=202,=203,=200,=0A= @@=20-5505,9=20+5500,14=20@@=20DEFUN=20("string-search",=20= Fstring_search,=20Sstring_search,=202,=203,=200,=0A=20=20=20haystart=20=3D= =20SSDATA=20(haystack)=20+=20start_byte;=0A=20=20=20haybytes=20=3D=20= SBYTES=20(haystack)=20-=20start_byte;=0A=20=0A-=20=20if=20= (STRING_MULTIBYTE=20(haystack)=20=3D=3D=20STRING_MULTIBYTE=20(needle)=0A= -=20=20=20=20=20=20||=20string_ascii_p=20(needle)=0A-=20=20=20=20=20=20= ||=20string_ascii_p=20(haystack))=0A+=20=20/*=20We=20can=20do=20a=20= direct=20byte-string=20search=20if=20both=20strings=20have=20the=0A+=20=20= =20=20=20same=20multibyteness,=20or=20if=20at=20least=20one=20of=20them=20= consists=20of=20ASCII=0A+=20=20=20=20=20characters=20only.=20=20*/=0A+=20= =20if=20(STRING_MULTIBYTE=20(haystack)=0A+=20=20=20=20=20=20?=20= (STRING_MULTIBYTE=20(needle)=0A+=20=20=20=20=20=20=20=20=20||=20SCHARS=20= (haystack)=20=3D=3D=20SBYTES=20(haystack)=20||=20string_ascii_p=20= (needle))=0A+=20=20=20=20=20=20:=20(!STRING_MULTIBYTE=20(needle)=0A+=20=20= =20=20=20=20=20=20=20||=20SCHARS=20(needle)=20=3D=3D=20SBYTES=20(needle)=20= ||=20string_ascii_p=20(haystack)))=0A=20=20=20=20=20res=20=3D=20memmem=20= (haystart,=20haybytes,=0A=20=09=09=20=20SSDATA=20(needle),=20SBYTES=20= (needle));=0A=20=20=20else=20if=20(STRING_MULTIBYTE=20(haystack))=20=20= /*=20unibyte=20needle=20*/=0A@@=20-5521,26=20+5521,21=20@@=20DEFUN=20= ("string-search",=20Fstring_search,=20Sstring_search,=202,=203,=200,=0A=20= =20=20=20=20=20=20/*=20The=20only=20possible=20way=20we=20can=20find=20= the=20multibyte=20needle=20in=20the=0A=20=09=20unibyte=20stack=20(since=20= we=20know=20that=20neither=20are=20pure-ASCII)=20is=0A=20=09=20if=20they=20= contain=20"raw=20bytes"=20(and=20no=20other=20non-ASCII=20chars.)=20=20= */=0A-=20=20=20=20=20=20ptrdiff_t=20chars=20=3D=20SCHARS=20(needle);=0A-=20= =20=20=20=20=20const=20unsigned=20char=20*src=20=3D=20SDATA=20(needle);=0A= -=0A-=20=20=20=20=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20chars;=20= i++)=0A-=09{=0A-=09=20=20int=20c=20=3D=20string_char_advance=20(&src);=0A= -=0A-=09=20=20if=20(!CHAR_BYTE8_P=20(c)=0A-=09=20=20=20=20=20=20&&=20= !ASCII_CHAR_P=20(c))=0A-=09=20=20=20=20/*=20Found=20a=20char=20that=20= can't=20be=20in=20the=20haystack.=20=20*/=0A-=09=20=20=20=20return=20= Qnil;=0A-=09}=0A+=20=20=20=20=20=20ptrdiff_t=20nbytes=20=3D=20SBYTES=20= (needle);=0A+=20=20=20=20=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20= nbytes;=20i++)=0A+=20=20=20=20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20= =20int=20c=20=3D=20SREF=20(needle,=20i);=0A+=20=20=20=20=20=20=20=20=20=20= if=20(CHAR_BYTE8_HEAD_P=20(c))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= i++;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20/*=20Skip=20raw=20= byte.=20=20*/=0A+=20=20=20=20=20=20=20=20=20=20else=20if=20= (!ASCII_CHAR_P=20(c))=0A+=20=20=20=20=20=20=20=20=20=20=20=20return=20= Qnil;=20=20/*=20Found=20a=20char=20that=20can't=20be=20in=20the=20= haystack.=20=20*/=0A+=20=20=20=20=20=20=20=20}=0A=20=0A-=20=20=20=20=20=20= {=0A-=09/*=20"Raw=20bytes"=20(aka=20eighth-bit)=20are=20represented=20= differently=20in=0A-=09=20=20=20multibyte=20and=20unibyte=20strings.=20=20= */=0A-=09Lisp_Object=20uni_needle=20=3D=20Fstring_to_unibyte=20(needle);=0A= -=09res=20=3D=20memmem=20(haystart,=20haybytes,=0A-=09=09=20=20=20=20=20=20= SSDATA=20(uni_needle),=20SBYTES=20(uni_needle));=0A-=20=20=20=20=20=20}=0A= +=20=20=20=20=20=20/*=20"Raw=20bytes"=20(aka=20eighth-bit)=20are=20= represented=20differently=20in=0A+=20=20=20=20=20=20=20=20=20multibyte=20= and=20unibyte=20strings.=20=20*/=0A+=20=20=20=20=20=20Lisp_Object=20= uni_needle=20=3D=20Fstring_to_unibyte=20(needle);=0A+=20=20=20=20=20=20= res=20=3D=20memmem=20(haystart,=20haybytes,=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20SSDATA=20(uni_needle),=20SBYTES=20= (uni_needle));=0A=20=20=20=20=20}=0A=20=0A=20=20=20if=20(!=20res)=0Adiff=20= --git=20a/test/src/fns-tests.el=20b/test/src/fns-tests.el=0Aindex=20= 41969f2af2..d3c22f966e=20100644=0A---=20a/test/src/fns-tests.el=0A+++=20= b/test/src/fns-tests.el=0A@@=20-913,6=20+913,7=20@@=20string-search=0A=20= =20=20(should=20(equal=20(string-search=20"ab\0"=20"ab")=20nil))=0A=20=20= =20(should=20(equal=20(string-search=20"ab"=20"abababab"=203)=204))=0A=20= =20=20(should=20(equal=20(string-search=20"ab"=20"ababac"=203)=20nil))=0A= +=20=20(should=20(equal=20(string-search=20"aaa"=20"aa")=20nil))=0A=20=20= =20(let=20((case-fold-search=20t))=0A=20=20=20=20=20(should=20(equal=20= (string-search=20"ab"=20"AB")=20nil)))=0A=20=0A@@=20-936,14=20+937,16=20= @@=20string-search=0A=20=20=20(should=20(equal=20(string-search=20= (string-to-multibyte=20"\377")=20"ab\377c")=202))=0A=20=20=20(should=20= (equal=20(string-search=20"\303"=20"a=C3=B8b")=20nil))=0A=20=20=20= (should=20(equal=20(string-search=20"\270"=20"a=C3=B8b")=20nil))=0A-=20=20= ;;=20This=20test=20currently=20fails,=20but=20it=20shouldn't!=0A-=20=20= ;;(should=20(equal=20(string-search=20"=C3=B8"=20"\303\270")=20nil))=0A+=20= =20(should=20(equal=20(string-search=20"=C3=B8"=20"\303\270")=20nil))=0A= +=0A+=20=20(should=20(equal=20(string-search=20"a\U00010f98z"=20= "a\U00010f98a\U00010f98z")=202))=0A=20=0A=20=20=20(should-error=20= (string-search=20"a"=20"abc"=20-1))=0A=20=20=20(should-error=20= (string-search=20"a"=20"abc"=204))=0A=20=20=20(should-error=20= (string-search=20"a"=20"abc"=20100000000000))=0A=20=0A=20=20=20(should=20= (equal=20(string-search=20"a"=20"aaa"=203)=20nil))=0A+=20=20(should=20= (equal=20(string-search=20"aa"=20"aa"=201)=20nil))=0A=20=20=20(should=20= (equal=20(string-search=20"\0"=20"")=20nil))=0A=20=0A=20=20=20(should=20= (equal=20(string-search=20""=20"")=200))=0A@@=20-955,6=20+958,21=20@@=20= string-search=0A=20=20=20(should-error=20(string-search=20""=20"abc"=20= -1))=0A=20=0A=20=20=20(should-not=20(string-search=20"=C3=B8"=20= "foo\303\270"))=0A+=20=20(should-not=20(string-search=20"\303\270"=20= "=C3=B8"))=0A+=20=20(should-not=20(string-search=20"\370"=20"=C3=B8"))=0A= +=20=20(should-not=20(string-search=20(string-to-multibyte=20"\370")=20= "=C3=B8"))=0A+=20=20(should-not=20(string-search=20"=C3=B8"=20"\370"))=0A= +=20=20(should-not=20(string-search=20"=C3=B8"=20(string-to-multibyte=20= "\370")))=0A+=20=20(should-not=20(string-search=20"\303\270"=20"\370"))=0A= +=20=20(should-not=20(string-search=20(string-to-multibyte=20"\303\270")=20= "\370"))=0A+=20=20(should-not=20(string-search=20"\303\270"=20= (string-to-multibyte=20"\370")))=0A+=20=20(should-not=20(string-search=20= (string-to-multibyte=20"\303\270")=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(string-to-multibyte=20= "\370")))=0A+=20=20(should-not=20(string-search=20"\370"=20"\303\270"))=0A= +=20=20(should-not=20(string-search=20(string-to-multibyte=20"\370")=20= "\303\270"))=0A+=20=20(should-not=20(string-search=20"\370"=20= (string-to-multibyte=20"\303\270")))=0A+=20=20(should-not=20= (string-search=20(string-to-multibyte=20"\370")=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (string-to-multibyte=20"\303\270")))=0A=20=20=20(should=20(equal=20= (string-search=20(string-to-multibyte=20"o\303\270")=20"foo\303\270")=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=202))=0A=20=20=20= (should=20(equal=20(string-search=20"\303\270"=20"foo\303\270")=203)))=0A= --Apple-Mail=_35CDC5F5-ADF1-498A-9828-F919DD32CC45-- From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 11:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160120730412128 (code B ref 43598); Sun, 27 Sep 2020 11:49:02 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 11:48:24 +0000 Received: from localhost ([127.0.0.1]:48527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVAG-00039Y-JR for submit@debbugs.gnu.org; Sun, 27 Sep 2020 07:48:24 -0400 Received: from quimby.gnus.org ([95.216.78.240]:36266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVAF-00039L-1n for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 07:48:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7q4zjn+Q3nDwYGLNpEFHxOXz9/zO3/XuCqra0wL69v0=; b=Wm6G9kxIlneAzFD6fz+CGM+JjP 3U7rkrclqGYaWwEiSvAof+bElvPrzbrt5R98fsFs4PKJwXS2GQ2IfOELcn/k3F4W6ijN+cc+ozjJA pZ/se0xNNhyb1QOiYhmKyE1jRE29/XiIS4x3MFv3FDjWTFqnwJlgIu5q2HbLducS4E84=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMVA5-0003ad-Qb; Sun, 27 Sep 2020 13:48:16 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEW8xch5hIdBPkP/ //9qUcmpAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+QJGwsjOr/5AOkAAAGZSURBVCjPTZGxbpxAEIYH K4dsqiQykXyVC1c8xRLlkNw5EoPMdJEOC/YpOCmVq3N0XEF1iliL/Z8ys/gSZ4vVfszwz/wzlDJc Z2ExEVFaie8Aa/cBBL7WiKMAdvQsf0FG/2ghJSNEgLZGvLEBAPhBVqndEmXw1h1HZvQB5ngYxIcs suKObrDgWeFoX+EqOB+KTn2TsWpgo+B6VnFgmxqi5/4CAoyOH4jiXeK7H4DhUouaZJ6+Z3jhR6LX XXHYplI5qYm0lb2ayt12VBCrfSTk756I4KxqXpK/+UW0bjITfCHZqRpf6zOufPhy8y3cq2qKqKS0 jDRt1WjT15rGCjEUPmikNmRi/Fym00q5onhzuI2CGjdlFN+f2o8BxO2Lkfdyv0Chv3AuwULXtZcF DnSlAmsMpwaoTEVhbpI7eDYXWi5zV4kbxFCkTmzRr4+1dqFlqH3qk2c2iw36MicYOX+DbNK1HeJ+ AfyGTx8+lW+gc2bO2bwD/4vMm/9gqrw9w4DTZ1g+g7x8ha5vqYNiKMK2aLFwbiWcBO/vP9bos2ts 4KKOAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA5LTI3VDExOjM1OjU3KzAwOjAwSQ82wQAAACV0 RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOS0yN1QxMTozNTo1NyswMDowMDhSjn0AAAAASUVORK5CYII= X-Now-Playing: LCD Soundsystem's _London Sessions_: "Drunk Girls" Date: Sun, 27 Sep 2020 13:48:12 +0200 In-Reply-To: <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Sun, 27 Sep 2020 13:12:04 +0200") Message-ID: <87zh5b5tkz.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > Here are some minor optimisations: > > - Do the fast all-ASCII test (bytes == chars) before iterating through > the bytes to check for non-ASCII chars. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > Here are some minor optimisations: > > - Do the fast all-ASCII test (bytes =3D=3D chars) before iterating through > the bytes to check for non-ASCII chars. [...] > - if (STRING_MULTIBYTE (string)) > - return SBYTES (string) =3D=3D SCHARS (string); [...] > - if (STRING_MULTIBYTE (haystack) =3D=3D STRING_MULTIBYTE (needle) > - || string_ascii_p (needle) > - || string_ascii_p (haystack)) > + /* We can do a direct byte-string search if both strings have the > + same multibyteness, or if at least one of them consists of ASCII > + characters only. */ > + if (STRING_MULTIBYTE (haystack) > + ? (STRING_MULTIBYTE (needle) > + || SCHARS (haystack) =3D=3D SBYTES (haystack) || string_ascii_p= (needle)) > + : (!STRING_MULTIBYTE (needle) > + || SCHARS (needle) =3D=3D SBYTES (needle) || string_ascii_p (ha= ystack))) Didn't you just move the STRING_MULTIBYTE bits of the test from the string_ascii_p function and open-code it into Fstring_search function here? I'm not sure how that's an optimisation?=20 > + ptrdiff_t nbytes =3D SBYTES (needle); > + for (ptrdiff_t i =3D 0; i < nbytes; i++) > + { > + int c =3D SREF (needle, i); > + if (CHAR_BYTE8_HEAD_P (c)) > + i++; /* Skip raw byte. */ > + else if (!ASCII_CHAR_P (c)) > + return Qnil; /* Found a char that can't be in the haystack.= */ > + } Looks good. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 11:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160120786912915 (code B ref 43598); Sun, 27 Sep 2020 11:58:02 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 11:57:49 +0000 Received: from localhost ([127.0.0.1]:48533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVJN-0003ME-Hh for submit@debbugs.gnu.org; Sun, 27 Sep 2020 07:57:49 -0400 Received: from mail1448c50.megamailservers.eu ([91.136.14.48]:49944 helo=mail265c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVJK-0003Lu-Mn for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 07:57:48 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601207858; bh=F4peK/VWVd8ucZFuF2kQzcX/nPPMeH3LLZco4eDVYmA=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=hUOUH7sf9WllH4my2am0qZOGILEu4m79DS/ufJqOGXvqVgnnH0LaUgGdt3qzz2h21 2XB3vnikvMjY1jOq+p0/1HN7XbBvImgWgRx4icFu25Pwh1gKOUnbhgjy7iql1qED3O q9SzZ2V0B+TYZfTV83+dhuNvvUpTcVaJm+mA1mvo= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail265c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08RBvaJk016418; Sun, 27 Sep 2020 11:57:37 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: <87zh5b5tkz.fsf@gnus.org> Date: Sun, 27 Sep 2020 13:57:35 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F16.5F707E32.0044, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=D5w51cZj c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=hMKo0ocIJzxlVEhjlJ0A:9 a=-jn58D8MVyG5DauE:21 a=xkCxnnm3gUyJ7P2M:21 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 27 sep. 2020 kl. 13.48 skrev Lars Ingebrigtsen : > Didn't you just move the STRING_MULTIBYTE bits of the test from the > string_ascii_p function and open-code it into Fstring_search function > here? Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 27 sep. 2020 kl. 13.48 skrev Lars Ingebrigtsen : > Didn't you just move the STRING_MULTIBYTE bits of the test from the > string_ascii_p function and open-code it into Fstring_search function > here? No, look again. Previously, we would loop through all bytes of a unibyte = needle before checking the lengths of a multibyte haystack. With the = patch, we always do the cheap (length) check first. That's why that = check had to be moved out of the helper function. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 12:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160120818313520 (code B ref 43598); Sun, 27 Sep 2020 12:04:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 12:03:03 +0000 Received: from localhost ([127.0.0.1]:48552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVOQ-0003W0-TI for submit@debbugs.gnu.org; Sun, 27 Sep 2020 08:03:03 -0400 Received: from quimby.gnus.org ([95.216.78.240]:36428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMVOO-0003VX-FM for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 08:03:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=D9Ml/C6T5k3AxDfjdV5wHIlBMs/kDb+/phX7OBm8rQo=; b=TLj4kECkC38jn3ee3XEURy62rG 9fhI/WN8GZYetXsk+w1nKq7yYfIFWp056SB7gfhftgiPHeQNr4iWHp568+CpHkrK32DfXNSKDFl7m F+FGsNbgcPTCkTmtEjm1H8+pw2Do4RoyeGvnpbL+o81b2/FVMIB3BKH1cRaQ6kyc/oRU=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMVOF-0003jA-Fy; Sun, 27 Sep 2020 14:02:54 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEW8xch5hIdBPkP/ //9qUcmpAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+QJGwsjOr/5AOkAAAGZSURBVCjPTZGxbpxAEIYH K4dsqiQykXyVC1c8xRLlkNw5EoPMdJEOC/YpOCmVq3N0XEF1iliL/Z8ys/gSZ4vVfszwz/wzlDJc Z2ExEVFaie8Aa/cBBL7WiKMAdvQsf0FG/2ghJSNEgLZGvLEBAPhBVqndEmXw1h1HZvQB5ngYxIcs suKObrDgWeFoX+EqOB+KTn2TsWpgo+B6VnFgmxqi5/4CAoyOH4jiXeK7H4DhUouaZJ6+Z3jhR6LX XXHYplI5qYm0lb2ayt12VBCrfSTk756I4KxqXpK/+UW0bjITfCHZqRpf6zOufPhy8y3cq2qKqKS0 jDRt1WjT15rGCjEUPmikNmRi/Fym00q5onhzuI2CGjdlFN+f2o8BxO2Lkfdyv0Chv3AuwULXtZcF DnSlAmsMpwaoTEVhbpI7eDYXWi5zV4kbxFCkTmzRr4+1dqFlqH3qk2c2iw36MicYOX+DbNK1HeJ+ AfyGTx8+lW+gc2bO2bwD/4vMm/9gqrw9w4DTZ1g+g7x8ha5vqYNiKMK2aLFwbiWcBO/vP9bos2ts 4KKOAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA5LTI3VDExOjM1OjU3KzAwOjAwSQ82wQAAACV0 RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOS0yN1QxMTozNTo1NyswMDowMDhSjn0AAAAASUVORK5CYII= X-Now-Playing: LCD Soundsystem's _London Sessions_: "All My Friends" Date: Sun, 27 Sep 2020 14:02:50 +0200 In-Reply-To: <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Sun, 27 Sep 2020 13:57:35 +0200") Message-ID: <87imbz5swl.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= writes: > No, look again. Previously, we would loop through all bytes of a > unibyte needle before checking the lengths of a multibyte > haystack. Duh; you're right. Please go ahead and apply. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > No, look again. Previously, we would loop through all bytes of a > unibyte needle before checking the lengths of a multibyte > haystack. Duh; you're right. Please go ahead and apply. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Subject: bug#43598: closed (Re: bug#43598: replace-in-string: finishing touches) Message-ID: References: <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> X-Gnu-PR-Message: they-closed 43598 X-Gnu-PR-Package: emacs Reply-To: 43598@debbugs.gnu.org Date: Sun, 27 Sep 2020 16:15:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1601223302-22811-1" This is a multi-part message in MIME format... ------------=_1601223302-22811-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #43598: replace-in-string: finishing touches which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 43598@debbugs.gnu.org. --=20 43598: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D43598 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1601223302-22811-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 43598-done) by debbugs.gnu.org; 27 Sep 2020 16:14:44 +0000 Received: from localhost ([127.0.0.1]:50279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZK0-0005vJ-4w for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:14:44 -0400 Received: from mail154c50.megamailservers.eu ([91.136.10.164]:51916 helo=mail50c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZJw-0005v9-Qo for 43598-done@debbugs.gnu.org; Sun, 27 Sep 2020 12:14:42 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601223279; bh=eQ9rtlnQ8M2JD8ADjqs6qiNYp/qUc5GYJ0SDkwLSqwQ=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Herb/JV476xOjZuKCVv7AqosmKTBap4rzsAmui/LtX4NBVUroQuTW9NI0akeM7olK 99empfDDEwoQf4WUU8yBNC7ovfu4aIwHFsAXNfwf8EIQmETOalY1Oulp9vOKPCU3Ql bUzadWt8gvN8123nlqeblulz4eg6Rb+k7xjVqkvs= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail50c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08RGEavs018688; Sun, 27 Sep 2020 16:14:38 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: bug#43598: replace-in-string: finishing touches From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <87imbz5swl.fsf@gnus.org> Date: Sun, 27 Sep 2020 18:14:36 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> <87imbz5swl.fsf@gnus.org> To: Lars Ingebrigtsen X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F15.5F70BA6F.0002, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=NoevjPVJ c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=6P22_dU0F-H7CJD_y6UA:9 a=CjuIK1q_8ugA:10 a=3fbLLLLNgwQA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 27 sep. 2020 kl. 14.02 skrev Lars Ingebrigtsen : > Please go ahead and apply. Applied, thank you. Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 43598-done Cc: 43598-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 27 sep. 2020 kl. 14.02 skrev Lars Ingebrigtsen : > Please go ahead and apply. Applied, thank you. Looks like we are done now. string-replace seems to be substantially = faster than replace-regexp-in-string. Good job! ------------=_1601223302-22811-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 24 Sep 2020 20:52:21 +0000 Received: from localhost ([127.0.0.1]:41923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYE0-0005OS-OD for submit@debbugs.gnu.org; Thu, 24 Sep 2020 16:52:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:48136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLYDx-0005OJ-Do for submit@debbugs.gnu.org; Thu, 24 Sep 2020 16:52:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLYDx-0000Oh-4b for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:52:17 -0400 Received: from mail78c50.megamailservers.eu ([91.136.10.88]:59052 helo=mail70c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLYDu-00008U-Ie for bug-gnu-emacs@gnu.org; Thu, 24 Sep 2020 16:52:16 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1600980729; bh=REyLP06U+y2uakEpIGEywOnO+Dn6PSP+/csd/f1MmHM=; h=From:Subject:Date:Cc:To:From; b=bRYOmn6Ci49tnvBZ+MmW1JfHGAjPb1mtOa7UmZ5igzTRGMvJcrZdH1f/dE159Eye8 zmGgLYupW8vt6g99JoxYuo3ue+kmvqUT4EiWpUdrOXxMN01bgTKVI91un+5dFy3zo5 1Tllw4eHaH6zaongTIxs4sxZ7D4/Qm8Zj45P5xjc= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail70c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08OKq7lP014751; Thu, 24 Sep 2020 20:52:09 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Subject: replace-in-string: finishing touches Message-Id: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> Date: Thu, 24 Sep 2020 22:52:06 +0200 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F1E.5F6D06F9.001B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OKBZIhSB c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=IkcTkHD0fZMA:10 a=M51BFTxLslgA:10 a=Lz5n3o7qXXkDrfnKqmYA:9 a=QEXdDO2ut3YA:10 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.10.88; envelope-from=mattiase@acm.org; helo=mail70c50.megamailservers.eu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 16:52:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Lars Ingebrigtsen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) The new replace-in-string function is welcome but needs a few tweaks = before we can call it done: 1. It doesn't quite work correctly with raw bytes: (replace-in-string "\377" "x" "a\377b") =3D> "axb" (replace-in-string "\377" "x" "a\377=C3=B8") =3D> "a\377=C3=B8" The easiest solution is to reimplement it in terms of = replace-regexp-in-string for now, and optimise it later (although I feel = a bit bad undoing Lars's pretty handiwork...) We have messy semantics here, because string-equal does not equate = "\377" and (string-to-multibyte "\377"), but string-match-p does... 2. It is documented always to return a new string, but that's a tad = over-generous nowadays; very few string functions do that. If we drop = that guarantee, we get some optimisation opportunities: - it can return the input string itself if no matches were found (a = fairly common case) - it can be marked pure, not just side-effect-free, so that the byte = compiler can constant-propagate through calls to it 3. The name is somewhat unfortunate since a function by that name in = XEmacs uses regexp matching. In fact, the new function probably broke prolog-mode because of that = (see prolog-replace-in-string). While we can fix prolog-mode, we can't easily fix code outside the Emacs = tree that may have similar problems. Perhaps we should rename it to string-replace, in line with the modern = naming convention discussed some time ago. ------------=_1601223302-22811-1-- From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 16:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: mattiase@acm.org, 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160122361523323 (code B ref 43598); Sun, 27 Sep 2020 16:21:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 16:20:15 +0000 Received: from localhost ([127.0.0.1]:50286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZPK-000647-Ve for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:20:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZPI-00063s-RJ for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 12:20:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53531) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMZPD-0002S2-Hy; Sun, 27 Sep 2020 12:20:07 -0400 Received: from [176.228.60.248] (port=2613 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMZPC-0000VY-Fa; Sun, 27 Sep 2020 12:20:07 -0400 Date: Sun, 27 Sep 2020 19:19:52 +0300 Message-Id: <831rinnqdz.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> (message from Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= on Sun, 27 Sep 2020 18:14:36 +0200) References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> <87imbz5swl.fsf@gnus.org> <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mattias Engdegård > Date: Sun, 27 Sep 2020 18:14:36 +0200 > Cc: 43598-done@debbugs.gnu.org > > Looks like we are done now. string-replace seems to be substantially faster than replace-regexp-in-string. > Good job! Thanks. Is it possible to have some speed comparison for these two? From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 16:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160122492025331 (code B ref 43598); Sun, 27 Sep 2020 16:42:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 16:42:00 +0000 Received: from localhost ([127.0.0.1]:50304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZkO-0006aV-Cf for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:42:00 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZkM-0006aG-7Q for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 12:41:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9LpKL6qZC+cOHSs4Cj+V3viN8lSpQr05fuoG+OWoyWQ=; b=M+6gMH7lLUwecKCMxaa/P0JeIf RuX45aAxHKrSa/Ip5hBlrLJCSA7Ua96iECigcLzQA/pO7140F6HckWk6p1Bjw6fVc28FuBqUN+xov TlWtHdppZuzae3pRBRAP0qz6ubm5pwAMVHdr/D23VzvAt15HiBLX7Lt191Mb3XeLPQ2I=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMZkA-0006st-FY; Sun, 27 Sep 2020 18:41:51 +0200 From: Lars Ingebrigtsen References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> <87imbz5swl.fsf@gnus.org> <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> <831rinnqdz.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEVOdZg8aJXZyLRn YWr///+0ydZhAAAAAWJLR0QEj2jZUQAAAAd0SU1FB+QJGxAUIizhdBoAAAFxSURBVDjLdZMBjsQg CEXFXgDTCzRwgVbuf7f9gLrtTIdsNvU/Qfwypcyg9cXlK2jhdt8rcoTWkFID4IOoVBGB2uJDVlFi X16pTuCo7fIIiFvmLEknsBN6FfnKQHg39QVkm9FVfwF+j7Zbv4Hjdvk22M2Nxripu0C72T8ozOlR S4QyLRzhp8cUzt2tXJ7HXWktie5g+P2MeaHjF/C3+AGAqG2nHDUKPK07qPFLRqIfAAW3H0DUXoEh PoG6aBc/S4VK/NmV77yPaoAoENc+U68xPL4Xc8kY2TZdDwDVY78fnA9DkF3MBni+FvLJt4/hHMRf n5g2DIwmA1pzVMj1npOG/4OwHNahmmmPU0SvMJhrMV9ZiPhA9pkNbBZLkT7GtkcxJrMeuh/SfaH4 xdTCSIhzHaI1b8LNLLx07cN3VT257Am6zUBKl2sB7UPNfNzfZqncr2Ga6VVy2cerZCD/KrHFG5HH KVbQfldR/HkeNOxU1PoDgHFqbywcqW4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjAtMDktMjdUMTY6 MjA6MzMrMDA6MDAh+wmJAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTA5LTI3VDE2OjIwOjMzKzAw OjAwUKaxNQAAAABJRU5ErkJggg== X-Now-Playing: Ida's _Heart Like A River_: "Sundown" Date: Sun, 27 Sep 2020 18:41:39 +0200 In-Reply-To: <831rinnqdz.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 27 Sep 2020 19:19:52 +0300") Message-ID: <87pn67yxx8.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: > Thanks. Is it possible to have some speed comparison for these two? This is what I used: Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Thanks. Is it possible to have some speed comparison for these two? This is what I used: (let ((elems (mapcar (lambda (s) (let ((start (random 80))) (cons (substring s start (+ start (random 20))) s))) (cl-loop repeat 1000 collect (cl-coerce (cl-loop repeat 100 collect (+ (random 26) ?a)) 'string))))) (list (benchmark-run 10000 (dolist (elem elems) (string-search (car elem) (cdr elem)))) (benchmark-run 10000 (dolist (elem elems) (string-match (car elem) (cdr elem)))))) => ((7.47099299 29 3.773541741999992) (19.673036086 74 9.616665831000006)) This is rather geared towards the weaknesses of string-match, though -- we're blowing through the regexp cache. If you decrease the number of regexps to 10 and the run to 1000000, we get: ((7.818917279000001 37 4.791844609999998) (11.049133279 37 4.713127558000011)) And to compare with a "do-nothing" version: (benchmark-run 10000 (dolist (elem elems) elem)))) => ((5.74714395 28 3.722243896000009)) Using that as a baseline, the difference is 2s vs 5.2s. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Sep 2020 16:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: mattiase@acm.org, 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160122536226058 (code B ref 43598); Sun, 27 Sep 2020 16:50:01 +0000 Received: (at 43598) by debbugs.gnu.org; 27 Sep 2020 16:49:22 +0000 Received: from localhost ([127.0.0.1]:50321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZrW-0006mE-Fu for submit@debbugs.gnu.org; Sun, 27 Sep 2020 12:49:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33332) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMZrR-0006ly-Kl for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 12:49:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54206) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMZrK-0006je-J5; Sun, 27 Sep 2020 12:49:11 -0400 Received: from [176.228.60.248] (port=4389 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMZrK-0005kY-2r; Sun, 27 Sep 2020 12:49:10 -0400 Date: Sun, 27 Sep 2020 19:48:56 +0300 Message-Id: <83y2kvmah3.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87pn67yxx8.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 27 Sep 2020 18:41:39 +0200) References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <9EAF49DE-5B51-4F8D-B5F1-50D853FCA4B9@acm.org> <87zh5b5tkz.fsf@gnus.org> <0CB4CF76-F4C1-447A-87A4-0CF120AB8A60@acm.org> <87imbz5swl.fsf@gnus.org> <0DD2B3C3-8ADA-4F90-815C-84D27AE03344@acm.org> <831rinnqdz.fsf@gnu.org> <87pn67yxx8.fsf@gnus.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Lars Ingebrigtsen > Cc: Mattias Engdegård , > 43598@debbugs.gnu.org > Date: Sun, 27 Sep 2020 18:41:39 +0200 > > Using that as a baseline, the difference is 2s vs 5.2s. Thanks. So a factor of 2.5, not bad. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Richard Stallman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Sep 2020 03:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: mattiase@acm.org, 43598@debbugs.gnu.org Reply-To: rms@gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.16012645264190 (code B ref 43598); Mon, 28 Sep 2020 03:43:01 +0000 Received: (at 43598) by debbugs.gnu.org; 28 Sep 2020 03:42:06 +0000 Received: from localhost ([127.0.0.1]:50936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMk3C-00015W-GF for submit@debbugs.gnu.org; Sun, 27 Sep 2020 23:42:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMk3B-000154-FJ for 43598@debbugs.gnu.org; Sun, 27 Sep 2020 23:42:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34699) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMk35-0003hy-Pl; Sun, 27 Sep 2020 23:41:59 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1kMk35-0007gf-0J; Sun, 27 Sep 2020 23:41:59 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman In-Reply-To: <87pn68vyzw.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 27 Sep 2020 02:34:27 +0200) References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <87pn68vyzw.fsf@gnus.org> Message-Id: Date: Sun, 27 Sep 2020 23:41:59 -0400 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > (string-match (string-to-multibyte "o\303\270") "o\303\270") > => 0 > (equal (string-to-multibyte "o\303\270") "o\303\270") > => nil It is paradoxical, but I think it is correct. Equal compares the type of the string, not just the characters in it. -- Dr Richard Stallman Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Sep 2020 09:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Richard Stallman Cc: Lars Ingebrigtsen , 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160128601023281 (code B ref 43598); Mon, 28 Sep 2020 09:41:02 +0000 Received: (at 43598) by debbugs.gnu.org; 28 Sep 2020 09:40:10 +0000 Received: from localhost ([127.0.0.1]:51433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMpdi-00063R-A4 for submit@debbugs.gnu.org; Mon, 28 Sep 2020 05:40:10 -0400 Received: from mail85c50.megamailservers.eu ([91.136.10.95]:45254 helo=mail18c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMpdg-00063I-AD for 43598@debbugs.gnu.org; Mon, 28 Sep 2020 05:40:09 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1601286005; bh=ygTlcvrJFh/gNosXfIdKaPZa4GdcJ5gKjZp0sftuqAY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=l9jGEzvElKKk5BeO38UmT8t2mGf7sl0FUvO86UFvZLjyJ6rN/jMyM22zO40iwWY5P EDLOukMrUau3qWBGhXmNcAyBlA8+rIsDtEbLphhRBnUXEN5P1ZSyzTu8u5MFmdfoZt hbleWsOHPm1+FeYHIR4E6tEI1YtVDd7JVVqCObgI= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail18c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08S9e3Rp015126; Mon, 28 Sep 2020 09:40:05 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= In-Reply-To: Date: Mon, 28 Sep 2020 11:40:02 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <8B720C0F-AD35-4DCC-B935-0C2513DBFE86@acm.org> References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <87pn68vyzw.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F29.5F71AF75.00B5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=K8Zc4BeI c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=j7qoaR80LesGMiX2GnIA:9 a=CjuIK1q_8ugA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 28 sep. 2020 kl. 05.41 skrev Richard Stallman : > It is paradoxical, but I think it is correct. > Equal compares the type of the string, not just the > characters in it. No it doesn't. (equal (string-to-multibyte "A") "A") => t. Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 28 sep. 2020 kl. 05.41 skrev Richard Stallman : > It is paradoxical, but I think it is correct. > Equal compares the type of the string, not just the > characters in it. No it doesn't. (equal (string-to-multibyte "A") "A") =3D> t. There is no deep reason for the current behaviour. It's just how things = came to be, and nobody has been sufficiently annoyed to change it. The = implementation is efficient and good enough for most purposes. It is inconsistent and confusing though, and occasionally it does break = down. One such case is when two strings that are not 'equal' become = 'equal' after printing and reading them back, since unibyte and = multibyte strings have the same printed representation. This can arise = in conjunction with byte compilation. Again, I have no plans to do anything about it right now. From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Richard Stallman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Sep 2020 03:30:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=83=C2=A5rd?= Cc: larsi@gnus.org, 43598@debbugs.gnu.org Reply-To: rms@gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160135018419977 (code B ref 43598); Tue, 29 Sep 2020 03:30:01 +0000 Received: (at 43598) by debbugs.gnu.org; 29 Sep 2020 03:29:44 +0000 Received: from localhost ([127.0.0.1]:54498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN6Kl-0005C9-Lp for submit@debbugs.gnu.org; Mon, 28 Sep 2020 23:29:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN6Kj-0005Bw-LP for 43598@debbugs.gnu.org; Mon, 28 Sep 2020 23:29:42 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57968) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kN6Ke-00017k-9j; Mon, 28 Sep 2020 23:29:36 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1kN6Kc-0007bC-My; Mon, 28 Sep 2020 23:29:34 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman In-Reply-To: <8B720C0F-AD35-4DCC-B935-0C2513DBFE86@acm.org> (message from Mattias =?UTF-8?Q?Engdeg=C3=83=C2=A5rd?= on Mon, 28 Sep 2020 11:40:02 +0200) References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <87pn68vyzw.fsf@gnus.org> <8B720C0F-AD35-4DCC-B935-0C2513DBFE86@acm.org> Message-Id: Date: Mon, 28 Sep 2020 23:29:34 -0400 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > > It is paradoxical, but I think it is correct. > > Equal compares the type of the string, not just the > > characters in it. > No it doesn't. (equal (string-to-multibyte "A") "A") => t. I am puzzled, then. Why DOES the other example return nil? -- Dr Richard Stallman Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) From unknown Mon Aug 18 21:50:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43598: replace-in-string: finishing touches Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Sep 2020 04:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43598 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: rms@gnu.org, Richard Stallman , Mattias =?UTF-8?Q?Engdeg=C3=83=C2=A5rd?= Cc: larsi@gnus.org, 43598@debbugs.gnu.org Received: via spool by 43598-submit@debbugs.gnu.org id=B43598.160135276023998 (code B ref 43598); Tue, 29 Sep 2020 04:13:02 +0000 Received: (at 43598) by debbugs.gnu.org; 29 Sep 2020 04:12:40 +0000 Received: from localhost ([127.0.0.1]:54533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN70J-0006F0-RE for submit@debbugs.gnu.org; Tue, 29 Sep 2020 00:12:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN70E-0006Ea-0V for 43598@debbugs.gnu.org; Tue, 29 Sep 2020 00:12:37 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59074) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kN708-0007N4-KH; Tue, 29 Sep 2020 00:12:28 -0400 Received: from [2a02:14f:1fe:f8df::9b1b:6319] (port=56764) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1kN700-0001dm-1y; Tue, 29 Sep 2020 00:12:20 -0400 Date: Tue, 29 Sep 2020 07:12:16 +0300 User-Agent: K-9 Mail for Android In-Reply-To: References: <77CD28C7-77C0-4DED-ACD0-21418489BADE@acm.org> <87blhuu3w9.fsf@gnus.org> <2CFAAACA-2FD3-44C2-B12E-E49DAA968115@acm.org> <87lfgyqffw.fsf@gnus.org> <2C702C6F-9E36-4BB1-A8A5-6EAD29B4E616@acm.org> <878scwaxw6.fsf@gnus.org> <87pn68vyzw.fsf@gnus.org> <8B720C0F-AD35-4DCC-B935-0C2513DBFE86@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Eli Zaretskii Message-ID: <166D0DE0-579B-49D1-AAF7-0A03EE717F8D@gnu.org> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On September 29, 2020 6:29:34 AM GMT+03:00, Richard Stallman wrote: >=20 > > > It is paradoxical, but I think it is correct=2E > > > Equal compares the type of the string, not just the > > > characters in it=2E >=20 > > No it doesn't=2E (equal (string-to-multibyte "A") "A") =3D> t=2E >=20 > I am puzzled, then=2E Why DOES the other example return nil? Because the byte sequences of the two strings are different when there are= non-ASCII bytes in the original unibyte string=2E