mirror of
https://github.com/cc65/cc65.git
synced 2025-02-19 06:30:53 +00:00
Added check for ## at either end of macro expansion.
This commit is contained in:
parent
a3a5fbe809
commit
cf7558add3
@ -1043,6 +1043,7 @@ static void DoDefine (void)
|
||||
Macro* M;
|
||||
Macro* Existing;
|
||||
int C89;
|
||||
unsigned Len;
|
||||
|
||||
/* Read the macro name */
|
||||
SkipWhitespace (0);
|
||||
@ -1151,6 +1152,24 @@ static void DoDefine (void)
|
||||
printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement));
|
||||
#endif
|
||||
|
||||
/* Check for ## at start or end */
|
||||
Len = SB_GetLen (&M->Replacement);
|
||||
if (Len >= 2) {
|
||||
if (SB_LookAt (&M->Replacement, 0) == '#' &&
|
||||
SB_LookAt (&M->Replacement, 1) == '#') {
|
||||
/* Diagnose and bail out */
|
||||
PPError ("'##' cannot appear at start of macro expansion");
|
||||
FreeMacro (M);
|
||||
return;
|
||||
} else if (SB_LookAt (&M->Replacement, Len - 1) == '#' &&
|
||||
SB_LookAt (&M->Replacement, Len - 2) == '#') {
|
||||
/* Diagnose and bail out */
|
||||
PPError ("'##' cannot appear at end of macro expansion");
|
||||
FreeMacro (M);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get an existing macro definition with this name */
|
||||
Existing = FindMacro (M->Name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user