Support manual callout with string argument at start of condition.

This commit is contained in:
Philip.Hazel 2015-03-12 17:00:18 +00:00
parent e43b3d435b
commit baf08a3d37
5 changed files with 181 additions and 31 deletions

View File

@ -5219,9 +5219,39 @@ for (;; ptr++)
if (ptr[1] == CHAR_QUESTION_MARK && ptr[2] == CHAR_C)
{
for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break;
if (ptr[i] == CHAR_RIGHT_PARENTHESIS)
tempptr += i + 1;
if (IS_DIGIT(ptr[3]) || ptr[3] == CHAR_RIGHT_PARENTHESIS)
{
for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break;
if (ptr[i] == CHAR_RIGHT_PARENTHESIS)
tempptr += i + 1;
}
else
{
uint32_t delimiter = 0;
for (i = 0; PRIV(callout_start_delims)[i] != 0; i++)
{
if (ptr[3] == PRIV(callout_start_delims)[i])
{
delimiter = PRIV(callout_end_delims)[i];
break;
}
}
if (delimiter != 0)
{
for (i = 4; ptr + i < cb->end_pattern; i++)
{
if (ptr[i] == delimiter)
{
if (ptr[i+1] == delimiter) i++;
else
{
if (ptr[i+1] == CHAR_RIGHT_PARENTHESIS) tempptr += i + 2;
break;
}
}
}
}
}
}
/* For conditions that are assertions, check the syntax, and then exit

8
testdata/testinput2 vendored
View File

@ -4210,4 +4210,12 @@ a random value. /Ix
/(?:a(?C`code`)){3}/B
/^(?(?C25)(?=abc)abcd|xyz)/B
abcdefg
xyz123
/^(?(?C$abc$)(?=abc)abcd|xyz)/B
abcdefg
xyz123
# End of testinput2

8
testdata/testinput6 vendored
View File

@ -4827,4 +4827,12 @@
/^a(b)c(?C{AB})def/B
abcdef\=callout_capture
/^(?(?C25)(?=abc)abcd|xyz)/B
abcdefg
xyz123
/^(?(?C$abc$)(?=abc)abcd|xyz)/B
abcdefg
xyz123
# End of testinput6

52
testdata/testoutput2 vendored
View File

@ -14094,4 +14094,56 @@ Callout: {AB} last capture = 1
End
------------------------------------------------------------------
/^(?(?C25)(?=abc)abcd|xyz)/B
------------------------------------------------------------------
Bra
^
Cond
Callout 25 9 7
Assert
abc
Ket
abcd
Alt
xyz
Ket
Ket
End
------------------------------------------------------------------
abcdefg
--->abcdefg
25 ^ (?=abc)
0: abcd
xyz123
--->xyz123
25 ^ (?=abc)
0: xyz
/^(?(?C$abc$)(?=abc)abcd|xyz)/B
------------------------------------------------------------------
Bra
^
Cond
CalloutStr $abc$ 12 7
Assert
abc
Ket
abcd
Alt
xyz
Ket
Ket
End
------------------------------------------------------------------
abcdefg
Callout: $abc$
--->abcdefg
^ (?=abc)
0: abcd
xyz123
Callout: $abc$
--->xyz123
^ (?=abc)
0: xyz
# End of testinput2

52
testdata/testoutput6 vendored
View File

@ -7835,4 +7835,56 @@ Callout: {AB} last capture = 0
^ ^ d
0: abcdef
/^(?(?C25)(?=abc)abcd|xyz)/B
------------------------------------------------------------------
Bra
^
Cond
Callout 25 9 7
Assert
abc
Ket
abcd
Alt
xyz
Ket
Ket
End
------------------------------------------------------------------
abcdefg
--->abcdefg
25 ^ (?=abc)
0: abcd
xyz123
--->xyz123
25 ^ (?=abc)
0: xyz
/^(?(?C$abc$)(?=abc)abcd|xyz)/B
------------------------------------------------------------------
Bra
^
Cond
CalloutStr $abc$ 12 7
Assert
abc
Ket
abcd
Alt
xyz
Ket
Ket
End
------------------------------------------------------------------
abcdefg
Callout: $abc$
--->abcdefg
^ (?=abc)
0: abcd
xyz123
Callout: $abc$
--->xyz123
^ (?=abc)
0: xyz
# End of testinput6