From owner-freebsd-standards@FreeBSD.ORG Sun Sep 5 19:36:41 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 48ABB16A4D0 for ; Sun, 5 Sep 2004 19:36:41 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 122BE43D46 for ; Sun, 5 Sep 2004 19:36:41 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) i85JaeS9037237 for ; Sun, 5 Sep 2004 12:36:40 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost)i85JaeQe037236 for freebsd-standards@freebsd.org; Sun, 5 Sep 2004 12:36:40 -0700 (PDT) (envelope-from sgk) Date: Sun, 5 Sep 2004 12:36:40 -0700 From: Steve Kargl To: freebsd-standards@freebsd.org Message-ID: <20040905193640.GA37190@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: is printf() broken? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Sep 2004 19:36:41 -0000 The following program #include int main(void) { int d; double x; x = 1.234E05; for (d = 0; d < 5; d++) printf("%+-31.*e\n", d, x); return 0; } generates +1e+05 +1.2e+05 +1.23e+05 +1.234e+05 +1.2340e+05 The question is whether the first number should be "+1.e+05". That is, is the printing of the decimal point required or optional? I only have Harbison and Steele's book and it does not state what the expected behavior should be. -- Steve From owner-freebsd-standards@FreeBSD.ORG Sun Sep 5 19:51:56 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E25016A4CE for ; Sun, 5 Sep 2004 19:51:56 +0000 (GMT) Received: from av15-1-sn4.m-sp.skanova.net (av15-1-sn4.m-sp.skanova.net [81.228.10.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id 22B3B43D31 for ; Sun, 5 Sep 2004 19:51:55 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: by av15-1-sn4.m-sp.skanova.net (Postfix, from userid 502) id F0E0B37E49; Sun, 5 Sep 2004 21:51:53 +0200 (CEST) Received: from smtp4-2-sn4.m-sp.skanova.net (smtp4-2-sn4.m-sp.skanova.net [81.228.10.180]) by av15-1-sn4.m-sp.skanova.net (Postfix) with ESMTP id DBDD237E42 for ; Sun, 5 Sep 2004 21:51:53 +0200 (CEST) Received: from falcon.midgard.homeip.net (h201n1fls24o1048.bredband.comhem.se [212.181.162.201]) by smtp4-2-sn4.m-sp.skanova.net (Postfix) with SMTP id AC1C437E45 for ; Sun, 5 Sep 2004 21:51:53 +0200 (CEST) Received: (qmail 9236 invoked by uid 1001); 5 Sep 2004 19:51:53 -0000 Date: Sun, 5 Sep 2004 21:51:52 +0200 From: Erik Trulsson To: Steve Kargl Message-ID: <20040905195152.GA6096@falcon.midgard.homeip.net> Mail-Followup-To: Steve Kargl , freebsd-standards@freebsd.org References: <20040905193640.GA37190@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040905193640.GA37190@troutmask.apl.washington.edu> User-Agent: Mutt/1.5.6i cc: freebsd-standards@freebsd.org Subject: Re: is printf() broken? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Sep 2004 19:51:56 -0000 On Sun, Sep 05, 2004 at 12:36:40PM -0700, Steve Kargl wrote: > The following program > > #include > int main(void) { > int d; > double x; > x = 1.234E05; > for (d = 0; d < 5; d++) > printf("%+-31.*e\n", d, x); > return 0; > } > > generates > > +1e+05 > +1.2e+05 > +1.23e+05 > +1.234e+05 > +1.2340e+05 > > The question is whether the first number should be > "+1.e+05". That is, is the printing of the decimal > point required or optional? I only have Harbison > and Steele's book and it does not state what the > expected behavior should be. I believe printf() is correct, and that the printing of the decimal point for the first number above is neither required nor optional but actually not allowed at all >From Harbison & Steele 5th edition: The e and E conversions [...] If the precision is 0, then no digits appear after the decimal point. Moreover the decimal point also does not appear unless the # flag is present. (Nearly identical text is also in H&S 3rd edition.) >From n869.txt (the last publically available draft of C99) [the e and E conversions for fprintf] [...] if the precision is zero and the # flag is not specified, no decimal-point character appears -- Erik Trulsson ertr1013@student.uu.se From owner-freebsd-standards@FreeBSD.ORG Sun Sep 5 19:56:54 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 16E2016A4CE for ; Sun, 5 Sep 2004 19:56:54 +0000 (GMT) Received: from bgezal.rise.tuwien.ac.at (bgezal.rise.tuwien.ac.at [128.130.59.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9ABD743D53 for ; Sun, 5 Sep 2004 19:56:49 +0000 (GMT) (envelope-from stefan@fafoe.narf.at) Received: from fafoe.narf.at (unknown [212.186.3.235]) by bgezal.rise.tuwien.ac.at (Postfix) with ESMTP id A803620A2; Sun, 5 Sep 2004 21:56:47 +0200 (CEST) Received: from wombat.fafoe.narf.at (wombat.fafoe.narf.at [192.168.1.42]) by fafoe.narf.at (Postfix) with ESMTP id 62F9740EE; Sun, 5 Sep 2004 21:56:41 +0200 (CEST) Received: by wombat.fafoe.narf.at (Postfix, from userid 1001) id 165ECDC; Sun, 5 Sep 2004 21:56:38 +0200 (CEST) Date: Sun, 5 Sep 2004 21:56:38 +0200 From: Stefan Farfeleder To: Steve Kargl Message-ID: <20040905195632.GG72545@wombat.fafoe.narf.at> Mail-Followup-To: Steve Kargl , freebsd-standards@freebsd.org References: <20040905193640.GA37190@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040905193640.GA37190@troutmask.apl.washington.edu> User-Agent: Mutt/1.5.6i cc: freebsd-standards@freebsd.org Subject: Re: is printf() broken? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Sep 2004 19:56:54 -0000 On Sun, Sep 05, 2004 at 12:36:40PM -0700, Steve Kargl wrote: > The following program > > #include > int main(void) { > int d; > double x; > x = 1.234E05; > for (d = 0; d < 5; d++) > printf("%+-31.*e\n", d, x); > return 0; > } > > generates > > +1e+05 > +1.2e+05 > +1.23e+05 > +1.234e+05 > +1.2340e+05 > > The question is whether the first number should be > "+1.e+05". That is, is the printing of the decimal > point required or optional? I only have Harbison > and Steele's book and it does not state what the > expected behavior should be. The output is correct: e, E A double argument representing a floating-point number is converted in the style [-]d.ddd eħdd, where there is one digit (which is nonzero if the argument is nonzero) before the decimal-point character and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the precision is zero and the # flag is not specified, no decimal-point character appears. The value is rounded to the appropriate number of digits. [...] Cheers, Stefan From owner-freebsd-standards@FreeBSD.ORG Sun Sep 5 20:04:28 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0674816A4CE for ; Sun, 5 Sep 2004 20:04:28 +0000 (GMT) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id DCE1C43D39 for ; Sun, 5 Sep 2004 20:04:27 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) i85K4R3H037387 for ; Sun, 5 Sep 2004 13:04:27 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost)i85K4RT9037386 for freebsd-standards@freebsd.org; Sun, 5 Sep 2004 13:04:27 -0700 (PDT) (envelope-from sgk) Date: Sun, 5 Sep 2004 13:04:27 -0700 From: Steve Kargl To: freebsd-standards@freebsd.org Message-ID: <20040905200427.GA37254@troutmask.apl.washington.edu> References: <20040905193640.GA37190@troutmask.apl.washington.edu> <20040905195152.GA6096@falcon.midgard.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040905195152.GA6096@falcon.midgard.homeip.net> User-Agent: Mutt/1.4.1i Subject: Re: is printf() broken? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Sep 2004 20:04:28 -0000 On Sun, Sep 05, 2004 at 09:51:52PM +0200, Erik Trulsson wrote: > On Sun, Sep 05, 2004 at 12:36:40PM -0700, Steve Kargl wrote: > > >From Harbison & Steele 5th edition: > > The e and E conversions > [...] > If the precision is 0, then no digits appear after the decimal point. > Moreover the decimal point also does not appear unless the # flag is > present. > Thanks. I was reading section 15.11.5 of H&S. I did not think to actually look at the "e and E conversion" section. Sorry about the noise. -- Steve From owner-freebsd-standards@FreeBSD.ORG Mon Sep 6 11:03:04 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BD4C016A4D2 for ; Mon, 6 Sep 2004 11:03:04 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A40B543D48 for ; Mon, 6 Sep 2004 11:03:04 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i86B34lB094493 for ; Mon, 6 Sep 2004 11:03:04 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i86B33ep094487 for freebsd-standards@freebsd.org; Mon, 6 Sep 2004 11:03:03 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 6 Sep 2004 11:03:03 GMT Message-Id: <200409061103.i86B33ep094487@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2004 11:03:05 -0000 Current FreeBSD problem reports Critical problems Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/03/05] bin/25542 standards /bin/sh: null char in quoted string p [2002/02/25] standards/35307standards standard include files are not standard c o [2002/12/13] kern/46239 standards posix semaphore implementation errors o [2003/04/21] standards/51209standards [PATCH] add a64l()/l64a/l64a_r functions p [2003/06/05] standards/52972standards /bin/sh arithmetic not POSIX compliant o [2003/06/18] kern/53447 standards poll(2) semantics differ from susV3/POSIX o [2003/07/12] standards/54410standards one-true-awk not POSIX compliant (no exte o [2003/09/15] standards/56906standards Several math(3) functions fail to set err o [2004/01/01] standards/60772standards _Bool and bool should be unsigned 9 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- f [1995/01/11] i386/105 standards Distributed libm (msun) has non-standard o [2000/09/24] bin/21519 standards sys/dir.h should be deprecated some more o [2001/01/16] bin/24390 standards Replacing old dir-symlinks when using /bi s [2001/01/24] standards/24590standards timezone function not compatible witn Sin s [2001/06/18] kern/28260 standards UIO_MAXIOV needs to be made public o [2001/11/20] standards/32126standards getopt(3) not Unix-98 conformant o [2002/02/27] misc/35381 standards incorrect floating-point display of large s [2002/03/19] standards/36076standards Implementation of POSIX fuser command o [2002/06/14] standards/39256standards [v]snprintf aren't POSIX-conformant for s o [2002/07/09] kern/40378 standards stdlib.h gives needless warnings with -an p [2002/08/12] standards/41576standards POSIX compliance of ln(1) o [2002/10/23] standards/44425standards getcwd() succeeds even if current dir has o [2002/12/09] standards/46119standards Priority problems for SCHED_OTHER using p o [2002/12/23] standards/46504standards Warnings in headers o [2003/06/22] standards/53613standards FreeBSD doesn't define EPROTO o [2003/07/24] standards/54809standards pcvt deficits o [2003/07/25] standards/54833standards more pcvt deficits o [2003/07/25] standards/54839standards pcvt deficits o [2003/07/31] standards/55112standards glob.h, glob_t's gl_pathc should be "size o [2003/09/05] standards/56476standards cd9660 unicode support simple hack o [2003/10/29] standards/58676standards grantpt(3) alters storage used by ptsname p [2003/12/26] standards/60597standards FreeBSD's /usr/include lacks of cpio.h s [2004/02/14] standards/62858standards malloc(0) not C99 compliant p [2004/02/21] standards/63173standards Patch to add getopt_long_only(3) to libc o [2004/05/07] standards/66357standards make POSIX conformance problem ('sh -e' & o [2004/05/11] standards/66531standards _gettemp uses a far smaller set of filena o [2004/08/22] standards/70813standards [PATCH] ls not Posix compliant o [2004/08/26] docs/70985 standards [patch] sh(1): incomplete documentation o 28 problems total. From owner-freebsd-standards@FreeBSD.ORG Mon Sep 6 13:56:55 2004 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A0F2A16A4CE; Mon, 6 Sep 2004 13:56:55 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82B2443D1D; Mon, 6 Sep 2004 13:56:55 +0000 (GMT) (envelope-from arved@FreeBSD.org) Received: from freefall.freebsd.org (arved@localhost [127.0.0.1]) i86Dut5l024260; Mon, 6 Sep 2004 13:56:55 GMT (envelope-from arved@freefall.freebsd.org) Received: (from arved@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i86DutQu024256; Mon, 6 Sep 2004 13:56:55 GMT (envelope-from arved) Date: Mon, 6 Sep 2004 13:56:55 GMT From: Tilman Linneweh Message-Id: <200409061356.i86DutQu024256@freefall.freebsd.org> To: arved@FreeBSD.org, freebsd-bugs@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: kern/64875: [patch] add a system call: fdatasync() X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2004 13:56:55 -0000 Synopsis: [patch] add a system call: fdatasync() Responsible-Changed-From-To: freebsd-bugs->freebsd-standards Responsible-Changed-By: arved Responsible-Changed-When: Mon Sep 6 13:56:20 GMT 2004 Responsible-Changed-Why: Over to standards Mailinglist http://www.freebsd.org/cgi/query-pr.cgi?pr=64875 From owner-freebsd-standards@FreeBSD.ORG Tue Sep 7 14:17:53 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1424D16A4CE for ; Tue, 7 Sep 2004 14:17:53 +0000 (GMT) Received: from rhid.com (rhid.com [200.46.204.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id CB40143D46 for ; Tue, 7 Sep 2004 14:17:52 +0000 (GMT) (envelope-from flaw@rhid.com) Received: from [127.0.0.1] (rhid.com [200.46.204.134]) by rhid.com (Postfix) with ESMTP id 767BDF84D2F; Tue, 7 Sep 2004 15:17:42 +0100 (BST) From: James William Pye To: FreeBSD Standards Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-vnjDFZ++OAcpD3br6Rx3" Organization: rhid development Message-Id: <1094566670.80264.78.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 07 Sep 2004 07:17:51 -0700 cc: Dan Nelson Subject: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2004 14:17:53 -0000 --=-vnjDFZ++OAcpD3br6Rx3 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable FreeBSD's test--and likely BSD's in general--use strtol to parse number strings to catch errors. Other shells and test implementations do not. zsh, pdksh, and, allegedly, GNU's test being notable implementations that more than likely use atoi, which just renders 0 for strings that don't make sense to it. That is, test asdf -ge 0 succeeds in some shells, and fails in others. I am curious if anyone knows if this behavior conforms to a specification. Personally, I find FreeBSD's behavior "correct", so I find the implementation differences disturbing. If it is conforming to a specification, I think it would be possible to convince some developers to change their implementations, which would be a good thing(tm). I first noticed this when zsh did not give me an error on test asdf -ge 0. I contacted the zsh developers about the apparent behavioral error, and Dan Nelson responded with examples of other shells that do the same thing("/bin/sh on Tru64 5.1, AIX 5.2, and Solaris 9 all succeed."). (I sent in my report after checking only /bin/sh and bash. =3D\) In short, does anyone know if this behavior conforms to a specification or does it fall into the range of "undefined behavior" that Dan figured it is in? (I'm betting on what Dan figured, but I wanted to check with standards to see if anyone else could confirm it). test(1) says it "implements a superset of the IEEE Std 1003.2", which I'm not sure if that's the same thing as or part of what's accessible at unix.org. --=20 Regards, James William Pye --=-vnjDFZ++OAcpD3br6Rx3 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (FreeBSD) iQEVAwUAQT3DDqZpiPNPvu8yAQL3Swf/fMBsIY/ZFWyailyDOgLHCI3Xu8kPtAwl uOwAGjjXp1XxbKQZ2WbX19jUEhjpQd/Vt+8vFw7xRY8OIsvNFiul2otZwSHO5Z5L 2vDNIfaendZXzXEdwDibWNYPuzCmNzUSe0Z9JPtphq3EsbWA1g6E20zGsNsFAibj Uw/Qdtca3uQbMlSuzbl9wSWZDRXA1n211314pOrHtqm0OjrMnnS5AluLe4Yy57us GosuHp3waiBjvv9KwB6P4AUm/G7b01UZm8pgJGT/NbCLxmRIXkQBr/lUl/rRP8Gn 3J2SSRkTtC1rVdZbcCE7O+472tIQOr2JTveAn3/UILtGqgcOhUPjFw== =7Caq -----END PGP SIGNATURE----- --=-vnjDFZ++OAcpD3br6Rx3-- From owner-freebsd-standards@FreeBSD.ORG Tue Sep 7 14:46:30 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A17616A4CF for ; Tue, 7 Sep 2004 14:46:30 +0000 (GMT) Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com [129.247.16.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 65A4443D49 for ; Tue, 7 Sep 2004 14:46:29 +0000 (GMT) (envelope-from harti@freebsd.org) Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) i87EkO2605928; Tue, 7 Sep 2004 16:46:24 +0200 Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3]) i87EkNI51684; Tue, 7 Sep 2004 16:46:23 +0200 Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178]) by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i87EkCe12398; Tue, 7 Sep 2004 16:46:23 +0200 (MET DST) Date: Tue, 7 Sep 2004 16:46:14 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt@beagle.kn.op.dlr.de To: James William Pye In-Reply-To: <1094566670.80264.78.camel@localhost> Message-ID: <20040907163809.M20166@beagle.kn.op.dlr.de> References: <1094566670.80264.78.camel@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Dan Nelson cc: FreeBSD Standards Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2004 14:46:30 -0000 On Tue, 7 Sep 2004, James William Pye wrote: JWP>FreeBSD's test--and likely BSD's in general--use strtol to parse number JWP>strings to catch errors. Other shells and test implementations do not. JWP>zsh, pdksh, and, allegedly, GNU's test being notable implementations JWP>that more than likely use atoi, which just renders 0 for strings that JWP>don't make sense to it. JWP>That is, test asdf -ge 0 succeeds in some shells, and fails in others. JWP> JWP>I am curious if anyone knows if this behavior conforms to a JWP>specification. Personally, I find FreeBSD's behavior "correct", so I JWP>find the implementation differences disturbing. If it is conforming to a JWP>specification, I think it would be possible to convince some developers JWP>to change their implementations, which would be a good thing(tm). JWP> JWP>I first noticed this when zsh did not give me an error on test asdf -ge JWP>0. I contacted the zsh developers about the apparent behavioral error, JWP>and Dan Nelson responded with examples of other shells that do the same JWP>thing("/bin/sh on Tru64 5.1, AIX 5.2, and Solaris 9 all succeed."). (I JWP>sent in my report after checking only /bin/sh and bash. =\) JWP> JWP>In short, does anyone know if this behavior conforms to a specification JWP>or does it fall into the range of "undefined behavior" that Dan figured JWP>it is in? (I'm betting on what Dan figured, but I wanted to check with JWP>standards to see if anyone else could confirm it). JWP> JWP>test(1) says it "implements a superset of the IEEE Std 1003.2", which JWP>I'm not sure if that's the same thing as or part of what's accessible at JWP>unix.org. I just checked the TC1 of Posix and it doesn't say anything in the description of test about this. Also the 'utility argument syntax' section talks only about range errors of numeric operands in point 6. So the behaviour seems to be unspecified. It's not clear whether this is an oversight or intended. I would recommend you to send a mail to the Austin Group with this question (probably austin-group-l@opengroup.org). harti From owner-freebsd-standards@FreeBSD.ORG Tue Sep 7 18:45:18 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5A66F16A50E; Tue, 7 Sep 2004 18:45:18 +0000 (GMT) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [128.30.28.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1056543D3F; Tue, 7 Sep 2004 18:45:18 +0000 (GMT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.9/8.12.9) with ESMTP id i87IjB8g099897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK CN=khavrinen.lcs.mit.edu issuer=SSL+20Client+20CA); Tue, 7 Sep 2004 14:45:11 -0400 (EDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.9/8.12.9/Submit) id i87IjAu6099894; Tue, 7 Sep 2004 14:45:10 -0400 (EDT) (envelope-from wollman) Date: Tue, 7 Sep 2004 14:45:10 -0400 (EDT) From: Garrett Wollman Message-Id: <200409071845.i87IjAu6099894@khavrinen.lcs.mit.edu> To: Harti Brandt In-Reply-To: <20040907163809.M20166@beagle.kn.op.dlr.de> References: <1094566670.80264.78.camel@localhost> <20040907163809.M20166@beagle.kn.op.dlr.de> X-Spam-Score: -19.8 () IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES X-Scanned-By: MIMEDefang 2.37 cc: FreeBSD Standards cc: Dan Nelson Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2004 18:45:18 -0000 < said: > I just checked the TC1 of Posix and it doesn't say anything in the > description of test about this. Also the 'utility argument syntax' section > talks only about range errors of numeric operands in point 6. So the > behaviour seems to be unspecified. It's not clear whether this is an > oversight or intended. I agree. I believe that an interpretation request would receive the "the standard is silent and no conformance distinction can be made" (and therefore FreeBSD's implementation is not incorrect). It's instructive to contrast the description of expr(1), where the standard makes it very clear what constitutes a number. -GAWollman From owner-freebsd-standards@FreeBSD.ORG Wed Sep 8 14:46:46 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1D1A716A4CE; Wed, 8 Sep 2004 14:46:46 +0000 (GMT) Received: from rhid.com (rhid.com [200.46.204.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id DAF4043D54; Wed, 8 Sep 2004 14:46:45 +0000 (GMT) (envelope-from flaw@rhid.com) Received: from [127.0.0.1] (rhid.com [200.46.204.134]) by rhid.com (Postfix) with ESMTP id 2C260F84A92; Wed, 8 Sep 2004 15:46:34 +0100 (BST) From: James William Pye To: Garrett Wollman In-Reply-To: <200409071845.i87IjAu6099894@khavrinen.lcs.mit.edu> References: <1094566670.80264.78.camel@localhost> <20040907163809.M20166@beagle.kn.op.dlr.de> <200409071845.i87IjAu6099894@khavrinen.lcs.mit.edu> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-C3Rs4GaqaPQBXMcT6gI1" Organization: rhid development Message-Id: <1094654804.85018.94.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 08 Sep 2004 07:46:44 -0700 cc: Dan Nelson cc: FreeBSD Standards Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2004 14:46:46 -0000 --=-C3Rs4GaqaPQBXMcT6gI1 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2004-09-07 at 11:45, Garrett Wollman wrote: > I agree. I believe that an interpretation request would receive the > "the standard is silent and no conformance distinction can be made" > (and therefore FreeBSD's implementation is not incorrect). It's > instructive to contrast the description of expr(1), where the standard > makes it very clear what constitutes a number. I think that you are likely to be correct here. Perhaps I will send a clarification request noting the constrast you mentioned between test(1) and expr(1) to the OpenGroup list Harti referred to. I think I will also mention arithmetic expansion, as I think the issue exists there as well. --=20 Regards, James William Pye --=-C3Rs4GaqaPQBXMcT6gI1 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (FreeBSD) iQEVAwUAQT8bVKZpiPNPvu8yAQJe/wf9E/sino/JDLCE8hFVDtoK2VGEuiV6dYxw OkCP/kwEbjVnMTRsmeQkMq6g2IDnndx4S2QZzANTEQnKtAKFpyYAj9yH8Dixgo5C RCnlbrr3awMAKiYaZVoQERBlUpiSohENzOf5qVGDTdpeSFP7f+wVQMgAj0VUWL4k RuDjXfJm8zqlre11S9G+tnKXuGt5d+yg7X5FQdZaKHqx+2vG62zS8X1K+PXT1Ltc JMscCe9xq972wHAOPx4j06T50oGVnqQXm07Owg/bZhG9DOTLGbuw6UDV4xxhMLYM VMFIo1HIWkSV+4zqUZjFwFsEALAQxU2eYnaKf+CCWIzuo078loPUdQ== =8xdA -----END PGP SIGNATURE----- --=-C3Rs4GaqaPQBXMcT6gI1-- From owner-freebsd-standards@FreeBSD.ORG Wed Sep 8 14:56:23 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3777916A4CE for ; Wed, 8 Sep 2004 14:56:23 +0000 (GMT) Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com [129.247.16.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EC3043D48 for ; Wed, 8 Sep 2004 14:56:22 +0000 (GMT) (envelope-from harti@freebsd.org) Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) i88Etc2555620; Wed, 8 Sep 2004 16:55:39 +0200 Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3]) i88EtcI94914; Wed, 8 Sep 2004 16:55:38 +0200 Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178]) by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i88Etbe12890; Wed, 8 Sep 2004 16:55:37 +0200 (MET DST) Date: Wed, 8 Sep 2004 16:55:44 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt@beagle.kn.op.dlr.de To: James William Pye In-Reply-To: <1094654804.85018.94.camel@localhost> Message-ID: <20040908165429.F23565@beagle.kn.op.dlr.de> References: <1094566670.80264.78.camel@localhost> <20040907163809.M20166@beagle.kn.op.dlr.de> <1094654804.85018.94.camel@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: FreeBSD Standards cc: Dan Nelson Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2004 14:56:23 -0000 On Wed, 8 Sep 2004, James William Pye wrote: JWP>On Tue, 2004-09-07 at 11:45, Garrett Wollman wrote: JWP>> I agree. I believe that an interpretation request would receive the JWP>> "the standard is silent and no conformance distinction can be made" JWP>> (and therefore FreeBSD's implementation is not incorrect). It's JWP>> instructive to contrast the description of expr(1), where the standard JWP>> makes it very clear what constitutes a number. JWP> JWP>I think that you are likely to be correct here. Perhaps I will send a JWP>clarification request noting the constrast you mentioned between test(1) JWP>and expr(1) to the OpenGroup list Harti referred to. I think I will also JWP>mention arithmetic expansion, as I think the issue exists there as well. If you want to place an official request there is also a web interface I think. harti From owner-freebsd-standards@FreeBSD.ORG Wed Sep 8 21:34:14 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A9B3C16A4CE for ; Wed, 8 Sep 2004 21:34:14 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7BE6F43D1F for ; Wed, 8 Sep 2004 21:34:14 +0000 (GMT) (envelope-from chitt@speakeasy.net) Received: (qmail 29404 invoked from network); 8 Sep 2004 21:34:14 -0000 Received: from dsl231-047-005.sea1.dsl.speakeasy.net (HELO [192.168.102.42]) ([216.231.47.5]) (envelope-sender ) encrypted SMTP for ; 8 Sep 2004 21:34:13 -0000 From: Sean Chittenden To: standards@freebsd.org User-Agent: KMail/1.7 MIME-Version: 1.0 Date: Wed, 8 Sep 2004 14:34:35 -0700 Content-Type: Multipart/Mixed; boundary="Boundary-00=_rr3PBiq01cMFQZ6" Message-Id: <200409081434.35952.chitt@speakeasy.net> Subject: Trivial cleanup for lib/libutil/libutil.h... X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2004 21:34:14 -0000 --Boundary-00=_rr3PBiq01cMFQZ6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Howdy. I was looking at fparseln(3)'s declaration in include/libutil.h and noticed that it's wrapped in an #ifdef _STDIO_H_. Is there any reason to have FPARSELN_* not wrapped in the same #define? If not, the attatched wraps the #define's so that they only apply when fparseln(3) is visible. Are there any objections to me committing this change? -sc -- Sean Chittenden seanc@FreeBSD.org --Boundary-00=_rr3PBiq01cMFQZ6 Content-Type: text/x-diff; charset="us-ascii"; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch" Index: lib/libutil/libutil.h =================================================================== RCS file: /home/ncvs/src/lib/libutil/libutil.h,v retrieving revision 1.40 diff -u -r1.40 libutil.h --- lib/libutil/libutil.h 24 May 2004 22:19:27 -0000 1.40 +++ lib/libutil/libutil.h 8 Sep 2004 20:41:10 -0000 @@ -121,11 +121,13 @@ #define HOSTNAME_INVALIDNAME (3) /* fparseln(3) */ +#ifdef _STDIO_H_ #define FPARSELN_UNESCESC 0x01 #define FPARSELN_UNESCCONT 0x02 #define FPARSELN_UNESCCOMM 0x04 #define FPARSELN_UNESCREST 0x08 #define FPARSELN_UNESCALL 0x0f +#endif /* pw_scan() */ #define PWSCAN_MASTER 0x01 --Boundary-00=_rr3PBiq01cMFQZ6-- From owner-freebsd-standards@FreeBSD.ORG Thu Sep 9 06:31:40 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 74D7016A4CE for ; Thu, 9 Sep 2004 06:31:40 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id 154D143D1F for ; Thu, 9 Sep 2004 06:31:40 +0000 (GMT) (envelope-from wartan.hachaturow@gmail.com) Received: by mproxy.gmail.com with SMTP id 74so408182rnl for ; Wed, 08 Sep 2004 23:31:39 -0700 (PDT) Received: by 10.38.9.78 with SMTP id 78mr109377rni; Wed, 08 Sep 2004 23:31:39 -0700 (PDT) Received: by 10.38.102.49 with HTTP; Wed, 8 Sep 2004 23:31:39 -0700 (PDT) Message-ID: <4aaa2e1c0409082331317e70e0@mail.gmail.com> Date: Thu, 9 Sep 2004 10:31:39 +0400 From: Wartan Hachaturow To: James William Pye In-Reply-To: <1094566670.80264.78.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1094566670.80264.78.camel@localhost> cc: FreeBSD Standards Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Wartan Hachaturow List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2004 06:31:40 -0000 On Tue, 07 Sep 2004 07:17:51 -0700, James William Pye wrote: > I am curious if anyone knows if this behavior conforms to a > specification. Personally, I find FreeBSD's behavior "correct", so I > find the implementation differences disturbing. If it is conforming to a > specification, I think it would be possible to convince some developers > to change their implementations, which would be a good thing(tm). When I've been writing arithmetic evaluation in our /bin/sh, I haven't found any signs of "standard convsersion" in SUS, so I used strtol() with a couple of checks, which I assumed to be most logical in this case. Perhaps, aardvark for the clarification might be good, yes. -- Regards, Wartan. From owner-freebsd-standards@FreeBSD.ORG Fri Sep 10 19:05:45 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0037F16A4CE for ; Fri, 10 Sep 2004 19:05:44 +0000 (GMT) Received: from rhid.com (rhid.com [200.46.204.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CFD443D4C for ; Fri, 10 Sep 2004 19:05:44 +0000 (GMT) (envelope-from flaw@rhid.com) Received: from [127.0.0.1] (rhid.com [200.46.204.134]) by rhid.com (Postfix) with ESMTP id B2A29F83833 for ; Fri, 10 Sep 2004 20:05:39 +0100 (BST) From: James William Pye To: FreeBSD Standards In-Reply-To: <1094566670.80264.78.camel@localhost> References: <1094566670.80264.78.camel@localhost> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-8zHU2d9nIA4XC0U6zsxo" Organization: rhid development Message-Id: <1094843141.488.69.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 10 Sep 2004 12:05:41 -0700 Subject: Re: /bin/test asdf -ge 0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2004 19:05:45 -0000 --=-8zHU2d9nIA4XC0U6zsxo Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Here is the aardvark defect submission that I made: --------------------------------------------------------------- 7. Please describe the problem in the box below: test asdf -ge 0 $((asdf + 1)) What constitutes a number in both of these cases, test(1) and shell arithmetic expansion, does not appear to be specified. This was brought to my attention when I noticed the differing implementations. Firstly, zsh, which will return 0 on the first command, and the arithmetic expansion will expand to 1. As opposed to FreeBSD's--and likely BSDs in general--/bin/sh, which will cause an error to be echoed to stderr and a non-zero result in both cases. At first I contacted the zsh developers, as I assumed this was specified behaviour after checking /bin/sh's and bash's test implementation. This was not the case, and Dan Nelson on the zsh work list responded with examples of other shells that behaved the same way as zsh. (A couple notable examples being GNU's test and pdksh). He also said that he believed this fell into undefined behaviour, and, therefore, zsh was not incorrect. I then contacted the FreeBSD-standards list to try to confirm that this was undefined behaviour. Those who responded believed that this was undefined, and thought that I should at least bring this question to the austin group mailing list. In case you are interested in the threads that led up to this clarification request, here are their URIs: http://www.zsh.org/mla/workers/2004/msg00937.html http://lists.freebsd.org/pipermail/freebsd-standards/2004-September/000673.= html 8. Please describe the desired action to be taken in the box below: Clarification of what constitutes a number in XCU's test(1) and shell arithmetic expansion, and perhaps other related locations. Specifically, a given number should be considered valid if strtol(str, &end, 0) accepts str as a valid number. This would allow the usage of hexadecimal and octal numbers in test and arithmetic expansion, which is likely a feature that would be welcomed by all. (See http://www.opengroup.org/onlinepubs/000095399/functions/strtol.html) In the case of an invalid number, the utility should throw an error and return non-zero, perhaps a standard error code for an invalid numbers should be allocated, if one is not already. An invalid number in arithmetic expansion should cause an error to be thrown before the command is executed, and result in a non-zero value, and perhaps a different value than the former so that a distinction can be made between where the invalid number error occurred--before or during the execution of a command. An important note to make is the contrast between test(1) and expr(1), where expr defines a valid integer, and test does not. =46rom http://www.opengroup.org/onlinepubs/000095399/utilities/expr.html: integer - An argument consisting only of an (optional) unary minus followed by digits. I also recommend that expr(1) be updated to allow hexadecimal and octal numbers in the format that strtol(str, &end, 0) accepts, so as to be consistent with the newly defined behaviour in test(1) and shell arithmetic expansion. (Props to Garrett Wollman on freebsd-standards for the notice of this contrast!) ------------------------------------------------------------------- I hope I wasn't a bit too ambitious with strtol(str, &end, 0).. =3D\ --=20 Regards, James William Pye --=-8zHU2d9nIA4XC0U6zsxo Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (FreeBSD) iQEVAwUAQUH7BaZpiPNPvu8yAQJkkwf7BA2SCU01uAqkvxdCYUEjKkTzksHheOnE /P5BvvyMsQcCychNL9PabRaWClDmvmTDuUteUR8PLPqedYvQoHmYznXMu/PorN92 mpemghJpGJ0Mr8cx0IDJA2sEAW6oNfMpMFsbdRjiPuCTjYmrCXLiOlPual2VFGSR UbWF8EzgjXklCA/BPzPWVoMwWzDLgRe5HxNlFdTUbJvZq/ODsT8qA4PqzrJ+28T0 LY9qa78SpmCxUzC9ArF63DawDhlJyVh/KlkctmB7b54Z8txnLSjidJzHRbRFDEMh 5Q5usz4DjQcN4BxJ1+5K5iFs1f2cUzTtpTDmpt0sooB3YyAvA+YL7w== =Bce6 -----END PGP SIGNATURE----- --=-8zHU2d9nIA4XC0U6zsxo--