X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcommondsp.c;h=c00338a7afe11adbfb92f409a2242293a69b847e;hb=20d40511cdff77e1ecb01ea28861403e125a7549;hp=0b677b182c3e9db0154e8ba53a2f3a571065c3a7;hpb=00e10bc4a760150665436b17c50abf264f28d435;p=gnushogi.git diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 0b677b1..c00338a 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -4,11 +4,14 @@ * Common display routines for GNU Shogi. * * ---------------------------------------------------------------------- - * - * Copyright (c) 2012 Free Software Foundation + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * * This file is part of GNU SHOGI. * * GNU Shogi is free software; you can redistribute it and/or modify it @@ -125,6 +128,17 @@ movealgbr(short m, char *s) /* * Generate move strings in different formats. + * + * INPUT: + * - f piece to be moved + * - 0 < f < NO_SQUARES source square + * - NO_SQUARES <= f NO_SQUARES + 2*NO_PIECES dropped piece modulo NO_PIECES + * - t & 0x7f target square + * - t & 0x80 promotion flag + * - flag FIXME: must be zero ? + * + * OUTPUT: + * - GLOBAL mvstr */ void @@ -386,17 +400,17 @@ parser(char *f, int side, short *fpiece) if (f[1] == '*' || f[1] == '\'') { - c2 = '9' - f[2]; - r2 = 'i' - f[3]; + c2 = COL_NAME(f[2]); + r2 = ROW_NAME(f[3]); return ((NO_SQUARES + *fpiece) << 8) | locn(r2, c2); } else { - c1 = '9' - f[1]; - r1 = 'i' - f[2]; - c2 = '9' - f[3]; - r2 = 'i' - f[4]; + c1 = COL_NAME(f[1]); + r1 = ROW_NAME(f[2]); + c2 = COL_NAME(f[3]); + r2 = ROW_NAME(f[4]); p = (f[5] == '+') ? 0x80 : 0; return (locn(r1, c1) << 8) | locn(r2, c2) | p; @@ -707,16 +721,16 @@ SaveGame(void) fprintf(fd, CP[37], w, b, Game50, flag.force ? "force" : ""); - fprintf(fd, empty); + fputs(empty, fd); fprintf(fd, CP[111], TCflag, OperatorTime); fprintf(fd, CP[117], TimeControl.clock[black], TimeControl.moves[black], TimeControl.clock[white], TimeControl.moves[white]); - fprintf(fd, empty); + fputs(empty, fd); for (i = NO_ROWS - 1; i > -1; i--) { - fprintf(fd, "%c ", 'i' - i); + fprintf(fd, "%c ", ROW_NAME(i)); for (c = 0; c < NO_COLS; c++) { @@ -750,9 +764,9 @@ SaveGame(void) fprintf(fd, "\n"); } - fprintf(fd, empty); - fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); - fprintf(fd, empty); + fputs(empty, fd); + fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); /* FIXME */ + fputs(empty, fd); fprintf(fd, " p l n s g b r k\n"); for (side = 0; side <= 1; side++) @@ -769,8 +783,8 @@ SaveGame(void) fprintf(fd, "\n"); } - fprintf(fd, empty); - fprintf(fd, CP[126]); + fputs(empty, fd); + fputs(CP[126], fd); for (i = 1; i <= GameCnt; i++) { @@ -1200,8 +1214,8 @@ ListGame(void) /* fprintf(fd, "gnushogi game %d\n", u); */ fprintf(fd, CP[161], version, patchlevel); - fprintf(fd, CP[10]); - fprintf(fd, CP[11]); + fputs(CP[10], fd); + fputs(CP[11], fd); for (i = 1; i <= GameCnt; i++) { @@ -1731,8 +1745,8 @@ InputCommand(char *command) { s[0] = sx[0] = '\0'; - while(!sx[0]) - (void)fgets(sx, 80, stdin); + while(!eof && !sx[0]) + eof = (fgets(sx, 80, stdin) == NULL); } else { @@ -2147,8 +2161,6 @@ InputCommand(char *command) printf("\n"); #endif } - - signal(SIGUSR1, TerminateSearch); }