| 29 | |
| 30 | namespace { |
| 31 | std::string pcreErrorCodeToString(const int pcreExecRet) |
| 32 | { |
| 33 | switch (pcreExecRet) { |
| 34 | case PCRE_ERROR_NULL: |
| 35 | return "Either code or subject was passed as NULL, or ovector was NULL " |
| 36 | "and ovecsize was not zero (PCRE_ERROR_NULL)"; |
| 37 | case PCRE_ERROR_BADOPTION: |
| 38 | return "An unrecognized bit was set in the options argument (PCRE_ERROR_BADOPTION)"; |
| 39 | case PCRE_ERROR_BADMAGIC: |
| 40 | return "PCRE stores a 4-byte \"magic number\" at the start of the compiled code, " |
| 41 | "to catch the case when it is passed a junk pointer and to detect when a " |
| 42 | "pattern that was compiled in an environment of one endianness is run in " |
| 43 | "an environment with the other endianness. This is the error that PCRE " |
| 44 | "gives when the magic number is not present (PCRE_ERROR_BADMAGIC)"; |
| 45 | case PCRE_ERROR_UNKNOWN_NODE: |
| 46 | return "While running the pattern match, an unknown item was encountered in the " |
| 47 | "compiled pattern. This error could be caused by a bug in PCRE or by " |
| 48 | "overwriting of the compiled pattern (PCRE_ERROR_UNKNOWN_NODE)"; |
| 49 | case PCRE_ERROR_NOMEMORY: |
| 50 | return "If a pattern contains back references, but the ovector that is passed " |
| 51 | "to pcre_exec() is not big enough to remember the referenced substrings, " |
| 52 | "PCRE gets a block of memory at the start of matching to use for this purpose. " |
| 53 | "If the call via pcre_malloc() fails, this error is given. The memory is " |
| 54 | "automatically freed at the end of matching. This error is also given if " |
| 55 | "pcre_stack_malloc() fails in pcre_exec(). " |
| 56 | "This can happen only when PCRE has been compiled with " |
| 57 | "--disable-stack-for-recursion (PCRE_ERROR_NOMEMORY)"; |
| 58 | case PCRE_ERROR_NOSUBSTRING: |
| 59 | return "This error is used by the pcre_copy_substring(), pcre_get_substring(), " |
| 60 | "and pcre_get_substring_list() functions (see below). " |
| 61 | "It is never returned by pcre_exec() (PCRE_ERROR_NOSUBSTRING)"; |
| 62 | case PCRE_ERROR_MATCHLIMIT: |
| 63 | return "The backtracking limit, as specified by the match_limit field in a pcre_extra " |
| 64 | "structure (or defaulted) was reached. " |
| 65 | "See the description above (PCRE_ERROR_MATCHLIMIT)"; |
| 66 | case PCRE_ERROR_CALLOUT: |
| 67 | return "This error is never generated by pcre_exec() itself. " |
| 68 | "It is provided for use by callout functions that want to yield a distinctive " |
| 69 | "error code. See the pcrecallout documentation for details (PCRE_ERROR_CALLOUT)"; |
| 70 | case PCRE_ERROR_BADUTF8: |
| 71 | return "A string that contains an invalid UTF-8 byte sequence was passed as a subject, " |
| 72 | "and the PCRE_NO_UTF8_CHECK option was not set. If the size of the output vector " |
| 73 | "(ovecsize) is at least 2, the byte offset to the start of the the invalid UTF-8 " |
| 74 | "character is placed in the first element, and a reason code is placed in the " |
| 75 | "second element. The reason codes are listed in the following section. For " |
| 76 | "backward compatibility, if PCRE_PARTIAL_HARD is set and the problem is a truncated " |
| 77 | "UTF-8 character at the end of the subject (reason codes 1 to 5), " |
| 78 | "PCRE_ERROR_SHORTUTF8 is returned instead of PCRE_ERROR_BADUTF8"; |
| 79 | case PCRE_ERROR_BADUTF8_OFFSET: |
| 80 | return "The UTF-8 byte sequence that was passed as a subject was checked and found to " |
| 81 | "be valid (the PCRE_NO_UTF8_CHECK option was not set), but the value of " |
| 82 | "startoffset did not point to the beginning of a UTF-8 character or the end of " |
| 83 | "the subject (PCRE_ERROR_BADUTF8_OFFSET)"; |
| 84 | case PCRE_ERROR_PARTIAL: |
| 85 | return "The subject string did not match, but it did match partially. See the " |
| 86 | "pcrepartial documentation for details of partial matching (PCRE_ERROR_PARTIAL)"; |
| 87 | case PCRE_ERROR_BADPARTIAL: |
| 88 | return "This code is no longer in use. It was formerly returned when the PCRE_PARTIAL " |