Bläddra i källkod

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 -

paul 14 år sedan
förälder
incheckning
41e85bc36a
5 ändrade filer med 31 tillägg och 0 borttagningar
  1. 2 0
      .gitattributes
  2. 2 0
      compiler/asmutils.pas
  3. 2 0
      compiler/globals.pas
  4. 12 0
      tests/test/tcpstr10.pp
  5. 13 0
      tests/test/tcpstr9.pp

+ 2 - 0
.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

+ 2 - 0
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}

+ 2 - 0
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;

+ 12 - 0
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.
+

+ 13 - 0
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.
+