From e63ca12ab815e0cd4d5cc7fd129cde04f7c4404a Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 6 Sep 2014 18:10:36 +0000 Subject: [PATCH] (svn r26775) -Cleanup [Squirrel]: "resolve" several of the unicode wrapper defines --- src/3rdparty/squirrel/etc/minimal.c | 2 +- src/3rdparty/squirrel/include/squirrel.h | 24 ------- src/3rdparty/squirrel/sq/sq.c | 26 ++++---- src/3rdparty/squirrel/sqstdlib/sqstdaux.cpp | 4 +- src/3rdparty/squirrel/sqstdlib/sqstdrex.cpp | 16 ++--- .../squirrel/sqstdlib/sqstdstring.cpp | 14 ++-- src/3rdparty/squirrel/squirrel/sqapi.cpp | 2 +- src/3rdparty/squirrel/squirrel/sqbaselib.cpp | 8 +-- src/3rdparty/squirrel/squirrel/sqcompiler.cpp | 2 +- src/3rdparty/squirrel/squirrel/sqdebug.cpp | 6 +- .../squirrel/squirrel/sqfuncstate.cpp | 66 +++++++++---------- src/3rdparty/squirrel/squirrel/sqlexer.cpp | 22 +++---- src/3rdparty/squirrel/squirrel/sqstate.cpp | 2 +- src/3rdparty/squirrel/squirrel/sqvm.cpp | 58 ++++++++-------- src/script/script_info_dummy.cpp | 4 +- src/script/squirrel.cpp | 15 +++-- src/script/squirrel_std.cpp | 11 ++-- 17 files changed, 130 insertions(+), 152 deletions(-) diff --git a/src/3rdparty/squirrel/etc/minimal.c b/src/3rdparty/squirrel/etc/minimal.c index dfbff0cc12..660647be4f 100644 --- a/src/3rdparty/squirrel/etc/minimal.c +++ b/src/3rdparty/squirrel/etc/minimal.c @@ -16,7 +16,7 @@ void printfunc(HSQUIRRELVM v, const SQChar *s, ...) { va_list arglist; va_start(arglist, s); -scvprintf(s, arglist); +vprintf(s, arglist); va_end(arglist); } diff --git a/src/3rdparty/squirrel/include/squirrel.h b/src/3rdparty/squirrel/include/squirrel.h index 9ed0e550c0..9a58adca61 100644 --- a/src/3rdparty/squirrel/include/squirrel.h +++ b/src/3rdparty/squirrel/include/squirrel.h @@ -90,30 +90,6 @@ struct SQInstance; struct SQDelegable; typedef char SQChar; -#define scstrcmp strcmp -#define scsprintf sprintf -#define scsnprintf snprintf -#define scstrlen strlen -#define scstrtod strtod -#define scstrtol strtol -#define scatoi atoi -#define scstrtoul strtoul -#define scvsprintf vsprintf -#define scstrstr strstr -#define scisspace isspace -#define scisdigit isdigit -#define scisxdigit isxdigit -#define sciscntrl iscntrl -#define scisalpha isalpha -#define scisalnum isalnum -#define scprintf printf -#define scfprintf fprintf -#define scvprintf vprintf -#define scvfprintf vfprintf -#define scvsnprintf vsnprintf -#define scstrdup strdup -#define scstrrchr strrchr -#define scstrcat strcat #define MAX_CHAR 0xFFFF #if defined(_MSC_VER) || defined(__MINGW32__) diff --git a/src/3rdparty/squirrel/sq/sq.c b/src/3rdparty/squirrel/sq/sq.c index 5044025cf6..0b6c014a99 100644 --- a/src/3rdparty/squirrel/sq/sq.c +++ b/src/3rdparty/squirrel/sq/sq.c @@ -46,21 +46,21 @@ void printfunc(HSQUIRRELVM v,const SQChar *s,...) { va_list vl; va_start(vl, s); - scvprintf( s, vl); + vprintf( s, vl); va_end(vl); } void PrintVersionInfos() { - scfprintf(stdout,"%s %s (%d bits)\n",SQUIRREL_VERSION,SQUIRREL_COPYRIGHT,sizeof(SQInteger)*8); + fprintf(stdout,"%s %s (%d bits)\n",SQUIRREL_VERSION,SQUIRREL_COPYRIGHT,sizeof(SQInteger)*8); if(sizeof(SQFloat) != sizeof(float)) { - scfprintf(stdout,"[%d bits floats]\n",sizeof(SQFloat)*8); + fprintf(stdout,"[%d bits floats]\n",sizeof(SQFloat)*8); } } void PrintUsage() { - scfprintf(stderr,"usage: sq .\n" + fprintf(stderr,"usage: sq .\n" "Available options are:\n" " -c compiles the file to bytecode(default output 'out.cnut')\n" " -o specifies output file for the -c option\n" @@ -113,7 +113,7 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[]) return _DONE; default: PrintVersionInfos(); - scprintf("unknown prameter '-%c'\n",argv[arg][1]); + printf("unknown prameter '-%c'\n",argv[arg][1]); PrintUsage(); return _DONE; } @@ -161,7 +161,7 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[]) const SQChar *err; sq_getlasterror(v); if(SQ_SUCCEEDED(sq_getstring(v,-1,&err))) { - scprintf("Error [%s]\n",err); + printf("Error [%s]\n",err); return _DONE; } } @@ -194,7 +194,7 @@ void Interactive(HSQUIRRELVM v) while (!done) { SQInteger i = 0; - scprintf("\nsq>"); + printf("\nsq>"); for(;;) { int c; if(done)return; @@ -217,7 +217,7 @@ void Interactive(HSQUIRRELVM v) buffer[i++] = (SQChar)c; } else if (i >= MAXINPUT-1) { - scfprintf(stderr, "sq : input line too long\n"); + fprintf(stderr, "sq : input line too long\n"); break; } else{ @@ -227,17 +227,17 @@ void Interactive(HSQUIRRELVM v) buffer[i] = '\0'; if(buffer[0]=='='){ - scsprintf(sq_getscratchpad(v,MAXINPUT),"return (%s)",&buffer[1]); - memcpy(buffer,sq_getscratchpad(v,-1),(scstrlen(sq_getscratchpad(v,-1))+1)*sizeof(SQChar)); + sprintf(sq_getscratchpad(v,MAXINPUT),"return (%s)",&buffer[1]); + memcpy(buffer,sq_getscratchpad(v,-1),(strlen(sq_getscratchpad(v,-1))+1)*sizeof(SQChar)); retval=1; } - i=scstrlen(buffer); + i=strlen(buffer); if(i>0){ SQInteger oldtop=sq_gettop(v); if(SQ_SUCCEEDED(sq_compilebuffer(v,buffer,i,"interactive console",SQTrue))){ sq_pushroottable(v); if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue)) && retval){ - scprintf("\n"); + printf("\n"); sq_pushroottable(v); sq_pushstring(v,"print",-1); sq_get(v,-2); @@ -245,7 +245,7 @@ void Interactive(HSQUIRRELVM v) sq_push(v,-4); sq_call(v,2,SQFalse,SQTrue); retval=0; - scprintf("\n"); + printf("\n"); } } diff --git a/src/3rdparty/squirrel/sqstdlib/sqstdaux.cpp b/src/3rdparty/squirrel/sqstdlib/sqstdaux.cpp index e4c266362c..c4002bf2ca 100644 --- a/src/3rdparty/squirrel/sqstdlib/sqstdaux.cpp +++ b/src/3rdparty/squirrel/sqstdlib/sqstdaux.cpp @@ -27,8 +27,8 @@ void sqstd_printcallstack(HSQUIRRELVM v) * Since the path only reaches NoAI code in a formatted string we have * to strip it here. Let's hope nobody installs openttd in a subdirectory * of a directory named /ai/. */ - src = scstrstr(si.source, "\\ai\\"); - if (!src) src = scstrstr(si.source, "/ai/"); + src = strstr(si.source, "\\ai\\"); + if (!src) src = strstr(si.source, "/ai/"); if (src) { src += 4; } else { diff --git a/src/3rdparty/squirrel/sqstdlib/sqstdrex.cpp b/src/3rdparty/squirrel/sqstdlib/sqstdrex.cpp index a7aa5303da..4029bff62f 100644 --- a/src/3rdparty/squirrel/sqstdlib/sqstdrex.cpp +++ b/src/3rdparty/squirrel/sqstdlib/sqstdrex.cpp @@ -526,7 +526,7 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex)); exp->_eol = exp->_bol = NULL; exp->_p = pattern; - exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar); + exp->_nallocated = (SQInteger)strlen(pattern) * sizeof(SQChar); exp->_nodes = (SQRexNode *)sq_malloc(exp->_nallocated * sizeof(SQRexNode)); exp->_nsize = 0; exp->_matches = 0; @@ -544,16 +544,16 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) SQRexNode *t; nsize = exp->_nsize; t = &exp->_nodes[0]; - scprintf("\n"); + printf("\n"); /* XXX -- The (int) casts are needed to silent warnings on 64bit systems (SQInteger is 64bit, %d assumes 32bit, (int) is 32bit) */ for(i = 0;i < nsize; i++) { if(exp->_nodes[i].type>MAX_CHAR) - scprintf("[%02d] %10s ",(int)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); + printf("[%02d] %10s ",(int)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); else - scprintf("[%02d] %10c ",(int)i,exp->_nodes[i].type); - scprintf("left %02d right %02d next %02d\n",(int)exp->_nodes[i].left,(int)exp->_nodes[i].right,(int)exp->_nodes[i].next); + printf("[%02d] %10c ",(int)i,exp->_nodes[i].type); + printf("left %02d right %02d next %02d\n",(int)exp->_nodes[i].left,(int)exp->_nodes[i].right,(int)exp->_nodes[i].next); } - scprintf("\n"); + printf("\n"); } #endif exp->_matches = (SQRexMatch *) sq_malloc(exp->_nsubexpr * sizeof(SQRexMatch)); @@ -579,7 +579,7 @@ SQBool sqstd_rex_match(SQRex* exp,const SQChar* text) { const SQChar* res = NULL; exp->_bol = text; - exp->_eol = text + scstrlen(text); + exp->_eol = text + strlen(text); exp->_currsubexp = 0; res = sqstd_rex_matchnode(exp,exp->_nodes,text,NULL); if(res == NULL || res != exp->_eol) @@ -618,7 +618,7 @@ SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* t SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end) { - return sqstd_rex_searchrange(exp,text,text + scstrlen(text),out_begin,out_end); + return sqstd_rex_searchrange(exp,text,text + strlen(text),out_begin,out_end); } SQInteger sqstd_rex_getsubexpcount(SQRex* exp) diff --git a/src/3rdparty/squirrel/sqstdlib/sqstdstring.cpp b/src/3rdparty/squirrel/sqstdlib/sqstdstring.cpp index 1671f0b1a4..777302efce 100644 --- a/src/3rdparty/squirrel/sqstdlib/sqstdstring.cpp +++ b/src/3rdparty/squirrel/sqstdlib/sqstdstring.cpp @@ -22,7 +22,7 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, SQInteger start = n; fmt[0] = '%'; while (scstrchr("-+ #0", src[n])) n++; - while (scisdigit(src[n])) { + while (isdigit(src[n])) { swidth[wc] = src[n]; n++; wc++; @@ -31,7 +31,7 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, } swidth[wc] = '\0'; if(wc > 0) { - width = scatoi(swidth); + width = atoi(swidth); } else width = 0; @@ -39,7 +39,7 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, n++; wc = 0; - while (scisdigit(src[n])) { + while (isdigit(src[n])) { swidth[wc] = src[n]; n++; wc++; @@ -48,7 +48,7 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src, } swidth[wc] = '\0'; if(wc > 0) { - width += scatoi(swidth); + width += atoi(swidth); } } if (n-start > MAX_FORMAT_LEN ) @@ -69,7 +69,7 @@ static void _append_string(SQInteger &i, SQChar *dest, SQInteger allocated, cons { va_list va; va_start(va, fmt); - i += scvsnprintf(&dest[i],allocated-i,fmt,va); + i += vsnprintf(&dest[i],allocated-i,fmt,va); va_end(va); } @@ -156,7 +156,7 @@ static SQInteger _string_format(HSQUIRRELVM v) static void __strip_l(const SQChar *str,const SQChar **start) { const SQChar *t = str; - while(((*t) != '\0') && scisspace(*t)){ t++; } + while(((*t) != '\0') && isspace(*t)){ t++; } *start = t; } @@ -167,7 +167,7 @@ static void __strip_r(const SQChar *str,SQInteger len,const SQChar **end) return; } const SQChar *t = &str[len-1]; - while(t != str && scisspace(*t)) { t--; } + while(t != str && isspace(*t)) { t--; } *end = t+1; } diff --git a/src/3rdparty/squirrel/squirrel/sqapi.cpp b/src/3rdparty/squirrel/squirrel/sqapi.cpp index 6dc3def6e2..1f523e71cf 100644 --- a/src/3rdparty/squirrel/squirrel/sqapi.cpp +++ b/src/3rdparty/squirrel/squirrel/sqapi.cpp @@ -40,7 +40,7 @@ SQInteger sq_aux_throwobject(HSQUIRRELVM v,SQObjectPtr &e) SQInteger sq_aux_invalidtype(HSQUIRRELVM v,SQObjectType type) { - scsprintf(_ss(v)->GetScratchPad(100), "unexpected type %s", IdType2Name(type)); + sprintf(_ss(v)->GetScratchPad(100), "unexpected type %s", IdType2Name(type)); return sq_throwerror(v, _ss(v)->GetScratchPad(-1)); } diff --git a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp index e952a60816..f29ed60be7 100644 --- a/src/3rdparty/squirrel/squirrel/sqbaselib.cpp +++ b/src/3rdparty/squirrel/squirrel/sqbaselib.cpp @@ -19,14 +19,14 @@ bool str2num(const SQChar *s,SQObjectPtr &res) { SQChar *end; - if(scstrstr(s,".")){ - SQFloat r = SQFloat(scstrtod(s,&end)); + if(strstr(s,".")){ + SQFloat r = SQFloat(strtod(s,&end)); if(s == end) return false; res = r; return true; } else{ - SQInteger r = SQInteger(scstrtol(s,&end,10)); + SQInteger r = SQInteger(strtol(s,&end,10)); if(s == end) return false; res = r; return true; @@ -651,7 +651,7 @@ static SQInteger string_find(HSQUIRRELVM v) if(((top=sq_gettop(v))>1) && SQ_SUCCEEDED(sq_getstring(v,1,&str)) && SQ_SUCCEEDED(sq_getstring(v,2,&substr))){ if(top>2)sq_getinteger(v,3,&start_idx); if((sq_getsize(v,1)>start_idx) && (start_idx>=0)){ - ret=scstrstr(&str[start_idx],substr); + ret=strstr(&str[start_idx],substr); if(ret){ sq_pushinteger(v,(SQInteger)(ret-str)); return 1; diff --git a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp index f0b8536cee..fc6ede6ac9 100644 --- a/src/3rdparty/squirrel/squirrel/sqcompiler.cpp +++ b/src/3rdparty/squirrel/squirrel/sqcompiler.cpp @@ -66,7 +66,7 @@ public: static SQChar temp[256]; va_list vl; va_start(vl, s); - scvsnprintf(temp, sizeof(temp), s, vl); + vsnprintf(temp, sizeof(temp), s, vl); va_end(vl); throw temp; } diff --git a/src/3rdparty/squirrel/squirrel/sqdebug.cpp b/src/3rdparty/squirrel/squirrel/sqdebug.cpp index 43bf7df042..54f883f4ee 100644 --- a/src/3rdparty/squirrel/squirrel/sqdebug.cpp +++ b/src/3rdparty/squirrel/squirrel/sqdebug.cpp @@ -60,7 +60,7 @@ void SQVM::Raise_Error(const SQChar *s, ...) { va_list vl; va_start(vl, s); - scvsprintf(_sp(rsl((SQInteger)scstrlen(s)+(NUMBER_MAX_CHAR*2))), s, vl); + vsprintf(_sp(rsl((SQInteger)strlen(s)+(NUMBER_MAX_CHAR*2))), s, vl); va_end(vl); _lasterror = SQString::Create(_ss(this),_spval,-1); } @@ -75,11 +75,11 @@ SQString *SQVM::PrintObjVal(const SQObject &o) switch(type(o)) { case OT_STRING: return _string(o); case OT_INTEGER: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), SQ_PRINTF64, _integer(o)); + sprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), SQ_PRINTF64, _integer(o)); return SQString::Create(_ss(this), _spval); break; case OT_FLOAT: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), "%.14g", _float(o)); + sprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), "%.14g", _float(o)); return SQString::Create(_ss(this), _spval); break; default: diff --git a/src/3rdparty/squirrel/squirrel/sqfuncstate.cpp b/src/3rdparty/squirrel/squirrel/sqfuncstate.cpp index 760624fbaf..91219adf86 100644 --- a/src/3rdparty/squirrel/squirrel/sqfuncstate.cpp +++ b/src/3rdparty/squirrel/squirrel/sqfuncstate.cpp @@ -78,11 +78,11 @@ SQInstructionDesc g_InstrDesc[]={ void DumpLiteral(SQObjectPtr &o) { switch(type(o)){ - case OT_STRING: scprintf("\"%s\"",_stringval(o));break; - case OT_FLOAT: scprintf("{%f}",_float(o));break; - case OT_INTEGER: scprintf("{" SQ_PRINTF64 "}",_integer(o));break; - case OT_BOOL: scprintf("%s",_integer(o)?"true":"false");break; - default: scprintf("(%s %p)",GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler + case OT_STRING: printf("\"%s\"",_stringval(o));break; + case OT_FLOAT: printf("{%f}",_float(o));break; + case OT_INTEGER: printf("{" SQ_PRINTF64 "}",_integer(o));break; + case OT_BOOL: printf("%s",_integer(o)?"true":"false");break; + default: printf("(%s %p)",GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler } } @@ -115,11 +115,11 @@ void SQFuncState::Dump(SQFunctionProto *func) { SQUnsignedInteger n=0,i; SQInteger si; - scprintf("SQInstruction sizeof %d\n",sizeof(SQInstruction)); - scprintf("SQObject sizeof %d\n",sizeof(SQObject)); - scprintf("--------------------------------------------------------------------\n"); - scprintf("*****FUNCTION [%s]\n",type(func->_name)==OT_STRING?_stringval(func->_name):"unknown"); - scprintf("-----LITERALS\n"); + printf("SQInstruction sizeof %d\n",sizeof(SQInstruction)); + printf("SQObject sizeof %d\n",sizeof(SQObject)); + printf("--------------------------------------------------------------------\n"); + printf("*****FUNCTION [%s]\n",type(func->_name)==OT_STRING?_stringval(func->_name):"unknown"); + printf("-----LITERALS\n"); SQObjectPtr refidx,key,val; SQInteger idx; SQObjectPtrVec templiterals; @@ -129,43 +129,43 @@ void SQFuncState::Dump(SQFunctionProto *func) templiterals[_integer(val)]=key; } for(i=0;i>\n"); + printf("<>\n"); n=0; for(i=0;i<_parameters.size();i++){ - scprintf("[%d] ",n); + printf("[%d] ",n); DumpLiteral(_parameters[i]); - scprintf("\n"); + printf("\n"); n++; } - scprintf("-----LOCALS\n"); + printf("-----LOCALS\n"); for(si=0;si_nlocalvarinfos;si++){ SQLocalVarInfo lvi=func->_localvarinfos[si]; - scprintf("[%d] %s \t%d %d\n",lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op); + printf("[%d] %s \t%d %d\n",lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op); n++; } - scprintf("-----LINE INFO\n"); + printf("-----LINE INFO\n"); for(i=0;i<_lineinfos.size();i++){ SQLineInfo li=_lineinfos[i]; - scprintf("op [%d] line [%d] \n",li._op,li._line); + printf("op [%d] line [%d] \n",li._op,li._line); n++; } - scprintf("-----dump\n"); + printf("-----dump\n"); n=0; for(i=0;i<_instructions.size();i++){ SQInstruction &inst=_instructions[i]; if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){ SQInteger lidx = inst._arg1; - scprintf("[%03d] %15s %d ",n,g_InstrDesc[inst.op].name,inst._arg0); + printf("[%03d] %15s %d ",n,g_InstrDesc[inst.op].name,inst._arg0); if(lidx >= 0xFFFFFFFF) - scprintf("null"); + printf("null"); else { SQInteger refidx; SQObjectPtr val,key,refo; @@ -175,13 +175,13 @@ void SQFuncState::Dump(SQFunctionProto *func) DumpLiteral(key); } if(inst.op != _OP_DLOAD) { - scprintf(" %d %d \n",inst._arg2,inst._arg3); + printf(" %d %d \n",inst._arg2,inst._arg3); } else { - scprintf(" %d ",inst._arg2); + printf(" %d ",inst._arg2); lidx = inst._arg3; if(lidx >= 0xFFFFFFFF) - scprintf("null"); + printf("null"); else { SQInteger refidx; SQObjectPtr val,key,refo; @@ -189,23 +189,23 @@ void SQFuncState::Dump(SQFunctionProto *func) refo = refidx; } DumpLiteral(key); - scprintf("\n"); + printf("\n"); } } } else if(inst.op==_OP_LOADFLOAT) { - scprintf("[%03d] %15s %d %f %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3); + printf("[%03d] %15s %d %f %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3); } else if(inst.op==_OP_ARITH){ - scprintf("[%03d] %15s %d %d %d %c\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); + printf("[%03d] %15s %d %d %d %c\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); } else - scprintf("[%03d] %15s %d %d %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); + printf("[%03d] %15s %d %d %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); n++; } - scprintf("-----\n"); - scprintf("stack size[%d]\n",func->_stacksize); - scprintf("--------------------------------------------------------------------\n\n"); + printf("-----\n"); + printf("stack size[%d]\n",func->_stacksize); + printf("--------------------------------------------------------------------\n\n"); } #endif diff --git a/src/3rdparty/squirrel/squirrel/sqlexer.cpp b/src/3rdparty/squirrel/squirrel/sqlexer.cpp index 5d91fa8880..4653ab0a80 100644 --- a/src/3rdparty/squirrel/squirrel/sqlexer.cpp +++ b/src/3rdparty/squirrel/squirrel/sqlexer.cpp @@ -251,17 +251,17 @@ SQInteger SQLexer::Lex() case SQUIRREL_EOB: return 0; default:{ - if (scisdigit(CUR_CHAR)) { + if (isdigit(CUR_CHAR)) { SQInteger ret = ReadNumber(); RETURN_TOKEN(ret); } - else if (scisalpha(CUR_CHAR) || CUR_CHAR == '_') { + else if (isalpha(CUR_CHAR) || CUR_CHAR == '_') { SQInteger t = ReadID(); RETURN_TOKEN(t); } else { SQInteger c = CUR_CHAR; - if (sciscntrl((int)c)) Error("unexpected character(control)"); + if (iscntrl((int)c)) Error("unexpected character(control)"); NEXT(); RETURN_TOKEN(c); } @@ -317,7 +317,7 @@ SQInteger SQLexer::ReadString(LexChar ndelim,bool verbatim) } temp[n] = 0; SQChar *sTemp; - APPEND_CHAR((SQChar)scstrtoul(temp,&sTemp,16)); + APPEND_CHAR((SQChar)strtoul(temp,&sTemp,16)); } break; case 't': APPEND_CHAR('\t'); NEXT(); break; @@ -368,8 +368,8 @@ void LexHexadecimal(const SQChar *s,SQUnsignedInteger *res) *res = 0; while(*s != 0) { - if(scisdigit(*s)) *res = (*res)*16+((*s++)-'0'); - else if(scisxdigit(*s)) *res = (*res)*16+(toupper(*s++)-'A'+10); + if(isdigit(*s)) *res = (*res)*16+((*s++)-'0'); + else if(isxdigit(*s)) *res = (*res)*16+(toupper(*s++)-'A'+10); else { assert(0); } } } @@ -417,7 +417,7 @@ SQInteger SQLexer::ReadNumber() APPEND_CHAR(CUR_CHAR); NEXT(); } - if(scisdigit(CUR_CHAR)) Error("invalid octal number"); + if(isdigit(CUR_CHAR)) Error("invalid octal number"); } else { NEXT(); @@ -431,7 +431,7 @@ SQInteger SQLexer::ReadNumber() } else { APPEND_CHAR((int)firstchar); - while (CUR_CHAR == '.' || scisdigit(CUR_CHAR) || isexponent(CUR_CHAR)) { + while (CUR_CHAR == '.' || isdigit(CUR_CHAR) || isexponent(CUR_CHAR)) { if(CUR_CHAR == '.' || isexponent(CUR_CHAR)) type = TFLOAT; if(isexponent(CUR_CHAR)) { if(type != TFLOAT) Error("invalid numeric format"); @@ -442,7 +442,7 @@ SQInteger SQLexer::ReadNumber() APPEND_CHAR(CUR_CHAR); NEXT(); } - if(!scisdigit(CUR_CHAR)) Error("exponent expected"); + if(!isdigit(CUR_CHAR)) Error("exponent expected"); } APPEND_CHAR(CUR_CHAR); @@ -453,7 +453,7 @@ SQInteger SQLexer::ReadNumber() switch(type) { case TSCIENTIFIC: case TFLOAT: - _fvalue = (SQFloat)scstrtod(&_longstr[0],&sTemp); + _fvalue = (SQFloat)strtod(&_longstr[0],&sTemp); return TK_FLOAT; case TINT: LexInteger(&_longstr[0],(SQUnsignedInteger *)&_nvalue); @@ -475,7 +475,7 @@ SQInteger SQLexer::ReadID() do { APPEND_CHAR(CUR_CHAR); NEXT(); - } while(scisalnum(CUR_CHAR) || CUR_CHAR == '_'); + } while(isalnum(CUR_CHAR) || CUR_CHAR == '_'); TERMINATE_BUFFER(); res = GetIDType(&_longstr[0]); if(res == TK_IDENTIFIER || res == TK_CONSTRUCTOR) { diff --git a/src/3rdparty/squirrel/squirrel/sqstate.cpp b/src/3rdparty/squirrel/squirrel/sqstate.cpp index 1bc5efd6b4..bd270d4705 100644 --- a/src/3rdparty/squirrel/squirrel/sqstate.cpp +++ b/src/3rdparty/squirrel/squirrel/sqstate.cpp @@ -513,7 +513,7 @@ void SQStringTable::AllocNodes(SQInteger size) SQString *SQStringTable::Add(const SQChar *news,SQInteger len) { if(len<0) - len = (SQInteger)scstrlen(news); + len = (SQInteger)strlen(news); SQHash h = ::_hashstr(news,(size_t)len)&(_numofslots-1); SQString *s; for (s = _strings[h]; s; s = s->_next){ diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index b1ff8e5f5c..e94f051185 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -185,7 +185,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result) SQObjectPtr res; switch(type(o1)){ case OT_STRING: - _RET_SUCCEED(scstrcmp(_stringval(o1),_stringval(o2))); + _RET_SUCCEED(strcmp(_stringval(o1),_stringval(o2))); case OT_INTEGER: /* FS#3954: wrong integer comparison */ _RET_SUCCEED((_integer(o1)<_integer(o2))?-1:(_integer(o1)==_integer(o2))?0:1); @@ -256,13 +256,13 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) res = o; return; case OT_FLOAT: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),"%g",_float(o)); + sprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),"%g",_float(o)); break; case OT_INTEGER: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),SQ_PRINTF64,_integer(o)); + sprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),SQ_PRINTF64,_integer(o)); break; case OT_BOOL: - scsprintf(_sp(rsl(6)),_integer(o)?"true":"false"); + sprintf(_sp(rsl(6)),_integer(o)?"true":"false"); break; case OT_TABLE: case OT_USERDATA: @@ -276,7 +276,7 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) } } default: - scsprintf(_sp(rsl(sizeof(void*)+20)),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o)); + sprintf(_sp(rsl(sizeof(void*)+20)),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o)); } res = SQString::Create(_ss(this),_spval); } @@ -735,7 +735,7 @@ exception_restore: const SQInstruction &_i_ = *ci->_ip++; //dumpstack(_stackbase); - //scprintf("%s %d %d %d %d\n",g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3); + //printf("%s %d %d %d %d\n",g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3); switch(_i_.op) { case _OP_LINE: @@ -1554,37 +1554,37 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall) { SQInteger size=dumpall?_stack.size():_top; SQInteger n=0; - scprintf("\n>>>>stack dump<<<<\n"); + printf("\n>>>>stack dump<<<<\n"); CallInfo &ci=_callsstack[_callsstacksize-1]; - scprintf("IP: %p\n",ci._ip); - scprintf("prev stack base: %d\n",ci._prevstkbase); - scprintf("prev top: %d\n",ci._prevtop); + printf("IP: %p\n",ci._ip); + printf("prev stack base: %d\n",ci._prevstkbase); + printf("prev top: %d\n",ci._prevtop); for(SQInteger i=0;i");else scprintf(" "); - scprintf("[%d]:",n); + if(stackbase==i)printf(">");else printf(" "); + printf("[%d]:",n); switch(type(obj)){ - case OT_FLOAT: scprintf("FLOAT %.3f",_float(obj));break; - case OT_INTEGER: scprintf("INTEGER %d",_integer(obj));break; - case OT_BOOL: scprintf("BOOL %s",_integer(obj)?"true":"false");break; - case OT_STRING: scprintf("STRING %s",_stringval(obj));break; - case OT_NULL: scprintf("NULL"); break; - case OT_TABLE: scprintf("TABLE %p[%p]",_table(obj),_table(obj)->_delegate);break; - case OT_ARRAY: scprintf("ARRAY %p",_array(obj));break; - case OT_CLOSURE: scprintf("CLOSURE [%p]",_closure(obj));break; - case OT_NATIVECLOSURE: scprintf("NATIVECLOSURE");break; - case OT_USERDATA: scprintf("USERDATA %p[%p]",_userdataval(obj),_userdata(obj)->_delegate);break; - case OT_GENERATOR: scprintf("GENERATOR %p",_generator(obj));break; - case OT_THREAD: scprintf("THREAD [%p]",_thread(obj));break; - case OT_USERPOINTER: scprintf("USERPOINTER %p",_userpointer(obj));break; - case OT_CLASS: scprintf("CLASS %p",_class(obj));break; - case OT_INSTANCE: scprintf("INSTANCE %p",_instance(obj));break; - case OT_WEAKREF: scprintf("WEAKERF %p",_weakref(obj));break; + case OT_FLOAT: printf("FLOAT %.3f",_float(obj));break; + case OT_INTEGER: printf("INTEGER %d",_integer(obj));break; + case OT_BOOL: printf("BOOL %s",_integer(obj)?"true":"false");break; + case OT_STRING: printf("STRING %s",_stringval(obj));break; + case OT_NULL: printf("NULL"); break; + case OT_TABLE: printf("TABLE %p[%p]",_table(obj),_table(obj)->_delegate);break; + case OT_ARRAY: printf("ARRAY %p",_array(obj));break; + case OT_CLOSURE: printf("CLOSURE [%p]",_closure(obj));break; + case OT_NATIVECLOSURE: printf("NATIVECLOSURE");break; + case OT_USERDATA: printf("USERDATA %p[%p]",_userdataval(obj),_userdata(obj)->_delegate);break; + case OT_GENERATOR: printf("GENERATOR %p",_generator(obj));break; + case OT_THREAD: printf("THREAD [%p]",_thread(obj));break; + case OT_USERPOINTER: printf("USERPOINTER %p",_userpointer(obj));break; + case OT_CLASS: printf("CLASS %p",_class(obj));break; + case OT_INSTANCE: printf("INSTANCE %p",_instance(obj));break; + case OT_WEAKREF: printf("WEAKERF %p",_weakref(obj));break; default: assert(0); break; }; - scprintf("\n"); + printf("\n"); ++n; } } diff --git a/src/script/script_info_dummy.cpp b/src/script/script_info_dummy.cpp index 049e593426..15f417c582 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 dc71d1ef40..bfffc5c3dd 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 ccd8affc11..ccebe20157 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 != '/')