From owner-freebsd-current@FreeBSD.ORG Sat Aug 12 04:31:15 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 7F10D16A4E1; Sat, 12 Aug 2006 04:31:15 +0000 (UTC) (envelope-from prvs=julian=372565577@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3B23B43D46; Sat, 12 Aug 2006 04:31:15 +0000 (GMT) (envelope-from prvs=julian=372565577@elischer.org) Received: from unknown (HELO [192.168.2.3]) ([10.251.60.35]) by a50.ironport.com with ESMTP; 11 Aug 2006 21:31:15 -0700 Message-ID: <44DD5992.5080409@elischer.org> Date: Fri, 11 Aug 2006 21:31:14 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.13) Gecko/20060414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Giorgos Keramidas References: <44DD4510.5070002@elischer.org> <20060812033607.GB80768@gothmog.pc> <44DD50FF.5040406@elischer.org> <20060812041535.GA82669@gothmog.pc> In-Reply-To: <20060812041535.GA82669@gothmog.pc> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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:31:15 -0000 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? > ha! > 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 > err(1, "stdout"); > } > } ... > >_______________________________________________ >freebsd-current@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-current >To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > >