all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `match-data' set improperly
@ 2003-02-12  3:16 Matthew Swift
  2003-02-12 10:53 ` Kim F. Storm
       [not found] ` <mailman.1845.1045043916.21513.bug-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew Swift @ 2003-02-12  3:16 UTC (permalink / raw)


This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.2.1 (i386-debian-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2002-11-06 on beth, modified by Debian
configured using `configure  i386-debian-linux-gnu --prefix=/usr/local --sharedstatedir=/var/lib --libexecdir=/usr/local/lib --localstatedir=/var/lib --infodir=/usr/local/share/info --mandir=/usr/local/share/man --with-pop=yes --with-x=yes --with-x-toolkit=athena --without-gif'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

Evaluating the following `let' form gives varying results, but the results
should be consistent.  Correct results are always returned when `s' is "The
quick fox...", which matches the regexp `r'.  When `s' is "great grey
green...", which does not match `r', the results in my trials have never been
correct: either an 'args-out-of-range' error is raised, or incorrect data is
given, which appears to be the result of applying match-data from matching a
previous value of `s' ("The quick fox...") to the current value of `s'.  Sample
results are copied below.

My *guess* is that when `string-match' fails, it either fails to set
`match-data' or sets it incorrectly in one of two (or more) ways.

(let ((r "\\(qu\\)\\(ick\\)")
      ;; \C-x\C-t to swap next two lines
      ;; \M-\C-x to evaluate the `let' form
      (s "The quick fox jumped quickly.")
      (s "great grey green greasy Limpopo River")
      )
  (string-match r s)
  (list
   (match-data)
   (match-string 0 s)
   (match-string 1 s)
   (match-string 2 s)
   (match-string 3 s)
   (match-beginning 0)
   (match-beginning 1)
   (match-beginning 2)
   (match-beginning 3)
   ))


Debugger entered--Lisp error: (args-out-of-range "great grey green greasy Limpopo River" 27326 27327)
  match-string(0 "great grey green greasy Limpopo River")
  (list (match-data) (match-string 0 s) (match-string 1 s) (match-string 2 s) (match-string 3 s) (match-beginning 0) (match-beginning 1) (match-beginning 2) (match-beginning 3))
  (let ((r "\\(qu\\)\\(ick\\)") (s "The quick fox jumped quickly.") (s "great grey green greasy Limpopo River")) (string-match r s) (list (match-data) (match-string 0 s) (match-string 1 s) (match-string 2 s) (match-string 3 s) (match-beginning 0) (match-beginning 1) (match-beginning 2) (match-beginning 3)))
  eval((let ((r "\\(qu\\)\\(ick\\)") (s "The quick fox jumped quickly.") (s "great grey green greasy Limpopo River")) (string-match r s) (list (match-data) (match-string 0 s) (match-string 1 s) (match-string 2 s) (match-string 3 s) (match-beginning 0) (match-beginning 1) (match-beginning 2) (match-beginning 3))))
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp)


Sometimes I get:

((4 9 4 6 6 9) "t gre" "t " "gre" nil 4 4 6 nil)

I get this less often, and I cannot tell you a reliable way to get it.  I
evaluate the `let' form, evaluate one or more individual lines
e.g. (match-beginning 2), swap the `s' strings, and evaluate the `let' form
again.  Then most of the time I still get the error, but sometimes I get these
incorrect results.

Notice that the match-data is the same as for a successful match of the other
string:

((4 9 4 6 6 9) quick qu ick nil 4 4 6 nil)






Recent input:
<mouse-1> <down-mouse-5> <mouse-5> <double-down-mouse-5> 
<double-mouse-5> <down-mouse-1> <mouse-1> C-a C-n <return> 
M-1 C-n C-n C-n C-n C-n C-n <return> C-n C-n <return> 
M-1 C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-p <return> <help-echo> <help-echo> <down-mouse-1> 
<mouse-1> C-a C-SPC C-n C-n C-n C-n C-n C-n C-n C-SPC 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p M-w C-x o q g M-x r e p o r t - e m a c s - b u 
g <return>

Recent messages:
nndiary: Reading incoming mail (no new mail)...done
1 -> require: nnmail
1 <- require: nnmail
1 -> require: nnmail
1 <- require: nnmail
Checking new news...done
Loading emacsbug...
1 -> require: sendmail
1 <- require: sendmail
Loading emacsbug...done

^ permalink raw reply	[flat|nested] 8+ messages in thread
* `match-data' set improperly
@ 2003-02-13  0:54 Luc Teirlinck
  2003-02-13  6:42 ` Matt Swift
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Teirlinck @ 2003-02-13  0:54 UTC (permalink / raw)
  Cc: 'Kim F. Storm'

Matthew Swift wrote:

    The documentation (TeXinfo and docstrings) is pretty clear that
    (match-string N) when submatch N>0 does not match anything is nil,
    and = it is also clear that (match-string 0) is like the case for
    N>0 but referring = to the entire match instead of a submatch.
    There is no suggestion that match-data is ever undefined, once one
    match has been done,

The following in the Elisp manual (Chapter: Searching and Matching, Simple
Match Data Access) suggests exactly that to me:

       A search which fails may or may not alter the match data.  In the
    past, a failing search did not do this, but we may change it in the
    future.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-02-13 12:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-12  3:16 `match-data' set improperly Matthew Swift
2003-02-12 10:53 ` Kim F. Storm
2003-02-12 19:25   ` Matt Swift
     [not found] ` <mailman.1845.1045043916.21513.bug-gnu-emacs@gnu.org>
2003-02-12 16:02   ` Kevin Rodgers
2003-02-13 10:08     ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2003-02-13  0:54 Luc Teirlinck
2003-02-13  6:42 ` Matt Swift
2003-02-13 12:25   ` Kim F. Storm

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.