瀏覽代碼

* don't stop at #0 characters for setstring with pchar either

git-svn-id: trunk@13828 -
Jonas Maebe 16 年之前
父節點
當前提交
be39c47d02
共有 3 個文件被更改,包括 14 次插入16 次删除
  1. 1 7
      rtl/inc/ustrings.inc
  2. 1 9
      rtl/inc/wstrings.inc
  3. 12 0
      tests/webtbs/tw14740.pp

+ 1 - 7
rtl/inc/ustrings.inc

@@ -1660,13 +1660,7 @@ var
 begin
   SetLength(S,Len);
   If (Buf<>Nil) and (Len>0) then
-    begin
-      BufLen := IndexByte(Buf^, Len+1, 0);
-      If (BufLen>0) and (BufLen < Len) then
-        Len := BufLen;
-      widestringmanager.Ansi2UnicodeMoveProc(Buf,S,Len);
-      //PUnicodeChar(Pointer(S)+Len*sizeof(UnicodeChar))^:=#0;
-    end;
+    widestringmanager.Ansi2UnicodeMoveProc(Buf,S,Len);
 end;
 
 

+ 1 - 9
rtl/inc/wstrings.inc

@@ -1025,18 +1025,10 @@ end;
 
 
 Procedure SetString (Out S : WideString; Buf : PChar; Len : SizeInt);
-var
-  BufLen: SizeInt;
 begin
   SetLength(S,Len);
   If (Buf<>Nil) and (Len>0) then
-    begin
-      BufLen := IndexByte(Buf^, Len+1, 0);
-      If (BufLen>0) and (BufLen < Len) then
-        Len := BufLen;
-      widestringmanager.Ansi2WideMoveProc(Buf,S,Len);
-      //PWideChar(Pointer(S)+Len*sizeof(WideChar))^:=#0;
-    end;
+    widestringmanager.Ansi2WideMoveProc(Buf,S,Len);
 end;
 
 

+ 12 - 0
tests/webtbs/tw14740.pp

@@ -3,14 +3,26 @@ var
   u: unicodestring;
   pw: pwidechar;
   pu: punicodechar;
+  p: pchar;
 begin
   pw:='abc'#0'def';
   setstring(w,pw,7);
   if w<>'abc'#0'def' then
     halt(1);
+  w:='';
 
   pu:='abc'#0'def';
   setstring(u,pu,7);
   if u<>'abc'#0'def' then
     halt(2);
+  u:='';
+
+  p:='abc'#0'def';
+  setstring(w,p,7);
+  if w<>'abc'#0'def' then
+    halt(3);
+
+  setstring(u,p,7);
+  if u<>'abc'#0'def' then
+    halt(4);
 end.