mirror of
https://github.com/open-simh/simtools.git
synced 2026-05-05 07:23:31 +00:00
A trailing comma in a macro call is an empty argument
which should also be counted for the purposes of .NARG.
This commit is contained in:
7
macros.c
7
macros.c
@@ -414,14 +414,16 @@ STREAM *expandmacro(
|
|||||||
STREAM *str;
|
STREAM *str;
|
||||||
BUFFER *buf;
|
BUFFER *buf;
|
||||||
int nargs;
|
int nargs;
|
||||||
|
int onemore;
|
||||||
|
|
||||||
args = NULL;
|
args = NULL;
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
nargs = 0; /* for the .NARG directive */
|
nargs = 0; /* for the .NARG directive */
|
||||||
|
onemore = 0;
|
||||||
|
|
||||||
/* Parse the arguments */
|
/* Parse the arguments */
|
||||||
|
|
||||||
while (!EOL(*cp)) {
|
while (!EOL(*cp) || onemore) {
|
||||||
char *nextcp;
|
char *nextcp;
|
||||||
|
|
||||||
/* Check for named argument */
|
/* Check for named argument */
|
||||||
@@ -464,7 +466,8 @@ STREAM *expandmacro(
|
|||||||
|
|
||||||
eval_arg(refstr, arg); /* Check for expression evaluation */
|
eval_arg(refstr, arg); /* Check for expression evaluation */
|
||||||
|
|
||||||
cp = skipdelim(nextcp);
|
/* If there is a trailing comma, there is an empty last argument */
|
||||||
|
cp = skipdelim_comma(nextcp, &onemore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now go back and fill in defaults */ {
|
/* Now go back and fill in defaults */ {
|
||||||
|
|||||||
15
parse.c
15
parse.c
@@ -35,6 +35,21 @@ char *skipdelim(
|
|||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skipdelim_comma - used to advance between tokens. Whitespace
|
||||||
|
and one comma are allowed delims.
|
||||||
|
Set *comma depending on whether a comma was skipped. */
|
||||||
|
|
||||||
|
char *skipdelim_comma(
|
||||||
|
char *cp,
|
||||||
|
int *comma)
|
||||||
|
{
|
||||||
|
cp = skipwhite(cp);
|
||||||
|
if (*comma = (*cp == ',')) {
|
||||||
|
cp = skipwhite(cp + 1);
|
||||||
|
}
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parses a string from the input stream. */
|
/* Parses a string from the input stream. */
|
||||||
/* If not bracketed by <...> or ^/.../, then */
|
/* If not bracketed by <...> or ^/.../, then */
|
||||||
/* the string is delimited by trailing comma or whitespace. */
|
/* the string is delimited by trailing comma or whitespace. */
|
||||||
|
|||||||
Reference in New Issue
Block a user