mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-22 22:19:08 +00:00
(svn r15135) -Fix/Change: allow str_validate (part of receiving strings from the network) to pass newlines instead of replacing them with question marks, but only when asked to do so.
This commit is contained in:
@@ -98,7 +98,7 @@ char *CDECL str_fmt(const char *str, ...)
|
||||
}
|
||||
|
||||
|
||||
void str_validate(char *str)
|
||||
void str_validate(char *str, bool allow_newlines)
|
||||
{
|
||||
char *dst = str;
|
||||
WChar c;
|
||||
@@ -113,7 +113,14 @@ void str_validate(char *str)
|
||||
do {
|
||||
*dst++ = *str++;
|
||||
} while (--len != 0);
|
||||
} else if (allow_newlines && c == '\n') {
|
||||
*dst++ = *str++;
|
||||
} else {
|
||||
if (allow_newlines && c == '\r' && str[1] == '\n') {
|
||||
str += len;
|
||||
continue;
|
||||
}
|
||||
assert(c != '\r');
|
||||
/* Replace the undesirable character with a question mark */
|
||||
str += len;
|
||||
*dst++ = '?';
|
||||
|
Reference in New Issue
Block a user