Allow string constants with up to 32760 bytes.

This allows the length of the string plus a few extra bytes used internally to be represented by a 16-bit integer. Since the size limit for memory allocations has been raised, there is no good reason to impose a shorter limit on strings.

Note that C99 and later specify a minimum translation limit for string constants of at least 4095 characters.
This commit is contained in:
Stephen Heumann 2021-10-24 15:54:25 -05:00
parent 26d0f2ad35
commit 73d194c12f
3 changed files with 7 additions and 7 deletions

View File

@ -78,7 +78,7 @@ const
maxLine = 255; {max length of a line}
maxPath = 255; {max length of a path name}
{NOTE: maxPath is used in Scanner.asm}
longstringlen = 4000; {max length of a string constant}
longstringlen = 32760; {max length of a string constant}
minChar = 0; {min ordinal value of source character}
maxChar = 255; {max ordinal value of source character}

View File

@ -4388,17 +4388,17 @@ procedure NextToken;
label 1,2,3,4,5,6;
type
three = (s100,s1000,s4000); {these declarations are used for a}
three = (s100,s1000,sMAX); {these declarations are used for a}
gstringPtr = ^gstringRecord; { variable length string record }
gstringRecord = record
case three of
s100: (len1: integer;
s100: (len1: integer;
str1: packed array[1..100] of char;
);
s1000: (len2: integer;
str2: packed array[1..1000] of char;
);
s4000: (len3: integer;
sMAX: (len3: integer;
str3: packed array[1..longstringlen] of char;
);
end;
@ -5000,7 +5000,7 @@ case charKinds[ord(ch)] of
end {if}
else if i = 1001 then begin
sPtr^.len2 := 1000;
new(tsPtr,s4000);
new(tsPtr,sMAX);
CopyLongString(pointer(tsPtr), pointer(sPtr));
dispose(sPtr);
sPtr := tsPtr;
@ -5021,7 +5021,7 @@ case charKinds[ord(ch)] of
Error(167);
end; {if}
i := 1;
new(sPtr,s4000);
new(sPtr,sMAX);
while not (charKinds[ord(ch)] in [ch_string,ch_eol,ch_eof]) do begin
if i > longstringlen-8 then begin {leave space for char and null}
i := 1;

View File

@ -120,7 +120,7 @@ Character and string constants may now have prefixes indicating they should use
p. 238
The limit on the total length of string constants in a single function has been raised to 12500 characters.
The limit on the length of a single string constant is now 32760 bytes. The limit on the total length of string constants in a single function is now 12500 bytes (larger string constants can be used to initialize static arrays).
p. 239