From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5007 invoked by alias); 2 Jul 2010 08:25:12 -0000 Received: (qmail 4806 invoked by uid 48); 2 Jul 2010 08:24:55 -0000 Date: Fri, 02 Jul 2010 08:25:00 -0000 From: "bonzini at gnu dot org" To: glibc-bugs-regex@sources.redhat.com Message-ID: <20100702082455.11783.bonzini@gnu.org> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug regex/11783] New: Wrong result with RE_NO_SUB, $ and {n} 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: 2010-07/txt/msg00000.txt.bz2 The following program emits RE_NO_SUB 1: matched at 4 ~RE_NO_SUB 1: not matched RE_NO_SUB 2: matched at 4 ~RE_NO_SUB 2: not matched RE_NO_SUB 3: matched at 4 ~RE_NO_SUB 3: not matched RE_NO_SUB 4: not matched ~RE_NO_SUB 4: not matched so matching regexes 1 to 3 is buggy. #define _GNU_SOURCE 1 #include #include #include #include int test (const char *regex, const char *text, int syntax, const char *name) { const char *error; regex_t pat; int ret; re_set_syntax (RE_SYNTAX_POSIX_EXTENDED | syntax); memset (&pat, 0, sizeof(pat)); error = re_compile_pattern (regex, strlen(regex), &pat); ret = re_search (&pat, text, strlen (text), 0, strlen (text), NULL); if (ret > -1) printf ("%s: matched at %d\n", name, ret); else printf ("%s: not matched\n", name); regfree (&pat); } int main() { const char regex1[] = "([0-9]+([^0-9]+|$)){2}"; const char regex2[] = "([0-9][0-9]*([^0-9][^0-9]*|$)){2}"; const char regex3[] = "([0-9]+([^0-9]+|$)){3}"; const char regex4[] = "([0-9]+([^0-9]+|$))([0-9]+([^0-9]+|$))"; const char text[] = "xxx 888"; test (regex1, text, RE_NO_SUB, "RE_NO_SUB 1"); test (regex1, text, 0, "~RE_NO_SUB 1"); test (regex2, text, RE_NO_SUB, "RE_NO_SUB 2"); test (regex2, text, 0, "~RE_NO_SUB 2"); test (regex3, text, RE_NO_SUB, "RE_NO_SUB 3"); test (regex3, text, 0, "~RE_NO_SUB 3"); test (regex4, text, RE_NO_SUB, "RE_NO_SUB 4"); test (regex4, text, 0, "~RE_NO_SUB 4"); } -- Summary: Wrong result with RE_NO_SUB, $ and {n} Product: glibc Version: 2.12 Status: NEW Severity: normal Priority: P2 Component: regex AssignedTo: drepper at redhat dot com ReportedBy: bonzini at gnu dot org CC: 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=11783 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.