From 3076655d51195e09429c2abde2763e917d3a67a9 Mon Sep 17 00:00:00 2001 From: A. Scotti Date: Thu, 16 Apr 2009 13:59:12 -0700 Subject: [PATCH] changes from Alessandro Scotti from 20051129 --- backend.c | 317 ++++- backend.h | 9 +- backendz.h | 2 +- common.h | 2 + config.h | 133 ++ frontend.h | 2 +- gamelist.c | 2 +- lists.c | 2 +- lists.h | 2 +- moves.c | 62 +- moves.h | 2 +- parser.c | 3875 ++++++++++++++++++++++++++++++++++++++++++++++++++ parser.h | 2 +- pgntags.c | 2 +- winboard/resource.h | 13 +- winboard/wclipbrd.c | 2 +- winboard/wedittags.c | 2 +- winboard/wedittags.h | 2 +- winboard/wgamelist.c | 248 +++- winboard/wgamelist.h | 2 +- winboard/winboard.c | 123 ++- winboard/winboard.rc | 113 +- winboard/wplugin.c | 225 +++ winboard/wplugin.h | 40 + zippy.c | 2 +- zippy.h | 2 +- 26 files changed, 5062 insertions(+), 126 deletions(-) create mode 100644 config.h create mode 100644 parser.c create mode 100644 winboard/wplugin.c create mode 100644 winboard/wplugin.h diff --git a/backend.c b/backend.c index 958f503..b347a3e 100644 --- a/backend.c +++ b/backend.c @@ -597,6 +597,10 @@ InitBackEnd1() first.analyzing = second.analyzing = FALSE; first.initDone = second.initDone = FALSE; + /* New features added by Tord: */ + first.useFEN960 = FALSE; second.useFEN960 = FALSE; + first.useOOCastle = TRUE; second.useOOCastle = TRUE; + /* End of new features added by Tord. */ first.scoreIsAbsolute = appData.firstScoreIsAbsolute; /* [AS] */ second.scoreIsAbsolute = appData.secondScoreIsAbsolute; /* [AS] */ @@ -663,7 +667,7 @@ InitBackEnd1() switch (variant) { case VariantBughouse: /* need four players and two boards */ case VariantKriegspiel: /* need to hide pieces and move details */ - case VariantFischeRandom: /* castling doesn't work, shuffle not done */ + /* case VariantFischeRandom: (Fabien: moved below) */ sprintf(buf, "Variant %s supported only in ICS mode", appData.variant); DisplayFatalError(buf, 0, 2); return; @@ -686,6 +690,7 @@ InitBackEnd1() case VariantNormal: /* definitely works! */ case VariantWildCastle: /* pieces not automatically shuffled */ case VariantNoCastle: /* pieces not automatically shuffled */ + case VariantFischeRandom: /* Fabien: pieces not automatically shuffled */ case VariantCrazyhouse: /* holdings not shown, offboard interposition not understood */ case VariantLosers: /* should work except for win condition, @@ -3235,7 +3240,25 @@ SendMoveToProgram(moveNum, cps) } SendToProgram(buf, cps); } else { - SendToProgram(moveList[moveNum], cps); + /* Added by Tord: Send castle moves in "O-O" in FRC games if required by + * the engine. It would be nice to have a better way to identify castle + * moves here. */ + if(gameInfo.variant == VariantFischeRandom && cps->useOOCastle) { + int fromX = moveList[moveNum][0] - 'a'; + int fromY = moveList[moveNum][1] - '1'; + int toX = moveList[moveNum][2] - 'a'; + int toY = moveList[moveNum][3] - '1'; + if((boards[currentMove][fromY][fromX] == WhiteKing + && boards[currentMove][toY][toX] == WhiteRook) + || (boards[currentMove][fromY][fromX] == BlackKing + && boards[currentMove][toY][toX] == BlackRook)) { + if(toX > fromX) SendToProgram("O-O\n", cps); + else SendToProgram("O-O-O\n", cps); + } + else SendToProgram(moveList[moveNum], cps); + } + else SendToProgram(moveList[moveNum], cps); + /* End of additions by Tord */ } } @@ -3256,12 +3279,20 @@ SendMoveToICS(moveType, fromX, fromY, toX, toY) case BlackKingSideCastle: case WhiteQueenSideCastleWild: case BlackQueenSideCastleWild: + /* PUSH Fabien */ + case WhiteHSideCastleFR: + case BlackHSideCastleFR: + /* POP Fabien */ sprintf(user_move, "o-o\n"); break; case WhiteQueenSideCastle: case BlackQueenSideCastle: case WhiteKingSideCastleWild: case BlackKingSideCastleWild: + /* PUSH Fabien */ + case WhiteASideCastleFR: + case BlackASideCastleFR: + /* POP Fabien */ sprintf(user_move, "o-o-o\n"); break; case WhitePromotionQueen: @@ -3361,6 +3392,12 @@ ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) case WhiteQueenSideCastleWild: case BlackKingSideCastleWild: case BlackQueenSideCastleWild: + /* Code added by Tord: */ + case WhiteHSideCastleFR: + case WhiteASideCastleFR: + case BlackHSideCastleFR: + case BlackASideCastleFR: + /* End of code added by Tord */ case IllegalMove: /* bug or odd chess variant */ *fromX = currentMoveString[0] - 'a'; *fromY = currentMoveString[1] - '1'; @@ -3407,6 +3444,91 @@ ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) } } +/* [AS] FRC game initialization */ +static int FindEmptySquare( Board board, int n ) +{ + int i = 0; + + while( 1 ) { + while( board[0][i] != EmptySquare ) i++; + if( n == 0 ) + break; + n--; + i++; + } + + return i; +} + +static void ShuffleFRC( Board board ) +{ + int i; + + srand( time(0) ); + + for( i=0; i<8; i++ ) { + board[0][i] = EmptySquare; + } + + board[0][(rand() % 4)*2 ] = WhiteBishop; /* On dark square */ + board[0][(rand() % 4)*2+1] = WhiteBishop; /* On lite square */ + board[0][FindEmptySquare(board, rand() % 6)] = WhiteQueen; + board[0][FindEmptySquare(board, rand() % 5)] = WhiteKnight; + board[0][FindEmptySquare(board, rand() % 4)] = WhiteKnight; + board[0][FindEmptySquare(board, 0)] = WhiteRook; + board[0][FindEmptySquare(board, 0)] = WhiteKing; + board[0][FindEmptySquare(board, 0)] = WhiteRook; + + for( i=0; i<8; i++ ) { + board[7][i] = board[0][i] + BlackPawn - WhitePawn; + } +} + +static unsigned char FRC_KnightTable[10] = { + 0x00, 0x01, 0x02, 0x03, 0x11, 0x12, 0x13, 0x22, 0x23, 0x33 +}; + +static void SetupFRC( Board board, int pos_index ) +{ + int i; + unsigned char knights; + + /* Bring the position index into a safe range (just in case...) */ + if( pos_index < 0 ) pos_index = 0; + + pos_index %= 960; + + /* Clear the board */ + for( i=0; i<8; i++ ) { + board[0][i] = EmptySquare; + } + + /* Place bishops and queen */ + board[0][ (pos_index % 4)*2 + 1 ] = WhiteBishop; /* On lite square */ + pos_index /= 4; + + board[0][ (pos_index % 4)*2 ] = WhiteBishop; /* On dark square */ + pos_index /= 4; + + board[0][ FindEmptySquare(board, pos_index % 6) ] = WhiteQueen; + pos_index /= 6; + + /* Place knigths */ + knights = FRC_KnightTable[ pos_index ]; + + board[0][ FindEmptySquare(board, knights / 16) ] = WhiteKnight; + board[0][ FindEmptySquare(board, knights % 16) ] = WhiteKnight; + + /* Place rooks and king */ + board[0][ FindEmptySquare(board, 0) ] = WhiteRook; + board[0][ FindEmptySquare(board, 0) ] = WhiteKing; + board[0][ FindEmptySquare(board, 0) ] = WhiteRook; + + /* Mirror piece placement for black */ + for( i=0; i<8; i++ ) { + board[7][i] = board[0][i] + BlackPawn - WhitePawn; + } +} void InitPosition(redraw) @@ -3441,9 +3563,15 @@ InitPosition(redraw) break; case VariantFischeRandom: CopyBoard(boards[0], initialPosition); - /* !!shuffle according to FR rules */ + if( appData.defaultFrcPosition < 0 ) { + ShuffleFRC( boards[0] ); + } + else { + SetupFRC( boards[0], appData.defaultFrcPosition ); + } break; } + if (redraw) DrawPosition(FALSE, boards[currentMove]); } @@ -3456,7 +3584,7 @@ SendBoard(cps, moveNum) char message[MSG_SIZ]; if (cps->useSetboard) { - char* fen = PositionToFEN(moveNum); + char* fen = PositionToFEN(moveNum, cps->useFEN960); sprintf(message, "setboard %s\n", fen); SendToProgram(message, cps); free(fen); @@ -4062,6 +4190,35 @@ HandleMachineMove(message, cps) MakeMove(fromX, fromY, toX, toY, promoChar);/*updates forwardMostMove*/ + /* [AS] Adjudicate game if needed (note: remember that forwardMostMove now points past the last move) */ + if( gameMode == TwoMachinesPlay && adjudicateLossThreshold != 0 && forwardMostMove >= adjudicateLossPlies ) { + int count = 0; + + while( count < adjudicateLossPlies ) { + int score = pvInfoList[ forwardMostMove - count - 1 ].score; + + if( count & 1 ) { + score = -score; /* Flip score for winning side */ + } + + if( score > adjudicateLossThreshold ) { + break; + } + + count++; + } + + if( count >= adjudicateLossPlies ) { + ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ + + GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, + "Xboard adjudication", + GE_XBOARD ); + + return; + } + } + if (gameMode == TwoMachinesPlay) { if (cps->other->sendTime) { SendTimeRemaining(cps->other, @@ -4091,32 +4248,6 @@ HandleMachineMove(message, cps) if (gameMode != TwoMachinesPlay) SetUserThinkingEnables(); - - /* [AS] Adjudicate game if needed (note: forwardMostMove now points past the last move */ - if( gameMode == TwoMachinesPlay && adjudicateLossThreshold != 0 && forwardMostMove >= adjudicateLossPlies ) { - int count = 0; - - while( count < adjudicateLossPlies ) { - int score = pvInfoList[ forwardMostMove - count - 1 ].score; - - if( count & 1 ) { - score = -score; /* Flip score for winning side */ - } - - if( score > adjudicateLossThreshold ) { - break; - } - - count++; - } - - if( count >= adjudicateLossPlies ) { - GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, - "Xboard adjudication", - GE_XBOARD ); - } - } - return; } @@ -4790,6 +4921,12 @@ ParseGameHistory(game) case WhiteQueenSideCastleWild: case BlackKingSideCastleWild: case BlackQueenSideCastleWild: + /* PUSH Fabien */ + case WhiteHSideCastleFR: + case WhiteASideCastleFR: + case BlackHSideCastleFR: + case BlackASideCastleFR: + /* POP Fabien */ case IllegalMove: /* maybe suicide chess, etc. */ fromX = currentMoveString[0] - 'a'; fromY = currentMoveString[1] - '1'; @@ -4910,6 +5047,30 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) board[toY][toX] = (ChessSquare) fromX; } else if (fromX == toX && fromY == toY) { return; + } + + /* Code added by Tord: */ + /* FRC castling assumed when king captures friendly rook. */ + else if (board[fromY][fromX] == WhiteKing && + board[toY][toX] == WhiteRook) { + board[fromY][fromX] = EmptySquare; + board[toY][toX] = EmptySquare; + if(toX > fromX) { + board[0][6] = WhiteKing; board[0][5] = WhiteRook; + } else { + board[0][2] = WhiteKing; board[0][3] = WhiteRook; + } + } else if (board[fromY][fromX] == BlackKing && + board[toY][toX] == BlackRook) { + board[fromY][fromX] = EmptySquare; + board[toY][toX] = EmptySquare; + if(toX > fromX) { + board[7][6] = BlackKing; board[7][5] = BlackRook; + } else { + board[7][2] = BlackKing; board[7][3] = BlackRook; + } + /* End of code added by Tord */ + } else if (fromY == 0 && fromX == 4 && board[fromY][fromX] == WhiteKing && toY == 0 && toX == 6) { @@ -5743,6 +5904,12 @@ LoadGameOneMove(readAhead) case WhiteQueenSideCastleWild: case BlackKingSideCastleWild: case BlackQueenSideCastleWild: + /* PUSH Fabien */ + case WhiteHSideCastleFR: + case WhiteASideCastleFR: + case BlackHSideCastleFR: + case BlackASideCastleFR: + /* POP Fabien */ if (appData.debugMode) fprintf(debugFP, "Parsed %s into %s\n", yy_text, currentMoveString); fromX = currentMoveString[0] - 'a'; @@ -6801,7 +6968,7 @@ SaveGamePGN(f) PrintPGNTags(f, &gameInfo); if (backwardMostMove > 0 || startedFromSetupPosition) { - char *fen = PositionToFEN(backwardMostMove); + char *fen = PositionToFEN(backwardMostMove, 1); fprintf(f, "[FEN \"%s\"]\n[SetUp \"1\"]\n", fen); fprintf(f, "\n{--------------\n"); PrintPosition(f, backwardMostMove); @@ -6856,7 +7023,7 @@ SaveGamePGN(f) movetext = SavePart(parseList[i]); /* [AS] Add PV info if present */ - if( i > 0 && appData.saveExtendedInfoInPGN && pvInfoList[i].depth > 0 ) { + if( i >= 0 && appData.saveExtendedInfoInPGN && pvInfoList[i].depth > 0 ) { sprintf( move_buffer, "%s {%s%.2f/%d}", movetext, pvInfoList[i].score >= 0 ? "+" : "", @@ -7026,7 +7193,7 @@ SavePosition(f, dummy, dummy2) PrintPosition(f, currentMove); fprintf(f, "--------------]\n"); } else { - fen = PositionToFEN(currentMove); + fen = PositionToFEN(currentMove, 1); fprintf(f, "%s\n", fen); free(fen); } @@ -7416,13 +7583,13 @@ ExitEvent(status) DoSleep( appData.delayBeforeQuit ); SendToProgram("quit\n", &first); DoSleep( appData.delayAfterQuit ); - DestroyChildProcess(first.pr, first.useSigterm); + DestroyChildProcess(first.pr, 10 /* [AS] first.useSigterm */ ); } if (second.pr != NoProc) { DoSleep( appData.delayBeforeQuit ); SendToProgram("quit\n", &second); DoSleep( appData.delayAfterQuit ); - DestroyChildProcess(second.pr, second.useSigterm); + DestroyChildProcess(second.pr, 10 /* [AS] second.useSigterm */ ); } if (first.isr != NULL) { RemoveInputSource(first.isr); @@ -8918,7 +9085,7 @@ SetGameInfo() switch (gameMode) { case MachinePlaysWhite: - gameInfo.event = StrSave("Computer chess game"); + gameInfo.event = StrSave( appData.pgnEventHeader ); gameInfo.site = StrSave(HostName()); gameInfo.date = PGNDate(); gameInfo.round = StrSave("-"); @@ -8928,7 +9095,7 @@ SetGameInfo() break; case MachinePlaysBlack: - gameInfo.event = StrSave("Computer chess game"); + gameInfo.event = StrSave( appData.pgnEventHeader ); gameInfo.site = StrSave(HostName()); gameInfo.date = PGNDate(); gameInfo.round = StrSave("-"); @@ -8938,7 +9105,7 @@ SetGameInfo() break; case TwoMachinesPlay: - gameInfo.event = StrSave("Computer chess game"); + gameInfo.event = StrSave( appData.pgnEventHeader ); gameInfo.site = StrSave(HostName()); gameInfo.date = PGNDate(); if (matchGame > 0) { @@ -9353,6 +9520,10 @@ ParseFeatures(args, cps) FeatureDone(cps, val); continue; } + /* Added by Tord: */ + if (BoolFeature(&p, "fen960", &cps->useFEN960, cps)) continue; + if (BoolFeature(&p, "oocastle", &cps->useOOCastle, cps)) continue; + /* End of additions by Tord */ /* unknown feature: complain and skip */ q = p; @@ -10135,8 +10306,9 @@ PGNDate() char * -PositionToFEN(move) +PositionToFEN(move, useFEN960) int move; + int useFEN960; { int i, j, fromX, fromY, toX, toY; int whiteToPlay; @@ -10174,7 +10346,66 @@ PositionToFEN(move) *p++ = whiteToPlay ? 'w' : 'b'; *p++ = ' '; - /* !!We don't keep track of castling availability, so fake it */ + /* HACK: we don't keep track of castling availability, so fake it! */ + + /* PUSH Fabien & Tord */ + + /* Declare all potential FRC castling rights (conservative) */ + /* outermost rook on each side of the king */ + + if( gameInfo.variant == VariantFischeRandom ) { + int fk, fr; + + q = p; + + /* White castling rights */ + + for (fk = 1; fk < 7; fk++) { + + if (boards[move][0][fk] == WhiteKing) { + + for (fr = 7; fr > fk; fr--) { /* H side */ + if (boards[move][0][fr] == WhiteRook) { + *p++ = useFEN960 ? 'A' + fr : 'K'; + break; + } + } + + for (fr = 0; fr < fk; fr++) { /* A side */ + if (boards[move][0][fr] == WhiteRook) { + *p++ = useFEN960 ? 'A' + fr : 'Q'; + break; + } + } + } + } + + /* Black castling rights */ + + for (fk = 1; fk < 7; fk++) { + + if (boards[move][7][fk] == BlackKing) { + + for (fr = 7; fr > fk; fr--) { /* H side */ + if (boards[move][7][fr] == BlackRook) { + *p++ = useFEN960 ? 'a' + fr : 'k'; + break; + } + } + + for (fr = 0; fr < fk; fr++) { /* A side */ + if (boards[move][7][fr] == BlackRook) { + *p++ = useFEN960 ? 'a' + fr : 'q'; + break; + } + } + } + } + + if (q == p) *p++ = '-'; /* No castling rights */ + *p++ = ' '; + } + else { q = p; if (boards[move][0][4] == WhiteKing) { if (boards[move][0][7] == WhiteRook) *p++ = 'K'; @@ -10186,6 +10417,9 @@ PositionToFEN(move) } if (q == p) *p++ = '-'; *p++ = ' '; + } + + /* POP Fabien & Tord */ /* En passant target square */ if (move > backwardMostMove) { @@ -10207,7 +10441,7 @@ PositionToFEN(move) *p++ = '-'; } - /* !!We don't keep track of halfmove clock for 50-move rule */ + /* We don't keep track of halfmove clock for 50-move rule */ strcpy(p, " 0 "); p += 3; @@ -10263,6 +10497,7 @@ ParseFEN(board, blackPlaysFirst, fen) default: return FALSE; } + /* !!We ignore the rest of the FEN notation */ return TRUE; } diff --git a/backend.h b/backend.h index f311074..9d74c57 100644 --- a/backend.h +++ b/backend.h @@ -63,7 +63,8 @@ extern ProcRef firstProgramPR, secondProgramPR; extern Board boards[]; char *CmailMsg P((void)); -char *PositionToFEN P((int move)); +/* Tord: Added the useFEN960 parameter in PositionToFEN() below */ +char *PositionToFEN P((int move, int useFEN960)); void EditPositionPasteFEN P((char *fen)); void TimeDelay P((long ms)); void SendMultiLineToICS P(( char *text )); @@ -237,6 +238,12 @@ typedef struct _CPS { int analyzing; int protocolVersion; int initDone; + + /* Added by Tord: */ + int useFEN960; /* 0=use "KQkq" style FENs, 1=use "HAha" style FENs */ + int useOOCastle; /* 0="O-O" notation for castling, 1="king capture rook" + * notation */ + /* End of additions by Tord */ int scoreIsAbsolute; /* [AS] 0=don't know (standard), 1=score is always from white side */ } ChessProgramState; diff --git a/backendz.h b/backendz.h index 3bab93f..4014e3b 100644 --- a/backendz.h +++ b/backendz.h @@ -1,6 +1,6 @@ /* * backendz.h -- Internal interface exported by XBoard backend.c to zippy.c - * $Id$ + * $Id: backendz.h,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. diff --git a/common.h b/common.h index 61741a1..2cca437 100644 --- a/common.h +++ b/common.h @@ -428,6 +428,8 @@ typedef struct { int delayBeforeQuit; int delayAfterQuit; char * nameOfDebugFile; + char * pgnEventHeader; + int defaultFrcPosition; #if ZIPPY char *zippyLines; char *zippyPinhead; diff --git a/config.h b/config.h new file mode 100644 index 0000000..ff433ae --- /dev/null +++ b/config.h @@ -0,0 +1,133 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if you have that is POSIX.1 compatible. */ +/*#undef HAVE_SYS_WAIT_H*/ + +/* Define if you need to in order for stat and other things to work. */ +/*#undef _POSIX_SOURCE*/ + +/* Define as the return type of signal handlers (int or void). */ +/*#undef RETSIGTYPE*/ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +/*#undef TIME_WITH_SYS_TIME*/ + +/* Define if lex declares yytext as a char * by default, not a char[]. */ +/*#undef YYTEXT_POINTER*/ + +/*#define FIRST_PTY_LETTER 'p'*/ + +#define HAVE_FCNTL_H 1 + +#define HAVE_GETHOSTNAME 0 + +#define HAVE_GETTIMEOFDAY 0 + +/* Use our own random() defined in winboard.c. */ +#define HAVE_RANDOM 1 +#define random myrandom +#define srandom mysrandom + +#define HAVE_SYS_SOCKET_H 0 + +/*#undef IBMRTAIX*/ + +#define LAST_PTY_LETTER 'q' + +#define PATCHLEVEL "7" + +#define PRODUCT "WinBoard" + +#define PTY_ITERATION + +#define PTY_NAME_SPRINTF + +#define PTY_TTY_NAME_SPRINTF + +#define REMOTE_SHELL "" + +/*#undef RTU*/ + +/*#undef UNIPLUS*/ + +#define USE_PTYS 0 + +#define VERSION "4.2" + +/*#undef X_WCHAR*/ + +#ifndef __BORLANDC__ +#define WIN32 1 +#else +#define WIN32 +#endif + +#define ZIPPY 1 + +/* Define if you have the _getpty function. */ +/*#undef HAVE__GETPTY*/ + +/* Define if you have the ftime function. */ +#define HAVE_FTIME 1 + +/* Define if you have the grantpt function. */ +/*#undef HAVE_GRANTPT*/ + +/* Define if you have the rand48 function. */ +/*#undef HAVE_RAND48*/ + +/* Define if you have the sysinfo function. */ +/*#undef HAVE_SYSINFO*/ + +/* Define if you have the header file. */ +/*#undef HAVE_LAN_SOCKET_H*/ + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +/*#undef HAVE_STROPTS_H*/ + +/* Define if you have the header file. */ +#define HAVE_SYS_FCNTL_H 0 + +/* Define if you have the header file. */ +/*#undef HAVE_SYS_SYSTEMINFO_H*/ + +/* Define if you have the header file. */ +/*#undef HAVE_SYS_TIME_H*/ + +/* Define if you have the header file. */ +/*#undef HAVE_UNISTD_H*/ + +/* Define if you have the i library (-li). */ +/*#undef HAVE_LIBI*/ + +/* Define if you have the seq library (-lseq). */ +/*#undef HAVE_LIBSEQ*/ + +/* + Options + -DEMULATE_RSH -DREMOTE_SHELL=\"\" is necessary on Windows 95, because it + does not have its own rsh command. It works better this way on NT too, + because the NT rsh does not propagate signals to the remote process. + -DATTENTION is included even though I haven't been able to send signals to + child processes on Windows, because at least I can send them over rsh to + Unix programs. On Windows I send a newline instead, which wakes up the + chess program if it's polling. On my GNU Chess port the newline actually + works even for Move Now. +*/ +#define EMULATE_RSH 1 +#define ATTENTION 1 + +#ifdef __BORLANDC__ +#define _strdup(x) strdup(x) +#define STRICT +#define _winmajor 3 /* windows 95 */ +#define SCF_DEFAULT 0x0000 +#define SCF_ALL 0x0004 +#endif + diff --git a/frontend.h b/frontend.h index 7fad00f..732b316 100644 --- a/frontend.h +++ b/frontend.h @@ -1,6 +1,6 @@ /* * frontend.h -- Interface exported by all XBoard front ends - * $Id$ + * $Id: frontend.h,v 2.2 2003/11/06 07:22:14 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. diff --git a/gamelist.c b/gamelist.c index a09ef64..e8d4132 100644 --- a/gamelist.c +++ b/gamelist.c @@ -1,6 +1,6 @@ /* * gamelist.c -- Functions to manage a gamelist - * XBoard $Id$ + * XBoard $Id: gamelist.c,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/lists.c b/lists.c index 9f6d4b5..a9e0d41 100644 --- a/lists.c +++ b/lists.c @@ -1,6 +1,6 @@ /* * lists.c -- Functions to implement a double linked list - * XBoard $Id$ + * XBoard $Id: lists.c,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/lists.h b/lists.h index 780f6c2..31d6f5b 100644 --- a/lists.h +++ b/lists.h @@ -1,6 +1,6 @@ /* * lists.c -- Includefile of lists.c - * XBoard $Id$ + * XBoard $Id: lists.h,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/moves.c b/moves.c index bed2064..accbfed 100644 --- a/moves.c +++ b/moves.c @@ -1,6 +1,6 @@ /* * moves.c - Move generation and checking - * $Id$ + * $Id: moves.c,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. @@ -435,6 +435,12 @@ void GenLegalCallback(board, flags, kind, rf, ff, rt, ft, closure) } +typedef struct { + int rf, ff, rt, ft; + ChessMove kind; +} LegalityTestClosure; + + /* Like GenPseudoLegal, but (1) include castling moves, (2) unless F_IGNORE_CHECK is set in the flags, omit moves that would leave the king in check, and (3) if F_ATOMIC_CAPTURE is set in the flags, omit @@ -450,7 +456,7 @@ int GenLegal(board, flags, epfile, callback, closure) VOIDSTAR closure; { GenLegalClosure cl; - int ff; + int ff, ft; int ignoreCheck = (flags & F_IGNORE_CHECK) != 0; cl.cb = callback; @@ -524,6 +530,41 @@ int GenLegal(board, flags, epfile, callback, closure) } } + /* PUSH Fabien */ + + /* generate all potential FRC castling moves (KxR), ignoring flags */ + + if ((flags & F_WHITE_ON_MOVE) != 0) { + + for (ff = 1; ff < 7; ff++) { + if (board[0][ff] == WhiteKing) { + for (ft = 0; ft < 8; ft++) { + if (board[0][ft] == WhiteRook) { + callback(board, flags, + (ft > ff) ? WhiteHSideCastleFR : WhiteASideCastleFR, + 0, ff, 0, ft, closure); + } + } + } + } + + } else { + + for (ff = 1; ff < 7; ff++) { + if (board[7][ff] == BlackKing) { + for (ft = 0; ft < 8; ft++) { + if (board[7][ft] == BlackRook) { + callback(board, flags, + (ft > ff) ? BlackHSideCastleFR : BlackASideCastleFR, + 7, ff, 7, ft, closure); + } + } + } + } + } + + /* POP Fabien */ + return FALSE; } @@ -609,11 +650,6 @@ int CheckTest(board, flags, rf, ff, rt, ft, enPassant) } -typedef struct { - int rf, ff, rt, ft; - ChessMove kind; -} LegalityTestClosure; - extern void LegalityTestCallback P((Board board, int flags, ChessMove kind, int rf, int ff, int rt, int ft, VOIDSTAR closure)); @@ -872,9 +908,18 @@ ChessMove CoordsToAlgebraic(board, flags, epfile, case WhiteKing: case BlackKing: + /* Fabien moved code: FRC castling first (if KxR), wild castling second */ + /* Code added by Tord: FRC castling. */ + if((piece == WhiteKing && board[rt][ft] == WhiteRook) || + (piece == BlackKing && board[rt][ft] == BlackRook)) { + if(ft > ff) strcpy(out, "O-O"); else strcpy(out, "O-O-O"); + return LegalityTest(board, flags, epfile, + rf, ff, rt, ft, promoChar); + } + /* End of code added by Tord */ /* Test for castling or ICS wild castling */ /* Use style "O-O" (oh-oh) for PGN compatibility */ - if (rf == rt && + else if (rf == rt && rf == ((piece == WhiteKing) ? 0 : 7) && ((ff == 4 && (ft == 2 || ft == 6)) || (ff == 3 && (ft == 1 || ft == 5)))) { @@ -899,6 +944,7 @@ ChessMove CoordsToAlgebraic(board, flags, epfile, return LegalityTest(board, flags, epfile, rf, ff, rt, ft, promoChar); } + /* else fall through */ default: diff --git a/moves.h b/moves.h index b1cf2ef..c0c6b75 100644 --- a/moves.h +++ b/moves.h @@ -1,6 +1,6 @@ /* * moves.h - Move generation and checking - * $Id$ + * $Id: moves.h,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. diff --git a/parser.c b/parser.c new file mode 100644 index 0000000..49ebb34 --- /dev/null +++ b/parser.c @@ -0,0 +1,3875 @@ +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +// #include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define YY_USES_REJECT +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 42 +#define YY_END_OF_BUFFER 43 +static yyconst short int yy_acclist[661] = + { 0, + 43, 41, 42, 41, 42, 41, 42, 40, 41, 42, + 41, 42, 25, 41, 42, 41, 42, 40, 41, 42, + 40, 41, 42,16410, 40, 41, 42,16410, 41, 42, + 40, 41, 42, 40, 41, 42, 40, 41, 42, 40, + 41, 42, 40, 41, 42, 40, 41, 42, 40, 41, + 42, 40, 41, 42, 40, 41, 42, 40, 41, 42, + 40, 41, 42, 40, 41, 42, 40, 41, 42, 41, + 42, 40, 41, 42, 40, 41, 42, 40, 41, 42, + 40, 41, 42, 40, 41, 42, 40, 41, 42, 40, + 41, 42, 40, 41, 42, 40, 41, 42, 41, 42, + + 41, 42, 40, 41, 42, 40, 41, 42, 40, 41, + 42,16410, 40, 41, 42,16410, 41, 42, 40, 41, + 42, 40, 41, 42, 40, 41, 42, 40, 41, 42, + 40, 41, 42, 40, 41, 42, 40, 41, 42, 40, + 41, 42, 40, 41, 42, 40, 41, 42, 40, 41, + 42, 40, 41, 42, 40, 41, 42, 40, 41, 42, + 40, 41, 42, 40, 41, 42, 40, 41, 42, 40, + 41, 42, 40, 41, 42, 40, 41, 42, 40, 41, + 42, 40, 41, 42, 41, 42, 33, 40, 17, 40, + 9, 40, 40, 40,16410, 8218, 40, 35, 40, 40, + + 40, 40, 40, 40, 40, 40, 40, 40, 40, 9, + 40, 40, 40, 40, 40, 40, 36, 40, 3, 40, + 40, 40, 4, 40, 40, 3, 40, 40, 4, 40, + 40, 40, 40, 9, 40, 34, 40, 40, 9, 40, + 40, 40,16410, 8218, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 9, 40, 40, 40, + 40, 40, 40, 40, 3, 40, 40, 40, 4, 40, + 40, 3, 40, 40, 4, 40, 40, 40, 40, 9, + 40, 15, 9, 40, 23, 40, 23, 8, 40, 8218, + 22, 40, 22, 24, 40, 40, 40, 6, 40, 40, + + 40, 40, 40, 40, 40, 9, 40, 40, 40, 40, + 40, 20, 40, 4, 40, 40, 3, 40, 40, 3, + 40, 4, 5, 40, 4, 40, 40, 4, 40, 40, + 40, 3, 40, 4, 4, 40, 5, 6, 40, 4, + 40, 40, 9, 40, 34, 39, 9, 40, 23, 40, + 8, 40, 22, 40, 35, 40, 40, 40, 6, 40, + 40, 40, 40, 40, 40, 40, 9, 40, 40, 40, + 40, 40, 20, 40, 4, 40, 40, 3, 40, 40, + 3, 40, 5, 40, 4, 40, 40, 4, 40, 40, + 40, 3, 40, 4, 40, 5, 6, 40, 4, 40, + + 40, 9, 40, 38, 38, 37, 25, 25, 40, 6, + 40, 7, 40, 6, 10, 40, 40, 40, 40, 19, + 40, 40, 21, 40, 16, 40, 40, 40, 40, 40, + 20, 20, 40, 20, 40, 36, 3, 3, 2, 40, + 5, 4, 5, 40, 40, 4, 4, 40, 2, 7, + 40, 5, 6, 5, 6, 40, 5, 40, 40, 40, + 25, 39, 40, 6, 40, 7, 40, 40, 40, 40, + 40, 19, 40, 40, 21, 40, 16, 40, 40, 40, + 40, 40, 20, 40, 20, 20, 40, 2, 40, 5, + 40, 40, 4, 40, 2, 7, 40, 5, 6, 40, + + 5, 40, 40, 40, 7, 1, 40, 40, 40, 19, + 40, 40, 40, 21, 21, 40, 21, 40, 40, 40, + 40, 30, 36, 2, 2, 40, 5, 4, 5, 5, + 40, 2, 7, 39, 1, 40, 40, 40, 19, 40, + 40, 40, 21, 40, 21, 21, 40, 40, 40, 40, + 20, 39, 2, 40, 5, 40, 27, 38, 23, 23, + 22, 22, 24, 24, 20, 21, 1, 1, 40, 40, + 40, 40, 11, 40, 40, 28, 36, 30, 2, 2, + 5, 27, 34, 39, 39, 1, 40, 40, 40, 40, + 21, 39, 11, 40, 40, 20, 39, 18, 24, 20, + + 21, 1, 1, 19, 40, 40, 40, 11, 40, 40, + 40, 40, 21, 39, 40, 11, 40, 40, 12, 40, + 40, 40, 40, 12, 40, 40, 14, 40, 40, 40, + 14, 40, 40, 40, 39, 40, 40, 40, 40, 39, + 39, 40, 40, 31, 40, 39, 39, 31, 40, 13, + 31, 32, 32, 35, 39, 39, 31, 39, 34, 29 + } ; + +static yyconst short int yy_accept[712] = + { 0, + 1, 1, 1, 2, 4, 6, 8, 11, 13, 16, + 18, 21, 25, 29, 31, 34, 37, 40, 43, 46, + 49, 52, 55, 58, 61, 64, 67, 70, 72, 75, + 78, 81, 84, 87, 90, 93, 96, 99, 101, 103, + 106, 109, 113, 117, 119, 122, 125, 128, 131, 134, + 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, + 167, 170, 173, 176, 179, 182, 185, 187, 187, 188, + 189, 189, 189, 189, 189, 190, 190, 190, 191, 191, + 193, 193, 193, 193, 194, 194, 194, 196, 196, 198, + 198, 199, 199, 200, 200, 201, 201, 201, 202, 203, + + 204, 205, 206, 207, 208, 209, 210, 212, 213, 214, + 215, 216, 217, 217, 217, 217, 217, 218, 219, 221, + 221, 222, 223, 225, 226, 228, 228, 229, 231, 232, + 233, 234, 236, 236, 236, 236, 237, 237, 238, 238, + 239, 241, 241, 242, 244, 244, 246, 246, 247, 248, + 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, + 259, 260, 261, 262, 263, 264, 265, 267, 267, 268, + 269, 271, 272, 274, 274, 275, 277, 278, 279, 280, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 283, 283, 283, 283, 285, 287, 288, 290, + + 291, 291, 291, 291, 293, 294, 295, 295, 295, 295, + 295, 296, 296, 297, 297, 298, 298, 298, 300, 301, + 302, 303, 304, 305, 306, 308, 309, 310, 311, 312, + 314, 314, 314, 314, 314, 316, 316, 317, 317, 317, + 319, 320, 322, 323, 325, 325, 325, 327, 328, 330, + 331, 331, 332, 334, 335, 337, 340, 342, 343, 345, + 346, 346, 346, 346, 346, 347, 349, 351, 353, 355, + 355, 356, 356, 357, 358, 358, 359, 361, 362, 363, + 364, 365, 366, 367, 369, 370, 371, 372, 373, 375, + 377, 378, 378, 380, 381, 383, 385, 387, 388, 390, + + 391, 391, 392, 394, 396, 399, 401, 402, 404, 404, + 404, 405, 406, 406, 406, 407, 407, 407, 408, 408, + 409, 409, 409, 409, 410, 410, 410, 410, 410, 410, + 410, 410, 410, 410, 410, 410, 412, 412, 412, 414, + 415, 416, 417, 417, 418, 419, 420, 422, 422, 423, + 425, 427, 428, 429, 430, 431, 432, 434, 436, 436, + 436, 436, 436, 437, 438, 438, 439, 441, 442, 443, + 443, 443, 443, 445, 446, 447, 447, 449, 449, 452, + 454, 457, 459, 460, 461, 461, 462, 462, 462, 462, + 462, 463, 463, 464, 464, 464, 466, 468, 469, 469, + + 470, 471, 472, 474, 475, 477, 479, 480, 481, 482, + 483, 485, 486, 488, 490, 492, 493, 495, 498, 501, + 503, 504, 505, 505, 505, 505, 505, 505, 505, 505, + 505, 505, 505, 505, 505, 505, 505, 505, 505, 505, + 506, 508, 509, 510, 510, 512, 512, 513, 514, 515, + 517, 519, 520, 521, 522, 522, 522, 524, 524, 524, + 525, 525, 525, 527, 528, 528, 529, 530, 530, 532, + 532, 534, 534, 534, 534, 534, 534, 534, 535, 535, + 535, 537, 538, 539, 541, 542, 543, 545, 546, 548, + 549, 550, 551, 553, 555, 557, 557, 557, 559, 559, + + 559, 560, 560, 561, 561, 562, 562, 563, 563, 564, + 564, 565, 565, 565, 565, 565, 567, 567, 568, 568, + 568, 570, 571, 571, 571, 571, 571, 571, 572, 573, + 575, 576, 578, 578, 579, 580, 581, 582, 582, 582, + 584, 584, 584, 585, 586, 586, 586, 588, 589, 590, + 591, 593, 595, 596, 598, 598, 599, 599, 599, 599, + 600, 600, 600, 600, 602, 602, 603, 604, 604, 605, + 605, 605, 605, 605, 606, 607, 608, 610, 611, 611, + 611, 611, 611, 611, 612, 613, 615, 616, 618, 619, + 619, 619, 619, 619, 619, 619, 620, 620, 620, 620, + + 620, 621, 622, 622, 622, 622, 622, 623, 624, 624, + 624, 624, 624, 625, 625, 625, 625, 626, 627, 629, + 629, 629, 629, 629, 630, 630, 631, 633, 633, 633, + 633, 633, 634, 635, 635, 635, 635, 635, 636, 637, + 638, 638, 638, 638, 638, 638, 639, 640, 640, 640, + 640, 640, 641, 642, 643, 644, 644, 644, 644, 644, + 644, 646, 646, 646, 646, 646, 647, 648, 650, 650, + 650, 651, 651, 652, 652, 653, 653, 653, 655, 655, + 656, 657, 657, 657, 657, 657, 659, 659, 659, 659, + 659, 659, 659, 659, 659, 659, 659, 659, 659, 659, + + 659, 659, 659, 659, 659, 659, 659, 659, 660, 661, + 661 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 1, 5, 6, 7, 8, 1, 9, 10, + 11, 12, 13, 1, 14, 15, 16, 17, 18, 19, + 20, 20, 20, 20, 20, 20, 21, 22, 23, 1, + 24, 1, 1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 34, 44, 34, 45, 46, 34, 34, + 47, 1, 48, 1, 49, 1, 50, 51, 52, 53, + + 54, 55, 56, 57, 58, 34, 59, 60, 61, 62, + 63, 64, 41, 65, 66, 67, 68, 34, 69, 46, + 70, 34, 71, 1, 72, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[73] = + { 0, + 1, 2, 3, 2, 1, 1, 1, 1, 4, 5, + 6, 1, 1, 7, 1, 1, 4, 8, 8, 8, + 4, 9, 1, 10, 1, 4, 11, 4, 4, 4, + 4, 4, 4, 4, 11, 4, 4, 11, 12, 12, + 11, 11, 4, 4, 4, 7, 1, 1, 1, 13, + 14, 13, 13, 15, 13, 13, 13, 4, 11, 4, + 4, 11, 12, 12, 11, 4, 4, 4, 4, 4, + 1, 1 + } ; + +static yyconst short int yy_base[787] = + { 0, + 0, 72, 2588, 4394, 119, 129, 0, 141, 2583, 139, + 150, 171, 238, 2583, 257, 2527, 2518, 117, 159, 2518, + 2530, 190, 142, 233, 191, 2512, 239, 317, 376, 420, + 125, 205, 193, 114, 243, 120, 204, 331, 2574, 174, + 353, 476, 258, 260, 543, 244, 282, 346, 311, 334, + 256, 312, 365, 595, 331, 351, 354, 644, 688, 242, + 348, 327, 365, 386, 303, 392, 552, 2521, 432, 0, + 2566, 258, 557, 282, 4394, 2562, 393, 320, 2556, 2554, + 2552, 342, 442, 2551, 457, 364, 605, 2550, 0, 2562, + 4394, 576, 530, 617, 732, 625, 661, 449, 2514, 2509, + + 2512, 2517, 2492, 2493, 2490, 2517, 2515, 463, 572, 2503, + 2494, 2489, 2502, 789, 372, 861, 4394, 669, 924, 705, + 713, 468, 980, 765, 1032, 773, 789, 1076, 481, 637, + 2486, 2485, 390, 2475, 830, 2542, 2541, 383, 2540, 617, + 593, 546, 858, 874, 406, 579, 432, 865, 1120, 1005, + 505, 683, 726, 727, 621, 872, 870, 876, 603, 873, + 905, 665, 891, 884, 882, 973, 1168, 1013, 1049, 936, + 1225, 1057, 1277, 1093, 1101, 1321, 641, 983, 928, 930, + 896, 2478, 538, 543, 612, 2531, 622, 1030, 1221, 2528, + 2466, 4394, 2532, 2531, 2529, 2518, 2527, 2526, 0, 4394, + + 2525, 2524, 2523, 2521, 2520, 443, 2465, 2459, 2471, 2466, + 668, 709, 594, 1218, 732, 753, 756, 1365, 2467, 2466, + 2446, 803, 906, 2460, 2498, 0, 2453, 2449, 2441, 1422, + 689, 1069, 172, 1494, 790, 1251, 1294, 1302, 1415, 2496, + 838, 976, 1288, 1557, 1413, 1449, 678, 629, 910, 1338, + 1346, 992, 1105, 1502, 1057, 1609, 1182, 1100, 2492, 4394, + 1510, 996, 2501, 191, 2501, 1172, 960, 962, 1158, 831, + 2499, 1132, 1237, 889, 1482, 1300, 1653, 1176, 1228, 1010, + 1273, 1315, 1175, 1190, 0, 1204, 1531, 1071, 1710, 1774, + 1550, 1582, 1242, 1443, 1551, 1830, 1272, 1239, 1121, 1493, + + 1590, 1606, 1659, 1141, 1882, 1673, 1721, 1427, 1504, 2447, + 4394, 843, 1025, 2489, 4394, 1727, 2487, 2485, 2423, 2422, + 2475, 2474, 2473, 2473, 1010, 2472, 539, 2471, 1290, 1541, + 610, 2421, 2421, 2414, 2414, 0, 939, 1197, 0, 4394, + 4394, 1699, 1710, 1344, 2420, 2419, 885, 879, 1130, 1939, + 0, 2438, 2420, 2421, 2420, 0, 2011, 2083, 733, 949, + 1131, 1410, 2468, 2461, 1365, 4394, 2146, 1356, 1154, 689, + 1752, 1796, 1157, 715, 2417, 2406, 0, 1386, 0, 1564, + 2202, 1802, 1633, 2406, 1857, 2464, 1571, 1672, 2417, 2403, + 2462, 1187, 1451, 1003, 894, 1295, 1470, 1718, 1855, 1823, + + 1555, 1665, 1782, 1796, 2267, 1574, 1588, 1826, 1647, 1674, + 2339, 2460, 2411, 2475, 1840, 1858, 1608, 0, 2531, 1905, + 1956, 1857, 1728, 2409, 2451, 1639, 2450, 2385, 2445, 2383, + 2443, 2381, 2434, 1281, 2399, 2395, 2395, 2390, 1389, 4394, + 2587, 2443, 1146, 1916, 2442, 1281, 2415, 2390, 0, 2652, + 2724, 2378, 2378, 2428, 1322, 1883, 4394, 2426, 1966, 1457, + 2002, 2076, 2419, 1428, 952, 4394, 2375, 2364, 0, 2410, + 1544, 1774, 2396, 1877, 2392, 2347, 2341, 1521, 1030, 1255, + 2787, 1676, 1881, 1788, 1891, 1861, 2852, 2402, 2924, 1963, + 1841, 1944, 2402, 1691, 1649, 1816, 1235, 4394, 1979, 2393, + + 2392, 2330, 2329, 2389, 2388, 2326, 2325, 2385, 2381, 2319, + 2318, 2366, 2362, 2315, 2323, 1377, 2320, 1778, 2004, 2102, + 2355, 2310, 2348, 2304, 2287, 2326, 2288, 2289, 2264, 1524, + 2279, 4394, 1980, 4394, 2317, 4394, 4394, 2312, 2053, 2319, + 2268, 2261, 2315, 1999, 1555, 548, 1908, 1982, 1951, 1786, + 2301, 2043, 2029, 2297, 2054, 4394, 2243, 2158, 2289, 2284, + 2219, 2205, 2209, 4394, 2198, 2239, 4394, 2235, 2228, 2174, + 2228, 2182, 2157, 2174, 2105, 2086, 0, 2061, 2130, 2120, + 2054, 1040, 358, 2032, 2091, 2073, 2093, 1970, 2136, 2120, + 1988, 2029, 1542, 1985, 1941, 1941, 1923, 884, 1858, 1831, + + 2996, 1815, 1772, 1768, 1617, 651, 3068, 2150, 2149, 1757, + 1745, 1725, 4394, 1623, 1924, 2045, 3140, 2054, 0, 1631, + 1594, 1302, 1202, 3212, 2158, 2066, 2040, 2177, 1577, 1531, + 2110, 1524, 1496, 1455, 1427, 1308, 1895, 2162, 1448, 1422, + 2179, 1319, 1298, 2163, 2154, 1285, 1115, 1083, 1117, 1726, + 1576, 2196, 2198, 1062, 984, 2193, 2056, 930, 2153, 2166, + 0, 902, 804, 803, 1618, 2210, 2238, 0, 2213, 583, + 4394, 497, 2199, 486, 4394, 426, 460, 4394, 2116, 2203, + 2254, 2231, 392, 317, 1804, 2255, 2281, 239, 2027, 829, + 2006, 2117, 2293, 2295, 2298, 2299, 2303, 2317, 2321, 2322, + + 2323, 2365, 2366, 2369, 2370, 2371, 2233, 154, 4394, 4394, + 3281, 3296, 3311, 3326, 3341, 3353, 3368, 3383, 3397, 3412, + 3427, 3442, 3457, 3472, 3487, 3502, 3517, 3532, 3547, 3562, + 3577, 3592, 3607, 3622, 3633, 3648, 3663, 3678, 3693, 3708, + 3723, 3738, 3753, 3768, 3783, 3792, 3807, 3822, 3837, 3852, + 3867, 3882, 3897, 3908, 3923, 3938, 3953, 3968, 3983, 3998, + 4013, 4028, 4043, 4058, 4073, 4088, 4103, 4118, 4133, 4148, + 4163, 4174, 4188, 4203, 4218, 4233, 4244, 4258, 4273, 4288, + 4303, 4318, 4333, 4348, 4363, 4378 + } ; + +static yyconst short int yy_def[787] = + { 0, + 710, 710, 710, 710, 710, 710, 711, 712, 710, 710, + 711, 710, 12, 713, 711, 711, 711, 711, 15, 711, + 711, 15, 711, 711, 15, 711, 711, 714, 711, 15, + 29, 29, 29, 29, 29, 29, 711, 715, 710, 716, + 716, 710, 42, 713, 716, 716, 716, 716, 45, 716, + 716, 45, 716, 716, 45, 716, 716, 716, 45, 58, + 58, 58, 58, 58, 58, 716, 715, 710, 710, 711, + 717, 718, 717, 710, 710, 710, 710, 711, 710, 711, + 710, 719, 719, 711, 719, 710, 12, 710, 711, 713, + 710, 710, 711, 710, 711, 710, 710, 95, 711, 711, + + 711, 711, 711, 711, 711, 711, 711, 711, 95, 711, + 711, 711, 720, 714, 720, 721, 710, 711, 711, 710, + 711, 711, 711, 711, 119, 710, 711, 123, 95, 711, + 711, 711, 715, 722, 715, 710, 723, 716, 710, 716, + 716, 710, 716, 42, 710, 716, 724, 716, 148, 710, + 149, 716, 716, 716, 716, 716, 716, 716, 716, 716, + 716, 149, 716, 716, 716, 148, 148, 710, 148, 716, + 716, 148, 167, 710, 148, 171, 149, 716, 716, 716, + 715, 710, 717, 725, 725, 726, 727, 717, 717, 728, + 729, 710, 710, 710, 710, 711, 711, 710, 711, 710, + + 710, 710, 710, 711, 710, 710, 710, 710, 710, 710, + 711, 710, 95, 710, 711, 710, 710, 711, 711, 711, + 711, 711, 711, 711, 711, 218, 711, 711, 711, 730, + 731, 732, 733, 734, 123, 710, 711, 710, 710, 711, + 711, 711, 735, 711, 710, 710, 711, 711, 123, 711, + 710, 711, 711, 735, 123, 244, 711, 711, 711, 710, + 715, 710, 736, 710, 737, 716, 716, 716, 716, 738, + 736, 739, 716, 149, 710, 716, 149, 716, 716, 716, + 716, 716, 716, 716, 277, 716, 716, 716, 740, 716, + 716, 710, 716, 716, 716, 290, 716, 716, 290, 291, + + 710, 716, 716, 290, 296, 716, 716, 716, 715, 710, + 710, 741, 741, 742, 710, 743, 744, 744, 745, 745, + 710, 710, 710, 711, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 711, 746, 710, 711, 710, + 710, 711, 710, 711, 711, 711, 711, 710, 711, 747, + 711, 711, 711, 711, 711, 748, 749, 749, 750, 750, + 751, 752, 753, 710, 710, 710, 711, 754, 710, 710, + 710, 710, 711, 711, 710, 710, 711, 710, 367, 754, + 367, 711, 711, 711, 715, 710, 710, 710, 710, 710, + 755, 710, 716, 756, 756, 716, 716, 291, 710, 716, + + 716, 716, 716, 716, 757, 716, 716, 716, 716, 716, + 758, 748, 758, 716, 716, 716, 716, 414, 414, 716, + 716, 716, 715, 710, 759, 760, 761, 762, 763, 764, + 765, 766, 710, 710, 710, 710, 710, 710, 710, 710, + 711, 711, 711, 710, 711, 710, 711, 711, 767, 768, + 768, 711, 711, 711, 769, 770, 710, 771, 710, 772, + 710, 710, 711, 710, 710, 710, 710, 710, 711, 710, + 772, 715, 710, 710, 710, 710, 710, 773, 774, 774, + 414, 716, 716, 716, 716, 716, 775, 767, 775, 716, + 716, 716, 776, 716, 716, 715, 710, 710, 760, 761, + + 761, 762, 762, 763, 763, 764, 764, 765, 765, 766, + 766, 710, 710, 710, 710, 710, 710, 777, 710, 710, + 711, 711, 778, 710, 710, 710, 710, 711, 711, 711, + 711, 710, 710, 710, 710, 710, 710, 710, 715, 710, + 710, 710, 773, 773, 774, 774, 716, 716, 716, 716, + 779, 716, 716, 776, 715, 710, 710, 760, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 778, 778, 710, + 710, 710, 710, 711, 711, 711, 711, 711, 715, 710, + 710, 774, 774, 716, 716, 779, 716, 716, 716, 715, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + + 780, 711, 710, 710, 774, 774, 781, 716, 715, 710, + 710, 710, 710, 710, 782, 782, 780, 617, 711, 710, + 710, 774, 774, 781, 782, 624, 716, 715, 710, 710, + 782, 617, 617, 710, 710, 774, 774, 783, 624, 624, + 715, 710, 710, 782, 782, 617, 617, 710, 710, 774, + 774, 783, 783, 624, 624, 715, 710, 710, 782, 782, + 617, 784, 710, 785, 774, 783, 783, 624, 715, 710, + 710, 710, 782, 784, 710, 710, 785, 710, 774, 783, + 783, 715, 710, 710, 774, 783, 715, 710, 774, 715, + 786, 786, 786, 786, 786, 786, 786, 786, 786, 786, + + 786, 786, 786, 786, 786, 786, 786, 710, 710, 0, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710 + } ; + +static yyconst short int yy_nxt[4467] = + { 0, + 4, 4, 4, 5, 4, 4, 6, 4, 7, 8, + 4, 9, 10, 7, 4, 4, 11, 12, 13, 13, + 13, 4, 14, 4, 4, 7, 15, 16, 17, 7, + 7, 18, 7, 7, 19, 20, 21, 22, 23, 24, + 22, 25, 26, 7, 27, 7, 28, 4, 4, 29, + 30, 31, 32, 33, 34, 35, 36, 7, 19, 20, + 21, 22, 37, 24, 25, 26, 7, 7, 27, 7, + 38, 4, 4, 4, 4, 5, 4, 39, 6, 39, + 7, 8, 4, 9, 10, 40, 4, 4, 41, 42, + 43, 43, 43, 4, 44, 4, 4, 40, 45, 46, + + 47, 40, 40, 48, 40, 40, 49, 50, 51, 52, + 53, 54, 52, 55, 56, 40, 57, 40, 28, 4, + 4, 58, 59, 60, 61, 62, 63, 64, 65, 40, + 49, 50, 51, 52, 66, 54, 55, 56, 40, 40, + 57, 40, 67, 4, 68, 69, 69, 69, 69, 69, + 72, 75, 76, 77, 102, 106, 709, 73, 73, 73, + 73, 73, 710, 78, 122, 79, 80, 123, 68, 123, + 122, 81, 82, 82, 83, 123, 362, 123, 103, 70, + 107, 130, 70, 710, 84, 85, 86, 87, 87, 87, + 87, 87, 88, 710, 710, 139, 70, 89, 70, 70, + + 70, 70, 70, 70, 70, 89, 70, 70, 89, 89, + 89, 89, 89, 70, 70, 70, 70, 131, 70, 363, + 89, 89, 89, 89, 89, 89, 89, 89, 70, 89, + 70, 70, 89, 89, 89, 89, 70, 70, 70, 70, + 70, 82, 92, 122, 109, 123, 389, 123, 94, 70, + 70, 70, 70, 710, 390, 122, 123, 97, 123, 710, + 92, 82, 91, 147, 70, 139, 132, 186, 187, 101, + 93, 138, 94, 710, 95, 95, 95, 139, 96, 139, + 102, 97, 108, 108, 108, 108, 108, 108, 108, 108, + 70, 190, 662, 122, 171, 111, 112, 123, 178, 123, + + 153, 112, 93, 139, 103, 158, 98, 98, 98, 98, + 98, 98, 98, 98, 710, 710, 99, 113, 114, 114, + 114, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 115, 113, 113, 134, 710, 710, 196, 197, 113, 113, + 113, 113, 70, 82, 82, 82, 154, 135, 135, 135, + 135, 135, 191, 170, 70, 139, 77, 92, 171, 70, + 91, 70, 70, 113, 117, 113, 140, 139, 79, 141, + 138, 138, 139, 70, 142, 139, 688, 170, 159, 171, + 205, 171, 206, 155, 162, 231, 139, 113, 113, 118, + 138, 70, 134, 119, 119, 119, 157, 120, 170, 171, + + 70, 171, 136, 160, 139, 179, 193, 156, 194, 265, + 164, 165, 154, 139, 195, 170, 165, 163, 171, 117, + 171, 121, 205, 155, 606, 122, 123, 122, 122, 122, + 122, 122, 122, 124, 271, 272, 170, 125, 125, 125, + 171, 126, 171, 82, 82, 82, 330, 156, 69, 69, + 69, 69, 69, 556, 180, 201, 331, 202, 82, 82, + 82, 136, 678, 203, 331, 127, 218, 218, 218, 128, + 129, 128, 129, 129, 129, 129, 129, 82, 82, 83, + 226, 226, 226, 684, 70, 244, 244, 244, 675, 143, + 85, 86, 144, 144, 144, 144, 144, 145, 256, 256, + + 256, 138, 146, 138, 138, 138, 138, 138, 138, 138, + 146, 138, 138, 146, 146, 146, 146, 146, 138, 138, + 138, 138, 277, 277, 277, 146, 146, 146, 146, 146, + 146, 146, 146, 138, 146, 138, 138, 146, 146, 146, + 146, 138, 138, 138, 138, 138, 92, 184, 311, 265, + 91, 70, 186, 312, 134, 205, 148, 206, 94, 683, + 149, 149, 149, 198, 150, 181, 184, 97, 135, 135, + 135, 135, 135, 188, 188, 188, 188, 188, 189, 211, + 211, 211, 211, 211, 211, 211, 211, 70, 148, 218, + 218, 218, 151, 151, 151, 151, 151, 151, 151, 151, + + 139, 70, 152, 70, 207, 583, 208, 70, 82, 268, + 94, 70, 209, 433, 139, 710, 139, 210, 70, 97, + 710, 186, 312, 136, 139, 70, 710, 434, 207, 70, + 208, 314, 315, 266, 267, 671, 209, 227, 139, 70, + 210, 284, 139, 376, 161, 161, 161, 161, 161, 161, + 161, 161, 70, 91, 244, 244, 244, 166, 305, 305, + 305, 167, 167, 167, 281, 168, 212, 212, 212, 212, + 212, 212, 212, 212, 216, 216, 216, 216, 216, 216, + 216, 216, 277, 277, 277, 336, 336, 336, 375, 169, + 220, 70, 377, 170, 171, 170, 170, 170, 170, 170, + + 170, 172, 360, 376, 139, 173, 173, 173, 623, 174, + 217, 217, 217, 217, 217, 217, 217, 217, 235, 235, + 235, 235, 235, 235, 235, 235, 337, 337, 337, 468, + 286, 248, 278, 175, 70, 70, 117, 176, 177, 176, + 177, 177, 177, 177, 177, 213, 360, 139, 139, 339, + 339, 339, 466, 214, 243, 243, 243, 243, 243, 243, + 243, 243, 123, 123, 123, 123, 123, 123, 123, 123, + 340, 340, 340, 341, 341, 341, 280, 213, 469, 279, + 117, 215, 215, 215, 215, 215, 215, 215, 215, 113, + 114, 114, 114, 113, 113, 113, 113, 113, 113, 113, + + 113, 113, 113, 113, 113, 678, 348, 70, 70, 70, + 113, 113, 113, 113, 249, 249, 249, 249, 249, 249, + 249, 249, 254, 254, 254, 254, 254, 254, 254, 254, + 349, 691, 134, 271, 272, 113, 117, 113, 255, 255, + 255, 255, 255, 255, 255, 255, 135, 135, 135, 135, + 135, 261, 314, 315, 349, 367, 367, 367, 676, 113, + 113, 113, 232, 232, 232, 233, 70, 113, 113, 113, + 113, 113, 113, 70, 269, 113, 113, 82, 70, 139, + 70, 70, 113, 113, 70, 113, 139, 138, 444, 710, + 70, 139, 70, 139, 139, 139, 91, 139, 134, 70, + + 136, 136, 138, 139, 675, 139, 446, 113, 117, 309, + 139, 268, 139, 70, 273, 273, 273, 273, 273, 273, + 273, 273, 285, 285, 285, 524, 139, 336, 336, 336, + 446, 113, 113, 236, 138, 282, 70, 237, 70, 281, + 287, 288, 283, 289, 70, 238, 445, 239, 524, 139, + 240, 139, 343, 296, 296, 296, 480, 139, 240, 350, + 343, 240, 455, 325, 240, 240, 468, 136, 70, 237, + 70, 350, 350, 241, 242, 241, 241, 241, 241, 241, + 241, 139, 240, 139, 343, 240, 366, 672, 240, 245, + 308, 70, 268, 367, 367, 367, 117, 244, 244, 244, + + 296, 296, 296, 246, 139, 91, 247, 386, 265, 379, + 379, 379, 387, 388, 247, 537, 265, 247, 70, 427, + 247, 247, 290, 290, 290, 290, 290, 290, 290, 290, + 247, 139, 91, 248, 314, 315, 279, 668, 247, 184, + 311, 247, 91, 605, 247, 250, 188, 188, 188, 188, + 188, 189, 479, 251, 216, 216, 216, 216, 216, 216, + 216, 216, 243, 243, 243, 243, 243, 243, 243, 243, + 232, 232, 232, 233, 381, 381, 381, 250, 403, 70, + 428, 252, 253, 252, 252, 252, 252, 252, 252, 213, + 545, 668, 139, 256, 256, 256, 265, 214, 171, 171, + + 171, 171, 171, 171, 171, 171, 299, 299, 299, 299, + 299, 299, 299, 299, 376, 366, 117, 339, 339, 339, + 663, 213, 379, 379, 379, 215, 257, 215, 215, 258, + 215, 215, 215, 274, 91, 362, 662, 410, 396, 396, + 396, 275, 254, 254, 254, 254, 254, 254, 254, 254, + 304, 304, 304, 304, 304, 304, 304, 304, 419, 419, + 419, 329, 447, 377, 375, 274, 70, 467, 661, 276, + 276, 276, 276, 276, 276, 276, 276, 236, 363, 139, + 70, 291, 522, 70, 70, 393, 448, 394, 478, 292, + 478, 239, 375, 139, 293, 395, 139, 139, 70, 339, + + 339, 339, 293, 407, 91, 293, 522, 370, 293, 293, + 374, 139, 70, 291, 440, 440, 440, 294, 295, 294, + 294, 294, 294, 294, 294, 139, 293, 401, 406, 293, + 184, 311, 293, 70, 245, 248, 70, 316, 316, 316, + 316, 316, 296, 296, 296, 70, 139, 70, 246, 139, + 70, 297, 366, 376, 396, 396, 396, 91, 139, 297, + 139, 408, 297, 139, 637, 297, 297, 338, 338, 338, + 338, 338, 338, 338, 338, 297, 348, 364, 298, 402, + 70, 70, 375, 297, 512, 364, 297, 556, 364, 297, + 300, 364, 364, 139, 139, 557, 513, 245, 301, 429, + + 404, 364, 417, 70, 91, 368, 368, 368, 70, 364, + 91, 246, 364, 526, 661, 364, 139, 397, 397, 397, + 546, 139, 300, 70, 404, 298, 302, 303, 302, 302, + 302, 302, 302, 302, 274, 455, 139, 527, 305, 305, + 305, 370, 275, 241, 241, 241, 241, 241, 241, 241, + 241, 365, 365, 365, 365, 365, 365, 365, 365, 636, + 430, 441, 441, 441, 658, 371, 274, 650, 405, 532, + 276, 306, 276, 276, 307, 276, 276, 276, 342, 372, + 405, 405, 460, 460, 460, 657, 343, 252, 252, 252, + 252, 252, 252, 252, 252, 378, 378, 378, 378, 378, + + 378, 378, 378, 471, 471, 471, 518, 518, 518, 465, + 342, 456, 456, 456, 344, 344, 344, 344, 344, 344, + 344, 344, 356, 356, 236, 356, 356, 356, 356, 356, + 563, 356, 356, 356, 356, 70, 356, 356, 467, 369, + 422, 364, 564, 356, 356, 356, 356, 369, 139, 364, + 369, 70, 364, 369, 369, 364, 364, 457, 245, 70, + 414, 414, 414, 369, 139, 364, 461, 268, 356, 356, + 356, 369, 139, 364, 369, 369, 364, 369, 70, 364, + 462, 465, 655, 369, 654, 265, 369, 358, 649, 369, + 369, 139, 356, 356, 113, 232, 232, 232, 233, 369, + + 113, 113, 113, 113, 113, 113, 134, 369, 113, 113, + 369, 245, 134, 369, 648, 113, 113, 423, 113, 380, + 380, 380, 544, 392, 544, 246, 385, 385, 385, 385, + 385, 338, 338, 338, 338, 338, 338, 338, 338, 70, + 113, 117, 302, 302, 302, 302, 302, 302, 302, 302, + 431, 431, 139, 461, 331, 370, 647, 91, 70, 70, + 646, 366, 331, 70, 113, 113, 371, 462, 414, 414, + 414, 139, 139, 371, 77, 136, 139, 576, 91, 665, + 372, 136, 70, 373, 473, 265, 79, 372, 643, 577, + 409, 373, 81, 265, 373, 139, 70, 373, 373, 294, + + 294, 294, 294, 294, 294, 294, 294, 373, 582, 139, + 374, 432, 432, 482, 70, 373, 70, 465, 373, 91, + 91, 373, 342, 418, 418, 418, 268, 139, 642, 139, + 343, 365, 365, 365, 365, 365, 365, 365, 365, 378, + 378, 378, 378, 378, 378, 378, 378, 468, 184, 498, + 441, 441, 441, 499, 342, 70, 635, 70, 344, 382, + 344, 344, 383, 344, 344, 344, 398, 70, 139, 366, + 139, 622, 679, 70, 399, 474, 418, 418, 418, 92, + 139, 70, 70, 375, 70, 475, 139, 86, 634, 630, + 397, 397, 397, 88, 139, 139, 469, 139, 398, 70, + + 491, 536, 400, 400, 400, 400, 400, 400, 400, 400, + 356, 356, 139, 356, 356, 356, 356, 356, 357, 356, + 356, 356, 356, 483, 356, 356, 298, 492, 91, 70, + 134, 412, 356, 356, 356, 376, 184, 311, 397, 397, + 397, 496, 139, 426, 426, 426, 426, 426, 344, 344, + 344, 344, 344, 344, 344, 344, 356, 356, 356, 439, + 439, 439, 439, 439, 439, 439, 439, 400, 400, 400, + 400, 400, 400, 400, 400, 413, 134, 613, 464, 664, + 356, 356, 70, 245, 417, 444, 464, 519, 539, 464, + 70, 444, 464, 464, 70, 139, 70, 246, 629, 136, + + 297, 520, 464, 139, 70, 371, 91, 139, 297, 139, + 464, 297, 467, 464, 297, 297, 464, 139, 134, 441, + 441, 441, 464, 556, 297, 621, 620, 298, 485, 555, + 464, 70, 297, 464, 70, 297, 464, 464, 297, 371, + 481, 481, 481, 484, 139, 540, 464, 139, 70, 70, + 467, 585, 486, 372, 464, 374, 415, 464, 265, 134, + 464, 139, 139, 689, 415, 70, 70, 415, 619, 70, + 415, 415, 468, 472, 472, 472, 472, 472, 139, 139, + 415, 490, 139, 416, 456, 456, 456, 136, 415, 70, + 201, 415, 202, 416, 415, 398, 615, 91, 203, 70, + + 615, 553, 139, 399, 439, 439, 439, 439, 439, 439, + 439, 439, 139, 70, 550, 467, 70, 548, 567, 268, + 549, 495, 481, 481, 481, 523, 139, 398, 136, 139, + 457, 400, 420, 400, 400, 421, 400, 400, 400, 449, + 449, 548, 449, 449, 449, 449, 449, 92, 449, 449, + 449, 449, 70, 449, 449, 631, 651, 524, 416, 70, + 449, 449, 449, 449, 70, 139, 525, 533, 533, 533, + 468, 70, 139, 481, 481, 481, 614, 139, 70, 631, + 524, 533, 533, 533, 139, 449, 449, 449, 184, 311, + 70, 139, 451, 584, 612, 558, 558, 558, 558, 558, + + 544, 392, 544, 139, 451, 451, 613, 596, 693, 449, + 449, 356, 356, 534, 356, 356, 356, 356, 356, 495, + 356, 356, 356, 356, 552, 356, 356, 534, 535, 91, + 566, 158, 356, 356, 356, 356, 535, 70, 566, 535, + 70, 566, 535, 535, 566, 566, 611, 560, 70, 610, + 139, 70, 535, 139, 566, 134, 134, 356, 356, 356, + 535, 139, 566, 535, 139, 566, 535, 590, 566, 579, + 579, 579, 579, 579, 607, 392, 631, 260, 589, 632, + 664, 356, 356, 356, 356, 461, 356, 356, 356, 356, + 356, 639, 356, 356, 356, 356, 587, 356, 356, 70, + + 631, 70, 535, 633, 356, 356, 356, 356, 588, 670, + 535, 519, 139, 535, 139, 640, 535, 535, 91, 693, + 604, 671, 134, 603, 136, 136, 535, 602, 566, 356, + 356, 356, 134, 609, 535, 644, 566, 535, 577, 566, + 535, 631, 566, 566, 70, 588, 579, 579, 579, 579, + 579, 134, 566, 356, 356, 461, 607, 139, 70, 645, + 566, 638, 628, 566, 392, 631, 566, 184, 498, 462, + 601, 139, 463, 685, 558, 558, 558, 558, 558, 134, + 463, 134, 673, 463, 631, 631, 463, 463, 260, 631, + 641, 136, 656, 653, 631, 134, 463, 631, 392, 659, + + 392, 540, 608, 627, 463, 392, 669, 463, 631, 631, + 463, 371, 392, 631, 660, 134, 601, 653, 631, 673, + 136, 631, 600, 666, 599, 372, 682, 653, 373, 653, + 631, 598, 686, 134, 653, 693, 373, 597, 569, 373, + 392, 653, 373, 373, 687, 569, 680, 667, 136, 567, + 136, 653, 373, 653, 631, 374, 392, 392, 653, 596, + 373, 564, 595, 373, 136, 653, 373, 449, 449, 653, + 449, 449, 449, 449, 449, 450, 449, 449, 449, 449, + 594, 449, 449, 134, 136, 653, 653, 593, 488, 449, + 449, 449, 592, 653, 690, 693, 591, 693, 681, 392, + + 693, 693, 136, 392, 708, 693, 694, 686, 695, 653, + 653, 696, 697, 449, 449, 449, 698, 392, 581, 693, + 489, 580, 262, 693, 693, 693, 537, 536, 578, 575, + 699, 574, 489, 489, 700, 701, 702, 449, 449, 356, + 356, 573, 356, 356, 356, 356, 356, 357, 356, 356, + 356, 356, 136, 356, 356, 572, 571, 570, 569, 105, + 412, 356, 356, 356, 260, 567, 260, 693, 693, 260, + 260, 693, 693, 693, 260, 565, 562, 561, 703, 704, + 560, 559, 705, 706, 707, 356, 356, 356, 260, 511, + 511, 509, 260, 260, 260, 509, 507, 507, 505, 505, + + 503, 503, 501, 501, 392, 551, 542, 541, 205, 356, + 356, 356, 356, 198, 356, 356, 356, 356, 356, 357, + 356, 356, 356, 356, 466, 356, 356, 538, 465, 536, + 459, 92, 412, 356, 356, 356, 260, 260, 531, 530, + 260, 260, 260, 529, 528, 444, 92, 517, 516, 515, + 514, 434, 511, 509, 507, 505, 503, 356, 356, 356, + 501, 187, 497, 493, 392, 477, 476, 74, 199, 470, + 370, 366, 459, 454, 453, 452, 199, 443, 442, 438, + 437, 356, 356, 70, 461, 436, 435, 205, 205, 199, + 198, 198, 198, 320, 320, 318, 139, 318, 462, 187, + + 424, 494, 264, 392, 264, 384, 366, 355, 354, 494, + 353, 352, 494, 351, 347, 494, 494, 346, 345, 335, + 334, 333, 332, 329, 329, 494, 328, 327, 326, 325, + 325, 324, 323, 494, 322, 321, 494, 320, 318, 494, + 371, 311, 310, 265, 264, 262, 260, 199, 259, 117, + 230, 229, 228, 199, 372, 225, 224, 415, 223, 222, + 222, 221, 220, 219, 91, 415, 205, 204, 415, 198, + 199, 415, 415, 198, 192, 184, 182, 137, 110, 105, + 104, 415, 101, 100, 416, 91, 74, 710, 710, 415, + 710, 710, 415, 710, 710, 415, 519, 710, 710, 710, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 520, 710, 710, 521, 710, 710, 710, 710, 710, 710, + 710, 521, 710, 710, 521, 710, 710, 521, 521, 710, + 710, 710, 710, 710, 710, 710, 710, 521, 710, 710, + 710, 710, 710, 710, 710, 521, 710, 710, 521, 710, + 710, 521, 449, 449, 710, 449, 449, 449, 449, 449, + 710, 449, 449, 449, 449, 710, 449, 449, 710, 710, + 710, 710, 710, 449, 449, 449, 449, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 449, 449, + + 449, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 449, 449, 449, 449, 710, 449, 449, 449, + 449, 449, 710, 449, 449, 449, 449, 710, 449, 449, + 710, 710, 710, 710, 710, 449, 449, 449, 449, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 449, 449, 449, 710, 710, 710, 710, 451, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 451, + 451, 710, 710, 710, 449, 449, 519, 710, 710, 710, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 520, 710, 710, 547, 710, 710, 710, 710, 710, 710, + 710, 547, 710, 710, 547, 710, 710, 547, 547, 710, + 710, 710, 710, 710, 710, 710, 710, 547, 710, 710, + 710, 710, 710, 710, 710, 547, 710, 710, 547, 710, + 710, 547, 449, 449, 710, 449, 449, 449, 449, 449, + 450, 449, 449, 449, 449, 710, 449, 449, 710, 710, + 710, 710, 710, 488, 449, 449, 449, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 449, 449, + + 449, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 449, 449, 449, 449, 710, 449, 449, 449, + 449, 449, 450, 449, 449, 449, 449, 710, 449, 449, + 710, 710, 710, 710, 710, 488, 449, 449, 449, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 449, 449, 449, 710, 710, 710, 710, 489, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 489, + 489, 710, 710, 710, 449, 449, 616, 616, 710, 616, + + 616, 616, 616, 616, 710, 616, 616, 616, 616, 710, + 616, 616, 710, 710, 710, 710, 710, 616, 616, 616, + 616, 710, 710, 710, 710, 710, 710, 618, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 616, 616, 616, 710, 710, 710, 710, 710, + 710, 618, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 616, 616, 616, 616, + 710, 616, 616, 616, 616, 616, 617, 616, 616, 616, + 616, 710, 616, 616, 710, 710, 710, 710, 710, 625, + 616, 616, 616, 710, 710, 710, 710, 710, 710, 626, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 616, 616, 616, 710, 710, 710, + 710, 710, 710, 626, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 616, 616, + 616, 616, 710, 616, 616, 616, 616, 616, 710, 616, + 616, 616, 616, 710, 616, 616, 710, 710, 710, 710, + 710, 616, 616, 616, 616, 710, 710, 710, 710, 710, + 710, 618, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 616, 616, 616, 710, + 710, 710, 710, 710, 710, 618, 710, 710, 710, 710, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 616, 616, 616, 616, 710, 616, 616, 616, 616, 616, + 617, 616, 616, 616, 616, 710, 616, 616, 710, 710, + 710, 710, 710, 625, 616, 616, 616, 710, 710, 710, + 710, 710, 710, 626, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 616, 616, + 616, 710, 710, 710, 710, 710, 710, 626, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 616, 616, 70, 710, 710, 70, 70, 710, + 710, 70, 70, 70, 70, 70, 71, 71, 71, 71, + + 71, 710, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, + 116, 133, 133, 133, 133, 133, 133, 133, 133, 133, + 133, 133, 133, 133, 133, 133, 138, 710, 710, 138, + 138, 138, 710, 138, 138, 138, 138, 138, 183, 183, + 183, 183, 183, 710, 183, 183, 183, 183, 183, 183, + 183, 183, 183, 185, 185, 185, 185, 185, 185, 185, + 185, 185, 185, 185, 185, 185, 185, 185, 200, 200, + + 710, 710, 710, 710, 710, 710, 710, 200, 200, 200, + 200, 200, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 234, 234, 234, + 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, + 234, 234, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 270, 270, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 270, 270, 270, 270, 185, 185, 185, + 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, + + 185, 185, 186, 186, 186, 186, 186, 186, 186, 186, + 186, 186, 186, 186, 186, 186, 186, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 317, 317, 710, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 319, 319, 710, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 357, 357, 710, 357, 357, 357, 357, 357, + 357, 357, 357, 357, 357, 357, 357, 359, 359, 359, + 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, + 359, 359, 113, 113, 113, 113, 113, 113, 113, 113, + + 113, 113, 113, 113, 113, 113, 113, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 234, 234, 234, 234, 234, 234, 234, 234, + 234, 234, 234, 234, 234, 234, 234, 369, 710, 710, + 369, 710, 369, 369, 710, 710, 369, 369, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 391, 391, 391, 391, 391, 391, 391, + 391, 391, 391, 391, 391, 391, 391, 391, 270, 270, + 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 90, 90, 90, 90, 90, 90, 90, + + 90, 90, 90, 90, 90, 90, 90, 90, 411, 411, + 710, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 425, 425, + 425, 425, 710, 425, 425, 425, 425, 425, 425, 425, + 425, 425, 425, 183, 183, 183, 183, 183, 183, 183, + 183, 183, 183, 183, 183, 183, 183, 183, 317, 317, + 710, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 319, 319, 710, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 439, 710, + + 439, 710, 710, 710, 439, 439, 439, 450, 450, 710, + 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, + 450, 450, 356, 356, 710, 356, 356, 356, 356, 356, + 356, 356, 356, 356, 356, 356, 356, 357, 357, 710, + 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, + 357, 357, 359, 359, 359, 359, 359, 359, 359, 359, + 359, 359, 359, 359, 359, 359, 359, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 458, 458, 458, + + 458, 458, 458, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 464, 710, 710, 710, 710, 464, 464, 710, + 710, 464, 464, 391, 391, 391, 391, 391, 391, 391, + 391, 391, 391, 391, 391, 391, 391, 391, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 487, 487, 710, 487, 487, 487, 487, + 487, 487, 487, 487, 487, 487, 487, 487, 411, 411, + 710, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 425, 425, 425, 425, 710, 425, 425, + 425, 425, 425, 425, 425, 425, 425, 425, 183, 183, + + 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, + 183, 183, 183, 500, 500, 710, 500, 500, 500, 500, + 500, 500, 500, 500, 500, 500, 500, 500, 502, 502, + 710, 502, 502, 502, 502, 502, 502, 502, 502, 502, + 502, 502, 502, 504, 504, 710, 504, 504, 504, 504, + 504, 504, 504, 504, 504, 504, 504, 504, 506, 506, + 710, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 508, 508, 710, 508, 508, 508, 508, + 508, 508, 508, 508, 508, 508, 508, 508, 510, 510, + 710, 510, 510, 510, 510, 510, 510, 510, 510, 510, + + 510, 510, 510, 449, 449, 710, 449, 449, 449, 449, + 449, 449, 449, 449, 449, 449, 449, 449, 450, 450, + 710, 450, 450, 450, 450, 450, 450, 450, 450, 450, + 450, 450, 450, 359, 359, 359, 359, 359, 359, 359, + 359, 359, 359, 359, 359, 359, 359, 359, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 458, 458, 458, 458, 458, 458, 458, + 458, 458, 458, 458, 458, 458, 458, 458, 535, 710, + 710, 710, 710, 535, 535, 710, 710, 535, 543, 543, + 543, 543, 543, 543, 543, 543, 543, 543, 543, 543, + + 543, 543, 543, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 487, 487, + 710, 487, 487, 487, 487, 487, 487, 487, 487, 487, + 487, 487, 487, 554, 554, 554, 554, 554, 554, 554, + 554, 554, 554, 554, 554, 554, 554, 554, 566, 710, + 710, 710, 710, 566, 566, 710, 710, 566, 568, 568, + 710, 568, 568, 568, 568, 568, 568, 568, 568, 568, + 568, 568, 568, 586, 586, 586, 586, 586, 586, 586, + 586, 586, 586, 586, 586, 586, 586, 586, 617, 617, + 710, 617, 617, 617, 617, 617, 617, 617, 617, 617, + + 617, 617, 617, 624, 624, 710, 624, 624, 624, 624, + 624, 624, 624, 624, 624, 624, 624, 624, 616, 616, + 710, 616, 616, 616, 616, 616, 616, 616, 616, 616, + 616, 616, 616, 652, 652, 652, 652, 652, 652, 652, + 652, 652, 652, 652, 652, 652, 652, 652, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 677, 677, 677, 677, 677, 677, 677, + 677, 677, 677, 677, 677, 677, 677, 677, 692, 692, + 692, 692, 692, 692, 692, 692, 692, 692, 692, 692, + 692, 692, 692, 3, 710, 710, 710, 710, 710, 710, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710 + } ; + +static yyconst short int yy_chk[4467] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 5, 6, 6, 6, 6, 6, + 8, 10, 10, 11, 18, 23, 708, 8, 8, 8, + 8, 8, 19, 11, 34, 11, 11, 34, 5, 34, + 36, 11, 12, 12, 12, 36, 233, 31, 18, 12, + 23, 31, 40, 19, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 22, 25, 40, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 37, 19, 233, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 13, 27, 33, 25, 33, 264, 33, 24, 22, + 25, 13, 46, 13, 264, 32, 32, 24, 32, 13, + 15, 43, 44, 44, 51, 46, 37, 72, 72, 32, + 15, 43, 15, 43, 15, 15, 15, 51, 15, 43, + 35, 15, 24, 24, 24, 24, 24, 24, 24, 24, + 47, 74, 688, 35, 60, 27, 27, 35, 60, 35, + + 46, 27, 15, 47, 35, 51, 15, 15, 15, 15, + 15, 15, 15, 15, 49, 52, 15, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 38, 55, 49, 78, 78, 28, 28, + 28, 28, 50, 82, 82, 82, 47, 38, 38, 38, + 38, 38, 74, 65, 48, 50, 41, 57, 65, 56, + 583, 41, 57, 28, 28, 28, 41, 48, 41, 41, + 49, 52, 56, 53, 41, 57, 684, 62, 53, 62, + 86, 62, 86, 48, 55, 115, 53, 28, 28, 29, + 55, 138, 133, 29, 29, 29, 50, 29, 61, 61, + + 66, 61, 38, 53, 138, 66, 77, 48, 77, 145, + 57, 57, 61, 66, 77, 63, 57, 56, 63, 115, + 63, 29, 145, 64, 583, 29, 29, 29, 29, 29, + 29, 29, 29, 30, 147, 147, 64, 30, 30, 30, + 64, 30, 64, 83, 83, 83, 206, 64, 69, 69, + 69, 69, 69, 683, 66, 83, 206, 83, 85, 85, + 85, 133, 677, 83, 206, 30, 98, 98, 98, 30, + 30, 30, 30, 30, 30, 30, 30, 42, 42, 42, + 108, 108, 108, 676, 42, 122, 122, 122, 674, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 129, 129, + + 129, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 151, 151, 151, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 45, 183, 183, 142, + 546, 45, 184, 184, 67, 327, 45, 327, 45, 672, + 45, 45, 45, 142, 45, 67, 73, 45, 67, 67, + 67, 67, 67, 73, 73, 73, 73, 73, 73, 93, + 93, 93, 93, 93, 93, 93, 93, 146, 45, 109, + 109, 109, 45, 45, 45, 45, 45, 45, 45, 45, + + 146, 141, 45, 54, 92, 546, 92, 213, 87, 141, + 54, 159, 92, 331, 141, 213, 54, 92, 87, 54, + 87, 185, 185, 67, 159, 140, 87, 331, 92, 155, + 92, 187, 187, 140, 140, 670, 92, 109, 140, 213, + 92, 159, 155, 248, 54, 54, 54, 54, 54, 54, + 54, 54, 58, 606, 130, 130, 130, 58, 177, 177, + 177, 58, 58, 58, 155, 58, 94, 94, 94, 94, + 94, 94, 94, 94, 96, 96, 96, 96, 96, 96, + 96, 96, 162, 162, 162, 211, 211, 211, 247, 58, + 130, 152, 248, 58, 58, 58, 58, 58, 58, 58, + + 58, 59, 231, 370, 152, 59, 59, 59, 606, 59, + 97, 97, 97, 97, 97, 97, 97, 97, 118, 118, + 118, 118, 118, 118, 118, 118, 212, 212, 212, 374, + 162, 247, 152, 59, 153, 154, 231, 59, 59, 59, + 59, 59, 59, 59, 59, 95, 359, 153, 154, 215, + 215, 215, 370, 95, 120, 120, 120, 120, 120, 120, + 120, 120, 121, 121, 121, 121, 121, 121, 121, 121, + 216, 216, 216, 217, 217, 217, 154, 95, 374, 153, + 359, 95, 95, 95, 95, 95, 95, 95, 95, 114, + 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + + 114, 114, 114, 114, 114, 664, 222, 235, 235, 235, + 114, 114, 114, 114, 124, 124, 124, 124, 124, 124, + 124, 124, 126, 126, 126, 126, 126, 126, 126, 126, + 222, 690, 135, 270, 270, 114, 114, 114, 127, 127, + 127, 127, 127, 127, 127, 127, 135, 135, 135, 135, + 135, 135, 312, 312, 222, 241, 241, 241, 663, 114, + 114, 116, 116, 116, 116, 116, 143, 116, 116, 116, + 116, 116, 116, 148, 143, 116, 116, 144, 157, 143, + 156, 160, 116, 116, 158, 116, 148, 144, 347, 144, + 165, 157, 164, 156, 160, 144, 395, 158, 181, 163, + + 690, 135, 274, 165, 662, 164, 348, 116, 116, 181, + 274, 160, 163, 161, 148, 148, 148, 148, 148, 148, + 148, 148, 161, 161, 161, 598, 161, 249, 249, 249, + 348, 116, 116, 119, 274, 157, 179, 119, 180, 156, + 163, 164, 158, 165, 170, 119, 347, 119, 598, 179, + 119, 180, 337, 170, 170, 170, 395, 170, 119, 223, + 337, 119, 360, 267, 119, 119, 465, 181, 267, 119, + 268, 223, 223, 119, 119, 119, 119, 119, 119, 119, + 119, 267, 119, 268, 337, 119, 242, 658, 119, 123, + 179, 178, 180, 242, 242, 242, 360, 123, 123, 123, + + 178, 178, 178, 123, 178, 394, 123, 262, 150, 252, + 252, 252, 262, 262, 123, 465, 168, 123, 280, 325, + 123, 123, 166, 166, 166, 166, 166, 166, 166, 166, + 123, 280, 479, 123, 313, 313, 178, 655, 123, 188, + 188, 123, 582, 582, 123, 125, 188, 188, 188, 188, + 188, 188, 394, 125, 150, 150, 150, 150, 150, 150, + 150, 150, 168, 168, 168, 168, 168, 168, 168, 168, + 232, 232, 232, 232, 255, 255, 255, 125, 280, 288, + 325, 125, 125, 125, 125, 125, 125, 125, 125, 128, + 479, 654, 288, 128, 128, 128, 174, 128, 169, 169, + + 169, 169, 169, 169, 169, 169, 172, 172, 172, 172, + 172, 172, 172, 172, 258, 253, 232, 258, 258, 258, + 649, 128, 253, 253, 253, 128, 128, 128, 128, 128, + 128, 128, 128, 149, 272, 361, 648, 288, 299, 299, + 299, 149, 174, 174, 174, 174, 174, 174, 174, 174, + 175, 175, 175, 175, 175, 175, 175, 175, 304, 304, + 304, 269, 349, 258, 369, 149, 269, 373, 647, 149, + 149, 149, 149, 149, 149, 149, 149, 167, 361, 269, + 266, 167, 443, 283, 278, 266, 349, 272, 392, 167, + 392, 167, 257, 266, 167, 272, 283, 278, 284, 257, + + 257, 257, 167, 284, 623, 167, 443, 369, 167, 167, + 373, 284, 286, 167, 338, 338, 338, 167, 167, 167, + 167, 167, 167, 167, 167, 286, 167, 278, 283, 167, + 189, 189, 167, 171, 171, 257, 279, 189, 189, 189, + 189, 189, 171, 171, 171, 273, 171, 298, 171, 279, + 293, 171, 293, 298, 273, 273, 273, 480, 273, 171, + 298, 286, 171, 293, 623, 171, 171, 214, 214, 214, + 214, 214, 214, 214, 214, 171, 281, 236, 171, 279, + 297, 281, 297, 171, 434, 236, 171, 497, 236, 171, + 173, 236, 236, 297, 281, 497, 434, 243, 173, 329, + + 281, 236, 298, 396, 622, 243, 243, 243, 276, 236, + 636, 243, 236, 446, 646, 236, 396, 276, 276, 276, + 480, 276, 173, 282, 281, 297, 173, 173, 173, 173, + 173, 173, 173, 173, 176, 455, 282, 446, 176, 176, + 176, 243, 176, 237, 237, 237, 237, 237, 237, 237, + 237, 238, 238, 238, 238, 238, 238, 238, 238, 622, + 329, 344, 344, 344, 643, 368, 176, 636, 282, 455, + 176, 176, 176, 176, 176, 176, 176, 176, 218, 368, + 282, 282, 365, 365, 365, 642, 218, 250, 250, 250, + 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, + + 251, 251, 251, 378, 378, 378, 439, 439, 439, 368, + 218, 362, 362, 362, 218, 218, 218, 218, 218, 218, + 218, 218, 230, 230, 239, 230, 230, 230, 230, 230, + 516, 230, 230, 230, 230, 308, 230, 230, 464, 245, + 308, 239, 516, 230, 230, 230, 230, 245, 308, 239, + 245, 294, 239, 245, 245, 239, 239, 362, 246, 393, + 294, 294, 294, 245, 294, 239, 460, 393, 230, 230, + 230, 245, 393, 239, 245, 246, 239, 245, 397, 239, + 460, 464, 640, 246, 639, 275, 246, 230, 635, 246, + 246, 397, 230, 230, 234, 234, 234, 234, 234, 246, + + 234, 234, 234, 234, 234, 234, 309, 246, 234, 234, + 246, 254, 261, 246, 634, 234, 234, 309, 234, 254, + 254, 254, 478, 478, 478, 254, 261, 261, 261, 261, + 261, 275, 275, 275, 275, 275, 275, 275, 275, 287, + 234, 234, 300, 300, 300, 300, 300, 300, 300, 300, + 330, 593, 287, 471, 330, 254, 633, 545, 291, 295, + 632, 295, 330, 401, 234, 234, 244, 471, 295, 295, + 295, 291, 295, 380, 387, 309, 401, 530, 651, 651, + 244, 261, 406, 244, 387, 292, 387, 380, 630, 530, + 287, 244, 387, 301, 244, 406, 407, 244, 244, 291, + + 291, 291, 291, 291, 291, 291, 291, 244, 545, 407, + 244, 330, 593, 401, 302, 244, 417, 380, 244, 605, + 665, 244, 256, 302, 302, 302, 407, 302, 629, 417, + 256, 292, 292, 292, 292, 292, 292, 292, 292, 301, + 301, 301, 301, 301, 301, 301, 301, 383, 426, 426, + 383, 383, 383, 426, 256, 409, 621, 495, 256, 256, + 256, 256, 256, 256, 256, 256, 277, 303, 409, 303, + 495, 605, 665, 402, 277, 388, 303, 303, 303, 482, + 303, 306, 410, 306, 482, 388, 402, 388, 620, 614, + 306, 306, 306, 388, 306, 410, 383, 482, 277, 494, + + 409, 494, 277, 277, 277, 277, 277, 277, 277, 277, + 289, 289, 494, 289, 289, 289, 289, 289, 289, 289, + 289, 289, 289, 402, 289, 289, 306, 410, 650, 307, + 423, 289, 289, 289, 289, 307, 316, 316, 307, 307, + 307, 423, 307, 316, 316, 316, 316, 316, 342, 342, + 342, 342, 342, 342, 342, 342, 289, 289, 289, 343, + 343, 343, 343, 343, 343, 343, 343, 398, 398, 398, + 398, 398, 398, 398, 398, 289, 472, 612, 371, 650, + 289, 289, 290, 290, 307, 403, 371, 518, 472, 371, + 403, 484, 371, 371, 550, 290, 484, 290, 611, 423, + + 290, 518, 371, 403, 404, 372, 685, 550, 290, 484, + 371, 290, 382, 371, 290, 290, 371, 404, 496, 382, + 382, 382, 372, 610, 290, 604, 603, 290, 404, 496, + 372, 400, 290, 372, 408, 290, 372, 372, 290, 296, + 400, 400, 400, 403, 400, 472, 372, 408, 415, 491, + 415, 550, 404, 296, 372, 382, 296, 372, 399, 385, + 372, 415, 491, 685, 296, 422, 416, 296, 602, 486, + 296, 296, 416, 385, 385, 385, 385, 385, 422, 416, + 296, 408, 486, 296, 456, 456, 456, 496, 296, 483, + 474, 296, 474, 415, 296, 305, 600, 637, 474, 485, + + 599, 491, 483, 305, 399, 399, 399, 399, 399, 399, + 399, 399, 485, 420, 486, 420, 547, 483, 547, 422, + 485, 416, 420, 420, 420, 444, 420, 305, 385, 547, + 456, 305, 305, 305, 305, 305, 305, 305, 305, 350, + 350, 483, 350, 350, 350, 350, 350, 492, 350, 350, + 350, 350, 492, 350, 350, 615, 637, 444, 420, 549, + 350, 350, 350, 350, 421, 492, 444, 459, 459, 459, + 421, 490, 549, 421, 421, 421, 597, 421, 588, 615, + 444, 533, 533, 533, 490, 350, 350, 350, 499, 499, + 548, 588, 350, 549, 596, 499, 499, 499, 499, 499, + + 544, 544, 544, 548, 350, 350, 596, 595, 691, 350, + 350, 357, 357, 459, 357, 357, 357, 357, 357, 421, + 357, 357, 357, 357, 490, 357, 357, 533, 461, 689, + 519, 548, 357, 357, 357, 357, 461, 553, 519, 461, + 584, 519, 461, 461, 519, 519, 594, 592, 627, 591, + 553, 552, 461, 584, 519, 539, 555, 357, 357, 357, + 461, 627, 519, 461, 552, 519, 461, 555, 519, 539, + 539, 539, 539, 539, 584, 586, 616, 691, 553, 618, + 689, 357, 357, 358, 358, 462, 358, 358, 358, 358, + 358, 626, 358, 358, 358, 358, 552, 358, 358, 585, + + 616, 587, 462, 618, 358, 358, 358, 358, 552, 657, + 462, 520, 585, 462, 587, 626, 462, 462, 679, 692, + 581, 657, 590, 580, 539, 555, 462, 578, 520, 358, + 358, 358, 579, 590, 462, 631, 520, 462, 576, 520, + 462, 631, 520, 520, 589, 587, 579, 579, 579, 579, + 579, 609, 520, 358, 358, 367, 585, 589, 608, 631, + 520, 625, 609, 520, 638, 631, 520, 558, 558, 367, + 575, 608, 367, 679, 558, 558, 558, 558, 558, 628, + 367, 641, 659, 367, 659, 645, 367, 367, 692, 625, + 628, 590, 641, 638, 644, 656, 367, 660, 652, 644, + + 653, 579, 589, 608, 367, 680, 656, 367, 659, 645, + 367, 381, 666, 625, 645, 669, 574, 638, 644, 660, + 609, 660, 573, 653, 572, 381, 669, 652, 381, 653, + 673, 571, 680, 682, 680, 707, 381, 570, 569, 381, + 667, 666, 381, 381, 682, 568, 666, 653, 628, 566, + 641, 652, 381, 653, 673, 381, 681, 686, 680, 565, + 381, 563, 562, 381, 656, 666, 381, 405, 405, 667, + 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, + 561, 405, 405, 687, 669, 681, 686, 560, 405, 405, + 405, 405, 559, 667, 687, 693, 557, 694, 667, 554, + + 695, 696, 682, 551, 707, 697, 693, 681, 694, 681, + 686, 695, 696, 405, 405, 405, 697, 543, 542, 698, + 405, 541, 540, 699, 700, 701, 538, 535, 531, 529, + 698, 528, 405, 405, 699, 700, 701, 405, 405, 411, + 411, 527, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 687, 411, 411, 526, 525, 524, 523, 522, + 411, 411, 411, 411, 693, 521, 694, 702, 703, 695, + 696, 704, 705, 706, 697, 517, 515, 514, 702, 703, + 513, 512, 704, 705, 706, 411, 411, 411, 698, 511, + 510, 509, 699, 700, 701, 508, 507, 506, 505, 504, + + 503, 502, 501, 500, 493, 488, 477, 476, 475, 411, + 411, 413, 413, 473, 413, 413, 413, 413, 413, 413, + 413, 413, 413, 413, 470, 413, 413, 468, 467, 463, + 458, 454, 413, 413, 413, 413, 702, 703, 453, 452, + 704, 705, 706, 448, 447, 445, 442, 438, 437, 436, + 435, 433, 432, 431, 430, 429, 428, 413, 413, 413, + 427, 425, 424, 412, 391, 390, 389, 386, 384, 376, + 375, 364, 363, 355, 354, 353, 352, 346, 345, 335, + 334, 413, 413, 414, 414, 333, 332, 328, 326, 324, + 323, 322, 321, 320, 319, 318, 414, 317, 414, 314, + + 310, 414, 271, 265, 263, 259, 240, 229, 228, 414, + 227, 225, 414, 224, 221, 414, 414, 220, 219, 210, + 209, 208, 207, 205, 204, 414, 203, 202, 201, 198, + 197, 196, 195, 414, 194, 193, 414, 191, 190, 414, + 419, 186, 182, 139, 137, 136, 134, 132, 131, 113, + 112, 111, 110, 107, 419, 106, 105, 419, 104, 103, + 102, 101, 100, 99, 90, 419, 88, 84, 419, 81, + 80, 419, 419, 79, 76, 71, 68, 39, 26, 21, + 20, 419, 17, 16, 419, 14, 9, 3, 0, 419, + 0, 0, 419, 0, 0, 419, 441, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 441, 0, 0, 441, 0, 0, 0, 0, 0, 0, + 0, 441, 0, 0, 441, 0, 0, 441, 441, 0, + 0, 0, 0, 0, 0, 0, 0, 441, 0, 0, + 0, 0, 0, 0, 0, 441, 0, 0, 441, 0, + 0, 441, 450, 450, 0, 450, 450, 450, 450, 450, + 0, 450, 450, 450, 450, 0, 450, 450, 0, 0, + 0, 0, 0, 450, 450, 450, 450, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 450, 450, + + 450, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 450, 450, 451, 451, 0, 451, 451, 451, + 451, 451, 0, 451, 451, 451, 451, 0, 451, 451, + 0, 0, 0, 0, 0, 451, 451, 451, 451, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 451, 451, 451, 0, 0, 0, 0, 451, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 451, + 451, 0, 0, 0, 451, 451, 481, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 481, 0, 0, 481, 0, 0, 0, 0, 0, 0, + 0, 481, 0, 0, 481, 0, 0, 481, 481, 0, + 0, 0, 0, 0, 0, 0, 0, 481, 0, 0, + 0, 0, 0, 0, 0, 481, 0, 0, 481, 0, + 0, 481, 487, 487, 0, 487, 487, 487, 487, 487, + 487, 487, 487, 487, 487, 0, 487, 487, 0, 0, + 0, 0, 0, 487, 487, 487, 487, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 487, 487, + + 487, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 487, 487, 489, 489, 0, 489, 489, 489, + 489, 489, 489, 489, 489, 489, 489, 0, 489, 489, + 0, 0, 0, 0, 0, 489, 489, 489, 489, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 489, 489, 489, 0, 0, 0, 0, 489, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 489, + 489, 0, 0, 0, 489, 489, 601, 601, 0, 601, + + 601, 601, 601, 601, 0, 601, 601, 601, 601, 0, + 601, 601, 0, 0, 0, 0, 0, 601, 601, 601, + 601, 0, 0, 0, 0, 0, 0, 601, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 601, 601, 601, 0, 0, 0, 0, 0, + 0, 601, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 601, 601, 607, 607, + 0, 607, 607, 607, 607, 607, 607, 607, 607, 607, + 607, 0, 607, 607, 0, 0, 0, 0, 0, 607, + 607, 607, 607, 0, 0, 0, 0, 0, 0, 607, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 607, 607, 607, 0, 0, 0, + 0, 0, 0, 607, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 607, 607, + 617, 617, 0, 617, 617, 617, 617, 617, 0, 617, + 617, 617, 617, 0, 617, 617, 0, 0, 0, 0, + 0, 617, 617, 617, 617, 0, 0, 0, 0, 0, + 0, 617, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 617, 617, 617, 0, + 0, 0, 0, 0, 0, 617, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 617, 617, 624, 624, 0, 624, 624, 624, 624, 624, + 624, 624, 624, 624, 624, 0, 624, 624, 0, 0, + 0, 0, 0, 624, 624, 624, 624, 0, 0, 0, + 0, 0, 0, 624, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 624, 624, + 624, 0, 0, 0, 0, 0, 0, 624, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 624, 624, 711, 0, 0, 711, 711, 0, + 0, 711, 711, 711, 711, 711, 712, 712, 712, 712, + + 712, 0, 712, 712, 712, 712, 712, 712, 712, 712, + 712, 713, 713, 713, 713, 713, 713, 713, 713, 713, + 713, 713, 713, 713, 713, 713, 714, 714, 714, 714, + 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, + 714, 715, 715, 715, 715, 715, 715, 715, 715, 715, + 715, 715, 715, 715, 715, 715, 716, 0, 0, 716, + 716, 716, 0, 716, 716, 716, 716, 716, 717, 717, + 717, 717, 717, 0, 717, 717, 717, 717, 717, 717, + 717, 717, 717, 718, 718, 718, 718, 718, 718, 718, + 718, 718, 718, 718, 718, 718, 718, 718, 719, 719, + + 0, 0, 0, 0, 0, 0, 0, 719, 719, 719, + 719, 719, 720, 720, 720, 720, 720, 720, 720, 720, + 720, 720, 720, 720, 720, 720, 720, 721, 721, 721, + 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + 721, 721, 722, 722, 722, 722, 722, 722, 722, 722, + 722, 722, 722, 722, 722, 722, 722, 723, 723, 723, + 723, 723, 723, 723, 723, 723, 723, 723, 723, 723, + 723, 723, 724, 724, 724, 724, 724, 724, 724, 724, + 724, 724, 724, 724, 724, 724, 724, 725, 725, 725, + 725, 725, 725, 725, 725, 725, 725, 725, 725, 725, + + 725, 725, 726, 726, 726, 726, 726, 726, 726, 726, + 726, 726, 726, 726, 726, 726, 726, 727, 727, 727, + 727, 727, 727, 727, 727, 727, 727, 727, 727, 727, + 727, 727, 728, 728, 0, 728, 728, 728, 728, 728, + 728, 728, 728, 728, 728, 728, 728, 729, 729, 0, + 729, 729, 729, 729, 729, 729, 729, 729, 729, 729, + 729, 729, 730, 730, 0, 730, 730, 730, 730, 730, + 730, 730, 730, 730, 730, 730, 730, 731, 731, 731, + 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, + 731, 731, 732, 732, 732, 732, 732, 732, 732, 732, + + 732, 732, 732, 732, 732, 732, 732, 733, 733, 733, + 733, 733, 733, 733, 733, 733, 733, 733, 733, 733, + 733, 733, 734, 734, 734, 734, 734, 734, 734, 734, + 734, 734, 734, 734, 734, 734, 734, 735, 0, 0, + 735, 0, 735, 735, 0, 0, 735, 735, 736, 736, + 736, 736, 736, 736, 736, 736, 736, 736, 736, 736, + 736, 736, 736, 737, 737, 737, 737, 737, 737, 737, + 737, 737, 737, 737, 737, 737, 737, 737, 738, 738, + 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, + 738, 738, 738, 739, 739, 739, 739, 739, 739, 739, + + 739, 739, 739, 739, 739, 739, 739, 739, 740, 740, + 0, 740, 740, 740, 740, 740, 740, 740, 740, 740, + 740, 740, 740, 741, 741, 741, 741, 741, 741, 741, + 741, 741, 741, 741, 741, 741, 741, 741, 742, 742, + 742, 742, 0, 742, 742, 742, 742, 742, 742, 742, + 742, 742, 742, 743, 743, 743, 743, 743, 743, 743, + 743, 743, 743, 743, 743, 743, 743, 743, 744, 744, + 0, 744, 744, 744, 744, 744, 744, 744, 744, 744, + 744, 744, 744, 745, 745, 0, 745, 745, 745, 745, + 745, 745, 745, 745, 745, 745, 745, 745, 746, 0, + + 746, 0, 0, 0, 746, 746, 746, 747, 747, 0, + 747, 747, 747, 747, 747, 747, 747, 747, 747, 747, + 747, 747, 748, 748, 0, 748, 748, 748, 748, 748, + 748, 748, 748, 748, 748, 748, 748, 749, 749, 0, + 749, 749, 749, 749, 749, 749, 749, 749, 749, 749, + 749, 749, 750, 750, 750, 750, 750, 750, 750, 750, + 750, 750, 750, 750, 750, 750, 750, 751, 751, 751, + 751, 751, 751, 751, 751, 751, 751, 751, 751, 751, + 751, 751, 752, 752, 752, 752, 752, 752, 752, 752, + 752, 752, 752, 752, 752, 752, 752, 753, 753, 753, + + 753, 753, 753, 753, 753, 753, 753, 753, 753, 753, + 753, 753, 754, 0, 0, 0, 0, 754, 754, 0, + 0, 754, 754, 755, 755, 755, 755, 755, 755, 755, + 755, 755, 755, 755, 755, 755, 755, 755, 756, 756, + 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + 756, 756, 756, 757, 757, 0, 757, 757, 757, 757, + 757, 757, 757, 757, 757, 757, 757, 757, 758, 758, + 0, 758, 758, 758, 758, 758, 758, 758, 758, 758, + 758, 758, 758, 759, 759, 759, 759, 0, 759, 759, + 759, 759, 759, 759, 759, 759, 759, 759, 760, 760, + + 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, + 760, 760, 760, 761, 761, 0, 761, 761, 761, 761, + 761, 761, 761, 761, 761, 761, 761, 761, 762, 762, + 0, 762, 762, 762, 762, 762, 762, 762, 762, 762, + 762, 762, 762, 763, 763, 0, 763, 763, 763, 763, + 763, 763, 763, 763, 763, 763, 763, 763, 764, 764, + 0, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 765, 765, 0, 765, 765, 765, 765, + 765, 765, 765, 765, 765, 765, 765, 765, 766, 766, + 0, 766, 766, 766, 766, 766, 766, 766, 766, 766, + + 766, 766, 766, 767, 767, 0, 767, 767, 767, 767, + 767, 767, 767, 767, 767, 767, 767, 767, 768, 768, + 0, 768, 768, 768, 768, 768, 768, 768, 768, 768, + 768, 768, 768, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 770, 770, + 770, 770, 770, 770, 770, 770, 770, 770, 770, 770, + 770, 770, 770, 771, 771, 771, 771, 771, 771, 771, + 771, 771, 771, 771, 771, 771, 771, 771, 772, 0, + 0, 0, 0, 772, 772, 0, 0, 772, 773, 773, + 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, + + 773, 773, 773, 774, 774, 774, 774, 774, 774, 774, + 774, 774, 774, 774, 774, 774, 774, 774, 775, 775, + 0, 775, 775, 775, 775, 775, 775, 775, 775, 775, + 775, 775, 775, 776, 776, 776, 776, 776, 776, 776, + 776, 776, 776, 776, 776, 776, 776, 776, 777, 0, + 0, 0, 0, 777, 777, 0, 0, 777, 778, 778, + 0, 778, 778, 778, 778, 778, 778, 778, 778, 778, + 778, 778, 778, 779, 779, 779, 779, 779, 779, 779, + 779, 779, 779, 779, 779, 779, 779, 779, 780, 780, + 0, 780, 780, 780, 780, 780, 780, 780, 780, 780, + + 780, 780, 780, 781, 781, 0, 781, 781, 781, 781, + 781, 781, 781, 781, 781, 781, 781, 781, 782, 782, + 0, 782, 782, 782, 782, 782, 782, 782, 782, 782, + 782, 782, 782, 783, 783, 783, 783, 783, 783, 783, + 783, 783, 783, 783, 783, 783, 783, 783, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 785, 785, 785, 785, 785, 785, 785, + 785, 785, 785, 785, 785, 785, 785, 785, 786, 786, + 786, 786, 786, 786, 786, 786, 786, 786, 786, 786, + 786, 786, 786, 710, 710, 710, 710, 710, 710, 710, + + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, + 710, 710, 710, 710, 710, 710 + } ; + +static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; +static char *yy_full_match; +static int yy_lp; +static int yy_looking_for_trail_begin = 0; +static int yy_full_lp; +static int *yy_full_state; +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +#define REJECT \ +{ \ +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yy_full_match; /* restore poss. backed-over text */ \ +yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \ +yy_state_ptr = yy_full_state; /* restore orig. state */ \ +yy_current_state = *yy_state_ptr; /* restore curr. state */ \ +++yy_lp; \ +goto find_rule; \ +} +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "../parser.l" +#define INITIAL 0 +#line 8 "../parser.l" +/* + * parser.l -- lex parser of algebraic chess moves for XBoard + * $Id: parser.l,v 2.1 2003/10/27 19:21:00 mann Exp $ + * + * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. + * Enhancements Copyright 1992-95 Free Software Foundation, Inc. + * + * The following terms apply to Digital Equipment Corporation's copyright + * interest in XBoard: + * ------------------------------------------------------------------------ + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Digital not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * ------------------------------------------------------------------------ + * + * The following terms apply to the enhanced version of XBoard distributed + * by the Free Software Foundation: + * ------------------------------------------------------------------------ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ------------------------------------------------------------------------ + */ + +/* This parser handles all forms of promotion. + * The parser resolves ambiguous moves by searching and check-testing. + * It also parses comments of the form [anything] or (anything). + */ + +#include "config.h" + +#define NO_CONSTRAINT -1 +#undef YYLMAX +#define YYLMAX 4096 +#define UNPUT_BUF_SIZE YYLMAX + +#ifdef FLEX_SCANNER +/* yytext is probably a char*, but could be a char[]. yy_text is set + in YY_DECL below, because if yytext is a char*, its value is not + constant. */ +char *yy_text; +#else /*!FLEX_SCANNER*/ +/* yytext is definitely a char[], so yy_text can be set here, statically. */ +char *yy_text = (char *) yytext; +#endif + +#ifdef FLEX_SCANNER +/* This is flex */ +#undef YY_INPUT +#define YY_INPUT(buf, result, max_size) my_yy_input(buf, &result, max_size) +#undef YY_DECL +#define YY_DECL \ + int _yylex YY_PROTO((void)); \ + int yylex YY_PROTO((void)) \ + { \ + int result = _yylex(); \ + yy_text = (char *) yytext; \ + return(result); \ + } \ + int _yylex YY_PROTO((void)) +#else +/* This is lex */ +#undef input +#undef output +#undef unput +#endif + +/* The includes must be here, below the #undef input */ + +#include + +#if STDC_HEADERS +# include +# include +#else /* not STDC_HEADERS */ +# if HAVE_STRING_H +# include +# else /* not HAVE_STRING_H */ +# include +# endif /* not HAVE_STRING_H */ +#endif /* not STDC_HEADERS */ + +#if HAVE_UNISTD_H +# include +#endif + +#if defined(_amigados) +# include +# if HAVE_FCNTL_H +# include /* isatty() prototype */ +# endif /* HAVE_FCNTL_H */ +#endif /* defined(_amigados) */ + +#include "common.h" +#include "backend.h" +#include "frontend.h" +#include "parser.h" +#include "moves.h" + +extern int PosFlags P((int)); + +extern Board boards[MAX_MOVES]; +int yyboardindex; +int yyskipmoves = FALSE; +char currentMoveString[YYLMAX]; +#ifndef FLEX_SCANNER +char unputBuffer[UNPUT_BUF_SIZE]; +int unputCount = 0; +#endif + +#ifdef FLEX_SCANNER +void my_yy_input P((char *buf, int *result, int max_size)); +#else /*!FLEX_SCANNER*/ +static int input P((void)); +static void output P((int ch)); +static void unput P((int ch)); +int yylook P((void)); +int yyback P((int *, int)); +#endif +#undef yywrap +int yywrap P((void)); +extern void CopyBoard P((Board to, Board from)); + +#line 1835 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + yy_current_buffer->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 156 "../parser.l" + + +#line 1992 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 711 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 4394 ); + +yy_find_action: + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yy_lp]; + if ( yy_act & YY_TRAILING_HEAD_MASK || + yy_looking_for_trail_begin ) + { + if ( yy_act == yy_looking_for_trail_begin ) + { + yy_looking_for_trail_begin = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } + else if ( yy_act & YY_TRAILING_MASK ) + { + yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; + } + else + { + yy_full_match = yy_cp; + yy_full_state = yy_state_ptr; + yy_full_lp = yy_lp; + break; + } + ++yy_lp; + goto find_rule; + } + --yy_cp; + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +YY_RULE_SETUP +#line 158 "../parser.l" +{ + /* + * Fully-qualified algebraic move, possibly with promotion + */ + int skip1 = 0, skip2 = 0; + ChessSquare piece; + ChessMove result; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove the / */ + if (yytext[1] == '/') skip1 = 1; + + /* remove the [xX:-] */ + if ((yytext[3+skip1] == 'x') || (yytext[3+skip1] == 'X') || + (yytext[3+skip1] == '-') || (yytext[3+skip1] == ':')) skip2 = 1; + + currentMoveString[0] = yytext[1+skip1]; + currentMoveString[1] = yytext[2+skip1]; + currentMoveString[2] = yytext[3+skip1+skip2]; + currentMoveString[3] = yytext[4+skip1+skip2]; + currentMoveString[4] = NULLCHAR; + + if (yyleng-skip1-skip2 > 5) { + if (yytext[yyleng-1] == ')') { + currentMoveString[4] = ToLower(yytext[yyleng-2]); + } else { + currentMoveString[4] = ToLower(yytext[yyleng-1]); + } + currentMoveString[5] = NULLCHAR; + } + + piece = boards[yyboardindex] + [currentMoveString[1] - '1'][currentMoveString[0] - 'a']; + if (ToLower(yytext[0]) != ToLower(PieceToChar(piece))) + return (int) IllegalMove; + + result = LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + currentMoveString[1] - '1', + currentMoveString[0] - 'a', + currentMoveString[3] - '1', + currentMoveString[2] - 'a', + currentMoveString[4]); + + if (currentMoveString[4] == NULLCHAR && + (result == WhitePromotionQueen || result == BlackPromotionQueen)) { + currentMoveString[4] = 'q'; + currentMoveString[5] = NULLCHAR; + } + + return (int) result; +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 212 "../parser.l" +{ + /* + * Simple algebraic move, possibly with promotion + */ + int skip = 0; + ChessMove result; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove the [xX:-] */ + if ((yytext[2] == 'x') || (yytext[2] == 'X') || + (yytext[2] == '-') || (yytext[2] == ':')) skip = 1; + + currentMoveString[0] = yytext[0]; + currentMoveString[1] = yytext[1]; + currentMoveString[2] = yytext[2+skip]; + currentMoveString[3] = yytext[3+skip]; + currentMoveString[4] = NULLCHAR; + + if (yyleng-skip > 4) { + if (yytext[yyleng-1] == ')') { + currentMoveString[4] = ToLower(yytext[yyleng-2]); + } else { + currentMoveString[4] = ToLower(yytext[yyleng-1]); + } + currentMoveString[5] = NULLCHAR; + } + + result = LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + currentMoveString[1] - '1', + currentMoveString[0] - 'a', + currentMoveString[3] - '1', + currentMoveString[2] - 'a', + currentMoveString[4]); + + if (currentMoveString[4] == NULLCHAR && + (result == WhitePromotionQueen || result == BlackPromotionQueen)) { + currentMoveString[4] = 'q'; + currentMoveString[5] = NULLCHAR; + } + + return (int) result; +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 257 "../parser.l" +{ + /* + * Pawn move, possibly with promotion + */ + DisambiguateClosure cl; + int skip = 0; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove the =() */ + if (yytext[2] == '=') skip++; + if (yytext[2+skip] == '(') skip++; + + cl.pieceIn = WhiteOnMove(yyboardindex) ? WhitePawn : BlackPawn; + cl.rfIn = -1; + cl.ffIn = yytext[0] - 'a'; + cl.rtIn = yytext[1] - '1'; + cl.ftIn = yytext[0] - 'a'; + cl.promoCharIn = yytext[2+skip]; + Disambiguate(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, &cl); + + currentMoveString[0] = cl.ff + 'a'; + currentMoveString[1] = cl.rf + '1'; + currentMoveString[2] = cl.ft + 'a'; + currentMoveString[3] = cl.rt + '1'; + currentMoveString[4] = cl.promoChar; + currentMoveString[5] = NULLCHAR; + + return (int) cl.kind; +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 290 "../parser.l" +{ + /* + * Pawn capture, possibly with promotion, possibly ambiguous + */ + DisambiguateClosure cl; + int skip1 = 0, skip2 = 0; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove trailing ep or e.p. (nonstandard PGN) */ + if (yytext[yyleng-1] == 'p') { + yyleng -= 2; + yytext[yyleng] = NULLCHAR; + } else if (yytext[yyleng-1] == '.') { + yyleng -= 4; + yytext[yyleng] = NULLCHAR; + } + + /* remove the [xX:-] and =() */ + if ((yytext[1] == 'x') || (yytext[1] == 'X') + || (yytext[1] == ':') || (yytext[1] == '-')) skip1 = 1; + if (yytext[2+skip1] == '=') skip2++; + if (yytext[2+skip1+skip2] == '(') skip2++; + + cl.pieceIn = WhiteOnMove(yyboardindex) ? WhitePawn : BlackPawn; + cl.rfIn = -1; + cl.ffIn = yytext[0] - 'a'; + cl.rtIn = -1; + cl.ftIn = yytext[1+skip1] - 'a'; + cl.promoCharIn = yytext[2+skip1+skip2]; + Disambiguate(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, &cl); + + currentMoveString[0] = cl.ff + 'a'; + currentMoveString[1] = cl.rf + '1'; + currentMoveString[2] = cl.ft + 'a'; + currentMoveString[3] = cl.rt + '1'; + currentMoveString[4] = cl.promoChar; + currentMoveString[5] = NULLCHAR; + + return (int) cl.kind; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 333 "../parser.l" +{ + /* + * unambiguously abbreviated Pawn capture, possibly with promotion + */ + int skip = 0; + ChessMove result; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove trailing ep or e.p. (nonstandard PGN) */ + if (yytext[yyleng-1] == 'p') { + yyleng -= 2; + yytext[yyleng] = NULLCHAR; + } else if (yytext[yyleng-1] == '.') { + yyleng -= 4; + yytext[yyleng] = NULLCHAR; + } + + /* remove the [xX:-] */ + if ((yytext[1] == 'x') || (yytext[1] == 'X') + || (yytext[1] == ':') || (yytext[1] == '-')) skip = 1; + + currentMoveString[0] = yytext[0]; + currentMoveString[2] = yytext[1+skip]; + currentMoveString[3] = yytext[2+skip]; + if (WhiteOnMove(yyboardindex)) { + if (yytext[2+skip] == '1') return (int) ImpossibleMove; + currentMoveString[1] = yytext[2+skip] - 1; + } else { + if (yytext[2+skip] == '8') return (int) ImpossibleMove; + currentMoveString[1] = yytext[2+skip] + 1; + } + if (yyleng-skip > 3) { + if (yytext[yyleng-1] == ')') + currentMoveString[4] = ToLower(yytext[yyleng-2]); + else + currentMoveString[4] = ToLower(yytext[yyleng-1]); + currentMoveString[5] = NULLCHAR; + } else { + currentMoveString[4] = NULLCHAR; + } + + result = LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + currentMoveString[1] - '1', + currentMoveString[0] - 'a', + currentMoveString[3] - '1', + currentMoveString[2] - 'a', + currentMoveString[4]); + + if (currentMoveString[4] == NULLCHAR && + (result == WhitePromotionQueen || result == BlackPromotionQueen)) { + currentMoveString[4] = 'q'; + currentMoveString[5] = NULLCHAR; + } + + if (result != IllegalMove) return (int) result; + + /* Special case: improperly written en passant capture */ + if (WhiteOnMove(yyboardindex)) { + if (currentMoveString[3] == '5') { + currentMoveString[1] = '5'; + currentMoveString[3] = '6'; + } else { + return (int) IllegalMove; + } + } else { + if (currentMoveString[3] == '4') { + currentMoveString[1] = '4'; + currentMoveString[3] = '3'; + } else { + return (int) IllegalMove; + } + } + + result = LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + currentMoveString[1] - '1', + currentMoveString[0] - 'a', + currentMoveString[3] - '1', + currentMoveString[2] - 'a', + currentMoveString[4]); + + if (result == WhiteCapturesEnPassant || result == BlackCapturesEnPassant) + return (int) result; + else + return (int) IllegalMove; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 422 "../parser.l" +{ + /* + * piece move, possibly ambiguous + */ + DisambiguateClosure cl; + int skip = 0; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove the [xX:-] */ + if ((yytext[1] == 'x') || (yytext[1] == 'X') + || (yytext[1] == ':') || (yytext[1] == '-')) skip = 1; + + if (WhiteOnMove(yyboardindex)) { + cl.pieceIn = CharToPiece(ToUpper(yytext[0])); + } else { + cl.pieceIn = CharToPiece(ToLower(yytext[0])); + } + cl.rfIn = -1; + cl.ffIn = -1; + cl.rtIn = yytext[2+skip] - '1'; + cl.ftIn = yytext[1+skip] - 'a'; + cl.promoCharIn = NULLCHAR; + Disambiguate(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, &cl); + + currentMoveString[0] = cl.ff + 'a'; + currentMoveString[1] = cl.rf + '1'; + currentMoveString[2] = cl.ft + 'a'; + currentMoveString[3] = cl.rt + '1'; + currentMoveString[4] = cl.promoChar; + currentMoveString[5] = NULLCHAR; + + return (int) cl.kind; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 458 "../parser.l" +{ + /* + * piece move with rank or file disambiguator + */ + DisambiguateClosure cl; + int skip = 0; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + /* remove the [xX:-] */ + if ((yytext[2] == 'x') || (yytext[2] == 'X') + || (yytext[2] == ':') || (yytext[2] == '-')) skip = 1; + + if (WhiteOnMove(yyboardindex)) { + cl.pieceIn = CharToPiece(ToUpper(yytext[0])); + } else { + cl.pieceIn = CharToPiece(ToLower(yytext[0])); + } + if (isalpha(yytext[1])) { + cl.rfIn = -1; + cl.ffIn = yytext[1] - 'a'; + } else { + cl.rfIn = yytext[1] - '1'; + cl.ffIn = -1; + } + cl.rtIn = yytext[3+skip] - '1'; + cl.ftIn = yytext[2+skip] - 'a'; + cl.promoCharIn = NULLCHAR; + Disambiguate(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, &cl); + + currentMoveString[0] = cl.ff + 'a'; + currentMoveString[1] = cl.rf + '1'; + currentMoveString[2] = cl.ft + 'a'; + currentMoveString[3] = cl.rt + '1'; + currentMoveString[4] = cl.promoChar; + currentMoveString[5] = NULLCHAR; + + return (int) cl.kind; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 499 "../parser.l" +{ + int rf, ff, rt, ft; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + if (WhiteOnMove(yyboardindex)) { + if (boards[yyboardindex][0][3] == WhiteKing) { + /* ICS wild castling */ + strcpy(currentMoveString, "d1f1"); + rf = 0; + ff = 3; + rt = 0; + ft = 5; + } else { + strcpy(currentMoveString, "e1c1"); + rf = 0; + ff = 4; + rt = 0; + ft = 2; + } + } else{ + if (boards[yyboardindex][7][3] == BlackKing) { + /* ICS wild castling */ + strcpy(currentMoveString, "d8f8"); + rf = 7; + ff = 3; + rt = 7; + ft = 5; + } else { + strcpy(currentMoveString, "e8c8"); + rf = 7; + ff = 4; + rt = 7; + ft = 2; + } + } + return (int) LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + rf, ff, rt, ft, NULLCHAR); +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 540 "../parser.l" +{ + int rf, ff, rt, ft; + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + if (WhiteOnMove(yyboardindex)) { + if (boards[yyboardindex][0][3] == WhiteKing) { + /* ICS wild castling */ + strcpy(currentMoveString, "d1b1"); + rf = 0; + ff = 3; + rt = 0; + ft = 1; + } else { + strcpy(currentMoveString, "e1g1"); + rf = 0; + ff = 4; + rt = 0; + ft = 6; + } + } else { + if (boards[yyboardindex][7][3] == BlackKing) { + /* ICS wild castling */ + strcpy(currentMoveString, "d8b8"); + rf = 7; + ff = 3; + rt = 7; + ft = 1; + } else { + strcpy(currentMoveString, "e8g8"); + rf = 7; + ff = 4; + rt = 7; + ft = 6; + } + } + return (int) LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex), EP_UNKNOWN, + rf, ff, rt, ft, NULLCHAR); +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 581 "../parser.l" +{ + /* Bughouse piece drop. No legality checking for now. */ + currentMoveString[1] = '@'; + currentMoveString[2] = yytext[2]; + currentMoveString[3] = yytext[3]; + currentMoveString[4] = NULLCHAR; + if (WhiteOnMove(yyboardindex)) { + currentMoveString[0] = ToUpper(yytext[0]); + return (int) WhiteDrop; + } else { + currentMoveString[0] = ToLower(yytext[0]); + return (int) BlackDrop; + } +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 596 "../parser.l" +{ + if (WhiteOnMove(yyboardindex)) + return (int) BlackWins; + else + return (int) WhiteWins; +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 603 "../parser.l" +{ + return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 607 "../parser.l" +{ + return (int) GameUnfinished; +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 611 "../parser.l" +{ + return (int) GameIsDrawn; +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 615 "../parser.l" +{ + return (int) GameIsDrawn; +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 619 "../parser.l" +{ + if (WhiteOnMove(yyboardindex)) + return (int) BlackWins; + else + return (int) WhiteWins; +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 626 "../parser.l" +{ + if (WhiteOnMove(yyboardindex)) + return (int) BlackWins; + else + return (int) WhiteWins; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 633 "../parser.l" +{ + return (int) GameIsDrawn; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 637 "../parser.l" +{ + return (int) GameIsDrawn; +} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 641 "../parser.l" +{ + return (int) (ToUpper(yytext[0]) == 'W' ? WhiteWins : BlackWins); +} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 645 "../parser.l" +{ + return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); +} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 649 "../parser.l" +{ + return (int) WhiteWins; +} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 653 "../parser.l" +{ + return (int) BlackWins; +} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 657 "../parser.l" +{ + return (int) GameIsDrawn; +} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 661 "../parser.l" +{ + return (int) GameUnfinished; +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 665 "../parser.l" +{ + /* move numbers */ + if ((yyleng == 1) && (yytext[0] == '1')) + return (int) MoveNumberOne; +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 671 "../parser.l" +{ + /* elapsed time indication, e.g. (0:12) or {10:21.071} */ + return (int) ElapsedTime; +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 676 "../parser.l" +{ + /* position diagram enclosed in [-- --] */ + return (int) PositionDiagram; +} + YY_BREAK +case 29: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 681 "../parser.l" +{ + /* position diagram enclosed in {-- --} */ + return (int) PositionDiagram; +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 686 "../parser.l" +{ + return (int) PGNTag; +} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 690 "../parser.l" +{ + return (int) GNUChessGame; +} + YY_BREAK +case 32: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 694 "../parser.l" +{ + return (int) XBoardGame; +} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 698 "../parser.l" +{ /* numeric annotation glyph */ + return (int) NAG; +} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 702 "../parser.l" +{ /* anything in {} */ + return (int) Comment; +} + YY_BREAK +case 35: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 706 "../parser.l" +{ /* ; to end of line */ + return (int) Comment; +} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 710 "../parser.l" +{ /* anything in [] */ + return (int) Comment; +} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 714 "../parser.l" +{ /* nested () */ + return (int) Comment; +} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 718 "../parser.l" +{ /* >=2 chars in () */ + return (int) Comment; +} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 722 "../parser.l" +{ + /* Skip mail headers */ +} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 726 "../parser.l" +{ + /* Skip random words */ +} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 730 "../parser.l" +{ + /* Skip everything else */ +} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 734 "../parser.l" +ECHO; + YY_BREAK +#line 2809 "lex.yy.c" + case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 711 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 711 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 710); + if ( ! yy_is_jam ) + *yy_state_ptr++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + yy_current_buffer->yy_at_bol = (c == '\n'); + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 734 "../parser.l" + + + +static char *StringToLex; + +#ifndef FLEX_SCANNER +static FILE *lexFP; + +static int input() +{ + int ret; + + if (StringToLex != NULL) { + ret = *StringToLex; + if (ret == NULLCHAR) + ret = EOF; + else + StringToLex++; + } else if (unputCount > 0) { + ret = unputBuffer[--unputCount]; + } else { + ret = fgetc(lexFP); + } + + if (ret == EOF) + return 0; + else + return ret; +} + +/* + * Return offset of next pattern within current file + */ +int yyoffset() +{ + int offset = ftell(lexFP) - unputCount; + + if (offset < 0) { + offset = 0; + } + return(offset); +} + +static void output(ch) + int ch; +{ + fprintf(stderr, "PARSER BUG: unmatched character '%c' (0%o)\n", + ch, ch); +} + +static void unput(ch) + int ch; +{ + if (ch == 0) return; + if (StringToLex != NULL) { + StringToLex--; + } else { + if (unputCount >= UNPUT_BUF_SIZE) + fprintf(stderr, "PARSER BUG: unput buffer overflow '%c' (0%o)\n", + ch, ch); + unputBuffer[unputCount++] = ch; + } +} + +/* Get ready to lex from a new file. Kludge below sticks + an artificial newline at the front of the file, which the + above grammar ignores, but which makes ^ at start of pattern + match at the real start of the file. +*/ +void yynewfile(f) + FILE *f; +{ + lexFP = f; + StringToLex = NULL; + unputCount = 0; + unput('\n'); /* kludge */ +} + +/* Get ready to lex from a string. ^ at start of pattern WON'T + match at the start of the string! +*/ +void yynewstr(s) + char *s; +{ + lexFP = NULL; + StringToLex = s; + unputCount = 0; +} +#endif /*!FLEX_SCANNER*/ + +#ifdef FLEX_SCANNER +void my_yy_input(buf, result, max_size) + char *buf; + int *result; + int max_size; +{ + int count; + + if (StringToLex != NULL) { + count = 0; + while (*StringToLex != NULLCHAR) { + *buf++ = *StringToLex++; + count++; + } + *result = count; + return; + } else { + count = fread(buf, 1, max_size, yyin); + if (count == 0) { + *result = YY_NULL; + } else { + *result = count; + } + return; + } +} + +static YY_BUFFER_STATE my_file_buffer = NULL; + +/* + Return offset of next pattern in the current file. +*/ +int yyoffset() +{ + int pos = yy_c_buf_p - yy_current_buffer->yy_ch_buf; + + return(ftell(yy_current_buffer->yy_input_file) - + yy_n_chars + pos); +} + + +void yynewstr(s) + char *s; +{ + if (my_file_buffer != NULL) + yy_delete_buffer(my_file_buffer); + StringToLex = s; + my_file_buffer = yy_create_buffer(stdin, YY_BUF_SIZE); + yy_switch_to_buffer(my_file_buffer); +} + +void yynewfile(f) + FILE *f; +{ + if (my_file_buffer != NULL) + yy_delete_buffer(my_file_buffer); + StringToLex = NULL; + my_file_buffer = yy_create_buffer(f, YY_BUF_SIZE); + yy_switch_to_buffer(my_file_buffer); +} +#endif /*FLEX_SCANNER*/ + +int yywrap() +{ + return TRUE; +} + +/* Parse a move from the given string s */ +/* ^ at start of pattern WON'T work here unless using flex */ +ChessMove yylexstr(boardIndex, s) + int boardIndex; + char *s; +{ + ChessMove ret; + char *oldStringToLex; +#ifdef FLEX_SCANNER + YY_BUFFER_STATE buffer, oldBuffer; +#endif + + yyboardindex = boardIndex; + oldStringToLex = StringToLex; + StringToLex = s; +#ifdef FLEX_SCANNER + buffer = yy_create_buffer(stdin, YY_BUF_SIZE); + oldBuffer = YY_CURRENT_BUFFER; + yy_switch_to_buffer(buffer); +#endif /*FLEX_SCANNER*/ + + ret = (ChessMove) yylex(); + +#ifdef FLEX_SCANNER + if (oldBuffer != NULL) + yy_switch_to_buffer(oldBuffer); + yy_delete_buffer(buffer); +#endif /*FLEX_SCANNER*/ + StringToLex = oldStringToLex; + + return ret; +} diff --git a/parser.h b/parser.h index dfc257a..434a971 100644 --- a/parser.h +++ b/parser.h @@ -1,6 +1,6 @@ /* * parser.h -- Interface to XBoard move parser - * $Id$ + * $Id: parser.h,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. diff --git a/pgntags.c b/pgntags.c index 8a1f6b5..cd8f0d8 100644 --- a/pgntags.c +++ b/pgntags.c @@ -1,6 +1,6 @@ /* * pgntags.c -- Functions to manage PGN tags - * XBoard $Id$ + * XBoard $Id: pgntags.c,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/winboard/resource.h b/winboard/resource.h index 1f4411b..daea88c 100644 --- a/winboard/resource.h +++ b/winboard/resource.h @@ -86,6 +86,7 @@ #define DLG_IcsOptions 454 #define DLG_BoardOptions 455 #define DLG_Fonts 456 +#define DLG_NewGameFRC 457 #define DLG_Promotion 500 #define PB_Queen 502 #define PB_Rook 503 @@ -151,6 +152,8 @@ #define DLG_ConsoleRich 1022 #define IDC_EDIT1 1023 #define OPT_DarkSquareColor 1023 +#define IDC_GameListFilter 1023 +#define IDC_NFG_Edit 1023 #define OPT_ConsoleText 1024 #define OPT_LightSquareColor 1024 #define OPT_CommandInput 1025 @@ -217,6 +220,7 @@ #define IDM_UserAdjudication_White 1302 #define IDM_UserAdjudication_Black 1303 #define IDM_UserAdjudication_Draw 1304 +#define IDM_NewGameFRC 1305 #define PB_King 1307 #define OPT_Bold 1312 #define OPT_Italic 1313 @@ -345,6 +349,9 @@ #define OPT_ShowButtonBar 1422 #define OPT_SaveExtPGN 1423 #define OPT_HideThinkFromHuman 1424 +#define IDC_GameListDoFilter 1425 +#define IDC_NFG_Random 1426 +#define IDC_NFG_Label 1427 #define IDC_STATIC -1 // Next default values for new objects @@ -352,9 +359,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 457 -#define _APS_NEXT_COMMAND_VALUE 1305 -#define _APS_NEXT_CONTROL_VALUE 1425 +#define _APS_NEXT_RESOURCE_VALUE 458 +#define _APS_NEXT_COMMAND_VALUE 1306 +#define _APS_NEXT_CONTROL_VALUE 1428 #define _APS_NEXT_SYMED_VALUE 1404 #endif #endif diff --git a/winboard/wclipbrd.c b/winboard/wclipbrd.c index dbb47a7..3eecd38 100644 --- a/winboard/wclipbrd.c +++ b/winboard/wclipbrd.c @@ -47,7 +47,7 @@ CopyFENToClipboard() { char *fen = NULL; - fen = PositionToFEN(currentMove); + fen = PositionToFEN(currentMove,1); if (!fen) { DisplayError("Unable to convert position to FEN.", 0); return; diff --git a/winboard/wedittags.c b/winboard/wedittags.c index 8c6ea5a..935e761 100644 --- a/winboard/wedittags.c +++ b/winboard/wedittags.c @@ -1,6 +1,6 @@ /* * wedittags.c -- EditTags window for WinBoard - * $Id$ + * $Id: wedittags.c,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/winboard/wedittags.h b/winboard/wedittags.h index 18c64e4..9b3626a 100644 --- a/winboard/wedittags.h +++ b/winboard/wedittags.h @@ -1,6 +1,6 @@ /* * wedittags.h -- EditTags window for WinBoard - * $Id$ + * $Id: wedittags.h,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index 90528aa..34339d4 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -1,6 +1,6 @@ /* * wgamelist.c -- Game list window for WinBoard - * $Id$ + * $Id: wgamelist.c,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * @@ -48,33 +48,184 @@ int gameListX, gameListY, gameListW, gameListH; extern HINSTANCE hInst; extern HWND hwndMain; +struct GameListStats +{ + int white_wins; + int black_wins; + int drawn; + int unfinished; +}; + +/* [AS] Wildcard pattern matching */ +static BOOL HasPattern( const char * text, const char * pattern ) +{ + while( *pattern != '\0' ) { + if( *pattern == '*' ) { + while( *pattern == '*' ) { + pattern++; + } + + if( *pattern == '\0' ) { + return TRUE; + } + + while( *text != '\0' ) { + if( HasPattern( text, pattern ) ) { + return TRUE; + } + text++; + } + } + else if( (*pattern == *text) || ((*pattern == '?') && (*text != '\0')) ) { + pattern++; + text++; + continue; + } + + return FALSE; + } + + return TRUE; +} + +static BOOL SearchPattern( const char * text, const char * pattern ) +{ + BOOL result = TRUE; + + if( pattern != NULL && *pattern != '\0' ) { + if( *pattern == '*' ) { + result = HasPattern( text, pattern ); + } + else { + result = FALSE; + + while( *text != '\0' ) { + if( HasPattern( text, pattern ) ) { + result = TRUE; + break; + } + text++; + } + } + } + + return result; +} + +/* [AS] Setup the game list according to the specified filter */ +static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats ) +{ + ListGame * lg = (ListGame *) gameList.head; + int nItem; + BOOL hasFilter = FALSE; + int count = 0; + struct GameListStats dummy; + + /* Initialize stats (use a dummy variable if caller not interested in them) */ + if( stats == NULL ) { + stats = &dummy; + } + + stats->white_wins = 0; + stats->black_wins = 0; + stats->drawn = 0; + stats->unfinished = 0; + + if( boReset ) { + SendDlgItemMessage(hDlg, OPT_GameListText, LB_RESETCONTENT, 0, 0); + } + + if( pszFilter != NULL ) { + if( strlen( pszFilter ) > 0 ) { + hasFilter = TRUE; + } + } + + for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ + char * st = GameListLine(lg->number, &lg->gameInfo); + BOOL skip = FALSE; + + if( hasFilter ) { + if( ! SearchPattern( st, pszFilter ) ) { + skip = TRUE; + } + } + + if( ! skip ) { + SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st); + count++; + + /* Update stats */ + if( lg->gameInfo.result == WhiteWins ) + stats->white_wins++; + else if( lg->gameInfo.result == BlackWins ) + stats->black_wins++; + else if( lg->gameInfo.result == GameIsDrawn ) + stats->drawn++; + else + stats->unfinished++; + } + + free(st); + lg = (ListGame *) lg->node.succ; + } + + SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0); + + return count; +} + +/* [AS] Show number of visible (filtered) games and total on window caption */ +static int GameListUpdateTitle( HWND hDlg, char * pszTitle, int item_count, int item_total, struct GameListStats * stats ) +{ + char buf[256]; + + sprintf( buf, "%s - %d/%d games", pszTitle, item_count, item_total ); + + if( stats != 0 ) { + sprintf( buf+strlen(buf), " (%d-%d-%d)", stats->white_wins, stats->black_wins, stats->drawn ); + } + + SetWindowText( hDlg, buf ); + + return 0; +} + +#define MAX_FILTER_LENGTH 128 LRESULT CALLBACK GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { + static char szDlgTitle[64]; static HANDLE hwndText; int nItem; - ListGame *lg; RECT rect; static int sizeX, sizeY; int newSizeX, newSizeY, flags; MINMAXINFO *mmi; + static BOOL filterHasFocus = FALSE; + int count; + struct GameListStats stats; switch (message) { case WM_INITDIALOG: + GetWindowText( hDlg, szDlgTitle, sizeof(szDlgTitle) ); + szDlgTitle[ sizeof(szDlgTitle)-1 ] = '\0'; + if (gameListDialog) { SendDlgItemMessage(hDlg, OPT_GameListText, LB_RESETCONTENT, 0, 0); } + /* Initialize the dialog items */ hwndText = GetDlgItem(hDlg, OPT_TagsText); - lg = (ListGame *) gameList.head; - for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ - char *st = GameListLine(lg->number, &lg->gameInfo); - SendDlgItemMessage(hDlg, OPT_GameListText, LB_ADDSTRING, 0, (LPARAM) st); - free(st); - lg = (ListGame *) lg->node.succ; - } - SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, 0, 0); + + count = GameListToListBox( hDlg, gameListDialog ? TRUE : FALSE, NULL, &stats ); + + SendDlgItemMessage( hDlg, IDC_GameListFilter, WM_SETTEXT, 0, (LPARAM) "" ); + SendDlgItemMessage( hDlg, IDC_GameListFilter, EM_SETLIMITTEXT, MAX_FILTER_LENGTH, 0 ); + + filterHasFocus = FALSE; + /* Size and position the dialog */ if (!gameListDialog) { gameListDialog = hDlg; @@ -104,6 +255,8 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) sizeX = newSizeX; sizeY = newSizeY; } + + GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats ); } return FALSE; @@ -124,6 +277,27 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_COMMAND: + /* + [AS] + If is pressed while editing the filter, it's better to apply + the filter rather than selecting the current game. + */ + if( LOWORD(wParam) == IDC_GameListFilter ) { + switch( HIWORD(wParam) ) { + case EN_SETFOCUS: + filterHasFocus = TRUE; + break; + case EN_KILLFOCUS: + filterHasFocus = FALSE; + break; + } + } + + if( filterHasFocus && (LOWORD(wParam) == IDOK) ) { + wParam = IDC_GameListDoFilter; + } + /* [AS] End command replacement */ + switch (LOWORD(wParam)) { case IDOK: case OPT_GameListLoad: @@ -139,7 +313,8 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); nItem++; if (nItem >= ((ListGame *) gameList.tailPred)->number) { - DisplayError("Can't go forward any further", 0); + /* [AS] Removed error message */ + /* DisplayError("Can't go forward any further", 0); */ return TRUE; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); @@ -149,11 +324,27 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); nItem--; if (nItem < 0) { - DisplayError("Can't back up any further", 0); + /* [AS] Removed error message, added return */ + /* DisplayError("Can't back up any further", 0); */ + return TRUE; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); break; /* load the game*/ + /* [AS] */ + case IDC_GameListDoFilter: + { + char filter[MAX_FILTER_LENGTH+1]; + + if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) { + filter[ sizeof(filter)-1 ] = '\0'; + count = GameListToListBox( hDlg, TRUE, filter, &stats ); + GameListUpdateTitle( hDlg, szDlgTitle, count, ((ListGame *) gameList.tailPred)->number, &stats ); + } + } + return FALSE; + break; + case IDCANCEL: case OPT_GameListClose: GameListPopDown(); @@ -173,12 +364,43 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) default: return FALSE; } + /* Load the game */ + { + /* [AS] Get index from the item itself, because filtering makes original order unuseable. */ + int index = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); + char * text; + LRESULT res; + + if( index < 0 ) { + return TRUE; + } + + res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXTLEN, index, 0 ); + + if( res == LB_ERR ) { + return TRUE; + } + + text = (char *) malloc( res+1 ); + + res = SendDlgItemMessage( hDlg, OPT_GameListText, LB_GETTEXT, index, (LPARAM)text ); + + index = atoi( text ); + + nItem = index - 1; + + free( text ); + /* [AS] End: nItem has been "patched" now! */ + if (cmailMsgLoaded) { CmailLoadGame(gameFile, nItem + 1, gameFileName, TRUE); - } else { + } + else { LoadGame(gameFile, nItem + 1, gameFileName, TRUE); } + } + return TRUE; default: diff --git a/winboard/wgamelist.h b/winboard/wgamelist.h index 12e382f..92b0ca1 100644 --- a/winboard/wgamelist.h +++ b/winboard/wgamelist.h @@ -1,6 +1,6 @@ /* * wgamelist.h -- Game list window for WinBoard - * $Id$ + * $Id: wgamelist.h,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 1995 Free Software Foundation, Inc. * diff --git a/winboard/winboard.c b/winboard/winboard.c index 2ad3bcf..751e67e 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -415,6 +415,7 @@ VOID APIENTRY MenuPopup(HWND hwnd, POINT pt, HMENU hmenu, UINT def); void ParseIcsTextMenu(char *icsTextMenuString); VOID PopUpMoveDialog(char firstchar); VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca); +int NewGameFRC(); /* * Setting "frozen" should disable all user input other than deleting @@ -654,6 +655,12 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + + /* [AS] Disable the FRC stuff if not playing the proper variant */ + if( gameInfo.variant != VariantFischeRandom ) { + EnableMenuItem( GetMenu(hwndMain), IDM_NewGameFRC, MF_GRAYED ); + } + if (hwndConsole) { #if AOT_CONSOLE SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, @@ -1071,8 +1078,9 @@ ArgDescriptor argDescriptors[] = { { "delayBeforeQuit", ArgInt, (LPVOID) &appData.delayBeforeQuit, TRUE }, { "delayAfterQuit", ArgInt, (LPVOID) &appData.delayAfterQuit, TRUE }, { "nameOfDebugFile", ArgFilename, (LPVOID) &appData.nameOfDebugFile, FALSE }, - { "pgnEventHeader", ArgString, (LPVOID) &appData.pgnEventHeader, TRUE }, { "debugfile", ArgFilename, (LPVOID) &appData.nameOfDebugFile, FALSE }, + { "pgnEventHeader", ArgString, (LPVOID) &appData.pgnEventHeader, TRUE }, + { "defaultFrcPosition", ArgInt, (LPVOID) &appData.defaultFrcPosition, TRUE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, { "zt", ArgTrue, (LPVOID) &appData.zippyTalk, FALSE }, @@ -1750,6 +1758,7 @@ InitAppData(LPSTR lpCmdLine) appData.delayAfterQuit = 0; appData.nameOfDebugFile = "winboard.debug"; appData.pgnEventHeader = "Computer Chess Game"; + appData.defaultFrcPosition = -1; #ifdef ZIPPY appData.zippyTalk = ZIPPY_TALK; @@ -4145,6 +4154,13 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) AnalysisPopDown(); break; + case IDM_NewGameFRC: + if( NewGameFRC() == 0 ) { + ResetGameEvent(); + AnalysisPopDown(); + } + break; + case IDM_LoadGame: LoadGameDialog(hwnd, "Load Game from File"); break; @@ -6465,6 +6481,15 @@ DoReadFile(HANDLE hFile, char *buf, int count, DWORD *outCount, { int ok, err; + /* [AS] */ + if( count <= 0 ) { + if (appData.debugMode) { + fprintf( debugFP, "DoReadFile: trying to read past end of buffer, overflow = %d\n", count ); + } + + return ERROR_INVALID_USER_BUFFER; + } + ResetEvent(ovl->hEvent); ovl->Offset = ovl->OffsetHigh = 0; ok = ReadFile(hFile, buf, count, outCount, ovl); @@ -6523,8 +6548,8 @@ void CheckForInputBufferFull( InputSource * is ) fprintf( debugFP, "Input line exceeded buffer size (source id=%u)\n", is->id ); } - is->error = ERROR_BROKEN_PIPE; /* [AS] Just a non-successful code! */ - is->count = (DWORD) -2; + is->error = ERROR_BROKEN_PIPE; /* [AS] Just any non-successful code! */ + is->count = (DWORD) -1; is->next = is->buf; } } @@ -6551,16 +6576,27 @@ InputThread(LPVOID arg) is->count = 0; } else { is->count = (DWORD) -1; + /* [AS] The (is->count <= 0) check below is not useful for unsigned values! */ + break; } } CheckForInputBufferFull( is ); SendMessage(hwndMain, WM_USER_Input, 0, (LPARAM) is); + + if( is->count == ((DWORD) -1) ) break; /* [AS] */ + if (is->count <= 0) break; /* Quit on EOF or error */ } + CloseHandle(ovl.hEvent); CloseHandle(is->hFile); + + if (appData.debugMode) { + fprintf( debugFP, "Input thread terminated (id=%u, error=%d, count=%d)\n", is->id, is->error, is->count ); + } + return 0; } @@ -6614,6 +6650,9 @@ NonOvlInputThread(LPVOID arg) CheckForInputBufferFull( is ); SendMessage(hwndMain, WM_USER_Input, 0, (LPARAM) is); + + if( is->count == ((DWORD) -1) ) break; /* [AS] */ + if (is->count < 0) break; /* Quit on error */ } CloseHandle(is->hFile); @@ -6640,6 +6679,9 @@ SocketInputThread(LPVOID arg) } } SendMessage(hwndMain, WM_USER_Input, 0, (LPARAM) is); + + if( is->count == ((DWORD) -1) ) break; /* [AS] */ + if (is->count <= 0) break; /* Quit on EOF or error */ } return 0; @@ -7213,6 +7255,70 @@ AskQuestion(char* title, char *question, char *replyPrefix, ProcRef pr) FreeProcInstance(lpProc); } +/* [AS] Pick FRC position */ +LRESULT CALLBACK NewGameFRC_Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + static int * lpIndexFRC; + BOOL index_is_ok; + char buf[16]; + + switch( message ) + { + case WM_INITDIALOG: + lpIndexFRC = (int *) lParam; + + CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER)); + + SendDlgItemMessage( hDlg, IDC_NFG_Edit, EM_SETLIMITTEXT, sizeof(buf)-1, 0 ); + SetDlgItemInt( hDlg, IDC_NFG_Edit, *lpIndexFRC, TRUE ); + SendDlgItemMessage( hDlg, IDC_NFG_Edit, EM_SETSEL, 0, -1 ); + SetFocus(GetDlgItem(hDlg, IDC_NFG_Edit)); + + break; + + case WM_COMMAND: + switch( LOWORD(wParam) ) { + case IDOK: + *lpIndexFRC = GetDlgItemInt(hDlg, IDC_NFG_Edit, &index_is_ok, TRUE ); + EndDialog( hDlg, 0 ); + return TRUE; + case IDCANCEL: + EndDialog( hDlg, 1 ); + return TRUE; + case IDC_NFG_Edit: + if( HIWORD(wParam) == EN_CHANGE ) { + GetDlgItemInt(hDlg, IDC_NFG_Edit, &index_is_ok, TRUE ); + + EnableWindow( GetDlgItem(hDlg, IDOK), index_is_ok ); + } + return TRUE; + case IDC_NFG_Random: + sprintf( buf, "%d", myrandom() % 960 ); + SetDlgItemText(hDlg, IDC_NFG_Edit, buf ); + return TRUE; + } + + break; + } + + return FALSE; +} + +int NewGameFRC() +{ + int result; + int index = appData.defaultFrcPosition; + FARPROC lpProc = MakeProcInstance( (FARPROC) NewGameFRC_Proc, hInst ); + + result = DialogBoxParam( hInst, MAKEINTRESOURCE(DLG_NewGameFRC), hwndMain, (DLGPROC)lpProc, (LPARAM)&index ); + + if( result == 0 ) { + appData.defaultFrcPosition = index; + } + + return result; +} + VOID DisplayIcsInteractionTitle(char *str) @@ -8089,7 +8195,7 @@ AddInputSource(ProcRef pr, int lineByLine, is->kind = cp->kind; /* [AS] Try to avoid a race condition if the thread is given control too early: - we create all threads suspended to that the is->hThread variable can be + we create all threads suspended so that the is->hThread variable can be safely assigned, then let the threads start with ResumeThread. */ switch (cp->kind) { @@ -8550,6 +8656,13 @@ void HistorySet(char movelist[][2*MOVE_LEN], int first, int last, int current) { /* Currently not implemented in WinBoard */ -} +#if 1 + /* [AS] Let's see what this function is for... */ + char buf[256]; + sprintf( buf, "HistorySet: first=%d, last=%d, current=%d (%s)\n", + first, last, current, current >= 0 ? movelist[current] : "n/a" ); + OutputDebugString( buf ); +#endif +} diff --git a/winboard/winboard.rc b/winboard/winboard.rc index 1908a1a..085f5b9 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -204,17 +204,19 @@ BEGIN CONTROL "galactic",IDC_STATIC,"Static",SS_BITMAP,4,4,15,13 END -DLG_GameList DIALOG DISCARDABLE 6, 18, 307, 159 +DLG_GameList DIALOG DISCARDABLE 6, 18, 259, 153 STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "Game List" FONT 8, "MS Sans Serif" BEGIN - LISTBOX OPT_GameListText,4,4,299,130,LBS_NOINTEGRALHEIGHT | + LISTBOX OPT_GameListText,2,2,254,130,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - PUSHBUTTON "&Load",OPT_GameListLoad,61,138,40,15 - PUSHBUTTON "&Prev",OPT_GameListPrev,109,138,40,15 - PUSHBUTTON "&Next",OPT_GameListNext,157,138,40,15 - PUSHBUTTON "&Close",OPT_GameListClose,205,138,40,15 + PUSHBUTTON "&Load",OPT_GameListLoad,2,135,32,15 + PUSHBUTTON "&<",OPT_GameListPrev,38,135,22,15 + PUSHBUTTON "&>",OPT_GameListNext,64,135,24,15 + PUSHBUTTON "&Close",OPT_GameListClose,92,135,32,15 + PUSHBUTTON "Filter",IDC_GameListDoFilter,144,136,30,14 + EDITTEXT IDC_GameListFilter,178,136,78,14,ES_AUTOHSCROLL END DLG_EditTags DIALOG DISCARDABLE 6, 18, 160, 141 @@ -615,6 +617,18 @@ BEGIN GROUPBOX "All Board Sizes",IDC_STATIC,5,105,270,100 END +DLG_NewGameFRC DIALOG DISCARDABLE 0, 0, 176, 47 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "New FRC (Chess960) Game" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "&Start Position Number:",IDC_NFG_Label,4,7,71,8 + EDITTEXT IDC_NFG_Edit,76,4,42,14,ES_AUTOHSCROLL + PUSHBUTTON "Random",IDC_NFG_Random,122,4,50,14 + DEFPUSHBUTTON "OK",IDOK,34,28,50,14 + PUSHBUTTON "Cancel",IDCANCEL,92,28,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -624,6 +638,11 @@ END #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN + DLG_GameList, DIALOG + BEGIN + RIGHTMARGIN, 258 + END + DLG_GeneralOptions, DIALOG BEGIN LEFTMARGIN, 7 @@ -655,6 +674,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 224 END + + DLG_NewGameFRC, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 169 + TOPMARGIN, 7 + BOTTOMMARGIN, 40 + END END #endif // APSTUDIO_INVOKED @@ -679,13 +706,14 @@ WINBOARD MENU DISCARDABLE BEGIN POPUP "&File" BEGIN - MENUITEM "Reset &Game", IDM_NewGame + MENUITEM "New &Game\tCtrl-N", IDM_NewGame + MENUITEM "New FRC Game...", IDM_NewGameFRC MENUITEM SEPARATOR - MENUITEM "&Load Game...", IDM_LoadGame + MENUITEM "&Load Game...\tCtrl-O", IDM_LoadGame MENUITEM "Load &Next Game\tAlt+PgDn", IDM_LoadNextGame MENUITEM "Load &Previous Game\tAlt+PgUp", IDM_LoadPrevGame MENUITEM "&Reload Same Game", IDM_ReloadGame - MENUITEM "&Save Game...", IDM_SaveGame + MENUITEM "&Save Game...\tCtrl-S", IDM_SaveGame MENUITEM SEPARATOR MENUITEM "&Copy Game To Clipboard\tAlt+C", IDM_CopyGame MENUITEM "Paste Game &From Clipboard\tAlt+V", IDM_PasteGame @@ -898,6 +926,9 @@ BEGIN "2", IDM_DirectCommand2, VIRTKEY, ALT, NOINVERT "C", IDM_CopyGame, VIRTKEY, ALT, NOINVERT "C", IDM_CopyPosition, VIRTKEY, SHIFT, ALT, NOINVERT + "N", IDM_NewGame, VIRTKEY, CONTROL, NOINVERT + "O", IDM_LoadGame, VIRTKEY, CONTROL, NOINVERT + "S", IDM_SaveGame, VIRTKEY, CONTROL, NOINVERT "V", IDM_Paste, VIRTKEY, CONTROL, NOINVERT "V", IDM_PasteGame, VIRTKEY, ALT, NOINVERT "V", IDM_PastePosition, VIRTKEY, SHIFT, ALT, NOINVERT @@ -1315,38 +1346,38 @@ END // WAVE // -DING WAVE DISCARDABLE "..\\sounds\\ding1.wav" -CHING WAVE DISCARDABLE "..\\sounds\\ching.wav" -CLICK WAVE DISCARDABLE "..\\sounds\\click.wav" -CYMBAL WAVE DISCARDABLE "..\\sounds\\cymbal.wav" -DRIP WAVE DISCARDABLE "..\\sounds\\drip.wav" -GONG WAVE DISCARDABLE "..\\sounds\\gong.wav" -BEEPBEEP WAVE DISCARDABLE "..\\sounds\\honkhonk.wav" -LASER WAVE DISCARDABLE "..\\sounds\\laser.wav" -PENALTY WAVE DISCARDABLE "..\\sounds\\penalty.wav" -PHONE WAVE DISCARDABLE "..\\sounds\\phone.wav" -POP WAVE DISCARDABLE "..\\sounds\\pop.wav" -POP2 WAVE DISCARDABLE "..\\sounds\\pop2.wav" -SLAP WAVE DISCARDABLE "..\\sounds\\slap.wav" -SQUEAK WAVE DISCARDABLE "..\\sounds\\squeak.wav" -SWISH WAVE DISCARDABLE "..\\sounds\\swish.wav" -THUD WAVE DISCARDABLE "..\\sounds\\thud.wav" -WHIPCRACK WAVE DISCARDABLE "..\\sounds\\whipcrak.wav" -MOVE WAVE DISCARDABLE "..\\sounds\\move.wav" -ALARM WAVE DISCARDABLE "..\\sounds\\alarm.wav" -CHALLENGE WAVE DISCARDABLE "..\\sounds\\challenge.wav" -CHANNEL WAVE DISCARDABLE "..\\sounds\\channel.wav" -CHANNEL1 WAVE DISCARDABLE "..\\sounds\\channel1.wav" -DRAW WAVE DISCARDABLE "..\\sounds\\draw.wav" -KIBITZ WAVE DISCARDABLE "..\\sounds\\kibitz.wav" -LOSE WAVE DISCARDABLE "..\\sounds\\lose.wav" -REQUEST WAVE DISCARDABLE "..\\sounds\\request.wav" -SEEK WAVE DISCARDABLE "..\\sounds\\seek.wav" -SHOUT WAVE DISCARDABLE "..\\sounds\\shout.wav" -SSHOUT WAVE DISCARDABLE "..\\sounds\\sshout.wav" -TELL WAVE DISCARDABLE "..\\sounds\\tell.wav" -UNFINISHED WAVE DISCARDABLE "..\\sounds\\unfinished.wav" -WIN WAVE DISCARDABLE "..\\sounds\\win.wav" +DING WAVE DISCARDABLE "sounds\\ding1.wav" +CHING WAVE DISCARDABLE "sounds\\ching.wav" +CLICK WAVE DISCARDABLE "sounds\\click.wav" +CYMBAL WAVE DISCARDABLE "sounds\\cymbal.wav" +DRIP WAVE DISCARDABLE "sounds\\drip.wav" +GONG WAVE DISCARDABLE "sounds\\gong.wav" +BEEPBEEP WAVE DISCARDABLE "sounds\\honkhonk.wav" +LASER WAVE DISCARDABLE "sounds\\laser.wav" +PENALTY WAVE DISCARDABLE "sounds\\penalty.wav" +PHONE WAVE DISCARDABLE "sounds\\phone.wav" +POP WAVE DISCARDABLE "sounds\\pop.wav" +POP2 WAVE DISCARDABLE "sounds\\pop2.wav" +SLAP WAVE DISCARDABLE "sounds\\slap.wav" +SQUEAK WAVE DISCARDABLE "sounds\\squeak.wav" +SWISH WAVE DISCARDABLE "sounds\\swish.wav" +THUD WAVE DISCARDABLE "sounds\\thud.wav" +WHIPCRACK WAVE DISCARDABLE "sounds\\whipcrak.wav" +MOVE WAVE DISCARDABLE "sounds\\move.wav" +ALARM WAVE DISCARDABLE "sounds\\alarm.wav" +CHALLENGE WAVE DISCARDABLE "sounds\\challenge.wav" +CHANNEL WAVE DISCARDABLE "sounds\\channel.wav" +CHANNEL1 WAVE DISCARDABLE "sounds\\channel1.wav" +DRAW WAVE DISCARDABLE "sounds\\draw.wav" +KIBITZ WAVE DISCARDABLE "sounds\\kibitz.wav" +LOSE WAVE DISCARDABLE "sounds\\lose.wav" +REQUEST WAVE DISCARDABLE "sounds\\request.wav" +SEEK WAVE DISCARDABLE "sounds\\seek.wav" +SHOUT WAVE DISCARDABLE "sounds\\shout.wav" +SSHOUT WAVE DISCARDABLE "sounds\\sshout.wav" +TELL WAVE DISCARDABLE "sounds\\tell.wav" +UNFINISHED WAVE DISCARDABLE "sounds\\unfinished.wav" +WIN WAVE DISCARDABLE "sounds\\win.wav" #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/winboard/wplugin.c b/winboard/wplugin.c new file mode 100644 index 0000000..6213680 --- /dev/null +++ b/winboard/wplugin.c @@ -0,0 +1,225 @@ +#include "wplugin.h" + +static char * makePluginExeName( const char * name ) +{ + char buf[ MAX_PATH ]; + + strcpy( buf, "" ); + + strcat( buf, "plugins\\" ); + strcat( buf, name ); + strcat( buf, ".exe" ); + + return strdup( buf ); +} + +WbPlugin * wbpCreate( const char * name ) +{ + char buf[MAX_PATH]; + int result = 0; + + // Create the plugin + WbPlugin * plugin = (WbPlugin *) malloc( sizeof(WbPlugin) ); + + memset( plugin, 0, sizeof(WbPlugin) ); + + plugin->name_ = strdup( name ); + plugin->exe_name_ = makePluginExeName( name ); + plugin->hPipe_ = INVALID_HANDLE_VALUE; + plugin->hProcess_ = INVALID_HANDLE_VALUE; + + // Create the named pipe for plugin communication + if( result == 0 ) { + strcpy( buf, "\\\\.\\pipe\\" ); + strcat( buf, name ); + + plugin->hPipe_ = CreateNamedPipe( buf, + PIPE_ACCESS_DUPLEX, + 0, // Byte mode + 2, // Max instances + 4*1024, + 4*1024, + 1000, // Default timeout + NULL ); + + if( plugin->hPipe_ == INVALID_HANDLE_VALUE ) { + DWORD err = GetLastError(); + result = -1; + } + } + + // Create the plugin process + if( result == 0 ) { + STARTUPINFO si; + PROCESS_INFORMATION pi; + + ZeroMemory( &si, sizeof(si) ); + ZeroMemory( &pi, sizeof(pi) ); + + si.cb = sizeof(si); + + strcpy( buf, "\"" ); + strcat( buf, plugin->exe_name_ ); + strcat( buf, "\"" ); + + strcpy( buf, "\"C:\\Program Files\\Borland\\Delphi5\\Projects\\History\\History.exe\"" ); + + if( CreateProcess( NULL, + buf, + NULL, + NULL, + FALSE, // Inherit handles + 0, // Creation flags + NULL, // Environment + NULL, // Current directory + &si, + &pi ) ) + { + CloseHandle( pi.hThread ); + plugin->hProcess_ = pi.hProcess; + } + else { + result = -2; + } + } + + // Destroy the plugin instance if something went wrong + if( result != 0 ) { + wbpDelete( plugin ); + plugin = 0; + } + + return plugin; +} + +void wbpDelete( WbPlugin * plugin ) +{ + if( plugin != 0 ) { + if( plugin->hPipe_ != INVALID_HANDLE_VALUE ) { + CloseHandle( plugin->hPipe_ ); + } + + if( plugin->hProcess_ != INVALID_HANDLE_VALUE ) { + CloseHandle( plugin->hProcess_ ); + } + + free( plugin->name_ ); + + free( plugin->exe_name_ ); + + plugin->name_ = 0; + plugin->exe_name_ = 0; + plugin->hPipe_ = INVALID_HANDLE_VALUE; + plugin->hProcess_ = INVALID_HANDLE_VALUE; + + free( plugin ); + } +} + +int wbpSendMessage( WbPlugin * plugin, const char * msg, size_t msg_len ) +{ + int result = -1; + + if( plugin != 0 && plugin->hPipe_ != INVALID_HANDLE_VALUE ) { + DWORD zf = 0; + BOOL ok = TRUE; + + while( ok && (msg_len > 0) ) { + DWORD cb = 0; + + ok = WriteFile( plugin->hPipe_, + msg, + msg_len, + &cb, + NULL ); + + if( ok ) { + if( cb > msg_len ) break; // Should *never* happen! + + msg_len -= cb; + msg += cb; + } + + if( cb == 0 ) { + zf++; + if( zf >= 3 ) ok = FALSE; + } + else { + zf = 0; + } + } + + if( ok ) { + result = 0; + } + } + + return result; +} + +int wbpListInit( WbPluginList * list ) +{ + list->item_count_ = 0; + + return 0; +} + +int wbpListAdd( WbPluginList * list, WbPlugin * plugin ) +{ + int result = -1; + + if( plugin != 0 ) { + if( list->item_count_ < MaxWbPlugins ) { + list->item_[ list->item_count_ ] = plugin; + list->item_count_++; + + result = 0; + } + } + + return result; +} + +WbPlugin * wbpListGet( WbPluginList * list, int index ) +{ + WbPlugin * result = 0; + + if( index >= 0 && index < list->item_count_ ) { + result = list->item_[ index ]; + } + + return result; +} + +int wbpListGetCount( WbPluginList * list ) +{ + return list->item_count_; +} + +int wbpListDeleteAll( WbPluginList * list ) +{ + int i; + + for( i=0; iitem_count_; i++ ) { + wbpDelete( list->item_[i] ); + } + + return wbpListInit( list ); +} + +int wbpListBroadcastMessage( WbPluginList * list, const char * msg, size_t msg_len ) +{ + int result = 0; + int i; + + for( i=0; iitem_count_; i++ ) { + if( wbpSendMessage( list->item_[i], msg, msg_len ) == 0 ) { + result++; + } + else { + // Error sending message to plugin... + } + } + + return result; +} diff --git a/winboard/wplugin.h b/winboard/wplugin.h new file mode 100644 index 0000000..100ae1c --- /dev/null +++ b/winboard/wplugin.h @@ -0,0 +1,40 @@ +#ifndef WPLUGIN_H_ +#define WPLUGIN_H_ + +#include + +#define MaxWbPlugins 16 + +typedef struct WbPlugin_tag +{ + char * name_; + char * exe_name_; + HANDLE hPipe_; + HANDLE hProcess_; +} WbPlugin; + +typedef struct WbPluginList_tag +{ + int item_count_; + WbPlugin * item_[MaxWbPlugins]; +} WbPluginList; + +WbPlugin * wbpCreate( const char * name ); + +void wbpDelete( WbPlugin * plugin ); + +int wbpSendMessage( WbPlugin * plugin, const char * msg, size_t msg_len ); + +int wbpListInit( WbPluginList * list ); + +int wbpListAdd( WbPluginList * list, WbPlugin * plugin ); + +WbPlugin * wbpListGet( WbPluginList * list, int index ); + +int wbpListGetCount( WbPluginList * list ); + +int wbpListDeleteAll( WbPluginList * list ); + +int wbpListBroadcastMessage( WbPluginList * list, const char * msg, size_t msg_len ); + +#endif // WPLUGIN_H_ diff --git a/zippy.c b/zippy.c index c295459..c15b0b3 100644 --- a/zippy.c +++ b/zippy.c @@ -1,6 +1,6 @@ /* * zippy.c -- Implements Zippy the Pinhead chess player on ICS in XBoard - * $Id$ + * $Id: zippy.c,v 2.2 2003/11/25 05:25:20 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-2001 Free Software Foundation, Inc. diff --git a/zippy.h b/zippy.h index 1a80b67..c8cf6e8 100644 --- a/zippy.h +++ b/zippy.h @@ -1,6 +1,6 @@ /* * zippy.h -- Interface to zippy.c module in XBoard - * $Id$ + * $Id: zippy.h,v 2.1 2003/10/27 19:21:01 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * Enhancements Copyright 1992-95 Free Software Foundation, Inc. -- 1.7.0.4