mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-30 05:47:45 +00:00
parent
f800f4f633
commit
d19e816ece
@ -200,6 +200,19 @@ static int get_char (cfile)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a character to our input buffer.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
unget_char(struct parse *cfile, int c) {
|
||||||
|
if (c != EOF) {
|
||||||
|
cfile->bufix--;
|
||||||
|
cfile->ugflag = 1; /* do not put characters into
|
||||||
|
our error buffer on the next
|
||||||
|
call to get_char() */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GENERAL NOTE ABOUT TOKENS
|
* GENERAL NOTE ABOUT TOKENS
|
||||||
*
|
*
|
||||||
@ -231,7 +244,6 @@ get_raw_token(struct parse *cfile) {
|
|||||||
do {
|
do {
|
||||||
l = cfile -> line;
|
l = cfile -> line;
|
||||||
p = cfile -> lpos;
|
p = cfile -> lpos;
|
||||||
u = cfile -> ugflag;
|
|
||||||
|
|
||||||
c = get_char (cfile);
|
c = get_char (cfile);
|
||||||
if (!((c == '\n') && cfile->eol_token) &&
|
if (!((c == '\n') && cfile->eol_token) &&
|
||||||
@ -451,9 +463,7 @@ read_whitespace(int c, struct parse *cfile) {
|
|||||||
/*
|
/*
|
||||||
* Put the last (non-whitespace) character back.
|
* Put the last (non-whitespace) character back.
|
||||||
*/
|
*/
|
||||||
if (c != EOF) {
|
unget_char(cfile, c);
|
||||||
cfile->bufix--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return our token.
|
* Return our token.
|
||||||
@ -617,10 +627,7 @@ static enum dhcp_token read_number (c, cfile)
|
|||||||
* token. If not EOF, rewind the file one byte so
|
* token. If not EOF, rewind the file one byte so
|
||||||
* the next token is read from there.
|
* the next token is read from there.
|
||||||
*/
|
*/
|
||||||
if(c != EOF) {
|
unget_char(cfile, c);
|
||||||
cfile->bufix--;
|
|
||||||
cfile->ugflag = 1;
|
|
||||||
}
|
|
||||||
goto end_read;
|
goto end_read;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -655,10 +662,7 @@ static enum dhcp_token read_num_or_name (c, cfile)
|
|||||||
c = get_char (cfile);
|
c = get_char (cfile);
|
||||||
if (!isascii (c) ||
|
if (!isascii (c) ||
|
||||||
(c != '-' && c != '_' && !isalnum (c))) {
|
(c != '-' && c != '_' && !isalnum (c))) {
|
||||||
if (c != EOF) {
|
unget_char(cfile, c);
|
||||||
cfile -> bufix--;
|
|
||||||
cfile -> ugflag = 1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isxdigit (c))
|
if (!isxdigit (c))
|
||||||
|
@ -254,6 +254,23 @@ struct parse {
|
|||||||
const char *tlname;
|
const char *tlname;
|
||||||
int eol_token;
|
int eol_token;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In order to give nice output when we have a parsing error
|
||||||
|
* in our file, we keep track of where we are in the line so
|
||||||
|
* that we can show the user.
|
||||||
|
*
|
||||||
|
* We need to keep track of two lines, because we can look
|
||||||
|
* ahead, via the "peek" function, to the next line sometimes.
|
||||||
|
*
|
||||||
|
* The "line1" and "line2" variables act as buffers for this
|
||||||
|
* information. The "lpos" variable tells us where we are in the
|
||||||
|
* line.
|
||||||
|
*
|
||||||
|
* When we "put back" a character from the parsing context, we
|
||||||
|
* do not want to have the character appear twice in the error
|
||||||
|
* output. So, we set a flag, the "ugflag", which the
|
||||||
|
* get_char() function uses to check for this condition.
|
||||||
|
*/
|
||||||
char line1 [81];
|
char line1 [81];
|
||||||
char line2 [81];
|
char line2 [81];
|
||||||
int lpos;
|
int lpos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user