fcl-passrc: fixed resolve string lit on non utf-8 system

This commit is contained in:
mattias 2020-12-28 18:19:58 +00:00
parent dc85b9283f
commit 917aba3de2
2 changed files with 10 additions and 5 deletions

View File

@ -4203,6 +4203,7 @@ var
{$ENDIF}
begin
if h='' then exit;
//writeln('AddSrc ',length(h),' ',ord(h[1]),' ',stringcodepage(h),' ',defaultsystemcodepage);
{$ifdef FPC_HAS_CPSTRING}
OnlyASCII:=true;
for i:=1 to length(h) do
@ -4238,9 +4239,14 @@ var
RaiseNotYetImplemented(20201220222608,Expr);
else
begin
if Value.OnlyASCII and (Value.S<>'') then
SetCodePage(Value.S,TargetCP,false);
Value.S:=Value.S+h;
if Value.S<>'' then
begin
if Value.OnlyASCII then
SetCodePage(Value.S,TargetCP,false);
Value.S:=Value.S+h;
end else begin
Value.S:=h;
end;
end;
end;

View File

@ -2180,6 +2180,7 @@ begin
Result.OnFindUnit:=@OnPasResolverFindUnit;
Result.OnLog:=@OnPasResolverLog;
Result.Hub:=Hub;
Result.ExprEvaluator.DefaultStringCodePage:=CP_UTF8;
Result.ExprEvaluator.DefaultSourceCodePage:=CP_UTF8;
FModules.Add(Result);
end;
@ -14306,7 +14307,6 @@ end;
procedure TTestResolver.TestStaticArrayOfChar;
begin
ResolverEngine.ExprEvaluator.DefaultStringCodePage:=CP_UTF8;
StartProgram(false);
Add([
'type',
@ -14328,7 +14328,6 @@ end;
procedure TTestResolver.TestStaticArrayOfCharDelphi;
begin
ResolverEngine.ExprEvaluator.DefaultStringCodePage:=CP_UTF8;
StartProgram(false);
Add([
'{$mode delphi}',