X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=91c8edd4c4e9d28da3ca3bc365732a9ea19660e7;hb=4011e8678d85310eedf19fd00aa5d96a9a60770a;hp=f0279d88c5a30218e73573376b0dae758bc16376;hpb=63c29de9cd551a135ae1bf7a6fb7322ee7119d9f;p=xboard.git diff --git a/parser.c b/parser.c index f0279d8..91c8edd 100644 --- a/parser.c +++ b/parser.c @@ -1,7 +1,7 @@ /* * 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 @@ -143,11 +143,11 @@ unsigned char kanjiTab[] = { '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, @@ -180,7 +180,6 @@ GetKanji (char **p, int start) 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]) { @@ -228,8 +227,8 @@ KifuMove (char **p) 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 @@ -419,7 +418,10 @@ NextUnit (char **p) 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) { @@ -490,7 +492,7 @@ NextUnit (char **p) 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; @@ -675,7 +677,12 @@ badMove:// we failed to find algebraic move 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) ||