Bug 16216 - PCRE error codes should be removed
Summary: PCRE error codes should be removed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-30 18:12 PST by Eric Seidel (no email)
Modified: 2011-07-21 19:08 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-11-30 18:12:42 PST
PCRE error codes should be removed and replaced with extern const char* variables which expose the error strings directly (under nice variable names)

10 points to anyone who can figure out what errorText is trying to do in under 30 seconds:

/* Error code numbers. They are given names so that they can more easily be
tracked. */

enum ErrorCode {
    ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
    ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17
};

/* The texts of compile-time error messages. These are "char *" because they
are passed to the outside world. */

static const char* error_text(ErrorCode code)
{
    static const char error_texts[] =
      /* 1 */
      "\\ at end of pattern\0"
      "\\c at end of pattern\0"
      "character value in \\x{...} sequence is too large\0"
      "numbers out of order in {} quantifier\0"
      /* 5 */
      "number too big in {} quantifier\0"
      "missing terminating ] for character class\0"
      "internal error: code overflow\0"
      "range out of order in character class\0"
      "nothing to repeat\0"
      /* 10 */
      "unmatched parentheses\0"
      "internal error: unexpected repeat\0"
      "unrecognized character after (?\0"
      "failed to get memory\0"
      "missing )\0"
      /* 15 */
      "reference to non-existent subpattern\0"
      "regular expression too large\0"
      "parentheses nested too deeply"
    ;

    int i = code;
    const char* text = error_texts;
    while (i > 1)
        i -= !*text++;
    return text;
}
Comment 1 Gavin Barraclough 2011-07-21 19:08:57 PDT
PCRE has been removed entirely!