From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 Description of problem: The following code gives a response of "Didn't find a match (for regexec)." when it should give "Success." Originally submitted to gcc but they said this is a bug in glibc and to report to vendor. Problem does not show on glibc-2.2.5-40. Using gcc version 3.2 #include <iostream> #include <sys/types.h> #include <regex.h> const char* haystack = "2\n3"; const char* needle = ".+\n3"; int main() { using namespace std; regex_t r; int failed_p = regcomp(&r, needle, REG_EXTENDED | REG_NOSUB); int result = regexec(&r, haystack, 0, NULL, 0); switch (result) { case REG_NOERROR: cout<<"Success."<<endl;break; case REG_NOMATCH: cout<<"Didn't find a match (for regexec)."<<endl;break; case REG_BADPAT: cout<<" Invalid pattern."<<endl;break; case REG_ECOLLATE: cout<<" Not implemented."<<endl;break; case REG_ECTYPE: cout<<" Invalid character class name."<<endl;break; case REG_EESCAPE: cout<<" Trailing backslash."<<endl;break; case REG_ESUBREG: cout<<" Invalid back reference."<<endl;break; case REG_EBRACK: cout<<" Unmatched left bracket."<<endl;break; case REG_EPAREN: cout<<" Parenthesis imbalance."<<endl;break; case REG_EBRACE: cout<<" Unmatched \\{."<<endl;break; case REG_BADBR: cout<<" Invalid contents of \\{\\}."<<endl;break; case REG_ERANGE: cout<<" Invalid range end."<<endl;break; case REG_ESPACE: cout<<" Ran out of memory."<<endl;break; case REG_BADRPT: cout<<" No preceding re for repetition op."<<endl;break; case REG_EEND: cout<<" Premature end."<<endl;break; case REG_ESIZE: cout<<" Compiled pattern bigger than 2^16 bytes."<<endl;break; case REG_ERPAREN: cout<<" Unmatched ) or \\); not returned from regcomp."<<endl;break; default: cout<<"unknown result:"<<result<<endl; } } Version-Release number of selected component (if applicable): glibc-2.2.93-5 How reproducible: Always Steps to Reproduce: 1.compile code 2.run 3. Actual Results: Outputs "Didn't find a match (for regexec)." Expected Results: Output of "Success." Additional info:
Works just fine with glibc-2.3.2-95.17 (RHEL3 U2) or 2.3.3-18 (Fedora Core 2 test2). RHL 8.0 is no longer supported FYI.
Understand RH 8.0 is no longer supported. Thought it might be worthwhile to investigate to determine if the problem was truly fixed, fixed accidentally, fixed partially, or masked. Thanks for the check on Fedora Core 2 test2. --Ron
There have been more than fifty regex fixes since November 2003 in glibc.