Drop -pedantic from default gcc flags and restore use of explicit initializer fields.
[gnushogi.git] / gnushogi / rawdsp.c
index e8e7b98..d868179 100644 (file)
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/file.h>
+#ifndef WIN32
 #include <poll.h>
 #include <unistd.h>
+#endif
 
 #include "gnushogi.h"
 #include "rawdsp.h"
@@ -217,6 +219,10 @@ Raw_Initialize(void)
 
     if (XSHOGI)
     {
+#ifdef WIN32
+        /* needed because of inconsistency between MSVC run-time system and gcc includes */
+        setbuf(stdout, NULL);
+#else
 #ifdef HAVE_SETLINEBUF
         setlinebuf(stdout);
 #else
@@ -226,6 +232,7 @@ Raw_Initialize(void)
 #    error "Need setlinebuf() or setvbuf() to compile gnushogi!"
 #  endif
 #endif
+#endif
         printf("GNU Shogi %s\n", PACKAGE_VERSION);
     }
 
@@ -944,13 +951,19 @@ Raw_ShowPostnValues(void)
 void
 Raw_PollForInput(void)
 {
-    static struct pollfd pollfds[1] = { /* [0] = */ { /* .fd = */ STDIN_FILENO,
-                                                      /* .events = */ POLLIN } };
+#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);
     if (cnt < 0) {
         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; */