Permalink
Browse files

disable double quotes for TExprParserMatch

(it was not working anway)
  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Jan 8, 2019
1 parent b83b46c commit 109733121cb53ef073797f58deddca06811625de
Showing with 12 additions and 20 deletions.
  1. +1 −1 SynSelfTests.pas
  2. +10 −18 SynTable.pas
  3. +1 −1 SynopseCommit.inc
@@ -3155,7 +3155,7 @@ procedure TTestLowLevelCommon._TExprParserMatch;
['2', '5 2 3 4 1', '2 3', '41', '4 3', '3 5', '1 4 5']);
Test('1-(4&(5+6))', ['1', '1 2 3', '2 1', '1 4', '1 5', '1 6'],
['2', '5 2 3 4 1', '2 3', '41', '4 3', '3 5', '1 4 5', '1 4 6']);
Test('1-(4&("57"+6))', ['1', '1 2 3', '2 1', '1 4', '1 57', '1 6'],
Test('1 - ( 4 & ( 57 + 6 ) )', ['1', '1 2 3', '2 1', '1 4', '1 57', '1 6'],
['2', '57 2 3 4 1', '2 3', '41', '4 3', '3 5"7', '1 4 57', '1 4 6']);
finally
s.Free;
@@ -2218,8 +2218,6 @@ TExprNodeWordClass = class of TExprNodeWordAbstract;
// - searched expressions can use parenthesis and &=AND -=WITHOUT +=OR operators,
// e.g. '((w1 & w2) - w3) + w4' means ((w1 and w2) without w3) or w4
// - no operator is handled like a AND, e.g. 'w1 w2' = 'w1 & w2'
// - matching words should have no space nor & + - ( ) characters, or should
// be double-quotes-espaced as in SQL ('"one two" + "one ""two"" three"')
TExprParserAbstract = class(TSynPersistent)
protected
fWordClass: TExprNodeWordClass;
@@ -2234,7 +2232,7 @@ TExprParserAbstract = class(TSynPersistent)
function ParseExpr: TExprNode;
function ParseFactor: TExprNode;
function ParseTerm: TExprNode;
// may be overriden to provide custom escaping
// may be overriden to provide custom words escaping (e.g. handle quotes)
procedure ParseNextWord; virtual;
procedure Clear; virtual;
/// perform the expression search, calling virtual TExprNodeWord.Found
@@ -8259,13 +8257,9 @@ procedure TExprParserAbstract.ParseNextWord;
P: PUTF8Char;
begin
P := fCurrent;
if P^ = '"' then // unescape double quotes "" within text
P := UnQuoteSQLStringVar(P, fCurrentWord)
else begin
while not(P^ in STOPCHAR) do
inc(P);
SetString(fCurrentWord, PAnsiChar(fCurrent), P - fCurrent);
end;
while not(P^ in STOPCHAR) do
inc(P);
SetString(fCurrentWord, PAnsiChar(fCurrent), P - fCurrent);
fCurrent := P;
end;

@@ -8386,9 +8380,7 @@ function TExprParserAbstract.Found: boolean;
case n.NodeType of
entWord: begin
st^ := TExprNodeWordAbstract(n).Found;
if st = @fFoundStack[high(fFoundStack)] then
exit; // avoid buffer overflow
inc(st);
inc(st); // see eprTooManyParenthesis above to avoid buffer overflow
end;
entNot:
PAnsiChar(st)[-1] := AnsiChar(ord(PAnsiChar(st)[-1]) xor 1);
@@ -8463,6 +8455,11 @@ procedure TExprParserMatch.Clear;
const // rough estimation
IS_UTF8_WORD: TSynAnsicharSet = ['0' .. '9', 'A' .. 'Z', 'a' .. 'z', #$80 ..#$ff];

function TExprParserMatch.Search(const aText: RawUTF8): boolean;
begin
result := Search(pointer(aText), length(aText));
end;

procedure InitFast(m: PExprParserMatchOne; n: PtrInt);
begin
repeat
@@ -8517,11 +8514,6 @@ function TExprParserMatch.Search(aText: PUTF8Char; aTextLen: PtrInt): boolean;
result := Found;
end;

function TExprParserMatch.Search(const aText: RawUTF8): boolean;
begin
result := Search(pointer(aText), length(aText));
end;



initialization
@@ -1 +1 @@
'1.18.4945'
'1.18.4946'

0 comments on commit 1097331

Please sign in to comment.