From 41e85bc36abb7f1bf7589b1fe96528172835390d Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 19 Sep 2011 01:04:56 +0000 Subject: [PATCH] compiler: - emit ansistring constants with compiler codepage if no codepage is explicitly set - set default compiler codepage to default system codepage (delphi compatible) + tests git-svn-id: trunk@19145 - --- .gitattributes | 2 ++ compiler/asmutils.pas | 2 ++ compiler/globals.pas | 2 ++ tests/test/tcpstr10.pp | 12 ++++++++++++ tests/test/tcpstr9.pp | 13 +++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 tests/test/tcpstr10.pp create mode 100644 tests/test/tcpstr9.pp diff --git a/.gitattributes b/.gitattributes index 1a1f816810..97d0003606 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9938,6 +9938,7 @@ tests/test/tconstref2.pp svneol=native#text/pascal tests/test/tconstref3.pp svneol=native#text/pascal tests/test/tconstref4.pp svneol=native#text/pascal tests/test/tcpstr1.pp svneol=native#text/plain +tests/test/tcpstr10.pp svneol=native#text/pascal tests/test/tcpstr2.pp svneol=native#text/plain tests/test/tcpstr2a.pp svneol=native#text/plain tests/test/tcpstr3.pp svneol=native#text/plain @@ -9946,6 +9947,7 @@ tests/test/tcpstr5.pp svneol=native#text/plain tests/test/tcpstr6.pp svneol=native#text/plain tests/test/tcpstr7.pp svneol=native#text/plain tests/test/tcpstr8.pp svneol=native#text/pascal +tests/test/tcpstr9.pp svneol=native#text/pascal tests/test/tcpstransistr2shortstring.pp svneol=native#text/plain tests/test/tcpstransistr2widechararray.pp svneol=native#text/plain tests/test/tcpstransistrcompare.pp svneol=native#text/plain diff --git a/compiler/asmutils.pas b/compiler/asmutils.pas index f7e7e0112f..69697acca6 100644 --- a/compiler/asmutils.pas +++ b/compiler/asmutils.pas @@ -59,6 +59,8 @@ uses current_asmdata.getdatalabel(referencelab); list.concat(tai_label.create(referencelab)); end; + if encoding=CP_NONE then + encoding:=current_settings.sourcecodepage; list.concat(tai_const.create_16bit(encoding)); list.concat(tai_const.create_16bit(1)); {$ifdef cpu64bitaddr} diff --git a/compiler/globals.pas b/compiler/globals.pas index 786c1a13c2..fffbb8e254 100644 --- a/compiler/globals.pas +++ b/compiler/globals.pas @@ -1532,6 +1532,8 @@ implementation init_settings:=default_settings; if init_settings.optimizecputype=cpu_none then init_settings.optimizecputype:=init_settings.cputype; + { Compiler codepage should be default system codepage } + init_settings.sourcecodepage:=DefaultSystemCodePage; LinkLibraryAliases :=TLinkStrMap.Create; LinkLibraryOrder :=TLinkStrMap.Create; diff --git a/tests/test/tcpstr10.pp b/tests/test/tcpstr10.pp new file mode 100644 index 0000000000..e6be16f268 --- /dev/null +++ b/tests/test/tcpstr10.pp @@ -0,0 +1,12 @@ +program tcpstr10; +{$apptype console} +{$codepage cp866} +begin + if StringCodePage('test') <> 866 then + begin + WriteLn(StringCodePage('test'), ' <> ', 866); + halt(1); + end; + Writeln('ok'); +end. + diff --git a/tests/test/tcpstr9.pp b/tests/test/tcpstr9.pp new file mode 100644 index 0000000000..39bead4798 --- /dev/null +++ b/tests/test/tcpstr9.pp @@ -0,0 +1,13 @@ +program tcpstr9; +{$apptype console} +begin + // this test can be only run with the compiler built right now on the + // same system + if StringCodePage('test') <> DefaultSystemCodePage then + begin + WriteLn(StringCodePage('test'), ' <> ', DefaultSystemCodePage); + halt(1); + end; + Writeln('ok'); +end. +