Browse Source

* Patch from Alexey Torgashin for unquotechar issue 266. Fix issue #39696

Michaël Van Canneyt 3 years ago
parent
commit
96c6045023
1 changed files with 11 additions and 11 deletions
  1. 11 11
      packages/regexpr/src/regexpr.pas

+ 11 - 11
packages/regexpr/src/regexpr.pas

@@ -482,7 +482,7 @@ type
 
 
     function HexDig(Ch: REChar): integer;
     function HexDig(Ch: REChar): integer;
 
 
-    function UnQuoteChar(var APtr: PRegExprChar): REChar;
+    function UnQuoteChar(var APtr, AEnd: PRegExprChar): REChar;
 
 
     // the lowest level
     // the lowest level
     function ParseAtom(var FlagParse: integer): PRegExprChar;
     function ParseAtom(var FlagParse: integer): PRegExprChar;
@@ -817,7 +817,7 @@ uses
 const
 const
   // TRegExpr.VersionMajor/Minor return values of these constants:
   // TRegExpr.VersionMajor/Minor return values of these constants:
   REVersionMajor = 1;
   REVersionMajor = 1;
-  REVersionMinor = 153;
+  REVersionMinor = 154;
 
 
   OpKind_End = REChar(1);
   OpKind_End = REChar(1);
   OpKind_MetaClass = REChar(2);
   OpKind_MetaClass = REChar(2);
@@ -3411,7 +3411,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TRegExpr.UnQuoteChar(var APtr: PRegExprChar): REChar;
+function TRegExpr.UnQuoteChar(var APtr, AEnd: PRegExprChar): REChar;
 var
 var
   Ch: REChar;
   Ch: REChar;
 begin
 begin
@@ -3432,7 +3432,7 @@ begin
       begin // \cK => code for Ctrl+K
       begin // \cK => code for Ctrl+K
         Result := #0;
         Result := #0;
         Inc(APtr);
         Inc(APtr);
-        if APtr >= fRegexEnd then
+        if APtr >= AEnd then
           Error(reeNoLetterAfterBSlashC);
           Error(reeNoLetterAfterBSlashC);
         Ch := APtr^;
         Ch := APtr^;
         case Ch of
         case Ch of
@@ -3448,7 +3448,7 @@ begin
       begin // \x: hex char
       begin // \x: hex char
         Result := #0;
         Result := #0;
         Inc(APtr);
         Inc(APtr);
-        if APtr >= fRegexEnd then
+        if APtr >= AEnd then
         begin
         begin
           Error(reeNoHexCodeAfterBSlashX);
           Error(reeNoHexCodeAfterBSlashX);
           Exit;
           Exit;
@@ -3457,7 +3457,7 @@ begin
         begin // \x{nnnn} //###0.936
         begin // \x{nnnn} //###0.936
           repeat
           repeat
             Inc(APtr);
             Inc(APtr);
-            if APtr >= fRegexEnd then
+            if APtr >= AEnd then
             begin
             begin
               Error(reeNoHexCodeAfterBSlashX);
               Error(reeNoHexCodeAfterBSlashX);
               Exit;
               Exit;
@@ -3481,7 +3481,7 @@ begin
           Result := REChar(HexDig(APtr^));
           Result := REChar(HexDig(APtr^));
           // HexDig will cause Error if bad hex digit found
           // HexDig will cause Error if bad hex digit found
           Inc(APtr);
           Inc(APtr);
-          if APtr >= fRegexEnd then
+          if APtr >= AEnd then
           begin
           begin
             Error(reeNoHexCodeAfterBSlashX);
             Error(reeNoHexCodeAfterBSlashX);
             Exit;
             Exit;
@@ -3692,7 +3692,7 @@ begin
                 Exit;
                 Exit;
               end;
               end;
               Inc(regParse);
               Inc(regParse);
-              RangeEnd := UnQuoteChar(regParse);
+              RangeEnd := UnQuoteChar(regParse, fRegexEnd);
             end;
             end;
 
 
             // special handling for Russian range a-YA, add 2 ranges: a-ya and A-YA
             // special handling for Russian range a-YA, add 2 ranges: a-ya and A-YA
@@ -3763,7 +3763,7 @@ begin
               else
               else
               {$ENDIF}
               {$ENDIF}
               begin
               begin
-                TempChar := UnQuoteChar(regParse);
+                TempChar := UnQuoteChar(regParse, fRegexEnd);
                 // False if '-' is last char in []
                 // False if '-' is last char in []
                 DashForRange :=
                 DashForRange :=
                   (regParse + 2 < fRegexEnd) and
                   (regParse + 2 < fRegexEnd) and
@@ -4206,7 +4206,7 @@ begin
             end;
             end;
           {$ENDIF}
           {$ENDIF}
         else
         else
-          EmitExactly(UnQuoteChar(regParse));
+          EmitExactly(UnQuoteChar(regParse, fRegexEnd));
         end; { of case }
         end; { of case }
         Inc(regParse);
         Inc(regParse);
       end;
       end;
@@ -5858,7 +5858,7 @@ begin
             begin
             begin
               p := p - 1;
               p := p - 1;
               // UnquoteChar expects the escaped char under the pointer
               // UnquoteChar expects the escaped char under the pointer
-              QuotedChar := UnQuoteChar(p);
+              QuotedChar := UnQuoteChar(p, TemplateEnd);
               p := p + 1;
               p := p + 1;
               // Skip after last part of the escaped sequence - UnquoteChar stops on the last symbol of it
               // Skip after last part of the escaped sequence - UnquoteChar stops on the last symbol of it
               p0 := @QuotedChar;
               p0 := @QuotedChar;