X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Frawdsp.c;h=287e578e4146033dd345ad17afe4e67d6acaf2fc;hb=97a3bafdbb2b8f5c48c78b4aabfaaf2b9c329934;hp=4125d47957b3154d130ae42dd278e7d346b6498e;hpb=95369c6cb63d6513f7381dc3cc92c1f34044c607;p=gnushogi.git diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 4125d47..287e578 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -4,6 +4,7 @@ * ---------------------------------------------------------------------- * Copyright (c) 1993, 1994, 1995 Matthias Mutz * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * @@ -35,8 +36,10 @@ #include #include #include +#ifndef WIN32 #include #include +#endif #include "gnushogi.h" #include "rawdsp.h" @@ -217,16 +220,21 @@ Raw_Initialize(void) if (XSHOGI) { -#ifdef HAVE_SETLINEBUF - setlinebuf(stdout); +#ifdef WIN32 + /* needed because of inconsistency between MSVC run-time system and gcc includes */ + setbuf(stdout, NULL); #else -# ifdef HAVE_SETVBUF +#ifdef HAVE_SETVBUF setvbuf(stdout, NULL, _IOLBF, BUFSIZ); +#else +# ifdef HAVE_SETLINEBUF + setlinebuf(stdout); # else -# error "Need setlinebuf() or setvbuf() to compile gnushogi!" +# error "Need setvbuf() or setlinebuf() to compile gnushogi!" # endif #endif - printf("GNU Shogi %sp%s\n", version, patchlevel); +#endif + printf("GNU Shogi %s\n", PACKAGE_VERSION); } if (hard_time_limit) @@ -281,7 +289,7 @@ void Raw_help(void) { Raw_ClearScreen(); - printf("GNU Shogi %sp%s command summary\n", version, patchlevel); + printf("GNU Shogi %s command summary\n", PACKAGE_VERSION); printf("----------------------------------" "------------------------------\n"); fputs ("7g7f move from 7g to 7f quit Exit Shogi\n", stdout); @@ -341,11 +349,14 @@ Raw_EditBoard(void) a = black; - do + while(1) { scanf("%s", s); found = 0; + if (s[0] == '.') + break; + if (s[0] == '#') { for (sq = 0; sq < NO_SQUARES; sq++) @@ -377,8 +388,8 @@ Raw_EditBoard(void) } else { - c = COL_NAME(s[1]); - r = ROW_NAME(s[2]); + c = COL_NUM(s[1]); + r = ROW_NUM(s[2]); } if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) @@ -405,7 +416,6 @@ Raw_EditBoard(void) color[sq] = neutral; } } - while (s[0] != '.'); for (sq = 0; sq < NO_SQUARES; sq++) Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0); @@ -944,6 +954,11 @@ Raw_ShowPostnValues(void) void Raw_PollForInput(void) { +#ifdef WIN32 + DWORD cnt; + if (!PeekNamedPipe(GetStdHandle(STD_INPUT_HANDLE), NULL, 0, NULL, &cnt, NULL)) + cnt = 1; +#else static struct pollfd pollfds[1] = { /* [0] = */ { /* .fd = */ STDIN_FILENO, /* .events = */ POLLIN } }; int cnt = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 0); @@ -951,6 +966,7 @@ Raw_PollForInput(void) perror("polling standard input"); ExitShogi(); } +#endif if (cnt) { /* if anything to read, or error occured */ if (!flag.timeout) flag.back = true; /* previous: flag.timeout = true; */