From: Ingo Ruhnke Date: Fri, 26 Mar 2004 15:17:10 +0000 (+0000) Subject: - added some error checking, so that we get more usefull error messages than asserts X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=98a0575e108b88067893759143511d7ab348fc90;p=supertux.git - added some error checking, so that we get more usefull error messages than asserts SVN-Revision: 372 --- diff --git a/src/lispreader.cpp b/src/lispreader.cpp index 798118969..df34a9e91 100644 --- a/src/lispreader.cpp +++ b/src/lispreader.cpp @@ -26,7 +26,7 @@ #include #include #include - +#include "setup.h" #include "lispreader.h" #define TOKEN_ERROR -1 @@ -1041,6 +1041,8 @@ LispReader::read_int (const char* name, int* i) lisp_object_t* obj = search_for (name); if (obj) { + if (!lisp_integer_p(lisp_car(obj))) + st_abort("LispReader expected type integer at token: ", name); *i = lisp_integer(lisp_car(obj)); return true; } @@ -1066,6 +1068,8 @@ LispReader::read_float (const char* name, float* f) lisp_object_t* obj = search_for (name); if (obj) { + if (!lisp_real_p(lisp_car(obj)) && !lisp_integer_p(lisp_car(obj))) + st_abort("LispReader expected type real at token: ", name); *f = lisp_real(lisp_car(obj)); return true; } @@ -1080,6 +1084,8 @@ LispReader::read_string_vector (const char* name, std::vector* vec) { while(!lisp_nil_p(obj)) { + if (!lisp_string_p(lisp_car(obj))) + st_abort("LispReader expected type string at token: ", name); vec->push_back(lisp_string(lisp_car(obj))); obj = lisp_cdr(obj); } @@ -1096,6 +1102,8 @@ LispReader::read_int_vector (const char* name, std::vector* vec) { while(!lisp_nil_p(obj)) { + if (!lisp_integer_p(lisp_car(obj))) + st_abort("LispReader expected type integer at token: ", name); vec->push_back(lisp_integer(lisp_car(obj))); obj = lisp_cdr(obj); } @@ -1126,7 +1134,8 @@ LispReader::read_string (const char* name, std::string* str) lisp_object_t* obj = search_for (name); if (obj) { - + if (!lisp_string_p(lisp_car(obj))) + st_abort("LispReader expected type string at token: ", name); *str = lisp_string(lisp_car(obj)); return true; } @@ -1139,6 +1148,8 @@ LispReader::read_bool (const char* name, bool* b) lisp_object_t* obj = search_for (name); if (obj) { + if (!lisp_boolean_p(lisp_car(obj))) + st_abort("LispReader expected type bool at token: ", name); *b = lisp_boolean(lisp_car(obj)); return true; }