🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99754

regexp-search fails in complicated expression

#99754
From: Ralph P. Sobek
Date: Thu, 07 Jun 1990 15:31
73 lines
4144 bytes
Concerning: GNU Emacs 18.55.13 of Tue Nov 21 1989 on vega (berkeley-unix),
	    Run on a SparcStation 1 under SunOS 4.0.3.  Vega is a Sun-4/260.

I am using a number of complex regexps!  In the following narrowed-to
region:

"1989, p.453-65, 29 Refs, Country of Publ.: Netherlands"

a problem occurs at the blank between "Country" and "of".  The
following regexp fails:

"\\([0-9][0-9][0-9][0-9]\\),\\(  ?\\|\n\\)p\\.\\([---0-9+]+\\)\\([ \n]pp\\.\\)?
\\( vol\\.\\([^ ,]+\\)\\)?,\\(  ?\\|\n\\)[0-9]+\\(  ?\\|\n\\)Refs,
\\(  ?\\|\n\\)\\(.*,\\(  ?\\|\n\\)\\)*Country\\(  ?\\|\n\\)of\\(  ?\\|\n\\)
Publ\\.:\\(  ?\\|\n\\)\\(.*\\)$"

The physical linefeeds are there only for newsreader readability!  The
problem occurs in the "Country\\( ?\\|\n\\)" portion.  If the
alternating regexps after "Country" are replaced by "\\(  ?\\)", it
produces the following successful match-data:

(#<marker at 486 in *Backtrace*> #<marker at 540 in *Backtrace*>
#<marker at 486 in *Backtrace*> #<marker at 490 in *Backtrace*>
#<marker at 491 in *Backtrace*> #<marker at 492 in *Backtrace*>
#<marker at 494 in *Backtrace*> #<marker at 500 in *Backtrace*> nil
nil nil nil nil nil #<marker at 501 in *Backtrace*> #<marker at 502 in
*Backtrace*> #<marker at 504 in *Backtrace*> #<marker at 505 in
*Backtrace*> #<marker at 510 in *Backtrace*> #<marker at 511 in
*Backtrace*>)

The expression which matched is the following (\nl's are real linefeeds):

(looking-at "\\([0-9][0-9][0-9][0-9]\\),\\(  ?\\|
\\)p\\.\\([---0-9+]+\\)\\([ 
]pp\\.\\)?\\( vol\\.\\([^ ,]+\\)\\)?,\\(  ?\\|
\\)[0-9]+\\(  ?\\|
\\)Refs,\\(  ?\\|
\\)\\(.*,\\(  ?\\|
\\)\\)*Country\\(  ?\\)of\\(  ?\\)Publ\\.:\\(  ?\\)\\(.*\\)$")

Note that the length of the "(match-data)" is 20!!  The sub-regexp
matchs made after the ninth are *NOT* recorded!!  Does this have
anything to do with the TEN match constructs \&, \1, thru \9 ?  I
suppose so!

If so, it is either a GNU emacs error or a documentation error.  In
neither our GNU Emacs Manual (Fifth Edidion, Version 18) or our
preliminary GNU Emacs Lisp Manual (version 18, Sept. 1988), is there
mentioned a limit of TEN.  Only the "first 9 constructs" are accesible
as \<digit>.  In the documentation concerning the functions
match-data, match-beginning, match-end, etc., there is no mention that
the variable <count> must be less than 10!!

My diagnosis is that GNU Emacs ignores "\\("s and "\\)" over 9.
Unfortunately, if there follows an alternation "\\|" then it can not
backtrack correctly and therefor the match fails eventhough it is
syntactically correct.

Is there any other solution other than break-up the regexp?  Why is
there a limit on the number of allowed subexpressions?  The \<digit>
constructs could remain limited, but one could allow more flexibility
in Lisp.

As an aside, is gnu.emacs.bug gatewayed with the bug-gnu-emacs@prep.ai.mit.edu
mailing list?

--
Ralph P. Sobek			  Disclaimer: The above ruminations are my own.
ralph@laas.fr				   Addresses are ordered by importance.
ralph@laas.uucp, or ...!uunet!laas!ralph		
If all else fails, try:				      sobek@eclair.Berkeley.EDU
===============================================================================
Reliable software should kill people reliably! -Andy Mickel, Pascal News #13,78
Technical Details
Message-ID: <RALPH.90Jun7173149@cresus.laas.fr>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!i2unix!inria!laas!ralph

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10e6b9,55fe92c40cf68618,start
X-Google-Attributes: gid10e6b9,public
X-Google-Thread: fb2f1,55fe92c40cf68618,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-06-07 19:03:59 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!i2unix!inria!laas!ralph
From: ralph@laas.fr (Ralph P. Sobek)
Newsgroups: gnu.emacs.bug,gnu.emacs
Subject: regexp-search fails in complicated expression
Summary: The hidden magic number: 10 !!
Keywords: regexp, looking-at, emacs 18.55, match-data, match-end, match-beginning
Message-ID: <RALPH.90Jun7173149@cresus.laas.fr>
Date: 7 Jun 90 15:31:49 GMT
Sender: news@laas.laas.fr
Reply-To: ralph@laas.fr
Followup-To: gnu.emacs.bug
Distribution: gnu
Organization: LAAS-CNRS France
Lines: 73
Posted: Thu Jun  7 16:31:49 1990