diff options
author | rubidium <rubidium@openttd.org> | 2014-09-06 18:10:36 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-09-06 18:10:36 +0000 |
commit | e63ca12ab815e0cd4d5cc7fd129cde04f7c4404a (patch) | |
tree | e4fdbec2bc1b60a37442d882cfe3df8f8d85a6e8 /src/script | |
parent | 33ab50556760a84d6754235e553c68ada2f35a63 (diff) | |
download | openttd-e63ca12ab815e0cd4d5cc7fd129cde04f7c4404a.tar.xz |
(svn r26775) -Cleanup [Squirrel]: "resolve" several of the unicode wrapper defines
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/script_info_dummy.cpp | 4 | ||||
-rw-r--r-- | src/script/squirrel.cpp | 15 | ||||
-rw-r--r-- | src/script/squirrel_std.cpp | 11 |
3 files changed, 16 insertions, 14 deletions
diff --git a/src/script/script_info_dummy.cpp b/src/script/script_info_dummy.cpp index 049e59342..15f417c58 100644 --- a/src/script/script_info_dummy.cpp +++ b/src/script/script_info_dummy.cpp @@ -46,7 +46,7 @@ void Script_CreateDummyInfo(HSQUIRRELVM vm, const char *type, const char *dir) sq_pushroottable(vm); /* Load and run the script */ - if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, scstrlen(sq_dummy_script), "dummy", SQTrue))) { + if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) { sq_push(vm, -2); if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) { sq_pop(vm, 1); @@ -101,7 +101,7 @@ void Script_CreateDummy(HSQUIRRELVM vm, StringID string, const char *type) /* And finally we load and run the script */ sq_pushroottable(vm); - if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, scstrlen(sq_dummy_script), "dummy", SQTrue))) { + if (SQ_SUCCEEDED(sq_compilebuffer(vm, sq_dummy_script, strlen(sq_dummy_script), "dummy", SQTrue))) { sq_push(vm, -2); if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) { sq_pop(vm, 1); diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index dc71d1ef4..bfffc5c3d 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -21,7 +21,8 @@ /* Due to the different characters for Squirrel, the scsnprintf might be a simple * snprint which triggers the safeguard. But it isn't always a simple snprintf. - * Likewise for scvsnprintf and scstrcat. */ + * Likewise for scvsnprintf and scstrcat. + * TODO: use properly safe functions now that Squirrel uses chars exclusively. */ #include "../safeguards.h" #undef snprintf #undef vsnprintf @@ -50,13 +51,13 @@ void Squirrel::ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) SQChar buf[1024]; va_start(arglist, s); - scvsnprintf(buf, lengthof(buf), s, arglist); + vsnprintf(buf, lengthof(buf), s, arglist); va_end(arglist); /* Check if we have a custom print function */ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func; if (func == NULL) { - scfprintf(stderr, "%s", buf); + fprintf(stderr, "%s", buf); } else { (*func)(true, buf); } @@ -74,7 +75,7 @@ void Squirrel::RunError(HSQUIRRELVM vm, const SQChar *error) Squirrel *engine = (Squirrel *)sq_getforeignptr(vm); SQPrintFunc *func = engine->print_func; if (func == NULL) { - scfprintf(stderr, "%s", buf); + fprintf(stderr, "%s", buf); } else { (*func)(true, buf); } @@ -106,14 +107,14 @@ void Squirrel::PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) SQChar buf[1024]; va_start(arglist, s); - scvsnprintf(buf, lengthof(buf) - 2, s, arglist); + vsnprintf(buf, lengthof(buf) - 2, s, arglist); va_end(arglist); - scstrcat(buf, "\n"); + strcat(buf, "\n"); /* Check if we have a custom print function */ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func; if (func == NULL) { - scprintf("%s", buf); + printf("%s", buf); } else { (*func)(false, buf); } diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp index ccd8affc1..ccebe2015 100644 --- a/src/script/squirrel_std.cpp +++ b/src/script/squirrel_std.cpp @@ -19,7 +19,8 @@ #include "../string_func.h" /* Due to the different characters for Squirrel, the scstrcat might be a simple - * strcat which triggers the safeguard. But it isn't always a simple strcat. */ + * strcat which triggers the safeguard. But it isn't always a simple strcat. + * TODO: use properly safe functions now that Squirrel uses chars exclusively. */ #include "../safeguards.h" #undef strcat #undef strdup @@ -60,9 +61,9 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm) DEBUG(misc, 0, "[squirrel] Couldn't detect the script-name of the 'require'-caller; this should never happen!"); return SQ_ERROR; } - real_filename = scstrdup(si.source); + real_filename = strdup(si.source); /* Keep the dir, remove the rest */ - SQChar *s = scstrrchr(real_filename, PATHSEPCHAR); + SQChar *s = strrchr(real_filename, PATHSEPCHAR); if (s != NULL) { /* Keep the PATHSEPCHAR there, remove the rest */ s++; @@ -70,8 +71,8 @@ SQInteger SquirrelStd::require(HSQUIRRELVM vm) } /* And now we concat, so we are relative from the current script * First, we have to make sure we have enough space for the full path */ - real_filename = ReallocT(real_filename, scstrlen(real_filename) + scstrlen(filename) + 1); - scstrcat(real_filename, filename); + real_filename = ReallocT(real_filename, strlen(real_filename) + strlen(filename) + 1); + strcat(real_filename, filename); /* Tars dislike opening files with '/' on Windows.. so convert it to '\\' ;) */ char *filen = stredup(real_filename); #if (PATHSEPCHAR != '/') |