Implement yynewstr entry point in new parser
[xboard.git] / parser.c
index 407b92e..973d109 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -44,6 +44,7 @@ int ReadLine()
 {   // Read one line from the input file, and append to the buffer\r
     char c, *start = inPtr;\r
     if(fromString) return 0; // parsing string, so the end is a hard end\r
+    if(!inputFile) return 0;\r
     while((c = fgetc(inputFile)) != EOF) {\r
        *inPtr++ = c;\r
        if(c == '\n') { *inPtr = NULLCHAR; return 1; }\r
@@ -521,12 +522,16 @@ void yynewfile (FILE *f)
 {   // prepare parse buffer for reading file\r
     inputFile = f;\r
     inPtr = parsePtr = inputBuf;\r
+    fromString = 0;\r
     lastChar = '\n';\r
     *inPtr = NULLCHAR; // make sure we will start by reading a line\r
 }\r
 \r
 void yynewstr P((char *s))\r
 {\r
+    parsePtr = s;\r
+    inputFile = NULL;\r
+    fromString = 1;\r
 }\r
 \r
 int yylex()\r