* default widestring-ansistring conversion needs to use the same algorithm

as the rtl to behave the same on compile time and runtime

git-svn-id: trunk@8161 -
This commit is contained in:
peter 2007-07-23 21:57:48 +00:00
parent 1249bf70ff
commit c020d709b4
3 changed files with 36 additions and 1 deletions

1
.gitattributes vendored
View File

@ -8203,6 +8203,7 @@ tests/webtbs/tw6687.pp svneol=native#text/plain
tests/webtbs/tw6690.pp svneol=native#text/plain
tests/webtbs/tw6700.pp svneol=native#text/plain
tests/webtbs/tw6735.pp svneol=native#text/plain
tests/webtbs/tw6737.pp -text
tests/webtbs/tw6742.pp svneol=native#text/plain
tests/webtbs/tw6767.pp svneol=native#text/plain
tests/webtbs/tw6865.pp svneol=native#text/plain

View File

@ -225,6 +225,9 @@ unit widestr;
dest : pchar;
i : longint;
begin
{ This routine must work the same as the
the routine in the RTL to have the same compile time (for constant strings)
and runtime conversion (for variables) }
source:=tcompilerwidecharptr(r^.data);
dest:=p;
for i:=1 to r^.len do
@ -232,7 +235,7 @@ unit widestr;
if word(source^)<128 then
dest^:=char(word(source^))
else
dest^:=' ';
dest^:='?';
inc(dest);
inc(source);
end;

31
tests/webtbs/tw6737.pp Normal file
View File

@ -0,0 +1,31 @@
{$mode objfpc}
{$H+}
uses sysutils;
Function AnsiEndsStr(const ASubText, AText: string): Boolean;
begin
Writeln('ZZ',ASubText,'XX ',AText,'YY');
Result := AnsiCompareStr(Copy(AText,length(AText)-length(ASubText)+1,length(ASubText)),ASubText)=0;
end;
VAR
s: WideString;
t: WideString;
err : boolean;
BEGIN
s := 'This is a test.'#961#967;
t := 'test.'#961#967;
IF AnsiEndsStr(t, s) THEN
WriteLn('OK.')
ELSE
err:=true;
IF AnsiEndsStr('test.'#961#967, s) THEN
WriteLn('OK.')
ELSE
err:=true;
if err then
WriteLn('Not OK.');
if err then
halt(1);
END.