Devanagari upgrade
[supertux.git] / src / lisp / parser.cpp
index 232cfc0..e6a4198 100644 (file)
 #include <sstream>
 #include <stdexcept>
 #include <tinygettext/tinygettext.hpp>
+#include <physfs.h>
 
 #include "lisp/lisp.hpp"
 #include "lisp/parser.hpp"
-#include "obstack/obstackpp.hpp"
+#include "util/obstackpp.hpp"
 #include "physfs/ifile_stream.hpp"
 #include "physfs/ifile_streambuf.hpp"
 #include "supertux/globals.hpp"
@@ -76,7 +77,13 @@ Parser::parse(const std::string& filename)
   }
 
   if(dictionary_manager) {
-    dictionary_manager->add_directory(dirname(filename));
+    std::string rel_dir = dirname (filename);
+    char **searchpath = PHYSFS_getSearchPath();
+    for(char** i = searchpath; *i != NULL; i++)
+    {
+      std::string abs_dir = std::string (*i) + PHYSFS_getDirSeparator () + rel_dir;
+      dictionary_manager->add_directory (abs_dir);
+    }
     dictionary = & (dictionary_manager->get_dictionary());
   }
 
@@ -185,11 +192,11 @@ Parser::read()
     }
     case Lexer::TOKEN_INTEGER:
       result = new(obst) Lisp(Lisp::TYPE_INTEGER);
-      sscanf(lexer->getString(), "%d", &result->v.integer);
+      result->v.integer = atoi(lexer->getString());
       break;
     case Lexer::TOKEN_REAL:
       result = new(obst) Lisp(Lisp::TYPE_REAL);
-      sscanf(lexer->getString(), "%f", &result->v.real);
+      result->v.real = strtof(lexer->getString(), NULL);
       break;
     case Lexer::TOKEN_TRUE:
       result = new(obst) Lisp(Lisp::TYPE_BOOLEAN);
@@ -202,6 +209,7 @@ Parser::read()
 
     default:
       // this should never happen
+      result = NULL;
       assert(false);
   }