Forráskód Böngészése

Merged revisions 8161 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r8161 | peter | 2007-07-23 23:57:48 +0200 (Mon, 23 Jul 2007) | 3 lines

* 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: branches/fixes_2_2@8234 -

peter 18 éve
szülő
commit
a8486ac4d2
3 módosított fájl, 36 hozzáadás és 1 törlés
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/widestr.pas
  3. 31 0
      tests/webtbs/tw6737.pp

+ 1 - 0
.gitattributes

@@ -8026,6 +8026,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

+ 4 - 1
compiler/widestr.pas

@@ -223,6 +223,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
@@ -230,7 +233,7 @@ unit widestr;
            if word(source^)<128 then
             dest^:=char(word(source^))
            else
-            dest^:=' ';
+            dest^:='?';
            inc(dest);
            inc(source);
          end;

+ 31 - 0
tests/webtbs/tw6737.pp

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