summaryrefslogtreecommitdiff
path: root/ext/pcre/pcrelib/pcreposix.c
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2008-07-06 15:17:25 +0000
committerNuno Lopes <nlopess@php.net>2008-07-06 15:17:25 +0000
commit053dc572cae9811b28aca7e4494051bba2bcae51 (patch)
treebd19ec37ad302e591b4dfc18c5a61014a85db856 /ext/pcre/pcrelib/pcreposix.c
parent21bca5add33a7f74527d8021d99adc953124bcfa (diff)
downloadphp-git-053dc572cae9811b28aca7e4494051bba2bcae51.tar.gz
upgrade to PCRE 7.7
Diffstat (limited to 'ext/pcre/pcrelib/pcreposix.c')
-rw-r--r--ext/pcre/pcrelib/pcreposix.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c
index 4cb5e12a1b..53ea6c7231 100644
--- a/ext/pcre/pcrelib/pcreposix.c
+++ b/ext/pcre/pcrelib/pcreposix.c
@@ -124,7 +124,8 @@ static const int eint[] = {
REG_BADPAT, /* (?+ or (?- must be followed by a non-zero number */
REG_BADPAT, /* number is too big */
REG_BADPAT, /* subpattern name expected */
- REG_BADPAT /* digit expected after (?+ */
+ REG_BADPAT, /* digit expected after (?+ */
+ REG_BADPAT /* ] is an invalid data character in JavaScript compatibility mode */
};
/* Table of texts corresponding to POSIX error codes */
@@ -261,7 +262,7 @@ PCREPOSIX_EXP_DEFN int
regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{
-int rc;
+int rc, so, eo;
int options = 0;
int *ovector = NULL;
int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
@@ -294,7 +295,23 @@ else if (nmatch > 0)
}
}
-rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string),
+/* REG_STARTEND is a BSD extension, to allow for non-NUL-terminated strings.
+The man page from OS X says "REG_STARTEND affects only the location of the
+string, not how it is matched". That is why the "so" value is used to bump the
+start location rather than being passed as a PCRE "starting offset". */
+
+if ((eflags & REG_STARTEND) != 0)
+ {
+ so = pmatch[0].rm_so;
+ eo = pmatch[0].rm_eo;
+ }
+else
+ {
+ so = 0;
+ eo = strlen(string);
+ }
+
+rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),
0, options, ovector, nmatch * 3);
if (rc == 0) rc = nmatch; /* All captured slots were filled in */