Hi there,

setbuf(3) etc "are obsoleted by setvbuf(3)" and "should be avoided".
The patch below replaces all occurrences in cat, sed & top.

Cheers,
Frederic

Index: cat/cat.1
===================================================================
RCS file: /cvs/src/bin/cat/cat.1,v
retrieving revision 1.34
diff -u -p -r1.34 cat.1
--- cat/cat.1   15 Jan 2015 19:06:31 -0000      1.34
+++ cat/cat.1   4 Nov 2015 20:24:19 -0000
@@ -82,7 +82,7 @@ option and also prints tab characters as
 .Ql ^I .
 .It Fl u
 The output is guaranteed to be unbuffered (see
-.Xr setbuf 3 ) .
+.Xr setvbuf 3 ) .
 .It Fl v
 Displays non-printing characters so they are visible.
 Control characters print as
@@ -149,7 +149,7 @@ operand.
 .Xr sh 1 ,
 .Xr tail 1 ,
 .Xr vis 1 ,
-.Xr setbuf 3
+.Xr setvbuf 3
 .Rs
 .%A Rob Pike
 .%T "UNIX Style, or cat -v Considered Harmful"
Index: cat/cat.c
===================================================================
RCS file: /cvs/src/bin/cat/cat.c,v
retrieving revision 1.23
diff -u -p -r1.23 cat.c
--- cat/cat.c   9 Oct 2015 01:37:06 -0000       1.23
+++ cat/cat.c   4 Nov 2015 20:24:19 -0000
@@ -87,7 +87,7 @@ main(int argc, char *argv[])
                        tflag = vflag = 1;      /* -t implies -v */
                        break;
                case 'u':
-                       setbuf(stdout, NULL);
+                       setvbuf(stdout, NULL, _IONBF, 0);
                        break;
                case 'v':
                        vflag = 1;
Index: sed/sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.46
diff -u -p -r1.46 sed.1
--- sed/sed.1   18 Jul 2015 09:33:00 -0000      1.46
+++ sed/sed.1   4 Nov 2015 20:35:12 -0000
@@ -122,7 +122,7 @@ printing each line as it becomes availab
 By default, output is line buffered when standard output is a terminal
 and block buffered otherwise.
 See
-.Xr setbuf 3
+.Xr setvbuf 3
 for a more detailed explanation.
 .El
 .Pp
Index: top/top.c
===================================================================
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.86
diff -u -p -r1.86 top.c
--- top/top.c   30 Oct 2015 13:57:33 -0000      1.86
+++ top/top.c   4 Nov 2015 20:35:12 -0000
@@ -288,9 +288,9 @@ main(int argc, char *argv[])
 
        /* set the buffer for stdout */
 #ifdef DEBUG
-       setbuffer(stdout, NULL, 0);
+       setvbuf(stdout, NULL, _IONBUF, 0);
 #else
-       setbuffer(stdout, stdoutbuf, sizeof stdoutbuf);
+       setvbuf(stdout, stdoutbuf, _IOFBF, sizeof stdoutbuf);
 #endif
 
        /* initialize some selection options */

Reply via email to