From owner-freebsd-current@FreeBSD.ORG Fri Sep 1 20:55:40 2006 Return-Path: X-Original-To: freebsd-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 AB83316A4DA for ; Fri, 1 Sep 2006 20:55:40 +0000 (UTC) (envelope-from faber@ISI.EDU) Received: from boreas.isi.edu (boreas.isi.edu [128.9.160.161]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4B7BB43D6A for ; Fri, 1 Sep 2006 20:55:27 +0000 (GMT) (envelope-from faber@ISI.EDU) Received: from hut.isi.edu (hut.isi.edu [128.9.168.160]) by boreas.isi.edu (8.13.8/8.13.6) with ESMTP id k81KsTdD023102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 1 Sep 2006 13:54:29 -0700 (PDT) Received: (from faber@localhost) by hut.isi.edu (8.13.8/8.13.8/Submit) id k81KsTZT025081; Fri, 1 Sep 2006 13:54:29 -0700 (PDT) (envelope-from faber) Date: Fri, 1 Sep 2006 13:54:29 -0700 From: Ted Faber To: Julian Elischer Message-ID: <20060901205429.GF20006@hut.isi.edu> References: <200609011707.k81H7Ych050627@lurza.secnetix.de> <44F892AE.8040409@elischer.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Y/WcH0a6A93yCHGr" Content-Disposition: inline In-Reply-To: <44F892AE.8040409@elischer.org> User-Agent: Mutt/1.4.2.2i X-url: http://www.isi.edu/~faber X-ISI-4-43-8-MailScanner: Found to be clean X-MailScanner-From: faber@hut.isi.edu Cc: freebsd-current@freebsd.org, Oliver Fromme 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: Fri, 01 Sep 2006 20:55:40 -0000 --Y/WcH0a6A93yCHGr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 01, 2006 at 01:06:06PM -0700, Julian Elischer wrote: > Oliver Fromme wrote: >=20 > >Julian Elischer wrote: > >> Oliver Fromme wrote: > >> > John Baldwin wrote: > >> > > Oliver Fromme wrote: > >> > > > There's another possibility, which doesn't require a new > >> > > > option letter at all. You could add a new escape sequence > >> > > > to the format string, e.g. "%*". Whenever date(1) is > >> > > > called with a format string containing that sequence, it > >> > > > goes into filter mode and replaces the sequence with the > >> > > > current line. That would also enable you to be more > >> > > > flexible with the placement of the timestamps. > >> > > > For example: > >> > > >=20 > >> > > > $ printf 'foo\nbar\nbaz\n' | date +'%H:%M:%S %*' > >> > > > 16:39:58 foo > >> > > > 16:39:58 bar > >> > > > 16:39:58 baz > >> > >=20 > >> > > I prefer this of all the suggestions so far. > >> >=20 > >> > It's not very difficult, so I created a patch which does > >> > exactly that (includes an addition for the manpage, too). > >> > I've submitted it as bin/102609: > >> >=20 > >> > http://www.freebsd.org/cgi/query-pr.cgi?pr=3D102609 > >>=20 > >> A couple of comments: > >>=20 > >> you don't need to run strftime for each line if the time hasn't change= d. > >> (My original patch checks this) > > > >Good idea. I'll update the patch. > > > >> What is the effective maximum line length for a single fgetln? > > > >It's unlimited. fgetln() allocates sufficient amount of > >memory dynamically, that's why I used it instead of fgets(). > >It avoids reinventing the wheel. > >=20 > > >=20 > NOTHING is unlimitted. > what happens with a 3GB sequence of characters with no newlines? $ man fgetln [ ... ]=20 The fgetln() function may also fail and set errno for any of the errors specified for the routines fflush(3), malloc(3), read(2), stat(2), or realloc(3). [...] Looking at realloc, it sounds like you'll either get a 3GB string or NULL and ENOMEM in errno. --=20 Ted Faber http://www.isi.edu/~faber PGP: http://www.isi.edu/~faber/pubkeys.= asc Unexpected attachment on this mail? See http://www.isi.edu/~faber/FAQ.html#= SIG --Y/WcH0a6A93yCHGr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFE+J4EaUz3f+Zf+XsRAu4/AKDSp2uRCEp1g32e2sOgKOa/grh/DACghkWg jO4PYBn50HBE0Ow88B0zzhA= =pFp9 -----END PGP SIGNATURE----- --Y/WcH0a6A93yCHGr--