56 #if defined(_WIN32) && !defined(PCRE_STATIC)
57 # define PCREPOSIX_EXP_DECL extern __declspec(dllexport)
58 # define PCREPOSIX_EXP_DEFN __declspec(dllexport)
73 static const int eint[] = {
160 static const char *
const pstring[] = {
163 "invalid repeat counts in {}",
168 "collation error - not relevant",
170 "bad escape sequence",
173 "bad range inside []",
174 "expression too big",
175 "failed to get memory",
176 "bad back reference",
191 const char *message, *addmessage;
192 size_t length, addlength;
194 message = (errcode >= (int)(
sizeof(pstring)/
sizeof(
char *)))?
195 "unknown error code" : pstring[errcode];
196 length = strlen(message) + 1;
198 addmessage =
" at offset ";
199 addlength = (preg != NULL && (int)preg->
re_erroffset != -1)?
200 strlen(addmessage) + 6 : 0;
204 if (addlength > 0 && errbuf_size >= length + addlength)
205 sprintf(errbuf,
"%s%s%-6d", message, addmessage, (
int)preg->
re_erroffset);
208 strncpy(errbuf, message, errbuf_size - 1);
209 errbuf[errbuf_size-1] = 0;
213 return length + addlength;
249 const char *errorptr;
271 return (errorcode <
sizeof(eint)/
sizeof(
const int))?
313 ((
regex_t *)preg)->re_erroffset = (size_t)(-1);
319 if (nosub || pmatch == NULL) nmatch = 0;
325 ovector = &(small_ovector[0]);
329 if (nmatch > INT_MAX/(
sizeof(
int) * 3))
return REG_ESPACE;
330 ovector = (
int *)malloc(
sizeof(
int) * nmatch * 3);
332 allocated_ovector =
TRUE;
343 so = pmatch[0].
rm_so;
344 eo = pmatch[0].
rm_eo;
349 eo = (int)strlen(
string);
352 rc =
pcre_exec((
const pcre *)preg->re_pcre, NULL,
string + so, (eo - so),
353 0, options, ovector, (
int)(nmatch * 3));
355 if (rc == 0) rc = (int)nmatch;
364 for (i = 0; i < (size_t)rc; i++)
366 pmatch[i].
rm_so = ovector[i*2];
367 pmatch[i].
rm_eo = ovector[i*2+1];
369 if (allocated_ovector) free(ovector);
370 for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
377 if (allocated_ovector) free(ovector);
388 case (
sizeof(eint)/
sizeof(
int) ==
ERRCOUNT):