Commit 9b1f1d17 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix PeekToken(): Should never be called with EOI token, and thus cannot return NULL.

parent 0a4884c6
......@@ -457,7 +457,7 @@ vcc_acl_entry(struct vcc *tl)
*/
static void
vcc_acl_emit_tokens(struct vcc *tl, const struct acl_e *ae)
vcc_acl_emit_tokens(const struct vcc *tl, const struct acl_e *ae)
{
struct token *t;
const char *sep = "";
......@@ -490,7 +490,7 @@ vcc_acl_emit_tokens(struct vcc *tl, const struct acl_e *ae)
*/
static unsigned
vcc_acl_emit_tables(struct vcc *tl, unsigned n, const char *name)
vcc_acl_emit_tables(const struct vcc *tl, unsigned n, const char *name)
{
struct acl_e *ae;
unsigned rv = sizeof(ae->data) + 3;
......
......@@ -415,13 +415,13 @@ void vcc_Warn(struct vcc *);
void vcc__Expect(struct vcc *tl, unsigned tok, unsigned line);
int vcc_IdIs(const struct token *t, const char *p);
void vcc_PrintTokens(struct vcc *tl, const struct token *tb,
void vcc_PrintTokens(const struct vcc *tl, const struct token *tb,
const struct token *te);
void vcc_ExpectVid(struct vcc *tl, const char *what);
void vcc_Lexer(struct vcc *tl, struct source *sp);
void vcc_NextToken(struct vcc *tl);
struct token * vcc_PeekToken(struct vcc *tl);
struct token * vcc_PeekTokenFrom(struct vcc *tl, const struct token *t);
struct token * vcc_PeekToken(const struct vcc *tl);
struct token * vcc_PeekTokenFrom(const struct vcc *tl, const struct token *t);
void vcc__ErrInternal(struct vcc *tl, const char *func,
unsigned line);
......
......@@ -264,24 +264,20 @@ vcc_ErrWhere(struct vcc *tl, const struct token *t)
/*--------------------------------------------------------------------*/
struct token *
vcc_PeekTokenFrom(struct vcc *tl, const struct token *t)
vcc_PeekTokenFrom(const struct vcc *tl, const struct token *t)
{
struct token *tn;
struct token *t2;
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
AN(t);
tn = VTAILQ_NEXT(t, list);
if (tn == NULL) {
VSB_cat(tl->sb,
"Ran out of input, something is missing or"
" maybe unbalanced (...) or {...}\n");
tl->err = 1;
}
return (tn);
assert(t->tok != EOI);
t2 = VTAILQ_NEXT(t, list);
AN(t2);
return (t2);
}
struct token *
vcc_PeekToken(struct vcc *tl)
vcc_PeekToken(const struct vcc *tl)
{
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
......@@ -330,7 +326,8 @@ vcc_IdIs(const struct token *t, const char *p)
*/
void
vcc_PrintTokens(struct vcc *tl, const struct token *tb, const struct token *te)
vcc_PrintTokens(const struct vcc *tl,
const struct token *tb, const struct token *te)
{
CHECK_OBJ_NOTNULL(tl, VCC_MAGIC);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment