From owner-freebsd-current@FreeBSD.ORG Thu Jan 20 22:40:09 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0317516A4CF; Thu, 20 Jan 2005 22:40:09 +0000 (GMT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AF8743D3F; Thu, 20 Jan 2005 22:40:08 +0000 (GMT) (envelope-from j@uriah.heep.sax.de) Received: from sax.sax.de (localhost [127.0.0.1]) by sax.sax.de (8.12.10/8.12.10) with ESMTP id j0KMe7Yu057562; Thu, 20 Jan 2005 23:40:07 +0100 (CET) (envelope-from j@uriah.heep.sax.de) Received: (from uucp@localhost) by sax.sax.de (8.12.10/8.12.10/Submit) with UUCP id j0KMe7Ow057561; Thu, 20 Jan 2005 23:40:07 +0100 (CET) (envelope-from j@uriah.heep.sax.de) Received: from uriah.heep.sax.de (localhost [127.0.0.1]) by uriah.heep.sax.de (8.13.1/8.13.1) with ESMTP id j0KMWXxS036215; Thu, 20 Jan 2005 23:32:33 +0100 (MET) (envelope-from j@uriah.heep.sax.de) Received: (from j@localhost) by uriah.heep.sax.de (8.13.1/8.13.1/Submit) id j0KMWWjV036195; Thu, 20 Jan 2005 23:32:32 +0100 (MET) (envelope-from j) Date: Thu, 20 Jan 2005 23:32:32 +0100 From: Joerg Wunsch To: current@FreeBSD.ORG Message-ID: <20050120223232.GF30862@uriah.heep.sax.de> References: <20050120192324.GA30862@uriah.heep.sax.de> <20050120205501.GA69123@nagual.pp.ru> <20050120211449.GC30862@uriah.heep.sax.de> <20050120214406.GA70088@nagual.pp.ru> <20050120220227.GB70629@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050120220227.GB70629@nagual.pp.ru> User-Agent: Mutt/1.4.2.1i X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E X-GPG-Fingerprint: 5E84 F980 C3CA FD4B B584 1070 F48C A81B 69A8 5873 X-Spam-Status: No, score=-2.6 required=7.5 tests=AWL,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on uriah.heep.sax.de cc: Andrey Chernov cc: bde@FreeBSD.ORG Subject: Re: Implementation errors in strtol() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Joerg Wunsch List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jan 2005 22:40:09 -0000 As Andrey Chernov wrote: > > +- may produce EINVAL, as POSIX says. > Because "no conversion could be performed", i.e. no single digit > found. No, sorry. You can perform a conversion on any valid subject sequence (that ``has the expected form''). The optional sign is part of the valid sequence. ``The subject sequence contains no characters if the input string is empty or consists entirely of white-space characters, or if the first non-white-space character is other than a sign or a permissible letter or digit.'' That clearly doesn't apply to a string consisting of a single sign only, as its first non-white-space character is the sign (so it cannot be ``other than a sign''). Thus, we do not have a no-character subject sequence (which would constitute an empty subject sequence that in turn cannot be converted). Thus, we do have a subject sequence of the ``expected form''. Any such sequence is convertible per definitionem. An empty subject sequence would cause no conversion to be performed. Yet see the comparision to Solaris and Linux, they both don't flag it with an EINVAL. As Posix/SUSP doesn't make EINVAL mandatory, I'd rather go with not setting it in that case either. Well, as *I* read it, a single sign would cause that sign to become part of the number to be (successfully) converted, so it cannot be part of the final string. Yet, both the Solaris and the Linux implementation treat a single sign as becoming the final string. This is indeed a question for the language lawyers on comp.lang.c ... Are you going to ask there, Andrey, or do you want me to ask? -- cheers, J"org .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)