X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=7afd3488ddbee16f9b4dd974978c35552c8a0c3d;hb=407cd1126c6c24d890359f1fe1686f6d90c0ad61;hp=407b92e0abdea6f322054930c5d1f0486e27c0ab;hpb=9aeaed383b0ce7d578251ff5765b8c94d1b3f167;p=xboard.git diff --git a/parser.c b/parser.c index 407b92e..7afd348 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; } @@ -241,7 +242,8 @@ if(appData.debugMode)fprintf(debugFP, "trial %d,%d,%d,%d type %d%d%d%d\n", coor return ImpossibleMove; // for now treat as invalid } // fxg stuff, but also things like 0-0, 0-1 and 1-0 - if(!piece && type[1] == NOTHING && type[0] == ALPHABETIC && type[2] == ALPHABETIC) { + if(!piece && type[1] == NOTHING && type[0] == ALPHABETIC && type[2] == ALPHABETIC + && (coord[0] != 14 || coord[2] != 14) /* reserve oo for castling! */ ) { piece = 'P'; n = 4; // kludge alert: fake full to-square } } @@ -521,12 +523,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()