delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/03/14/01:37:55

X-Spam-Check-By: sourceware.org
Message-ID: <1142318263.441664b7bea01@imp1-g19.free.fr>
Date: Tue, 14 Mar 2006 19:37:43 +1300
From: dominique DOT pelle AT free DOT fr
To: cygwin AT cygwin DOT com
Subject: Re: Bug in POSIX.2 regex word boundary matching
References: <1142317647 DOT 4416624fd617a AT imp1-g19 DOT free DOT fr>
In-Reply-To: <1142317647.4416624fd617a@imp1-g19.free.fr>
MIME-Version: 1.0
User-Agent: Internet Messaging Program (IMP) 3.2.5
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Bleah. #include statements were missing in my
previously posted sample test case.  Here
is the test case again with #include statements
this time:

$ cat regex-bug.c

#include <stdio.h>
#include <regex.h>
#include <stdlib.h>

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

Outcome on Cywgin ................ FAIL (mismatch)

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019