Fix shift-JIS codes for N, P, +B, +R
[xboard.git] / parser.c
index f0279d8..496fef1 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -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
@@ -675,7 +674,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) ||