diff options
author | rubidium <rubidium@openttd.org> | 2011-12-18 18:37:54 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-12-18 18:37:54 +0000 |
commit | fefe22b4aa5194af499763d3cc4d4dc19116fa92 (patch) | |
tree | 5b2671aa4bc5b68584d962d11a8ceab705ad6321 /src/string.cpp | |
parent | 6ae8cac4320e098c1fa628a3afd5c090aacc80a2 (diff) | |
download | openttd-fefe22b4aa5194af499763d3cc4d4dc19116fa92.tar.xz |
(svn r23590) -Codechange: make the string validation settings better expandable
Diffstat (limited to 'src/string.cpp')
-rw-r--r-- | src/string.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/string.cpp b/src/string.cpp index 0c2777371..94377c1b6 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -184,10 +184,9 @@ char *CDECL str_fmt(const char *str, ...) * replaces them with a question mark '?' (if not ignored) * @param str the string to validate * @param last the last valid character of str - * @param allow_newlines whether newlines should be allowed or ignored - * @param ignore whether to ignore or replace with a question mark + * @param settings the settings for the string validation. */ -void str_validate(char *str, const char *last, bool allow_newlines, bool ignore) +void str_validate(char *str, const char *last, StringValidationSettings settings) { /* Assume the ABSOLUTE WORST to be in str as it comes from the outside. */ @@ -215,16 +214,16 @@ void str_validate(char *str, const char *last, bool allow_newlines, bool ignore) do { *dst++ = *str++; } while (--len != 0); - } else if (allow_newlines && c == '\n') { + } else if ((settings & SVS_ALLOW_NEWLINE) != 0 && c == '\n') { *dst++ = *str++; } else { - if (allow_newlines && c == '\r' && str[1] == '\n') { + if ((settings & SVS_ALLOW_NEWLINE) != 0 && c == '\r' && str[1] == '\n') { str += len; continue; } /* Replace the undesirable character with a question mark */ str += len; - if (!ignore) *dst++ = '?'; + if ((settings & SVS_REPLACE_WITH_QUESTION_MARK) != 0) *dst++ = '?'; /* In case of these two special cases assume that they really * mean SETX/SETXY and also "eat" the paramater. If this was |