Browse Source

* Copy() with WideChar array or PWideChar parameter should use fpc_unicodestr_copy compilerproc, since fpc_widestr_copy is available only on Windows. Bug #14307.
+ test.

git-svn-id: trunk@13511 -

yury 16 năm trước cách đây
mục cha
commit
6a6a6a6e6f
3 tập tin đã thay đổi với 23 bổ sung4 xóa
  1. 1 0
      .gitattributes
  2. 4 4
      compiler/pinline.pas
  3. 18 0
      tests/webtbs/tw14307.pp

+ 1 - 0
.gitattributes

@@ -9224,6 +9224,7 @@ tests/webtbs/tw14155.pp svneol=native#text/plain
 tests/webtbs/tw1416.pp svneol=native#text/plain
 tests/webtbs/tw14174.pp svneol=native#text/plain
 tests/webtbs/tw1430.pp svneol=native#text/plain
+tests/webtbs/tw14307.pp svneol=native#text/plain
 tests/webtbs/tw1433.pp svneol=native#text/plain
 tests/webtbs/tw1445.pp svneol=native#text/plain
 tests/webtbs/tw1450.pp svneol=native#text/plain

+ 4 - 4
compiler/pinline.pas

@@ -719,12 +719,12 @@ implementation
             is_pchar(paradef)) then
           copynode:=ccallnode.createintern('fpc_ansistr_copy',paras)
         else
-         if is_widestring(paradef) or
-            is_widechararray(paradef) or
-            is_pwidechar(paradef) then
+         if is_widestring(paradef) then
            copynode:=ccallnode.createintern('fpc_widestr_copy',paras)
         else
-         if is_unicodestring(paradef) then
+         if is_unicodestring(paradef) or
+            is_widechararray(paradef) or
+            is_pwidechar(paradef) then
            copynode:=ccallnode.createintern('fpc_unicodestr_copy',paras)
         else
          if is_char(paradef) then

+ 18 - 0
tests/webtbs/tw14307.pp

@@ -0,0 +1,18 @@
+var
+  buf: array[0..3] of widechar;
+  s: string;
+
+begin
+  buf[0]:='A';
+  buf[1]:='B';
+  buf[2]:='C';
+  buf[3]:=#0;
+
+  s:=Copy(buf, 2, MaxInt);
+  if s = 'BC' then
+    writeln('OK')
+  else begin
+    writeln('FAILED: ', s);
+    Halt(1);
+  end;
+end.