From owner-freebsd-current@FreeBSD.ORG Sat Aug 12 04:16:05 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 A5BC016A4DE for ; Sat, 12 Aug 2006 04:16:05 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8AAB743D49 for ; Sat, 12 Aug 2006 04:16:03 +0000 (GMT) (envelope-from keramida@FreeBSD.org) 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 k7C4FZ0l009631 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 12 Aug 2006 07:15:37 +0300 Received: from gothmog.pc (gothmog [127.0.0.1]) by gothmog.pc (8.13.7/8.13.7) with ESMTP id k7C4FZPg082890; Sat, 12 Aug 2006 07:15:35 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Received: (from giorgos@localhost) by gothmog.pc (8.13.7/8.13.7/Submit) id k7C4FZjg082889; Sat, 12 Aug 2006 07:15:35 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Sat, 12 Aug 2006 07:15:35 +0300 From: Giorgos Keramidas To: Julian Elischer Message-ID: <20060812041535.GA82669@gothmog.pc> References: <44DD4510.5070002@elischer.org> <20060812033607.GB80768@gothmog.pc> <44DD50FF.5040406@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44DD50FF.5040406@elischer.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.317, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.08, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org 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:16:05 -0000 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? Maybe something like this? if (sflag) { int ch; time_t otval = 0; while ((ch = getchar()) != EOF) { putchar(ch); if (ch != '\n') continue; if (rlfag == 0 && time(&tval) == -1) err(1, "time"); if (tval != otval) { lt = *localtime(&tval); badv = vary_apply(v, <); if (badv) { fprintf(stderr, "%s: Cannot apply date adjustment\n", badv->arg); vary_destroy(v); usage(); } (void)strftime(buf, sizeof(buf), format, <); otval = tval; } (void)printf("%s", buf); if (fflush(stdout)) err(1, "stdout"); } } ...