Give an error if you try to define a macro to + or - on the command line.

This affects command lines like:
cmpl myprog.c cc=(-da=+) ...

Previously, this would be accepted, but a was actually defined to 0 rather than +.

Now, this gives an error, consistent with other tokens that are not supported in such definitions on the command line. (Perhaps we should support definitions using any tokens, but that would require bigger code changes.)

This also cleans up some related code to avoid possible null-pointer dereferences.
This commit is contained in:
Stephen Heumann 2021-02-03 21:06:58 -06:00
parent 32b0d53b07
commit 4a95dbc597

View File

@ -3853,6 +3853,10 @@ repeat
bp := pointer(ord4(macros) + hash(mp^.name));
mp^.next := bp^;
bp^ := mp;
token.kind := intconst; {create the default value}
token.numString := nil;
token.class := intConstant;
token.ival := 1;
if lch = '=' then begin
NextCh; {record the value}
token.numString := nil;
@ -3876,12 +3880,8 @@ repeat
otherwise: ;
end; {case}
end {if}
else begin
token.kind := intconst;
token.numString := nil;
token.class := intConstant;
token.ival := 0;
end; {else}
else
Error(108);
end {else if}
else if lch in ['.','0'..'9'] then begin
token.name := GetWord;
@ -3891,17 +3891,11 @@ repeat
GetString
else
Error(108);
end {if}
else begin
token.kind := intconst; {create the default value}
token.numString := nil;
token.class := intConstant;
token.ival := 1;
end; {else}
end; {if}
new(mp^.tokens); {add the value to the definition}
with mp^.tokens^ do begin
next := nil;
tokenString := nil;
tokenString := @'';
expandEnabled := true;
tokenStart := nil;
tokenEnd := nil;