Do not generate extra zero bytes after certain string constants.

These extra bytes are unnecessary after the changes in commit 5871820e0c to make string constants explicitly include their null terminators.

The extra bytes would be generated for code like the following:

int main(void) {
        static char *s1 = "abc", *s2 = "def", *s3 = "ghi";
}
This commit is contained in:
Stephen Heumann 2022-01-29 18:27:03 -06:00
parent 02fbf97a1e
commit e8d90a1b69

View File

@ -674,12 +674,11 @@ case mode of
GenImmediate2;
sptr := icptr(name)^.pStr;
j := sptr^.length;
if maxString-stringSize >= j+1 then begin
if maxString-stringSize >= j then begin
for k := 1 to j do
stringSpace[k+stringSize] :=
sptr^.str[k];
stringSpace[stringSize+j+1] := chr(0);
stringSize := stringSize+j+1;
stringSize := stringSize+j;
end {if}
else
Error(cge3);