فهرست منبع

* small change to r24997: also use the {$modeswitch unicodestrings} state to
determine whether (wide)char->pchar will be preferred over (wide)char ->
p(wide)char or not (always convert to pchar if mode switch is not active,
otherwise always to pwidechar). Delphi-compatible + consistent with the
behaviour added for constant strings in that revision + tests

git-svn-id: branches/cpstrrtl@25430 -

Jonas Maebe 12 سال پیش
والد
کامیت
f539e9158a
7فایلهای تغییر یافته به همراه96 افزوده شده و 1 حذف شده
  1. 5 0
      .gitattributes
  2. 1 1
      compiler/defcmp.pas
  3. 18 0
      tests/test/tcpstr26.pp
  4. 18 0
      tests/test/tcpstr26a.pp
  5. 18 0
      tests/test/tcpstr26b.pp
  6. 18 0
      tests/test/tcpstr26c.pp
  7. 18 0
      tests/test/tcpstr26d.pp

+ 5 - 0
.gitattributes

@@ -11009,6 +11009,11 @@ tests/test/tcpstr22.pp svneol=native#text/pascal
 tests/test/tcpstr23.pp svneol=native#text/pascal
 tests/test/tcpstr24.pp svneol=native#text/plain
 tests/test/tcpstr25.pp svneol=native#text/plain
+tests/test/tcpstr26.pp svneol=native#text/plain
+tests/test/tcpstr26a.pp svneol=native#text/plain
+tests/test/tcpstr26b.pp svneol=native#text/plain
+tests/test/tcpstr26c.pp svneol=native#text/plain
+tests/test/tcpstr26d.pp svneol=native#text/plain
 tests/test/tcpstr2a.pp svneol=native#text/plain
 tests/test/tcpstr3.pp svneol=native#text/plain
 tests/test/tcpstr4.pp svneol=native#text/plain

+ 1 - 1
compiler/defcmp.pas

@@ -1178,7 +1178,7 @@ implementation
                            (is_pchar(def_to) or is_pwidechar(def_to)) then
                          begin
                            doconv:=tc_cchar_2_pchar;
-                           if is_char(def_from)=is_pchar(def_to) then
+                           if is_pwidechar(def_to)=(m_default_unicodestring in current_settings.modeswitches) then
                              eq:=te_convert_l1
                            else
                              eq:=te_convert_l2

+ 18 - 0
tests/test/tcpstr26.pp

@@ -0,0 +1,18 @@
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+procedure test(p: pchar); overload;
+begin
+  writeln('pchar');
+end;
+
+procedure test(p: pwidechar); overload;
+begin
+  writeln('pwidechar');
+  halt(1);
+end;
+
+begin
+  test('a');
+end.

+ 18 - 0
tests/test/tcpstr26a.pp

@@ -0,0 +1,18 @@
+{$ifdef fpc}
+{$mode delphiunicode}
+{$endif}
+
+procedure test(p: pansichar); overload;
+begin
+  writeln('pchar');
+  halt(1);
+end;
+
+procedure test(p: pwidechar); overload;
+begin
+  writeln('pwidechar');
+end;
+
+begin
+  test('a');
+end.

+ 18 - 0
tests/test/tcpstr26b.pp

@@ -0,0 +1,18 @@
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+procedure test(p: pansichar); overload;
+begin
+  writeln('pchar');
+end;
+
+procedure test(p: pwidechar); overload;
+begin
+  writeln('pwidechar');
+  halt(1);
+end;
+
+begin
+  test(#$1234);
+end.

+ 18 - 0
tests/test/tcpstr26c.pp

@@ -0,0 +1,18 @@
+{$ifdef fpc}
+{$mode delphiunicode}
+{$endif}
+
+procedure test(p: pansichar); overload;
+begin
+  writeln('pchar');
+  halt(1);
+end;
+
+procedure test(p: pwidechar); overload;
+begin
+  writeln('pwidechar');
+end;
+
+begin
+  test(#$1234);
+end.

+ 18 - 0
tests/test/tcpstr26d.pp

@@ -0,0 +1,18 @@
+{$ifdef fpc}
+{$mode delphiunicode}
+{$endif}
+
+procedure test(p: pansichar); overload;
+begin
+  writeln('pchar');
+  halt(1);
+end;
+
+procedure test(p: pwidechar); overload;
+begin
+  writeln('pwidechar');
+end;
+
+begin
+  test('abcdef');
+end.