mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-01 19:19:15 +02:00
pastojs: fixed reading #$00xx as widechar, bug #34923
git-svn-id: trunk@41046 -
This commit is contained in:
parent
6ad69d0ab9
commit
792858eab8
@ -3953,12 +3953,12 @@ function TResExprEvaluator.EvalPrimitiveExprString(Expr: TPrimitiveExpr
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure AddHash(u: longword);
|
||||
procedure AddHash(u: longword; ForceUTF16: boolean);
|
||||
{$ifdef FPC_HAS_CPSTRING}
|
||||
var
|
||||
h: RawByteString;
|
||||
begin
|
||||
if (u>255) and (Result.Kind=revkString) then
|
||||
if ((u>255) or (ForceUTF16)) and (Result.Kind=revkString) then
|
||||
begin
|
||||
// switch to unicodestring
|
||||
h:=TResEvalString(Result).S;
|
||||
@ -4060,11 +4060,11 @@ begin
|
||||
begin
|
||||
// split into two
|
||||
dec(u,$10000);
|
||||
AddHash($D800+(u shr 10));
|
||||
AddHash($DC00+(u and $3ff));
|
||||
AddHash($D800+(u shr 10),true);
|
||||
AddHash($DC00+(u and $3ff),true);
|
||||
end
|
||||
else
|
||||
AddHash(u);
|
||||
AddHash(u,p-StartP>2);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -4084,7 +4084,7 @@ begin
|
||||
end;
|
||||
if p=StartP then
|
||||
RaiseInternalError(20170523123806);
|
||||
AddHash(u);
|
||||
AddHash(u,false);
|
||||
end;
|
||||
end;
|
||||
'^':
|
||||
@ -4095,8 +4095,8 @@ begin
|
||||
RaiseInternalError(20181016121520);
|
||||
c:=S[p];
|
||||
case c of
|
||||
'a'..'z': AddHash(ord(c)-ord('a')+1);
|
||||
'A'..'Z': AddHash(ord(c)-ord('A')+1);
|
||||
'a'..'z': AddHash(ord(c)-ord('a')+1,false);
|
||||
'A'..'Z': AddHash(ord(c)-ord('A')+1,false);
|
||||
else RaiseInternalError(20170523123809);
|
||||
end;
|
||||
inc(p);
|
||||
|
@ -6315,33 +6315,35 @@ begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'const',
|
||||
' c: char = ''1'';',
|
||||
'begin',
|
||||
' c:=#0;',
|
||||
' c:=#1;',
|
||||
' c:=#9;',
|
||||
' c:=#10;',
|
||||
' c:=#13;',
|
||||
' c:=#31;',
|
||||
' c:=#32;',
|
||||
' c:=#$A;',
|
||||
' c:=#$0A;',
|
||||
' c:=#$b;',
|
||||
' c:=#$0b;',
|
||||
' c:=^A;',
|
||||
' c:=''"'';',
|
||||
' c:=default(char);',
|
||||
' c:=#$00E4;', // ä
|
||||
' c:=''ä'';',
|
||||
' c:=#$E4;', // ä
|
||||
' c:=#$D800;', // invalid UTF-16
|
||||
' c:=#$DFFF;', // invalid UTF-16
|
||||
' c:=#$FFFF;', // last UCS-2
|
||||
' c:=high(c);', // last UCS-2
|
||||
'']);
|
||||
' a = #$00F3;',
|
||||
' c: char = ''1'';',
|
||||
'begin',
|
||||
' c:=#0;',
|
||||
' c:=#1;',
|
||||
' c:=#9;',
|
||||
' c:=#10;',
|
||||
' c:=#13;',
|
||||
' c:=#31;',
|
||||
' c:=#32;',
|
||||
' c:=#$A;',
|
||||
' c:=#$0A;',
|
||||
' c:=#$b;',
|
||||
' c:=#$0b;',
|
||||
' c:=^A;',
|
||||
' c:=''"'';',
|
||||
' c:=default(char);',
|
||||
' c:=#$00E4;', // ä
|
||||
' c:=''ä'';',
|
||||
' c:=#$E4;', // ä
|
||||
' c:=#$D800;', // invalid UTF-16
|
||||
' c:=#$DFFF;', // invalid UTF-16
|
||||
' c:=#$FFFF;', // last UCS-2
|
||||
' c:=high(c);', // last UCS-2
|
||||
'']);
|
||||
ConvertProgram;
|
||||
CheckSource('TestCharConst',
|
||||
LinesToStr([
|
||||
'this.a="ó";',
|
||||
'this.c="1";'
|
||||
]),
|
||||
LinesToStr([
|
||||
@ -6452,6 +6454,8 @@ begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'{$H+}',
|
||||
'const',
|
||||
' a = #$00F3#$017C;', // first <256, then >=256
|
||||
'var',
|
||||
' s: string = ''abc'';',
|
||||
'begin',
|
||||
@ -6471,6 +6475,7 @@ begin
|
||||
ConvertProgram;
|
||||
CheckSource('TestStringConst',
|
||||
LinesToStr([
|
||||
'this.a = "óż";',
|
||||
'this.s="abc";'
|
||||
]),
|
||||
LinesToStr([
|
||||
|
Loading…
Reference in New Issue
Block a user