X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=f806abe3d1dfc9cfabf13ffe32ef510b8cd9ac4b;hb=18c9024957df2892adb21cd851cb7a27b9502d54;hp=424463dad2eca1e8477a821e39fb78ca9b85c765;hpb=60876535e02fb87e638a0aa94aa80490093099fc;p=xboard.git diff --git a/backend.c b/backend.c index 424463d..f806abe 100644 --- a/backend.c +++ b/backend.c @@ -3647,7 +3647,7 @@ read_from_ics(isr, closure, data, count, error) gameInfo.white, white_holding, gameInfo.black, black_holding); } - + if(!partnerUp) // [HGM] bughouse: when peeking at partner game we already know what he captured... DrawPosition(FALSE, boards[currentMove]); DisplayTitle(str); } else if(appData.bgObserve) { // [HGM] bughouse: holdings of other game => background @@ -4715,6 +4715,8 @@ AlphaRank(char *move, int n) } } +char yy_textstr[8000]; + /* Parser for moves from gnuchess, ICS, or user typein box */ Boolean ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) @@ -4727,7 +4729,7 @@ ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) if (appData.debugMode) { fprintf(debugFP, "move to parse: %s\n", move); } - *moveType = yylexstr(moveNum, move); + *moveType = yylexstr(moveNum, move, yy_textstr, sizeof yy_textstr); switch (*moveType) { case WhitePromotionChancellor: @@ -4821,15 +4823,15 @@ ParsePV(char *pv, Boolean storeComments) int fromX, fromY, toX, toY; char promoChar; ChessMove moveType; Boolean valid; - int nr = 0, dummy; + int nr = 0; endPV = forwardMostMove; do { - while(*pv == ' ') pv++; - if(nr == 0 && *pv == '(') pv++; // first (ponder) move can be in parentheses + while(*pv == ' ' || *pv == '\n' || *pv == '\t') pv++; // must still read away whitespace + if(nr == 0 && !storeComments && *pv == '(') pv++; // first (ponder) move can be in parentheses valid = ParseOneMove(pv, endPV, &moveType, &fromX, &fromY, &toX, &toY, &promoChar); if(appData.debugMode){ -fprintf(debugFP,"parsePV: %d %c%c%c%c '%s'\n", valid, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, pv); +fprintf(debugFP,"parsePV: %d %c%c%c%c yy='%s'\nPV = '%s'\n", valid, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, yy_textstr, pv); } if(!valid && nr == 0 && ParseOneMove(pv, endPV-1, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)){ @@ -4848,30 +4850,13 @@ fprintf(debugFP,"parsePV: %d %c%c%c%c '%s'\n", valid, fromX+AAA, fromY+ONE, toX+ strcpy(moveList[endPV-2], "_0_0"); // suppress premove highlight on takeback move } } - if(moveType == Comment) { - // [HGM] vari: try to skip comment - int level = 0; char c, *start = pv, wait = NULLCHAR; - do { - if(!wait) { - if(*pv == '(') level++; else - if(*pv == ')' && level) level--; - } - if(*pv == wait) wait = NULLCHAR; else - if(*pv == '{') wait = '}'; else - if(*pv == '[') wait = ']'; - pv++; - } while(*pv && (wait || level)); - if(storeComments) { - c = *pv; *pv = NULLCHAR; - AppendComment(endPV, start, FALSE); - *pv = c; - } - valid++; // allow comments in PV + pv = strstr(pv, yy_textstr) + strlen(yy_textstr); // skip what we parsed + if(nr == 0 && !storeComments && *pv == ')') pv++; // closing parenthesis of ponder move; + if(moveType == Comment && storeComments) AppendComment(endPV, yy_textstr, FALSE); + if(moveType == Comment || moveType == NAG || moveType == ElapsedTime) { + valid++; // allow comments in PV continue; } - if(sscanf(pv, "%d...", &dummy) == 1 || sscanf(pv, "%d.", &dummy) == 1) - while(*pv && *pv++ != ' '); // skip any move numbers - while(*pv && *pv++ != ' '); // skip what we parsed; assume space separators nr++; if(endPV+1 > framePtr) break; // no space, truncate if(!valid) break; @@ -4903,14 +4888,17 @@ Boolean LoadMultiPV(int x, int y, char *buf, int index, int *start, int *end) { int startPV; + char *p; if(index < 0 || index >= strlen(buf)) return FALSE; // sanity lastX = x; lastY = y; while(index > 0 && buf[index-1] != '\n') index--; // beginning of line startPV = index; - while(buf[index] != '\n') if(buf[index++] == '\t') startPV = index; - index = startPV; - while(buf[index] && buf[index] != '\n') index++; + while(buf[index] != '\n') if(buf[index++] == '\t') startPV = index; + if(index == startPV && (p = StrCaseStr(buf+index, "PV="))) startPV = p - buf + 3; + index = startPV; + do{ while(buf[index] && buf[index] != '\n') index++; + } while(buf[index] == '\n' && buf[index+1] == '\\' && buf[index+2] == ' ' && index++); // join kibitzed PV continuation line buf[index] = 0; ParsePV(buf+startPV, FALSE); *start = startPV; *end = index-1;