added support for escape characters in SMC files
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401079
This commit is contained in:
parent
9a2fbe5f9f
commit
3f4158aa7e
@ -166,10 +166,36 @@ const char *FixupString(StringInfo &data)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do some extra work on strings that have special quoted characters. */
|
||||
if (data.special)
|
||||
{
|
||||
//:TODO: this string has special tokens in it, like \, and we must
|
||||
//resolve these before passing the string back to the app
|
||||
char *outptr = data.ptr;
|
||||
size_t len = data.end - data.ptr;
|
||||
if (len >= 2)
|
||||
{
|
||||
for (size_t i=0; i<len; i++)
|
||||
{
|
||||
if (data.ptr[i] == '\\' && i < len - 1)
|
||||
{
|
||||
/* Resolve the next character. */
|
||||
i++;
|
||||
if (data.ptr[i] == 'n')
|
||||
{
|
||||
data.ptr[i] = '\n';
|
||||
} else if (data.ptr[i] == 't') {
|
||||
data.ptr[i] = '\t';
|
||||
} else if (data.ptr[i] == 'r') {
|
||||
data.ptr[i] = '\r';
|
||||
} else if (data.ptr[i] != '\\'
|
||||
&& data.ptr[i] != '"') {
|
||||
/* This character is invalid, so go back one */
|
||||
i--;
|
||||
}
|
||||
}
|
||||
*outptr++ = data.ptr[i];
|
||||
}
|
||||
*outptr = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
*(data.end) = '\0';
|
||||
@ -357,10 +383,13 @@ SMCParseError TextParsers::ParseStream_SMC(void *stream,
|
||||
err = SMCParse_InvalidTokens;
|
||||
goto failed;
|
||||
}
|
||||
} else if (c == '\\' && i == (read - 1)) {
|
||||
} else if (c == '\\') {
|
||||
strings[0].special = true;
|
||||
reparse_point = &parse_point[i];
|
||||
break;
|
||||
if (i == (read - 1))
|
||||
{
|
||||
reparse_point = &parse_point[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (ml_comment) {
|
||||
if (c == '*')
|
||||
|
@ -8,7 +8,7 @@
|
||||
"More than one client matches"
|
||||
{
|
||||
"#format" "{1:s}"
|
||||
"en" "More than one client matches the pattern '{1}'"
|
||||
"en" "More than one client matches the pattern \"{1}\""
|
||||
}
|
||||
|
||||
"Kicked player"
|
||||
|
@ -14,49 +14,49 @@
|
||||
"Value of cvar"
|
||||
{
|
||||
"#format" "{1:s},{2:s}"
|
||||
"en" "Value of cvar '{1}': '{2}'"
|
||||
"en" "Value of cvar \"{1}\": \"{2}\""
|
||||
}
|
||||
|
||||
"Cvar changed"
|
||||
{
|
||||
"#format" "{1:s},{2:s}"
|
||||
"en" "Changed cvar '{1}' to '{2}'."
|
||||
"en" "Changed cvar \"{1}\" to \"{2}\"."
|
||||
}
|
||||
|
||||
"Config not found"
|
||||
{
|
||||
"#format" "{1:s}"
|
||||
"en" "Config file '{1}' not found."
|
||||
"en" "Config file \"{1}\" not found."
|
||||
}
|
||||
|
||||
"Executed config"
|
||||
{
|
||||
"#format" "{1:s}"
|
||||
"en" "Executed config '{1}'."
|
||||
"en" "Executed config \"{1}\"."
|
||||
}
|
||||
|
||||
"Permabanned player"
|
||||
{
|
||||
"#format" "{1:s}"
|
||||
"en" "Permanently banned player '{1}'."
|
||||
"en" "Permanently banned player \"{1}\"."
|
||||
}
|
||||
|
||||
"Permabanned player reason"
|
||||
{
|
||||
"#format" "{1:s},{2:s}"
|
||||
"en" "Permanently banned player '{1}' (reason: {2})."
|
||||
"en" "Permanently banned player \"{1}\" (reason: {2})."
|
||||
}
|
||||
|
||||
"Banned player"
|
||||
{
|
||||
"#format" "{1:s},{2:d}"
|
||||
"en" "Banned player '{1}' for {2} minutes."
|
||||
"en" "Banned player \"{1}\" for {2} minutes."
|
||||
}
|
||||
|
||||
"Banned player reason"
|
||||
{
|
||||
"#format" "{1:s},{2:d},{3:s}"
|
||||
"en" "Banned player '{1}' for {2} minutes (reason: {3})."
|
||||
"en" "Banned player \"{1}\" for {2} minutes (reason: {3})."
|
||||
}
|
||||
|
||||
"Removed bans matching"
|
||||
@ -69,4 +69,9 @@
|
||||
{
|
||||
"en" "Ban has been added."
|
||||
}
|
||||
|
||||
"Admin cache refreshed"
|
||||
{
|
||||
"en" "Admin cache has been refreshed."
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user