From 045ae3ab69d0b0827fc0b718c1a45c4b9581c694 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 24 Apr 2009 22:29:05 +0000 Subject: [PATCH] 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 - --- compiler/symsym.pas | 17 +++++++++++++++-- tests/webtbs/tw13583.pp | 5 +++++ tests/webtbs/uw13583.pp | 5 +++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/compiler/symsym.pas b/compiler/symsym.pas index 17d6900a4f..b670f7c834 100644 --- a/compiler/symsym.pas +++ b/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 : diff --git a/tests/webtbs/tw13583.pp b/tests/webtbs/tw13583.pp index dd208c3875..e2b0952931 100644 --- a/tests/webtbs/tw13583.pp +++ b/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. diff --git a/tests/webtbs/uw13583.pp b/tests/webtbs/uw13583.pp index 1b7316cd52..a19143ba15 100644 --- a/tests/webtbs/uw13583.pp +++ b/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