X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=973d10922076f7df3674f9afea33d1a47fb8a1da;hb=065c7fdfab3182e5d5117a4c11b71eca40b70e12;hp=407b92e0abdea6f322054930c5d1f0486e27c0ab;hpb=2d966e8e4f88f9e98356a130ac43d43d67041762;p=xboard.git diff --git a/parser.c b/parser.c index 407b92e..973d109 100644 --- a/parser.c +++ b/parser.c @@ -44,6 +44,7 @@ int ReadLine() { // Read one line from the input file, and append to the buffer char c, *start = inPtr; if(fromString) return 0; // parsing string, so the end is a hard end + if(!inputFile) return 0; while((c = fgetc(inputFile)) != EOF) { *inPtr++ = c; if(c == '\n') { *inPtr = NULLCHAR; return 1; } @@ -521,12 +522,16 @@ void yynewfile (FILE *f) { // prepare parse buffer for reading file inputFile = f; inPtr = parsePtr = inputBuf; + fromString = 0; lastChar = '\n'; *inPtr = NULLCHAR; // make sure we will start by reading a line } void yynewstr P((char *s)) { + parsePtr = s; + inputFile = NULL; + fromString = 1; } int yylex()