summaryrefslogtreecommitdiff
path: root/pcre.c
diff options
context:
space:
mode:
authornigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:38:33 +0000
committernigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:38:33 +0000
commitc046fc1dd3ac4d0ab9f6c77951877746f0aabbdb (patch)
tree52fa6c90399536e750f2b028e4fab76fc43778df /pcre.c
parent9dc6505b56ff9ba2f87071990a26a109dcbfa322 (diff)
downloadpcre-c046fc1dd3ac4d0ab9f6c77951877746f0aabbdb.tar.gz
Load pcre-1.08 into code/trunk.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@19 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre.c')
-rw-r--r--pcre.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/pcre.c b/pcre.c
index 25daa07..bbfcf9c 100644
--- a/pcre.c
+++ b/pcre.c
@@ -623,6 +623,7 @@ compile_branch(int options, int *brackets, uschar **codeptr,
int repeat_type, op_type;
int repeat_min, repeat_max;
int bravalue, length;
+int greedy_default, greedy_non_default;
register int c;
register uschar *code = *codeptr;
const uschar *ptr = *ptrptr;
@@ -630,6 +631,11 @@ const uschar *oldptr;
uschar *previous = NULL;
uschar class[32];
+/* Set up the default and non-default settings for greediness */
+
+greedy_default = ((options & PCRE_UNGREEDY) != 0);
+greedy_non_default = greedy_default ^ 1;
+
/* Switch on next character until the end of the branch */
for (;; ptr++)
@@ -907,10 +913,13 @@ for (;; ptr++)
goto FAILED;
}
- /* If the next character is '?' this is a minimizing repeat. Advance to the
+ /* If the next character is '?' this is a minimizing repeat, by default,
+ but if PCRE_UNGREEDY is set, it works the other way round. Advance to the
next character. */
- if (ptr[1] == '?') { repeat_type = 1; ptr++; } else repeat_type = 0;
+ if (ptr[1] == '?')
+ { repeat_type = greedy_non_default; ptr++; }
+ else repeat_type = greedy_default;
/* If the maximum is zero then the minimum must also be zero; Perl allows
this case, so we do too - by simply omitting the item altogether. */
@@ -1149,6 +1158,8 @@ for (;; ptr++)
case 'm':
case 's':
case 'x':
+ case 'U':
+ case 'X':
ptr++;
while (*ptr != ')') ptr++;
previous = NULL;
@@ -1752,7 +1763,7 @@ while ((c = *(++ptr)) != 0)
ptr += 2;
break;
}
- /* Else fall thourh */
+ /* Else fall through */
/* Else loop setting valid options until ) is met. Anything else is an
error. */
@@ -1782,6 +1793,16 @@ while ((c = *(++ptr)) != 0)
length -= spaces; /* Already counted spaces */
continue;
}
+ else if (c == 'X')
+ {
+ options |= PCRE_EXTRA;
+ continue;
+ }
+ else if (c == 'U')
+ {
+ options |= PCRE_UNGREEDY;
+ continue;
+ }
else if (c == ')') break;
*errorptr = ERR12;
@@ -1987,14 +2008,15 @@ printf("Length = %d top_bracket = %d top_backref=%d\n",
if (re->options != 0)
{
- printf("%s%s%s%s%s%s%s\n",
+ printf("%s%s%s%s%s%s%s%s\n",
((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",
((re->options & PCRE_CASELESS) != 0)? "caseless " : "",
((re->options & PCRE_EXTENDED) != 0)? "extended " : "",
((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",
((re->options & PCRE_DOTALL) != 0)? "dotall " : "",
((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",
- ((re->options & PCRE_EXTRA) != 0)? "extra " : "");
+ ((re->options & PCRE_EXTRA) != 0)? "extra " : "",
+ ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : "");
}
if ((re->options & PCRE_FIRSTSET) != 0)