public inbox for glibc-bugs-regex@sourceware.org help / color / mirror / Atom feed
From: "bonzini at gnu dot org" <sourceware-bugzilla@sourceware.org> To: glibc-bugs-regex@sources.redhat.com Subject: [Bug regex/11783] New: Wrong result with RE_NO_SUB, $ and {n} Date: Fri, 02 Jul 2010 08:25:00 -0000 [thread overview] Message-ID: <20100702082455.11783.bonzini@gnu.org> (raw) 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 <regex.h> #include <string.h> #include <stdio.h> #include <stdlib.h> 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.
reply other threads:[~2010-07-02 8:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100702082455.11783.bonzini@gnu.org \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs-regex@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).