Преглед изворни кода

o fixed r13033:
* test now tests both ansistring and widestring constants, instead of only
ansistring
* fixed writing of widestring constants to ppu file
* fixed setting length of read widestring constants (don't only set maxlen)
* handle cross-endian reading of widestring constants

git-svn-id: trunk@13034 -

Jonas Maebe пре 16 година
родитељ
комит
045ae3ab69
3 измењених фајлова са 23 додато и 4 уклоњено
  1. 15 2
      compiler/symsym.pas
  2. 5 0
      tests/webtbs/tw13583.pp
  3. 3 2
      tests/webtbs/uw13583.pp

+ 15 - 2
compiler/symsym.pas

@@ -1501,6 +1501,7 @@ implementation
          ps : pnormalset;
          pc : pchar;
          pw : pcompilerwidestring;
+         i  : longint;
       begin
          inherited ppuload(constsym,ppufile);
          constdef:=nil;
@@ -1521,7 +1522,19 @@ implementation
              begin
                initwidestring(pw);
                setlengthwidestring(pw,ppufile.getlongint);
-               ppufile.getdata(pw^.data^,pw^.len*sizeof(tcompilerwidechar));
+               pw^.len:=pw^.maxlen;
+               { don't use getdata, because the compilerwidechars may have to
+                 be byteswapped
+               }
+{$if sizeof(tcompilerwidechar) = 2}
+               for i:=0 to pw^.len-1 do
+                 pw^.data[i]:=ppufile.getword;
+{$elseif sizeof(tcompilerwidechar) = 4}
+               for i:=0 to pw^.len-1 do
+                 pw^.data[i]:=cardinal(ppufile.getlongint);
+{$else}
+              {$error Unsupported tcompilerwidechar size}
+{$endif}
                pcompilerwidestring(value.valueptr):=pw;
              end;
            conststring,
@@ -1610,7 +1623,7 @@ implementation
            constwstring :
              begin
                ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
-               ppufile.putdata(pcompilerwidestring(value.valueptr)^.data,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
+               ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
              end;
            conststring,
            constresourcestring :

+ 5 - 0
tests/webtbs/tw13583.pp

@@ -5,4 +5,9 @@ uses
 
 begin
   writeln(DEFAULT_SIGNATURE);
+  if ('edb_signature' <> DEFAULT_SIGNATURE) then
+    halt(1);
+  writeln(DEFAULT_SIGNATURE2);
+  if ('edb_signature2' <> DEFAULT_SIGNATURE2) then
+    halt(1);
 end.

+ 3 - 2
tests/webtbs/uw13583.pp

@@ -3,11 +3,12 @@ unit uw13583;
 interface
 
 type
-//  TEDBString = WideString;
-  TEDBString = ansiString;
+  TEDBString = WideString;
+  TEDBString2 = ansiString;
 
 const
   DEFAULT_SIGNATURE = TEDBString('edb_signature');
+  DEFAULT_SIGNATURE2 = TEDBString('edb_signature2');
 
 implementation