From owner-freebsd-standards@FreeBSD.ORG Sun Apr 20 19:10:29 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 B24AA37B401; Sun, 20 Apr 2003 19:10:29 -0700 (PDT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3352E43F3F; Sun, 20 Apr 2003 19:10:29 -0700 (PDT) (envelope-from leimy2k@mac.com) Received: from asmtp01.mac.com (asmtp01-qfe3 [10.13.10.65]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h3L2AT0x026738; Sun, 20 Apr 2003 19:10:29 -0700 (PDT) Received: from mac.com ([67.33.226.72]) by asmtp01.mac.com (Netscape Messaging Server 4.15) with ESMTP id HDO8PG00.KBY; Sun, 20 Apr 2003 19:10:28 -0700 Date: Sun, 20 Apr 2003 21:10:26 -0500 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; charset=US-ASCII; format=flowed From: David Leimbach To: freebsd-current@freebsd.org, freebsd-standards@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com> X-Mailer: Apple Mail (2.552) Subject: test-strerror regression test 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, 21 Apr 2003 02:10:30 -0000 In /usr/src/tools/regression/lib/libc/string there is a test "test-strerror.c" which attempts to verify a correct value for strerror(0); This is probably a bogus value for strerror even though the posix standard does say it returns a string for any int. Unless the locales for the area are all predefined somewhere we probably don't need this regression test as it tests for the validity of the strings. In fact this test fails due to it not asserting the correct string. errno = 0; sret = strerror(0); assert(strcmp(sret, "Unknown Error: 0") == 0); assert(errno == EINVAL); I don't think this code has been tested in a long time... The string should be "Undefined error: 0" and why would 0 errno be EINVAL? If we are going to have a test suite it should at least be correct and documented don't you think? Dave From owner-freebsd-standards@FreeBSD.ORG Sun Apr 20 21:37:45 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 494C137B401; Sun, 20 Apr 2003 21:37:45 -0700 (PDT) Received: from altair.mukappabeta.net (pC19E930E.dip.t-dialin.net [193.158.147.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6CB0043FBF; Sun, 20 Apr 2003 21:37:43 -0700 (PDT) (envelope-from mkb@mukappabeta.de) Received: from mukappabeta.de (localhost [127.0.0.1]) by altair.mukappabeta.net (Postfix) with ESMTP id 47434591A; Mon, 21 Apr 2003 06:40:57 +0200 (CEST) Message-ID: <3EA37658.1000700@mukappabeta.de> Date: Mon, 21 Apr 2003 06:40:56 +0200 From: Matthias Buelow User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4a) Gecko/20030418 X-Accept-Language: de-de, de, en, en-gb, en-us MIME-Version: 1.0 To: David Leimbach References: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com> In-Reply-To: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-current@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: test-strerror regression test 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, 21 Apr 2003 04:37:45 -0000 David Leimbach wrote: > If we are going to have a test suite it should at least be correct and > documented don't you think? In fact, I think there should be a lot more testsuites... following a "make testworld" a "make buildworld" with a bazillion of test suites would be an excellent idea, especially for all of the library routines. -- Matthias Buelow home: mkb/at/mukappabeta.de uni: mkb/at/informatik.uni-wuerzburg.de From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 00:34:05 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 D619737B401; Mon, 21 Apr 2003 00:34:05 -0700 (PDT) Received: from smtp02.syd.iprimus.net.au (smtp02.syd.iprimus.net.au [210.50.76.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4842743FA3; Mon, 21 Apr 2003 00:34:05 -0700 (PDT) (envelope-from tim@robbins.dropbear.id.au) Received: from dilbert.robbins.dropbear.id.au (210.50.80.82) by smtp02.syd.iprimus.net.au (7.0.012) id 3E8A1600003AB4C5; Mon, 21 Apr 2003 17:34:03 +1000 Received: by dilbert.robbins.dropbear.id.au (Postfix, from userid 1000) id 066B1B4CD; Mon, 21 Apr 2003 17:33:54 +1000 (EST) Date: Mon, 21 Apr 2003 17:33:54 +1000 From: Tim Robbins To: David Leimbach Message-ID: <20030421173354.A41423@dilbert.robbins.dropbear.id.au> References: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com>; from leimy2k@mac.com on Sun, Apr 20, 2003 at 09:10:26PM -0500 cc: freebsd-current@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: test-strerror regression test 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, 21 Apr 2003 07:34:06 -0000 On Sun, Apr 20, 2003 at 09:10:26PM -0500, David Leimbach wrote: > In /usr/src/tools/regression/lib/libc/string there is a test > "test-strerror.c" which attempts to verify a correct value for > strerror(0); > > This is probably a bogus value for strerror even though the posix > standard > does say it returns a string for any int. Unless the locales for the > area are > all predefined somewhere we probably don't need this regression test > as it tests for the validity of the strings. > > In fact this test fails due to it not asserting the correct string. > > errno = 0; > sret = strerror(0); > assert(strcmp(sret, "Unknown Error: 0") == 0); > assert(errno == EINVAL); > > > I don't think this code has been tested in a long time... The string > should be "Undefined error: 0" and why would 0 errno be EINVAL? > > If we are going to have a test suite it should at least be correct and > documented don't you think? The regression tests are regression tests, and not conformance tests for any particular standard. FreeBSD prints "Unknown error: x", not "No error" like MSVC, and not "Error x" like Solaris. FreeBSD 4.8-RELEASE and 5.0-CURRENT pass the tests. $ uname -srm FreeBSD 5.0-CURRENT i386 $ make cc -O -pipe -mcpu=pentiumpro test-strerror.c -o test-strerror cc -O -pipe -mcpu=pentiumpro test-wcschr.c -o test-wcschr cc -O -pipe -mcpu=pentiumpro test-wcscmp.c -o test-wcscmp cc -O -pipe -mcpu=pentiumpro test-wcslen.c -o test-wcslen cc -O -pipe -mcpu=pentiumpro test-wmemchr.c -o test-wmemchr cc -O -pipe -mcpu=pentiumpro test-wmemset.c -o test-wmemset for p in test-strerror test-wcschr test-wcscmp test-wcslen test-wmemchr test-wmemset; do /home/tim/p4/wchar/src/tools/regression/lib/libc/string/$p; done PASS strerror() PASS strerror_r() PASS wcschr() PASS wcscmp() PASS wcslen() PASS wmemchr() PASS wmemset() Tim From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 01:01:34 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 4870C37B401; Mon, 21 Apr 2003 01:01:34 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 493F943FE5; Mon, 21 Apr 2003 01:01:33 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h3L81JA7022900; Mon, 21 Apr 2003 02:01:20 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 21 Apr 2003 02:01:06 -0600 (MDT) Message-Id: <20030421.020106.41513803.imp@bsdimp.com> To: ertr1013@student.uu.se From: "M. Warner Losh" In-Reply-To: <20030416172723.GA13575@falcon.midgard.homeip.net> References: <20030416125715.GA12300@falcon.midgard.homeip.net> <20030417005708.D6167@gamplex.bde.org> <20030416172723.GA13575@falcon.midgard.homeip.net> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-standards@freebsd.org cc: lamer@properfucked.net cc: schweikh@freebsd.org Subject: Re: standards/50889: NULL defined as 0 instead of (void *)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: Mon, 21 Apr 2003 08:01:34 -0000 I have a #define in my tree that I switch back and forth from time to time: #if defined(_cplusplus) || !defined(_NULL_VOID) #define NULL 0L #else #define NULL (void *) 0 #endif and I add -D_NULL_VOID to build when I want to detect problems that (void *) 0 detects, then switch it back to 0 for the problems that that detects. You can't win here. I'd be inclined to leave things as the status quo. Warner From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 03:48:43 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 7CACC37B401 for ; Mon, 21 Apr 2003 03:48:43 -0700 (PDT) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id EE80A43FE1 for ; Mon, 21 Apr 2003 03:48:41 -0700 (PDT) (envelope-from ertr1013@student.uu.se) Received: (qmail 92991 invoked by uid 1001); 21 Apr 2003 10:48:40 -0000 Date: Mon, 21 Apr 2003 12:48:40 +0200 From: Erik Trulsson To: "M. Warner Losh" Message-ID: <20030421104840.GA92922@falcon.midgard.homeip.net> Mail-Followup-To: "M. Warner Losh" , bde@zeta.org.au, lamer@properfucked.net, freebsd-standards@freebsd.org, schweikh@freebsd.org References: <20030416125715.GA12300@falcon.midgard.homeip.net> <20030417005708.D6167@gamplex.bde.org> <20030416172723.GA13575@falcon.midgard.homeip.net> <20030421.020106.41513803.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030421.020106.41513803.imp@bsdimp.com> User-Agent: Mutt/1.5.4i cc: freebsd-standards@freebsd.org cc: lamer@properfucked.net cc: schweikh@freebsd.org Subject: Re: standards/50889: NULL defined as 0 instead of (void *)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: Mon, 21 Apr 2003 10:48:43 -0000 On Mon, Apr 21, 2003 at 02:01:06AM -0600, M. Warner Losh wrote: > I have a #define in my tree that I switch back and forth from time to > time: > > #if defined(_cplusplus) || !defined(_NULL_VOID) > #define NULL 0L Why not just plain 0? I think either will work fine so it doesn't matter really matter much but I am a bit curious. > #else > #define NULL (void *) 0 Won't work correctly. You need to use ((void*)0) instead with the extra parenthesis. Otherwise expressions like 'sizeof NULL' will fail to compile. > #endif > > and I add -D_NULL_VOID to build when I want to detect problems that > (void *) 0 detects, then switch it back to 0 for the problems that > that detects. > > You can't win here. I'd be inclined to leave things as the status quo. I agree completely with that. -- Erik Trulsson ertr1013@student.uu.se From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 04:00:20 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 A3F8B37B401 for ; Mon, 21 Apr 2003 04:00:20 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E51543FBF for ; Mon, 21 Apr 2003 04:00:19 -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 h3LB0JUp006332 for ; Mon, 21 Apr 2003 04:00:19 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3LB0Jci006326; Mon, 21 Apr 2003 04:00:19 -0700 (PDT) Resent-Date: Mon, 21 Apr 2003 04:00:19 -0700 (PDT) Resent-Message-Id: <200304211100.h3LB0Jci006326@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, "Sergey A.Osokin" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D273B37B401 for ; Mon, 21 Apr 2003 03:59:50 -0700 (PDT) Received: from freebsd.org.ru (freebsd.org.ru [194.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id B36A243FD7 for ; Mon, 21 Apr 2003 03:59:49 -0700 (PDT) (envelope-from osa@freebsd.org.ru) Received: by freebsd.org.ru (Postfix, from userid 1000) id CECFDA5; Mon, 21 Apr 2003 14:59:46 +0400 (MSD) Message-Id: <20030421105946.CECFDA5@freebsd.org.ru> Date: Mon, 21 Apr 2003 14:59:46 +0400 (MSD) From: "Sergey A.Osokin" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A.Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2003 11:00:20 -0000 >Number: 51209 >Category: standards >Synopsis: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Mon Apr 21 04:00:18 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Sergey A. Osokin >Release: FreeBSD 5.0-CURRENT i386 >Organization: n/a >Environment: System: FreeBSD 5.0-CURRENT i386 >Description: add a64l()/l64a/l64a_r functions (obtained from NetBSD) From SUSv3 documentation: Issue 5: Moved from X/OPEN UNIX extension to BASE. >How-To-Repeat: >Fix: Index: src/lib/libc/stdlib/Makefile.inc =================================================================== RCS file: /home/ncvs/src/lib/libc/stdlib/Makefile.inc,v retrieving revision 1.45 diff -u -r1.45 Makefile.inc --- src/lib/libc/stdlib/Makefile.inc 5 Apr 2003 07:33:46 -0000 1.45 +++ src/lib/libc/stdlib/Makefile.inc 21 Apr 2003 09:52:58 -0000 @@ -4,26 +4,28 @@ # machine-independent stdlib sources .PATH: ${.CURDIR}/${MACHINE_ARCH}/stdlib ${.CURDIR}/stdlib -MISRCS+=_Exit.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \ +MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \ bsearch.c calloc.c div.c exit.c getenv.c getopt.c getopt_long.c \ getsubopt.c grantpt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \ - insque.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c merge.c \ - putenv.c qsort.c qsort_r.c radixsort.c rand.c random.c reallocf.c \ - realpath.c remque.c setenv.c strfmon.c strhash.c strtoimax.c \ - strtol.c strtoll.c strtoq.c strtoul.c strtoull.c strtoumax.c strtouq.c \ - system.c tdelete.c tfind.c tsearch.c twalk.c + insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \ + merge.c putenv.c qsort.c qsort_r.c radixsort.c rand.c random.c \ + reallocf.c realpath.c remque.c setenv.c strfmon.c strhash.c \ + strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \ + strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c # machine-dependent stdlib sources .if exists(${.CURDIR}/${MACHINE_ARCH}/stdlib/Makefile.inc) .include "${.CURDIR}/${MACHINE_ARCH}/stdlib/Makefile.inc" .endif -MAN+= abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \ - div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \ - hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \ - lsearch.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 random.3 \ - realpath.3 strfmon.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 +MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 \ + bsearch.3 div.3 exit.3 getenv.3 getopt.3 getopt_long.3 \ + getsubopt.3 grantpt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 \ + labs.3 ldiv.3 llabs.3 lldiv.3 lsearch.3 malloc.3 memory.3 qsort.3 \ + radixsort.3 rand.3 random.3 realpath.3 strfmon.3 strtod.3 strtol.3 \ + strtoul.3 system.3 tsearch.3 +MLINKS+=a64l.3 l64a.3 l64a_r.3 MLINKS+=atol.3 atoll.3 MLINKS+=exit.3 _Exit.3 MLINKS+=getenv.3 putenv.3 getenv.3 setenv.3 getenv.3 unsetenv.3 --- /dev/null Mon Apr 21 03:02:32 2003 +++ src/lib/libc/stdlib/a64l.3 Wed Apr 16 17:34:45 2003 @@ -0,0 +1,140 @@ +.\" $NetBSD: a64l.3,v 1.8 2003/04/16 13:34:45 wiz Exp $ +.\" +.\" Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Klaus Klein. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd April 21, 2003 +.Dt A64L 3 +.Os +.Sh NAME +.Nm a64l , +.Nm l64a , +.Nm l64a_r +.Nd "convert between a long integer and a base-64 ASCII string" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft long +.Fn a64l "const char *s" +.Ft char * +.Fn l64a "long int l" +.Ft int +.Fn l64a_r "long int l" "char *buffer" "int buflen" +.Sh DESCRIPTION +The +.Fn a64l +and +.Fn l64a +functions convert between a long integer and its base-64 ASCII string +representation. +.Pp +The characters used to represent ``digits'' are +`.' for 0, +`/' for 1, +`0' - `9' for 2 - 11, +`A' - `Z' for 12 - 37, and +`a' - `z' for 38 - 63. +.Pp +.Fn a64l +takes a pointer to a NUL-terminated base-64 ASCII string +representation, +.Fa s , +and returns the corresponding long integer value. +.Pp +.Fn l64a +takes a long integer value, +.Fa l , +and returns a pointer to the corresponding NUL-terminated base-64 +ASCII string representation. +.Pp +.Fn l64a_r +performs a conversion identical to that of +.Fn l64a +and stores the resulting representation in the memory area pointed to by +.Fa buffer , +consuming at most +.Fa buflen +characters including the terminating NUL character. +.Sh RETURN VALUES +On successful completion, +.Fn a64l +returns the long integer value corresponding to the input string. +If the string pointed to by +.Fa s +is an empty string, +.Fn a64l +returns a value of 0L. +.Pp +.Fn l64a +returns a pointer to the base-64 ASCII string representation corresponding to +the input value. +If +.Fa l +is 0L, +.Fn l64a +returns a pointer to an empty string. +.Pp +On successful completion, +.Fn l64a_r +returns 0; if +.Fa buffer +is of insufficient length, -1 is returned. +.Sh SEE ALSO +.Xr strtol 3 +.Sh STANDARDS +The +.Fn a64l +and +.Fn l64a +functions conform to +.St -xpg4.2 . +The +.Fn l64a_r +function conforms to +.St -svid4 , +Multithreading Extension. +.Sh BUGS +The +.Fn l64a +function is not reentrant. +The value returned by it points into a static buffer area; +subsequent calls to +.Fn la64a +may overwrite this buffer. +In multi-threaded applications, +.Fn l64a_r +should be used instead. --- /dev/null Mon Apr 21 03:02:32 2003 +++ src/lib/libc/stdlib/a64l.c Mon Apr 21 12:59:19 2003 @@ -0,0 +1,48 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: a64l.c,v 1.8 2000/01/22 22:19:19 mycroft Exp $"); +#endif /* LIBC_SCCS and not lint */ +__FBSDID("$FreeBSD$"); + +#include "namespace.h" + +#include +#include +#include +#include + +#ifndef _DIAGASSERT +#define _DIAGASSERT(X) +#endif + +long +a64l(const char *s) +{ + long value, digit, shift; + int i; + + _DIAGASSERT(s != NULL); + + value = 0; + shift = 0; + for (i = 0; *s && i < 6; i++, s++) { + if (*s <= '/') + digit = *s - '.'; + else if (*s <= '9') + digit = *s - '0' + 2; + else if (*s <= 'Z') + digit = *s - 'A' + 12; + else + digit = *s - 'a' + 38; + + value |= digit << shift; + shift += 6; + } + + return (value); +} --- /dev/null Mon Apr 21 03:02:32 2003 +++ src/lib/libc/stdlib/l64a.c Mon Apr 21 13:43:51 2003 @@ -0,0 +1,61 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: l64a.c,v 1.12 2000/01/22 22:19:19 mycroft Exp $"); +#endif /* LIBC_SCCS and not lint */ +__FBSDID("$FreeBSD$"); + +#include "namespace.h" + +#include +#include +#include + +#ifndef _DIAGASSERT +#define _DIAGASSERT(X) +#endif + +char * +l64a (long value) +{ + static char buf[8]; + + (void)l64a_r(value, buf, sizeof (buf)); + return buf; +} + +int +l64a_r (long value, char *buffer, int buflen) +{ + char *s = buffer; + int digit; + unsigned long v = value; + + _DIAGASSERT(buffer != NULL); + + if (value == 0UL) + goto out; + + for (; v != 0 && buflen > 1; s++, buflen--) { + digit = (int)(v & 0x3f); + + if (digit < 2) + *s = digit + '.'; + else if (digit < 12) + *s = digit + '0' - 2; + else if (digit < 38) + *s = digit + 'A' - 12; + else + *s = digit + 'a' - 38; + v >>= 6; + } + +out: + *s = '\0'; + + return (v == 0UL ? 0 : -1); +} Index: src/include/stdlib.h =================================================================== RCS file: /home/ncvs/src/include/stdlib.h,v retrieving revision 1.48 diff -u -r1.48 stdlib.h --- src/include/stdlib.h 12 Mar 2003 20:29:58 -0000 1.48 +++ src/include/stdlib.h 21 Apr 2003 10:11:03 -0000 @@ -174,7 +174,7 @@ */ #if __XSI_VISIBLE /* XXX XSI requires pollution from here. We'd rather not. */ -/* long a64l(const char *); */ +long a64l(const char *); double drand48(void); /* char *ecvt(double, int, int * __restrict, int * __restrict); */ double erand48(unsigned short[3]); @@ -187,7 +187,7 @@ int grantpt(int); char *initstate(unsigned long /* XSI requires u_int */, char *, long); long jrand48(unsigned short[3]); -/* char *l64a(long); */ +char *l64a(long); void lcong48(unsigned short[7]); long lrand48(void); #ifndef _MKSTEMP_DECLARED @@ -247,6 +247,7 @@ getprogname(void); int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); +int l64a_r (long, char *, int); int mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); void qsort_r(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 04:48:59 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 4D6F437B401; Mon, 21 Apr 2003 04:48:59 -0700 (PDT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id D081943FDF; Mon, 21 Apr 2003 04:48:58 -0700 (PDT) (envelope-from leimy2k@mac.com) Received: from asmtp02.mac.com (asmtp02-qfe3 [10.13.10.66]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h3LBmw2O016058; Mon, 21 Apr 2003 04:48:58 -0700 (PDT) Received: from mac.com ([66.156.160.96]) by asmtp02.mac.com (Netscape Messaging Server 4.15) with ESMTP id HDOZHL00.A1V; Mon, 21 Apr 2003 04:48:57 -0700 Date: Mon, 21 Apr 2003 06:48:56 -0500 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) To: Matthias Buelow From: David Leimbach In-Reply-To: <3EA37658.1000700@mukappabeta.de> Message-Id: <3B73CBEC-73EF-11D7-98DE-0003937E39E0@mac.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) cc: freebsd-current@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: test-strerror regression test 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, 21 Apr 2003 11:48:59 -0000 On Sunday, April 20, 2003, at 11:40 PM, Matthias Buelow wrote: > David Leimbach wrote: > >> If we are going to have a test suite it should at least be correct and >> documented don't you think? > > In fact, I think there should be a lot more testsuites... following a > "make testworld" a "make buildworld" with a bazillion of test suites > would be an excellent idea, especially for all of the library > routines. Yes. I actually agree with you here. In my effort to learn more about this system I am going to see what I can do to add as many new tests as I can. A harness around all tests like "testworld" would be cool... especially if its something that can be started easily from a cron job and have the report dump to file or email. That would be super useful. > > -- > Matthias Buelow > home: mkb/at/mukappabeta.de > uni: mkb/at/informatik.uni-wuerzburg.de > From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 04:51:26 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 C383937B401; Mon, 21 Apr 2003 04:51:26 -0700 (PDT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B15743FE9; Mon, 21 Apr 2003 04:51:26 -0700 (PDT) (envelope-from leimy2k@mac.com) Received: from asmtp01.mac.com (asmtp01-qfe3 [10.13.10.65]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h3LBpPdP001086; Mon, 21 Apr 2003 04:51:25 -0700 (PDT) Received: from mac.com ([66.156.160.96]) by asmtp01.mac.com (Netscape Messaging Server 4.15) with ESMTP id HDOZLP00.U32; Mon, 21 Apr 2003 04:51:25 -0700 Date: Mon, 21 Apr 2003 06:51:24 -0500 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) To: Tim Robbins From: David Leimbach In-Reply-To: <20030421173354.A41423@dilbert.robbins.dropbear.id.au> Message-Id: <938EF288-73EF-11D7-98DE-0003937E39E0@mac.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) cc: freebsd-current@FreeBSD.ORG cc: freebsd-standards@FreeBSD.ORG Subject: Re: test-strerror regression test 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, 21 Apr 2003 11:51:27 -0000 On Monday, April 21, 2003, at 02:33 AM, Tim Robbins wrote: > On Sun, Apr 20, 2003 at 09:10:26PM -0500, David Leimbach wrote: > >> In /usr/src/tools/regression/lib/libc/string there is a test >> "test-strerror.c" which attempts to verify a correct value for >> strerror(0); >> >> This is probably a bogus value for strerror even though the posix >> standard >> does say it returns a string for any int. Unless the locales for the >> area are >> all predefined somewhere we probably don't need this regression test >> as it tests for the validity of the strings. >> >> In fact this test fails due to it not asserting the correct string. >> >> errno = 0; >> sret = strerror(0); >> assert(strcmp(sret, "Unknown Error: 0") == 0); >> assert(errno == EINVAL); >> >> >> I don't think this code has been tested in a long time... The string >> should be "Undefined error: 0" and why would 0 errno be EINVAL? >> >> If we are going to have a test suite it should at least be correct and >> documented don't you think? > > The regression tests are regression tests, and not conformance tests > for any > particular standard. FreeBSD prints "Unknown error: x", not "No error" > like MSVC, and not "Error x" like Solaris. FreeBSD 4.8-RELEASE and > 5.0-CURRENT > pass the tests. > I guess my point was I didn't know how to make these "conform" when I looked at the POSIX standard for SUS. All it said about strerror is that any int should work and return a string per the locale that is currently set. > $ uname -srm > FreeBSD 5.0-CURRENT i386 > $ make > cc -O -pipe -mcpu=pentiumpro test-strerror.c -o test-strerror > cc -O -pipe -mcpu=pentiumpro test-wcschr.c -o test-wcschr > cc -O -pipe -mcpu=pentiumpro test-wcscmp.c -o test-wcscmp > cc -O -pipe -mcpu=pentiumpro test-wcslen.c -o test-wcslen > cc -O -pipe -mcpu=pentiumpro test-wmemchr.c -o test-wmemchr > cc -O -pipe -mcpu=pentiumpro test-wmemset.c -o test-wmemset > for p in test-strerror test-wcschr test-wcscmp test-wcslen > test-wmemchr test-wmemset; do > /home/tim/p4/wchar/src/tools/regression/lib/libc/string/$p; done > PASS strerror() Failed for me due to failing assertions. > PASS strerror_r() > PASS wcschr() > PASS wcscmp() > PASS wcslen() > PASS wmemchr() > PASS wmemset() > > > Tim From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 04:55:18 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 CDDC737B401; Mon, 21 Apr 2003 04:55:18 -0700 (PDT) Received: from freebsd.org.ru (www.freebsd.org.ru [194.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CBC543FDD; Mon, 21 Apr 2003 04:55:18 -0700 (PDT) (envelope-from osa@freebsd.org.ru) Received: by freebsd.org.ru (Postfix, from userid 1000) id E8A1FA5; Mon, 21 Apr 2003 15:55:16 +0400 (MSD) Date: Mon, 21 Apr 2003 15:55:16 +0400 From: "Sergey A. Osokin" To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org Message-ID: <20030421115516.GD54777@freebsd.org.ru> References: <20030421105946.CECFDA5@freebsd.org.ru> <200304211100.h3LB0I01006019@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200304211100.h3LB0I01006019@freefall.freebsd.org> User-Agent: Mutt/1.5.4i Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: osa@FreeBSD.org.ru List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2003 11:55:19 -0000 On Mon, Apr 21, 2003 at 04:00:18AM -0700, FreeBSD-gnats-submit@FreeBSD.org wrote: > Thank you very much for your problem report. > It has the internal identification `standards/51209'. > The individual assigned to look at your > report is: freebsd-standards. > > You can access the state of your problem report at any time > via this link: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=51209 > > >Category: standards > >Responsible: freebsd-standards > >Synopsis: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) > >Arrival-Date: Mon Apr 21 04:00:18 PDT 2003 New version of this patch avaliable at http://ozz.pp.ru/patches/patch-libc Thanks ru@. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 05:00: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 9670A37B401 for ; Mon, 21 Apr 2003 05:00:23 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A84043FAF for ; Mon, 21 Apr 2003 05:00: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 h3LC0NUp058715 for ; Mon, 21 Apr 2003 05:00: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 h3LC0NLt058710; Mon, 21 Apr 2003 05:00:23 -0700 (PDT) Date: Mon, 21 Apr 2003 05:00:23 -0700 (PDT) Message-Id: <200304211200.h3LC0NLt058710@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Stefan Farfeleder Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Stefan Farfeleder List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2003 12:00:23 -0000 The following reply was made to PR standards/51209; it has been noted by GNATS. From: Stefan Farfeleder To: bug-followup@FreeBSD.org Cc: Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) Date: Mon, 21 Apr 2003 13:52:01 +0200 On Mon, Apr 21, 2003 at 02:59:46PM +0400, Sergey A.Osokin wrote: > +int > +l64a_r (long value, char *buffer, int buflen) > +{ > + char *s = buffer; > + int digit; > + unsigned long v = value; ^^^^^^^^^^^^^ Shouldn't this be 'uint32_t'? According to SUSv3: "If the type long contains more than 32 bits, only the low-order 32 bits shall be used for these operations." > + > + _DIAGASSERT(buffer != NULL); > + > + if (value == 0UL) > + goto out; > + > + for (; v != 0 && buflen > 1; s++, buflen--) { > + digit = (int)(v & 0x3f); > + > + if (digit < 2) > + *s = digit + '.'; > + else if (digit < 12) > + *s = digit + '0' - 2; > + else if (digit < 38) > + *s = digit + 'A' - 12; > + else > + *s = digit + 'a' - 38; > + v >>= 6; > + } > + > +out: > + *s = '\0'; > + > + return (v == 0UL ? 0 : -1); > +} From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 05:00:26 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 B2C4C37B404 for ; Mon, 21 Apr 2003 05:00:26 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 55AF043FA3 for ; Mon, 21 Apr 2003 05:00:26 -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 h3LC0PUp058807 for ; Mon, 21 Apr 2003 05:00:25 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3LC0PEw058800; Mon, 21 Apr 2003 05:00:25 -0700 (PDT) Date: Mon, 21 Apr 2003 05:00:25 -0700 (PDT) Message-Id: <200304211200.h3LC0PEw058800@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2003 12:00:27 -0000 The following reply was made to PR standards/51209; it has been noted by GNATS. From: "Sergey A. Osokin" To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org Cc: Subject: Re: standards/51209: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) Date: Mon, 21 Apr 2003 15:55:16 +0400 On Mon, Apr 21, 2003 at 04:00:18AM -0700, FreeBSD-gnats-submit@FreeBSD.org wrote: > Thank you very much for your problem report. > It has the internal identification `standards/51209'. > The individual assigned to look at your > report is: freebsd-standards. > > You can access the state of your problem report at any time > via this link: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=51209 > > >Category: standards > >Responsible: freebsd-standards > >Synopsis: [PATCH] add a64l()/l64a/l64a_r functions (obtained from NetBSD) > >Arrival-Date: Mon Apr 21 04:00:18 PDT 2003 New version of this patch avaliable at http://ozz.pp.ru/patches/patch-libc Thanks ru@. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 06:17:56 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 94F4737B401; Mon, 21 Apr 2003 06:17:56 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1747943FB1; Mon, 21 Apr 2003 06:17:55 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA27996; Mon, 21 Apr 2003 23:17:29 +1000 Date: Mon, 21 Apr 2003 23:17:28 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Erik Trulsson In-Reply-To: <20030421104840.GA92922@falcon.midgard.homeip.net> Message-ID: <20030421230733.J11214@gamplex.bde.org> References: <20030416125715.GA12300@falcon.midgard.homeip.net> <20030416172723.GA13575@falcon.midgard.homeip.net> <20030421104840.GA92922@falcon.midgard.homeip.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-standards@freebsd.org cc: lamer@properfucked.net cc: "M. Warner Losh" cc: schweikh@freebsd.org Subject: Re: standards/50889: NULL defined as 0 instead of (void *)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: Mon, 21 Apr 2003 13:17:56 -0000 On Mon, 21 Apr 2003, Erik Trulsson wrote: > On Mon, Apr 21, 2003 at 02:01:06AM -0600, M. Warner Losh wrote: > > I have a #define in my tree that I switch back and forth from time to > > time: > > > > #if defined(_cplusplus) || !defined(_NULL_VOID) > > #define NULL 0L > > Why not just plain 0? > I think either will work fine so it doesn't matter really matter much > but I am a bit curious. Different types of integer for NULL can expose (or hide) bugs like: foo(NULL); /* No prototype in scope. */ ... int foo(void *) { ... } Bruce From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 07:17: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 CFFB137B401; Mon, 21 Apr 2003 07:17:33 -0700 (PDT) Received: from espresso.bsdmike.org (espresso.bsdmike.org [65.39.129.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id 417F643F3F; Mon, 21 Apr 2003 07:17:33 -0700 (PDT) (envelope-from mike@espresso.bsdmike.org) Received: by espresso.bsdmike.org (Postfix, from userid 1002) id 96DE39C4C; Mon, 21 Apr 2003 10:02:54 -0400 (EDT) Date: Mon, 21 Apr 2003 10:02:54 -0400 From: Mike Barcroft To: David Leimbach Message-ID: <20030421100254.A11165@espresso.bsdmike.org> References: <20030421173354.A41423@dilbert.robbins.dropbear.id.au> <938EF288-73EF-11D7-98DE-0003937E39E0@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <938EF288-73EF-11D7-98DE-0003937E39E0@mac.com>; from leimy2k@mac.com on Mon, Apr 21, 2003 at 06:51:24AM -0500 Organization: The FreeBSD Project cc: freebsd-current@FreeBSD.ORG cc: freebsd-standards@FreeBSD.ORG cc: Tim Robbins Subject: Re: test-strerror regression test 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, 21 Apr 2003 14:17:34 -0000 David Leimbach writes: > I guess my point was I didn't know how to make these "conform" when I > looked > at the POSIX standard for SUS. All it said about strerror is that any > int should > work and return a string per the locale that is currently set. I agree with Tim; the main purpose is to prevent regressions in our implementation, not to evaluate conformance to any given standard. In fact, I created the test to ensure I didn't break strerror() or strerror_r() while fixing a conformance bug in strerror_r(). > > cc -O -pipe -mcpu=pentiumpro test-wmemset.c -o test-wmemset > > for p in test-strerror test-wcschr test-wcscmp test-wcslen > > test-wmemchr test-wmemset; do > > /home/tim/p4/wchar/src/tools/regression/lib/libc/string/$p; done > > PASS strerror() > > Failed for me due to failing assertions. What's the output of: ident /usr/lib/libc.so.* | grep strerror.c Best regards, Mike Barcroft From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 07:35:59 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 3D8B337B401; Mon, 21 Apr 2003 07:35:59 -0700 (PDT) Received: from smtpout.mac.com (A17-250-248-89.apple.com [17.250.248.89]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD61743FE3; Mon, 21 Apr 2003 07:35:58 -0700 (PDT) (envelope-from leimy2k@mac.com) Received: from webmail07.mac.com (webmail07-en1 [10.13.11.149]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h3LEZwjC026565; Mon, 21 Apr 2003 07:35:58 -0700 (PDT) Received: from webmail07 (localhost [127.0.0.1]) by webmail07.mac.com (8.12.2/8.12.2) with ESMTP id h3LEZwYt022827; Mon, 21 Apr 2003 07:35:58 -0700 (PDT) Message-ID: <2179596.1050935758246.JavaMail.leimy2k@mac.com> Date: Mon, 21 Apr 2003 09:35:58 -0500 From: David Leimbach To: Mike Barcroft Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit cc: freebsd-current@FreeBSD.org cc: freebsd-standards@FreeBSD.org cc: Tim Robbins Subject: Re: test-strerror regression test 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, 21 Apr 2003 14:35:59 -0000 On Monday, April 21, 2003, at 09:02AM, Mike Barcroft wrote: >David Leimbach writes: >> I guess my point was I didn't know how to make these "conform" when I >> looked >> at the POSIX standard for SUS. All it said about strerror is that any >> int should >> work and return a string per the locale that is currently set. > >I agree with Tim; the main purpose is to prevent regressions in our >implementation, not to evaluate conformance to any given standard. In >fact, I created the test to ensure I didn't break strerror() or >strerror_r() while fixing a conformance bug in strerror_r(). Well yes... that is what a regression would be :). But I think a standards compliance test suite wouldn't hurt either :). Whether or not we regress doesn't matter much if we don't conform to the standard to begin with... it just means we haven't changed behavior. > >> > cc -O -pipe -mcpu=pentiumpro test-wmemset.c -o test-wmemset >> > for p in test-strerror test-wcschr test-wcscmp test-wcslen >> > test-wmemchr test-wmemset; do >> > /home/tim/p4/wchar/src/tools/regression/lib/libc/string/$p; done >> > PASS strerror() >> >> Failed for me due to failing assertions. > >What's the output of: > >ident /usr/lib/libc.so.* | grep strerror.c > I am not at that machine at the moment. I just did a new buildworld/installworld before leaving for work today. I can check this at lunch. Dave >Best regards, >Mike Barcroft > > From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 08:52:30 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 CEB0A37B401; Mon, 21 Apr 2003 08:52:30 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 91DFD43FDD; Mon, 21 Apr 2003 08:52:29 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.8/8.12.3) with ESMTP id h3LFqMA7025334; Mon, 21 Apr 2003 09:52:22 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 21 Apr 2003 09:52:03 -0600 (MDT) Message-Id: <20030421.095203.105584263.imp@bsdimp.com> To: ertr1013@student.uu.se From: "M. Warner Losh" In-Reply-To: <20030421104840.GA92922@falcon.midgard.homeip.net> References: <20030416172723.GA13575@falcon.midgard.homeip.net> <20030421.020106.41513803.imp@bsdimp.com> <20030421104840.GA92922@falcon.midgard.homeip.net> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-standards@freebsd.org cc: lamer@properfucked.net cc: schweikh@freebsd.org Subject: Re: standards/50889: NULL defined as 0 instead of (void *)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: Mon, 21 Apr 2003 15:52:31 -0000 In message: <20030421104840.GA92922@falcon.midgard.homeip.net> Erik Trulsson writes: : On Mon, Apr 21, 2003 at 02:01:06AM -0600, M. Warner Losh wrote: : > I have a #define in my tree that I switch back and forth from time to : > time: : > : > #if defined(_cplusplus) || !defined(_NULL_VOID) : > #define NULL 0L : : Why not just plain 0? : I think either will work fine so it doesn't matter really matter much : but I am a bit curious. Strange, but legal, to catch more issues. : > #else : > #define NULL (void *) 0 : : Won't work correctly. You need to use ((void*)0) instead with the : extra parenthesis. Otherwise expressions like 'sizeof NULL' will fail : to compile. Yes, I didn't cut and paste, but rather typed from memory. Warner From owner-freebsd-standards@FreeBSD.ORG Mon Apr 21 10:08:26 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 00F7637B401; Mon, 21 Apr 2003 10:08:26 -0700 (PDT) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66F1443F85; Mon, 21 Apr 2003 10:08:25 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0061.cvx22-bradley.dialup.earthlink.net ([209.179.198.61] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 197emC-0004nZ-00; Mon, 21 Apr 2003 10:08:20 -0700 Message-ID: <3EA42532.90F2ED12@mindspring.com> Date: Mon, 21 Apr 2003 10:06:58 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Matthias Buelow References: <6AE199CE-739E-11D7-98DE-0003937E39E0@mac.com> <3EA37658.1000700@mukappabeta.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a43a21e0469a0dc232d271aeba509d08b793caf27dac41a8fd350badd9bab72f9c350badd9bab72f9c cc: freebsd-current@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: test-strerror regression test 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, 21 Apr 2003 17:08:26 -0000 Matthias Buelow wrote: > David Leimbach wrote: > > If we are going to have a test suite it should at least be correct and > > documented don't you think? > > In fact, I think there should be a lot more testsuites... following a > "make testworld" a "make buildworld" with a bazillion of test suites > would be an excellent idea, especially for all of the library routines. Try running the NIST PCTS. It should run without modification (that's the first test you have to pass: correct header files). After that, it tests everything related with POSIX conformance. Too bad SVVS (the SVID verification suite) isn't public; though I doubt you'd actually want to comply with it completely, it's got a lot of good FS path verification tests. -- Terry From owner-freebsd-standards@FreeBSD.ORG Tue Apr 22 13:30: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 CB01937B404 for ; Tue, 22 Apr 2003 13:30:09 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B2ED43FE3 for ; Tue, 22 Apr 2003 13:30:07 -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 h3MKU7Up019492 for ; Tue, 22 Apr 2003 13:30:07 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3MKU7o0019488; Tue, 22 Apr 2003 13:30:07 -0700 (PDT) Resent-Date: Tue, 22 Apr 2003 13:30:07 -0700 (PDT) Resent-Message-Id: <200304222030.h3MKU7o0019488@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, "Sergey A.Osokin" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 72CED37B401 for ; Tue, 22 Apr 2003 13:26:51 -0700 (PDT) Received: from freebsd.org.ru (www.freebsd.org.ru [194.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id A738E43FB1 for ; Tue, 22 Apr 2003 13:26:49 -0700 (PDT) (envelope-from osa@freebsd.org.ru) Received: by freebsd.org.ru (Postfix, from userid 1000) id 7D3D4C4; Wed, 23 Apr 2003 00:26:47 +0400 (MSD) Message-Id: <20030422202647.7D3D4C4@freebsd.org.ru> Date: Wed, 23 Apr 2003 00:26:47 +0400 (MSD) From: "Sergey A.Osokin" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A.Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 20:30:10 -0000 >Number: 51292 >Category: standards >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Apr 22 13:30:06 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Sergey A. Osokin >Release: FreeBSD 5.0-CURRENT i386 >Organization: n/a >Environment: System: FreeBSD 5.0-CURRENT i386 >Description: add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) + add locale-specific tricks >How-To-Repeat: >Fix: Index: src/lib/libc/stdlib/Makefile.inc =================================================================== RCS file: /home/ncvs/src/lib/libc/stdlib/Makefile.inc,v retrieving revision 1.45 diff -u -r1.45 Makefile.inc --- src/lib/libc/stdlib/Makefile.inc 5 Apr 2003 07:33:46 -0000 1.45 +++ src/lib/libc/stdlib/Makefile.inc 22 Apr 2003 16:44:44 -0000 @@ -5,13 +5,13 @@ .PATH: ${.CURDIR}/${MACHINE_ARCH}/stdlib ${.CURDIR}/stdlib MISRCS+=_Exit.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \ - bsearch.c calloc.c div.c exit.c getenv.c getopt.c getopt_long.c \ - getsubopt.c grantpt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \ - insque.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c merge.c \ - putenv.c qsort.c qsort_r.c radixsort.c rand.c random.c reallocf.c \ - realpath.c remque.c setenv.c strfmon.c strhash.c strtoimax.c \ - strtol.c strtoll.c strtoq.c strtoul.c strtoull.c strtoumax.c strtouq.c \ - system.c tdelete.c tfind.c tsearch.c twalk.c + bsearch.c calloc.c div.c exit.c ecvt.c gcvt.c getenv.c getopt.c \ + getopt_long.c getsubopt.c grantpt.c hcreate.c heapsort.c imaxabs.c \ + imaxdiv.c insque.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \ + merge.c putenv.c qsort.c qsort_r.c radixsort.c rand.c random.c \ + reallocf.c realpath.c remque.c setenv.c strfmon.c strhash.c \ + strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \ + strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c # machine-dependent stdlib sources .if exists(${.CURDIR}/${MACHINE_ARCH}/stdlib/Makefile.inc) @@ -19,12 +19,13 @@ .endif MAN+= abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \ - div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 grantpt.3 \ - hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \ - lsearch.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 random.3 \ + div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \ + grantpt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 \ + lldiv.3 lsearch.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 random.3 \ realpath.3 strfmon.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 MLINKS+=atol.3 atoll.3 +MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 MLINKS+=exit.3 _Exit.3 MLINKS+=getenv.3 putenv.3 getenv.3 setenv.3 getenv.3 unsetenv.3 MLINKS+=grantpt.3 posix_openpt.3 grantpt.3 ptsname.3 grantpt.3 unlockpt.3 --- /dev/null Tue Apr 22 14:58:19 2003 +++ src/lib/libc/stdlib/ecvt.3 Tue Apr 22 16:49:38 2003 @@ -0,0 +1,174 @@ +.\" $OpenBSD +.\" +.\" Copyright (c) 2002 Todd C. Miller +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 22, 2003 +.Dt ECVT 3 +.Os +.Sh NAME +.Nm ecvt , +.Nm fcvt , +.Nm gcvt +.Nd convert double to +.Tn ASCII +string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #include +.Ft char * +.Fn ecvt "double value" "int ndigit" "int *decpt" "int *sign" +.Ft char * +.Fn fcvt "double value" "int ndigit" "int *decpt" "int *sign" +.Ft char * +.Fn gcvt "double value" "int ndigit" "char *buf" +.Sh DESCRIPTION +.Bf -symbolic +These functions are provided for compatibility with legacy code. +New code should use the +.Xr snprintf 3 +function for improved safety and portability. +.Ef +.Pp +The +.Fn ecvt , +.Fn fcvt +and +.Fn gcvt +functions convert the double precision floating-point number +.Fa value +to a NUL-terminated +.Tn ASCII +string. +.Pp +The +.Fn ecvt +function converts +.Fa value +to a NUL-terminated string of exactly +.Fa ndigit +digits and returns a pointer to that string. +The result is padded with zeroes from left to right as needed. +There are no leading zeroes unless +.Fa value +itself is 0. +The least significant digit is rounded in an implementation-dependent manner. +The position of the decimal point relative to the beginning of the string +is stored in +.Fa decpt . +A negative value indicates that the decimal point is located +to the left of the returned digits (this occurs when there is no +whole number component to +.Fa value ) . +If +.Fa value +is zero, it is unspecified whether the integer pointed to by +.Fa decpt +will be 0 or 1. +The decimal point itself is not included in the returned string. +If the sign of the result is negative, the integer pointed to by +.Fa sign +is non-zero; otherwise, it is 0. +.Pp +If the converted value is out of range or is not representable, +the contents of the returned string are unspecified. +.Pp +The +.Fn fcvt +function is identical to +.Fn ecvt +with the exception that +.Fa ndigit +specifies the number of digits after the decimal point (zero-padded as +needed). +.Pp +The +.Fn gcvt +function converts +.Fa value +to a NUL-terminated string similar to the %g +.Xr printf 3 +format specifier and stores the result in +.Fa buf . +It produces +.Fa ndigit +significant digits similar to the %f +.Xr printf 3 +format specifier where possible. +If +.Fa ndigit +does allow sufficient precision, the result is stored in +exponential notation similar to the %e +.Xr printf 3 +format specifier. +If +.Fa value +is less than zero, +.Fa buf +will be prefixed with a minus sign. +A decimal point is included in the returned string if +.Fa value +is not a whole number. +Unlike the +.Fn ecvt +and +.Fn fcvt +functions, +.Fa buf +is not zero-padded. +.Sh RETURN VALUES +The +.Fn ecvt , +.Fn fcvt +and +.Fn gcvt +functions return a NUL-terminated string representation of +.Fa value . +.Sh WARNINGS +The +.Fn ecvt +and +.Fn fcvt +functions return a pointer to internal storage space that will be +overwritten by subsequent calls to either function. +.Pp +The maximum possible precision of the return value is limited by the +precision of a double and may not be the same on all architectures. +.Pp +The +.Xr snprintf 3 +function is preferred over these functions for new code. +.Sh SEE ALSO +.Xr printf 3 , +.Xr strtod 3 +.Sh STANDARDS +The +.Fn ecvt , +.Fn fcvt +and +.Fn gcvt +functions conform to +.St -susv3 . --- /dev/null Tue Apr 22 14:58:19 2003 +++ src/lib/libc/stdlib/ecvt.c Tue Apr 22 17:52:36 2003 @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2002 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: ecvt.c,v 1.1 2002/12/02 15:38:54 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +extern char *__dtoa(double, int, int, int *, int *, char **); +static char *__cvt(double, int, int *, int *, int, int); + +static char * +__cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) +{ + static char *s; + char *p, *rve; + size_t siz; + + if (ndigit == 0) { + *sign = value < 0.0; + *decpt = 0; + return (""); + } + + if (s) { + free(s); + s = NULL; + } + + if (ndigit < 0) + siz = -ndigit + 1; + else + siz = ndigit + 1; + + + /* __dtoa() doesn't allocate space for 0 so we do it by hand */ + if (value == 0.0) { + *decpt = 1 - fmode; /* 1 for 'e', 0 for 'f' */ + *sign = 0; + if ((rve = s = (char *)malloc(siz)) == NULL) + return(NULL); + *rve++ = '0'; + *rve = '\0'; + } else { + p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); + if (*decpt == 9999) { + /* Nan or Infinity */ + *decpt = 0; + return(p); + } + /* make a local copy and adjust rve to be in terms of s */ + if (pad && fmode) + siz += *decpt; + if ((s = (char *)malloc(siz)) == NULL) + return(NULL); + (void) strlcpy(s, p, siz); + rve = s + (rve - p); + } + + /* Add trailing zeros (unless we got NaN or Inf) */ + if (pad && *decpt != 9999) { + siz -= rve - s; + while (--siz) + *rve++ = '0'; + *rve = '\0'; + } + + return(s); +} + +char * +ecvt(double value, int ndigit, int *decpt, int *sign) +{ + return(__cvt(value, ndigit, decpt, sign, 0, 1)); +} + +char * +fcvt(double value, int ndigit, int *decpt, int *sign) +{ + return(__cvt(value, ndigit, decpt, sign, 1, 1)); +} --- /dev/null Tue Apr 22 14:58:19 2003 +++ src/lib/libc/stdlib/gcvt.c Tue Apr 22 20:42:51 2003 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2002 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: gcvt.c,v 1.2 2003/04/02 02:43:50 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include "../locale/setlocale.h" /* for ENCODING_LEN */ + +extern char *__dtoa(double, int, int, int *, int *, char **); + +char * +gcvt(double value, int ndigit, char *buf) +{ + char *digits, *dst, *src; + int i, decpt, sign; + char *lang; + struct lconv *lc: + + if (ndigit == 0) { + buf[0] = '\0'; + return (buf); + } + + lang = getenv("LANG"); + + if (lang == NULL || *lang == '\0' || strlen(lang) > ENCODING_LEN || + (lang[0] == '.' && + (lang[1] == '\0' || (lang[1] == '.' && lang[2] == '\0'))) || + strchr(lang, '/') != NULL) + lang = "C"; + + if (setlocale(LC_ALL, lang) == NULL) + setlocale(LC_ALL, NULL); + + lc = localeconv(); + + digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); + if (decpt == 9999) { + /* Infinity or NaN, assume buffer is at least ndigit long. */ + strlcpy(buf, digits, ndigit); + return (buf); + } + + dst = buf; + if (sign) + *dst++ = (*lc->negative_sign == '\0') ? '-' + : *lc->negative_sign; + + if (decpt < 0 || decpt > ndigit) { + /* exponential format */ + if (--decpt < 0) { + sign = 1; + decpt = -decpt; + } else + sign = 0; + for (src = digits; *src != '\0'; ) + *dst++ = *src++; + *dst++ = 'e'; + if (sign) + *dst++ = (*lc->negative_sign == '\0') ? '-' + : *lc->negative_sign; + else + *dst++ = (*lc->positive_sign == '\0') ? '+' + : *lc->positive_sign; + if (decpt < 10) { + *dst++ = '0'; + *dst++ = '0' + decpt; + *dst = '\0'; + } else { + /* XXX - optimize */ + for (sign = decpt, i = 0; (sign /= 10) != 0; i++) + sign /= 10; + while (decpt != 0) { + dst[i--] = '0' + decpt % 10; + decpt /= 10; + } + } + } else { + /* standard format */ + for (i = 0, src = digits; i < decpt; i++) { + if (*src != '\0') + *dst++ = *src++; + else + *dst++ = '0'; + } + if (*src != '\0') { + *dst++ = (*lc->decimal_point == '\0' ? '.' + : *lc->decimal_point; + for (i = decpt; digits[i] != '\0'; i++) { + *dst++ = digits[i]; + } + } + *dst = '\0'; + } + return (buf); +} Index: src/include/stdlib.h =================================================================== RCS file: /home/ncvs/src/include/stdlib.h,v retrieving revision 1.48 diff -u -r1.48 stdlib.h --- src/include/stdlib.h 12 Mar 2003 20:29:58 -0000 1.48 +++ src/include/stdlib.h 22 Apr 2003 16:44:45 -0000 @@ -176,10 +176,10 @@ /* XXX XSI requires pollution from here. We'd rather not. */ /* long a64l(const char *); */ double drand48(void); -/* char *ecvt(double, int, int * __restrict, int * __restrict); */ +char *ecvt(double, int, int * __restrict, int * __restrict); double erand48(unsigned short[3]); -/* char *fcvt(double, int, int * __restrict, int * __restrict); */ -/* char *gcvt(double, int, int * __restrict, int * __restrict); */ +char *fcvt(double, int, int * __restrict, int * __restrict); +char *gcvt(double, int, char *); #ifndef _GETSUBOPT_DECLARED int getsubopt(char **, char *const *, char **); #define _GETSUBOPT_DECLARED >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Tue Apr 22 14:29:04 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 0D3C337B401; Tue, 22 Apr 2003 14:29:04 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9CB4D43FD7; Tue, 22 Apr 2003 14:29:02 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id HAA13250; Wed, 23 Apr 2003 07:28:50 +1000 Date: Wed, 23 Apr 2003 07:28:49 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: "Sergey A.Osokin" In-Reply-To: <20030422202647.7D3D4C4@freebsd.org.ru> Message-ID: <20030423071726.M19073@gamplex.bde.org> References: <20030422202647.7D3D4C4@freebsd.org.ru> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: FreeBSD-gnats-submit@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 22 Apr 2003 21:29:04 -0000 On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > >Description: > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > + add locale-specific tricks > +.Sh DESCRIPTION > +.Bf -symbolic > +These functions are provided for compatibility with legacy code. > +New code should use the > +.Xr snprintf 3 > +function for improved safety and portability. This statement was true 15 years ago when C90, (er, only 13 years ago) didn't standardize these functions. At least FreeBSD hasn't needed them for 10 years. Bringing them back now is a bug in whatever standards have them IMO. Unfortunately, POSIX.1 has them in its XSI section. Bruce From owner-freebsd-standards@FreeBSD.ORG Tue Apr 22 14:30:06 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 003FE37B4DB for ; Tue, 22 Apr 2003 14:30:06 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C77243FBF for ; Tue, 22 Apr 2003 14:30: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 h3MLU5Up066896 for ; Tue, 22 Apr 2003 14:30: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 h3MLU5JQ066895; Tue, 22 Apr 2003 14:30:05 -0700 (PDT) Date: Tue, 22 Apr 2003 14:30:05 -0700 (PDT) Message-Id: <200304222130.h3MLU5JQ066895@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Bruce Evans Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Bruce Evans List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 21:30:06 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Bruce Evans To: "Sergey A.Osokin" Cc: FreeBSD-gnats-submit@freebsd.org, "" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Wed, 23 Apr 2003 07:28:49 +1000 (EST) On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > >Description: > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > + add locale-specific tricks > +.Sh DESCRIPTION > +.Bf -symbolic > +These functions are provided for compatibility with legacy code. > +New code should use the > +.Xr snprintf 3 > +function for improved safety and portability. This statement was true 15 years ago when C90, (er, only 13 years ago) didn't standardize these functions. At least FreeBSD hasn't needed them for 10 years. Bringing them back now is a bug in whatever standards have them IMO. Unfortunately, POSIX.1 has them in its XSI section. Bruce From owner-freebsd-standards@FreeBSD.ORG Tue Apr 22 14:47:44 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 7D55F37B401; Tue, 22 Apr 2003 14:47:44 -0700 (PDT) Received: from freebsd.org.ru (www.freebsd.org.ru [194.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6977E43FBD; Tue, 22 Apr 2003 14:47:43 -0700 (PDT) (envelope-from osa@freebsd.org.ru) Received: by freebsd.org.ru (Postfix, from userid 1000) id CA74CBE; Wed, 23 Apr 2003 01:47:40 +0400 (MSD) Date: Wed, 23 Apr 2003 01:47:40 +0400 From: "Sergey A. Osokin" To: Bruce Evans Message-ID: <20030422214740.GB73209@freebsd.org.ru> References: <20030422202647.7D3D4C4@freebsd.org.ru> <20030423071726.M19073@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030423071726.M19073@gamplex.bde.org> User-Agent: Mutt/1.5.4i cc: FreeBSD-gnats-submit@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: osa@FreeBSD.org.ru List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 21:47:44 -0000 On Wed, Apr 23, 2003 at 07:28:49AM +1000, Bruce Evans wrote: > On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > > > >Description: > > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > > + add locale-specific tricks > > > +.Sh DESCRIPTION > > +.Bf -symbolic > > +These functions are provided for compatibility with legacy code. > > +New code should use the > > +.Xr snprintf 3 > > +function for improved safety and portability. > > This statement was true 15 years ago when C90, (er, only 13 years ago) > didn't standardize these functions. At least FreeBSD hasn't needed them > for 10 years. Bringing them back now is a bug in whatever standards have > them IMO. Unfortunately, POSIX.1 has them in its XSI section. So, why OpenBSDers add them 4 monthes ago to they source tree? Also quote from SUSv3: CHANGE HISTORY First released in Issue 4, Version 2. Issue 5 Moved from X/OPEN UNIX extension to BASE. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Tue Apr 22 14: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 676F237B401 for ; Tue, 22 Apr 2003 14:50:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE57343F93 for ; Tue, 22 Apr 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 h3MLoHUp048923 for ; Tue, 22 Apr 2003 14: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 h3MLoHQ2048918; Tue, 22 Apr 2003 14:50:17 -0700 (PDT) Date: Tue, 22 Apr 2003 14:50:17 -0700 (PDT) Message-Id: <200304222150.h3MLoHQ2048918@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 21:50:18 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Bruce Evans Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Wed, 23 Apr 2003 01:47:40 +0400 On Wed, Apr 23, 2003 at 07:28:49AM +1000, Bruce Evans wrote: > On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > > > >Description: > > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > > + add locale-specific tricks > > > +.Sh DESCRIPTION > > +.Bf -symbolic > > +These functions are provided for compatibility with legacy code. > > +New code should use the > > +.Xr snprintf 3 > > +function for improved safety and portability. > > This statement was true 15 years ago when C90, (er, only 13 years ago) > didn't standardize these functions. At least FreeBSD hasn't needed them > for 10 years. Bringing them back now is a bug in whatever standards have > them IMO. Unfortunately, POSIX.1 has them in its XSI section. So, why OpenBSDers add them 4 monthes ago to they source tree? Also quote from SUSv3: CHANGE HISTORY First released in Issue 4, Version 2. Issue 5 Moved from X/OPEN UNIX extension to BASE. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 00:01:19 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 4DBF837B401; Wed, 23 Apr 2003 00:01:19 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DCC4843F75; Wed, 23 Apr 2003 00:01:18 -0700 (PDT) (envelope-from schweikh@FreeBSD.org) Received: from freefall.freebsd.org (schweikh@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3N71IUp023075; Wed, 23 Apr 2003 00:01:18 -0700 (PDT) (envelope-from schweikh@freefall.freebsd.org) Received: (from schweikh@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3N71I55023036; Wed, 23 Apr 2003 00:01:18 -0700 (PDT) Date: Wed, 23 Apr 2003 00:01:18 -0700 (PDT) From: Jens Schweikhardt Message-Id: <200304230701.h3N71I55023036@freefall.freebsd.org> To: lamer@properfucked.net, schweikh@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/50889: NULL defined as 0 instead of (void *)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, 23 Apr 2003 07:01:19 -0000 Synopsis: NULL defined as 0 instead of (void *)0 State-Changed-From-To: analyzed->closed State-Changed-By: schweikh State-Changed-When: Tue Apr 22 23:56:12 PDT 2003 State-Changed-Why: #define NULL 0 is ISO 9899 compliant. A discussion if a change to #define NULL ((void*)0) would be beneficial has not shown a strong case either way. There are bugs that can be covered/uncovered with both definitions. In accordance with Newton's First Law, NULL is left as is. http://www.freebsd.org/cgi/query-pr.cgi?pr=50889 From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 06:11:16 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 4683C37B401; Wed, 23 Apr 2003 06:11:16 -0700 (PDT) Received: from HAL9000.homeunix.com (12-233-57-131.client.attbi.com [12.233.57.131]) by mx1.FreeBSD.org (Postfix) with ESMTP id 689C643FD7; Wed, 23 Apr 2003 06:11:15 -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.5) with ESMTP id h3NDBAjC013148; Wed, 23 Apr 2003 06:11:10 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.5/Submit) id h3NDB9l3013147; Wed, 23 Apr 2003 06:11:09 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Wed, 23 Apr 2003 06:11:09 -0700 From: David Schultz To: "Sergey A. Osokin" Message-ID: <20030423131109.GA13008@HAL9000.homeunix.com> Mail-Followup-To: "Sergey A. Osokin" , Bruce Evans , FreeBSD-gnats-submit@freebsd.org, freebsd-standards@freebsd.org References: <20030422202647.7D3D4C4@freebsd.org.ru> <20030423071726.M19073@gamplex.bde.org> <20030422214740.GB73209@freebsd.org.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030422214740.GB73209@freebsd.org.ru> cc: FreeBSD-gnats-submit@FreeBSD.ORG cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 23 Apr 2003 13:11:16 -0000 On Wed, Apr 23, 2003, Sergey A. Osokin wrote: > On Wed, Apr 23, 2003 at 07:28:49AM +1000, Bruce Evans wrote: > > On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > > > > > >Description: > > > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > > > + add locale-specific tricks > > > > > +.Sh DESCRIPTION > > > +.Bf -symbolic > > > +These functions are provided for compatibility with legacy code. > > > +New code should use the > > > +.Xr snprintf 3 > > > +function for improved safety and portability. > > > > This statement was true 15 years ago when C90, (er, only 13 years ago) > > didn't standardize these functions. At least FreeBSD hasn't needed them > > for 10 years. Bringing them back now is a bug in whatever standards have > > them IMO. Unfortunately, POSIX.1 has them in its XSI section. > > So, why OpenBSDers add them 4 monthes ago to they source tree? > > Also quote from SUSv3: > CHANGE HISTORY > First released in Issue 4, Version 2. > Issue 5 > Moved from X/OPEN UNIX extension to BASE. Nobody uses these functions anymore, so it doesn't seem particularly useful to implement them now, given that snprintf() provides almost equivalent functionality. Any active standards that still require them will most likely drop them in the near future. Is there a particular application you were trying to compile that prompted you to submit these patches? From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 06:20:08 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 4B66D37B404 for ; Wed, 23 Apr 2003 06:20:08 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 47D3543FD7 for ; Wed, 23 Apr 2003 06:20:07 -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 h3NDK7Up095883 for ; Wed, 23 Apr 2003 06:20:07 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3NDK7C0095870; Wed, 23 Apr 2003 06:20:07 -0700 (PDT) Date: Wed, 23 Apr 2003 06:20:07 -0700 (PDT) Message-Id: <200304231320.h3NDK7C0095870@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: David Schultz Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: David Schultz List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2003 13:20:08 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: David Schultz To: "Sergey A. Osokin" Cc: Bruce Evans , FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Wed, 23 Apr 2003 06:11:09 -0700 On Wed, Apr 23, 2003, Sergey A. Osokin wrote: > On Wed, Apr 23, 2003 at 07:28:49AM +1000, Bruce Evans wrote: > > On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > > > > > >Description: > > > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > > > + add locale-specific tricks > > > > > +.Sh DESCRIPTION > > > +.Bf -symbolic > > > +These functions are provided for compatibility with legacy code. > > > +New code should use the > > > +.Xr snprintf 3 > > > +function for improved safety and portability. > > > > This statement was true 15 years ago when C90, (er, only 13 years ago) > > didn't standardize these functions. At least FreeBSD hasn't needed them > > for 10 years. Bringing them back now is a bug in whatever standards have > > them IMO. Unfortunately, POSIX.1 has them in its XSI section. > > So, why OpenBSDers add them 4 monthes ago to they source tree? > > Also quote from SUSv3: > CHANGE HISTORY > First released in Issue 4, Version 2. > Issue 5 > Moved from X/OPEN UNIX extension to BASE. Nobody uses these functions anymore, so it doesn't seem particularly useful to implement them now, given that snprintf() provides almost equivalent functionality. Any active standards that still require them will most likely drop them in the near future. Is there a particular application you were trying to compile that prompted you to submit these patches? From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 06:40: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 5E38137B401 for ; Wed, 23 Apr 2003 06:40:05 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D9F6C43FBF for ; Wed, 23 Apr 2003 06:40:04 -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 h3NDe4Up087983 for ; Wed, 23 Apr 2003 06:40:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3NDe4ou087971; Wed, 23 Apr 2003 06:40:04 -0700 (PDT) Date: Wed, 23 Apr 2003 06:40:04 -0700 (PDT) Message-Id: <200304231340.h3NDe4ou087971@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2003 13:40:05 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: David Schultz Cc: Bruce Evans , FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Wed, 23 Apr 2003 17:30:30 +0400 On Wed, Apr 23, 2003 at 06:11:09AM -0700, David Schultz wrote: > On Wed, Apr 23, 2003, Sergey A. Osokin wrote: > > On Wed, Apr 23, 2003 at 07:28:49AM +1000, Bruce Evans wrote: > > > On Wed, 23 Apr 2003, Sergey A.Osokin wrote: > > > > > > > >Description: > > > > add ecvt()/fcvt()/gcvt() functions (SUSv3) (obtained from OpenBSD) > > > > + add locale-specific tricks > > > > > > > +.Sh DESCRIPTION > > > > +.Bf -symbolic > > > > +These functions are provided for compatibility with legacy code. > > > > +New code should use the > > > > +.Xr snprintf 3 > > > > +function for improved safety and portability. > > > > > > This statement was true 15 years ago when C90, (er, only 13 years ago) > > > didn't standardize these functions. At least FreeBSD hasn't needed them > > > for 10 years. Bringing them back now is a bug in whatever standards have > > > them IMO. Unfortunately, POSIX.1 has them in its XSI section. > > > > So, why OpenBSDers add them 4 monthes ago to they source tree? > > > > Also quote from SUSv3: > > CHANGE HISTORY > > First released in Issue 4, Version 2. > > Issue 5 > > Moved from X/OPEN UNIX extension to BASE. > > Nobody uses these functions anymore, so it doesn't seem > particularly useful to implement them now, given that snprintf() > provides almost equivalent functionality. Any active standards > that still require them will most likely drop them in the near > future. Is there a particular application you were trying to > compile that prompted you to submit these patches? AIX/IRIX/Linux/OpenBSD/SunOS have them. So, if its not really need - please close my PR. Thanks. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 10:38:41 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 4449037B401; Wed, 23 Apr 2003 10:38:41 -0700 (PDT) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4D7A443F3F; Wed, 23 Apr 2003 10:38:40 -0700 (PDT) (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 h3NHccmA074013 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Apr 2003 13:38:39 -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 h3NHccFq074010; Wed, 23 Apr 2003 13:38:38 -0400 (EDT) (envelope-from wollman) Date: Wed, 23 Apr 2003 13:38:38 -0400 (EDT) From: Garrett Wollman Message-Id: <200304231738.h3NHccFq074010@khavrinen.lcs.mit.edu> To: David Schultz In-Reply-To: <20030423131109.GA13008@HAL9000.homeunix.com> References: <20030422202647.7D3D4C4@freebsd.org.ru> <20030423071726.M19073@gamplex.bde.org> <20030422214740.GB73209@freebsd.org.ru> <20030423131109.GA13008@HAL9000.homeunix.com> cc: "Sergey A. Osokin" cc: FreeBSD-gnats-submit@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 23 Apr 2003 17:38:41 -0000 < said: > Nobody uses these functions anymore, so it doesn't seem particularly > useful to implement them now, given that snprintf() provides almost > equivalent functionality. However, it doesn't hurt to have them, even if we are not targeting XSI compliance. > Any active standards that still require them will most likely drop > them in the near future. POSIX has a five-year review cycle. -GAWollman From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 10:40:13 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 4A23137B401 for ; Wed, 23 Apr 2003 10:40:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0CE343FAF for ; Wed, 23 Apr 2003 10:40:12 -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 h3NHeCUp054818 for ; Wed, 23 Apr 2003 10:40:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3NHeCR8054815; Wed, 23 Apr 2003 10:40:12 -0700 (PDT) Date: Wed, 23 Apr 2003 10:40:12 -0700 (PDT) Message-Id: <200304231740.h3NHeCR8054815@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Garrett Wollman Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Garrett Wollman List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2003 17:40:13 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Garrett Wollman To: David Schultz Cc: "Sergey A. Osokin" , FreeBSD-gnats-submit@freebsd.org, freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Wed, 23 Apr 2003 13:38:38 -0400 (EDT) < said: > Nobody uses these functions anymore, so it doesn't seem particularly > useful to implement them now, given that snprintf() provides almost > equivalent functionality. However, it doesn't hurt to have them, even if we are not targeting XSI compliance. > Any active standards that still require them will most likely drop > them in the near future. POSIX has a five-year review cycle. -GAWollman From owner-freebsd-standards@FreeBSD.ORG Wed Apr 23 20:02:21 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 DEF3437B401; Wed, 23 Apr 2003 20:02:20 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 204EF43FBD; Wed, 23 Apr 2003 20:02:20 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 342475308; Thu, 24 Apr 2003 05:02:17 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Alex Semenyaka From: Dag-Erling Smorgrav Date: Thu, 24 Apr 2003 05:02:17 +0200 In-Reply-To: <20030420004639.GA52081@snark.ratmir.ru> (Alex Semenyaka's message of "Sun, 20 Apr 2003 04:46:39 +0400") Message-ID: User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: <20030420004639.GA52081@snark.ratmir.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: freebsd-hackers@freebsd.org cc: freebsd-performance@freebsd.org cc: freebsd-current@freebsd.org cc: freebsd-standards@freebsd.org Subject: Re: tjr@@freebsd.org, imp@freebsd.org, ru@freebsd.org 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: Thu, 24 Apr 2003 03:02:21 -0000 Alex Semenyaka writes: > Brief description what was done: I've chanched the arithmitics in the /bin/sh > from 32 bits to 64 bits. There are some doubts that it conforms to the > standards: it does, I have send a quotations to -standards, there were no > objections. Couple of people advuces me to use intmax_t and %jd - I've rewritten > the patch, now there is those species instead of long long and %qd. The last > question was performance, I will show the results of measurements below. Performance is irrelevant. Anyone who is doing so much arithmetic in the shell that performance is an issue should take a long hard look at dc(1). The only issues here are 1) correctness 2) portability (long long / %qd is not portable) and 3) standards compliance. You can safely ignore anyone trying to tell you otherwise. DES -- Dag-Erling Smorgrav - des@ofug.org From owner-freebsd-standards@FreeBSD.ORG Thu Apr 24 14:30:10 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 B526937B401 for ; Thu, 24 Apr 2003 14:30:10 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E8A143F75 for ; Thu, 24 Apr 2003 14:30: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 h3OLU9Up093843 for ; Thu, 24 Apr 2003 14:30:09 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3OLU9c1093837; Thu, 24 Apr 2003 14:30:09 -0700 (PDT) Date: Thu, 24 Apr 2003 14:30:09 -0700 (PDT) Message-Id: <200304242130.h3OLU9c1093837@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Alexey Zelkin Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alexey Zelkin List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2003 21:30:11 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Alexey Zelkin To: "Sergey A.Osokin" Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 00:30:12 +0300 hi, On Wed, Apr 23, 2003 at 12:26:47AM +0400, Sergey A.Osokin wrote: > > >Number: 51292 > >Category: standards > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Few questions related to code: 1. What's a reason to have some LANG handling logic here ? 2. Did you check correctness of dtoa()'s usage here ? It's not easy and after last netlib's import it become more uneasy. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 01:40: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 9A1F837B401 for ; Fri, 25 Apr 2003 01:40:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E5DF43FCB for ; Fri, 25 Apr 2003 01:40: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 h3P8eHUp020969 for ; Fri, 25 Apr 2003 01:40: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 h3P8eHre020968; Fri, 25 Apr 2003 01:40:17 -0700 (PDT) Date: Fri, 25 Apr 2003 01:40:17 -0700 (PDT) Message-Id: <200304250840.h3P8eHre020968@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 08:40:18 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Alexey Zelkin Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 12:38:51 +0400 On Fri, Apr 25, 2003 at 12:30:12AM +0300, Alexey Zelkin wrote: > hi, > > On Wed, Apr 23, 2003 at 12:26:47AM +0400, Sergey A.Osokin wrote: > > > > >Number: 51292 > > >Category: standards > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) > > Few questions related to code: > > 1. What's a reason to have some LANG handling logic here ? Because standart says: The radix character is determined by the current locale. Follow this way: check LANG, then set locale. > 2. Did you check correctness of dtoa()'s usage here ? It's not easy > and after last netlib's import it become more uneasy. I create a little test proram: ---- test.c --- #include #include int main(void) { char buff[255]; double value = -1000.010101011; char *link; link = buff; gcvt(value, 16, link); printf("%s\n", buff); return 0; } ---- test.c --- $ cc -Wall -g 1.c -o 1 $ LANG=C ./1 -1000.010101011 $ LANG=ru_RU.KOI8-R ./1 -1000,010101011 Looks like it works, isn't it? -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 05:20:12 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 EEDDA37B41F for ; Fri, 25 Apr 2003 05:20:12 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 900EE43F93 for ; Fri, 25 Apr 2003 05:20:12 -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 h3PCKBUp075273 for ; Fri, 25 Apr 2003 05:20:11 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3PCKBQr075267; Fri, 25 Apr 2003 05:20:11 -0700 (PDT) Date: Fri, 25 Apr 2003 05:20:11 -0700 (PDT) Message-Id: <200304251220.h3PCKBQr075267@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Alexey Zelkin Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alexey Zelkin List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 12:20:13 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Alexey Zelkin To: "Sergey A. Osokin" Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 15:19:37 +0300 hi, On Fri, Apr 25, 2003 at 12:38:51PM +0400, Sergey A. Osokin wrote: > > > >Number: 51292 > > > >Category: standards > > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) > > > > Few questions related to code: > > > > 1. What's a reason to have some LANG handling logic here ? > > Because standart says: > The radix character is determined by the current locale. > Follow this way: check LANG, then set locale. First sentence is correct, but second one is wrong. radix character is a 'property' of LC_NUMERIC locale category. So, having LANG=C and LC_NUMERIC=ru_RU.KOI8-R should use russian locale radix character. Actually, all these cases should be handled by setlocale() itself. And after call to 'setlocale()' you should use lconv() to receive current radix character. I also would object to using of setlocale() from libc's function internally. It's a application's problem to decide which locale to use and [fge]cvt() should use locale previously set by application. > > 2. Did you check correctness of dtoa()'s usage here ? It's not easy > > and after last netlib's import it become more uneasy. From reading of SUSv3's section related to these functions I'd suggest following way to check a function (and maybe write a regression-test for these funcs). 1. declare some set of floating values (more than one) 2. and try comapring result of gcvt() against of result of printf("%g"). same for others. 3. check these results against predefined values (if you'll write a regression test program) From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 05:40: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 CAD2637B401 for ; Fri, 25 Apr 2003 05:40:15 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F2F7443F3F for ; Fri, 25 Apr 2003 05:40: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 h3PCeEUp052865 for ; Fri, 25 Apr 2003 05:40: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 h3PCeEhw052858; Fri, 25 Apr 2003 05:40:14 -0700 (PDT) Date: Fri, 25 Apr 2003 05:40:14 -0700 (PDT) Message-Id: <200304251240.h3PCeEhw052858@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 12:40:16 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Alexey Zelkin Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 16:32:10 +0400 On Fri, Apr 25, 2003 at 03:19:37PM +0300, Alexey Zelkin wrote: > On Fri, Apr 25, 2003 at 12:38:51PM +0400, Sergey A. Osokin wrote: > > > > > >Number: 51292 > > > > >Category: standards > > > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) > > > > > > Few questions related to code: > > > > > > 1. What's a reason to have some LANG handling logic here ? > > > > Because standart says: > > The radix character is determined by the current locale. > > Follow this way: check LANG, then set locale. > > First sentence is correct, but second one is wrong. radix character > is a 'property' of LC_NUMERIC locale category. So, having LANG=C > and LC_NUMERIC=ru_RU.KOI8-R should use russian locale radix character. OK. > Actually, all these cases should be handled by setlocale() itself. And > after call to 'setlocale()' you should use lconv() to receive current > radix character. > I also would object to using of setlocale() from libc's function internally. Hmm, but from SUSv3: The radix character is determined by the current locale. If setlocale() has not been called successfully, the default locale, POSIX, is used. The default locale specifies a period ( '.' ) as the radix character. > It's a application's problem to decide which locale to use and [fge]cvt() > should use locale previously set by application. AFAIK only gcvt() have locale-specific "problem". I can't find any locale-specific words in documentation of [ef]cvt. Correct me if I'm wrong... > > > 2. Did you check correctness of dtoa()'s usage here ? It's not easy > > > and after last netlib's import it become more uneasy. > > >From reading of SUSv3's section related to these functions I'd suggest > following way to check a function (and maybe write a regression-test > for these funcs). > > 1. declare some set of floating values (more than one) > 2. and try comapring result of gcvt() against of result of printf("%g"). > same for others. > 3. check these results against predefined values (if you'll write a > regression test program) OK. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 06:28:05 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 55AA437B401 for ; Fri, 25 Apr 2003 06:28:05 -0700 (PDT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id ADE0343FD7 for ; Fri, 25 Apr 2003 06:28:03 -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 h3PDS1nd056890; Fri, 25 Apr 2003 17:28:01 +0400 (MSD) (envelope-from ache@pobrecita.freebsd.ru) Received: (from ache@localhost) by pobrecita.freebsd.ru (8.12.9/8.12.9/Submit) id h3PDS1dT056889; Fri, 25 Apr 2003 17:28:01 +0400 (MSD) Date: Fri, 25 Apr 2003 17:28:00 +0400 From: =?koi8-r?B?4c7E0sXKIP7F0s7P1w==?= To: Alexey Zelkin Message-ID: <20030425132800.GA56573@nagual.pp.ru> References: <200304251220.h3PCKBQr075267@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200304251220.h3PCKBQr075267@freefall.freebsd.org> User-Agent: Mutt/1.5.4i cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 25 Apr 2003 13:28:05 -0000 On Fri, Apr 25, 2003 at 05:20:11 -0700, Alexey Zelkin wrote: > I also would object to using of setlocale() from libc's function internally. libc can't _set_ anything using setlocale() but can _get_ things using it. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 06:56:57 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 D247237B401 for ; Fri, 25 Apr 2003 06:56:57 -0700 (PDT) Received: from relay1.cris.net (relay1.cris.net [212.110.128.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 53AEF43F75 for ; Fri, 25 Apr 2003 06:56:54 -0700 (PDT) (envelope-from phantom@phantom.cris.net) Received: from phantom.cris.net (root@phantom.cris.net [212.110.130.74]) by relay1.cris.net (8.12.6/8.12.6) with ESMTP id h3PG3B8k023588; Fri, 25 Apr 2003 16:03:12 GMT Received: (from phantom@localhost) by phantom.cris.net (8.12.6/8.12.2) id h3PE3Wbf042568; Fri, 25 Apr 2003 17:03:32 +0300 (EEST) (envelope-from phantom) Date: Fri, 25 Apr 2003 17:03:32 +0300 From: Alexey Zelkin To: =?koi8-r?B?4c7E0sXKIP7F0s7P1w==?= Message-ID: <20030425170332.B42462@phantom.cris.net> References: <200304251220.h3PCKBQr075267@freefall.freebsd.org> <20030425132800.GA56573@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <20030425132800.GA56573@nagual.pp.ru>; from ache@nagual.pp.ru on Fri, Apr 25, 2003 at 05:28:00PM +0400 X-Operating-System: FreeBSD 4.7-STABLE i386 cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 25 Apr 2003 13:56:58 -0000 On Fri, Apr 25, 2003 at 05:28:00PM +0400, Андрей Чернов wrote: > On Fri, Apr 25, 2003 at 05:20:11 -0700, Alexey Zelkin wrote: > >> I also would object to using of setlocale() from libc's function internally. > > libc can't _set_ anything using setlocale() but can _get_ things using it. Actually it can, but should not. And we are speaking about such case. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 07: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 149C937B404 for ; Fri, 25 Apr 2003 07:00:31 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61F3543F85 for ; Fri, 25 Apr 2003 07: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 h3PE0TUp009729 for ; Fri, 25 Apr 2003 07: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 h3PE0TAZ009728; Fri, 25 Apr 2003 07:00:29 -0700 (PDT) Date: Fri, 25 Apr 2003 07:00:29 -0700 (PDT) Message-Id: <200304251400.h3PE0TAZ009728@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Alexey Zelkin Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alexey Zelkin List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 14:00:31 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Alexey Zelkin To: "Sergey A. Osokin" Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 17:02:07 +0300 hi, Well, answers below, but please consider my general point (same as Bruce's) I don't think that we need it at all. SUSv3 marks these functions as legacy (i.e. deprecated) and suggest to use sprintf() instead (see APPLICATION USAGE section). On Fri, Apr 25, 2003 at 04:32:10PM +0400, Sergey A. Osokin wrote: > On Fri, Apr 25, 2003 at 03:19:37PM +0300, Alexey Zelkin wrote: > > On Fri, Apr 25, 2003 at 12:38:51PM +0400, Sergey A. Osokin wrote: > > > > > > > >Number: 51292 > > > > > >Category: standards > > > > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) [..] > > Actually, all these cases should be handled by setlocale() itself. And > > after call to 'setlocale()' you should use lconv() to receive current > > radix character. > > I also would object to using of setlocale() from libc's function internally. > > Hmm, but from SUSv3: > > The radix character is determined by the current locale. If > setlocale() has not been called successfully, the default locale, > POSIX, is used. The default locale specifies a period > ( '.' ) as the radix character. > And what? It does not mean that setlocale() should be called in *cvt() functions. Can you ever count amount of possible problems caused by call to setlocale() in middle of libc function ? > > It's a application's problem to decide which locale to use and [fge]cvt() > > should use locale previously set by application. > > AFAIK only gcvt() have locale-specific "problem". I can't find > any locale-specific words in documentation of [ef]cvt. Correct > me if I'm wrong... You may find 'radix character' related words there. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 07:08:10 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 5FD2637B401 for ; Fri, 25 Apr 2003 07:08:10 -0700 (PDT) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17AC843F85 for ; Fri, 25 Apr 2003 07:08:09 -0700 (PDT) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100])h3PE7rE08393; Fri, 25 Apr 2003 16:07:53 +0200 (MEST) Date: Fri, 25 Apr 2003 16:07:53 +0200 (CEST) From: Harti Brandt To: Alexey Zelkin In-Reply-To: <200304251400.h3PE0TAZ009728@freefall.freebsd.org> Message-ID: <20030425160604.X76877@beagle.fokus.fraunhofer.de> References: <200304251400.h3PE0TAZ009728@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 25 Apr 2003 14:08:10 -0000 On Fri, 25 Apr 2003, Alexey Zelkin wrote: AZ>The following reply was made to PR standards/51292; it has been noted by GNATS. AZ> AZ>From: Alexey Zelkin AZ>To: "Sergey A. Osokin" AZ>Cc: FreeBSD-gnats-submit@freebsd.org AZ>Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) AZ>Date: Fri, 25 Apr 2003 17:02:07 +0300 AZ> AZ> hi, AZ> AZ> Well, answers below, but please consider my general point (same as Bruce's) AZ> I don't think that we need it at all. SUSv3 marks these functions as AZ> legacy (i.e. deprecated) and suggest to use sprintf() instead (see AZ> APPLICATION USAGE section). AZ> AZ> On Fri, Apr 25, 2003 at 04:32:10PM +0400, Sergey A. Osokin wrote: AZ> > On Fri, Apr 25, 2003 at 03:19:37PM +0300, Alexey Zelkin wrote: AZ> > > On Fri, Apr 25, 2003 at 12:38:51PM +0400, Sergey A. Osokin wrote: AZ> > > AZ> > > > > > >Number: 51292 AZ> > > > > > >Category: standards AZ> > > > > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) AZ> AZ> [..] AZ> AZ> > > Actually, all these cases should be handled by setlocale() itself. And AZ> > > after call to 'setlocale()' you should use lconv() to receive current AZ> > > radix character. AZ> > > I also would object to using of setlocale() from libc's function internally. AZ> > AZ> > Hmm, but from SUSv3: AZ> > AZ> > The radix character is determined by the current locale. If AZ> > setlocale() has not been called successfully, the default locale, AZ> > POSIX, is used. The default locale specifies a period AZ> > ( '.' ) as the radix character. AZ> > AZ> AZ> And what? It does not mean that setlocale() should be called AZ> in *cvt() functions. AZ> AZ> Can you ever count amount of possible problems caused by call to setlocale() AZ> in middle of libc function ? I suppose localeconv()->decimal_point is the correct way to obtain the period? That's at what vfprintf() does. harti -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 07:20: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 87F4437B401 for ; Fri, 25 Apr 2003 07:20:11 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23EFF43FCB for ; Fri, 25 Apr 2003 07:20: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 h3PEKAUp091300 for ; Fri, 25 Apr 2003 07:20: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 h3PEKA2Y091294; Fri, 25 Apr 2003 07:20:10 -0700 (PDT) Date: Fri, 25 Apr 2003 07:20:10 -0700 (PDT) Message-Id: <200304251420.h3PEKA2Y091294@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 14:20:11 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Alexey Zelkin Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 18:19:16 +0400 On Fri, Apr 25, 2003 at 05:02:07PM +0300, Alexey Zelkin wrote: > > Well, answers below, but please consider my general point (same as Bruce's) > I don't think that we need it at all. SUSv3 marks these functions as > legacy (i.e. deprecated) and suggest to use sprintf() instead (see > APPLICATION USAGE section). OK, nevermnind. Please close this PR. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 08:40:13 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 C3DA137B401 for ; Fri, 25 Apr 2003 08:40:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4AE1043FBD for ; Fri, 25 Apr 2003 08:40:13 -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 h3PFeCUp084529 for ; Fri, 25 Apr 2003 08:40:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3PFeCv4084528; Fri, 25 Apr 2003 08:40:12 -0700 (PDT) Date: Fri, 25 Apr 2003 08:40:12 -0700 (PDT) Message-Id: <200304251540.h3PFeCv4084528@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 15:40:14 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Alexey Zelkin Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 19:33:06 +0400 On Fri, Apr 25, 2003 at 05:02:07PM +0300, Alexey Zelkin wrote: > On Fri, Apr 25, 2003 at 04:32:10PM +0400, Sergey A. Osokin wrote: > > On Fri, Apr 25, 2003 at 03:19:37PM +0300, Alexey Zelkin wrote: > > > On Fri, Apr 25, 2003 at 12:38:51PM +0400, Sergey A. Osokin wrote: > > > > > > > > > >Number: 51292 > > > > > > >Category: standards > > > > > > >Synopsis: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) > > > > Actually, all these cases should be handled by setlocale() itself. And > > > after call to 'setlocale()' you should use lconv() to receive current > > > radix character. > > > I also would object to using of setlocale() from libc's function internally. > > > > Hmm, but from SUSv3: > > > > The radix character is determined by the current locale. If > > setlocale() has not been called successfully, the default locale, > > POSIX, is used. The default locale specifies a period > > ( '.' ) as the radix character. > > > > And what? It does not mean that setlocale() should be called > in *cvt() functions. > > Can you ever count amount of possible problems caused by call to setlocale() > in middle of libc function ? BTW if (setlocale(LC_NUMERIC, NULL) == NULL) { radix = '.'; n_sign = '-'; p_sign = '+'; } else { lc = localeconv(); radix = *lc->decimal_point; n_sign = *lc->negative_sign; p_sign = *lc->positive_sign; } Correct? > > > It's a application's problem to decide which locale to use and [fge]cvt() > > > should use locale previously set by application. > > > > AFAIK only gcvt() have locale-specific "problem". I can't find > > any locale-specific words in documentation of [ef]cvt. Correct > > me if I'm wrong... > > You may find 'radix character' related words there. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 08:50:08 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 A4E4E37B401 for ; Fri, 25 Apr 2003 08:50:08 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4AD2643F85 for ; Fri, 25 Apr 2003 08:50:08 -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 h3PFo8Up025188 for ; Fri, 25 Apr 2003 08: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 h3PFo8c8025178; Fri, 25 Apr 2003 08:50:08 -0700 (PDT) Date: Fri, 25 Apr 2003 08:50:08 -0700 (PDT) Message-Id: <200304251550.h3PFo8c8025178@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Sergey A. Osokin" Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Sergey A. Osokin" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 15:50:09 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: "Sergey A. Osokin" To: Alexey Zelkin Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 19:46:27 +0400 On Fri, Apr 25, 2003 at 05:02:07PM +0300, Alexey Zelkin wrote: > > Well, answers below, but please consider my general point (same as Bruce's) > I don't think that we need it at all. SUSv3 marks these functions as > legacy (i.e. deprecated) and suggest to use sprintf() instead (see > APPLICATION USAGE section). Another idea. What do you think if I create a little manpage about [efg]cvt() functions, something like this? ecvt(),fcvt(),gcvt() functions shall convert floating-point numbers to null-terminated strings DESCRIPTION ecvt(),fcvt(),gcvt() functions marked by .Std SUSv3 as legacy (i.e. deprecated) and suggest to use sprintf() instead. -- Rgdz, /"\ ASCII RIBBON CAMPAIGN Sergey Osokin aka oZZ, \ / AGAINST HTML MAIL http://ozz.pp.ru/ X AND NEWS / \ From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 11:00:21 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 ED45F37B401 for ; Fri, 25 Apr 2003 11:00:21 -0700 (PDT) Received: from relay1.cris.net (relay1.cris.net [212.110.128.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D58643FAF for ; Fri, 25 Apr 2003 11:00:19 -0700 (PDT) (envelope-from phantom@phantom.cris.net) Received: from phantom.cris.net (root@phantom.cris.net [212.110.130.74]) by relay1.cris.net (8.12.6/8.12.6) with ESMTP id h3PK6W8k044417; Fri, 25 Apr 2003 20:06:32 GMT Received: (from phantom@localhost) by phantom.cris.net (8.12.6/8.12.2) id h3PI6n0Q043964; Fri, 25 Apr 2003 21:06:49 +0300 (EEST) (envelope-from phantom) Date: Fri, 25 Apr 2003 21:06:49 +0300 From: Alexey Zelkin To: Harti Brandt Message-ID: <20030425210649.B43798@phantom.cris.net> References: <200304251400.h3PE0TAZ009728@freefall.freebsd.org> <20030425160604.X76877@beagle.fokus.fraunhofer.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030425160604.X76877@beagle.fokus.fraunhofer.de>; from brandt@fokus.fraunhofer.de on Fri, Apr 25, 2003 at 04:07:53PM +0200 X-Operating-System: FreeBSD 4.7-STABLE i386 cc: freebsd-standards@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) 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, 25 Apr 2003 18:00:22 -0000 hi, On Fri, Apr 25, 2003 at 04:07:53PM +0200, Harti Brandt wrote: > I suppose localeconv()->decimal_point is the correct way to obtain the > period? That's at what vfprintf() does. Absolutely. From owner-freebsd-standards@FreeBSD.ORG Fri Apr 25 11:00:26 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 16DF937B401 for ; Fri, 25 Apr 2003 11:00:26 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B129543F93 for ; Fri, 25 Apr 2003 11:00:25 -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 h3PI0OUp061153 for ; Fri, 25 Apr 2003 11:00:24 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3PI0OU5061150; Fri, 25 Apr 2003 11:00:24 -0700 (PDT) Date: Fri, 25 Apr 2003 11:00:24 -0700 (PDT) Message-Id: <200304251800.h3PI0OU5061150@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Alexey Zelkin Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alexey Zelkin List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 18:00:26 -0000 The following reply was made to PR standards/51292; it has been noted by GNATS. From: Alexey Zelkin To: "Sergey A. Osokin" Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: standards/51292: [PATCH] add ecvt()/fcvt()/gcvt() functions (SUSv3) Date: Fri, 25 Apr 2003 21:05:09 +0300 hi, On Fri, Apr 25, 2003 at 07:33:06PM +0400, Sergey A. Osokin wrote: > BTW > if (setlocale(LC_NUMERIC, NULL) == NULL) { > radix = '.'; > n_sign = '-'; > p_sign = '+'; > } else { > lc = localeconv(); > radix = *lc->decimal_point; > n_sign = *lc->negative_sign; > p_sign = *lc->positive_sign; > } > > Correct? No. 1. 'if' statement will never return in this case. It's possible for setlocale() to retrun at 'set' request, but this is 'get' request. And if previously setlocale() was never called, default locale caregory name ("C") will be returned. 2. Even in case if setlocale() was never called, or setlocale() call for LC_NUMERIC category was failed before -- it always will be used default "C" locale settings. They're staticly available from libc. It's are always guaranted that localeconv() will return reasonable values (current or default)