mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 05:00:46 +00:00
Treat strings inside ""s as a single token.
This commit is contained in:
parent
ce3f526a5e
commit
36996c8c91
1 changed files with 17 additions and 2 deletions
19
src/m_misc.c
19
src/m_misc.c
|
@ -1783,7 +1783,6 @@ char *M_GetToken(const char *inputString)
|
|||
|| stringToUse[startPos] == '\r'
|
||||
|| stringToUse[startPos] == '\n'
|
||||
|| stringToUse[startPos] == '\0'
|
||||
|| stringToUse[startPos] == '"' // we're treating this as whitespace because SLADE likes adding it for no good reason
|
||||
|| stringToUse[startPos] == '=' || stringToUse[startPos] == ';' // UDMF TEXTMAP.
|
||||
|| inComment != 0)
|
||||
&& startPos < stringLength)
|
||||
|
@ -1842,6 +1841,23 @@ char *M_GetToken(const char *inputString)
|
|||
texturesToken[1] = '\0';
|
||||
return texturesToken;
|
||||
}
|
||||
// Return entire string within quotes, except without the quotes.
|
||||
else if (stringToUse[startPos] == '"')
|
||||
{
|
||||
endPos = ++startPos;
|
||||
while (stringToUse[endPos] != '"' && endPos < stringLength)
|
||||
endPos++;
|
||||
|
||||
texturesTokenLength = endPos++ - startPos;
|
||||
// Assign the memory. Don't forget an extra byte for the end of the string!
|
||||
texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
|
||||
// Copy the string.
|
||||
M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength);
|
||||
// Make the final character NUL.
|
||||
texturesToken[texturesTokenLength] = '\0';
|
||||
|
||||
return texturesToken;
|
||||
}
|
||||
|
||||
// Now find the end of the token. This includes several additional characters that are okay to capture as one character, but not trailing at the end of another token.
|
||||
endPos = startPos + 1;
|
||||
|
@ -1852,7 +1868,6 @@ char *M_GetToken(const char *inputString)
|
|||
&& stringToUse[endPos] != ','
|
||||
&& stringToUse[endPos] != '{'
|
||||
&& stringToUse[endPos] != '}'
|
||||
&& stringToUse[endPos] != '"' // see above
|
||||
&& stringToUse[endPos] != '=' && stringToUse[endPos] != ';' // UDMF TEXTMAP.
|
||||
&& inComment == 0)
|
||||
&& endPos < stringLength)
|
||||
|
|
Loading…
Reference in a new issue