diff options
author | Andrei Zmievski <andrei@php.net> | 2003-12-16 22:20:30 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2003-12-16 22:20:30 +0000 |
commit | 9fc9e4b2cf6f71f130ad080ea8a0924ec3732b62 (patch) | |
tree | 50329fc541100f6beccfc10b36a748365cde7081 /ext/pcre/pcrelib/pcreposix.c | |
parent | e9fb9a7fa75b7e8c0381c85628741ec27f2874a9 (diff) | |
download | php-git-9fc9e4b2cf6f71f130ad080ea8a0924ec3732b62.tar.gz |
MFB
Diffstat (limited to 'ext/pcre/pcrelib/pcreposix.c')
-rw-r--r-- | ext/pcre/pcrelib/pcreposix.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c index 49094f280d..856c97b4ae 100644 --- a/ext/pcre/pcrelib/pcreposix.c +++ b/ext/pcre/pcrelib/pcreposix.c @@ -43,14 +43,14 @@ restrictions: /* Corresponding tables of PCRE error messages and POSIX error codes. */ -static const char *estring[] = { +static const char *const estring[] = { ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40, - ERR41, ERR42, ERR43 }; + ERR41, ERR42, ERR43, ERR44 }; -static int eint[] = { +static const int eint[] = { REG_EESCAPE, /* "\\ at end of pattern" */ REG_EESCAPE, /* "\\c at end of pattern" */ REG_EESCAPE, /* "unrecognized character follows \\" */ @@ -93,12 +93,13 @@ static int eint[] = { REG_BADPAT, /* "recursive call could loop indefinitely" */ REG_BADPAT, /* "unrecognized character after (?P" */ REG_BADPAT, /* "syntax error after (?P" */ - REG_BADPAT /* "two named groups have the same name" */ + REG_BADPAT, /* "two named groups have the same name" */ + REG_BADPAT /* "invalid UTF-8 string" */ }; /* Table of texts corresponding to POSIX error codes */ -static const char *pstring[] = { +static const char *const pstring[] = { "", /* Dummy for value 0 */ "internal error", /* REG_ASSERT */ "invalid repeat counts in {}", /* BADBR */ @@ -144,7 +145,7 @@ return REG_ASSERT; * Translate error code to string * *************************************************/ -size_t +EXPORT size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) { const char *message, *addmessage; @@ -179,7 +180,7 @@ return length + addlength; * Free store held by a regex * *************************************************/ -void +EXPORT void regfree(regex_t *preg) { (pcre_free)(preg->re_pcre); @@ -202,7 +203,7 @@ Returns: 0 on success various non-zero codes on failure */ -int +EXPORT int regcomp(regex_t *preg, const char *pattern, int cflags) { const char *errorptr; @@ -217,7 +218,7 @@ preg->re_erroffset = erroffset; if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr); -preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL); +preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL); return 0; } @@ -235,7 +236,7 @@ ints. However, if the number of possible capturing brackets is small, use a block of store on the stack, to reduce the use of malloc/free. The threshold is in a macro that can be changed at configure time. */ -int +EXPORT int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) { @@ -264,8 +265,8 @@ if (nmatch > 0) } } -rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options, - ovector, nmatch * 3); +rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string), + 0, options, ovector, nmatch * 3); if (rc == 0) rc = nmatch; /* All captured slots were filled in */ @@ -293,6 +294,9 @@ else case PCRE_ERROR_BADMAGIC: return REG_INVARG; case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT; case PCRE_ERROR_NOMEMORY: return REG_ESPACE; + case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE; + case PCRE_ERROR_BADUTF8: return REG_INVARG; + case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG; default: return REG_ASSERT; } } |