Make xundump interpret escapes in identifiers
We need this because we have symbols with spaces, e.g. missions[].
This commit is contained in:
parent
5ef6559c6a
commit
f9e28d0491
1 changed files with 16 additions and 15 deletions
|
@ -132,21 +132,6 @@ skipfs(FILE *fp)
|
||||||
return ch;
|
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.
|
* Decode escape sequences in BUF.
|
||||||
* Return BUF on success, null pointer on failure.
|
* Return BUF on success, null pointer on failure.
|
||||||
|
@ -172,6 +157,22 @@ xuesc(char *buf)
|
||||||
return 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.
|
* Try to read a field name from FP.
|
||||||
* I is the field number, counting from zero.
|
* I is the field number, counting from zero.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue