diff --git a/src/stdafx.h b/src/stdafx.h index 0584cb36fc..cc5dce3972 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -82,12 +82,6 @@ # define CDECL #endif /* __GNUC__ || __clang__ */ -#if __GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1) -# define NOACCESS(args) __attribute__ ((access (none, args))) -#else -# define NOACCESS(args) -#endif - #if defined(_WIN32) # define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif diff --git a/src/string.cpp b/src/string.cpp index a5e6a7242c..2413d37ae3 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -188,30 +188,17 @@ static void StrMakeValid(T &dst, const char *str, const char *last, StringValida } /** - * Scans the string for invalid characters and replaces then with a + * Scans the string for invalid characters and replaces them with a * question mark '?' (if not ignored). * @param str The string to validate. - * @param last The last valid character of str. * @param settings The settings for the string validation. - */ -void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings) -{ - char *dst = str; - StrMakeValid(dst, str, last, settings); - *dst = '\0'; -} - -/** - * Scans the string for invalid characters and replaces then with a - * question mark '?' (if not ignored). - * Only use this function when you are sure the string ends with a '\0'; - * otherwise use StrMakeValidInPlace(str, last, settings) variant. - * @param str The string (of which you are sure ends with '\0') to validate. + * @note The string must be properly NUL terminated. */ void StrMakeValidInPlace(char *str, StringValidationSettings settings) { - /* We know it is '\0' terminated. */ - StrMakeValidInPlace(str, str + strlen(str), settings); + char *dst = str; + StrMakeValid(dst, str, str + strlen(str), settings); + *dst = '\0'; } /** diff --git a/src/string_func.h b/src/string_func.h index 7a37952a6e..9fd207289c 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -21,7 +21,6 @@ void strecpy(std::span dst, std::string_view src); std::string FormatArrayAsHex(std::span data); -void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK) NOACCESS(2); [[nodiscard]] std::string StrMakeValid(std::string_view str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); void StrMakeValidInPlace(char *str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);