Browse Source

Fix bug #34117, more clear hexdig

git-svn-id: trunk@39610 -
michael 7 years ago
parent
commit
134b5553c3
1 changed files with 8 additions and 9 deletions
  1. 8 9
      packages/regexpr/src/regexpr.pas

+ 8 - 9
packages/regexpr/src/regexpr.pas

@@ -2105,17 +2105,16 @@ function TRegExpr.ParseAtom (var flagp : integer) : PRegExprChar;
   end;
 
  function HexDig (ch : REChar) : PtrInt;
+
   begin
-   Result := 0;
-   if (ch >= 'a') and (ch <= 'f')
-    then ch := REChar (ord (ch) - (ord ('a') - ord ('A')));
-   if (ch < '0') or (ch > 'F') or ((ch > '9') and (ch < 'A')) then begin
+   Result := Ord(Ch);
+   Case Result of
+     Ord('A')..Ord('F') : Result:=10+Result-Ord('A');
+     Ord('a')..Ord('f') : Result:=10+Result-Ord('a');
+     Ord('0')..Ord('9') : Result:=Result-Ord('0');
+   else
      Error (reeBadHexDigit);
-     EXIT;
-    end;
-   Result := ord (ch) - ord ('0');
-   if ch >= 'A'
-    then Result := Result - (ord ('A') - ord ('9') - 1);
+   end;
   end;
 
  function EmitRange (AOpCode : REChar) : PRegExprChar;