NetBSD Problem Report #42940

From dholland@eecs.harvard.edu  Tue Mar  9 20:29:27 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 7545C63B873
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  9 Mar 2010 20:29:27 +0000 (UTC)
Message-Id: <20100309202909.250A2F974@tanaqui.eecs.harvard.edu>
Date: Tue,  9 Mar 2010 15:29:08 -0500 (EST)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: units(1) parsing glitch
X-Send-Pr-Version: 3.95

>Number:         42940
>Category:       bin
>Synopsis:       units(1) parsing glitch
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 09 20:30:00 +0000 2010
>Last-Modified:  Sat Jun 12 16:45:01 +0000 2021
>Originator:     David A. Holland
>Release:        NetBSD 5.99.22 (20091208)
>Organization:
>Environment:
System: NetBSD tanaqui 5.99.22 NetBSD 5.99.22 (TANAQUI) #31: Tue Dec 8 22:53:35 EST 2009 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

units interprets "km/h" as "kilometers per hecto-nothing", which is
both not very useful (as "km/h" is a standard abbreviation) and also
contrary to the usual practice in which SI prefixes are not allowed to
be freestanding.

>How-To-Repeat:

% units
524 units, 41 prefixes

You have: km/h
You want: meter   
        * 10
        / 0.1
You have: km/h     
You want: kilometer/hour
conformability error
        10 m
        0.27777778 m / sec

>Fix:

dunno, have to go squint at the parser sometime

>Audit-Trail:
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 11:34:00 +0200

 On Tue, 09 Mar 2010, dholland@eecs.harvard.edu wrote:
 > You have: km/h     
 > You want: kilometer/hour
 > conformability error
 >         10 m
 >         0.27777778 m / sec

 Similarly:

 You have: 3600 s
 You want: h
 conformability error
         3600 sec
         100

 --apb (Alan Barrett)

From: Dave Huang <khym@azeotrope.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 03:46:19 -0600

 On 3/10/2010 3:35 AM, Alan Barrett wrote:
 > The following reply was made to PR bin/42940; it has been noted by GNATS.
 >
 > From: Alan Barrett<apb@cequrux.com>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: bin/42940: units(1) parsing glitch
 > Date: Wed, 10 Mar 2010 11:34:00 +0200
 >
 >   On Tue, 09 Mar 2010, dholland@eecs.harvard.edu wrote:
 >   >  You have: km/h
 >   >  You want: kilometer/hour
 >   >  conformability error
 >   >          10 m
 >   >          0.27777778 m / sec
 >
 >   Similarly:
 >
 >   You have: 3600 s
 >   You want: h
 >   conformability error
 >           3600 sec
 >           100

 /usr/share/misc/units.lib doesn't define "h" as a synonym for "hour". Simply 
 adding it seems to do the right thing:

 --- /usr/share/misc/units.lib   2007-02-17 03:12:59.000000000 -0600
 +++ /tmp/units.lib      2010-03-10 03:43:01.000000000 -0600
 @@ -98,6 +98,7 @@
   min                    minute
   hour                   60 min
   hr                     hour
 +h                      hour
   day                    24 hr
   da                     day
   week                   7 day

 $ units -f /tmp/units.lib
 525 units, 41 prefixes

 You have: km/h
 You want: kilometer/hour
          * 1
          / 1
 You have: 3600 s
 You want: h
          * 1
          / 1
 You have: hm^2
 You want: m^2
          * 10000
          / 0.0001

