| 1817 |
it's anchored. However, if this is a multiline pattern, then only OP_SOD |
it's anchored. However, if this is a multiline pattern, then only OP_SOD |
| 1818 |
counts, since OP_CIRC can match in the middle. |
counts, since OP_CIRC can match in the middle. |
| 1819 |
|
|
| 1820 |
A branch is also implicitly anchored if it starts with .* because that will try |
A branch is also implicitly anchored if it starts with .* and DOTALL is set, |
| 1821 |
the rest of the pattern at all possible matching points, so there is no point |
because that will try the rest of the pattern at all possible matching points, |
| 1822 |
trying them again. |
so there is no point trying them again. |
| 1823 |
|
|
| 1824 |
Arguments: |
Arguments: |
| 1825 |
code points to start of expression (the bracket) |
code points to start of expression (the bracket) |
| 1837 |
register int op = *scode; |
register int op = *scode; |
| 1838 |
if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) |
if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) |
| 1839 |
{ if (!is_anchored(scode, options)) return FALSE; } |
{ if (!is_anchored(scode, options)) return FALSE; } |
| 1840 |
else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR) |
else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) && |
| 1841 |
|
(*options & PCRE_DOTALL) != 0) |
| 1842 |
{ if (scode[1] != OP_ANY) return FALSE; } |
{ if (scode[1] != OP_ANY) return FALSE; } |
| 1843 |
else if (op != OP_SOD && |
else if (op != OP_SOD && |
| 1844 |
((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC)) |
((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC)) |
| 1852 |
|
|
| 1853 |
|
|
| 1854 |
/************************************************* |
/************************************************* |
| 1855 |
* Check for start with \n line expression * |
* Check for starting with ^ or .* * |
| 1856 |
*************************************************/ |
*************************************************/ |
| 1857 |
|
|
| 1858 |
/* This is called for multiline expressions to try to find out if every branch |
/* This is called to find out if every branch starts with ^ or .* so that |
| 1859 |
starts with ^ so that "first char" processing can be done to speed things up. |
"first char" processing can be done to speed things up in multiline |
| 1860 |
|
matching and for non-DOTALL patterns that start with .* (which must start at |
| 1861 |
|
the beginning or after \n). |
| 1862 |
|
|
| 1863 |
Argument: points to start of expression (the bracket) |
Argument: points to start of expression (the bracket) |
| 1864 |
Returns: TRUE or FALSE |
Returns: TRUE or FALSE |
| 1872 |
register int op = *scode; |
register int op = *scode; |
| 1873 |
if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) |
if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) |
| 1874 |
{ if (!is_startline(scode)) return FALSE; } |
{ if (!is_startline(scode)) return FALSE; } |
| 1875 |
|
else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR) |
| 1876 |
|
{ if (scode[1] != OP_ANY) return FALSE; } |
| 1877 |
else if (op != OP_CIRC) return FALSE; |
else if (op != OP_CIRC) return FALSE; |
| 1878 |
code += (code[1] << 8) + code[2]; |
code += (code[1] << 8) + code[2]; |
| 1879 |
} |
} |
| 2551 |
return NULL; |
return NULL; |
| 2552 |
} |
} |
| 2553 |
|
|
| 2554 |
/* If the anchored option was not passed, set flag if we can determine that it |
/* If the anchored option was not passed, set flag if we can determine that the |
| 2555 |
is anchored by virtue of ^ characters or \A or anything else. Otherwise, see if |
pattern is anchored by virtue of ^ characters or \A or anything else (such as |
| 2556 |
we can determine what the first character has to be, because that speeds up |
starting with .* when DOTALL is set). |
| 2557 |
unanchored matches no end. In the case of multiline matches, an alternative is |
|
| 2558 |
to set the PCRE_STARTLINE flag if all branches start with ^. */ |
Otherwise, see if we can determine what the first character has to be, because |
| 2559 |
|
that speeds up unanchored matches no end. If not, see if we can set the |
| 2560 |
|
PCRE_STARTLINE flag. This is helpful for multiline matches when all branches |
| 2561 |
|
start with ^. and also when all branches start with .* for non-DOTALL matches. |
| 2562 |
|
*/ |
| 2563 |
|
|
| 2564 |
if ((options & PCRE_ANCHORED) == 0) |
if ((options & PCRE_ANCHORED) == 0) |
| 2565 |
{ |
{ |