🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99558

Re: Bug in match-end ?

#99558
From: Kyle Jones
Date: Tue, 10 Jul 1990 13:53
34 lines
1891 bytes
Piet van Oostrum writes:
 > When string-match matches an empty substring, (match-end 0) will report 1,
 > while it should report 0.
 > 
 > E.g: (string-match "x*" "abc") gives (match-end 0) => 1
 >      (string-match "x*" "xyz") also gives (match-end 0) => 1.
 > 
 > Probably the normal regexp match will also do this, but I
 > haven't checked it.

What version of Emacs are you using?  I tried this under v18.52
and match-end returned 0 for the first example, as it should.

On the other hand, the function `match-data' always returns
incorrect values if either end of the match is at the beginning
of the string or or if either match position is greater than
(point-max) in the current buffer.  This is because match-data
returns a list of _markers_ representing the match positions.
Marker positions are constrained by legal buffer positions and
positions less than (point-min) or greater than (point-max) are
rounded up or down to whichever end of the buffer is closest.

Bug?  Certainly, but I don't know if the behavior is worth
changing since you can write your own version of match-data that
returns a list of integers instead of markers.  E.g.

(defun match-data ()
  (let ((index '(9 8 7 6 5 4 3 2 1 0))
        (list))
    (while index
      (setq list (cons (match-beginning (car index))
		       (cons (match-end (car index)) list))
	    index (cdr index)))
    list ))
Technical Details
Message-ID: <1990Jul10.135327.5430@talos.pm.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!talos!kjones
References: <3583@ruuinf.cs.ruu.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,eaf3364749557a81
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-07-10 06:53:27 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!talos!kjones
From: kjones@talos.pm.com (Kyle Jones)
Newsgroups: gnu.emacs.bug
Subject: Re: Bug in match-end ?
Message-ID: <1990Jul10.135327.5430@talos.pm.com>
Date: 10 Jul 90 13:53:27 GMT
References: <3583@ruuinf.cs.ruu.nl>
Lines: 34
Posted: Tue Jul 10 14:53:27 1990