(svn r26775) -Cleanup [Squirrel]: "resolve" several of the unicode wrapper defines

This commit is contained in:
rubidium
2014-09-06 18:10:36 +00:00
parent 65cab46a84
commit a7044da533
17 changed files with 130 additions and 152 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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 != '/')