From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15487 invoked by alias); 2 Feb 2007 13:23:17 -0000 Received: (qmail 15315 invoked by uid 48); 2 Feb 2007 13:23:03 -0000 Date: Fri, 02 Feb 2007 13:23:00 -0000 From: "andrew dot mackey at baesystems dot com" To: glibc-bugs-regex@sources.redhat.com Message-ID: <20070202132302.3957.andrew.mackey@baesystems.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug regex/3957] New: regcomp with REG_NEWLINE flag does operate as POSIX specification for a non-matching list X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-regex-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-regex-owner@sourceware.org X-SW-Source: 2007-02/txt/msg00000.txt.bz2 Given the string ‘foo\nbar’ (where \n is a linefeed) the regular expression ‘foo[^ ]+’ matches the complete string. The regex is compiled with REG_EXTENDED and REG_NEWLINE flags. The POSIX specification at http://www.opengroup.org/onlinepubs/009695399/functions/regcomp.html Says for the REG_NEWLINE flag that “A in string shall not be matched by a period outside a bracket expression or by any form of a non-matching list “ For older versions of glicb (glibc-2.1.3) the behaviour of regcomp is as the POSIX specification. For glibc-2.5 and from at least glibc-2.3.2 this is not the behaviour The following code demonstrates the issue #include #include #include int main(int argc, char **argv) { char regex[] = "foo[^ ]+"; char text[] = "foo\nbar"; regex_t preg; regmatch_t pmatch[1]; int flags = REG_EXTENDED | REG_NEWLINE; int i; printf("About to compile regexp '%s', with flags %d\n", regex, flags); if(!regcomp(&preg, regex, flags)) { printf("About to search string '%s'\n", text); if(!regexec(&preg, text, 1, pmatch, 0)) { printf("Regex matched, match text is '"); for(i = pmatch[0].rm_so; i < pmatch[0].rm_eo; i++) { printf("%c", text[i]); } printf("'\n"); } else { printf("Regex did not match\n"); } regfree(&preg); } else { printf("Failed to compile regex\n"); } return 0; } On glib-2.3.2, glibc-2.3.6 or glibc-2.5 the program gives About to compile regexp 'foo[^ ]+', with flags 5 About to search string 'foo bar' Regex matched, match text is 'foo bar' On glibc-2.1.3 and other C libraries such as found on Solaris 9 the output is About to compile regexp 'foo[^ ]+', with flags 9 About to search string 'foo bar' Regex did not match Which I believe is the expected POISX behaviour. -- Summary: regcomp with REG_NEWLINE flag does operate as POSIX specification for a non-matching list Product: glibc Version: 2.4 Status: NEW Severity: normal Priority: P2 Component: regex AssignedTo: drepper at redhat dot com ReportedBy: andrew dot mackey at baesystems dot com CC: andrew dot mackey at baesystems dot com,glibc-bugs-regex at sources dot redhat dot com,glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=3957 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.