* const array of char and pchar length fixed (merged)

This commit is contained in:
peter 2000-09-30 13:23:04 +00:00
parent 5f21bf64b8
commit 084e294150

View File

@ -261,9 +261,14 @@ implementation
consts^.concat(new(pai_label,init(ll))); consts^.concat(new(pai_label,init(ll)));
if p^.treetype=stringconstn then if p^.treetype=stringconstn then
begin begin
getmem(ca,p^.length+2); len:=p^.length;
move(p^.value_str^,ca^,p^.length+1); { For tp7 the maximum lentgh can be 255 }
consts^.concat(new(pai_string,init_length_pchar(ca,p^.length+1))); if (m_tp in aktmodeswitches) and
(len>255) then
len:=255;
getmem(ca,len+2);
move(p^.value_str^,ca^,len+1);
consts^.concat(new(pai_string,init_length_pchar(ca,len+1)));
end end
else else
if is_constcharnode(p) then if is_constcharnode(p) then
@ -539,36 +544,38 @@ implementation
do_firstpass(p); do_firstpass(p);
if p^.treetype=stringconstn then if p^.treetype=stringconstn then
begin begin
if p^.length>255 then len:=p^.length;
len:=255 { For tp7 the maximum lentgh can be 255 }
else if (m_tp in aktmodeswitches) and
len:=p^.length; (len>255) then
s[0]:=chr(len); len:=255;
move(p^.value_str^,s[1],len); ca:=p^.value_str;
end end
else else
if is_constcharnode(p) then if is_constcharnode(p) then
s:=char(byte(p^.value)) begin
ca:=pchar(@p^.value);
len:=1;
end
else else
begin begin
Message(cg_e_illegal_expression); Message(cg_e_illegal_expression);
s:=''; len:=0;
end; end;
disposetree(p); if len>(Parraydef(def)^.highrange-Parraydef(def)^.lowrange+1) then
l:=length(s); Message(parser_e_string_larger_array);
for i:=Parraydef(def)^.lowrange to Parraydef(def)^.highrange do for i:=Parraydef(def)^.lowrange to Parraydef(def)^.highrange do
begin begin
if i+1-Parraydef(def)^.lowrange<=l then if i+1-Parraydef(def)^.lowrange<=len then
begin begin
curconstsegment^.concat(new(pai_const,init_8bit(byte(s[1])))); curconstsegment^.concat(new(pai_const,init_8bit(byte(ca^))));
delete(s,1,1); inc(ca);
end end
else else
{Fill the remaining positions with #0.} {Fill the remaining positions with #0.}
curconstsegment^.concat(new(pai_const,init_8bit(0))); curconstsegment^.concat(new(pai_const,init_8bit(0)));
end; end;
if length(s)>0 then disposetree(p);
Message(parser_e_string_larger_array);
end end
else else
begin begin
@ -803,7 +810,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.7 2000-09-24 15:06:25 peter Revision 1.8 2000-09-30 13:23:04 peter
* const array of char and pchar length fixed (merged)
Revision 1.7 2000/09/24 15:06:25 peter
* use defines.inc * use defines.inc
Revision 1.6 2000/08/27 16:11:52 peter Revision 1.6 2000/08/27 16:11:52 peter