Sfoglia il codice sorgente

Merged revisions 8317 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r8317 | yury | 2007-08-28 12:53:29 +0300 (Вт, 28 авг 2007) | 2 lines

* Fixed fpc_WideCharArray_To_WideStr in case if widechar array contains empty string.
+ Test.
........

git-svn-id: branches/fixes_2_2@8318 -

yury 18 anni fa
parent
commit
158a0f3a34
3 ha cambiato i file con 16 aggiunte e 3 eliminazioni
  1. 1 0
      .gitattributes
  2. 1 3
      rtl/inc/wstrings.inc
  3. 14 0
      tests/tbs/tb0541.pp

+ 1 - 0
.gitattributes

@@ -6216,6 +6216,7 @@ tests/tbs/tb0533.pp svneol=native#text/plain
 tests/tbs/tb0534.pp svneol=native#text/plain
 tests/tbs/tb0534.pp svneol=native#text/plain
 tests/tbs/tb0535.pp svneol=native#text/plain
 tests/tbs/tb0535.pp svneol=native#text/plain
 tests/tbs/tb0540.pp svneol=native#text/x-pascal
 tests/tbs/tb0540.pp svneol=native#text/x-pascal
+tests/tbs/tb0541.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 1 - 3
rtl/inc/wstrings.inc

@@ -695,9 +695,7 @@ begin
   else
   else
     i := high(arr)+1;
     i := high(arr)+1;
   SetLength(fpc_WideCharArray_To_WideStr,i);
   SetLength(fpc_WideCharArray_To_WideStr,i);
-  Move(pwidechar(@arr)^, PWideChar(Pointer(@fpc_WideCharArray_To_WideStr[1]))^,i*sizeof(WideChar));
-  { Terminating Zero }
-  PWideChar(Pointer(@fpc_WideCharArray_To_WideStr[1])+i*sizeof(WideChar))^:=#0;
+  Move(arr[0], Pointer(fpc_WideCharArray_To_WideStr)^,i*sizeof(WideChar));
 end;
 end;
 
 
 {$ifndef FPC_STRTOCHARARRAYPROC}
 {$ifndef FPC_STRTOCHARARRAYPROC}

+ 14 - 0
tests/tbs/tb0541.pp

@@ -0,0 +1,14 @@
+const
+  TestStr: widestring = 'Test';
+
+var
+  buf: array[0..10] of widechar;
+  s: widestring;
+
+begin
+  Move(TestStr[1], buf[0], (Length(TestStr) + 1)*SizeOf(widechar));
+  s:=buf;
+  writeln(s);
+  buf[0]:=#0;
+  s:=buf;
+end.