From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/62950 Path: news.gmane.org!not-for-mail From: Steve Youngs Newsgroups: gmane.emacs.gnus.general Subject: Re: gnus-replace-in-string: Avoid inf-loop in XEmacs Date: Fri, 21 Apr 2006 02:06:56 +1000 Organization: The SXEmacs Project Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: sea.gmane.org 1145549318 6480 80.91.229.2 (20 Apr 2006 16:08:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2006 16:08:38 +0000 (UTC) Keywords: string,start,matches,regexp,substring,setq,rep,match,replace-regexp-in-string,replace-match,function,str Original-X-From: ding-owner+m11477@lists.math.uh.edu Thu Apr 20 18:08:36 2006 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FWbhd-0004Bb-74 for ding-account@gmane.org; Thu, 20 Apr 2006 18:08:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1FWbhS-0002Be-00; Thu, 20 Apr 2006 11:08:10 -0500 Original-Received: from nas01.math.uh.edu ([129.7.128.39]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1FWbgT-0002BZ-00 for ding@lists.math.uh.edu; Thu, 20 Apr 2006 11:07:09 -0500 Original-Received: from quimby.gnus.org ([80.91.224.244]) by nas01.math.uh.edu with esmtp (Exim 4.52) id 1FWbgP-0000aZ-Qy for ding@lists.math.uh.edu; Thu, 20 Apr 2006 11:07:08 -0500 Original-Received: from 203-206-170-37.perm.iinet.net.au ([203.206.170.37] helo=bastard.youngs.au.com) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1FWbgJ-0003Cj-00 for ; Thu, 20 Apr 2006 18:07:00 +0200 Original-Received: from bastard.youngs.au.com (localhost [127.0.0.1]) by bastard.youngs.au.com (8.13.5/8.13.5) with ESMTP id k3KG6usH028827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 21 Apr 2006 02:06:56 +1000 Original-Received: (from steve@localhost) by bastard.youngs.au.com (8.13.5/8.13.5/Submit) id k3KG6us8028826; Fri, 21 Apr 2006 02:06:56 +1000 Original-To: ding@gnus.org X-Face: #O)>9erkUv7RJ~0G~5_6lEMz\HC2&~&kV2bsu4TWHI_v~<8Hj%KBBj1[*\uKF*dxbEzwAli ;tSuN`c)F,}p|7{6lA~e.P+7Qo\A%q"lJ7/UtUX@yEZ!X"Tph(3O8`nhPJF>hI4_GOvb%X{+e*Mi_| ^yTf#aTwGG,(3e41?C9B7Pak*'A$+$/hV Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAD1BMVEUpHB9XSkr8+87BuKOK f3UUQ+/kAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAwAAAAMADO7oxXAAAB2ElEQVR4 2nWU2XHDMAxEgYkKAEQWYIsuwJZcgCiy/5qCBanDEweTjwyeiMVpmv4x+uNJ01TLFSy7OwnReIJ5 /+fNwqqfoVKtmVgo1jxfwUIwiarLB3iIBSfOaha3E0AToMoQcoBGk00rOWEiezE38WTsSepAh5U1 tjrgf5gmvh+yJabbWWCW6NIhR2UdAZJnlBHFQNQY8x7KrKwGBnHhbRJNHaTspSGYWAxSf2GxXk98 S+x/08qHeJXWCnuj+UVWRgeFmKOI/tysJaRhH5RJcI2aeUuIVbepV/5+eu8YDbAS4zHaAu2Vwxvz sLy2DlLxZKkZkg79hdLF/IP5C3AbvwIlCQ3IRyjbBvqZKJn2engZA1+hTr2BJ8nBHBsAJnNBuVQt yOouvYSuZKvTKr+j4S0ZWMSKOLgpiwjzntpafLdperDtjVLsgNHzuQO1aFnavg3zfjh3dWtJs5S+ sMjK3NITQF/btUAcdWgPdLnBl/kxcQfzcV1kyym4Lb0EmnxLXEDbizOSgSeJMmWcnvDoNTTxu7YF xDFpuL7QvRtaJR5nbZtqc/HGC1e7vXYWaImwbQyDCcexpYSsHqZsBF2puI15bldpAPkaiLXWpUdq u5uW8i5my8evxy//LmnkhQmz/AAAABp6VFh0SlBFRy1Db2xvcnNwYWNlAAB42jMCAAAzADMRFn5j AAAAJ3pUWHRKUEVHLVNhbXBsaW5nLWZhY3RvcnMAAHjaM6ow0jGsMARhABGDAulkDxtiAAAAAElF TkSuQmCC Mail-Copies-To: never X-X-Day: Only 2430765 days till X-Day. Got Slack? X-URL: X-Request-PGP: X-OpenPGP-Fingerprint: 1659 2093 19D5 C06E D320 3A20 1D27 DB4B A94B 3003 X-Now-Playing: All Around Me --- [Savage Garden] X-Discordian-Date: Sweetmorn, the 38th day of Discord, 3172. X-Attribution: SY X-Arch-Repo: steve@sxemacs.org--2006 http://arch.sxemacs.org/2006/ Mail-Followup-To: ding@gnus.org In-Reply-To: (Reiner Steib's message of "Thu, 20 Apr 2006 15:07:24 +0200") User-Agent: Gnus/5.110005 (No Gnus v0.5) SXEmacs/22.1.4 (Bentley Turbo, linux) X-Spam-Score: -2.5 (--) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:62950 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Transfer-Encoding: quoted-printable * Reiner Steib writes: > On Mon, Apr 17 2006, Steve Youngs wrote: > [ from ] >> * Reiner Steib writes: > [...] >> > - In `message-put-addresses-in-ecomplete' you should use >> > `gnus-replace-in-string' instead of `replace-regexp-in-string' for >> > compatibility with XEmacs. >>=20 >> Only needed for XEmacs 21.4. XEmacs 21.5 and SXEmacs has >> `replace-regexp-in-string'.=20 > Is it just a wrapper around `replace-in-string' or is it Emacs > implementation of `replace-regexp-in-string'? Hm... This is from SXEmacs (which I ripped from XE 21.5)... --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline Content-Transfer-Encoding: quoted-printable (defun replace-regexp-in-string (regexp rep string &optional fixedcase literal subexp start) "Replace all matches for REGEXP with REP in STRING. Return a new string containing the replacements. Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the arguments with the same names of function `replace-match'. If START is non-nil, start replacements at that index in STRING. REP is either a string used as the NEWTEXT arg of `replace-match' or a function. If it is a function it is applied to each match to generate the replacement passed to `replace-match'; the match-data at this point are such that match 0 is the function's argument. To replace only the first match (if any), make REGEXP match up to \\' and replace a sub-expression, e.g. (replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo foo\" nil nil= 1) =3D> \" bar foo\" " ;; To avoid excessive consing from multiple matches in long strings, ;; don't just call `replace-match' continually. Walk down the ;; string looking for matches of REGEXP and building up a (reversed) ;; list MATCHES. This comprises segments of STRING which weren't ;; matched interspersed with replacements for segments that were. ;; [For a `large' number of replacments it's more efficient to ;; operate in a temporary buffer; we can't tell from the function's ;; args whether to choose the buffer-based implementation, though it ;; might be reasonable to do so for long enough STRING.] (let ((l (length string)) (start (or start 0)) matches str mb me) (save-match-data (while (and (< start l) (string-match regexp string start)) (setq mb (match-beginning 0) me (match-end 0)) ;; If we matched the empty string, make sure we advance by one char (when (=3D me mb) (setq me (min l (1+ mb)))) ;; Generate a replacement for the matched substring. ;; Operate only on the substring to minimize string consing. ;; Set up match data for the substring for replacement; ;; presumably this is likely to be faster than munging the ;; match data directly in Lisp. (string-match regexp (setq str (substring string mb me))) (setq matches (cons (replace-match (if (stringp rep) rep (funcall rep (match-string 0 str))) fixedcase literal str subexp) (cons (substring string start mb) ; unmatched prefix matches))) (setq start me)) ;; Reconstruct a string from the pieces. (setq matches (cons (substring string start l) matches)) ; leftover (apply #'concat (nreverse matches))))) --=-=-= Content-Transfer-Encoding: quoted-printable > We should change `gnus-replace-in-string' as follows, I think: > --- gnus-util.el 20 Apr 2006 12:10:00 +0200 6.104.2.24 > +++ gnus-util.el 20 Apr 2006 14:52:55 +0200=09 I wondered why this wouldn't apply for me, until I realised it was a much older version of gnus-util.el that I had. Is it from the v5-10 branch? My copy (from CVS HEAD) is version 7.something. > On Thu, Apr 20 2006, Steve Youngs wrote: >> * Katsumi Yamaoka writes: >> > Though it seems to be solved by replacing the regexp with "^ >> > +\\| +$". >>=20 >> This fixed the problem I was seeing in SXEmacs too. > Does shifting down "((fboundp 'replace-in-string) ...)" solve this > problem too? Yes. --=20 |---------------------| | I am Dyslexic of Borg. |=20 | Fusistance is retile. Your arse will be laminated. | |---------------------------------------| --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Eicq - The SXEmacs ICQ Client iEYEABECAAYFAkRHsaAACgkQHSfbS6lLMANu0QCdGsYsBCBEp/3/Cz6NRQpNZ4bz CB4AnjxYk9AfwV+EkKWmdtS03w5P6v7v =Qu9H -----END PGP SIGNATURE----- --==-=-=--