mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Python style long strings ("""...""") now supported for parsing. Any such strings will be written out as standard strings with escaped quotes when writing the plist.
This commit is contained in:
parent
5294a97d6a
commit
5c73d81e00
2 changed files with 17 additions and 3 deletions
|
@ -60,9 +60,11 @@
|
|||
|
||||
An unquoted string may contain only alphanumeric characters and/or the
|
||||
underscore character, '_'. Quoted strings may contain whitespace, C escape
|
||||
sequences, and so on. The quote character is '"'.
|
||||
sequences, and so on. The quote character is '"'. Optionally, Python style
|
||||
long strings ("""...""") may be used, allowing for unquoted '"' quotes in
|
||||
the string.
|
||||
|
||||
<!-- in the following paragram, the \< and \> are just < and >. the \ is
|
||||
<!-- in the following paragraph, the \< and \> are just < and >. the \ is
|
||||
for doxygen -->
|
||||
QFBinary data is hex-encoded and contained within angle brackets, \< \>.
|
||||
The length of the encoded data must be an even number, so while \<FF00\>
|
||||
|
|
|
@ -467,8 +467,16 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
unsigned int escaped = 0;
|
||||
unsigned int shrink = 0;
|
||||
qboolean hex = false;
|
||||
qboolean long_string = false;
|
||||
char *str;
|
||||
|
||||
if (pl->ptr[pl->pos] == '"' &&
|
||||
pl->ptr[pl->pos + 1] == '"') {
|
||||
long_string = true;
|
||||
start += 2;
|
||||
pl->pos += 2;
|
||||
}
|
||||
|
||||
while (pl->pos < pl->end) {
|
||||
|
||||
char c = pl->ptr[pl->pos];
|
||||
|
@ -499,7 +507,9 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
if (c == '\\') {
|
||||
escaped = 1;
|
||||
shrink++;
|
||||
} else if (c == '"') {
|
||||
} else if (c == '"'
|
||||
&& (!long_string || (pl->ptr[pl->pos + 1] == '"'
|
||||
&& pl->ptr[pl->pos + 2] == '"'))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -594,6 +604,8 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
str = strncat (calloc ((pl->pos - start - shrink) + 1, 1), chars,
|
||||
pl->pos - start - shrink);
|
||||
}
|
||||
if (long_string)
|
||||
pl->pos += 2;
|
||||
pl->pos++;
|
||||
return str;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue