goto error;
p->arg_type = ARG_CHAREND;
- p->charend = (struct token) { .type = T_STOP };
if (!lex_force_match (lexer, T_LPAREN)
- || !parse_quoted_token (lexer, &p->charend)
+ || !parse_quoted_token (lexer, &p->end)
|| !lex_force_match (lexer, T_RPAREN))
goto error;
}
goto error;
p->arg_type = ARG_ENCLOSE;
- p->enclose[0] = p->enclose[1] = (struct token) { .type = T_STOP };
if (!lex_force_match (lexer, T_LPAREN)
- || !parse_quoted_token (lexer, &p->enclose[0])
+ || !parse_quoted_token (lexer, &p->start)
|| !lex_force_match (lexer, T_COMMA)
- || !parse_quoted_token (lexer, &p->enclose[1])
+ || !parse_quoted_token (lexer, &p->end)
|| !lex_force_match (lexer, T_RPAREN))
goto error;
}
free (p->name);
macro_tokens_uninit (&p->def);
-
- switch (p->arg_type)
- {
- case ARG_N_TOKENS:
- break;
-
- case ARG_CHAREND:
- token_uninit (&p->charend);
- break;
-
- case ARG_ENCLOSE:
- token_uninit (&p->enclose[0]);
- token_uninit (&p->enclose[1]);
- break;
-
- case ARG_CMDEND:
- break;
- }
+ token_uninit (&p->start);
+ token_uninit (&p->end);
}
free (m->params);
macro_tokens_uninit (&m->body);
{
next_arg = (p->arg_type == ARG_CMDEND
? token->type == T_ENDCMD || token->type == T_STOP
- : token_equal (token, (p->arg_type == ARG_CHAREND
- ? &p->charend : &p->enclose[1])));
+ : token_equal (token, &p->end));
add_token = !next_arg;
}
const struct token *token = &mt->token;
mc->n_tokens++;
- if (token_equal (&mc->param->enclose[0], token))
+ if (token_equal (&mc->param->start, token))
{
mc->state = MC_ARG;
return 0;
}
- return mc_expected (mc, mt, loc, &mc->param->enclose[0]);
+ return mc_expected (mc, mt, loc, &mc->param->start);
}
static const struct macro_param *
ARG_CMDEND
}
arg_type;
- union
- {
- int n_tokens; /* ARG_N_TOKENS. */
- struct token charend; /* ARG_CHAREND. */
- struct token enclose[2]; /* ARG_ENCLOSE. */
- };
+
+ int n_tokens; /* ARG_N_TOKENS only. */
+ struct token start; /* ARG_ENCLOSE only. */
+ struct token end; /* ARG_ENCLOSE and ARG_CHAREND only. */
};
/* A macro. */