[pcre-dev] [Bug 1158] Spurious match for "^$"

Αρχική Σελίδα
Delete this message
Συντάκτης: Philip Hazel
Ημερομηνία:  
Προς: pcre-dev
Αντικείμενο: [pcre-dev] [Bug 1158] Spurious match for "^$"
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1158




--- Comment #1 from Philip Hazel <ph10@???> 2011-09-30 10:28:58 ---
On Fri, 30 Sep 2011, Roberto Bagnara wrote:

> $ cat r.c
> #include <stdio.h>
> #if PCRE
> #include <pcreposix.h>
> #else
> #include <regex.h>
> #endif
>
> int main() {
>   char buf[1024];
>   regex_t re;
>   int r;
>   r = regcomp(&re, "^$", REG_EXTENDED);
>   if (r != 0) {
>     regerror(r, &re, buf, sizeof(buf));
>     printf("regcomp: %s\n", buf);
>   }
>   r = regexec(&re, "\n", 0, 0, 0);
>   if (r != 0) {
>     regerror(r, &re, buf, sizeof(buf));
>     printf("regexec: %s\n", buf);
>   }
>   return 0;
> }
> $ gcc -W -Wall r.c
> $ ./a.out
> regexec: No match
> $ gcc -W -Wall -DPCRE r.c -lpcreposix
> $ ./a.out 
> $


Why do you think that the PCRE match is spurious? It looks OK to me.
Remember, the PCRE POSIX interface is *just an interface*. It does NOT
give POSIX semantics. You still get Perl semantics, where $ matches
either the end of the string or a newline at the end of the string.

Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email