all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* posix-string-match does not distinguish "*" from "*?"
@ 2003-02-16  5:58 Matt Swift
  2003-02-17 13:59 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Swift @ 2003-02-16  5:58 UTC (permalink / raw)




`posix-string-match' (and I presume the other `posix-*' searching
functions) do not seem to distinguish between the "*" and "*?"
operators.  No mention is made of this difference from `string-match'
in the Elisp manual, which describes the posix- functions as having
super-greedy repetition constructs and handling of "|", but a reader
would not guess that these functions differ with respect to the
explicitly non-greedy operators "*?", "+?"  and "??".  Since I do not
have access to the POSIX specs, someone else will have to discern
whether this is a dox bug or a bug in `posix-string-match'.


This is the example from the manual description of the non-greedy operators:

(let ((s "cdaaada")
      (rshort "c[ad]*?a"))
  (list
   (progn
     (string-match rshort s)
     (match-string 0 s))
   (progn
     (posix-string-match rshort s)
     (match-string 0 s))
))

=> ("cda" "cdaaada")


node (elisp)POSIX Regexps: 

       The usual regular expression functions do backtracking when necessary
    to handle the `\|' and repetition constructs, but they continue this
    only until they find _some_ match.  Then they succeed and report the
    first match found.

       This section describes alternative search functions which perform the
    full backtracking specified by the POSIX standard for regular expression
    matching.  They continue backtracking until they have tried all
    possibilities and found all matches, so they can report the longest
    match, as required by POSIX.  This is much slower, so use these
    functions only when you really need the longest match.

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

* Re: posix-string-match does not distinguish "*" from "*?"
  2003-02-16  5:58 posix-string-match does not distinguish "*" from "*?" Matt Swift
@ 2003-02-17 13:59 ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2003-02-17 13:59 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Matt Swift <swift@alum.mit.edu> writes:

|> `posix-string-match' (and I presume the other `posix-*' searching
|> functions) do not seem to distinguish between the "*" and "*?"
|> operators.  No mention is made of this difference from `string-match'
|> in the Elisp manual, which describes the posix- functions as having
|> super-greedy repetition constructs and handling of "|", but a reader
|> would not guess that these functions differ with respect to the
|> explicitly non-greedy operators "*?", "+?"  and "??".  Since I do not
|> have access to the POSIX specs, someone else will have to discern
|> whether this is a dox bug or a bug in `posix-string-match'.

POSIX does not define any of these non-greedy operators:

  The behavior of multiple adjacent duplication symbols ('+', '*', '?',
  and intervals) produces undefined results.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-16  5:58 posix-string-match does not distinguish "*" from "*?" Matt Swift
2003-02-17 13:59 ` Andreas Schwab

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.