NetBSD Problem Report #50768

From dholland@netbsd.org  Fri Feb  5 03:20:15 2016
Return-Path: <dholland@netbsd.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id CC2017A140
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  5 Feb 2016 03:20:15 +0000 (UTC)
Message-Id: <20160205032015.4C72E85E61@mail.netbsd.org>
Date: Fri,  5 Feb 2016 03:20:15 +0000 (UTC)
From: dholland@netbsd.org
Reply-To: dholland@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: units(1) silently fails on negative exponents
X-Send-Pr-Version: 3.95

>Number:         50768
>Category:       bin
>Synopsis:       units(1) silently fails on negative exponents
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 05 03:25:00 +0000 2016
>Closed-Date:    Mon Jul 16 07:54:42 +0000 2018
>Last-Modified:  Mon Jul 16 07:54:42 +0000 2018
>Originator:     David A. Holland
>Release:        NetBSD 7.99.26 (20160204)
>Organization:
>Environment:
System: n/a
Architecture: n/a
Machine: n/a
>Description:

Observe:

   % units
   531 units, 41 prefixes

   You have: cm^-2
   You want: m^-2
           * 0.01
           / 100

This is completely wrong; the -2 is silently ignored. The same thing
happens with many more subtle cases, e.g.

   You have: 6.23e+8 horsepower ft^-2 degree^-2
   You want: watt m^-2 sr^-1
           * 3.1056629e+10
           / 3.2199245e-11

(the right answer is 1.6416004e+16)

>How-To-Repeat:

>Fix:
beat on the parser

>Release-Note:

>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50768 CVS commit: src/usr.bin/units
Date: Fri, 5 Feb 2016 03:30:08 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Fri Feb  5 03:30:08 UTC 2016

 Modified Files:
 	src/usr.bin/units: units.c

 Log Message:
 Improve the parser. Now we understand negative exponents; fixes PR 50768.

 Also handle negative numbers better in general (don't randomly drop
 the sign in a number of cases) and don't choke on exponents > 9.

 This commit alters the meaning of a few previously valid but marginal
 inputs (e.g. "3 foot-5 pound" is now treated as "3*-5 foot-pound"
 rather than "3*5 foot-pound"; if you want the latter insert another
 space) but corrects obviously wrong handling of many more.


 To generate a diff of this commit:
 cvs rdiff -u -r1.25 -r1.26 src/usr.bin/units/units.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: PR/50768 CVS commit: src/usr.bin/units
Date: Fri, 5 Feb 2016 03:52:05 +0000

 On Fri, Feb 05, 2016 at 03:35:01AM +0000, David A. Holland wrote:
  >  Log Message:
  >  Improve the parser. Now we understand negative exponents; fixes PR 50768.
  >  
  >  Also handle negative numbers better in general (don't randomly drop
  >  the sign in a number of cases) and don't choke on exponents > 9.
  >  
  >  This commit alters the meaning of a few previously valid but marginal
  >  inputs (e.g. "3 foot-5 pound" is now treated as "3*-5 foot-pound"
  >  rather than "3*5 foot-pound"; if you want the latter insert another
  >  space) but corrects obviously wrong handling of many more.
  >  
  >  
  >  To generate a diff of this commit:
  >  cvs rdiff -u -r1.25 -r1.26 src/usr.bin/units/units.c

 This is now fixed, but should be pulled up to -7 and probably -6, but
 I want to wait a bit first.

 Anyone who wants to swipe the patch note that you also almost
 certainly want -r1.27 of units.c.

 (the issue seems to date back and it affects other variants of units,
 including e.g. Apple's.)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->needs-pullups
State-Changed-By: maya@NetBSD.org
State-Changed-When: Wed, 20 Jun 2018 00:03:47 +0000
State-Changed-Why:
Correct status.


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 15 Jul 2018 06:52:04 +0000
State-Changed-Why:
pullup-7 #1620
I think I shan't do -6 as it doesn't merge cleanly and it's been two years
since I looked at the code.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50768 CVS commit: [netbsd-7] src/usr.bin/units
Date: Sun, 15 Jul 2018 10:47:54 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Jul 15 10:47:54 UTC 2018

 Modified Files:
 	src/usr.bin/units [netbsd-7]: units.c

 Log Message:
 Pull up following revision(s) (requested by dholland in ticket #1620):

 	usr.bin/units/units.c: revision 1.26,1.27

 Improve the parser. Now we understand negative exponents; fixes PR 50768.

 Also handle negative numbers better in general (don't randomly drop
 the sign in a number of cases) and don't choke on exponents > 9.

 This commit alters the meaning of a few previously valid but marginal
 inputs (e.g. "3 foot-5 pound" is now treated as "3*-5 foot-pound"
 rather than "3*5 foot-pound"; if you want the latter insert another
 space) but corrects obviously wrong handling of many more.

  -

 Improve previous slightly; while we accept e.g. "meter2" to mean "meter^2",
 don't allow "meter-2" to be interpreted as "meter^-2" as that's very
 confusing.


 To generate a diff of this commit:
 cvs rdiff -u -r1.25 -r1.25.4.1 src/usr.bin/units/units.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 16 Jul 2018 07:54:42 +0000
State-Changed-Why:
done.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.