浏览代码

compiler: don't return te_eual when we convert from RawByteString to another codepage

git-svn-id: trunk@19283 -
paul 14 年之前
父节点
当前提交
a769ef0ad2
共有 5 个文件被更改,包括 28 次插入3 次删除
  1. 1 0
      .gitattributes
  2. 0 1
      compiler/defcmp.pas
  3. 1 1
      rtl/inc/astrings.inc
  4. 1 1
      rtl/inc/compproc.inc
  5. 25 0
      tests/test/tcpstr13.pp

+ 1 - 0
.gitattributes

@@ -9956,6 +9956,7 @@ tests/test/tcpstr1.pp svneol=native#text/plain
 tests/test/tcpstr10.pp svneol=native#text/pascal
 tests/test/tcpstr10.pp svneol=native#text/pascal
 tests/test/tcpstr11.pp svneol=native#text/pascal
 tests/test/tcpstr11.pp svneol=native#text/pascal
 tests/test/tcpstr12.pp svneol=native#text/pascal
 tests/test/tcpstr12.pp svneol=native#text/pascal
+tests/test/tcpstr13.pp svneol=native#text/pascal
 tests/test/tcpstr2.pp svneol=native#text/plain
 tests/test/tcpstr2.pp svneol=native#text/plain
 tests/test/tcpstr2a.pp svneol=native#text/plain
 tests/test/tcpstr2a.pp svneol=native#text/plain
 tests/test/tcpstr3.pp svneol=native#text/plain
 tests/test/tcpstr3.pp svneol=native#text/plain

+ 0 - 1
compiler/defcmp.pas

@@ -355,7 +355,6 @@ implementation
                              (tstringdef(def_from).stringtype=st_ansistring) then 
                              (tstringdef(def_from).stringtype=st_ansistring) then 
                       begin
                       begin
                         if (tstringdef(def_from).encoding=tstringdef(def_to).encoding) or
                         if (tstringdef(def_from).encoding=tstringdef(def_to).encoding) or
-                           (tstringdef(def_from).encoding=globals.CP_NONE) or
                            (tstringdef(def_to).encoding=globals.CP_NONE) then
                            (tstringdef(def_to).encoding=globals.CP_NONE) then
                          begin
                          begin
                            //doconv := tc_string_2_string;
                            //doconv := tc_string_2_string;

+ 1 - 1
rtl/inc/astrings.inc

@@ -931,7 +931,7 @@ begin
      move(S[1],(pointer(S)+ofs)^,strlength+1)
      move(S[1],(pointer(S)+ofs)^,strlength+1)
 end;
 end;
 
 
-Function Fpc_Ansistr_Copy (Const S : RawByteString; Index,Size : SizeInt) : AnsiString;compilerproc;
+Function Fpc_Ansistr_Copy (Const S : RawByteString; Index,Size : SizeInt) : RawByteString;compilerproc;
 var
 var
   ResultAddress : Pointer;
   ResultAddress : Pointer;
 begin
 begin

+ 1 - 1
rtl/inc/compproc.inc

@@ -290,7 +290,7 @@ Procedure fpc_AnsiStr_CheckRange(p : Pointer; index : SizeInt); compilerproc;
 {$endif VER2_4}
 {$endif VER2_4}
 
 
 Procedure fpc_AnsiStr_SetLength (Var S : RawByteString; l : SizeInt{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
 Procedure fpc_AnsiStr_SetLength (Var S : RawByteString; l : SizeInt{$ifdef FPC_HAS_CPSTRING};cp : TSystemCodePage{$endif FPC_HAS_CPSTRING}); compilerproc;
-Function  fpc_ansistr_Copy (Const S : RawByteString; Index,Size : SizeInt) : AnsiString;compilerproc;
+Function  fpc_ansistr_Copy (Const S : RawByteString; Index,Size : SizeInt) : RawByteString;compilerproc;
 {$ifdef EXTRAANSISHORT}
 {$ifdef EXTRAANSISHORT}
 Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): SizeInt; compilerproc;
 Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): SizeInt; compilerproc;
 {$endif EXTRAANSISHORT}
 {$endif EXTRAANSISHORT}

+ 25 - 0
tests/test/tcpstr13.pp

@@ -0,0 +1,25 @@
+program tcpstr13;
+
+// check that copy operation converts from 866 to DefaultSystemCodePage encoding
+
+{$mode delphi}
+
+{$ifdef unix}
+uses
+  cwstring;
+{$endif}
+
+type
+  ts866 = type ansistring(866);
+
+var
+  s: ts866;
+  a: ansistring;
+begin
+  s:='abc'#$00A9#$00AE'123';
+//  if s[4] <> 'c' then
+//    halt(1);
+  a:=copy(s,1,4);
+  if stringcodepage(a)<>DefaultSystemCodePage then
+    halt(2);
+end.