Bug 119224 - regcomp returns false when true is correct return
regcomp returns false when true is correct return
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-26 12:43 EST by Ronald Van Iwaarden
Modified: 2016-11-24 10:21 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-26 12:48:30 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ronald Van Iwaarden 2004-03-26 12:43:16 EST
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:
Comment 1 Jakub Jelinek 2004-03-26 12:48:30 EST
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.
Comment 2 Ronald Van Iwaarden 2004-03-26 13:46:58 EST
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
Comment 3 Jakub Jelinek 2004-03-26 13:56:44 EST
There have been more than fifty regex fixes since November 2003 in glibc.

Note You need to log in before you can comment on or make changes to this bug.