(xuflds): Allow unescaped space and tab in strings. Also fix the

previous revision, which broke '#' in strings.
This commit is contained in:
Markus Armbruster 2005-12-03 11:36:55 +00:00
parent 1eb7d1795c
commit b7eb39ebef

View file

@ -150,13 +150,17 @@ xuflds(FILE *fp, struct value values[])
values[i].v_type = VAL_DOUBLE; values[i].v_type = VAL_DOUBLE;
break; break;
case '"': case '"':
if (fscanf(fp, "%1023[^ \t#\n]", buf) != 1 ch = getc(fp);
|| buf[strlen(buf)-1] != '"') if (ch == '"')
return gripe("Malformed string in field %d", i + 1); buf[0] = 0;
buf[strlen(buf)-1] = '\0'; else {
if (!xuesc(buf)) ungetc(ch, fp);
return gripe("Invalid escape sequence in field %d", if (fscanf(fp, "%1023[^\"\n]", buf) != 1 || getc(fp) != '"')
i + 1); return gripe("Malformed string in field %d", i + 1);
if (!xuesc(buf))
return gripe("Invalid escape sequence in field %d",
i + 1);
}
values[i].v_type = VAL_STRING; values[i].v_type = VAL_STRING;
values[i].v_field.v_string = strdup(buf); values[i].v_field.v_string = strdup(buf);
break; break;