From owner-freebsd-current@FreeBSD.ORG Thu Jan 20 21:44: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 4AF1916A4CE; Thu, 20 Jan 2005 21:44:09 +0000 (GMT) Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7EDA143D53; Thu, 20 Jan 2005 21:44:08 +0000 (GMT) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.13.1/8.13.1) with ESMTP id j0KLi7cR070596; Fri, 21 Jan 2005 00:44:07 +0300 (MSK) (envelope-from ache@nagual.pp.ru) Received: (from ache@localhost) by nagual.pp.ru (8.13.1/8.13.1/Submit) id j0KLi6DC070595; Fri, 21 Jan 2005 00:44:06 +0300 (MSK) (envelope-from ache) Date: Fri, 21 Jan 2005 00:44:06 +0300 From: Andrey Chernov To: Joerg Wunsch Message-ID: <20050120214406.GA70088@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , Joerg Wunsch , current@FreeBSD.ORG, bde@FreeBSD.ORG References: <20050120192324.GA30862@uriah.heep.sax.de> <20050120205501.GA69123@nagual.pp.ru> <20050120211449.GC30862@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050120211449.GC30862@uriah.heep.sax.de> User-Agent: Mutt/1.5.6i X-AntiVirus: checked by AntiVir Milter (version: 1.1.0-3; AVE: 6.29.0.8; VDF: 6.29.0.73; host: nagual.pp.ru) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.5.6 (nagual.pp.ru [0.0.0.0]); Fri, 21 Jan 2005 00:44:07 +0300 (MSK) cc: current@FreeBSD.ORG cc: bde@FreeBSD.ORG Subject: Re: Implementation errors in strtol() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jan 2005 21:44:09 -0000 On Thu, Jan 20, 2005 at 10:14:49PM +0100, Joerg Wunsch wrote: > Yes, I know. Anyway, how could POSIX (or the Single UNIX > Specification, for that matter) possibly contradict to the C standard? There is common practice for both POSIX and SUS to extend errno values beyond C standard, see lots of other functions. Personally I do not research the reason of their decision, just point to the fact. > ``The value of errno is zero at program startup, but is never set to > zero by any library function.170) The value of errno may be set to ^^^^^^^^^^^^^^^^ > nonzero by a library function call whether or not there is an error, > provided the use of errno is not documented in the description of the ^^^^^^^^^^^^^^^^^ > function in this International Standard.'' Errno may be set in case of error with not documented errno. Thats how I read it, but I may miss something. > Still, my major point was that "0x" sequences are falsely rejected as It clearly should be rejected with EINVAL in case base == 16, because 0 alone is not valid HEX sequence and no valid sequence found at this point. I am not sure about other bases. > conversion errors, and that strings consisting solely of a plus or > minus sign should not throw an error either, as I read the C standard. +- may produce EINVAL, as POSIX says. In general please don't forget that strtol(), atol() etc. supposed to parse user input and _detect_ syntax errors, it is their purpose. If they not do it or do it in half, each program forced to use its own parser instead. -- http://ache.pp.ru/