diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f58a17..56cc53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ project(squirrel C CXX) include_directories(${CMAKE_SOURCE_DIR}/include) if(CMAKE_COMPILER_IS_GNUCXX) - set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra) + set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra -pedantic) if(CMAKE_BUILD_TYPE STREQUAL "Release") set(SQ_FLAGS ${SQ_FLAGS} -O3) @@ -26,7 +26,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(${SQ_FLAGS}) endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++0x") elseif(MSVC) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() diff --git a/include/sqconfig.h b/include/sqconfig.h index f8360f9..58bc979 100644 --- a/include/sqconfig.h +++ b/include/sqconfig.h @@ -60,10 +60,10 @@ typedef wchar_t SQChar; #define scstrcmp wcscmp -#ifdef _MSC_VER +#ifdef _WIN32 #define scsprintf _snwprintf #else -#define scsprintf snwprintf +#define scsprintf swprintf #endif #define scstrlen wcslen #define scstrtod wcstod diff --git a/sq/sq.c b/sq/sq.c index 980903c..be20886 100644 --- a/sq/sq.c +++ b/sq/sq.c @@ -52,6 +52,7 @@ void printfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...) va_start(vl, s); scvprintf(stdout, s, vl); va_end(vl); + (void)v; /* UNUSED */ } void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...) @@ -87,6 +88,9 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval) { int i; int compiles_only = 0; +#ifdef SQUNICODE + static SQChar temp[500]; +#endif char * output = NULL; *retval = 0; if(argc>1) diff --git a/sqstdlib/sqstdblob.cpp b/sqstdlib/sqstdblob.cpp index 590cde7..1db973b 100644 --- a/sqstdlib/sqstdblob.cpp +++ b/sqstdlib/sqstdblob.cpp @@ -172,7 +172,7 @@ static const SQRegFunction _blob_methods[] = { _DECL_BLOB_FUNC(_typeof,1,_SC("x")), _DECL_BLOB_FUNC(_nexti,2,_SC("x")), _DECL_BLOB_FUNC(_cloned,2,_SC("xx")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; @@ -230,7 +230,7 @@ static const SQRegFunction bloblib_funcs[]={ _DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr) diff --git a/sqstdlib/sqstdio.cpp b/sqstdlib/sqstdio.cpp index 43277f1..273bb5c 100644 --- a/sqstdlib/sqstdio.cpp +++ b/sqstdlib/sqstdio.cpp @@ -168,7 +168,7 @@ static const SQRegFunction _file_methods[] = { _DECL_FILE_FUNC(constructor,3,_SC("x")), _DECL_FILE_FUNC(_typeof,1,_SC("x")), _DECL_FILE_FUNC(close,1,_SC("x")), - {0,0,0,0}, + {NULL,(SQFUNCTION)0,0,NULL} }; @@ -463,7 +463,7 @@ static const SQRegFunction iolib_funcs[]={ _DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; SQRESULT sqstd_register_iolib(HSQUIRRELVM v) diff --git a/sqstdlib/sqstdmath.cpp b/sqstdlib/sqstdmath.cpp index b29fdf8..c41ffd5 100644 --- a/sqstdlib/sqstdmath.cpp +++ b/sqstdlib/sqstdmath.cpp @@ -78,7 +78,7 @@ static const SQRegFunction mathlib_funcs[] = { _DECL_FUNC(rand,1,NULL), _DECL_FUNC(fabs,2,_SC(".n")), _DECL_FUNC(abs,2,_SC(".n")), - {0,0,0,0}, + {NULL,(SQFUNCTION)0,0,NULL} }; #undef _DECL_FUNC diff --git a/sqstdlib/sqstdrex.cpp b/sqstdlib/sqstdrex.cpp index 22c1317..9390c2d 100644 --- a/sqstdlib/sqstdrex.cpp +++ b/sqstdlib/sqstdrex.cpp @@ -550,7 +550,7 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar /* public api */ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) { - SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex)); + SQRex * volatile exp = (SQRex *)sq_malloc(sizeof(SQRex)); // "volatile" is needed for setjmp() exp->_eol = exp->_bol = NULL; exp->_p = pattern; exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar); @@ -578,7 +578,7 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); else scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type); - scprintf(_SC("left %02d right %02d next %02d\n"),exp->_nodes[i].left,exp->_nodes[i].right,exp->_nodes[i].next); + scprintf(_SC("left %02d right %02d next %02d\n"), (SQInt32)exp->_nodes[i].left, (SQInt32)exp->_nodes[i].right, (SQInt32)exp->_nodes[i].next); } scprintf(_SC("\n")); } diff --git a/sqstdlib/sqstdstream.cpp b/sqstdlib/sqstdstream.cpp index ea1c58c..406f561 100644 --- a/sqstdlib/sqstdstream.cpp +++ b/sqstdlib/sqstdstream.cpp @@ -249,7 +249,7 @@ static const SQRegFunction _stream_methods[] = { _DECL_STREAM_FUNC(eos,1,_SC("x")), _DECL_STREAM_FUNC(flush,1,_SC("x")), _DECL_STREAM_FUNC(_cloned,0,NULL), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; void init_streamclass(HSQUIRRELVM v) diff --git a/sqstdlib/sqstdstring.cpp b/sqstdlib/sqstdstring.cpp index 9be7996..6190edd 100644 --- a/sqstdlib/sqstdstring.cpp +++ b/sqstdlib/sqstdstring.cpp @@ -94,9 +94,9 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen if(n < 0) return -1; SQInteger addlen = 0; SQInteger valtype = 0; - const SQChar *ts; - SQInteger ti; - SQFloat tf; + const SQChar *ts = NULL; + SQInteger ti = 0; + SQFloat tf = 0; switch(format[n]) { case 's': if(SQ_FAILED(sq_getstring(v,nparam,&ts))) @@ -452,7 +452,7 @@ static const SQRegFunction rexobj_funcs[]={ _DECL_REX_FUNC(capture,-2,_SC("xsn")), _DECL_REX_FUNC(subexpcount,1,_SC("x")), _DECL_REX_FUNC(_typeof,1,_SC("x")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; #undef _DECL_REX_FUNC @@ -466,7 +466,7 @@ static const SQRegFunction stringlib_funcs[]={ _DECL_FUNC(escape,2,_SC(".s")), _DECL_FUNC(startswith,3,_SC(".ss")), _DECL_FUNC(endswith,3,_SC(".ss")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; #undef _DECL_FUNC diff --git a/sqstdlib/sqstdsystem.cpp b/sqstdlib/sqstdsystem.cpp index 5d46e27..b008a44 100644 --- a/sqstdlib/sqstdsystem.cpp +++ b/sqstdlib/sqstdsystem.cpp @@ -126,7 +126,7 @@ static const SQRegFunction systemlib_funcs[]={ _DECL_FUNC(date,-1,_SC(".nn")), _DECL_FUNC(remove,2,_SC(".s")), _DECL_FUNC(rename,3,_SC(".ss")), - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; #undef _DECL_FUNC diff --git a/squirrel/sqbaselib.cpp b/squirrel/sqbaselib.cpp index ed3d4c1..71dfc26 100644 --- a/squirrel/sqbaselib.cpp +++ b/squirrel/sqbaselib.cpp @@ -296,7 +296,7 @@ static const SQRegFunction base_funcs[]={ {_SC("collectgarbage"),base_collectgarbage,0, NULL}, {_SC("resurrectunreachable"),base_resurectureachable,0, NULL}, #endif - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; void sq_base_register(HSQUIRRELVM v) @@ -475,7 +475,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={ {_SC("clear"),obj_clear,1, _SC(".")}, {_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")}, {_SC("getdelegate"),table_getdelegate,1, _SC(".")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //ARRAY DEFAULT DELEGATE/////////////////////////////////////// @@ -794,7 +794,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={ {_SC("reduce"),array_reduce,2, _SC("ac")}, {_SC("filter"),array_filter,2, _SC("ac")}, {_SC("find"),array_find,2, _SC("a.")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //STRING DEFAULT DELEGATE////////////////////////// @@ -863,7 +863,7 @@ const SQRegFunction SQSharedState::_string_default_delegate_funcz[]={ {_SC("tolower"),string_tolower,-1, _SC("s n n")}, {_SC("toupper"),string_toupper,-1, _SC("s n n")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //INTEGER DEFAULT DELEGATE////////////////////////// @@ -873,7 +873,7 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={ {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tochar"),number_delegate_tochar,1, _SC("n|b")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //CLOSURE DEFAULT DELEGATE////////////////////////// @@ -983,7 +983,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={ {_SC("getinfos"),closure_getinfos,1, _SC("c")}, {_SC("getroot"),closure_getroot,1, _SC("c")}, {_SC("setroot"),closure_setroot,2, _SC("ct")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //GENERATOR DEFAULT DELEGATE @@ -1002,7 +1002,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={ {_SC("getstatus"),generator_getstatus,1, _SC("g")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; //THREAD DEFAULT DELEGATE @@ -1162,7 +1162,7 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = { {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0,0,0}, + {NULL,(SQFUNCTION)0,0,NULL} }; static SQInteger class_getattributes(HSQUIRRELVM v) @@ -1229,7 +1229,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = { {_SC("getbase"),class_getbase,1, _SC("y")}, {_SC("newmember"),class_newmember,-3, _SC("y")}, {_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; @@ -1247,7 +1247,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = { {_SC("rawin"),container_rawexists,2, _SC("x")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; static SQInteger weakref_ref(HSQUIRRELVM v) @@ -1261,6 +1261,5 @@ const SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = { {_SC("ref"),weakref_ref,1, _SC("r")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0,0,0} + {NULL,(SQFUNCTION)0,0,NULL} }; - diff --git a/squirrel/sqcompiler.cpp b/squirrel/sqcompiler.cpp index 8a54d65..8a932f9 100644 --- a/squirrel/sqcompiler.cpp +++ b/squirrel/sqcompiler.cpp @@ -982,7 +982,7 @@ public: SQInteger val = _fs->PopTarget(); SQInteger key = _fs->PopTarget(); SQInteger attrs = hasattrs ? _fs->PopTarget():-1; - ((void)attrs); + ((void)attrs); assert((hasattrs && (attrs == key-1)) || !hasattrs); unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0); SQInteger table = _fs->TopTarget(); //<