* 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 -
This commit is contained in:
Jonas Maebe 2013-09-06 08:02:59 +00:00
parent b3b404db4b
commit f539e9158a
7 changed files with 96 additions and 1 deletions

5
.gitattributes vendored
View File

@ -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

View File

@ -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
tests/test/tcpstr26.pp Normal file
View File

@ -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
tests/test/tcpstr26a.pp Normal file
View File

@ -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
tests/test/tcpstr26b.pp Normal file
View File

@ -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
tests/test/tcpstr26c.pp Normal file
View File

@ -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
tests/test/tcpstr26d.pp Normal file
View File

@ -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.