* shortstring reuse fixed

This commit is contained in:
peter 1999-03-31 13:51:49 +00:00
parent 57b01570ba
commit 6fa76bfc12

View File

@ -147,7 +147,7 @@ implementation
lastlabel : plabel; lastlabel : plabel;
pc : pchar; pc : pchar;
same_string : boolean; same_string : boolean;
l, l,j,
i,mylength : longint; i,mylength : longint;
begin begin
lastlabel:=nil; lastlabel:=nil;
@ -176,26 +176,44 @@ implementation
(pai_string(hp1)^.len=mylength) then (pai_string(hp1)^.len=mylength) then
begin begin
same_string:=true; same_string:=true;
for i:=0 to p^.length do { if shortstring then check the length byte first and
if pai_string(hp1)^.str[i]<>p^.value_str[i] then set the start index to 1 }
begin if is_shortstring(p^.resulttype) then
same_string:=false; begin
break; if p^.length<>ord(pai_string(hp1)^.str[0]) then
end; same_string:=false;
j:=1;
end
else
j:=0;
{ don't check if the length byte was already wrong }
if same_string then if same_string then
begin begin
{ found! } for i:=0 to p^.length do
p^.lab_str:=lastlabel; begin
if (p^.stringtype in [st_ansistring,st_widestring]) then if pai_string(hp1)^.str[j]<>p^.value_str[i] then
begin begin
getdatalabel(l2); same_string:=false;
consts^.concat(new(pai_label,init(l2))); break;
consts^.concat(new(pai_const_symbol,init(lab2str(p^.lab_str))));
{ return the offset of the real string }
p^.lab_str:=l2;
end; end;
break; inc(j);
end; end;
end;
{ found ? }
if same_string then
begin
p^.lab_str:=lastlabel;
{ create a new entry for ansistrings, but reuse the data }
if (p^.stringtype in [st_ansistring,st_widestring]) then
begin
getdatalabel(l2);
consts^.concat(new(pai_label,init(l2)));
consts^.concat(new(pai_const_symbol,init(lab2str(p^.lab_str))));
{ return the offset of the real string }
p^.lab_str:=l2;
end;
break;
end;
end; end;
lastlabel:=nil; lastlabel:=nil;
end; end;
@ -384,7 +402,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.29 1999-02-25 21:02:25 peter Revision 1.30 1999-03-31 13:51:49 peter
* shortstring reuse fixed
Revision 1.29 1999/02/25 21:02:25 peter
* ag386bin updates * ag386bin updates
+ coff writer + coff writer