Restore the previous state after a FILL operation in properties_read()
rather than forcing the state to LOOK. If we are in the middle of parsing a line when we have to do a FILL we would have lost any token we were in the middle of parsing and would have treated the next character as being at the start of a new line instead. PR: kern/89181 Submitted by: Antony Mawer gnats at mawer dot org MFC after: 1 week
This commit is contained in:
parent
8fa1d32e68
commit
a54bb702d7
@ -75,17 +75,18 @@ properties_read(int fd)
|
||||
char hold_v[PROPERTY_MAX_VALUE + 1];
|
||||
char buf[BUFSIZ * 4];
|
||||
int bp, n, v, max;
|
||||
enum { LOOK, COMMENT, NAME, VALUE, MVALUE, COMMIT, FILL, STOP } state;
|
||||
enum { LOOK, COMMENT, NAME, VALUE, MVALUE, COMMIT, FILL, STOP } state, last_state;
|
||||
int ch = 0, blevel = 0;
|
||||
|
||||
n = v = bp = max = 0;
|
||||
head = ptr = NULL;
|
||||
state = LOOK;
|
||||
state = last_state = LOOK;
|
||||
while (state != STOP) {
|
||||
if (state != COMMIT) {
|
||||
if (bp == max)
|
||||
if (bp == max) {
|
||||
last_state = state;
|
||||
state = FILL;
|
||||
else
|
||||
} else
|
||||
ch = buf[bp++];
|
||||
}
|
||||
switch(state) {
|
||||
@ -96,13 +97,19 @@ properties_read(int fd)
|
||||
}
|
||||
if (max == 0) {
|
||||
state = STOP;
|
||||
break;
|
||||
} else {
|
||||
state = LOOK;
|
||||
/*
|
||||
* Restore the state from before the fill (which will be
|
||||
* initialised to LOOK for the first FILL). This ensures that
|
||||
* if we were part-way through eg., a VALUE state, when the
|
||||
* buffer ran out, that the previous operation will be allowed
|
||||
* to complete.
|
||||
*/
|
||||
state = last_state;
|
||||
ch = buf[0];
|
||||
bp = 1;
|
||||
bp = 0;
|
||||
}
|
||||
/* FALLTHROUGH deliberately since we already have a character and state == LOOK */
|
||||
continue;
|
||||
|
||||
case LOOK:
|
||||
if (isspace((unsigned char)ch))
|
||||
|
Loading…
Reference in New Issue
Block a user