Fix music not properly fading in again
[supertux.git] / src / lisp / lexer.cpp
index 690d571..166d655 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "lisp/lexer.hpp"
 
-#include <cstring>
+#include <string.h>
 #include <sstream>
 #include <stdexcept>
 #include <stdio.h>
 namespace lisp {
 
 Lexer::Lexer(std::istream& newstream) :
-  stream(newstream), 
-  eof(false), 
+  stream(newstream),
+  eof(false),
   linenumber(0),
   bufend(),
   bufpos(),
   c(),
+  token_string(),
   token_length()
 {
   // trigger a refill of the buffer
@@ -45,7 +46,7 @@ Lexer::~Lexer()
 void
 Lexer::nextChar()
 {
-  if(bufpos >= bufend) {
+  if(bufpos >= bufend || (bufpos == NULL && bufend == NULL) /* Initial refill trigger */) {
     if(eof) {
       c = EOF;
       return;
@@ -65,6 +66,10 @@ Lexer::nextChar()
       ++bufend;
     }
   }
+
+  if(bufpos == NULL)
+    return;
+
   c = *bufpos++;
   if(c == '\n')
     ++linenumber;