From owner-freebsd-bugs@FreeBSD.ORG Thu Jul 8 03:10:03 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E6EC16A4CE for ; Thu, 8 Jul 2004 03:10:03 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00AA843D49 for ; Thu, 8 Jul 2004 03:10:03 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i683A2LN053870 for ; Thu, 8 Jul 2004 03:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i683A2Yc053869; Thu, 8 Jul 2004 03:10:02 GMT (envelope-from gnats) Resent-Date: Thu, 8 Jul 2004 03:10:02 GMT Resent-Message-Id: <200407080310.i683A2Yc053869@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Ponte Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 939C716A4CE for ; Thu, 8 Jul 2004 03:01:28 +0000 (GMT) Received: from lakermmtao11.cox.net (lakermmtao11.cox.net [68.230.240.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id DDC8C43D53 for ; Thu, 8 Jul 2004 03:01:27 +0000 (GMT) (envelope-from dcp1990@styx.flinkpoyd.homeunix.com) Received: from styx.flinkpoyd.homeunix.com ([68.226.93.87]) by lakermmtao11.cox.netESMTP <20040708030127.CSCC25349.lakermmtao11.cox.net@styx.flinkpoyd.homeunix.com>; Wed, 7 Jul 2004 23:01:27 -0400 Received: by styx.flinkpoyd.homeunix.com (Postfix, from userid 1001) id A1EA04431; Wed, 7 Jul 2004 23:01:26 -0400 (EDT) Message-Id: <20040708030126.A1EA04431@styx.flinkpoyd.homeunix.com> Date: Wed, 7 Jul 2004 23:01:26 -0400 (EDT) From: Dan Ponte To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: amistry@am-productions.biz Subject: bin/68797: cut(1) patches to fflush after each write if an option is specified. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Ponte List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2004 03:10:03 -0000 >Number: 68797 >Category: bin >Synopsis: cut(1) patches to fflush after each write if an option is specified. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jul 08 03:10:02 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Dan Ponte >Release: FreeBSD 5.2.1-RELEASE-p9 i386 >Organization: Unix Users Anonymous >Environment: System: FreeBSD styx.cox.net 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #7: Thu Jul 1 13:17:08 EDT 2004 dcp1990@styx.cox.net:/usr/obj/usr/src/sys/STYX i386 >Description: Some applications require that the stream be flushed after each write (such as tail -f). This adds a new option, -u, that does this. >How-To-Repeat: (none) >Fix: Apply the following patches: --- cut.c.patch begins here --- --- /usr/src/usr.bin/cut/cut.c Wed Sep 4 19:28:59 2002 +++ cut.c Wed Jul 7 22:51:23 2004 @@ -59,6 +59,7 @@ int fflag; int nflag; int sflag; +int uflag; void b_n_cut(FILE *, const char *); void c_cut(FILE *, const char *); @@ -83,7 +84,7 @@ * Since we don't support multi-byte characters, the -c and -b * options are equivalent. */ - while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1) + while ((ch = getopt(argc, argv, "b:c:d:f:snu")) != -1) switch(ch) { case 'b': fcn = c_cut; @@ -110,6 +111,9 @@ case 'n': nflag = 1; break; + case 'u': + uflag = 1; + break; case '?': default: usage(); @@ -268,6 +272,8 @@ canwrite &= positions[1 + i]; if (canwrite) fwrite(lbuf, 1, clen, stdout); + if(uflag) + fflush(stdout); } else { /* * Print the character if all of it has @@ -282,6 +288,8 @@ } if (canwrite) fwrite(lbuf, 1, clen, stdout); + if(uflag) + fflush(stdout); } lbuf += clen; lbuflen -= clen; @@ -349,6 +357,8 @@ if (ch == '\n') { if (!isdelim && !sflag) (void)fwrite(lbuf, lbuflen, 1, stdout); + if(uflag) + fflush(stdout); break; } } @@ -388,8 +398,8 @@ usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: cut -b list [-n] [file ...]", - " cut -c list [file ...]", - " cut -f list [-s] [-d delim] [file ...]"); + "usage: cut -b list [-nu] [file ...]", + " cut -c list [-u] [file ...]", + " cut -f list [-su] [-d delim] [file ...]"); exit(1); } --- cut.c.patch ends here --- --- cut.1.patch begins here --- --- /usr/src/usr.bin/cut/cut.1 Sat May 3 11:55:23 2003 +++ cut.1 Wed Jul 7 22:54:45 2004 @@ -116,6 +116,8 @@ .It Fl s Suppress lines with no field delimiter characters. Unless specified, lines with no delimiters are passed through unmodified. +.It Fl u +Flush the output stream after every write. Useful for applications involving tail -f and similar ``keep-stream-open'' applications. .El .Sh ENVIRONMENT The --- cut.1.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: