From owner-freebsd-current@FreeBSD.ORG Sat Aug 12 04:56:56 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9FB9716A4E7 for ; Sat, 12 Aug 2006 04:56:56 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id BE3FF43D53 for ; Sat, 12 Aug 2006 04:56:54 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.pc (host5.bedc.ondsl.gr [62.103.39.229]) (authenticated bits=128) by igloo.linux.gr (8.13.7/8.13.7/Debian-2) with ESMTP id k7C4uNCS010373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 12 Aug 2006 07:56:24 +0300 Received: from gothmog.pc (gothmog [127.0.0.1]) by gothmog.pc (8.13.7/8.13.7) with ESMTP id k7C4uN4n084430; Sat, 12 Aug 2006 07:56:23 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.pc (8.13.7/8.13.7/Submit) id k7C4uMtK084429; Sat, 12 Aug 2006 07:56:22 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 12 Aug 2006 07:56:22 +0300 From: Giorgos Keramidas To: Julian Elischer Message-ID: <20060812045622.GA84354@gothmog.pc> References: <44DD4510.5070002@elischer.org> <20060812033607.GB80768@gothmog.pc> <44DD50FF.5040406@elischer.org> <20060812041535.GA82669@gothmog.pc> <44DD5992.5080409@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44DD5992.5080409@elischer.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.814, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.58, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: current@freebsd.org Subject: Re: suggested addition to 'date' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Aug 2006 04:56:56 -0000 On 2006-08-11 21:31, Julian Elischer wrote: >Giorgos Keramidas wrote: >>On 2006-08-11 20:54, Julian Elischer wrote: >>> Yes I said I hacked it in :-) >>> In my app you will never have such long lines.. >>> basically you need something that reads lines and tells you how much it >>> read.. >>> (I have no idea WHY fgets need sto return the START.. you already KNOW >>> that!) >>> it'd be nice if you didn't have to to a strlen() on each line. >> >> Perhaps the solution Sam proposed is much better then? >> >>To read one >>character at-a-time and only special-case the '\n' characters? > > I didn't see that being mentionned anywhere, but I guess compared to > running date once for every line > I could live with a strlen(). :-) > it'd probably be more efficient than doing it one char at a time. > > >Maybe something like this? > > > > if (sflag) { > > > > > > > [...] > > > otval = tval; > > } > > (void)printf("%s", buf); > > if (fflush(stdout)) > > > > > > wonder if it would want to be flushed less often if stdout was a file.. > I think stdio would do the right thing in most cases so I guess teh > fflush woudl only be needed at the end, after the last file, > or maybe just on a signal handler so it flushes out the last buffer on ^C IIRC, stdio can buffer more than one line, so now that you mention it, maybe it is a good idea to flush at every '\n' character to make output appear every time there's a complete line ready. I'm too sleepy to run tests now, but if you still want something inside date(1) -- which is probably the only logical place to put it (to let us leverage the date/time formatting code date(1) already has) -- then I can run a few tests during the weekend and see which approach works better, for some definition of `better' :-)