1
0
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:
rubidium
2009-01-18 13:12:57 +00:00
parent b8219eb7a1
commit 07e135547e
5 changed files with 13 additions and 6 deletions

View File

@@ -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++ = '?';