Make xundump interpret escapes in identifiers

We need this because we have symbols with spaces, e.g. missions[].
This commit is contained in:
Markus Armbruster 2008-03-04 21:41:26 +01:00
parent 5ef6559c6a
commit f9e28d0491

View file

@ -132,21 +132,6 @@ skipfs(FILE *fp)
return ch;
}
/*
* Read an identifier from FP into BUF.
* BUF must have space for 1024 characters.
* Return number of characters read on success, -1 on failure.
*/
static int
getid(FILE *fp, char *buf)
{
int n;
if (fscanf(fp, "%1023[^#()<>=#\" \t\n]%n", buf, &n) != 1
|| !isalpha(buf[0]))
return -1;
return n;
}
/*
* Decode escape sequences in BUF.
* Return BUF on success, null pointer on failure.
@ -172,6 +157,22 @@ xuesc(char *buf)
return buf;
}
/*
* Read an identifier from FP into BUF.
* BUF must have space for 1024 characters.
* Return number of characters read on success, -1 on failure.
*/
static int
getid(FILE *fp, char *buf)
{
int n;
if (fscanf(fp, "%1023[^\"#()<>= \t\n]%n", buf, &n) != 1
|| !isalpha(buf[0]))
return -1;
xuesc(buf);
return n;
}
/*
* Try to read a field name from FP.
* I is the field number, counting from zero.