/*
* 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
{
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
}
}
// 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
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);
}
// ********* 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;
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)++;