🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99196

(prog2 (re-search ".*\\'") (replace-match "\\&"))

#99196
From: NEWSMGR
Date: Wed, 17 Oct 1990 10:09
52 lines
2528 bytes
Relay-Version: VMS News - V6.0 1/9/90 VAX/VMS V5.3; site kontu.utu.fi
Path: kontu.utu.fi!polaris.utu.fi!news.funet.fi!sunic!mcsun!uunet!tut.cis.ohio-state.edu!RICE.EDU!bbc
Newsgroups: gnu.emacs.bug
Subject: (prog2 (re-search ".*\\'") (replace-match "\\&"))
Message-ID: <9010121706.AA08299@sicilia.rice.edu>
From: bbc@RICE.EDU (Benjamin Chase)
Date: 12 Oct 90 17:06:33 GMT
Reply-To: Benjamin Chase <bbc@rice.edu>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Approved: bug-gnu-emacs@prep.ai.mit.edu
Lines: 38

Shouldn't

    (prog2 (re-search-forward <foo>) (replace-match "\\&"))

(where <foo> is any pattern that results in a match) more or less do
nothing?  Well...

GNU Emacs 18.55.2  (really epoch)
SPARCstation 1
SunOS Release 4.1

Create a buffer, and put only zeroes in it (ie. no newline).  Place
dot anywhere but at the end of the buffer, do an ESC-x
eval-expression.  Feed eval-expression the following expression:

    (prog2 (re-search-forward "0+\\'") (replace-match "\\&"))

and a strange thing happens.  The last character disappears.  I think
it shouldn't do anything to the buffer. (other than marking the buffer
as having been modified...)  This same sequence does work as I expect
it to under GNU Emacs 18.55.1 (actually GNU emacs this time, not
epoch).

If I add a newline to the end of the buffer, and change the expression to

    (prog2 (re-search-forward "0+$") (replace-match "\\&"))

it works as I think it should.  

Looking further, the bug seems to occur whenever the buffer does not
end with a newline, and the search pattern tries to match the end of
the buffer (ie. ends with \\').  For example
	
    (prog2 (re-search-forward ".*\\'") (replace-match "\\&"))

seems to be a reliable loser, for buffers not ending in newlines.
--
	Ben Chase <bbc@rice.edu>, Rice University, Houston, Texas
Technical Details
Message-ID: <1ADF67A41A8720618C@kontu.utu.fi>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!KONTU.UTU.FI!NEWSMGR

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,73446945951802f9,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-17 03:09:00 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!KONTU.UTU.FI!NEWSMGR
From: NEWSMGR@KONTU.UTU.FI
Newsgroups: gnu.emacs.bug
Subject: (prog2 (re-search ".*\\'") (replace-match "\\&"))
Message-ID: <1ADF67A41A8720618C@kontu.utu.fi>
Date: 17 Oct 90 10:09:00 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 52
Approved: bug-gnu-emacs@prep.ai.mit.edu
Posted: Wed Oct 17 11:09:00 1990