From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12940 invoked from network); 26 Apr 2021 23:26:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Apr 2021 23:26:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1619479586; b=lzWKOn/EHQ3bYfqPoKrBXBmWrJ4INoRMREbtphVzGI9WZ4jRfdDZwmQRdWgMDgWVYubCqSbbD9 WntwEaLvDcZCK3xJGwIdCr17qCJIoLNtSgTeBOygvflJjPq5ORA7hrCDcoVf/MpKrzJ6mGpaYl g+r30nWaXZjef4sJTcJInOvoZjzclHrSbpG0qv+Q5eidJv5jt6rT9Jri1Bx6LmK8Zz4NA1O/yW /iCiKZJ/4XWEdbd4cGBTsCuA2pBCYDU1LcUh8OfizwgeuPcR+/fBwMQfZQz4h6lR32BT7rU7P/ OZWBxvx7Wqeb690FjRbLKlwhpmqTG29kzV7aYE2mI4AwSw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1619479586; bh=UJPgSsmzhTqh1TupOirgFLaG/8ovOCDzk8B1dpaWEso=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=RYk9dT28FkUoUnVWRkZ8jRjMDY+ClSBd6Uhy7pVh3nAwSnl18otiq+RMFyabPX7Vvuj3+gcIPm ZobS5fUUPAJtQqOoAPSoSkDSxcP4gnn52sUxabU/TR7tS/NMnJdFLi9/B9IZmaVvoJZNzFyAxQ +b+RCXCE4obkcsc69Ws4LMxmrCZZK4b+ypv7sHpaZQJnyecSvgrmM1qYb9TGVwzI8zoJOQRg+J AdqaX7L7eVTIAZImLVI37wbh3UazbIwv7VzVn4pphnpVuJltWWwhYxuA83HztHMKyGoh7ROgDf P+00pWLop0bxq4f91CNrCxuk1/H3gQEXmyEBTPZgdaZn8Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=fdd0jQRvPXBmaRuc+itUtWaknDln/Ms3oKXYsH1nAaw=; b=s8GX3yRSsvgwEBL6iOTpMFLeq7 115keDCVjuqvz2uxEZwzQgIXCx6wsh7GCZLsc70Av5zH4vMOI2+LGoZJZC6PFXtJrFOS+84BPxwRG gEyw2Vdw6lvGaHeNL9I4ggCfXX0koTd5hgvDPv4DnuV3WNPVG/sCt6cdx0B9CokujMoontltiIRCm g4aMn8sYie8wYorms20oF6E27uykYYFeoDFJ7aPu3qhIczH9puCpPtoyO6vlSkrbYsJ6HkwQq7lN1 WgulF93JyT1k9MO1cTmBDAiiCYFs6ZcDgFCUKgxUjsXXt7/bdc8DzgDci198Gk+O0BpRo2SrvOBR4 IO7n+8ww==; Received: from authenticated user by zero.zsh.org with local id 1lbAcR-000Hkj-L1; Mon, 26 Apr 2021 23:26:24 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:54490) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lbAc0-000H9z-AS; Mon, 26 Apr 2021 23:26:04 +0000 Received: from smtp-zira.vinc17.net (unknown [IPv6:2a01:cb19:869c:7700:6150:861a:e24c:595d]) by joooj.vinc17.net (Postfix) with ESMTPSA id 62F792F6; Tue, 27 Apr 2021 01:25:55 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id 1C91CC2072E; Tue, 27 Apr 2021 01:25:53 +0200 (CEST) Date: Tue, 27 Apr 2021 01:25:53 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: sh emulation POSIX non-conformances ("inf"/"Inf" in arithmetic expressions) Message-ID: <20210426232553.GA842212@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20210422153100.GD154089@zira.vinc17.org> <20210423164525.GA2033191@zira.vinc17.org> <55222-1619218004.791735@3FXq.NU49.vlrg> <20210424230219.GD2587578@zira.vinc17.org> <20210425201730.GA3907643@zira.vinc17.org> <20210426103436.GA3949742@zira.vinc17.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="O9xGPhl+EAOakTzO" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210426103436.GA3949742@zira.vinc17.org> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.0.6+162 (8b7dd25b) vl-137001 (2021-04-24) X-Seq: 48723 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: --O9xGPhl+EAOakTzO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2021-04-26 12:34:36 +0200, Vincent Lefevre wrote: > On 2021-04-25 15:00:03 -0700, Bart Schaefer wrote: > > On Sun, Apr 25, 2021 at 1:18 PM Vincent Lefevre wrote: > > > > > > math.c is obviously incorrect: > > > > > > else if (strncasecmp(p, "Inf", 3) == 0) { > > > > What should it (and the corresponding NaN line) be, then? > > This depends on the expected behavior: Should it match only > [Ii][Nn][Ff], or also the lowercase and uppercase versions? > ... so that in Turkish locales under Debian: [Iıİi][Nn][Ff], > i.e. also with > U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE > U+0131 LATIN SMALL LETTER DOTLESS I I think that matching ASCII only would be the expected behavior, as this would not depend on the locales and this would be like ksh93, strtod(), and so on. See attached patch. Alternatively, you could keep the strncasecmp for NaN and possibly for the "nf" part of "Inf" since AFAIK, 'i' is the only letter to have such an issue, but for 3 characters, individual comparisons seem OK. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) --O9xGPhl+EAOakTzO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="inf-nan.patch" diff --git a/Src/math.c b/Src/math.c index 1d0d86639..ade02d80c 100644 --- a/Src/math.c +++ b/Src/math.c @@ -864,13 +864,17 @@ zzlex(void) p = ptr; ptr = ie; if (ie - p == 3) { - if (strncasecmp(p, "NaN", 3) == 0) { + if ((p[0] == 'N' || p[0] == 'n') && + (p[1] == 'A' || p[1] == 'a') && + (p[2] == 'N' || p[2] == 'n')) { yyval.type = MN_FLOAT; yyval.u.d = 0.0; yyval.u.d /= yyval.u.d; return NUM; } - else if (strncasecmp(p, "Inf", 3) == 0) { + else if ((p[0] == 'I' || p[0] == 'i') && + (p[1] == 'N' || p[1] == 'n') && + (p[2] == 'F' || p[2] == 'f')) { yyval.type = MN_FLOAT; yyval.u.d = 0.0; yyval.u.d = 1.0 / yyval.u.d; --O9xGPhl+EAOakTzO--