/*
* parser.c --
*
- * Copyright 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ * Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
'S', 0213, 0342, 0,
'R', 0224, 0362, 0,
'B', 0212, 0160, 0,
- 'N', 0225, 0340, 0,
+ 'N', 0214, 0152, 0,
'L', 0215, 0201, 0,
- 'P', 0214, 0152, 0,
- 'r', 0224, 0156, 0,
- 'b', 0227, 0264, 0,
+ 'P', 0225, 0340, 0,
+ 'r', 0227, 0264, 0,
+ 'b', 0224, 0156, 0,
'p', 0202, 0306, 0,
'r', 0227, 0263, 0,
'+', 0220, 0254, 0,
int i;
if((*q & 0x80) == 0) return 0; // plain ASCII, refuse to parse
-fprintf(debugFP, "kanji %03o %03o\n", *q, q[1]);
if((**p & 0xC0) == 0x80) { // this is an illegal starting code in utf-8, so assume shift-JIS
for(i=start+JIS; kanjiTab[i]; i+=4) {
if(q[0] == kanjiTab[i+1] && q[1] == kanjiTab[i+2]) {
int res;
parseStart = yytext;
if(wom)
- res = BlackWins, strcpy(yytext, "0-1 {resign}");
- else res = WhiteWins, strcpy(yytext, "1-0 {resign}");
+ res = BlackWins, strcpy(yytext, "{sente resigns} 0-1");
+ else res = WhiteWins, strcpy(yytext, "{gote resigns} 1-0");
return res;
} else {
while(**p && **p != '\n') (*p)++; // unrecognized Japanese kanji: skip to end of line
if(**p == '+') (*p)++, promoted++;
if(**p >= 'a' && **p <= 'z' && (*p)[1]== '@') piece =*(*p)++ + 'A' - 'a'; else
if(**p >= 'A' && **p <= 'Z') {
+ static char s[] = SUFFIXES;
+ char *q;
piece = *(*p)++; // Note we could test for 2-byte non-ascii names here
+ if(q = strchr(s, **p)) (*p)++, piece += 64*(q - s + 1);
if(**p == '/') slash = *(*p)++;
}
while(n < 4) {
else if(toY >= BOARD_HEIGHT || toY < 0) return ImpossibleMove; // vert off-board to-square
if(toX < BOARD_LEFT || toX >= BOARD_RGHT) return ImpossibleMove;
if(piece) {
- cl.pieceIn = CharToPiece(wom ? piece : ToLower(piece));
+ cl.pieceIn = CharToPiece(wom ? piece : piece + 'a' - 'A');
if(cl.pieceIn == EmptySquare) return ImpossibleMove; // non-existent piece
if(promoted) cl.pieceIn = (ChessSquare) (CHUPROMOTED cl.pieceIn);
} else cl.pieceIn = EmptySquare;
commentEnd = *p; if(i) return Comment; // return comment that runs to EOF immediately
}
if(commentEnd) SkipWhite(p);
- if(lastChar == '\n' && kifu && **p == '*') { while(**p && **p != '\n') (*p)++; return Comment; } // .kif comment
+ if(kifu && **p == '*') { // .kif comment
+ char *q = yytext;
+ while(**p && **p != '\n') { if(q < yytext + 10*MSG_SIZ-3) *q++ = **p; (*p)++; }
+ parseStart = yytext; *yytext = '{'; strcpy(q, "}\n"); // wrap in braces
+ return Comment;
+ }
if(Match("*", p)) result = GameUnfinished;
else if(**p == '0') {
if( Match("0-1", p) || Match("0/1", p) || Match("0:1", p) ||