From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 07:10:21 2003 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 A592E37B404 for ; Sun, 22 Jun 2003 07:10:21 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 77F3743F85 for ; Sun, 22 Jun 2003 07:10:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5MEAHUp017953 for ; Sun, 22 Jun 2003 07:10:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5MEAHm7017952; Sun, 22 Jun 2003 07:10:17 -0700 (PDT) Resent-Date: Sun, 22 Jun 2003 07:10:17 -0700 (PDT) Resent-Message-Id: <200306221410.h5MEAHm7017952@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Faried Nawaz Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CBF537B40D for ; Sun, 22 Jun 2003 07:04:41 -0700 (PDT) Received: from loops.nilpotent.org (loops.nilpotent.org [12.17.163.70]) by mx1.FreeBSD.org (Postfix) with SMTP id 4C11143FA3 for ; Sun, 22 Jun 2003 07:04:36 -0700 (PDT) (envelope-from fn@hungry.org) Received: (qmail 1261 invoked from network); 22 Jun 2003 14:04:34 -0000 Received: from unknown (203.215.182.20) by loops.nilpotent.org with QMTP; 22 Jun 2003 14:04:34 -0000 Received: (qmail 633 invoked from network); 22 Jun 2003 13:59:20 -0000 Received: from unknown (HELO xpf.nilpotent.org) (127.0.0.1) by localhost with SMTP; 22 Jun 2003 13:59:20 -0000 Received: (from fn@localhost) by xpf.nilpotent.org (8.12.8p1/8.12.8/Submit) id h5MDxIdM000629; Sun, 22 Jun 2003 18:59:18 +0500 (PKT) Message-Id: <200306221359.h5MDxIdM000629@xpf.nilpotent.org> Date: Sun, 22 Jun 2003 18:59:18 +0500 (PKT) From: Faried Nawaz To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/53613: FreeBSD doesn't define EPROTO X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Faried Nawaz List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jun 2003 14:10:22 -0000 >Number: 53613 >Category: standards >Synopsis: FreeBSD doesn't define EPROTO >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jun 22 07:10:17 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Faried Nawaz >Release: FreeBSD 4.8-STABLE i386 >Organization: Hungry Programmers, Inc >Environment: System: FreeBSD xpf.nilpotent.org 4.8-STABLE FreeBSD 4.8-STABLE #0: Sun Jun 8 05:13:09 PKT 2003 root@xpf.nilpotent.org:/usr/obj/usr/src/sys/xpf i386 >Description: There is no EPROTO defined in errno.h. See http://www.opengroup.org/onlinepubs/007904975/basedefs/errno.h.html >How-To-Repeat: Read errno.h, compare with http://www.opengroup.org/onlinepubs/007904975/basedefs/errno.h.html >Fix: None provided... >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 13:50:05 2003 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 EC4C937B401 for ; Sun, 22 Jun 2003 13:50:05 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F79B43FBD for ; Sun, 22 Jun 2003 13:50:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5MKo5Up034335 for ; Sun, 22 Jun 2003 13:50:05 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5MKo5Ph034334; Sun, 22 Jun 2003 13:50:05 -0700 (PDT) Date: Sun, 22 Jun 2003 13:50:05 -0700 (PDT) Message-Id: <200306222050.h5MKo5Ph034334@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Jens Schweikhardt Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jens Schweikhardt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jun 2003 20:50:06 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Jens Schweikhardt To: Wartan Hachaturow Cc: GNATS Bug Followup Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Sun, 22 Jun 2003 22:43:27 +0200 Wartan, [please always cc to with the subject left as is (like in this mail), so GNATS can add your comments to the audit trail. Thanks!] On Mon, Jun 23, 2003 at 12:21:58AM +0400, Wartan Hachaturow wrote: # Hello. # # I think I may try to fix this bug, but for now I've failed to # find a precise line in SUS that requires this ( $((a+1)) vs $(($a+1)) ) # kind of arithmetic evaluation. # I understand that in order to have "+=" operators, for example, # we've got to have some way to use a variable itself, not substituted # by its value, but still.. # Perhaps someone may point me to the exact part of SUS that describes # this particular thing? It's in "Token Recognition" [...] If the current character is an unquoted '$' or '`' , the shell shall identify the start of any candidates for parameter expansion ( Parameter Expansion ), command substitution ( Command Substitution ), or arithmetic expansion ( Arithmetic Expansion ) from their introductory unquoted character sequences: '$' or "${" , "$(" or '`' , and "$((" , respectively. The shell shall read sufficient input to determine the end of the unit to be expanded (as explained in the cited sections). While processing the characters, if instances of expansions or quoting are found nested within the substitution, the shell shall recursively process them in the manner specified for the construct that is found. The characters found from the beginning of the substitution to its end, allowing for any recursion necessary to recognize embedded constructs, shall be included unmodified in the result token, including any embedded or enclosing substitution operators or quotes. The token shall not be delimited by the end of the substitution. The recursive processing requires that $(($a+1)) needs to undergo parameter expansion within $(()). Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 14:50:17 2003 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 DBA2237B401 for ; Sun, 22 Jun 2003 14:50:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 80E0243FCB for ; Sun, 22 Jun 2003 14:50:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5MLoGUp061342 for ; Sun, 22 Jun 2003 14:50:16 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5MLoGpX061341; Sun, 22 Jun 2003 14:50:16 -0700 (PDT) Date: Sun, 22 Jun 2003 14:50:16 -0700 (PDT) Message-Id: <200306222150.h5MLoGpX061341@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant 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: Sun, 22 Jun 2003 21:50:18 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Jens Schweikhardt Cc: GNATS Bug Followup Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 01:41:42 +0400 On Sun, Jun 22, 2003 at 10:43:27PM +0200, Jens Schweikhardt wrote: > [please always cc to with the subject left as > is (like in this mail), so GNATS can add your comments to the audit > trail. Thanks!] Sure, I just thought my initial letter wasn't valuable enough to be included in the trail :) > The recursive processing requires that $(($a+1)) needs to undergo > parameter expansion within $(()). Right, but this construction works in /bin/sh: wart@mojo:~$ /bin/sh $ a=1 $ echo $(($a+1)) 2 You've said the problem was with the variable without leading $, like this: $ a=1 $ echo $((a+1)) arith: syntax error: "a+1" And, as far as my English allows me to judge, the quoted part of SUS says that "a" in this construct should be left in output as is (since it doesn't have leading $, ${, $(, etc.), shouldn't it? -- Regards, Wartan. "Computers are not intelligent. They only think they are." From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 23:32:58 2003 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 EF6A837B401; Sun, 22 Jun 2003 23:32:58 -0700 (PDT) Received: from smtp.des.no (37.80-203-228.nextgentel.com [80.203.228.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B9AC43FAF; Sun, 22 Jun 2003 23:32:57 -0700 (PDT) (envelope-from des@des.no) Received: by smtp.des.no (Postfix, from userid 666) id 877059595C; Mon, 23 Jun 2003 08:32:56 +0200 (CEST) Received: from dwp.des.no (dwp.des.no [10.0.0.4]) by smtp.des.no (Postfix) with ESMTP id B201B95958; Mon, 23 Jun 2003 08:32:55 +0200 (CEST) Received: by dwp.des.no (Postfix, from userid 2602) id 70E5EB823; Mon, 23 Jun 2003 08:32:55 +0200 (CEST) To: Wartan Hachaturow References: <200306222150.h5MLoGpX061341@freefall.freebsd.org> From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Mon, 23 Jun 2003 08:32:55 +0200 In-Reply-To: <200306222150.h5MLoGpX061341@freefall.freebsd.org> (Wartan Hachaturow's message of "Sun, 22 Jun 2003 14:50:16 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-3.0 required=8.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: freebsd-gnats-submit@freebsd.org cc: freebsd-standards@FreeBSD.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant 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, 23 Jun 2003 06:32:59 -0000 Wartan Hachaturow writes: > The following reply was made to PR standards/52972; it has been noted by = GNATS. > On Sun, Jun 22, 2003 at 10:43:27PM +0200, Jens Schweikhardt wrote: > > The recursive processing requires that $(($a+1)) needs to undergo > > parameter expansion within $(()). >=20=20 > Right, but this construction works in /bin/sh: >=20=20 > wart@mojo:~$ /bin/sh > $ a=3D1 > $ echo $(($a+1)) > 2 Yes. It expands to $((1+1)) which evaluates to 2. > You've said the problem was with the variable without leading $, like > this: > $ a=3D1 > $ echo $((a+1))=20 > arith: syntax error: "a+1" This *should* work, but doesn't. > And, as far as my English allows me to judge, the quoted part of SUS > says that "a" in this construct should be left in output as is (since it > doesn't have leading $, ${, $(, etc.), shouldn't it? Yes, it should be left as-is so the part of the code that evaluates arithmetic expressions knows what variable is involved. For instance, "$(($a+=3D1)) would expand to "$((1+=3D1))" before evaluation, which makes no sense, while "$((a+=3D1))" clearly says to increase a with 1. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 23:40:11 2003 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 40B0A37B401 for ; Sun, 22 Jun 2003 23:40:11 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D41AC43F75 for ; Sun, 22 Jun 2003 23:40:10 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5N6eAUp035320 for ; Sun, 22 Jun 2003 23:40:10 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5N6eAt4035319; Sun, 22 Jun 2003 23:40:10 -0700 (PDT) Date: Sun, 22 Jun 2003 23:40:10 -0700 (PDT) Message-Id: <200306230640.h5N6eAt4035319@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2003 06:40:11 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) To: Wartan Hachaturow Cc: freebsd-standards@FreeBSD.org, freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 08:32:55 +0200 Wartan Hachaturow writes: > The following reply was made to PR standards/52972; it has been noted by = GNATS. > On Sun, Jun 22, 2003 at 10:43:27PM +0200, Jens Schweikhardt wrote: > > The recursive processing requires that $(($a+1)) needs to undergo > > parameter expansion within $(()). >=20=20 > Right, but this construction works in /bin/sh: >=20=20 > wart@mojo:~$ /bin/sh > $ a=3D1 > $ echo $(($a+1)) > 2 Yes. It expands to $((1+1)) which evaluates to 2. > You've said the problem was with the variable without leading $, like > this: > $ a=3D1 > $ echo $((a+1))=20 > arith: syntax error: "a+1" This *should* work, but doesn't. > And, as far as my English allows me to judge, the quoted part of SUS > says that "a" in this construct should be left in output as is (since it > doesn't have leading $, ${, $(, etc.), shouldn't it? Yes, it should be left as-is so the part of the code that evaluates arithmetic expressions knows what variable is involved. For instance, "$(($a+=3D1)) would expand to "$((1+=3D1))" before evaluation, which makes no sense, while "$((a+=3D1))" clearly says to increase a with 1. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 01:50:27 2003 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 0794A37B401; Mon, 23 Jun 2003 01:50:27 -0700 (PDT) Received: from atlas.informatik.rwth-aachen.de (atlas.Informatik.RWTH-Aachen.DE [137.226.194.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA62743FAF; Mon, 23 Jun 2003 01:50:12 -0700 (PDT) (envelope-from stolz@i2.informatik.rwth-aachen.de) Received: from menelaos.informatik.rwth-aachen.de (menelaos.Informatik.RWTH-Aachen.DE [137.226.194.73]) 8.11.1-0.5) with ESMTP id h5N8nQK22074; Mon, 23 Jun 2003 10:49:26 +0200 Received: (from stolz@localhost)h5N8nNUA000497; Mon, 23 Jun 2003 10:49:23 +0200 (CEST) (envelope-from stolz) Date: Mon, 23 Jun 2003 10:49:23 +0200 From: Volker Stolz To: Wartan Hachaturow Message-ID: <20030623084923.GA450@i2.informatik.rwth-aachen.de> References: <200306201421.h5KELfUh011622@menelaos.informatik.rwth-aachen.de> <20030621163449.GA19155@mojo.tepkom.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030621163449.GA19155@mojo.tepkom.ru> X-PGP-Key: finger vs@foldr.org X-PGP-Id: 0x3FD1B6B5 User-Agent: Mutt/1.5.3i cc: simonmar@microsoft.com cc: standards@freebsd.org cc: FreeBSD-gnats-submit@freebsd.org cc: rwatson@freebsd.org Subject: Re: standards/53554 fix for review (Re: interval timers not cleared in fork()) 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, 23 Jun 2003 08:50:27 -0000 On Sat, Jun 21, 2003 at 08:34:49PM +0400, Wartan Hachaturow wrote: > On Fri, Jun 20, 2003 at 04:21:42PM +0200, Volker Stolz wrote: > > > SUSv2 says that on invoking fork(): > > - If the Timers option is supported, per-process timers created by the > > parent are not inherited by the child process. > > SUSv3 requires this as well. > This is a quick fix (for 5.1, it's also affected): The patch applies fine to -STABLE and has the desired effect: virtual set: 1 500 real get: 0 0 prof get: 0 0 virtual get: 0 0 Thanks for looking into this! Volker -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME rage against the finite state machine From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 02:00:30 2003 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 61D1537B401 for ; Mon, 23 Jun 2003 02:00:30 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0232143FE9 for ; Mon, 23 Jun 2003 02:00:30 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5N90TUp049220 for ; Mon, 23 Jun 2003 02:00:29 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5N90Tsi049219; Mon, 23 Jun 2003 02:00:29 -0700 (PDT) Date: Mon, 23 Jun 2003 02:00:29 -0700 (PDT) Message-Id: <200306230900.h5N90Tsi049219@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Volker Stolz Subject: Re: standards/53554 fix for review (Re: interval timers not cleared in fork()) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Volker Stolz List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2003 09:00:30 -0000 The following reply was made to PR standards/53554; it has been noted by GNATS. From: Volker Stolz To: Wartan Hachaturow Cc: FreeBSD-gnats-submit@freebsd.org, standards@freebsd.org, rwatson@freebsd.org, simonmar@microsoft.com Subject: Re: standards/53554 fix for review (Re: interval timers not cleared in fork()) Date: Mon, 23 Jun 2003 10:49:23 +0200 On Sat, Jun 21, 2003 at 08:34:49PM +0400, Wartan Hachaturow wrote: > On Fri, Jun 20, 2003 at 04:21:42PM +0200, Volker Stolz wrote: > > > SUSv2 says that on invoking fork(): > > - If the Timers option is supported, per-process timers created by the > > parent are not inherited by the child process. > > SUSv3 requires this as well. > This is a quick fix (for 5.1, it's also affected): The patch applies fine to -STABLE and has the desired effect: virtual set: 1 500 real get: 0 0 prof get: 0 0 virtual get: 0 0 Thanks for looking into this! Volker -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME rage against the finite state machine From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 03:00:31 2003 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 178C437B401 for ; Mon, 23 Jun 2003 03:00:31 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0DE043FEC for ; Mon, 23 Jun 2003 03:00:30 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5NA0UUp055291 for ; Mon, 23 Jun 2003 03:00:30 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5NA0UD5055287; Mon, 23 Jun 2003 03:00:30 -0700 (PDT) Date: Mon, 23 Jun 2003 03:00:30 -0700 (PDT) Message-Id: <200306231000.h5NA0UD5055287@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/53554 fix for review (Re: interval timers not cleared in fork()) 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: Mon, 23 Jun 2003 10:00:31 -0000 The following reply was made to PR standards/53554; it has been noted by GNATS. From: Wartan Hachaturow To: Volker Stolz Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/53554 fix for review (Re: interval timers not cleared in fork()) Date: Mon, 23 Jun 2003 13:51:47 +0400 On Mon, Jun 23, 2003 at 10:49:23AM +0200, Volker Stolz wrote: > The patch applies fine to -STABLE and has the desired effect: By the way, I must note that this is not _required_ by SUS, but rather is a feature for X/Open Systems-compliant systems, and therefore is an extension to POSIX. But, of course, as we provide itimers feature, which is also XSI, it makes sense to follow it in fork() also :) -- Regards, Wartan. From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 03:10:23 2003 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 8835637B401 for ; Mon, 23 Jun 2003 03:10:23 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E96A43FDF for ; Mon, 23 Jun 2003 03:10:23 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5NAANUp059087 for ; Mon, 23 Jun 2003 03:10:23 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5NAANq7059086; Mon, 23 Jun 2003 03:10:23 -0700 (PDT) Date: Mon, 23 Jun 2003 03:10:23 -0700 (PDT) Message-Id: <200306231010.h5NAANq7059086@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant 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: Mon, 23 Jun 2003 10:10:23 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Dag-Erling Sm?rgrav Cc: freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 14:06:19 +0400 On Mon, Jun 23, 2003 at 08:32:55AM +0200, Dag-Erling Sm?rgrav wrote: > Yes, it should be left as-is so the part of the code that evaluates > arithmetic expressions knows what variable is involved. For instance, > "$(($a+=1)) would expand to "$((1+=1))" before evaluation, which makes > no sense, while "$((a+=1))" clearly says to increase a with 1. Yes, the latter was the thing that I couldn't understand -- how may one implement +=, if variables are not required in arithmetic evaluation. But now, I've noticed the line I've missed while reading SUS: "Arithmetic Precision and Operations Integer variables and constants, including the values of operands and option-arguments, used by the standard utilities listed in this volume of IEEE Std 1003.1-2001 shall be implemented" Question is closed :) -- Regards, Wartan. From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 04:50:11 2003 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 B0A7337B401 for ; Mon, 23 Jun 2003 04:50:11 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5398A43FEA for ; Mon, 23 Jun 2003 04:50:11 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5NBoAUp071820 for ; Mon, 23 Jun 2003 04:50:10 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5NBoAka071819; Mon, 23 Jun 2003 04:50:10 -0700 (PDT) Date: Mon, 23 Jun 2003 04:50:10 -0700 (PDT) Message-Id: <200306231150.h5NBoAka071819@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant 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: Mon, 23 Jun 2003 11:50:12 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Dag-Erling Sm?rgrav Cc: freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 15:40:24 +0400 On Mon, Jun 23, 2003 at 08:32:55AM +0200, Dag-Erling Sm?rgrav wrote: > This *should* work, but doesn't. I've filed just the same bug against Debian package of ash. This is the answer I got from Herbert Xu, also an upstream of what's called "dash", Debian fork of ash shell (it has just the same behaviour as FreeBSD's ash): ---- > Package: ash > Version: 0.4.17 > Severity: normal > Tags: upstream That's me. > According to SUSv3, shell should implement integer variables in > arithmetic evaluation: You're mistaken. SUSv3 only requires constant arithmetic. Variables must be expanded before reaching arithmetic expansion. Read C.2.6.4 for a detailed explanation. > P.S. I'll try to make a patch fixing this bug in near future. Please use bash/ksh instead. ---- .. and he has closed the bug. Now I am really lost -- where is the truth? -- Regards, Wartan. From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 11:30:15 2003 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 494AF37B401 for ; Mon, 23 Jun 2003 11:30:15 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBFB943FF2 for ; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5NIUEUp006713 for ; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5NIUEM6006712; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) Date: Mon, 23 Jun 2003 11:30:14 -0700 (PDT) Message-Id: <200306231830.h5NIUEM6006712@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2003 18:30:15 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) To: Wartan Hachaturow Cc: freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 20:24:51 +0200 Wartan Hachaturow writes: > I've filed just the same bug against Debian package of ash. This is the > answer I got from Herbert Xu, also an upstream of what's called "dash", > Debian fork of ash shell (it has just the same behaviour as FreeBSD's=20 > ash): >=20 > > > According to SUSv3, shell should implement integer variables in=20 > > > arithmetic evaluation: > > > > You're mistaken. SUSv3 only requires constant arithmetic. Variables > > must be expanded before reaching arithmetic expansion. He's wrong. The full text of section 2.6.4 is: | Arithmetic expansion provides a mechanism for evaluating an arithmetic | expression and substituting its value. The format for arithmetic | expansion shall be as follows: |=20 | $((expression)) |=20 | The expression shall be treated as if it were in double-quotes, except | that a double-quote inside the expression is not treated | specially. The shell shall expand all tokens in the expression for | parameter expansion, command substitution, and quote removal. |=20 | Next, the shell shall treat this as an arithmetic expression and | substitute the value of the expression. The arithmetic expression | shall be processed according to the rules given in Arithmetic | Precision and Operations , with the following exceptions: |=20 | - Only signed long integer arithmetic is required. |=20 | - Only the decimal-constant, octal-constant, and hexadecimal-constant | constants specified in the ISO C standard, Section 6.4.4.1 are | required to be recognized as constants. |=20 | - The sizeof() operator and the prefix and postfix "++" and "--" | operators are not required. |=20 | - Selection, iteration, and jump statements are not supported. |=20 | As an extension, the shell may recognize arithmetic expressions beyond | those listed. The shell may use a signed integer type with a rank | larger than the rank of signed long. The shell may use a real-floating | type instead of signed long as long as it does not affect the results | in cases where there is no overflow. If the expression is invalid, the | expansion fails and the shell shall write a message to standard error | indicating the failure. Not only is there nothing there about only supporting constant artithmetic, but the assignment operators are *not* listed as exceptions to the "rules given in Arithmetic Precision and Operations", which refers to section 1.7.2.1, which you will find at the following URL: http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap01.html#tag= _01_07_02_01 Therefore, assignment operators *are* required to work. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 02:50:18 2003 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 BB48237B401 for ; Tue, 24 Jun 2003 02:50:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5FDE643FE1 for ; Tue, 24 Jun 2003 02:50:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5O9oHUp021599 for ; Tue, 24 Jun 2003 02:50:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5O9oHxe021598; Tue, 24 Jun 2003 02:50:17 -0700 (PDT) Date: Tue, 24 Jun 2003 02:50:17 -0700 (PDT) Message-Id: <200306240950.h5O9oHxe021598@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant 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: Tue, 24 Jun 2003 09:50:19 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Dag-Erling Sm?rgrav Cc: freebsd-gnats-submit@freebsd.org, schweikh@schweikhardt.net Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Tue, 24 Jun 2003 13:46:24 +0400 On Mon, Jun 23, 2003 at 11:30:14AM -0700, Dag-Erling Sm?rgrav wrote: > He's wrong. The full text of section 2.6.4 is: Now, he has clarified himself, and pointed me to rationale. This is the relevant part of rationale for 2.6.4: "The syntax and semantics for arithmetic were changed for the ISO/IEC 9945-2:1993 standard. The language is essentially a pure arithmetic evaluator of constants and operators (excluding assignment) and represents a simple subset of the previous arithmetic language (which was derived from the KornShell "(())" construct)." .. "The portion of the ISO C standard arithmetic operations selected corresponds to the operations historically supported in the KornShell." In other words, rationale says that only constants and operators are the language of arithmetic evaluation, and assignment shouldn't be supported. Jens, perhaps, you may clarify further, what particular test you've run, post snippets of the code in question? If the tests are valid and verified OpenGroup ones, we may have to ask them for clarification, or issue a defect report.. -- Regards, Wartan. From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 04:44:20 2003 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 201CC37B401 for ; Tue, 24 Jun 2003 04:44:20 -0700 (PDT) Received: from HAL9000.homeunix.com (ip114.bella-vista.sfo.interquest.net [66.199.86.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A96643FAF for ; Tue, 24 Jun 2003 04:44:19 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.9) with ESMTP id h5OBiIiP073234 for ; Tue, 24 Jun 2003 04:44:18 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.9/Submit) id h5OBiIIW073233 for standards@FreeBSD.ORG; Tue, 24 Jun 2003 04:44:18 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Tue, 24 Jun 2003 04:44:18 -0700 From: David Schultz To: standards@FreeBSD.ORG Message-ID: <20030624114418.GA58305@HAL9000.homeunix.com> Mail-Followup-To: standards@FreeBSD.ORG Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 11:44:20 -0000 The following patch adds support to scanf(3) for various floating point formats specified in C99. The old code encodes the parse state as a set of flags; this does not scale well due to the complexity of the logic needed to ungetc() the right amount in the end. The new version uses a real state machine. It isn't optimized, but I find it clearer, and it's just as short as the integer-parsing code. Note that strtod() still does the actual conversion, but scanf() is responsible for knowing exactly how much to read from the file, so it has to understand exactly what constitutes a valid floating point number. New features: - parse [+|-]Inf, [+|-]NaN, nan(...), etc. - handle hex FP constants, e.g. -0xabc.123p+56 - add %a and %A, which are aliases for %e - long doubles are now supported - updated documentation, with incorrect description of %a removed Outstanding issues: - I'm not sure that it's okay to use isdigit(3) and friends in sprintf(). The standard seems to imply that it would be okay if every digit in the C locale were also a digit in all other locales. Comments and suggestions are appreciated. Index: lib/libc/stdio/vfscanf.c =================================================================== RCS file: /cvs/src/lib/libc/stdio/vfscanf.c,v retrieving revision 1.31 diff -u -r1.31 vfscanf.c --- lib/libc/stdio/vfscanf.c 1 Nov 2002 05:13:01 -0000 1.31 +++ lib/libc/stdio/vfscanf.c 20 May 2003 11:35:37 -0000 @@ -81,16 +81,11 @@ #define UNSIGNED 0x8000 /* %[oupxX] conversions */ /* - * The following are used in numeric conversions only: - * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; - * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. + * The following are used in integral conversions only: + * SIGNOK, NDIGITS, PFXOK, and NZDIGITS */ #define SIGNOK 0x40 /* +/- is (still) legal */ #define NDIGITS 0x80 /* no digits detected */ - -#define DPTOK 0x100 /* (float) decimal point is still legal */ -#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */ - #define PFXOK 0x100 /* 0x prefix is (still) legal */ #define NZDIGITS 0x200 /* no zero digits detected */ @@ -104,6 +99,9 @@ #define CT_FLOAT 4 /* %[efgEFG] conversion */ static const u_char *__sccl(char *, const u_char *); +static int parsefloat(FILE *, char *, char *); + +int __scanfdebug = 0; __weak_reference(__vfscanf, vfscanf); @@ -148,9 +146,6 @@ /* `basefix' is used to avoid `if' tests in the integer scanner */ static short basefix[17] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; -#ifdef FLOATING_POINT - char decimal_point = localeconv()->decimal_point[0]; -#endif ORIENT(fp, -1); @@ -258,8 +253,8 @@ break; #ifdef FLOATING_POINT - case 'E': case 'F': case 'G': - case 'e': case 'f': case 'g': + case 'A': case 'E': case 'F': case 'G': + case 'a': case 'e': case 'f': case 'g': c = CT_FLOAT; break; #endif @@ -769,96 +764,26 @@ #ifdef FLOATING_POINT case CT_FLOAT: /* scan a floating point number as if by strtod */ -#ifdef hardway if (width == 0 || width > sizeof(buf) - 1) width = sizeof(buf) - 1; -#else - /* size_t is unsigned, hence this optimisation */ - if (--width > sizeof(buf) - 2) - width = sizeof(buf) - 2; - width++; -#endif - flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; - for (p = buf; width; width--) { - c = *fp->_p; - /* - * This code mimicks the integer conversion - * code, but is much simpler. - */ - switch (c) { - - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - flags &= ~(SIGNOK | NDIGITS); - goto fok; - - case '+': case '-': - if (flags & SIGNOK) { - flags &= ~SIGNOK; - goto fok; - } - break; - case 'e': case 'E': - /* no exponent without some digits */ - if ((flags&(NDIGITS|EXPOK)) == EXPOK) { - flags = - (flags & ~(EXPOK|DPTOK)) | - SIGNOK | NDIGITS; - goto fok; - } - break; - default: - if ((char)c == decimal_point && - (flags & DPTOK)) { - flags &= ~(SIGNOK | DPTOK); - goto fok; - } - break; - } - break; - fok: - *p++ = c; - if (--fp->_r > 0) - fp->_p++; - else if (__srefill(fp)) - break; /* EOF */ - } - /* - * If no digits, might be missing exponent digits - * (just give back the exponent) or might be missing - * regular digits, but had sign and/or decimal point. - */ - if (flags & NDIGITS) { - if (flags & EXPOK) { - /* no digits at all */ - while (p > buf) - __ungetc(*(u_char *)--p, fp); - goto match_failure; - } - /* just a bad exponent (e and maybe sign) */ - c = *(u_char *)--p; - if (c != 'e' && c != 'E') { - (void) __ungetc(c, fp);/* sign */ - c = *(u_char *)--p; - } - (void) __ungetc(c, fp); - } + if ((width = parsefloat(fp, buf, buf + width)) == 0) + goto match_failure; if ((flags & SUPPRESS) == 0) { - double res; - - *p = 0; - /* XXX this loses precision for long doubles. */ - res = strtod(buf, (char **) NULL); - if (flags & LONGDBL) + if (flags & LONGDBL) { + long double res = strtold(buf, &p); *va_arg(ap, long double *) = res; - else if (flags & LONG) + } else if (flags & LONG) { + double res = strtod(buf, &p); *va_arg(ap, double *) = res; - else + } else { + float res = strtof(buf, &p); *va_arg(ap, float *) = res; + } + if (__scanfdebug && p - buf != width) + abort(); nassigned++; } - nread += p - buf; + nread += width; nconversions++; break; #endif /* FLOATING_POINT */ @@ -982,3 +907,157 @@ } /* NOTREACHED */ } + +#ifdef FLOATING_POINT +static int +parsefloat(FILE *fp, char *buf, char *end) +{ + char *commit, *p; + int infnanpos = 0; + enum { + S_START, S_GOTSIGN, S_INF, S_NAN, S_MAYBEHEX, + S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS + } state = S_START; + char c; + char decpt = *localeconv()->decimal_point; + _Bool gotmantdig = 0, ishex = 0; + + /* + * We set commit = p whenever the string we have read so far + * constitutes a valid representation of a floating point + * number by itself. At some point, the parse will complete + * or fail, and we will ungetc() back to the last commit point. + */ + commit = buf - 1; + for (p = buf; p < end; ) { + c = *fp->_p; +reswitch: + switch (state) { + case S_START: + state = S_GOTSIGN; + if (c == '-' || c == '+') + break; + else + goto reswitch; + case S_GOTSIGN: + switch (c) { + case '0': + state = S_MAYBEHEX; + commit = p; + break; + case 'I': + case 'i': + state = S_INF; + break; + case 'N': + case 'n': + state = S_NAN; + break; + default: + state = S_DIGITS; + goto reswitch; + } + break; + case S_INF: + if (infnanpos > 6) + abort(); + if (c == "nfinity"[infnanpos] || + c == "NFINITY"[infnanpos]) { + if (infnanpos == 1) /* "inf" */ + commit = p; + else if (infnanpos == 6) { /* "infinity" */ + commit = p; + goto parsedone; + } + } else + goto parsedone; + infnanpos++; + break; + case S_NAN: + switch (infnanpos) { + case 0: + if (c != 'A' && c != 'a') + goto parsedone; + break; + case 1: + if (c != 'N' && c != 'n') + goto parsedone; + else + commit = p; + break; + case 2: + if (c != '(') + goto parsedone; + break; + default: + if (c == ')') { + commit = p; + goto parsedone; + } else if (!isalnum(c) && c != '_') + goto parsedone; + break; + } + infnanpos++; + break; + case S_MAYBEHEX: + state = S_DIGITS; + if (c == 'X' || c == 'x') { + ishex = 1; + break; + } else { /* we saw a '0', but no 'x' */ + gotmantdig = 1; + goto reswitch; + } + case S_DIGITS: + if (ishex && isxdigit(c) || isdigit(c)) + gotmantdig = 1; + else { + state = S_FRAC; + if (c != decpt) + goto reswitch; + } + if (gotmantdig) + commit = p; + break; + case S_FRAC: + if ((c == 'E' || c == 'e') && !ishex || + (c == 'P' || c == 'p') && ishex) { + if (!gotmantdig) + goto parsedone; + else + state = S_EXP; + } else if (ishex && isxdigit(c) || isdigit(c)) { + commit = p; + gotmantdig = 1; + } else + goto parsedone; + break; + case S_EXP: + state = S_EXPDIGITS; + if (c == '-' || c == '+') + break; + else + goto reswitch; + case S_EXPDIGITS: + if (isdigit(c)) + commit = p; + else + goto parsedone; + break; + default: + abort(); + } + *p++ = c; + if (--fp->_r > 0) + fp->_p++; + else if (__srefill(fp)) + break; /* EOF */ + } + +parsedone: + while (commit < --p) + __ungetc(*(u_char *)p, fp); + *++commit = '\0'; + return (commit - buf); +} +#endif Index: lib/libc/stdio/scanf.3 =================================================================== RCS file: /cvs/src/lib/libc/stdio/scanf.3,v retrieving revision 1.23 diff -u -r1.23 scanf.3 --- lib/libc/stdio/scanf.3 6 Jan 2003 06:19:19 -0000 1.23 +++ lib/libc/stdio/scanf.3 23 Jun 2003 04:26:37 -0000 @@ -172,7 +172,9 @@ (rather than .Vt int ) , that the conversion will be one of -.Cm aefg +.Cm a , e , f , +or +.Cm g and the next pointer is a pointer to .Vt double (rather than @@ -197,15 +199,11 @@ .Vt int ) . .It Cm L Indicates that the conversion will be one of -.Cm aef +.Cm a , e , f , or .Cm g and the next pointer is a pointer to .Vt "long double" . -(This type is not implemented; although the argument is -required to be a pointer to -.Vt "long double" , -no additional precision is used in the conversion.) .It Cm j Indicates that the conversion will be one of .Cm dioux @@ -309,29 +307,16 @@ Matches an optionally signed hexadecimal integer; the next pointer must be a pointer to .Vt "unsigned int" . -.It Cm e , E , f , F , g , G -Matches an optionally signed floating-point number; -the next pointer must be a pointer to -.Vt float . -.It Cm a , A -Matches a hexadecimal number represented in the style -.Sm off -.Oo \- Oc Li 0x Ar h Li \&. Ar hhh Cm p Oo \\*[Pm] Oc Ar d . -.Sm on -This is an exact conversion of the sign, exponent, mantissa internal -floating point representation; the -.Sm off -.Oo \- Oc Li 0x Ar h Li \&. Ar hhh -.Sm on -portion represents exactly the mantissa; only denormalized -mantissas have a zero value to the left of the hexadecimal -point. -The -.Cm p -is a literal character -.Ql p ; -the exponent is preceded by a positive or negative sign -and is represented in decimal. +.It Cm a , A , e , E , f , F , g , G +Matches a floating-point number in the style of +.Xr strtod 3 . +The next pointer must be a pointer to +.Vt float +(unless +.Cm l +or +.Cm L +is specified.) .It Cm s Matches a sequence of non-white-space characters; the next pointer must be a pointer to @@ -524,12 +509,6 @@ The .Cm %n$ modifiers for positional arguments are not implemented. -.Pp -The -.Cm \&%a -and -.Cm \&%A -floating-point formats are not implemented. .Pp The .Nm From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 05:42:38 2003 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 6C0D037B401; Tue, 24 Jun 2003 05:42:37 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2807943F3F; Tue, 24 Jun 2003 05:42:36 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.9/8.12.9) with ESMTP id h5OCgYt0083905; Tue, 24 Jun 2003 16:42:35 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.9/8.12.9/Submit) id h5OCgYA1083904; Tue, 24 Jun 2003 16:42:34 +0400 (MSD) Date: Tue, 24 Jun 2003 16:42:34 +0400 From: Andrey Chernov To: standards@FreeBSD.ORG Message-ID: <20030624124233.GA83552@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030624114418.GA58305@HAL9000.homeunix.com> User-Agent: Mutt/1.5.4i cc: das@FreeBSD.ORG Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 12:42:38 -0000 On Tue, Jun 24, 2003 at 04:44:18 -0700, David Schultz wrote: > Outstanding issues: > - I'm not sure that it's okay to use isdigit(3) and > friends in sprintf(). The standard seems to imply that > it would be okay if every digit in the C locale were > also a digit in all other locales. isdigit() always for 0..9 only, isxdigit() is a like, don't know, what you mean by 'friends'. > + } else if (!isalnum(c) && c != '_') F.e. isalnum() you should use with care, it may hit national characters. BTW, in all cases calling is*() macros on char may have side effects, you need to promote argument to (unsigned char) first. From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 06:25:55 2003 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 39C2537B401 for ; Tue, 24 Jun 2003 06:25:55 -0700 (PDT) Received: from HAL9000.homeunix.com (ip114.bella-vista.sfo.interquest.net [66.199.86.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B55D43F75 for ; Tue, 24 Jun 2003 06:25:54 -0700 (PDT) (envelope-from das@freebsd.org) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.9) with ESMTP id h5ODPriP038573; Tue, 24 Jun 2003 06:25:53 -0700 (PDT) (envelope-from das@freebsd.org) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.9/Submit) id h5ODPq56038567; Tue, 24 Jun 2003 06:25:52 -0700 (PDT) (envelope-from das@freebsd.org) Date: Tue, 24 Jun 2003 06:25:52 -0700 From: David Schultz To: Andrey Chernov Message-ID: <20030624132552.GA33228@HAL9000.homeunix.com> Mail-Followup-To: Andrey Chernov , standards@freebsd.org References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030624124233.GA83552@nagual.pp.ru> cc: standards@freebsd.org Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 13:25:55 -0000 On Tue, Jun 24, 2003, Andrey Chernov wrote: > On Tue, Jun 24, 2003 at 04:44:18 -0700, David Schultz wrote: > > Outstanding issues: > > - I'm not sure that it's okay to use isdigit(3) and > > friends in sprintf(). The standard seems to imply that > > it would be okay if every digit in the C locale were > > also a digit in all other locales. > > isdigit() always for 0..9 only, isxdigit() is a like, don't know, what > you mean by 'friends'. > > > + } else if (!isalnum(c) && c != '_') > > F.e. isalnum() you should use with care, it may hit national characters. That's what I was worried about. I believe that's okay by the standard as long as isalnum() still accepts *at least* [a-z][A-Z][0-9] in any locale. Is this a valid assumption or do I need to test by hand? > BTW, in all cases calling is*() macros on char may have side effects, you > need to promote argument to (unsigned char) first. Okay, I'll do that. Thanks. From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 07:37:07 2003 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 DB4EF37B401 for ; Tue, 24 Jun 2003 07:37:07 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACD6043F3F for ; Tue, 24 Jun 2003 07:37:06 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.9/8.12.9) with ESMTP id h5OEb5t0086966 for ; Tue, 24 Jun 2003 18:37:05 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.9/8.12.9/Submit) id h5OEb5aD086965 for standards@freebsd.org; Tue, 24 Jun 2003 18:37:05 +0400 (MSD) Date: Tue, 24 Jun 2003 18:37:05 +0400 From: Andrey Chernov To: standards@freebsd.org Message-ID: <20030624143705.GB86804@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> <20030624132552.GA33228@HAL9000.homeunix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030624132552.GA33228@HAL9000.homeunix.com> User-Agent: Mutt/1.5.4i Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 14:37:08 -0000 On Tue, Jun 24, 2003 at 06:25:52 -0700, David Schultz wrote: > That's what I was worried about. I believe that's okay by the > standard as long as isalnum() still accepts *at least* > [a-z][A-Z][0-9] in any locale. Is this a valid assumption or do I > need to test by hand? Yes, *at least* is guaranteed, we have only ASCII-compatible locales and will never have other ones, due to big problems with C own internal charset, etc. From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 10:50:09 2003 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 85F0337B401 for ; Tue, 24 Jun 2003 10:50:09 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0580043F75 for ; Tue, 24 Jun 2003 10:50:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5OHo8Up005448 for ; Tue, 24 Jun 2003 10:50:08 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5OHo8ih005447; Tue, 24 Jun 2003 10:50:08 -0700 (PDT) Date: Tue, 24 Jun 2003 10:50:08 -0700 (PDT) Message-Id: <200306241750.h5OHo8ih005447@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Jens Schweikhardt Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jens Schweikhardt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jun 2003 17:50:09 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Jens Schweikhardt To: Wartan Hachaturow Cc: Dag-Erling Sm?rgrav , freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Tue, 24 Jun 2003 19:16:00 +0200 On Tue, Jun 24, 2003 at 01:46:24PM +0400, Wartan Hachaturow wrote: # On Mon, Jun 23, 2003 at 11:30:14AM -0700, Dag-Erling Sm?rgrav wrote: # # > He's wrong. The full text of section 2.6.4 is: # # Now, he has clarified himself, and pointed me to rationale. # This is the relevant part of rationale for 2.6.4: # # "The syntax and semantics for arithmetic were changed for the ISO/IEC # 9945-2:1993 standard. The language is essentially a pure arithmetic # evaluator of constants and operators (excluding assignment) and # represents a simple subset of the previous arithmetic language (which # was derived from the KornShell "(())" construct)." # .. # "The portion of the ISO C standard arithmetic operations selected # corresponds to the operations historically supported in the KornShell." # # In other words, rationale says that only constants and operators are the # language of arithmetic evaluation, and assignment shouldn't be # supported. The rationale is not a normative part of POSIX 2001. If it disagrees with anything in POSIX 2001, then POSIX 2001 is what counts. # Jens, perhaps, you may clarify further, what particular test you've run, # post snippets of the code in question? If the tests are valid and # verified OpenGroup ones, we may have to ask them for clarification, # or issue a defect report.. I'm using the VSC-lite test suite with the TET3.6 Test Environment as made available for Austin Group members by the OpenGroup. The TET contains scripts to generate the automated test suite. It is the generation step that already fails (so I can't even *run* the actual test suite). The script in question from tet3.6-lite.src.tar.gz is src/posix_sh/api/tcm.sh: schweikh@hal9000:/tmp $ fgrep '$((' src/posix_sh/api/tcm.sh : $((tet_l1_iccount += 1)) while test $((tet_l1_tpnum += 1)) -le $tet_tpcount : $((tet_l1_tpcount += 1)) while test $((tet_l3_sig += 1)) -lt $TET_NSIG : $((tet_l31_testnum += $#)) : $((tet_testnum += tet_l33_tpnum - 1)) if test $tet_l36_icstart -lt $((tet_l34_last_icend + 1)) tet_l36_icstart=$((tet_l34_last_icend + 1)) : $((tet_l36_icstart += 1)) while test $((tet_l36_icstart += 1)) -le $tet_l36_icend while test $((tet_l36_icend -= 1)) -gt $tet_l36_icstart tet_l37_icnum=$((tet_l37_icstart - 1)) while test $((tet_l37_icnum += 1)) -le $tet_l37_icend Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 11:49:27 2003 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 513B937B401; Tue, 24 Jun 2003 11:49:27 -0700 (PDT) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6871043F85; Tue, 24 Jun 2003 11:49:26 -0700 (PDT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.12.9/8.12.9) with ESMTP id h5OInOWa004869; Tue, 24 Jun 2003 14:49:24 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20030624124233.GA83552@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> Date: Tue, 24 Jun 2003 14:49:22 -0400 To: Andrey Chernov , standards@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: unclaimed-spam X-Scanned-By: CanIt (www . canit . ca) cc: das@freebsd.org Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 18:49:27 -0000 At 4:42 PM +0400 6/24/03, Andrey Chernov wrote: >BTW, in all cases calling is*() macros on char may have side >effects, you need to promote argument to (unsigned char) first. For what it's worth, I like to use the following #define'd macros for using the is*() and to*() routines with byte values. These have worked well for me, if for no other reason than they explicitly remind me that I have to do something for char types... /* * All the standard is*() routines are defined to work on an 'int', * in the range of 0 to 255 plus EOF (-1). So we define wrappers * which can take values of type 'char', either signed or unsigned. */ #define isdigitch(Anychar) isdigit(((int) Anychar) & 255) #define isupperch(Anychar) isupper(((int) Anychar) & 255) #define isxdigitch(Anychar) isdigit(((int) Anychar) & 255) #define tolowerch(Anychar) tolower(((int) Anychar) & 255) -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 11:57:07 2003 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 10FAF37B401; Tue, 24 Jun 2003 11:57:07 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6DF843FBD; Tue, 24 Jun 2003 11:57:05 -0700 (PDT) (envelope-from ache@pobrecita.freebsd.ru) Received: from pobrecita.freebsd.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.12.9/8.12.9) with ESMTP id h5OIv4t0092175; Tue, 24 Jun 2003 22:57:04 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.9/8.12.9/Submit) id h5OIv4re092174; Tue, 24 Jun 2003 22:57:04 +0400 (MSD) Date: Tue, 24 Jun 2003 22:57:04 +0400 From: Andrey Chernov To: Garance A Drosihn Message-ID: <20030624185704.GB92022@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i cc: standards@freebsd.org cc: das@freebsd.org Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 18:57:07 -0000 On Tue, Jun 24, 2003 at 14:49:22 -0400, Garance A Drosihn wrote: > #define isdigitch(Anychar) isdigit(((int) Anychar) & 255) > #define isupperch(Anychar) isupper(((int) Anychar) & 255) > #define isxdigitch(Anychar) isdigit(((int) Anychar) & 255) > #define tolowerch(Anychar) tolower(((int) Anychar) & 255) Just (unsigned char) cast produce better code and more readable. In any case & 255 alone will be enough without needs to convert to (int) first. From owner-freebsd-standards@FreeBSD.ORG Tue Jun 24 12:27:33 2003 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 A8EA937B401; Tue, 24 Jun 2003 12:27:33 -0700 (PDT) Received: from smtp4.server.rpi.edu (smtp4.server.rpi.edu [128.113.2.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id E798343FA3; Tue, 24 Jun 2003 12:27:32 -0700 (PDT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp4.server.rpi.edu (8.12.9/8.12.9) with ESMTP id h5OJRU1g017642; Tue, 24 Jun 2003 15:27:30 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20030624185704.GB92022@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> <20030624185704.GB92022@nagual.pp.ru> Date: Tue, 24 Jun 2003 15:27:29 -0400 To: Andrey Chernov From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: unclaimed-spam X-Scanned-By: CanIt (www . canit . ca) cc: standards@freebsd.org cc: das@freebsd.org Subject: Re: scanf(3) patch for C99-conformant FP parsing 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, 24 Jun 2003 19:27:33 -0000 At 10:57 PM +0400 6/24/03, Andrey Chernov wrote: >On Tue, Jun 24, 2003, Garance A Drosihn wrote: > >> #define isdigitch(Anychar) isdigit(((int) Anychar) & 255) >> #define isupperch(Anychar) isupper(((int) Anychar) & 255) >> #define isxdigitch(Anychar) isdigit(((int) Anychar) & 255) >> #define tolowerch(Anychar) tolower(((int) Anychar) & 255) > >Just (unsigned char) cast produce better code and more readable. > >In any case & 255 alone will be enough without needs to convert >to (int) first. Yeah, I actually have two or three different versions of the macros, depending on what I was thinking at the time. The above lines are from a file I just happened to have open while reading today's email. It wouldn't surprise me too much if they include a bit of overkill. In any case, my main suggestion is having is*ch() macros, and using them whenever dealing with byte-values. I often see code that uses one of the is*() routines with a parameter that is 'char *'. It's an easy mistake to make, and it can introduce subtle bugs when porting code. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu