Hi there,

setbuf(3) etc "are obsoleted by setvbuf(3)" and "should be avoided".
The patch below updates all occurrences in src/games.

Cheers,
Frederic


Index: atc/graphics.c
===================================================================
RCS file: /cvs/src/games/atc/graphics.c,v
retrieving revision 1.9
diff -u -p -r1.9 graphics.c
--- atc/graphics.c      13 Jul 2014 13:00:40 -0000      1.9
+++ atc/graphics.c      4 Nov 2015 20:27:10 -0000
@@ -117,7 +117,7 @@ setup_screen(const C_SCREEN *scp)
                endwin();
                errx(1, "screen too small.");
        }
-       setbuf(stdout, buffer);
+       setvbuf(stdout, buffer, _IOFBF, sizeof buffer);
        input = newwin(INPUT_LINES, COLS - PLANE_COLS, LINES - INPUT_LINES,
0);
        credit = newwin(INPUT_LINES, PLANE_COLS, LINES - INPUT_LINES, 
                COLS - PLANE_COLS);
Index: gomoku/main.c
===================================================================
RCS file: /cvs/src/games/gomoku/main.c,v
retrieving revision 1.27
diff -u -p -r1.27 main.c
--- gomoku/main.c       7 Dec 2014 19:56:19 -0000       1.27
+++ gomoku/main.c       4 Nov 2015 20:27:10 -0000
@@ -155,7 +155,7 @@ again:
                        clrtoeol();
                }
        } else {
-               setbuf(stdout, 0);
+               setvbuf(stdout, NULL, _IONBF, 0);
                get_line(buf, sizeof(buf));
                if (strcmp(buf, "black") == 0)
                        color = BLACK;
Index: hack/hack.main.c
===================================================================
RCS file: /cvs/src/games/hack/hack.main.c,v
retrieving revision 1.17
diff -u -p -r1.17 hack.main.c
--- hack/hack.main.c    27 Sep 2015 05:13:11 -0000      1.17
+++ hack/hack.main.c    4 Nov 2015 20:27:10 -0000
@@ -175,7 +175,7 @@ main(int argc, char **argv)
         * Remember tty modes, to be restored on exit.
         */
        gettty();
-       setbuf(stdout,obuf);
+       setvbuf(stdout, obuf, _IOFBF, sizeof obuf);
        umask(007);
        startup();
        cls();
Index: mille/mille.c
===================================================================
RCS file: /cvs/src/games/mille/mille.c,v
retrieving revision 1.20
diff -u -p -r1.20 mille.c
--- mille/mille.c       19 Jan 2015 00:47:01 -0000      1.20
+++ mille/mille.c       4 Nov 2015 20:27:10 -0000
@@ -48,7 +48,7 @@ main(ac, av)
 #ifdef DEBUG
        if (strcmp(av[0], "a.out") == 0) {
                outf = fopen("q", "w");
-               setbuf(outf, (char *)NULL);
+               setvbuf(outf, NULL, _IONBF, 0);
                Debug = TRUE;
        }
 #endif
Index: mille/move.c
===================================================================
RCS file: /cvs/src/games/mille/move.c,v
retrieving revision 1.14
diff -u -p -r1.14 move.c
--- mille/move.c        24 Oct 2015 17:51:59 -0000      1.14
+++ mille/move.c        4 Nov 2015 20:27:10 -0000
@@ -442,7 +442,7 @@ over:
                                leaveok(Board, TRUE);
                                if ((outf = fopen(buf, "w")) == NULL)
                                        warn("%s", buf);
-                               setbuf(outf, (char *)NULL);
+                               setvbuf(outf, NULL, _IONBF, 0);
                        }
                        Debug = !Debug;
                        break;
Index: mille/varpush.c
===================================================================
RCS file: /cvs/src/games/mille/varpush.c,v
retrieving revision 1.8
diff -u -p -r1.8 varpush.c
--- mille/varpush.c     19 Jan 2015 00:47:01 -0000      1.8
+++ mille/varpush.c     4 Nov 2015 20:27:10 -0000
@@ -85,7 +85,7 @@ over:
                                goto over;
                        }
                        if (strcmp(buf, _PATH_DEVNULL) != 0)
-                               setbuf(outf, (char *)NULL);
+                               setvbuf(outf, NULL, _IONBF, 0);
                }
 #endif
        } else {
Index: random/random.c
===================================================================
RCS file: /cvs/src/games/random/random.c,v
retrieving revision 1.13
diff -u -p -r1.13 random.c
--- random/random.c     14 Oct 2015 08:12:12 -0000      1.13
+++ random/random.c     4 Nov 2015 20:27:10 -0000
@@ -101,7 +101,7 @@ main(int argc, char *argv[])
         * to write to the standard output.
         */
        if (unbuffer_output)
-               setbuf(stdout, NULL);
+               setvbuf(stdout, NULL, _IONBF, 0);
        
        /*
         * Select whether to print the first line.  (Prime the pump.)
Index: worm/worm.c
===================================================================
RCS file: /cvs/src/games/worm/worm.c,v
retrieving revision 1.32
diff -u -p -r1.32 worm.c
--- worm/worm.c 26 Aug 2015 01:25:57 -0000      1.32
+++ worm/worm.c 4 Nov 2015 20:27:10 -0000
@@ -94,7 +94,7 @@ main(int argc, char **argv)
 
        timespecclear(&t);
 
-       setbuf(stdout, outbuf);
+       setvbuf(stdout, outbuf, _IOFBF, sizeof outbuf);
        signal(SIGINT, leave);
        signal(SIGQUIT, leave);
        signal(SIGTSTP, suspend);       /* process control signal */

Reply via email to