Details

[Home]

Issue of the Standard # S0555

Brief

The difference between error codes REG_EBRACE and REG_BADBR for regcomp() function is not clearly defined.

Detailed Description

The description of the regcomp() function does not fully define the function’s return value when basic regular expression has error - “\{“”\}” imbalance, when there’re more “\{“ than “\}”. Example: a\{\{3,4\} The return value of regcomp() for this basic regular expression is not clearly defined because regular expression has two errors: “\{“”\}” slash brace imbalance and content of "\{\}" invalid (because the next character after the first “\{“ not digit) – hence regcomp() can possibly return either REG_EBRACE or REG_BADBR error code. Example of regular expression containing error: a\{\{3,4\} For error codes described in section ERRORS there’s a special note (section 2.3 Error Numbers): If more than one error occurs in processing a function call, any one of the possible errors may be returned, as the order of detection is undefined. However, there is no reason to apply this note for error codes returned by regcomp().

Problem location(s) in the standard

The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition (SUS 3.0), Chapter 9. Regular Expressions, the description of the <nobr>regcomp()</nobr> function.

Possible solutions

Add a note: If more than one error occurs in processing a function call, any one of the possible constants may be returned, as the order of detection is undefined. Or define clearly what must be the return value of regcomp() in case when there’re more “\{“ than “\}”.

[Home]