]> git.pond.sub.org Git - empserver/commitdiff
(main) [_WIN32]: Windows putchar() screws up when printing multibyte
authorRon Koenderink <rkoenderink@yahoo.ca>
Thu, 30 Jun 2005 16:10:42 +0000 (16:10 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Thu, 30 Jun 2005 16:10:42 +0000 (16:10 +0000)
strings bytewise unless the stream is buffered.  Switch stdout to
line-buffered mode.
(login): Explicitly flush stdout, because Windows doesn't implement
line-buffering faithfully.

src/client/login.c
src/client/main.c

index 869eb1deb657bfe12b8971888d2a728866ff9768..f67f0a8ca9ee7159ad7b2b69d447dd858ffba10f 100644 (file)
@@ -71,6 +71,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc, int utf8)
     }
     if (cname == NULL) {
        (void)printf("Country name? ");
+       fflush(stdout);
        cname = fgets(tmp, sizeof(tmp), stdin);
        if (cname == NULL || *cname == 0)
            return 0;
@@ -91,6 +92,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc, int utf8)
 #else
        printf("Note: This is echoed to the screen\n");
        printf("Your name? ");
+       fflush(stdout);
        cpass = fgets(tmp, sizeof(tmp), stdin);
        if (cpass == NULL || *cpass == 0)
            return 0;
@@ -129,5 +131,6 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc, int utf8)
        printf("   this version: %d, current version: %d\n",
               CLIENTPROTO, atoi(ptr));
     }
+    fflush(stdout);
     return 1;
 }
index f56bd44f461a93dd205df3d0abeffaf6c6169304..7c84182363df7fdad7df6a42ac5ea7507e14be45 100644 (file)
@@ -109,6 +109,7 @@ main(int ac, char **av)
     int utf8 = 0;
 
 #ifdef _WIN32
+    setvbuf(stdout, NULL, _IOLBF, 4096);
     err = WSAStartup(0x0101, &WsaData);
     if (err == SOCKET_ERROR) {
        printf("WSAStartup Failed\n");