Bug in POSIX.2 regex word boundary matching

dominique.pelle@free.fr dominique.pelle@free.fr
Tue Mar 14 06:27:00 GMT 2006


Hi,

Word boundary regular expression matching (\b \< \>) does not
work with POSIX.2 regex functions in cygwin (#include <regex.h>).
It works fine using Linux.

Here is a simple test case to easily reproduce the problem:

$ cat regex-bug.c
int main()
{
  regex_t    r;
  regmatch_t pmatch[2];

  if (regcomp(&r, "\\bfoobar\\b", REG_EXTENDED) != 0) {
    fprintf(stderr, "regcomp failed\n");
    exit(-1);
  }

  /* I'd expect above regex to match following string */
  if (regexec(&r, "test foobar test", 2, pmatch, 0) == 0) {
    fprintf(stderr, "OK (match)\n");  /* expected behavior */
  } else {
    fprintf(stderr, "FAIL (mismatch)\n"); /* unexpected!? */
  }
  return 0;
}

$ gcc regex-bug.c
$ ./a.out

Here is the outcome on Cywgin ................ FAIL (mismatch)

Here is the outcome on Linux (Ubuntu-5.10) ... OK (match)

Cheers
-- Dominique

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list