X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=6da13d40b7c73700ee52e2de2dabbe149e928ed4;hb=9d84fbc414dd9e4112e6ba42c9eca6c2244be6db;hp=c4330d12dd9aecf188f173d233c8fe52ccfdd34b;hpb=4e062d14429ed3a3a251c971690bade4c8cba946;p=xboard.git diff --git a/parser.c b/parser.c index c4330d1..6da13d4 100644 --- a/parser.c +++ b/parser.c @@ -1,7 +1,7 @@ /* * parser.c -- * - * Copyright 2011, 2012 Free Software Foundation, Inc. + * Copyright 2011, 2012, 2013 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -151,10 +151,10 @@ PromoSuffix (char **p) { char *start = *p; if(**p == 'e' && (Match("ep", p) || Match("e.p.", p))) { *p = start; return NULLCHAR; } // non-compliant e.p. suffix is no promoChar! - if(**p == '+' && gameInfo.variant == VariantShogi) { (*p)++; return '+'; } + if(**p == '+' && gameInfo.variant == VariantShogi) { (*p)++; return '+'; } if(**p == '=' || (gameInfo.variant == VariantSChess) && **p == '/') (*p)++; // optional = (or / for Seirawan gating) - if(**p == '(' && (*p)[2] == ')' && isalpha( (*p)[1] )) { (*p) += 3; return (*p)[-2]; } - if(isalpha(**p)) return *(*p)++; + if(**p == '(' && (*p)[2] == ')' && isalpha( (*p)[1] )) { (*p) += 3; return ToLower((*p)[-2]); } + if(isalpha(**p)) return ToLower(*(*p)++); if(*p != start) return '='; // must be the optional = return NULLCHAR; // no suffix detected } @@ -220,10 +220,9 @@ NextUnit (char **p) type[1] = NOTHING; // disambiguator goes in first two positions n = 4; } -if(appData.debugMode)fprintf(debugFP, "trial %d,%d,%d,%d type %d%d%d%d\n", coord[0], coord[1], coord[2], coord[3], type[0], type[1], type[2], type[3]); // we always get here; move must be completely read now, with to-square coord(s) at end if(n == 3) { // incomplete to-square. Could be Xiangqi traditional, or stuff like fxg - if(piece && type[1] == NOTHING && type[0] == NUMERIC && type[2] == NUMERIC && + if(piece && type[1] == NOTHING && type[0] == NUMERIC && type[2] == NUMERIC && (separator == '+' || separator == '=' || separator == '-')) { // Xiangqi traditional @@ -335,7 +334,7 @@ badMove:// we failed to find algebraic move if(**p == '[') { oldp = ++(*p); if(Match("--", p)) { // "[--" could be start of position diagram - if(!Scan(']', p) && (*p)[-3] == '-' && (*p)[-2] == '-') return PositionDiagram; + if(!Scan(']', p) && (*p)[-3] == '-' && (*p)[-2] == '-') return PositionDiagram; *p = oldp; } SkipWhite(p); @@ -354,9 +353,9 @@ badMove:// we failed to find algebraic move } // ********* SAN Castings ************************************* - if(**p == 'O' || **p == 'o' || **p == '0') { + if(**p == 'O' || **p == 'o' || **p == '0' && !Match("00:", p)) { // exclude 00 in time stamps int castlingType = 0; - if(Match("O-O-O", p) || Match("o-o-o", p) || Match("0-0-0", p) || + if(Match("O-O-O", p) || Match("o-o-o", p) || Match("0-0-0", p) || Match("OOO", p) || Match("ooo", p) || Match("000", p)) castlingType = 2; else if(Match("O-O", p) || Match("o-o", p) || Match("0-0", p) || Match("OO", p) || Match("oo", p) || Match("00", p)) castlingType = 1; @@ -533,6 +532,8 @@ badMove:// we failed to find algebraic move return Nothing; } + // ********* Prevent 00 in unprotected time stamps to be mistaken for castling ******* + if(Match(":00", p)) return Nothing; // ********* Could not match to anything. Return offending character **** (*p)++;