Browse Source

merge r17438 from cpstrnew branch by michael:
* Applied patch from Inoussa to fix copy of unicode string

git-svn-id: trunk@19112 -

paul 14 years ago
parent
commit
f8b5920f31
3 changed files with 11 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      rtl/inc/ustrings.inc
  3. 9 0
      tests/test/tunistrcopy.pp

+ 1 - 0
.gitattributes

@@ -10528,6 +10528,7 @@ tests/test/tunistr4.pp svneol=native#text/plain
 tests/test/tunistr5.pp svneol=native#text/plain
 tests/test/tunistr6.pp svneol=native#text/plain
 tests/test/tunistr7.pp svneol=native#text/plain
+tests/test/tunistrcopy.pp svneol=native#text/plain
 tests/test/tunit1.pp svneol=native#text/plain
 tests/test/tunit2.pp svneol=native#text/plain
 tests/test/tunit3.pp svneol=native#text/plain

+ 1 - 1
rtl/inc/ustrings.inc

@@ -1585,7 +1585,7 @@ begin
      if ResultAddress<>Nil then
       begin
         Move (PUnicodeChar(S)[Index],ResultAddress^,Size*sizeof(UnicodeChar));
-        PUnicodeRec(ResultAddress-UnicodeFirstOff)^.Len:=Size*sizeof(UnicodeChar);
+        PUnicodeRec(ResultAddress-UnicodeFirstOff)^.Len:=Size;
         PUnicodeChar(ResultAddress+Size*sizeof(UnicodeChar))^:=#0;
       end;
    end;

+ 9 - 0
tests/test/tunistrcopy.pp

@@ -0,0 +1,9 @@
+var
+  a, b : UnicodeString;
+begin
+  a := '12345';
+  b := Copy(a,1,Length(a));
+  if (a <> b) then
+    Halt(1);
+  WriteLn('ok');
+end.