浏览代码

* Fixed bug #9221.
+ Test.

git-svn-id: trunk@7975 -

yury 18 年之前
父节点
当前提交
55d6a37865
共有 3 个文件被更改,包括 18 次插入3 次删除
  1. 1 0
      .gitattributes
  2. 4 3
      rtl/inc/wstrings.inc
  3. 13 0
      tests/webtbs/tw9221.pp

+ 1 - 0
.gitattributes

@@ -8325,6 +8325,7 @@ tests/webtbs/tw9179.pp svneol=native#text/plain
 tests/webtbs/tw9187.pp svneol=native#text/plain
 tests/webtbs/tw9190.pp svneol=native#text/plain
 tests/webtbs/tw9209.pp svneol=native#text/plain
+tests/webtbs/tw9221.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 4 - 3
rtl/inc/wstrings.inc

@@ -984,9 +984,10 @@ begin
         end;
       { Force nil termination in case it gets shorter }
       PWord(Pointer(S)+l*sizeof(WideChar))^:=0;
-{$ifndef FPC_WINLIKEWIDESTRING}
-      PWideRec(Pointer(S)-WideFirstOff)^.Len:=l*sizeof(WideChar);
-{$endif FPC_WINLIKEWIDESTRING}
+{$ifdef MSWINDOWS}
+      if not winwidestringalloc then
+{$endif MSWINDOWS}
+        PWideRec(Pointer(S)-WideFirstOff)^.Len:=l*sizeof(WideChar);
     end
   else
     begin

+ 13 - 0
tests/webtbs/tw9221.pp

@@ -0,0 +1,13 @@
+{%target=win32,win64}
+
+var
+  s: widestring;
+begin
+  winwidestringalloc:=false;
+  s:='1234';
+  SetLength(s, 10);
+  if Length(s) <> 10 then begin
+    writeln('Test failed!');
+    Halt(1);
+  end;
+end.