diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-01-13 23:42:19 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-01-13 23:42:19 +0000 |
commit | 0d2b74477a542c2adf08902350b7c7f411cc7a13 (patch) | |
tree | 8c0c04ab3d2f1810e930b0602ba0878049a18d7a /sbin | |
parent | 3ece6c92b0a8cc82f3b6564c709f613fca902c9b (diff) |
peek_token() a bit more to replace a bunch of manual checks with
the perfectly adequate parse_semi(). And some blocks didn't even
need to peek.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/clparse.c | 39 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 8 |
2 files changed, 19 insertions, 28 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 29949c19110..9fc075369da 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.70 2014/01/13 21:36:46 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.71 2014/01/13 23:42:18 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -347,13 +347,13 @@ parse_option_list(FILE *cfile, u_int8_t *list, size_t sz) ; if (j == ix) list[ix++] = i; - token = next_token(&val, cfile); + token = peek_token(NULL, cfile); + if (token == ',') + token = next_token(NULL, cfile); } while (token == ','); - if (token != ';') { - parse_warn("expecting semicolon."); - goto syntaxerror; - } - return (ix); + + if (parse_semi(cfile)) + return (ix); syntaxerror: skip_to_semi(cfile); @@ -578,11 +578,8 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease) skip_to_semi(cfile); return; } - token = next_token(&val, cfile); - if (token != ';') { - parse_warn("expecting semicolon."); - skip_to_semi(cfile); - } + + parse_semi(cfile); } int @@ -724,14 +721,13 @@ bad_flag: return (-1); } } - token = next_token(&val, cfile); + token = peek_token(NULL, cfile); + if (*fmt == 'A' && token == ',') + token = next_token(NULL, cfile); } while (*fmt == 'A' && token == ','); - if (token != ';') { - parse_warn("semicolon expected."); - skip_to_semi(cfile); + if (!parse_semi(cfile)) return (-1); - } options[code].data = malloc(hunkix + nul_term); if (!options[code].data) @@ -762,11 +758,10 @@ parse_reject_statement(FILE *cfile) elem->addr = addr; TAILQ_INSERT_TAIL(&config->reject_list, elem, next); - token = next_token(NULL, cfile); + token = peek_token(NULL, cfile); + if (token == ',') + token = next_token(NULL, cfile); } while (token == ','); - if (token != ';') { - parse_warn("expecting semicolon."); - skip_to_semi(cfile); - } + parse_semi(cfile); } diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index 31f49f8f160..d77661f31db 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.30 2014/01/13 20:56:24 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.31 2014/01/13 23:42:18 krw Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -161,11 +161,7 @@ parse_hardware_param(FILE *cfile, struct ether_addr *hardware) ETHER_ADDR_LEN, ':', 16) == 0) return; - token = next_token(NULL, cfile); - if (token != ';') { - parse_warn("expecting semicolon."); - skip_to_semi(cfile); - } + parse_semi(cfile); } /* |