Calling PHYSFS_freeList in destructor
[supertux.git] / src / lisp / parser.cpp
index d827c61..f9759dc 100644 (file)
@@ -25,7 +25,6 @@
 #include "physfs/ifile_stream.hpp"
 #include "physfs/ifile_streambuf.hpp"
 #include "supertux/globals.hpp"
-#include "util/log.hpp"
 
 #include "supertux/gameconfig.hpp"
 
@@ -37,7 +36,8 @@ Parser::Parser(bool translate) :
   dictionary_manager(0), 
   dictionary(0),
   token(),
-  obst()
+  obst(),
+  searchpath()
 {
   if(translate) {
     dictionary_manager = new tinygettext::DictionaryManager();
@@ -47,6 +47,7 @@ Parser::Parser(bool translate) :
   }
 
   obstack_init(&obst);
+  searchpath = PHYSFS_getSearchPath();
 }
 
 Parser::~Parser()
@@ -54,6 +55,7 @@ Parser::~Parser()
   obstack_free(&obst, NULL);
   delete lexer;
   delete dictionary_manager;
+  PHYSFS_freeList(searchpath);
 }
 
 static std::string dirname(const std::string& filename)
@@ -79,11 +81,9 @@ Parser::parse(const std::string& filename)
 
   if(dictionary_manager) {
     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;
-      log_debug << "Adding " << abs_dir << std::endl;
       dictionary_manager->add_directory (abs_dir);
     }
     dictionary = & (dictionary_manager->get_dictionary());
@@ -194,11 +194,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);