From: =?UTF-8?Q?Zafer_Aydo=C4=9Fan?= <zafer@aydogan.de>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, dholland@eecs.harvard.edu
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 11:46:29 +0100

 2010/3/10 Dave Huang <khym@azeotrope.org>:
 > The following reply was made to PR bin/42940; it has been noted by GNATS.
 >
 > From: Dave Huang <khym@azeotrope.org>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: bin/42940: units(1) parsing glitch
 > Date: Wed, 10 Mar 2010 03:46:19 -0600
 >
 > =C2=A0On 3/10/2010 3:35 AM, Alan Barrett wrote:
 > =C2=A0> The following reply was made to PR bin/42940; it has been noted b=
 y GNATS.
 > =C2=A0>
 > =C2=A0> From: Alan Barrett<apb@cequrux.com>
 > =C2=A0> To: gnats-bugs@NetBSD.org
 > =C2=A0> Cc:
 > =C2=A0> Subject: Re: bin/42940: units(1) parsing glitch
 > =C2=A0> Date: Wed, 10 Mar 2010 11:34:00 +0200
 > =C2=A0>
 > =C2=A0> =C2=A0 On Tue, 09 Mar 2010, dholland@eecs.harvard.edu wrote:
 > =C2=A0> =C2=A0 > =C2=A0You have: km/h
 > =C2=A0> =C2=A0 > =C2=A0You want: kilometer/hour
 > =C2=A0> =C2=A0 > =C2=A0conformability error
 > =C2=A0> =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A010 m
 > =C2=A0> =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00.27777778 m / sec
 > =C2=A0>
 > =C2=A0> =C2=A0 Similarly:
 > =C2=A0>
 > =C2=A0> =C2=A0 You have: 3600 s
 > =C2=A0> =C2=A0 You want: h
 > =C2=A0> =C2=A0 conformability error
 > =C2=A0> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 3600 sec
 > =C2=A0> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 100
 >
 > =C2=A0/usr/share/misc/units.lib doesn't define "h" as a synonym for "hour=
 ". Simply
 > =C2=A0adding it seems to do the right thing:
 >
 > =C2=A0--- /usr/share/misc/units.lib =C2=A0 2007-02-17 03:12:59.000000000 =
 -0600
 > =C2=A0+++ /tmp/units.lib =C2=A0 =C2=A0 =C2=A02010-03-10 03:43:01.00000000=
 0 -0600
 > =C2=A0@@ -98,6 +98,7 @@
 > =C2=A0 min =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
  =C2=A0minute
 > =C2=A0 hour =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 =A0 60 min
 > =C2=A0 hr =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
 =C2=A0 hour
 > =C2=A0+h =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
 =C2=A0 =C2=A0hour
 > =C2=A0 day =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
  =C2=A024 hr
 > =C2=A0 da =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
 =C2=A0 day
 > =C2=A0 week =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 =A0 7 day
 >
 > =C2=A0$ units -f /tmp/units.lib
 > =C2=A0525 units, 41 prefixes
 >
 > =C2=A0You have: km/h
 > =C2=A0You want: kilometer/hour
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* 1
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/ 1
 > =C2=A0You have: 3600 s
 > =C2=A0You want: h
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* 1
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/ 1
 > =C2=A0You have: hm^2
 > =C2=A0You want: m^2
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* 10000
 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/ 0.0001
 >
 >

 should a pullup be reqested for 5.0.2 ?

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 19:17:27 +0700

     Date:        Wed, 10 Mar 2010 09:50:05 +0000 (UTC)
     From:        Dave Huang <khym@azeotrope.org>
     Message-ID:  <20100310095005.1A22963B873@www.NetBSD.org>


   |  /usr/share/misc/units.lib doesn't define "h" as a synonym for "hour".

 No, nor should it, 'h' is only used for hour in a very few restricted
 usages.

 units doesn't define 'k' for kilometres either, yet if someone one
 day is going to wonder why units can't convert k/h into m/h (for that
 matter, "m" is metre, not mile, so ...)

 If you're already thinking about speeds (or perhaps velocities) then
 k/h (or kph) and m/h (or mph) are obvious - to you, but if you're
 thinking crop yields, then k/h might be kilogrammes per hectare (or
 something...)

 Just leave units alone in this case, nothing needs fixing except the
 usage expectation.   The man page shows using full names of units,
 any time things don't work quite like you'd hope when you use a
 (perhaps very common, but usually ambiguous without context) abbreviation
 it can always be fixed by just using the full name of the unit of concern.

 That's good enough - don't make it start giving out incorrect answers
 because it has started to guess what you might have meant.

 kre

From: "Martin S. Weber" <Ephaeton@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 09:14:09 -0500

 On Wed, Mar 10, 2010 at 12:20:05PM +0000, Robert Elz wrote:
 >  (...)
 >    |  /usr/share/misc/units.lib doesn't define "h" as a synonym for "hour".
 >  
 >  No, nor should it, 'h' is only used for hour in a very few restricted
 >  usages.
 >  

 Now that's an interesting statement. The BIPM defines the hour as one
 of the few units outside of the SI. Its well-defined symbol is "h".
 Cf. http://physics.nist.gov/Pubs/SP811/sec05.html [SP811 is the en-US
 "translation" of the relevant BIPM document. If you don't believe the
 US pagans, try http://www.bipm.org/en/si/si_brochure/chapter4/table6.html ].

 > (...)
 >  Just leave units alone in this case, nothing needs fixing except the
 >  usage expectation.   

 Well, usage of well-defined (by BIPM via SI) symbols should definitely
 be supported.

 >  (...)
 >  That's good enough - don't make it start giving out incorrect answers
 >  because it has started to guess what you might have meant.

 SI has specific rules about prefixes in combination with unit symbols.
 'h' never will mean 'hecto' by itself. The right answer must be 'hour',
 see above.

 Regards,

 -Martin

From: David Holland <dholland@eecs.harvard.edu>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Wed, 10 Mar 2010 14:29:18 -0500

 On Wed, Mar 10, 2010 at 12:20:05PM +0000, Robert Elz wrote:
  >  Just leave units alone in this case, nothing needs fixing except the
  >  usage expectation.   The man page shows using full names of units,
  >  any time things don't work quite like you'd hope when you use a
  >  (perhaps very common, but usually ambiguous without context) abbreviation
  >  it can always be fixed by just using the full name of the unit of concern.

 no, units should not be recognizing freestanding SI prefixes as
 dimensionless units.

 'h' is not the only one; it appears all of them that aren't also
 defined some other way exhibit this behavior.

 for example:

    You have: 1
    You want: M
 	   * 1e-06
 	   / 1000000
    You have: 1 
    You want: G
 	   * 1e-09
 	   / 1e+09

 and this is even more broken:

 You have: 1
 You want: milli
         * 1000
         / 0.001

 -- 
    - David A. Holland / dholland@eecs.harvard.edu

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42940: units(1) parsing glitch
Date: Sat, 12 Jun 2021 16:43:11 +0000

 On Wed, Mar 10, 2010 at 07:35:02PM +0000, David Holland wrote:
  >  no, units should not be recognizing freestanding SI prefixes as
  >  dimensionless units.
  >  
  >  'h' is not the only one; it appears all of them that aren't also
  >  defined some other way exhibit this behavior.

 Not only that, I discovered today (the hard way) that you can combine
 them:

    % units
    537 units, 41 prefixes

    You have: hG
    You want: 1
            * 1e+11
            / 1e-11
    You have: myrianano
    You want: 1
            * 1e-05
            / 100000

 Normally, "ha" is a standard abbreviation for "hectare", but to units
 it means "hectoatto".

 Very broken.

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: gnats-precook-prs,v 1.4 2018/12/21 14:20:20 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.