From: <ave...@us...> - 2003-11-08 23:22:42
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1:/tmp/cvs-serv3798 Modified Files: GUIScript.cpp Log Message: Fixed GetTableValue to return numeric value for negative numbers Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** GUIScript.cpp 8 Nov 2003 22:13:34 -0000 1.39 --- GUIScript.cpp 8 Nov 2003 23:22:39 -0000 1.40 *************** *** 23,26 **** --- 23,34 ---- #include "../Core/Label.h" + inline bool valid_number(const char *string, long &val) + { + char *endpr; + + val = strtol(string, &endpr, 0); + return (const char *) endpr!=string; + } + static PyObject * GemRB_LoadWindowPack(PyObject */*self*/, PyObject *args) { *************** *** 159,170 **** if(ret == NULL) return NULL; ! if((ret[0] >= '0') && (ret[0] <= '9')) { ! if(ret[1] == 'x') { ! unsigned int val; ! sscanf(ret, "0x%x", &val); ! return Py_BuildValue("i", val); ! } ! else ! return Py_BuildValue("i", atoi(ret)); } return Py_BuildValue("s", ret); --- 167,174 ---- if(ret == NULL) return NULL; ! ! long val; ! if(valid_number(ret,val) ) { ! return Py_BuildValue("l", val); } return Py_BuildValue("s", ret); *************** *** 189,200 **** for(row = 0; row < tm->GetRowCount(); row++) { char * ret = tm->QueryField(row, col); ! if((ret[0] >= '0') && (ret[0] <= '9')) { ! if(ret[1] == 'x') ! sscanf(ret, "0x%lx", &val); ! else ! val=atol(ret); ! if(Value==val) return Py_BuildValue("i", row); - } } return Py_BuildValue("i",-1); //row not found --- 193,199 ---- for(row = 0; row < tm->GetRowCount(); row++) { char * ret = tm->QueryField(row, col); ! long val; ! if(valid_number(ret, val) && Value==val) return Py_BuildValue("i", row); } return Py_BuildValue("i",-1); //row not found |