43 |
|
|
44 |
/* Corresponding tables of PCRE error messages and POSIX error codes. */ |
/* Corresponding tables of PCRE error messages and POSIX error codes. */ |
45 |
|
|
46 |
static const char *estring[] = { |
static const char *const estring[] = { |
47 |
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10, |
ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9, ERR10, |
48 |
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20, |
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20, |
49 |
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30, |
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30, |
50 |
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40, |
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40, |
51 |
ERR41, ERR42, ERR43, ERR44 }; |
ERR41, ERR42, ERR43, ERR44 }; |
52 |
|
|
53 |
static int eint[] = { |
static const int eint[] = { |
54 |
REG_EESCAPE, /* "\\ at end of pattern" */ |
REG_EESCAPE, /* "\\ at end of pattern" */ |
55 |
REG_EESCAPE, /* "\\c at end of pattern" */ |
REG_EESCAPE, /* "\\c at end of pattern" */ |
56 |
REG_EESCAPE, /* "unrecognized character follows \\" */ |
REG_EESCAPE, /* "unrecognized character follows \\" */ |
99 |
|
|
100 |
/* Table of texts corresponding to POSIX error codes */ |
/* Table of texts corresponding to POSIX error codes */ |
101 |
|
|
102 |
static const char *pstring[] = { |
static const char *const pstring[] = { |
103 |
"", /* Dummy for value 0 */ |
"", /* Dummy for value 0 */ |
104 |
"internal error", /* REG_ASSERT */ |
"internal error", /* REG_ASSERT */ |
105 |
"invalid repeat counts in {}", /* BADBR */ |
"invalid repeat counts in {}", /* BADBR */ |
145 |
* Translate error code to string * |
* Translate error code to string * |
146 |
*************************************************/ |
*************************************************/ |
147 |
|
|
148 |
size_t |
EXPORT size_t |
149 |
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) |
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) |
150 |
{ |
{ |
151 |
const char *message, *addmessage; |
const char *message, *addmessage; |
180 |
* Free store held by a regex * |
* Free store held by a regex * |
181 |
*************************************************/ |
*************************************************/ |
182 |
|
|
183 |
void |
EXPORT void |
184 |
regfree(regex_t *preg) |
regfree(regex_t *preg) |
185 |
{ |
{ |
186 |
(pcre_free)(preg->re_pcre); |
(pcre_free)(preg->re_pcre); |
203 |
various non-zero codes on failure |
various non-zero codes on failure |
204 |
*/ |
*/ |
205 |
|
|
206 |
int |
EXPORT int |
207 |
regcomp(regex_t *preg, const char *pattern, int cflags) |
regcomp(regex_t *preg, const char *pattern, int cflags) |
208 |
{ |
{ |
209 |
const char *errorptr; |
const char *errorptr; |
236 |
block of store on the stack, to reduce the use of malloc/free. The threshold is |
block of store on the stack, to reduce the use of malloc/free. The threshold is |
237 |
in a macro that can be changed at configure time. */ |
in a macro that can be changed at configure time. */ |
238 |
|
|
239 |
int |
EXPORT int |
240 |
regexec(const regex_t *preg, const char *string, size_t nmatch, |
regexec(const regex_t *preg, const char *string, size_t nmatch, |
241 |
regmatch_t pmatch[], int eflags) |
regmatch_t pmatch[], int eflags) |
242 |
{ |
{ |
294 |
case PCRE_ERROR_BADMAGIC: return REG_INVARG; |
case PCRE_ERROR_BADMAGIC: return REG_INVARG; |
295 |
case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT; |
case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT; |
296 |
case PCRE_ERROR_NOMEMORY: return REG_ESPACE; |
case PCRE_ERROR_NOMEMORY: return REG_ESPACE; |
297 |
|
case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE; |
298 |
|
case PCRE_ERROR_BADUTF8: return REG_INVARG; |
299 |
|
case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG; |
300 |
default: return REG_ASSERT; |
default: return REG_ASSERT; |
301 |
} |
} |
302 |
} |
} |