previous code tried to encode a "packed array[..] of char" as a c-string. But it didn't actually work (it was never considered packed due to looking in the wrong place).

Additionally, this refines it so that
- packed array[1..x] of char is encoded as a c-string
- packed array[0..x] of char is encoded as a p-string
- packed array[a..x] of char (where a not in [1,2]) is not considered a string
- packed array[..] of boolean isn't considered a string
This commit is contained in:
Kelvin Sherlock 2018-03-24 22:23:36 -04:00
parent cf72a073f8
commit 6be050fcd2

View File

@ -966,22 +966,34 @@ var
count: unsigned; {# of subscripts}
lmin, lmax: addrrange; {index range}
tp2: stp; {used to trace array type list}
tp3: stp;
begin {WriteArrays}
count := 0; {count the subscripts}
tp2 := tp;
tp3 := nil;
while tp2^.form = arrays do begin
count := count+1;
tp3 := tp2;
tp2 := tp2^.aeltype;
end; {while}
if tp2^.form = scalar then {write the type code}
if GetType(tp2, tp^.isPacked) in [cgByte,cgUByte] then begin
count := count-1;
CnOut(6);
CnOut2(count);
if tp2^.form = scalar then begin {write the type code}
{ cstring = packed array[1..x] of char }
{ pstring = packed array[0..x] of char }
if (boolean(tp2^.isPacked)) and (tp2 = charptr) then begin
GetBounds(tp3^.inxtype, lmin, lmax);
if (lmin = 0) or (lmin = 1) then begin
count := count-1;
{ 6 = cstring, 7 = pstring }
CnOut(7 - ord(lmin));
CnOut2(count);
end {if}
else WriteScalarType(tp2, 0, count);
end {if}
else
WriteScalarType(tp2, 0, count)
WriteScalarType(tp2, 0, count);
end {if}
else if tp2^.form = subrange then
WriteScalarType(tp2^.rangetype, 0, count)
else if tp2^.form = pointerStruct then