summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/script/api/script_text.cpp2
-rw-r--r--src/script/script_info.cpp8
-rw-r--r--src/script/squirrel.cpp2
-rw-r--r--src/string.cpp4
-rw-r--r--src/string_func.h2
5 files changed, 9 insertions, 9 deletions
diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp
index dd32d0d42..eeb7b2221 100644
--- a/src/script/api/script_text.cpp
+++ b/src/script/api/script_text.cpp
@@ -157,7 +157,7 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
if (sq_gettype(vm, 2) == OT_STRING) {
const SQChar *key_string;
sq_getstring(vm, 2, &key_string);
- StrMakeValidInPlace(key_string);
+ StrMakeValidInPlace(const_cast<char *>(key_string));
if (strncmp(key_string, "param_", 6) != 0 || strlen(key_string) > 8) return SQ_ERROR;
k = atoi(key_string + 6);
diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp
index 17b0e1969..d381ae9c2 100644
--- a/src/script/script_info.cpp
+++ b/src/script/script_info.cpp
@@ -122,7 +122,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
while (SQ_SUCCEEDED(sq_next(vm, -2))) {
const SQChar *key;
if (SQ_FAILED(sq_getstring(vm, -2, &key))) return SQ_ERROR;
- StrMakeValidInPlace(key);
+ StrMakeValidInPlace(const_cast<char *>(key));
if (strcmp(key, "name") == 0) {
const SQChar *sqvalue;
@@ -141,7 +141,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
const SQChar *sqdescription;
if (SQ_FAILED(sq_getstring(vm, -1, &sqdescription))) return SQ_ERROR;
config.description = stredup(sqdescription);
- StrMakeValidInPlace(config.description);
+ StrMakeValidInPlace(const_cast<char *>(config.description));
items |= 0x002;
} else if (strcmp(key, "min_value") == 0) {
SQInteger res;
@@ -226,7 +226,7 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
{
const SQChar *setting_name;
if (SQ_FAILED(sq_getstring(vm, -2, &setting_name))) return SQ_ERROR;
- StrMakeValidInPlace(setting_name);
+ StrMakeValidInPlace(const_cast<char *>(setting_name));
ScriptConfigItem *config = nullptr;
for (auto &item : this->config_list) {
@@ -253,7 +253,7 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
/* Because squirrel doesn't support identifiers starting with a digit,
* we skip the first character. */
int key = atoi(key_string + 1);
- StrMakeValidInPlace(label);
+ StrMakeValidInPlace(const_cast<char *>(label));
/* !Contains() prevents stredup from leaking. */
if (!config->labels->Contains(key)) config->labels->Insert(key, stredup(label));
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp
index 89d86180d..aa698af83 100644
--- a/src/script/squirrel.cpp
+++ b/src/script/squirrel.cpp
@@ -448,7 +448,7 @@ bool Squirrel::CallStringMethodStrdup(HSQOBJECT instance, const char *method_nam
if (!this->CallMethod(instance, method_name, &ret, suspend)) return false;
if (ret._type != OT_STRING) return false;
*res = stredup(ObjectToString(&ret));
- StrMakeValidInPlace(*res);
+ StrMakeValidInPlace(const_cast<char *>(*res));
return true;
}
diff --git a/src/string.cpp b/src/string.cpp
index 930d0dba1..1cf61e8b4 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -266,10 +266,10 @@ void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings s
* otherwise use StrMakeValidInPlace(str, last, settings) variant.
* @param str The string (of which you are sure ends with '\0') to validate.
*/
-void StrMakeValidInPlace(const char *str, StringValidationSettings settings)
+void StrMakeValidInPlace(char *str, StringValidationSettings settings)
{
/* We know it is '\0' terminated. */
- StrMakeValidInPlace(const_cast<char *>(str), str + strlen(str), settings);
+ StrMakeValidInPlace(str, str + strlen(str), settings);
}
/**
diff --git a/src/string_func.h b/src/string_func.h
index be409072e..0988f01b3 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -41,7 +41,7 @@ char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2);
void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK) NOACCESS(2);
[[nodiscard]] std::string StrMakeValid(const std::string &str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
-void StrMakeValidInPlace(const char *str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
+void StrMakeValidInPlace(char *str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
void str_fix_scc_encoded(char *str, const char *last) NOACCESS(2);
void str_strip_colours(char *str);