2014-03-07 18:28:52 +01:00
|
|
|
/*************************************************
|
|
|
|
* Perl-Compatible Regular Expressions *
|
|
|
|
*************************************************/
|
|
|
|
|
|
|
|
/* PCRE is a library of functions to support regular expressions whose syntax
|
|
|
|
and semantics are as close as possible to those of the Perl 5 language.
|
|
|
|
|
|
|
|
Written by Philip Hazel
|
|
|
|
Original API code Copyright (c) 1997-2012 University of Cambridge
|
2017-03-12 14:47:01 +01:00
|
|
|
New API code Copyright (c) 2016-2017 University of Cambridge
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the University of Cambridge nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pcre2_internal.h"
|
|
|
|
|
2014-05-20 20:48:43 +02:00
|
|
|
#define STRING(a) # a
|
|
|
|
#define XSTRING(s) STRING(s)
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
/* The texts of compile-time error messages. Compile-time error numbers start
|
2014-06-14 20:29:51 +02:00
|
|
|
at COMPILE_ERROR_BASE (100).
|
|
|
|
|
2015-08-10 18:17:10 +02:00
|
|
|
This used to be a table of strings, but in order to reduce the number of
|
|
|
|
relocations needed when a shared library is loaded dynamically, it is now one
|
|
|
|
long string. We cannot use a table of offsets, because the lengths of inserts
|
|
|
|
such as XSTRING(MAX_NAME_SIZE) are not known. Instead,
|
2014-06-21 14:39:48 +02:00
|
|
|
pcre2_get_error_message() counts through to the one it wants - this isn't a
|
|
|
|
performance issue because these strings are used only when there is an error.
|
2014-05-20 20:48:43 +02:00
|
|
|
|
|
|
|
Each substring ends with \0 to insert a null character. This includes the final
|
|
|
|
substring, so that the whole string ends with \0\0, which can be detected when
|
|
|
|
counting through. */
|
|
|
|
|
2016-02-16 11:23:06 +01:00
|
|
|
static const unsigned char compile_error_texts[] =
|
2014-05-20 20:48:43 +02:00
|
|
|
"no error\0"
|
|
|
|
"\\ at end of pattern\0"
|
|
|
|
"\\c at end of pattern\0"
|
|
|
|
"unrecognized character follows \\\0"
|
|
|
|
"numbers out of order in {} quantifier\0"
|
|
|
|
/* 5 */
|
|
|
|
"number too big in {} quantifier\0"
|
|
|
|
"missing terminating ] for character class\0"
|
|
|
|
"invalid escape sequence in character class\0"
|
|
|
|
"range out of order in character class\0"
|
2015-01-28 18:31:11 +01:00
|
|
|
"quantifier does not follow a repeatable item\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 10 */
|
|
|
|
"internal error: unexpected repeat\0"
|
|
|
|
"unrecognized character after (? or (?-\0"
|
|
|
|
"POSIX named classes are supported only within a class\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"POSIX collating elements are not supported\0"
|
|
|
|
"missing closing parenthesis\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 15 */
|
|
|
|
"reference to non-existent subpattern\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"pattern passed as NULL\0"
|
2015-04-13 19:29:05 +02:00
|
|
|
"unrecognised compile-time option bit(s)\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"missing ) after (?# comment\0"
|
|
|
|
"parentheses are too deeply nested\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 20 */
|
|
|
|
"regular expression is too large\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"failed to allocate heap memory\0"
|
|
|
|
"unmatched closing parenthesis\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"internal error: code overflow\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"missing closing parenthesis for condition\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 25 */
|
|
|
|
"lookbehind assertion is not fixed length\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"a relative value of zero is not allowed\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"conditional group contains more than two branches\0"
|
2015-03-20 13:37:28 +01:00
|
|
|
"assertion expected after (?( or (?(?C)\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"digit expected after (?+ or (?-\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 30 */
|
|
|
|
"unknown POSIX class name\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"internal error in pcre2_study(): should not occur\0"
|
2014-11-12 17:57:56 +01:00
|
|
|
"this version of PCRE2 does not have Unicode support\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"parentheses are too deeply nested (stack check)\0"
|
|
|
|
"character code point value in \\x{} or \\o{} is too large\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 35 */
|
2016-10-02 18:01:01 +02:00
|
|
|
"lookbehind is too complicated\0"
|
2016-06-20 20:14:51 +02:00
|
|
|
"\\C is not allowed in a lookbehind assertion in UTF-" XSTRING(PCRE2_CODE_UNIT_WIDTH) " mode\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"number after (?C is greater than 255\0"
|
|
|
|
"closing parenthesis for (?C expected\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 40 */
|
2015-08-30 19:47:36 +02:00
|
|
|
"invalid escape sequence in (*VERB) name\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"unrecognized character after (?P\0"
|
|
|
|
"syntax error in subpattern name (missing terminator)\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"two named subpatterns have the same name (PCRE2_DUPNAMES not set)\0"
|
|
|
|
"group name must start with a non-digit\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 45 */
|
2014-11-12 17:57:56 +01:00
|
|
|
"this version of PCRE2 does not have support for \\P, \\p, or \\X\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"malformed \\P or \\p sequence\0"
|
|
|
|
"unknown property name after \\P or \\p\0"
|
|
|
|
"subpattern name is too long (maximum " XSTRING(MAX_NAME_SIZE) " characters)\0"
|
|
|
|
"too many named subpatterns (maximum " XSTRING(MAX_NAME_COUNT) ")\0"
|
|
|
|
/* 50 */
|
2014-06-21 14:39:48 +02:00
|
|
|
"invalid range in character class\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"octal value is greater than \\377 in 8-bit non-UTF-8 mode\0"
|
|
|
|
"internal error: overran compiling workspace\0"
|
|
|
|
"internal error: previously-checked referenced subpattern not found\0"
|
|
|
|
"DEFINE group contains more than one branch\0"
|
|
|
|
/* 55 */
|
2014-06-21 14:39:48 +02:00
|
|
|
"missing opening brace after \\o\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"internal error: unknown newline setting\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"(?R (recursive pattern call) must be followed by a closing parenthesis\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)\0"
|
|
|
|
/* 60 */
|
|
|
|
"(*VERB) not recognized or malformed\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"group number is too big\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"subpattern name expected\0"
|
2016-11-04 17:35:47 +01:00
|
|
|
"internal error: parsed pattern overflow\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"non-octal character in \\o{} (closing brace missing?)\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 65 */
|
|
|
|
"different names for subpatterns of the same number are not allowed\0"
|
|
|
|
"(*MARK) must have an argument\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"non-hex character in \\x{} (closing brace missing?)\0"
|
2015-06-18 18:39:25 +02:00
|
|
|
#ifndef EBCDIC
|
2014-07-24 18:32:38 +02:00
|
|
|
"\\c must be followed by a printable ASCII character\0"
|
2015-06-18 18:39:25 +02:00
|
|
|
#else
|
2015-06-13 18:10:14 +02:00
|
|
|
"\\c must be followed by a letter or one of [\\]^_?\0"
|
|
|
|
#endif
|
2014-05-20 20:48:43 +02:00
|
|
|
"\\k is not followed by a braced, angle-bracketed, or quoted name\0"
|
|
|
|
/* 70 */
|
2016-10-02 18:01:01 +02:00
|
|
|
"internal error: unknown meta code in check_lookbehinds()\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"\\N is not supported in a class\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"callout string is too long\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"disallowed Unicode code point (>= 0xd800 && <= 0xdfff)\0"
|
2014-07-24 18:32:38 +02:00
|
|
|
"using UTF is disabled by the application\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
/* 75 */
|
2014-07-24 18:32:38 +02:00
|
|
|
"using UCP is disabled by the application\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"
|
2014-06-21 14:39:48 +02:00
|
|
|
"character code point value in \\u.... sequence is too large\0"
|
2014-08-26 13:46:21 +02:00
|
|
|
"digits missing in \\x{} or \\o{}\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
"syntax error or number too big in (?(VERSION condition\0"
|
2015-02-20 12:20:40 +01:00
|
|
|
/* 80 */
|
2015-02-06 17:47:15 +01:00
|
|
|
"internal error: unknown opcode in auto_possessify()\0"
|
2015-03-11 18:44:16 +01:00
|
|
|
"missing terminating delimiter for callout with string argument\0"
|
|
|
|
"unrecognized string delimiter follows (?C\0"
|
2015-04-13 19:29:05 +02:00
|
|
|
"using \\C is disabled by the application\0"
|
2015-06-18 18:39:25 +02:00
|
|
|
"(?| and/or (?J: or (?x: parentheses are too deeply nested\0"
|
2015-10-17 15:50:56 +02:00
|
|
|
/* 85 */
|
|
|
|
"using \\C is disabled in this PCRE2 library\0"
|
2015-11-03 18:38:00 +01:00
|
|
|
"regular expression is too complicated\0"
|
|
|
|
"lookbehind assertion is too long\0"
|
2015-11-05 18:33:39 +01:00
|
|
|
"pattern string is longer than the limit set by the application\0"
|
2017-01-16 18:40:47 +01:00
|
|
|
"internal error: unknown code in parsed pattern\0"
|
2016-10-02 18:01:01 +02:00
|
|
|
/* 90 */
|
2017-01-16 18:40:47 +01:00
|
|
|
"internal error: bad code value in parsed_skip()\0"
|
2017-06-15 18:41:44 +02:00
|
|
|
"PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowed in UTF-16 mode\0"
|
|
|
|
"invalid option bits with PCRE2_LITERAL\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
;
|
|
|
|
|
2014-06-14 20:29:51 +02:00
|
|
|
/* Match-time and UTF error texts are in the same format. */
|
2014-05-20 20:48:43 +02:00
|
|
|
|
2016-02-16 11:23:06 +01:00
|
|
|
static const unsigned char match_error_texts[] =
|
2014-05-20 20:48:43 +02:00
|
|
|
"no error\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"no match\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"partial match\0"
|
|
|
|
"UTF-8 error: 1 byte missing at end\0"
|
|
|
|
"UTF-8 error: 2 bytes missing at end\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 5 */
|
2014-06-14 20:29:51 +02:00
|
|
|
"UTF-8 error: 3 bytes missing at end\0"
|
|
|
|
"UTF-8 error: 4 bytes missing at end\0"
|
|
|
|
"UTF-8 error: 5 bytes missing at end\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"UTF-8 error: byte 2 top bits not 0x80\0"
|
|
|
|
"UTF-8 error: byte 3 top bits not 0x80\0"
|
|
|
|
/* 10 */
|
|
|
|
"UTF-8 error: byte 4 top bits not 0x80\0"
|
|
|
|
"UTF-8 error: byte 5 top bits not 0x80\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"UTF-8 error: byte 6 top bits not 0x80\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"UTF-8 error: 5-byte character is not allowed (RFC 3629)\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"UTF-8 error: 6-byte character is not allowed (RFC 3629)\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 15 */
|
2014-08-05 18:51:32 +02:00
|
|
|
"UTF-8 error: code points greater than 0x10ffff are not defined\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"UTF-8 error: code points 0xd800-0xdfff are not defined\0"
|
|
|
|
"UTF-8 error: overlong 2-byte sequence\0"
|
|
|
|
"UTF-8 error: overlong 3-byte sequence\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"UTF-8 error: overlong 4-byte sequence\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 20 */
|
2014-06-14 20:29:51 +02:00
|
|
|
"UTF-8 error: overlong 5-byte sequence\0"
|
|
|
|
"UTF-8 error: overlong 6-byte sequence\0"
|
2015-11-27 16:58:44 +01:00
|
|
|
"UTF-8 error: isolated byte with 0x80 bit set\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"UTF-8 error: illegal byte (0xfe or 0xff)\0"
|
|
|
|
"UTF-16 error: missing low surrogate at end\0"
|
|
|
|
/* 25 */
|
|
|
|
"UTF-16 error: invalid low surrogate\0"
|
|
|
|
"UTF-16 error: isolated low surrogate\0"
|
2014-08-05 18:51:32 +02:00
|
|
|
"UTF-32 error: code points 0xd800-0xdfff are not defined\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"UTF-32 error: code points greater than 0x10ffff are not defined\0"
|
2014-09-19 09:43:39 +02:00
|
|
|
"bad data value\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 30 */
|
2015-01-23 17:51:47 +01:00
|
|
|
"patterns do not all use the same character tables\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"magic number missing\0"
|
|
|
|
"pattern compiled in wrong mode: 8/16/32-bit error\0"
|
|
|
|
"bad offset value\0"
|
|
|
|
"bad option value\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 35 */
|
2014-11-11 11:19:23 +01:00
|
|
|
"invalid replacement string\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"bad offset into UTF string\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
"callout error code\0" /* Never returned by PCRE2 itself */
|
2014-06-14 20:29:51 +02:00
|
|
|
"invalid data in workspace for DFA restart\0"
|
|
|
|
"too much recursion for DFA matching\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 40 */
|
2014-12-14 18:17:06 +01:00
|
|
|
"backreference condition or recursion test is not supported for DFA matching\0"
|
|
|
|
"function is not supported for DFA matching\0"
|
|
|
|
"pattern contains an item that is not supported for DFA matching\0"
|
2014-06-14 20:29:51 +02:00
|
|
|
"workspace size exceeded in DFA matching\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"internal error - pattern overwritten?\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 45 */
|
2014-12-14 18:17:06 +01:00
|
|
|
"bad JIT option\0"
|
2014-11-11 11:19:23 +01:00
|
|
|
"JIT stack limit reached\0"
|
2014-05-20 20:48:43 +02:00
|
|
|
"match limit exceeded\0"
|
|
|
|
"no more memory\0"
|
2014-12-13 18:43:26 +01:00
|
|
|
"unknown substring\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
/* 50 */
|
2014-12-14 18:17:06 +01:00
|
|
|
"non-unique substring name\0"
|
2014-11-11 11:19:23 +01:00
|
|
|
"NULL argument passed\0"
|
2014-10-31 13:34:34 +01:00
|
|
|
"nested recursion at the same subject position\0"
|
2017-03-12 14:47:01 +01:00
|
|
|
"matching depth limit exceeded\0"
|
2014-12-19 10:55:25 +01:00
|
|
|
"requested value is not available\0"
|
2015-10-07 19:32:48 +02:00
|
|
|
/* 55 */
|
2014-10-20 19:28:49 +02:00
|
|
|
"requested value is not set\0"
|
2015-10-07 19:32:48 +02:00
|
|
|
"offset limit set without PCRE2_USE_OFFSET_LIMIT\0"
|
|
|
|
"bad escape sequence in replacement string\0"
|
|
|
|
"expected closing curly bracket in replacement string\0"
|
2015-11-03 18:38:00 +01:00
|
|
|
"bad substitution in replacement string\0"
|
|
|
|
/* 60 */
|
|
|
|
"match with end before start is not supported\0"
|
2015-12-17 19:44:06 +01:00
|
|
|
"too many replacements (more than INT_MAX)\0"
|
2016-06-17 13:30:27 +02:00
|
|
|
"bad serialized data\0"
|
2017-05-06 18:19:39 +02:00
|
|
|
"heap limit exceeded\0"
|
|
|
|
"invalid syntax\0"
|
2014-10-20 19:28:49 +02:00
|
|
|
;
|
2014-05-20 20:48:43 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Return error message *
|
|
|
|
*************************************************/
|
|
|
|
|
2014-10-20 19:28:49 +02:00
|
|
|
/* This function copies an error message into a buffer whose units are of an
|
|
|
|
appropriate width. Error numbers are positive for compile-time errors, and
|
|
|
|
negative for match-time errors (except for UTF errors), but the numbers are all
|
2014-06-14 20:29:51 +02:00
|
|
|
distinct.
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
Arguments:
|
|
|
|
enumber error number
|
|
|
|
buffer where to put the message (zero terminated)
|
2017-03-21 18:46:21 +01:00
|
|
|
size size of the buffer in code units
|
2014-10-20 19:28:49 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
Returns: length of message if all is well
|
2014-05-20 20:48:43 +02:00
|
|
|
negative on error
|
2014-10-20 19:28:49 +02:00
|
|
|
*/
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
2016-10-15 11:21:12 +02:00
|
|
|
pcre2_get_error_message(int enumber, PCRE2_UCHAR *buffer, PCRE2_SIZE size)
|
2014-03-07 18:28:52 +01:00
|
|
|
{
|
2016-02-16 11:23:06 +01:00
|
|
|
const unsigned char *message;
|
2016-10-15 11:21:12 +02:00
|
|
|
PCRE2_SIZE i;
|
2016-02-16 11:23:06 +01:00
|
|
|
int n;
|
2014-05-20 20:48:43 +02:00
|
|
|
|
|
|
|
if (size == 0) return PCRE2_ERROR_NOMEMORY;
|
|
|
|
|
2016-06-17 13:30:27 +02:00
|
|
|
if (enumber >= COMPILE_ERROR_BASE) /* Compile error */
|
2014-05-20 20:48:43 +02:00
|
|
|
{
|
|
|
|
message = compile_error_texts;
|
2014-10-20 19:28:49 +02:00
|
|
|
n = enumber - COMPILE_ERROR_BASE;
|
|
|
|
}
|
2016-06-17 13:30:27 +02:00
|
|
|
else if (enumber < 0) /* Match or UTF error */
|
2014-05-20 20:48:43 +02:00
|
|
|
{
|
|
|
|
message = match_error_texts;
|
2014-10-20 19:28:49 +02:00
|
|
|
n = -enumber;
|
|
|
|
}
|
2016-06-17 13:30:27 +02:00
|
|
|
else /* Invalid error number */
|
|
|
|
{
|
|
|
|
message = (unsigned char *)"\0"; /* Empty message list */
|
|
|
|
n = 1;
|
|
|
|
}
|
2014-10-20 19:28:49 +02:00
|
|
|
|
2014-05-20 20:48:43 +02:00
|
|
|
for (; n > 0; n--)
|
|
|
|
{
|
2017-05-26 19:14:36 +02:00
|
|
|
while (*message++ != CHAR_NUL) {};
|
|
|
|
if (*message == CHAR_NUL) return PCRE2_ERROR_BADDATA;
|
2014-10-20 19:28:49 +02:00
|
|
|
}
|
2014-03-07 18:28:52 +01:00
|
|
|
|
|
|
|
for (i = 0; *message != 0; i++)
|
|
|
|
{
|
|
|
|
if (i >= size - 1)
|
|
|
|
{
|
|
|
|
buffer[i] = 0; /* Terminate partial message */
|
2014-05-20 20:48:43 +02:00
|
|
|
return PCRE2_ERROR_NOMEMORY;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
buffer[i] = *message++;
|
|
|
|
}
|
2014-10-20 19:28:49 +02:00
|
|
|
|
2014-03-07 18:28:52 +01:00
|
|
|
buffer[i] = 0;
|
2016-02-16 11:23:06 +01:00
|
|
|
return (int)i;
|
2014-03-07 18:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of pcre2_error.c */
|