diff -Nru units-2.18/configure units-2.19/configure --- units-2.18/configure 2018-09-24 23:32:36.000000000 +0000 +++ units-2.19/configure 2019-05-24 23:15:50.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for GNU units 2.18. +# Generated by GNU Autoconf 2.69 for GNU units 2.19. # # Report bugs to . # @@ -580,8 +580,8 @@ # Identity of this package. PACKAGE_NAME='GNU units' PACKAGE_TARNAME='units' -PACKAGE_VERSION='2.18' -PACKAGE_STRING='GNU units 2.18' +PACKAGE_VERSION='2.19' +PACKAGE_STRING='GNU units 2.19' PACKAGE_BUGREPORT='adrianm@gnu.org' PACKAGE_URL='http://www.gnu.org/software/units/' @@ -1254,7 +1254,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU units 2.18 to adapt to many kinds of systems. +\`configure' configures GNU units 2.19 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1321,7 +1321,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU units 2.18:";; + short | recursive ) echo "Configuration of GNU units 2.19:";; esac cat <<\_ACEOF @@ -1410,7 +1410,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU units configure 2.18 +GNU units configure 2.19 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1825,7 +1825,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU units $as_me 2.18, which was +It was created by GNU units $as_me 2.19, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4614,7 +4614,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU units $as_me 2.18, which was +This file was extended by GNU units $as_me 2.19, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4669,7 +4669,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -GNU units config.status 2.18 +GNU units config.status 2.19 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru units-2.18/configure.ac units-2.19/configure.ac --- units-2.18/configure.ac 2018-09-22 22:48:35.000000000 +0000 +++ units-2.19/configure.ac 2019-05-24 22:39:13.000000000 +0000 @@ -1,7 +1,7 @@ dnl Copyright (C) 2006, 2014, 2017, 2018 Free Software Foundation, Inc dnl Process this file with autoconf to produce a configure script. -AC_INIT(GNU units,2.18,adrianm@gnu.org) +AC_INIT(GNU units,2.19,adrianm@gnu.org) AC_PREREQ(2.59) AC_ARG_PROGRAM diff -Nru units-2.18/currency.units units-2.19/currency.units --- units-2.18/currency.units 2018-10-20 14:04:18.000000000 +0000 +++ units-2.19/currency.units 2019-05-31 22:35:38.000000000 +0000 @@ -173,7 +173,7 @@ # Currency exchange rates source -!message Currency exchange rates from FloatRates (USD base) on 2018-10-20 +!message Currency exchange rates from FloatRates (USD base) on 2019-05-31 austriaschilling 1|13.7603 euro belgiumfranc 1|40.3399 euro @@ -194,163 +194,163 @@ spainpeseta 1|166.386 euro netherlandsguilder 1|2.20371 euro portugalescudo 1|200.482 euro -capeverdeescudo 0.010318874498 USD -bulgarialev 0.586320148727 USD -bosniaconvertiblemark 0.583840855296 USD -comorosfranc 0.0023233424643 USD +capeverdeescudo 0.0101044210089 USD +bulgarialev 0.569832695195 USD +bosniaconvertiblemark 0.571172528443 USD +comorosfranc 0.00227440386514 USD westafricafranc 1|655.957 euro cfpfranc 1|119.33 euro -centralafricacfafranc 0.00174095785264 USD -uaedirham 0.272129962337 USD -afghanafghani 0.0129797079865 USD -albanialek 0.00912050211431 USD -armeniadram 0.00205383326283 USD -antillesguilder 0.556314991623 USD -angolakwanza 0.00324459455866 USD -argentinapeso 0.0274338815436 USD -australiadollar 0.712489145888 USD -arubaflorin 0.545570596527 USD -azerbaijanmanat 0.587816387756 USD -barbadosdollar 0.499386932484 USD -bangladeshtaka 0.0117639399661 USD -bahraindinar 2.6534764841 USD -burundifranc 0.00055583628095 USD -bruneidollar 0.724470842005 USD -boliviaboliviano 0.144170169197 USD -brazilreal 0.270026788382 USD -bahamasdollar 0.987287572139 USD -botswanapula 0.0934472550859 USD -belarusruble 0.473199514671 USD +centralafricacfafranc 0.00168809696578 USD +uaedirham 0.272294233532 USD +afghanafghani 0.0125076627357 USD +albanialek 0.00908047171282 USD +armeniadram 0.00208237913772 USD +antillesguilder 0.534183593953 USD +angolakwanza 0.00303911891527 USD +argentinapeso 0.022425572153 USD +australiadollar 0.691924138002 USD +arubaflorin 0.553301470206 USD +azerbaijanmanat 0.589424489635 USD +barbadosdollar 0.500137771884 USD +bangladeshtaka 0.0118358067087 USD +bahraindinar 2.65432622511 USD +burundifranc 0.000546002389735 USD +bruneidollar 0.724959291959 USD +boliviaboliviano 0.14519949806 USD +brazilreal 0.251192789606 USD +bahamasdollar 1.00145462102 USD +botswanapula 0.0928468743331 USD +belarusruble 0.477369511625 USD oldbelarusruble 1|10000 BYN -belizedollar 0.491263530225 USD -canadadollar 0.767284000383 USD -drcfranccongolais 0.000601313794846 USD -swissfranc 1.00390504913 USD -chilepeso 0.00148081739266 USD -chinayuan 0.144261082775 USD -colombiapeso 0.000323859361331 USD -costaricacolon 0.0016745336777 USD -cubapeso 0.987287572139 USD -czechkoruna 0.0443338764462 USD -djiboutifranc 0.00554666099306 USD -denmarkkrona 0.153716660893 USD -dominicanrepublicpeso 0.019760112763 USD -algeriadinar 0.00841395598531 USD -egyptpound 0.0559259210092 USD -eritreanakfa 0.0655035770325 USD -ethiopiabirr 0.0355043748836 USD -euro 1.14682738915 USD -fijidollar 0.463418526103 USD -ukpound 1.30339311684 USD -georgialari 0.369830589612 USD -ghanacedi 0.203505225925 USD -gibraltarpound 1.29767825324 USD -gambiadalasi 0.0196803276509 USD -guineafranc 0.000109039653201 USD -guatemalaquetzal 0.127656179357 USD -guyanadollar 0.00472141698359 USD -hongkongdollar 0.127547741585 USD -honduraslempira 0.0410627376931 USD -croatiakuna 0.154363516722 USD -haitigourde 0.0138560144677 USD -hungariaforint 0.00354526419134 USD -indonesiarupiah 6.57527712626e-05 USD -israelnewshekel 0.273323656056 USD -indiarupee 0.0136240266711 USD -iraqdinar 0.000827637562831 USD -iranrial 2.37720430162e-05 USD -icelandkrona 0.00851243298639 USD -jamaicadollar 0.00749980053722 USD -jordandinar 1.40019769393 USD -japanyen 0.0088934879871 USD -kenyaschilling 0.0097718145794 USD -kyrgyzstansom 0.0143368005909 USD -cambodiariel 0.000240951038536 USD -southkoreawon 0.000883853373104 USD -kuwaitdinar 3.29354948225 USD -kazakhstantenge 0.00272829647003 USD -laokip 0.000115688412542 USD -lebanonpound 0.000656270823825 USD -srilankarupee 0.00577458046329 USD -liberiadollar 0.00622323874365 USD -lesotholoti 0.069386452488 USD -libyadinar 1.27995660471 USD -moroccodirham 0.104545091886 USD -moldovaleu 0.0587879325291 USD -madagascarariary 0.000279247892343 USD -macedoniadenar 0.0185702507912 USD -myanmarkyat 0.000618600569134 USD -mongoliatugrik 0.000384830190686 USD -macaupataca 0.122310576846 USD +belizedollar 0.496908930334 USD +canadadollar 0.738998182015 USD +drcfranccongolais 0.000608343290561 USD +swissfranc 0.994429717702 USD +chilepeso 0.00141176656462 USD +chinayuan 0.144801330126 USD +colombiapeso 0.000297363808638 USD +costaricacolon 0.00170175074365 USD +cubapeso 1.00145462102 USD +czechkoruna 0.0431115375124 USD +djiboutifranc 0.00562600654579 USD +denmarkkrona 0.149253655362 USD +dominicanrepublicpeso 0.0198192113876 USD +algeriadinar 0.00835430970538 USD +egyptpound 0.0595867283947 USD +eritreanakfa 0.0664450101304 USD +ethiopiabirr 0.0346771260845 USD +euro 1.11429646845 USD +fijidollar 0.464257883526 USD +ukpound 1.26153920067 USD +georgialari 0.357706893865 USD +ghanacedi 0.188789028001 USD +gibraltarpound 1.26614369578 USD +gambiadalasi 0.0198451867629 USD +guineafranc 0.000109616083952 USD +guatemalaquetzal 0.129902852096 USD +guyanadollar 0.00477037768196 USD +hongkongdollar 0.127440900637 USD +honduraslempira 0.0409371915424 USD +croatiakuna 0.150134699061 USD +haitigourde 0.0109616083952 USD +hungariaforint 0.0034294207435 USD +indonesiarupiah 6.95865312836e-05 USD +israelnewshekel 0.275704154063 USD +indiarupee 0.0143233712752 USD +iraqdinar 0.000839524131124 USD +iranrial 2.38529210867e-05 USD +icelandkrona 0.00804248688156 USD +jamaicadollar 0.0073510312224 USD +jordandinar 1.41233493639 USD +japanyen 0.00918008626144 USD +kenyaschilling 0.00988207179594 USD +kyrgyzstansom 0.0142898470647 USD +cambodiariel 0.000245467297002 USD +southkoreawon 0.000839675225101 USD +kuwaitdinar 3.28846922998 USD +kazakhstantenge 0.00261577255379 USD +laokip 0.000115070912775 USD +lebanonpound 0.000660752285911 USD +srilankarupee 0.00568107434152 USD +liberiadollar 0.00529897657021 USD +lesotholoti 0.0674580497688 USD +libyadinar 0.715361836979 USD +moroccodirham 0.10286107151 USD +moldovaleu 0.0549249984388 USD +madagascarariary 0.000273001194867 USD +macedoniadenar 0.0181645799782 USD +myanmarkyat 0.000652501428646 USD +mongoliatugrik 0.000378720972518 USD +macaupataca 0.123876565016 USD mauritaniaoldouguiya 1|10 MRU -mauritaniaouguiya 0.027100343076 USD -mauritiusrupee 0.0290031062457 USD -maldiverufiyaa 0.0638812797532 USD -malawikwacha 0.00135581500492 USD -mexicopeso 0.0522784832613 USD -malaysiaringgit 0.240477410803 USD -mozambiquemetical 0.0161431876812 USD -namibiadollar 0.0694130475253 USD -nigerianaira 0.00324130813823 USD -nicaraguacordobaoro 0.0309848776 USD -norwaykrone 0.12137314227 USD -nepalrupee 0.00848211009678 USD -newzealanddollar 0.658036827063 USD -omanrial 2.56602218026 USD -panamabalboa 0.987287572139 USD -perunuevosol 0.299883659541 USD -papuanewguineakina 0.297634239022 USD -philippinepeso 0.0186184533929 USD -pakistanrupee 0.00747970279064 USD -polandzloty 0.266378870427 USD -paraguayguarani 0.000166925716024 USD -qatarrial 0.269620488817 USD -romanianewlei 0.245719812831 USD -serbiadinar 0.00966004669137 USD -russiaruble 0.0152253547897 USD -rwandafranc 0.00111433206564 USD -saudiarabiariyal 0.266525017017 USD -solomonislandsdollar 0.123055237893 USD -seychellesrupee 0.0724980718598 USD -sudanpound 0.0209834844818 USD -swedenkrona 0.110934301103 USD -singaporedollar 0.725646064284 USD -sierraleoneleone 0.000115156511795 USD -somaliaschilling 0.00170686949815 USD -surinamedollar 0.132097550597 USD -southsudanpound 0.00660727108322 USD -saotome&principedobra 0.0464349352411 USD -elsalvadorcolon 0.112789553469 USD -syriapound 0.00191484269035 USD -swazilandlilangeni 0.069386452488 USD -thailandbaht 0.0306772736637 USD -tajikistansomoni 0.105451992223 USD -turkmenistanmanat 0.284201853993 USD -tunisiadinar 0.352327444409 USD -tongapa'anga 0.436663918513 USD -turkeylira 0.1773585205 USD -trinidadandtobagodollar 0.146512060849 USD -taiwandollar 0.032337269205 USD -tanzaniashilling 0.000431105555703 USD -ukrainehryvnia 0.0354836464493 USD -ugandaschilling 0.000261163266934 USD +mauritaniaouguiya 0.0270143903579 USD +mauritiusrupee 0.0282229704927 USD +maldiverufiyaa 0.0647825861084 USD +malawikwacha 0.0013512390254 USD +mexicopeso 0.0515379189303 USD +malaysiaringgit 0.238302191557 USD +mozambiquemetical 0.0161047327134 USD +namibiadollar 0.0674060990181 USD +nigerianaira 0.0032628410721 USD +nicaraguacordobaoro 0.0303517893009 USD +norwaykrone 0.113999227235 USD +nepalrupee 0.00894591926853 USD +newzealanddollar 0.651260761699 USD +omanrial 2.59826484493 USD +panamabalboa 1.00145462102 USD +perunuevosol 0.297608988204 USD +papuanewguineakina 0.29551750023 USD +philippinepeso 0.0191643579797 USD +pakistanrupee 0.00662852410795 USD +polandzloty 0.259643935488 USD +paraguayguarani 0.000158409745144 USD +qatarrial 0.273546677749 USD +romanianewlei 0.234502601246 USD +serbiadinar 0.009461386826 USD +russiaruble 0.0153344749757 USD +rwandafranc 0.00110213517585 USD +saudiarabiariyal 0.266645771679 USD +solomonislandsdollar 0.124889604655 USD +seychellesrupee 0.0732245830952 USD +sudanpound 0.0222089459193 USD +swedenkrona 0.104589432619 USD +singaporedollar 0.725207344 USD +sierraleoneleone 0.000110655098966 USD +somaliaschilling 0.00173125876669 USD +surinamedollar 0.133980986025 USD +southsudanpound 0.00633980986025 USD +saotome&principedobra 0.0455348329783 USD +elsalvadorcolon 0.114421528391 USD +syriapound 0.00194815315081 USD +swazilandlilangeni 0.0674320743935 USD +thailandbaht 0.0314820697102 USD +tajikistansomoni 0.106008233005 USD +turkmenistanmanat 0.286192631879 USD +tunisiadinar 0.334199179178 USD +tongapa'anga 0.439815055328 USD +turkeylira 0.169734054462 USD +trinidadandtobagodollar 0.147877811834 USD +taiwandollar 0.0316263165797 USD +tanzaniashilling 0.000435866798275 USD +ukrainehryvnia 0.037214106022 USD +ugandaschilling 0.000266507351031 USD US$ ! # Base unit, the primitive unit of currency -uruguaypeso 0.0301688571547 USD -uzbekistansum 0.000121015412383 USD -venezuelabolivarsoberano 0.0157204846195 USD -vietnamdong 4.27601493772e-05 USD -vanuatuvatu 0.0086045583894 USD -samoatala 0.376851679477 USD -eastcaribbeandollar 0.364245631765 USD -yemenrial 0.00394829924736 USD -southafricarand 0.0697326155464 USD -zambiakwacha 0.0842264833382 USD -bitcoin 6464.89 US$ # From services.packetizer.com/btc +uruguaypeso 0.0284695723084 USD +uzbekistansum 0.000117908173048 USD +venezuelabolivarsoberano 0.000172888964033 USD +vietnamdong 4.27328581423e-05 USD +vanuatuvatu 0.00856538001974 USD +samoatala 0.378045612759 USD +eastcaribbeandollar 0.369915320276 USD +yemenrial 0.00401111746065 USD +southafricarand 0.0679688184146 USD +zambiakwacha 0.075172736246 USD +bitcoin 8512.16 US$ # From services.packetizer.com/btc # Precious metals prices from Packetizer (services.packetizer.com/spotprices) -silverprice 14.64 US$/troyounce -goldprice 1226.32 US$/troyounce -platinumprice 832.50 US$/troyounce +silverprice 14.52 US$/troyounce +goldprice 1288.30 US$/troyounce +platinumprice 797.00 US$/troyounce diff -Nru units-2.18/debian/changelog units-2.19/debian/changelog --- units-2.18/debian/changelog 2019-01-14 20:04:58.000000000 +0000 +++ units-2.19/debian/changelog 2019-08-15 19:15:21.000000000 +0000 @@ -1,8 +1,22 @@ -units (2.18-1build1) disco; urgency=medium +units (2.19-1) unstable; urgency=medium - * No-change rebuild for readline soname change. + * Upload to unstable. + * Standards-Version 4.4.0, no change required. - -- Matthias Klose Mon, 14 Jan 2019 20:04:58 +0000 + -- Stephen Kitt Thu, 15 Aug 2019 21:15:21 +0200 + +units (2.19-1~exp1) experimental; urgency=medium + + * New upstream release. + - Continuation paragraphs are indented in the manpage. + Closes: #921160. + - The AUTHORS section of the manpage is now filled in. + Closes: #926559. + * Update debian/copyright. + * Standards-Version 4.3.0, no further change required. + * Switch to debhelper compatibility level 12. + + -- Stephen Kitt Sat, 01 Jun 2019 14:09:02 +0200 units (2.18-1) unstable; urgency=medium diff -Nru units-2.18/debian/compat units-2.19/debian/compat --- units-2.18/debian/compat 2018-05-16 22:29:59.000000000 +0000 +++ units-2.19/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru units-2.18/debian/control units-2.19/debian/control --- units-2.18/debian/control 2018-10-22 08:21:08.000000000 +0000 +++ units-2.19/debian/control 2019-08-15 19:14:24.000000000 +0000 @@ -3,11 +3,11 @@ Section: utils Priority: optional Build-Depends: bison, - debhelper (>= 11~), + debhelper-compat (= 12), libreadline-dev, python3, texinfo -Standards-Version: 4.2.1 +Standards-Version: 4.4.0 Vcs-Browser: https://salsa.debian.org/debian/units Vcs-Git: https://salsa.debian.org/debian/units.git Homepage: https://www.gnu.org/software/units/ diff -Nru units-2.18/debian/copyright units-2.19/debian/copyright --- units-2.18/debian/copyright 2017-10-25 20:54:10.000000000 +0000 +++ units-2.19/debian/copyright 2019-06-01 12:05:40.000000000 +0000 @@ -3,7 +3,7 @@ Source: https://www.gnu.org/software/units/ Files: * -Copyright: 1984-2017 Free Software Foundation, Inc. +Copyright: 1984-2019 Free Software Foundation, Inc. License: GPL-3+ Files: getopt.h @@ -11,13 +11,13 @@ License: GPL-2+ Files: units.info units.pdf units.texinfo units.txt -Copyright: 1996-2017 Free Software Foundation, Inc. +Copyright: 1996-2019 Free Software Foundation, Inc. License: GFDL-1.3+ Files: debian/* Copyright: 1997-1998 James Troup 1999-2012 John G. Hasler - 2013-2017 Stephen Kitt + 2013-2019 Stephen Kitt License: GPL-2+ License: GPL-2+ diff -Nru units-2.18/debian/patches/reproducible.patch units-2.19/debian/patches/reproducible.patch --- units-2.18/debian/patches/reproducible.patch 2015-04-11 22:10:52.000000000 +0000 +++ units-2.19/debian/patches/reproducible.patch 2019-06-01 11:51:07.000000000 +0000 @@ -6,12 +6,12 @@ --- a/texi2man +++ b/texi2man -@@ -21,7 +21,7 @@ +@@ -23,7 +23,7 @@ $args=($#ARGV < 0) ? "stdin" : "@ARGV"; printf(".\\\"Do not edit this file. It was created from %s\n", $args); --printf(".\\\"using texi2man version %s on %s", $version, `date`); -+printf(".\\\"using texi2man version", $version); +-printf(".\\\"using %s version %s on %s", $thisprog, $version, `date`); ++printf(".\\\"using %s version %s", $thisprog, $version); while(<>) { diff -Nru units-2.18/definitions.units units-2.19/definitions.units --- units-2.18/definitions.units 2018-10-16 23:09:25.000000000 +0000 +++ units-2.19/definitions.units 2019-05-30 01:18:07.000000000 +0000 @@ -2,9 +2,9 @@ # This file is the units database for use with GNU units, a units conversion # program by Adrian Mariano adrianm@gnu.org # -# October 2018 Version 2.44 +# May 2019 Version 3.04 # -# Copyright (C) 1996-2002, 2004-2018 +# Copyright (C) 1996-2002, 2004-2019 # Free Software Foundation, Inc # # This program is free software; you can redistribute it and/or modify @@ -26,15 +26,16 @@ # # Improvements and corrections are welcome. # -# Fundamental constants in this file are the 2014 CODATA recommended values. +# Fundamental constants in this file are the 2018 CODATA recommended values. # # Most units data was drawn from # 1. NIST Special Publication 811, Guide for the # Use of the International System of Units (SI). -# Barry N. Taylor. 1995 +# Barry N. Taylor. 2008 +# https://www.nist.gov/pml/special-publication-811 # 2. CRC Handbook of Chemistry and Physics 70th edition # 3. Oxford English Dictionary -# 4. Websters New Universal Unabridged Dictionary +# 4. Webster's New Universal Unabridged Dictionary # 5. Units of Measure by Stephen Dresner # 6. A Dictionary of English Weights and Measures by Ronald Zupko # 7. British Weights and Measures by Ronald Zupko @@ -67,8 +68,12 @@ # 23. CRC Handbook of Chemistry and Physics, 96th edition # 24. Dictionary of Scientific Units, 6th ed. H.G. Jerrard and D.B. # McNeill. 1992 -# -# Thanks to Jeff Conrad for assistance in ferreting out unit definitions. +# 25. NIST Special Publication 330, The International System of +# Units (SI). ed. Barry N. Taylor and Ambler Thompson. 2008 +# https://www.nist.gov/pml/special-publication-330 +# 26. BIPM Brochure, The International System of Units (SI). +# 9th ed., 2019 +# https://www.bipm.org/en/publications/si-brochure/ # ########################################################################### # @@ -147,42 +152,250 @@ # # SI units # - -kg ! # Mass of the international prototype -kilogram kg - -s ! # Duration of 9192631770 periods of the radiation -second s # corresponding to the transition between the two hyperfine - # levels of the ground state of the cesium-133 atom - -m ! # Length of the path traveled by light in a vacuum -meter m # during 1|299792458 seconds. Originally meant to be - # 1e-7 of the length along a meridian from the equator - # to a pole. - -A ! # The current which produces a force of 2e-7 N/m between two -ampere A # infinitely long wires that are 1 meter apart -amp ampere - -cd ! # Luminous intensity in a given direction of a source which -candela cd # emits monochromatic radiation at 540e12 Hz with radiant - # intensity 1|683 W/steradian. (This differs from radiant - # intensity (W/sr) in that it is adjusted for human - # perceptual dependence on wavelength. The frequency of - # 540e12 Hz (yellow) is where human perception is most - # efficient.) - -mol ! # The amount of substance of a system which contains as many -mole mol # elementary entities as there are atoms in 0.012 kg of - # carbon 12. The elementary entities must be specified and - # may be atoms, molecules, ions, electrons, or other - # particles or groups of particles. It is understood that - # unbound atoms of carbon 12, at rest and in the ground - # state, are referred to. - -K ! # 1|273.16 of the thermodynamic temperature of the triple -kelvin K # point of water - +# On 20 May 2019, the SI was revised to define the units by fixing the +# values of physical constants that depend on those units. +# +# https://www.nist.gov/si-redefinition/ +# +# The BIPM--the International Bureau of Weights and Measures--provides a +# succinct description of the new SI in its Concise Summary: +# +# https://www.bipm.org/utils/common/pdf/si-brochure/SI-Brochure-9-concise-EN.pdf +# +# The SI is the system of units in which: +# +# * the unperturbed ground state hyperfine transition frequency of the +# caesium 133 atom is delta nu_Cs = 9 192 631 770 Hz, +# * the speed of light in vacuum, c, is 299 792 458 m/s, +# * the Planck constant, h, is 6.626 070 15 * 10^-34 J s, +# * the elementary charge, e, is 1.602 176 634 * 10^-19 C, +# * the Boltzmann constant, k, is 1.380 649 * 10^-23 J/K, +# * the Avogadro constant, N_A, is 6.022 140 76 * 10^23 mol^-1, +# * the luminous efficacy of monochromatic radiation of frequency +# 540 * 10^12 Hz, K_cd, is 683 lm/W, +# +# where the hertz, joule, coulomb, lumen, and watt, with unit symbols Hz, +# J, C, lm, and W, respectively, are related to the units second, metre, +# kilogram, ampere, kelvin, mole, and candela, with unit symbols s, m, kg, +# A, K, mol, and cd, respectively, according to Hz = s^–1, J = kg m^2 s^–2, +# C = A s, lm = cd m^2 m^–2 = cd sr, and W = kg m^2 s^–3. +# +# These definitions specify the exact numerical value of each constant when +# its value is expressed in the corresponding SI unit. By fixing the exact +# numerical value the unit becomes defined, since the product of the +# numerical value and the unit has to equal the value of the constant, +# which is invariant. +# +# The defining constants have been chosen such that, when taken together, +# their units cover all of the units of the SI. In general, there is no +# one-to-one correspondence between the defining constants and the SI base +# units. Any SI unit is a product of powers of these seven constants and a +# dimensionless factor. +# +# Until 2018, the SI was defined in terms of base units and derived units. +# These categories are no longer essential in the SI, but they are maintained +# in view of their convenience and widespread use. They are arguably more +# intuitive than the new definitions. (They are also essential to the +# operation of GNU units.) The definitions of the base units, which follow +# from the definition of the SI in terms of the seven defining constants, are +# given below. +# + +s ! # The second, symbol s, is the SI unit of time. It is defined +second s # by taking the fixed numerical value of the unperturbed + # ground-state hyperfine transition frequency of the + # cesium-133 atom to be 9 192 1631 770 when expressed in the + # unit Hz, which is equal to 1/s. + # + # This definition is a restatement of the previous one, the + # duration of 9192631770 periods of the radiation corresponding + # to the cesium-133 transition. + +c 299792458 m/s # speed of light in vacuum (exact) + +m ! # The metre, symbol m, is the SI unit of length. It is +meter m # defined by taking the fixed numerical value of the speed +metre m # of light in vacuum, c, to be 299 792 458 when expressed in + # units of m/s. + # + # This definition is a rewording of the previous one and is + # equivalent to defining the meter as the distance light + # travels in 1|299792458 seconds. The meter was originally + # intended to be 1e-7 of the length along a meridian from the + # equator to a pole. + +h 6.62607015e-34 J s # Planck constant (exact) + +kg ! # The kilogram, symbol kg, is the SI unit of mass. It is +kilogram kg # defined by taking the fixed numerical value of the Planck + # constant, h, to be 6.626 070 15 * 10^-34 when expressed in + # the unit J s which is equal to kg m^2 / s. + # + # One advantage of fixing h to define the kilogram is that this + # affects constants used to define the ampere. If the kg were + # defined by directly fixing the mass of something, then h + # would be subject to error. + # + # The previous definition of the kilogram was the mass of the + # international prototype kilogram. The kilogram was the last + # unit whose definition relied on reference to an artifact. + # + # It is not obvious what this new definition means, or + # intuitively how fixing Planck's constant defines the + # kilogram. To define the kilogram we need to give the mass + # of some reference in kilograms. Previously the prototype in + # France served as this reference, and it weighed exactly 1 + # kg. But the reference can have any weight as long as you + # know the weight of the reference. The new definition uses + # the "mass" of a photon, or more accurately, the mass + # equivalent of the energy of a photon. The energy of a + # photon depends on its frequency. If you pick a frequency, + # f, then the energy of the photon is hf, and hence the mass + # equivalent is hf/c^2. If we reduce this expression using + # the constant defined values for h and c the result is a + # value in kilograms for the mass-equivalent of a photon of + # frequency f, which can therefore define the size of the + # kilogram. + # + # For more on the relationship between mass an Planck's + # constant: + # + # https://www.nist.gov/si-redefinition/kilogram-mass-and-plancks-constant + # This definition may still seem rather abstract: you can't + # place a "kilogram of radiation" on one side of a balance. + # Metrologists realize the kilogram using a Kibble Balance, a + # device which relates mechanical energy to electrical energy + # and can measure mass with extreme accuracy if h is known. + # + # For more on the Kibble Balance see + # + # https://www.nist.gov/si-redefinition/kilogram-kibble-balance + # https://en.wikipedia.org/wiki/Kibble_balance + +boltzmann 1.380649e-23 J/K # Boltzmann constant (exact) +k boltzmann + +K ! # The kelvin, symbol K, is the SI unit of thermodynamic +kelvin K # temperature. It is defined by taking the fixed numerical + # value of the Boltzmann constant, k, to be 1.380 649 * 10^-23 + # when expressed in the unit J/K, which is equal to + # kg m^2/s^2 K. + # + # The boltzmann constant establishes the relationship between + # energy and temperature. The average thermal energy carried + # by each degree of freedom is kT/2. A monatomic ideal gas + # has three degrees of freedom corresponding to the three + # spatial directions, which means its thermal energy is + # (3/2) k T. + # + # The previous definition of the kelvin was based on the + # triple point of water. The change in the definition of the + # kelvin will not have much effect on measurement practice. + # Practical temperature calibration makes use of two scales, + # the International Temperature Scale of 1990 (ITS-90), which + # covers the range of 0.65 K to 1357.77K and the Provisional + # Low Temperature Scale of 2000 (PLTS-2000), which covers the + # range of 0.9 mK to 1 K. + # https://www.bipm.org/en/committees/cc/cct/publications-cc.html + # + # The ITS-90 contains 17 reference points including things + # like the triple point of hydrogen (13.8033 K) or the + # freezing point of gold (1337.33 K), and of course the triple + # point of water. The PLTS-2000 specifies four reference + # points, all based on properties of helium-3. + # + # The redefinition of the kelvin will not affect the values of + # these reference points, which have been determined by + # primary thermometry, using thermometers that rely only on + # relationships that allow temperature to be calculated + # directly without using any unknown quantities. Examples + # include acoustic thermometers, which measure the speed of + # sound in a gas, or electronic thermometers, which measure + # tiny voltage fluctuations in resistors. Both variables + # depend directly on temperature. + +e 1.602176634e-19 C # electron charge (exact) + +A ! # The ampere, symbol A, is the SI unit of electric current. +ampere A # It is defined by taking the fixed numerical value of the +amp ampere # elementary charge, e, to be 1.602 176 634 * 10^-19 when + # expressed in the unit C, which is equal to A*s. + # + # The previous definition was the current which produces a + # force of 2e-7 N/m between two infinitely long wires a meter + # apart. This definition was difficult to realize accurately. + # + # The ampere is actually realized by establishing the volt and + # the ohm, since A = V / ohm. These measurements can be done + # using the Josephson effect and the quantum Hall effect, + # which accurately measure voltage and resistance, respectively, + # with reference to two fixed constants, the Josephson + # constant, K_J=2e/h and the von Klitzing constant, R_K=h/e^2. + # Under the previous SI system, these constants had official + # fixed values, defined in 1990. This created a situation + # where the standard values for the volt and ohm were in some + # sense outside of SI because they depended primarily on + # constants different from the ones used to define SI. After + # the revision, since e and h have exact definitions, the + # Josephson and von Klitzing constants will also have exact + # definitions that derive from SI instead of the conventional + # 1990 values. + # + # In fact we know that there is a small offset between the + # conventional values of the electrical units based on the + # conventional 1990 values and the SI values. The new + # definition, which brings the practical electrical units back + # into SI, will lead to a one time change of +0.1ppm for + # voltage values and +0.02ppm for resistance values. + # + # The previous definition resulted in fixed exact values for + # the vacuum permeability (mu0), the impedance of free space + # (Z0), the vacuum permittivity (epsilon0), and the Coulomb + # constant. With the new definition, these four values are + # subject to experimental error. + +avogadro 6.02214076e23 / mol # Size of a mole (exact) +N_A avogadro + +mol ! # The mole, symbol mol, is the SI unit of amount of +mole mol # substance. One mole contains exactly 6.022 140 76 * 10^23 + # elementary entities. This number is the fixed numerical + # value of the Avogadro constant, N_A, when expressed in the + # unit 1/mol and is called the Avogadro number. The amount of + # substance, symbol n, of a system is a measure of the number + # of specified elementary entities. An elementary entity may + # be an atom, a molecule, an ion, an electron, any other + # particle or specified group of particles. + # + # The atomic mass unit (u) is defined as 1/12 the mass of + # carbon-12. Previously the mole was defined so that a mole + # of carbon-12 weighed exactly 12g, or N_A u = 1 g/mol + # exactly. This relationship is now an experimental, + # approximate relationship. + # + # To determine the size of the mole, researchers used spheres + # of very pure silicon-28 that weighed a kilogram. They + # measured the molar mass of Si-28 using mass spectrometry and + # used X-ray diffraction interferometry to determine the + # spacing of the silicon atoms in the sphere. Using the + # sphere's volume it was then possible to determine the number + # of silicon atoms in the sphere, and hence determine the + # Avogadro constant. The results of this experiment were used to + # define N_A, which is henceforth a fixed, unchanging quantity. + +cd ! # The candela, symbol cd, is the SI unit of luminous intensity +candela cd # in a given direction. It is defined by taking the fixed + # numerical value of the luminous efficacy of monochromatic + # radiation of the frequency 540e12 Hz to be 683 when + # expressed in the unit lumen/watt, which is equal to + # cd sr/W, or cd sr s^3/kg m^2 + # + # This definition is a rewording of the previous definition. + # Luminous intensity differs from radiant intensity (W/sr) in + # that it is adjusted for human perceptual dependence on + # wavelength. The frequency of 540e12 Hz (yellow; + # wavelength approximately 555 nm in vacuum) is where human + # perception is most efficient. # # The radian and steradian are defined as dimensionless primitive units. # The radian is equal to m/m and the steradian to m^2/m^2 so these units are @@ -528,13 +741,13 @@ INDUCTANCE henry E_FIELD ELECTRIC_POTENTIAL / LENGTH B_FIELD tesla -# The D and H fields are related to the E and B fields by factors of epsilon -# and mu respectively, so their units can be found by multiplying/dividing by -# the epsilon0 and mu0, but then it is necessary to remove the constant factors -# to get the correct scaling. Defining the units this way allows conversion to -# CGS units to work correctly. -D_FIELD E_FIELD epsilon0 (c/(m/s))^2 4 pi 1e-7 -H_FIELD B_FIELD / mu0 * 4 pi 1e-7 +# The D and H fields are related to the E and B fields by factors of +# epsilon and mu respectively, so their units can be found by +# multiplying/dividing by the epsilon0 and mu0. The more complex +# definitions below make it possible to use D_FIELD and E_FIELD to +# convert between SI and CGS units for these dimensions. +D_FIELD E_FIELD epsilon0 mu0_SI c^2 F / m +H_FIELD B_FIELD / (mu0/mu0_SI) (H/m) ELECTRIC_DIPOLE_MOMENT C m MAGNETIC_DIPOLE_MOMENT J / T POLARIZATION ELECTRIC_DIPOLE_MOMENT / VOLUME @@ -589,7 +802,16 @@ # reference to common x-ray lines, either # the K-alpha 1 line of copper or the # same line of molybdenum. -angstromstar 1.00001495 angstrom # Defined by JA Bearden in 1965 +angstromstar 1.00001495 angstrom # Defined by JA Bearden in 1965 to replace + # the X unit. The wavelength of the + # tungsten K alpha1 line was defined as + # exactly 0.20901 angstrom star, with the + # valule chosen to try to make the new + # unit close to the angstrom. +silicon_d220 1.920155716e-10 m # Silicon lattice spacing +siliconlattice sqrt(8) silicon_d220# Silicon lattice parameter, (a), the side + # length of the unit cell for the diamond + # centered cubic structure of silicon. fermi 1e-15 m # Convenient for describing nuclear sizes # Nuclear radius is from 1 to 10 fermis barn 1e-28 m^2 # Used to measure cross section for @@ -898,58 +1120,59 @@ # Basic constants pi 3.14159265358979323846 -c 2.99792458e8 m/s # speed of light in vacuum (exact) light c -mu0 4 pi 1e-7 H/m # permeability of vacuum (exact) -epsilon0 1/mu0 c^2 # permittivity of vacuum (exact) -energy c^2 # convert mass to energy -e 1.6021766208e-19 C # electron charge -h 4.135667662e-15 eV s # Planck constant +mu0_SI 2 alpha h / e^2 c # Vacuum magnetic permeability +mu0 mu0_SI # Gets overridden in CGS modes +epsilon0 1/mu0 c^2 # Vacuum electric permittivity +Z0 mu0 c # Free space impedance +energy c^2 # Convert mass to energy hbar h / 2 pi spin hbar -G 6.67408e-11 N m^2 / kg^2 # Newtonian gravitational constant - # This is the NIST 2006 value. - # The relative uncertainty on this - # is 1e-4. -coulombconst 1/4 pi epsilon0 # listed as "k" sometimes +G 6.67430e-11 N m^2 / kg^2 # Newtonian gravitational constant +coulombconst 1/4 pi epsilon0 # Listed as k or k_C sometimes +k_C coulombconst # Physico-chemical constants -atomicmassunit 1.660539040e-27 kg # atomic mass unit (defined to be -u atomicmassunit # 1|12 of the mass of carbon 12) -amu atomicmassunit +atomicmassunit 1.66053906660e-27 kg # Unified atomic mass unit, defined as +u atomicmassunit # 1|12 of the mass of carbon 12. +amu atomicmassunit # The relationship N_A u = 1 g/mol +dalton u # is approximately, but not exactly +Da dalton # true (with the 2019 SI). + # Previously the mole was defined to + # make this relationship exact. amu_chem 1.66026e-27 kg # 1|16 of the weighted average mass of # the 3 naturally occuring neutral # isotopes of oxygen amu_phys 1.65981e-27 kg # 1|16 of the mass of a neutral # oxygen 16 atom -dalton u # Maybe this should be amu_chem? -avogadro grams/amu mol # size of a mole -N_A avogadro -gasconstant k N_A # molar gas constant +gasconstant k N_A # Molar gas constant (exact) R gasconstant -boltzmann 1.38064852e-23 J/K # Boltzmann constant -k boltzmann kboltzmann boltzmann molarvolume mol R stdtemp / atm # Volume occupied by one mole of an # ideal gas at STP. loschmidt avogadro mol / molarvolume # Molecules per cubic meter of an # ideal gas at STP. Loschmidt did # work similar to Avogadro. +molarvolume_si N_A siliconlattice^3 / 8 # Volume of a mole of crystalline + # silicon. The unit cell contains 8 + # silicon atoms and has a side + # length of siliconlattice. stefanboltzmann pi^2 k^4 / 60 hbar^3 c^2 # The power per area radiated by a sigma stefanboltzmann # blackbody at temperature T is - # given by sigma T^4. -wiendisplacement 2.8977729e-3 m K # Wien's Displacement Law gives the - # frequency at which the the Planck - # spectrum has maximum intensity. - # The relation is lambda T = b where - # lambda is wavelength, T is - # temperature and b is the Wien + # given by sigma T^4. (exact) +wiendisplacement (h c/k)/4.9651142317442763 # Wien's Displacement Law gives + # the frequency at which the the + # Planck spectrum has maximum + # intensity. The relation is lambda + # T = b where lambda is wavelength, + # T is temperature and b is the Wien # displacement. This relation is # used to determine the temperature - # of stars. + # of stars. The constant is the + # solution to x=5(1-exp(-x)). (exact) K_J90 483597.9 GHz/V # Direct measurement of the volt is difficult. Until -K_J 483597.8525 GHz/V # recently, laboratories kept Weston cadmium cells as +K_J 2e/h # recently, laboratories kept Weston cadmium cells as # a reference, but they could drift. In 1987 the # CGPM officially recommended the use of the # Josephson effect as a laboratory representation of @@ -959,12 +1182,12 @@ # with a frequency that depends on the potential # applied across the superconductors. This frequency # can be very accurately measured. The Josephson - # constant K_J, which is equal to 2e/h, relates the - # measured frequency to the potential. Two values - # given, the conventional (exact) value from 1990 and - # the current CODATA measured value. + # constant K_J relates the measured frequency to the + # potential. Two values given, the conventional + # (exact) value from 1990, which was used until the + # 2019 SI revision, and the current exact value. R_K90 25812.807 ohm # Measurement of the ohm also presents difficulties. -R_K 25812.8074555 ohm # The old approach involved maintaining resistances +R_K h/e^2 # The old approach involved maintaining resistances # that were subject to drift. The new standard is # based on the Hall effect. When a current carrying # ribbon is placed in a magnetic field, a potential @@ -975,9 +1198,25 @@ # in discrete jumps when the magnetic field is very # large and the temperature very low. This enables # accurate realization of the resistance h/e^2 in the - # lab. Two values given, the conventional (exact) - # value from 1990 and the current CODATA measured - # value. + # lab. The 1990 value was an exact conventional + # value used until the SI revision in 2019. This value + # did not agree with measurements. The new value + # is exact. + +# The 2019 update to SI gives exact definitions for R_K and K_J. Previously +# the electromagnetic units were realized using the 1990 conventional values +# for these constants, and as a result, the standard definitions were in some +# sense outside of SI. The revision corrects this problem. The definitions +# below give the 1990 conventional values for the electromagnetic units in +# terms of 2019 SI. + +ampere90 (K_J90 R_K90 / K_J R_K) A +coulomb90 (K_J90 R_K90 / K_J R_K) C +farad90 (R_K90/R_K) F +henry90 (R_K/R_K90) H +ohm90 (R_K/R_K90) ohm +volt90 (K_J90/K_J) V +watt90 (K_J90^2 R_K90 / K_J^2 R_K) W # Various conventional values @@ -1017,7 +1256,7 @@ # Atomic constants -Rinfinity 10973731.568539 /m # The wavelengths of a spectral series +Rinfinity 10973731.568160 /m # The wavelengths of a spectral series R_H 10967760 /m # can be expressed as # 1/lambda = R (1/m^2 - 1/n^2). # where R is a number that various @@ -1027,56 +1266,54 @@ # approaches Rinfinity, which can be # computed from # m_e c alpha^2 / 2 h - # with a loss of 4 digits + # with a loss of 2 digits # of precision. -alpha 7.2973525664e-3 # The fine structure constant was +alpha 7.2973525693e-3 # The fine structure constant was # introduced to explain fine # structure visible in spectral - # lines. It can be computed from - # mu0 c e^2 / 2 h - # with a loss of 3 digits precision - # and loss of precision in derived - # values which use alpha. + # lines. bohrradius alpha / 4 pi Rinfinity prout 185.5 keV # nuclear binding energy equal to 1|12 # binding energy of the deuteron +conductancequantum 2 e^2 / h + # Planck constants -planckmass 2.17651e-8 kg # sqrt(hbar c / G) +planckmass sqrt(hbar c / G) m_P planckmass plancktime hbar / planckmass c^2 t_P plancktime plancklength plancktime c l_P plancklength +plancktemperature hbar / k plancktime +T_P plancktemperature # Particle radius electronradius coulombconst e^2 / electronmass c^2 # Classical -deuteronchargeradius 2.1413e-15 m +deuteronchargeradius 2.12799e-15 m protonchargeradius 0.8751e-15 m # Masses of elementary particles -electronmass 5.48579909070e-4 u +electronmass 5.48579909065e-4 u m_e electronmass -protonmass 1.007276466879 u -m_p protonmass -neutronmass 1.00866491588 u -m_n neutronmass -muonmass 0.1134289257 u +muonmass 0.1134289259 u m_mu muonmass -deuteronmass 2.013553212745 u -m_d deuteronmass -alphaparticlemass 4.001506179127 u -m_alpha alphaparticlemass -taumass 1.90749 u +taumass 1.90754 u m_tau taumass -tritonmass 3.01550071632 u -m_t tritonmass -helionmass 3.01493224673 u -m_h helionmass - - +protonmass 1.007276466621 u +m_p protonmass +neutronmass 1.00866491595 u +m_n neutronmass +deuteronmass 2.013553212745 u # Nucleus of deuterium, one +m_d deuteronmass # proton and one neutron +alphaparticlemass 4.001506179127 u # Nucleus of He, two protons +m_alpha alphaparticlemass # and two neutrons +tritonmass 3.01550071621 u # Nucleius of H3, one proton +m_t tritonmass # and two neutrons +helionmass 3.014932247175 u # Nucleus of He3, two protons +m_h helionmass # and one neutron # particle wavelengths: the compton wavelength of a particle is # defined as h / m c where m is the mass of the particle. @@ -1087,21 +1324,39 @@ lambda_C,p protonwavelength neutronwavelength h / m_n c lambda_C,n neutronwavelength +muonwavelength h / m_mu c +lambda_C,mu muonwavelength -# Magnetic moments - -bohrmagneton e hbar / 2 electronmass -mu_B bohrmagneton -nuclearmagneton e hbar / 2 protonmass -mu_N nuclearmagneton -mu_mu -4.49044826e-26 J/T # Muon magnetic moment -mu_p 1.4106067873e-26 J/T # Proton magnetic moment -mu_e -928.4764620e-26 J/T # Electron magnetic moment -mu_n -0.96623650e-26 J/T # Neutron magnetic moment -mu_d 0.4330735040e-26 J/T # Deuteron magnetic moment -mu_t 1.504609503e-26 J/T # Triton magnetic moment -mu_h -1.074617522e-26 J/T # Helion magnetic moment - +# The g-factor or dimensionless magnetic moment is a quantity that +# characterizes the magnetic moment of a particle. The electron g-factor is +# one of the most precisely measured values in physics, with a relative +# uncertainty of 1.7e-13. + +g_d 0.8574382338 # Deuteron g-factor +g_e -2.00231930436256 # Electron g-factor +g_h -4.255250615 # Helion g-factor +g_mu -2.0023318418 # Muon g-factor +g_n -3.82608545 # Neutron g-factor +g_p 5.5856946893 # Proton g-factor +g_t 5.957924931 # Triton g-factor + +# Magnetic moments (derived from the more accurate g-factors) +# +# The magnetic moment is g * mu_ref * spin where in most cases +# the reference is the nuclear magneton, and all of the particles +# except the deuteron have spin 1/2. + +bohrmagneton e hbar / 2 electronmass # Reference magnetic moment for +mu_B bohrmagneton # the electron +nuclearmagneton e hbar / 2 protonmass # Convenient reference magnetic +mu_N nuclearmagneton # moment for heavy particles +mu_e g_e mu_B / 2 # Electron spin magnet moment +mu_mu g_mu e hbar / 4 muonmass # Muon spin magnetic moment +mu_p g_p mu_N / 2 # Proton magnetic moment +mu_n g_n mu_N / 2 # Neutron magnetic moment +mu_t g_t mu_N / 2 # Triton magnetic moment +mu_d g_d mu_N # Deuteron magnetic moment, spin 1 +mu_h g_h mu_N / 2 # Helion magnetic moment # # Units derived from physical constants @@ -1131,7 +1386,7 @@ # heliocentric parallax of 1 # arcsec (derived from parallax # second). A distant object with - # paralax theta will be about + # parallax theta will be about # (arcsec/theta) parsecs from the # sun (using the approximation # that tan(theta) = theta). @@ -1201,11 +1456,11 @@ # dimension of current, define the ampere to measure current, and derive the # other electromagnetic units from the ampere. With the CGS units one approach # is to use the basic equations of electromagnetism to define units that -# eliminate constants from those equations. Coulombs law has the form +# eliminate constants from those equations. Coulomb's law has the form # # F = k_C q1 q2 / r^2 # -# where k_C is the coulomb constant equal to 1|4 pi epsilon0 in SI units. +# where k_C is the Coulomb constant equal to 1|4 pi epsilon0 in SI units. # Ampere's force law takes the form # # dF/dl = 2 k_A I1 I2 / r @@ -1842,7 +2097,7 @@ # is close to 19 eclipse years.) # The eclipse will occur about # 120 degrees west of the - # preceeding one because the + # preceding one because the # saros is not an even number of # days. After 3 saros, an # eclipse will occur at @@ -1912,7 +2167,7 @@ # 32.5 years. islamicmonth 1|12 islamicyear # They have 29 day and 30 day months. -# The Hewbrew year is also based on lunar months, but synchronized to the solar +# The Hebrew year is also based on lunar months, but synchronized to the solar # calendar. The months vary irregularly between 29 and 30 days in length, and # the years likewise vary. The regular year is 353, 354, or 355 days long. To # keep up with the solar calendar, a leap month of 30 days is inserted every @@ -1998,8 +2253,9 @@ au astronomicalunit # ephemeris for the above described # astronomical unit. (See the NASA # site listed above.) -solarmass 1.9891e30 kg -sunmass solarmass +GMsun 1.32712440018e20 m^3 / s^2 # heliocentric gravitational constant +solarmass GMsun/G # with uncertainty 8e9 is known more +sunmass solarmass # accurately than G. sundist 1.0000010178 au # mean earth-sun distance @@ -2265,26 +2521,39 @@ # 13.553962 - -# # The Hartree system of atomic units, derived from fundamental units -# of mass (of electron), action (planck's constant), charge, and -# the coulomb constant. +# of mass (of electron), action (Planck's constant), charge, and +# the Coulomb constant. +# The Hartree energy can be derived from m_e, e, hbar, and coulombconst by +# hartree = coulombconst^2 m_e e^4 / hbar^2 +# but due to correlations between the measurements for m_e and coulombconst +# this results in a significant loss of precision. So we use an alternate +# equivalent definition for the hartree and derive then use energy instead +# of the Coulomb constant to derive the other units. This method retains the +# precision. + +hartree 2 rydberg # Approximate electric potential energy of + # the hydrogen atom in its ground state, + # and approximately twice its ionization + # energy. # Fundamental units atomicmass electronmass atomiccharge e atomicaction hbar +atomicenergy hartree -# derived units (Warning: accuracy is lost from deriving them this way) +# Derived units -atomiclength bohrradius -atomictime hbar^3/coulombconst^2 atomicmass e^4 # Period of first - # bohr orbit -atomicvelocity atomiclength / atomictime -atomicenergy hbar / atomictime -hartree atomicenergy +atomicvelocity sqrt(atomicenergy / atomicmass) +atomictime atomicaction / atomicenergy +atomiclength atomicvelocity atomictime +atomicforce atomicenergy / atomiclength +atomicmomentum atomicenergy / atomicvelocity +atomiccurrent atomiccharge / atomictime +atomicpotential atomicenergy / atomiccharge # electrical potential +atomicEfield atomicpotential / atomiclength # # These thermal units treat entropy as charge, from [5] @@ -2904,7 +3173,6 @@ # alternate spellings -metre meter gramme gram litre liter dioptre diopter @@ -2977,7 +3245,7 @@ legaltbsp legaltablespoon # Scoop size. Ice cream scoops in the US are marked with numbers -# indicating the number of scoops requird to fill a US quart. +# indicating the number of scoops required to fill a US quart. scoop(n) units=[1;cup] domain=[4,100] range=[0.04,1] \ 32 usfloz / n ; 32 usfloz / scoop @@ -3133,7 +3401,7 @@ # # But I'm using equation (3) which is credited to Starzak and Peacock, # "Water activity coefficient in aqueous solutions of sucrose--A comprehensive -# data analyzis. Zuckerindustrie, 122, 380-387. (I couldn't find this +# data analysis. Zuckerindustrie, 122, 380-387. (I couldn't find this # document.) # # Note that the range of validity is uncertain, but answers are in agreement @@ -3158,8 +3426,8 @@ # sc(x) (x / 342.3) / (( x/342.3) + (100-x)/18.02); \ # 100 sc 342.3|18.02 / (sc (342.3|18.02-1)+1) # -# Here is a simplfied version of this equation where the temperature of boiling -# water has been fixed at 100 degrees Celcius and the argument is now the +# Here is a simplified version of this equation where the temperature of boiling +# water has been fixed at 100 degrees Celsius and the argument is now the # concentration (brix). # # sugar_bpe(x) ((1+ 0.48851085 * sc(x)^2 (1+ -1.0038 sc(x) + -0.24653 sc(x)^2)) \ @@ -3211,7 +3479,7 @@ # not possible to convert to a nested function, so you're stuck retyping the # absolute temperature in Kelvins to convert to celsius or Fahrenheit. To # prevent this we supply definitions that build in the temperature conversion -# and produce results in the Fahrenheit and Celcius scales. So using these +# and produce results in the Fahrenheit and Celsius scales. So using these # measures, to convert 46 degrees Baume to a Fahrenheit boiling point: # # You have: baume(45) @@ -3284,6 +3552,423 @@ apidegree(x) units=[1;g/cm^3] domain=[-131.5,) range=[0,) \ 141.5 g/cm^3 / (x+131.5) ; \ 141.5 (g/cm^3) / apidegree + (-131.5) +# +# Average densities of various woods (dried) +# Data from The Wood Database https://www.wood-database.com +# + +# North American Hardwoods + +wood_cherry 35 lb/ft^3 +wood_redoak 44 lb/ft^3 +wood_whiteoak 47 lb/ft^3 +wood_blackwalnut 38 lb/ft^3 +wood_walnut wood_blackwalnut +wood_birch 43 lb/ft^3 +wood_hardmaple 44 lb/ft^3 + +wood_bigleafmaple 34 lb/ft^3 +wood_boxeldermaple 30 lb/ft^3 +wood_redmaple 38 lb/ft^3 +wood_silvermaple 33 lb/ft^3 +wood_stripedmaple 32 lb/ft^3 +wood_softmaple (wood_bigleafmaple \ + + wood_boxeldermaple \ + + wood_redmaple \ + + wood_silvermaple \ + + wood_stripedmaple) / 5 +wood_poplar 29 lb/ft^3 +wood_beech 45 lb/ft^3 + +# North American Softwoods + +wood_jeffreypine 28 lb/ft^3 +wood_ocotepine 44 lb/ft^3 +wood_ponderosapine 28 lb/ft^3 + +wood_loblollypine 35 lb/ft^3 +wood_longleafpine 41 lb/ft^3 +wood_shortleafpine 35 lb/ft^3 +wood_slashpine 41 lb/ft^3 +wood_yellowpine (wood_loblollypine \ + + wood_longleafpine \ + + wood_shortleafpine \ + + wood_slashpine) / 4 +wood_redpine 34 lb/ft^3 + +wood_easternwhitepine 25 lb/ft^3 +wood_westernwhitepine 27 lb/ft^3 +wood_whitepine (wood_easternwhitepine + wood_westernwhitepine) / 2 + +wood_douglasfir 32 lb/ft^3 + +wood_blackspruce 28 lb/ft^3 +wood_engelmannspruce 24 lb/ft^3 +wood_redspruce 27 lb/ft^3 +wood_sitkaspruce 27 lb/ft^3 +wood_whitespruce 27 lb/ft^3 +wood_spruce (wood_blackspruce \ + + wood_engelmannspruce \ + + wood_redspruce \ + + wood_sitkaspruce \ + + wood_whitespruce) / 5 + +# Other woods + +wood_basswood 26 lb/ft^3 +wood_balsa 9 lb/ft^3 +wood_ebony_gaboon 60 lb/ft^3 +wood_ebony_macassar 70 lb/ft^3 +wood_mahogany 37 lb/ft^3 # True (Honduran) mahogany, + # Swietenia macrophylla +wood_teak 41 lb/ft^3 +wood_rosewood_brazilian 52 lb/ft^3 +wood_rosewood_honduran 64 lb/ft^3 +wood_rosewood_indian 52 lb/ft^3 +wood_cocobolo 69 lb/ft^3 +wood_bubinga 56 lb/ft^3 +wood_zebrawood 50 lb/ft^3 +wood_koa 38 lb/ft^3 +wood_snakewood 75.7 lb/ft^3 +wood_lignumvitae 78.5 lb/ft^3 +wood_blackwood 79.3 lb/ft^3 +wood_blackironwood 84.5 lb/ft^3 # Krugiodendron ferreum, listed + # in database as the heaviest wood + +# +# Modulus of elasticity of selected woods. +# Data from The Wood Database https://www.wood-database.com +# + +# North American Hardwoods + +wood_mod_beech 1.720e6 lbf/in^2 +wood_mod_birchyellow 2.010e6 lbf/in^2 +wood_mod_birch wood_mod_birchyellow +wood_mod_cherry 1.490e6 lbf/in^2 +wood_mod_hardmaple 1.830e6 lbf/in^2 + +wood_mod_bigleafmaple 1.450e6 lbf/in^2 +wood_mod_boxeldermaple 1.050e6 lbf/in^2 +wood_mod_redmaple 1.640e6 lbf/in^2 +wood_mod_silvermaple 1.140e6 lbf/in^2 +wood_mod_softmaple (wood_mod_bigleafmaple \ + + wood_mod_boxeldermaple \ + + wood_mod_redmaple \ + + wood_mod_silvermaple) / 4 + +wood_mod_redoak 1.761e6 lbf/in^2 +wood_mod_whiteoak 1.762e6 lbf/in^2 +wood_mod_poplar 1.580e6 lbf/in^2 +wood_mod_blackwalnut 1.680e6 lbf/in^2 +wood_mod_walnut wood_mod_blackwalnut + +# North American Softwoods + +wood_mod_jeffreypine 1.240e6 lbf/in^2 +wood_mod_ocotepine 2.209e6 lbf/in^2 +wood_mod_ponderosapine 1.290e6 lbf/in^2 + +wood_mod_loblollypine 1.790e6 lbf/in^2 +wood_mod_longleafpine 1.980e6 lbf/in^2 +wood_mod_shortleafpine 1.750e6 lbf/in^2 +wood_mod_slashpine 1.980e6 lbf/in^2 +wood_mod_yellowpine (wood_mod_loblollypine \ + + wood_mod_longleafpine \ + + wood_mod_shortleafpine \ + + wood_mod_slashpine) / 4 + +wood_mod_redpine 1.630e6 lbf/in^2 + +wood_mod_easternwhitepine 1.240e6 lbf/in^2 +wood_mod_westernwhitepine 1.460e6 lbf/in^2 +wood_mod_whitepine (wood_mod_easternwhitepine + \ + wood_mod_westernwhitepine) / 2 + +wood_mod_douglasfir 1.765e6 lbf/in^2 + +wood_mod_blackspruce 1.523e6 lbf/in^2 +wood_mod_englemannspruce 1.369e6 lbf/in^2 +wood_mod_redspruce 1.560e6 lbf/in^2 +wood_mod_sitkaspruce 1.600e6 lbf/in^2 +wood_mod_whitespruce 1.315e6 lbf/in^2 +wood_mod_spruce (wood_mod_blackspruce \ + + wood_mod_englemannspruce \ + + wood_mod_redspruce + wood_mod_sitkaspruce \ + + wood_mod_whitespruce) / 5 + +# Other woods + +wood_mod_balsa 0.538e6 lbf/in^2 +wood_mod_basswood 1.460e6 lbf/in^2 +wood_mod_blackwood 2.603e6 lbf/in^2 # African, Dalbergia melanoxylon +wood_mod_bubinga 2.670e6 lbf/in^2 +wood_mod_cocobolo 2.712e6 lbf/in^2 +wood_mod_ebony_gaboon 2.449e6 lbf/in^2 +wood_mod_ebony_macassar 2.515e6 lbf/in^2 +wood_mod_blackironwood 2.966e6 lbf/in^2 # Krugiodendron ferreum +wood_mod_koa 1.503e6 lbf/in^2 +wood_mod_lignumvitae 2.043e6 lbf/in^2 +wood_mod_mahogany 1.458e6 lbf/in^2 # True (Honduran) mahogany, + # Swietenia macrophylla +wood_mod_rosewood_brazilian 2.020e6 lbf/in^2 +wood_mod_rosewood_honduran 3.190e6 lbf/in^2 +wood_mod_rosewood_indian 1.668e6 lbf/in^2 +wood_mod_snakewood 3.364e6 lbf/in^2 +wood_mod_teak 1.781e6 lbf/in^2 +wood_mod_zebrawood 2.374e6 lbf/in^2 + +# +# Area of countries and other regions. This is the "total area" which +# includes land and water areas within international boundaries and +# coastlines. Data from January, 2019. +# +# https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area +# https://www.cia.gov/library/publications/the-world-factbook) + +area_russia 17098246 km^2 +area_antarctica 14000000 km^2 +area_canada 9984670 km^2 +area_china 9596961 km^2 +area_unitedstates 9525067 km^2 # includes only the 50 states +area_us area_unitedstates # and District of Columbia +area_brazil 8515767 km^2 +area_australia 7692024 km^2 +area_europeanunion 4475757 km^2 +area_eu area_europeanunion +area_india 3287263 km^2 +area_argentina 2780400 km^2 +area_kazakhstan 2724900 km^2 +area_algeria 2381741 km^2 +area_drcongo 2344858 km^2 +area_greenland 2166086 km^2 +area_saudiarabia 2149690 km^2 +area_mexico 1964375 km^2 +area_indonesia 1910931 km^2 +area_sudan 1861484 km^2 +area_libya 1759540 km^2 +area_iran 1648195 km^2 +area_mongolia 1564110 km^2 +area_peru 1285216 km^2 +area_chad 1284000 km^2 +area_niger 1267000 km^2 +area_angola 1246700 km^2 +area_mali 1240192 km^2 +area_southafrica 1221037 km^2 +area_colombia 1141748 km^2 +area_ethiopia 1104300 km^2 +area_bolivia 1098581 km^2 +area_mauritania 1030700 km^2 +area_egypt 1002450 km^2 +area_tanzania 945087 km^2 +area_nigeria 923768 km^2 +area_venezuela 916445 km^2 +area_pakistan 881912 km^2 +area_namibia 825615 km^2 +area_mozambique 801590 km^2 +area_turkey 783562 km^2 +area_chile 756102 km^2 +area_zambia 752612 km^2 +area_myanmar 676578 km^2 +area_afghanistan 652230 km^2 +area_southsudan 644329 km^2 +area_france 640679 km^2 +area_somalia 637657 km^2 +area_centralafrica 622984 km^2 +area_ukraine 603500 km^2 +area_crimea 27000 km^2 # occupied by Russia; included in + # (Encyclopedia Britannica) +area_madagascar 587041 km^2 +area_botswana 581730 km^2 +area_kenya 580367 km^2 +area_yemen 527968 km^2 +area_thailand 513120 km^2 +area_spain 505992 km^2 +area_turkmenistan 488100 km^2 +area_cameroon 475422 km^2 +area_papuanewguinea 462840 km^2 +area_sweden 450295 km^2 +area_uzbekistan 447400 km^2 +area_morocco 446550 km^2 +area_iraq 438317 km^2 +area_paraguay 406752 km^2 +area_zimbabwe 390757 km^2 +area_japan 377973 km^2 +area_germany 357114 km^2 +area_congorepublic 342000 km^2 +area_finland 338424 km^2 +area_vietnam 331212 km^2 +area_malaysia 330803 km^2 +area_norway 323802 km^2 +area_ivorycoast 322463 km^2 +area_poland 312696 km^2 +area_oman 309500 km^2 +area_italy 301339 km^2 +area_philippines 300000 km^2 +area_ecuador 276841 km^2 +area_burkinafaso 274222 km^2 +area_newzealand 270467 km^2 +area_gabon 267668 km^2 +area_westernsahara 266000 km^2 +area_guinea 245857 km^2 +area_uk 242495 km^2 +area_uganda 241550 km^2 +area_ghana 238533 km^2 +area_romania 238397 km^2 +area_laos 236800 km^2 +area_guyana 214969 km^2 +area_belarus 207600 km^2 +area_kyrgyzstan 199951 km^2 +area_senegal 196722 km^2 +area_syria 185180 km^2 +area_golanheights 1150 km^2 # occupied by Israel; included in + # Syria (Encyclopedia Britannica) +area_cambodia 181035 km^2 +area_uruguay 176215 km^2 +area_somaliland 176120 km^2 +area_suriname 163820 km^2 +area_tunisia 163610 km^2 +area_bangladesh 147570 km^2 +area_nepal 147181 km^2 +area_tajikistan 143100 km^2 +area_greece 131990 km^2 +area_nicaragua 130373 km^2 +area_northkorea 120540 km^2 +area_malawi 118484 km^2 +area_eritrea 117600 km^2 +area_benin 114763 km^2 +area_honduras 112492 km^2 +area_liberia 111369 km^2 +area_bulgaria 110879 km^2 +area_cuba 109884 km^2 +area_guatemala 108889 km^2 +area_iceland 103000 km^2 +area_southkorea 100210 km^2 +area_hungary 93028 km^2 +area_portugal 92090 km^2 +area_jordan 89342 km^2 +area_serbia 88361 km^2 +area_azerbaijan 86600 km^2 +area_austria 83871 km^2 +area_uae 83600 km^2 +area_czechrepublic 78865 km^2 +area_panama 75417 km^2 +area_sierraleone 71740 km^2 +area_ireland 70273 km^2 +area_georgia 69700 km^2 +area_srilanka 65610 km^2 +area_lithuania 65300 km^2 +area_latvia 64559 km^2 +area_togo 56785 km^2 +area_croatia 56594 km^2 +area_bosnia 51209 km^2 +area_costarica 51100 km^2 +area_slovakia 49037 km^2 +area_dominicanrepublic 48671 km^2 +area_estonia 45227 km^2 +area_denmark 43094 km^2 +area_netherlands 41850 km^2 +area_switzerland 41284 km^2 +area_bhutan 38394 km^2 +area_taiwan 36193 km^2 +area_guineabissau 36125 km^2 +area_moldova 33846 km^2 +area_gelgium 30528 km^2 +area_lesotho 30355 km^2 +area_armenia 29743 km^2 +area_solomonislands 28896 km^2 +area_albania 28748 km^2 +area_equitorialguinea 28051 km^2 +area_burundi 27834 km^2 +area_haiti 27750 km^2 +area_rwanda 26338 km^2 +area_northmacedonia 25713 km^2 +area_djibouti 23200 km^2 +area_belize 22966 km^2 +area_elsalvador 21041 km^2 +area_israel 20770 km^2 +area_slovenia 20273 km^2 +area_fiji 18272 km^2 +area_kuwait 17818 km^2 +area_eswatini 17364 km^2 +area_easttimor 14919 km^2 +area_bahamas 13943 km^2 +area_montenegro 13812 km^2 +area_vanatu 12189 km^2 +area_qatar 11586 km^2 +area_gambia 11295 km^2 +area_jamaica 10991 km^2 +area_kosovo 10887 km^2 +area_lebanon 10452 km^2 +area_cyprus 9251 km^2 +area_puertorico 9104 km^2 # United States territory; not included + # in United States area +area_westbank 5860 km^2 # (CIA World Factbook) +area_hongkong 2755 km^2 +area_luxembourg 2586 km^2 +area_singapore 716 km^2 +area_gazastrip 360 km^2 # (CIA World Factbook) +area_liechtenstein 160 km^2 +area_monaco 2.02 km^2 +area_vaticancity 0.44 km^2 + +# +# Area of the individual United States +# +# https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_area +# + +area_alaska 1723337 km^2 +area_texas 695662 km^2 +area_california 423972 km^2 +area_montana 380831 km^2 +area_newmexico 314917 km^2 +area_arizona 295234 km^2 +area_nevada 286380 km^2 +area_colorado 269601 km^2 +area_oregon 254799 km^2 +area_wyoming 253335 km^2 +area_michigan 250487 km^2 +area_minnesota 225163 km^2 +area_utah 219882 km^2 +area_idaho 216443 km^2 +area_kansas 213100 km^2 +area_nebraska 200330 km^2 +area_southdakota 199729 km^2 +area_washington 184661 km^2 +area_northdakota 183108 km^2 +area_oklahoma 181037 km^2 +area_missouri 180540 km^2 +area_florida 170312 km^2 +area_wisconsin 169635 km^2 +area_georgia_us 153910 km^2 +area_illinois 149995 km^2 +area_iowa 145746 km^2 +area_newyork 141297 km^2 +area_northcarolina 139391 km^2 +area_arkansas 137732 km^2 +area_alabama 135767 km^2 +area_louisiana 135659 km^2 +area_mississippi 125438 km^2 +area_pennsylvania 119280 km^2 +area_ohio 116098 km^2 +area_virginia 110787 km^2 +area_tennessee 109153 km^2 +area_kentucky 104656 km^2 +area_indiana 94326 km^2 +area_maine 91633 km^2 +area_southcarolina 82933 km^2 +area_westvirginia 62756 km^2 +area_maryland 32131 km^2 +area_hawaii 28313 km^2 +area_massachusetts 27336 km^2 +area_vermont 24906 km^2 +area_newhampshire 24214 km^2 +area_newjersey 22591 km^2 +area_connecticut 14357 km^2 +area_delaware 6446 km^2 +area_rhodeisland 4001 km^2 +area_districtofcolumbia 177 km^2 # # Units derived from imperial system @@ -3732,6 +4417,8 @@ littleboy hiroshima ivyking 500 kiloton tnt # most powerful fission bomb castlebravo 15 megaton tnt # most powerful US test +tsarbomba 50 megaton tnt # most powerful test ever: USSR, + # 30 October 1961 b53bomb 9 megaton tnt # http://rarehistoricalphotos.com/gadget-first-atomic-bomb/ trinity 18 kiloton tnt # July 16, 1945 @@ -5531,7 +6218,7 @@ plf lb / foot # pounds per linear foot # -# Compatibility units with unix version +# Compatibility units with Unix version # pa Pa @@ -5981,6 +6668,45 @@ doppelzentner 2 zentner pfund 500 g +# The klafter, which was used in central Europe, was derived from the span of +# outstretched arms. +# +# https://en.wikipedia.org/wiki/Obsolete_Austrian_units_of_measurement +# https://www.llv.li/files/abi/klafter-m2-en.pdf + +austriaklafter 1.89648384 m # Exact definition, 23 July 1871 +austriafoot 1|6 austriaklafter +prussiaklafter 1.88 m +prussiafoot 1|6 prussiaklafter +bavariaklafter 1.751155 m +bavariafoot 1|6 bavariaklafter +hesseklafter 2.5 m +hessefoot 1|6 hesseklafter +switzerlandklafter metricklafter +switzerlandfoot 1|6 switzerlandklafter +swissklafter switzerlandklafter +swissfoot 1|6 swissklafter +metricklafter 1.8 m + +austriayoke 8 austriaklafter * 200 austriaklafter + +liechtensteinsquareklafter 3.596652 m^2 # Used until 2017 to measure land area +liechtensteinklafter sqrt(liechtensteinsquareklafter) + +# The klafter was also used to measure volume of wood, generally being a stack +# of wood one klafter wide, one klafter long, with logs 3 feet (half a klafter) +# in length + +prussiawoodklafter 0.5 prussiaklafter^3 +austriawoodklafter 0.5 austriaklafter^3 +festmeter m^3 # modern measure of wood, solid cube +raummeter 0.7 festmeter # Air space between the logs, stacked +schuettraummeter 0.65 raummeter # A cubic meter volume of split and cut +schüttraummeter schuettraummeter# firewood in a loose, unordered + # pile, not stacked. This is called + # "tipped". + + # # Swedish (Sweden) pre-metric units of 1739. # The metric system was adopted in 1878. @@ -6298,7 +7024,7 @@ # liters, but then says the amphora is a # cubic Roman foot. This gives a value for the # sextarius of 0.540 liters. And the - # encyclopedia Brittanica lists 0.53 liters for + # encyclopedia Britannica lists 0.53 liters for # this unit. Both [7] and [11], which were # written by scholars of weights and measures, # give the value of 35.4 cubic inches. @@ -6656,7 +7382,7 @@ ₩ ₩ # -# Square unicode symbols starting at U+3371 +# Square Unicode symbols starting at U+3371 # ㍱ hPa @@ -6783,7 +7509,7 @@ ############################################################################ # -# The following units were in the unix units database but do not appear in +# The following units were in the Unix units database but do not appear in # this file: # # wey used for cheese, salt and other goods. Measured mass or diff -Nru units-2.18/Makefile.in units-2.19/Makefile.in --- units-2.18/Makefile.in 2018-09-14 19:37:11.000000000 +0000 +++ units-2.19/Makefile.in 2019-05-29 10:01:05.000000000 +0000 @@ -97,10 +97,10 @@ units.@OBJEXT@: units.c units.h -parse.tab.c: parse.y +parse.tab.c: parse.y bison parse.y -parse.tab.@OBJEXT@: parse.tab.c +parse.tab.@OBJEXT@: parse.tab.c units.h units@EXEEXT@: $(OBJECTS) @MKS_RES@ $(CC) $(CFLAGS) $(LDFLAGS) -o units@EXEEXT@ $(OBJECTS) @MKS_RES@ $(LIBS) @@ -298,7 +298,7 @@ www: doc -rm -r wwwold wwwnew mkdir wwwnew - ./gendocs.sh -o wwwnew/units/manual units "GNU Units Manual" + ./mygendocs.sh --email adrianm@gnu.org -o wwwnew/units/manual units "GNU Units Manual" mkdir wwwold cd wwwold;CVS_RSH=ssh cvs -z3 -d:ext:adrianm@cvs.savannah.gnu.org:/webcvs/units co units cd wwwold/units/manual;ls > /tmp/wwwunits.listold @@ -315,9 +315,9 @@ @if [ -s /tmp/wwwunits.rm ]; then cd wwwold/units/manual; cvs remove `cat /tmp/wwwunits.rm`; \ cvs commit `cat /tmp/wwwunits.rm`; fi @if [ -s /tmp/wwwunits.html.add ]; then cd wwwold/units/manual/html_node; \ - cvs add `cat /tmp/wwwunits.add`; cvs commit `cat /tmp/wwwunits.add`; fi + cvs add `cat /tmp/wwwunits.add`; cvs add `cat /tmp/wwwunits.add`; fi @if [ -s /tmp/wwwunits.html.rm ]; then cd wwwold/units/manual/html_node; \ - cvs remove `cat /tmp/wwwunits.htmlrm`; cvs commit `cat /tmp/wwwunits.rm`; fi + cvs remove `cat /tmp/wwwunits.htmlrm`; cvs remove `cat /tmp/wwwunits.rm`; fi cd wwwold/units; cvs commit -rm /tmp/wwwunits.hlistnew /tmp/wwwunits.hlistold /tmp/wwwunits.listnew /tmp/wwwunits.listold -rm /tmp/wwwunits.html.rm /tmp/wwwunits.html.add /tmp/wwwunits.add /tmp/wwwunits.rm diff -Nru units-2.18/NEWS units-2.19/NEWS --- units-2.18/NEWS 2018-10-20 04:12:16.000000000 +0000 +++ units-2.19/NEWS 2019-05-29 00:14:16.000000000 +0000 @@ -1,6 +1,13 @@ GNU units NEWS - User visible changes. Copyright (C) 1996, 1997, 1999-2007, 2010-2018 Free Software Foundation, Inc. +Version 2.19 - 28 May 2019 +* Unit definitions updated to reflect new 2019 revisions to SI and the + 2018 NIST CODATA. +* Added definitions of country and USA state areas, and physical + properties of selected woods. +* Changes only to definitions.units in this release. + Version 2.18 - 20 October 2018 * The yahoo currency server has disappeared. The units_cur script now supports multiple currency sources: FloatRates the European Central diff -Nru units-2.18/parse.tab.c units-2.19/parse.tab.c --- units-2.18/parse.tab.c 2018-09-27 03:06:20.000000000 +0000 +++ units-2.19/parse.tab.c 2019-05-29 00:32:20.000000000 +0000 @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.3.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.3.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -68,8 +72,8 @@ #define yynerrs unitsnerrs -/* Copy the first part of user declarations. */ -#line 24 "parse.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 24 "parse.y" /* yacc.c:337 */ #include #include "units.h" @@ -197,13 +201,16 @@ -#line 201 "parse.tab.c" /* yacc.c:339 */ - +#line 205 "parse.tab.c" /* yacc.c:337 */ # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -267,7 +274,7 @@ union UNITSSTYPE { -#line 157 "parse.y" /* yacc.c:355 */ +#line 157 "parse.y" /* yacc.c:352 */ double number; int integer; @@ -275,7 +282,7 @@ struct function *realfunc; struct func *unitfunc; -#line 279 "parse.tab.c" /* yacc.c:355 */ +#line 286 "parse.tab.c" /* yacc.c:352 */ }; typedef union UNITSSTYPE UNITSSTYPE; @@ -289,9 +296,7 @@ -/* Copy the second part of user declarations. */ -#line 295 "parse.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -312,13 +317,13 @@ #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -330,7 +335,7 @@ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -366,15 +371,6 @@ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -382,7 +378,7 @@ # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -544,16 +540,16 @@ /* YYNSTATES -- Number of states. */ #define YYNSTATES 61 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 279 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -762,22 +758,22 @@ #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (comm, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (comm, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -817,38 +813,38 @@ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); YYUSE (comm); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, comm); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep, comm); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -882,7 +878,7 @@ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, struct commtype *comm) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -893,7 +889,7 @@ YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] , comm); YYFPRINTF (stderr, "\n"); } @@ -997,7 +993,10 @@ case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1015,7 +1014,7 @@ if (! yyres) return yystrlen (yystr); - return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -1093,10 +1092,10 @@ yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1108,6 +1107,7 @@ case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1119,9 +1119,10 @@ { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1171,37 +1172,36 @@ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 4: /* UNIT */ + case 4: /* UNIT */ #line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1178 "parse.tab.c" /* yacc.c:1257 */ +#line 1179 "parse.tab.c" /* yacc.c:1257 */ break; case 29: /* unitexpr */ #line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1184 "parse.tab.c" /* yacc.c:1257 */ +#line 1185 "parse.tab.c" /* yacc.c:1257 */ break; case 30: /* expr */ #line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1190 "parse.tab.c" /* yacc.c:1257 */ +#line 1191 "parse.tab.c" /* yacc.c:1257 */ break; case 32: /* pexpr */ #line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1196 "parse.tab.c" /* yacc.c:1257 */ +#line 1197 "parse.tab.c" /* yacc.c:1257 */ break; case 33: /* list */ #line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1202 "parse.tab.c" /* yacc.c:1257 */ +#line 1203 "parse.tab.c" /* yacc.c:1257 */ break; - default: break; } @@ -1287,23 +1287,31 @@ yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1319,14 +1327,10 @@ &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1342,22 +1346,22 @@ goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1366,11 +1370,11 @@ goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1443,7 +1447,7 @@ /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1464,229 +1468,229 @@ switch (yyn) { case 2: -#line 203 "parse.y" /* yacc.c:1646 */ +#line 203 "parse.y" /* yacc.c:1652 */ { comm->result = makenumunit(1,&err); CHECK(0); comm->errorcode = 0; YYACCEPT; } -#line 1471 "parse.tab.c" /* yacc.c:1646 */ +#line 1475 "parse.tab.c" /* yacc.c:1652 */ break; case 3: -#line 205 "parse.y" /* yacc.c:1646 */ +#line 205 "parse.y" /* yacc.c:1652 */ { comm->result = (yyvsp[-1].unit); comm->errorcode = 0; YYACCEPT; } -#line 1477 "parse.tab.c" /* yacc.c:1646 */ +#line 1481 "parse.tab.c" /* yacc.c:1652 */ break; case 4: -#line 206 "parse.y" /* yacc.c:1646 */ +#line 206 "parse.y" /* yacc.c:1652 */ { YYABORT; } -#line 1483 "parse.tab.c" /* yacc.c:1646 */ +#line 1487 "parse.tab.c" /* yacc.c:1652 */ break; case 5: -#line 209 "parse.y" /* yacc.c:1646 */ +#line 209 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit);} -#line 1489 "parse.tab.c" /* yacc.c:1646 */ +#line 1493 "parse.tab.c" /* yacc.c:1652 */ break; case 6: -#line 210 "parse.y" /* yacc.c:1646 */ +#line 210 "parse.y" /* yacc.c:1652 */ { invertunit((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1495 "parse.tab.c" /* yacc.c:1646 */ +#line 1499 "parse.tab.c" /* yacc.c:1652 */ break; case 7: -#line 213 "parse.y" /* yacc.c:1646 */ +#line 213 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); } -#line 1501 "parse.tab.c" /* yacc.c:1646 */ +#line 1505 "parse.tab.c" /* yacc.c:1652 */ break; case 8: -#line 214 "parse.y" /* yacc.c:1646 */ +#line 214 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); (yyval.unit)->factor *= -1; } -#line 1507 "parse.tab.c" /* yacc.c:1646 */ +#line 1511 "parse.tab.c" /* yacc.c:1652 */ break; case 9: -#line 215 "parse.y" /* yacc.c:1646 */ +#line 215 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); (yyval.unit)->factor *= -1; } -#line 1513 "parse.tab.c" /* yacc.c:1646 */ +#line 1517 "parse.tab.c" /* yacc.c:1652 */ break; case 10: -#line 216 "parse.y" /* yacc.c:1646 */ +#line 216 "parse.y" /* yacc.c:1652 */ { err = addunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1520 "parse.tab.c" /* yacc.c:1646 */ +#line 1524 "parse.tab.c" /* yacc.c:1652 */ break; case 11: -#line 218 "parse.y" /* yacc.c:1646 */ +#line 218 "parse.y" /* yacc.c:1652 */ { (yyvsp[0].unit)->factor *= -1; err = addunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1528 "parse.tab.c" /* yacc.c:1646 */ +#line 1532 "parse.tab.c" /* yacc.c:1652 */ break; case 12: -#line 221 "parse.y" /* yacc.c:1646 */ +#line 221 "parse.y" /* yacc.c:1652 */ { err = divunit((yyvsp[-2].unit), (yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1535 "parse.tab.c" /* yacc.c:1646 */ +#line 1539 "parse.tab.c" /* yacc.c:1652 */ break; case 13: -#line 223 "parse.y" /* yacc.c:1646 */ +#line 223 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1542 "parse.tab.c" /* yacc.c:1646 */ +#line 1546 "parse.tab.c" /* yacc.c:1652 */ break; case 14: -#line 225 "parse.y" /* yacc.c:1646 */ +#line 225 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1549 "parse.tab.c" /* yacc.c:1646 */ +#line 1553 "parse.tab.c" /* yacc.c:1652 */ break; case 15: -#line 229 "parse.y" /* yacc.c:1646 */ +#line 229 "parse.y" /* yacc.c:1652 */ { (yyval.number) = (yyvsp[0].number); } -#line 1555 "parse.tab.c" /* yacc.c:1646 */ +#line 1559 "parse.tab.c" /* yacc.c:1652 */ break; case 16: -#line 230 "parse.y" /* yacc.c:1646 */ +#line 230 "parse.y" /* yacc.c:1652 */ { (yyval.number) = (yyvsp[-2].number) / (yyvsp[0].number); } -#line 1561 "parse.tab.c" /* yacc.c:1646 */ +#line 1565 "parse.tab.c" /* yacc.c:1652 */ break; case 17: -#line 233 "parse.y" /* yacc.c:1646 */ +#line 233 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[-1].unit); } -#line 1567 "parse.tab.c" /* yacc.c:1646 */ +#line 1571 "parse.tab.c" /* yacc.c:1652 */ break; case 18: -#line 239 "parse.y" /* yacc.c:1646 */ +#line 239 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = makenumunit((yyvsp[0].number),&err); CHECK(0);} -#line 1573 "parse.tab.c" /* yacc.c:1646 */ +#line 1577 "parse.tab.c" /* yacc.c:1652 */ break; case 19: -#line 240 "parse.y" /* yacc.c:1646 */ +#line 240 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); } -#line 1579 "parse.tab.c" /* yacc.c:1646 */ +#line 1583 "parse.tab.c" /* yacc.c:1652 */ break; case 20: -#line 241 "parse.y" /* yacc.c:1646 */ +#line 241 "parse.y" /* yacc.c:1652 */ { err = unitpower((yyvsp[-2].unit),(yyvsp[0].unit));destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1586 "parse.tab.c" /* yacc.c:1646 */ +#line 1590 "parse.tab.c" /* yacc.c:1652 */ break; case 21: -#line 243 "parse.y" /* yacc.c:1646 */ +#line 243 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1593 "parse.tab.c" /* yacc.c:1646 */ +#line 1597 "parse.tab.c" /* yacc.c:1652 */ break; case 22: -#line 245 "parse.y" /* yacc.c:1646 */ +#line 245 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-1].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-1].unit));(yyval.unit)=(yyvsp[-1].unit);} -#line 1600 "parse.tab.c" /* yacc.c:1646 */ +#line 1604 "parse.tab.c" /* yacc.c:1652 */ break; case 23: -#line 247 "parse.y" /* yacc.c:1646 */ +#line 247 "parse.y" /* yacc.c:1652 */ { (yyval.unit)=(yyvsp[0].unit); } -#line 1606 "parse.tab.c" /* yacc.c:1646 */ +#line 1610 "parse.tab.c" /* yacc.c:1652 */ break; case 24: -#line 248 "parse.y" /* yacc.c:1646 */ +#line 248 "parse.y" /* yacc.c:1652 */ { err = rootunit((yyvsp[0].unit),2); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1612 "parse.tab.c" /* yacc.c:1646 */ +#line 1616 "parse.tab.c" /* yacc.c:1652 */ break; case 25: -#line 249 "parse.y" /* yacc.c:1646 */ +#line 249 "parse.y" /* yacc.c:1652 */ { err = rootunit((yyvsp[0].unit),3); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1618 "parse.tab.c" /* yacc.c:1646 */ +#line 1622 "parse.tab.c" /* yacc.c:1652 */ break; case 26: -#line 250 "parse.y" /* yacc.c:1646 */ +#line 250 "parse.y" /* yacc.c:1652 */ { err = funcunit((yyvsp[0].unit),(yyvsp[-1].realfunc));CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1624 "parse.tab.c" /* yacc.c:1646 */ +#line 1628 "parse.tab.c" /* yacc.c:1652 */ break; case 27: -#line 251 "parse.y" /* yacc.c:1646 */ +#line 251 "parse.y" /* yacc.c:1652 */ { err = logunit((yyvsp[0].unit),(yyvsp[-1].integer)); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1630 "parse.tab.c" /* yacc.c:1646 */ +#line 1634 "parse.tab.c" /* yacc.c:1652 */ break; case 28: -#line 252 "parse.y" /* yacc.c:1646 */ +#line 252 "parse.y" /* yacc.c:1652 */ { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),0,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} -#line 1636 "parse.tab.c" /* yacc.c:1646 */ +#line 1640 "parse.tab.c" /* yacc.c:1652 */ break; case 29: -#line 253 "parse.y" /* yacc.c:1646 */ +#line 253 "parse.y" /* yacc.c:1652 */ { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),1,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} -#line 1642 "parse.tab.c" /* yacc.c:1646 */ +#line 1646 "parse.tab.c" /* yacc.c:1652 */ break; case 30: -#line 255 "parse.y" /* yacc.c:1646 */ +#line 255 "parse.y" /* yacc.c:1652 */ { (yyvsp[0].unit)->factor *= -1; err = unitpower((yyvsp[-3].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit));CHECK((yyvsp[-3].unit));(yyval.unit)=(yyvsp[-3].unit);} -#line 1649 "parse.tab.c" /* yacc.c:1646 */ +#line 1653 "parse.tab.c" /* yacc.c:1652 */ break; case 31: -#line 258 "parse.y" /* yacc.c:1646 */ +#line 258 "parse.y" /* yacc.c:1652 */ { (yyvsp[0].unit)->factor *= -1; err = unitpower((yyvsp[-3].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit));CHECK((yyvsp[-3].unit));(yyval.unit)=(yyvsp[-3].unit);} -#line 1656 "parse.tab.c" /* yacc.c:1646 */ +#line 1660 "parse.tab.c" /* yacc.c:1652 */ break; case 32: -#line 260 "parse.y" /* yacc.c:1646 */ +#line 260 "parse.y" /* yacc.c:1652 */ { err = E_BADNUM; CHECK(0); } -#line 1662 "parse.tab.c" /* yacc.c:1646 */ +#line 1666 "parse.tab.c" /* yacc.c:1652 */ break; case 33: -#line 261 "parse.y" /* yacc.c:1646 */ +#line 261 "parse.y" /* yacc.c:1652 */ { err = E_PARSEMEM; CHECK(0); } -#line 1668 "parse.tab.c" /* yacc.c:1646 */ +#line 1672 "parse.tab.c" /* yacc.c:1652 */ break; case 34: -#line 262 "parse.y" /* yacc.c:1646 */ +#line 262 "parse.y" /* yacc.c:1652 */ { err = E_UNITEND; CHECK(0); } -#line 1674 "parse.tab.c" /* yacc.c:1646 */ +#line 1678 "parse.tab.c" /* yacc.c:1652 */ break; case 35: -#line 263 "parse.y" /* yacc.c:1646 */ +#line 263 "parse.y" /* yacc.c:1652 */ { err = E_LASTUNSET;CHECK(0); } -#line 1680 "parse.tab.c" /* yacc.c:1646 */ +#line 1684 "parse.tab.c" /* yacc.c:1652 */ break; case 36: -#line 264 "parse.y" /* yacc.c:1646 */ +#line 264 "parse.y" /* yacc.c:1652 */ { err = E_NOTAFUNC; CHECK((yyvsp[0].unit));} -#line 1686 "parse.tab.c" /* yacc.c:1646 */ +#line 1690 "parse.tab.c" /* yacc.c:1652 */ break; -#line 1690 "parse.tab.c" /* yacc.c:1646 */ +#line 1694 "parse.tab.c" /* yacc.c:1652 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1711,14 +1715,13 @@ /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -1801,12 +1804,10 @@ | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1868,6 +1869,7 @@ yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1875,6 +1877,7 @@ yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1885,6 +1888,10 @@ /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1914,7 +1921,7 @@ #endif return yyresult; } -#line 267 "parse.y" /* yacc.c:1906 */ +#line 267 "parse.y" /* yacc.c:1918 */ struct function diff -Nru units-2.18/texi2man units-2.19/texi2man --- units-2.18/texi2man 2018-10-17 01:20:08.000000000 +0000 +++ units-2.19/texi2man 2019-04-03 01:20:10.000000000 +0000 @@ -4,9 +4,11 @@ # Jeff Conrad. # Script to translate a texinfo file into an nroff/troff manual page. -# last revision: 15 October 2018 Jeff Conrad +# last revision: 30 March 2019 Jeff Conrad -$version="1.01u"; +$thisprog = $0; +$thisprog =~ s/.*[\/\\]//; +$version="1.01w"; $html=0; $example=0; @@ -21,7 +23,7 @@ $args=($#ARGV < 0) ? "stdin" : "@ARGV"; printf(".\\\"Do not edit this file. It was created from %s\n", $args); -printf(".\\\"using texi2man version %s on %s", $version, `date`); +printf(".\\\"using %s version %s on %s", $thisprog, $version, `date`); while(<>) { @@ -33,9 +35,28 @@ print; next; } + if (/\@c\s+man\s+program/) { + chop; + s/\@c\s+man\s+program\s+//; + $program = $_; + next; + } if (s/\@c man //) { print; + if (/AUTHOR/) { + $errors = 0; + if (! $author) { + printf(STDERR "%s: missing '\@author'\n", $thisprog); + $errors++; + } + if (! $program) { + printf(STDERR "%s: missing '\@c man program'\n", $thisprog); + $errors++; + } + if ($errors) { exit; } + else { printf(".I %s\nwas written by %s\n", $program, $author); } + } if (/\.TH/) { add_extensions(); } next; } @@ -53,6 +74,12 @@ if (/^START-INFO-DIR-ENTRY/) { next; } if (/^END-INFO-DIR-ENTRY/) { next; } + if (/\@author/) { + chop; + s/\@author\s+//; + $author = $_; + next; + } if (/\@titlepage/) { $title=1; next; } if (/\@end titlepage/) { $title=0; next; } if (/\@tex/) { $tex=1; next; } @@ -64,7 +91,8 @@ if (/\@html/) { $html=1; next; } if (/\@end html/) { $html=0; next; } if (!$doman && ($ignore || $html || $title || $tex)) { next; } - if (/\@codequoteundirected/) { next; } + if (/\@set codequoteundirected/) { print ".aQ\n"; next; } + if (/\@clear codequoteundirected/) { print ".aE\n"; next; } s/\@\*$/\n\.br/g; s/^\@\*/.br/g; @@ -75,6 +103,10 @@ s/\@w\{}/\@no_break_space\{}/g; s/\@backslashchar\{}/\\e/g; + # opening and closing double quotes + s/``(\S)/\\\*(lQ$1/g; + s/(\S)''/$1\\\*(rQ/g; + # ellipsis, defined in extensions s/\@dots\{}/\\*(El/g; @@ -206,7 +238,12 @@ # tables of command-line options as used in units(1) if (/\@table (.*)/) { $intable = 1; next; } - if (/\@end *table/) { $intable = 0; next; } + if (/\@end *table/) + { + $intable = 0; + if ($in_taggedlist == 1) { $in_taggedlist = 0; } + next; + } if ($intable == 1) { if (/\@itemx (.*)/) @@ -219,20 +256,31 @@ { printf(".TP\n.BR \"$samp\""); } else { printf(" \", \" \"$samp\""); } - $diditem=1; next; + $diditem=1; + $new_paragraph = ""; + next; } elsif ($diditem) { printf("\n"); $diditem=0; } if (/\@item (.*)/) { + $in_taggedlist = 1; $samp = $1; # add hair space to visually separate the hyphens in roman type $samp =~ s/--/-\\^-/; $samp =~ s/-([[:alnum:]])/-\\^$1/; printf("%s.TP\n%s.BR \"$samp\"", $manprefix, $manprefix); $diditem=1; + $new_paragraph = ""; next; } } + # output a paragraph macro unless already done with a TP macro above + if ($new_paragraph) + { + printf("%s\n", $new_paragraph); + $justdidlp = 1; + $new_paragraph = ""; + } # unordered list: bullet or minus if (/^\@itemize *$/ || /^\@itemize +@(bullet|minus)(\{})?/) @@ -251,6 +299,7 @@ if (s/\@chapter (.*)/.SH \U$1\E/) { + if (/GNU FREE DOCUMENTATION/) { next; } # restore proper case on font switches s/\\FR/\\fR/g; s/\\FI/\\f(BI/g; # chapter headings (SH in man) are bold @@ -285,11 +334,18 @@ if ($example) { s/\\\s*$/\\e\n/ }; + # blank line: new paragraph; don't output until we see if @item or @itemx follows if (!$example && /^\s*$/ && !$doman) { if ($justdidlp) { next; } - printf(".PP\n"); - $justdidlp=1; + if ($in_taggedlist == 1) + { + $new_paragraph = ".IP"; + } + else + { + $new_paragraph = ".PP"; + } next; } @@ -307,73 +363,174 @@ sub add_extensions { - # ensure that ASCII circumflex U+005E (^) is not remapped with groff printf(".\\\"\n"); - printf(".\\\" ensure that ASCII circumflex U+005E (^) is not remapped with groff\n"); - printf(".if \\n(.g .tr ^\\(ha\n"); + printf(".if \\n(.g \\{\\\n"); + printf(". \\\" ensure that ASCII circumflex U+005E (^) is not remapped\n"); + printf(". tr ^\\(ha\n"); + printf(". \\\" override translation in troffrc\n"); + printf(". ie '\\*[.T]'utf8' .tr `\\(oq'\\(cq\n"); + printf(". \\\" override mapping of ` to 60h with Tascii; assume\n"); + printf(". \\\" we don't need a backquote for an example\n"); + printf(". el .if n .tr `'\n"); + printf(".\\}\n"); # ellipsis: space periods with troff but not with nroff printf(".\\\" ellipsis: space periods with troff but not with nroff\n"); printf(".if n .ds El \\&...\n"); printf(".if t .ds El \\&.\\ .\\ .\n"); - # constant-width font + # bullet: use '*' rather than 'o' for ASCII/Latin1; override groff's + # translation to MIDDLE DOT for others + printf(".if n \\{\\\n"); + printf(". tr \\(bu\*\n"); + printf(". \\\" override translation to MIDDLE DOT\n"); + printf(". if \\n(.g .if '\\*(.T'utf8' .tr \\(bu\\(bu\n"); + printf(". if \\n(.g .if '\\*(.T'cp1252' .tr \\(bu\\(bu\n"); + printf(". if \\n(.g .if '\\*(.T'ansi' .tr \\(bu\\(bu\n"); + printf(".\\}\n"); + printf(".\\\"\n"); printf(".\\\" Extensions to man macros\n"); printf(".\\\"\n"); + + printf(".\\\" set handling of single quotes: 0=>straight, >0=>left and right\n"); + printf(".nr tQ 0\n"); + printf(".\\\" groff only\n"); + printf(".if '\\\*(.T'utf8' .nr tQ 1\n"); + printf(".\\\" non-standard devices: Windows code page 1252\n"); + printf(".if '\\\*(.T'cp1252' .nr tQ 1\n"); + printf(".if '\\\*(.T'ansi' .nr tQ 1\n"); + + # constant-width font printf(".\\\" Constant-width font\n"); printf(".de CW\n"); printf(".hy 0\n"); - # just single quotes with nroff + printf(".\\\" nroff can't show CW font, so enclose in single quotes\n"); printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); - printf(".el \\&'\\\\\$1'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ>0 \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\\\\$2\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\\\\$1\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\\\\$2\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\\\\$1\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); + printf(". el \\&'\\\\\$1'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width font with troff + printf(".\\\" troff can change fonts, so no need for quotes\n"); printf(".if t \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1\\f(CW\\\\\$2\\fR\\\\\$3\n"); - printf(".el \\&\\f(CW\\\\\$1\\fR\\\\\$2\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\f(CW\\\\\$2\\fR\\\\\$3\n"); + printf(". el \\&\\f(CW\\\\\$1\\fR\\\\\$2\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); - # constant-width oblique font printf(".\\\" Constant-width oblique font\n"); printf(".de CI\n"); printf(".hy 0\n"); - # single quotes with nroff + printf(".\\\" nroff can't show CW font, so enclose in single quotes\n"); printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\fI\\\\\$2\\fR'\\\\\$3\n"); - printf(".el \\&'\\fI\\\\\$1\\fR'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\fI\\\\\$2\\fR\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\fI\\\\\$1\\fR\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\fI\\\\\$2\\fR\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\fI\\\\\$1\\fR\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\fI\\\\\$2\\fR'\\\\\$3\n"); + printf(". el \\&'\\fI\\\\\$1\\fR'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width oblique font with troff + printf(".\\\" troff can change fonts, so no need for quotes\n"); printf(".if t \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1\\f(CI\\\\\$2\\fR\\\\\$3\n"); - printf(".el \\&\\f(CI\\\\\$1\\fR\\\\\$2\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\f(CI\\\\\$2\\fR\\\\\$3\n"); + printf(". el \\&\\f(CI\\\\\$1\\fR\\\\\$2\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); - # constant-width font with quotes with troff - printf(".\\\" Constant-width font with quotes\n"); + printf(".\\\" Constant-width font with quotes with nroff and troff\n"); printf(".de CQ\n"); printf(".hy 0\n"); - # just single quotes with nroff printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); - printf(".el \\&'\\\\\$1'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\\\\$2\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\\\\$1\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\\\\$2\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\\\\$1\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); + printf(". el \\&'\\\\\$1'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width font with troff printf(".if t \\{\\\n"); - # quotes passed as literal text encoded as \(fm - # make it a double quote because groff converts ` and ' to opening and - # closing quotes - printf(".ie \\\\n(.\$>2 \\&\\\\\$1`\\f(CW\\\\\$2\\fR'\\\\\$3\n"); - printf(".el \\&`\\f(CW\\\\\$1\\fR'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\f(CW\\\\\$2\\fR\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\f(CW\\\\\$1\\fR\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" legacy troff doesn't have 'oq' or 'cq'\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1`\\f(CW\\\\\$2\\fR'\\\\\$3\n"); + printf(". el \\&`\\f(CW\\\\\$1\\fR'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); + # equivalent of \@set codequoteundirected + printf(".\\\" equivalent of \@set codequoteundirected\n"); + printf(".de aQ\n"); + printf(".if \\\\n(.g .tr '\\(aq\n"); + printf("..\n"); + printf(".\\\" equivalent of \@clear codequoteundirected\n"); + printf(".de aE\n"); + printf(".if \\\\n(.g \\{ .ie \\\\n(tQ>0 .tr '\\(cq\n"); + printf(".el .tr '' \\}\n"); + printf("..\n"); + + # opening and closing double quotes + printf(".\\\" opening and closing double quotes\n"); + printf(".\\\" groff: true opening and closing quotes\n"); + printf(".ie \\n(.g \\{\\\n"); + printf(". ds lQ \\(lq\n"); + printf(". ds rQ \\(rq\n"); + printf(".\\}\n"); + printf(".el \\{\\\n"); + printf(".\\\" legacy nroff: ASCII neutral double quotes\n"); + printf(". ie n \\{\\\n"); + printf(". ds lQ \"\"\n"); + printf(". ds rQ \"\"\n"); + printf(". \\}\n"); + printf(".\\\" legacy troff: adjacent opening and closing single quotes\n"); + printf(". el \\{\\\n"); + printf(". ds lQ ``\n"); + printf(". ds rQ ''\n"); + printf(". \\}\n"); + printf(".\\}\n"); + # Display Start--indent, no fill printf(".\\\" Display start\n"); printf(".de DS\n"); @@ -488,5 +645,3 @@ return $line; } - - diff -Nru units-2.18/units.c units-2.19/units.c --- units-2.18/units.c 2018-10-16 23:41:30.000000000 +0000 +++ units-2.19/units.c 2019-05-30 09:53:20.000000000 +0000 @@ -1,4 +1,4 @@ -#define VERSION "2.18" +#define VERSION "2.19" /* * units, a program for units conversion @@ -4819,7 +4819,7 @@ UNITSEPCHAR) for errors. All units must be parseable and conformable to each other. Returns 0 on success and 1 on failure. - I an error is found then print an error message on stdout. A + If an error is found then print an error message on stdout. A pointer ('^') will be printed to mark the error. The promptlen parameter should be set to the printing width of the prompt string so that the pointer is correctly aligned. @@ -5709,7 +5709,6 @@ strcpy(queryhave, promptprefix); strcat(queryhave, QUERYHAVE); memset(querywant, ' ', strlen(promptprefix)); - //for(i=0;i -will complete unit names. *Note Readline Support::, for more +would type 'feet'. If the 'readline' library was compiled in, then + will complete unit names. *Note Readline Support::, for more information about 'readline'. To quit the program type 'quit' or 'exit' at either prompt. @@ -265,12 +266,19 @@ and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. + 'units' does not require a space between a numerical value and the +unit, so the previous example can be given as + + units 2liters quarts + +to avoid having to quote the first argument. + If the conversion is successful, then 'units' will return success -(zero) to the calling environment. If you enter non-conformable units +(zero) to the calling environment. If you enter non-conformable units, then 'units' will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. - When you invoke 'units' with only one argument, it will print out the + When you invoke 'units' with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. @@ -347,9 +355,9 @@ percent. By default if 'units' runs in the 'en_GB' locale you will get the British volume measures. If it runs in the 'en_US' locale you will get the US volume measures. In other locales the default values are the -US definitions. If you wish to force different definitions then set the -environment variable 'UNITS_ENGLISH' to either 'US' or 'GB' to set the -desired definitions independent of the locale. +US definitions. If you wish to force different definitions, then set +the environment variable 'UNITS_ENGLISH' to either 'US' or 'GB' to set +the desired definitions independent of the locale. Before 1959, the value of a yard (and other units of measure defined in terms of it) differed slightly among English-speaking countries. In @@ -834,9 +842,9 @@ with a space, giving it a higher precedence than division. When '-' is used as a unary operator it negates its operand. -Regardless of the 'units' options, if '-' appears after '(' or after '+' -then it will act as a negation operator. So you can always compute 20 -degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You +Regardless of the 'units' options, if '-' appears after '(' or after +'+', then it will act as a negation operator. So you can always compute +20 degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You must use this construction when you define new units because you cannot know what options will be in force when your definition is processed. @@ -1564,7 +1572,7 @@ option is ignored when 'units' is used non-interactively.  -File: units.info, Node: Invoking Units, Next: Defining Your Own Units, Prev: Logging Calculations, Up: Top +File: units.info, Node: Invoking Units, Next: Output Styles, Prev: Logging Calculations, Up: Top 10 Invoking 'units' ******************* @@ -1580,7 +1588,9 @@ FROM-UNIT appears on the command line, 'units' will display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to -group them into two arguments. *Note Command Line Use::. +group them into two arguments. Note also that the '--quiet' option is +enabled by default if you specify FROM-UNIT on the command line. *Note +Command Line Use::. The default behavior of 'units' can be changed by various options given on the command line. In most cases, the options may be given in @@ -1729,20 +1739,6 @@ usual rules of algebra: the precedence of '*' is the same as the precedence of '/', so that '1/2*3' will equal '3/2'. -'--compact' - Give compact output featuring only the conversion factor. This - turns off the '--verbose' option. - -'-q' -'--quiet' -'--silent' - Suppress prompting of the user for units and the display of - statistics about the number of units loaded. - -'-n' -'--nolists' - Disable conversion to unit lists. - '-r' '--round' When converting to a combination of units given by a unit list, @@ -1766,31 +1762,6 @@ cup', a result equivalent to 1 1/2 cups will always be shown as '2 * 3|4 cup' whether or not the '--show-factor' option is given. -'-s' -'--strict' - Suppress conversion of units to their reciprocal units. For - example, 'units' will normally convert hertz to seconds because - these units are reciprocals of each other. The strict option - requires that units be strictly conformable to perform a - conversion, and will give an error if you attempt to convert hertz - to seconds. - -'-1' -'--one-line' - Give only one line of output (the forward conversion). Do not - print the reverse conversion. If a reciprocal conversion is - performed then 'units' will still print the "reciprocal conversion" - line. - -'-t' -'--terse' - Give terse output when converting units. This option can be used - when calling 'units' from another program so that the output is - easy to parse. This option has the combined effect of these - options: '--strict' '--quiet' '--one-line' '--compact'. When - combined with '--version' it produces a display showing only the - program name and version number. - '-v' '--verbose' Give slightly more verbose output when converting units. When @@ -1838,12 +1809,55 @@ '-l LOCALE' '--locale LOCALE' - Print the information given with the '--version' option, show the Force a specified locale such as 'en_GB' to get British definitions by default. This overrides the locale determined from system settings or environment variables. *Note Locale::, for a description of locale format. +'-n' +'--nolists' + Disable conversion to unit lists. + +'-s' +'--strict' + Suppress conversion of units to their reciprocal units. For + example, 'units' will normally convert hertz to seconds because + these units are reciprocals of each other. The strict option + requires that units be strictly conformable to perform a + conversion, and will give an error if you attempt to convert hertz + to seconds. + +'-1' +'--one-line' + Give only one line of output (the forward conversion); do not print + the reverse conversion. If a reciprocal conversion is performed, + then 'units' will still print the "reciprocal conversion" line. + +'-t' +'--terse' + Print only a single conversion factor. This option can be used + when calling 'units' from another program so that the output is + easy to parse. This option has the combined effect of these + options: '--strict' '--quiet' '--one-line' '--compact'. When + combined with '--version' it produces a display showing only the + program name and version number. + +'--compact' + Give compact output featuring only the conversion factor; the + multiplication and division signs are not shown, and there is no + leading whitespace. If you convert to a unit list, then the output + is a semicolon separated list of factors. This turns off the + '--verbose' option. + +'-q' +'--quiet' +'--silent' + Suppress the display of statistics about the number of units + loaded, any messages printed by the units database, and the + prompting of the user for units. This option does not affect how + 'units' displays the results. This option is turned on by default + if you invoke 'units' with a unit expression on the command line. + ---------- Footnotes ---------- (1) This document refers to "decimal point," but strictly, the @@ -1852,9 +1866,114 @@ in most other countries it is a comma (',').  -File: units.info, Node: Defining Your Own Units, Next: Numeric Output Format, Prev: Invoking Units, Up: Top +File: units.info, Node: Output Styles, Next: Defining Your Own Units, Prev: Invoking Units, Up: Top -11 Adding Your Own Definitions +11 Output Styles +**************** + +The output can be tweaked in various ways using command line options. +With no options, the output looks like this + + $ units + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23ft + You want: m + * 7.0104 + / 0.14264521 + You have: m + You want: ft;in + 3 ft + 3.3700787 in + +This is arguably a bit cryptic; the '--verbose' option makes clear what +the output means: + + $ units --verbose + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23 ft + You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m + You have: meter + You want: ft;in + meter = 3 ft + 3.3700787 in + +The '--quiet' option suppresses the clutter displayed when 'units' +starts, as well as the prompts to the user. This option is enabled by +default when you give units on the command line. + + $ units --quiet + 23 ft + m + * 7.0104 + / 0.14264521 + + $ units 23ft m + * 7.0104 + / 0.14264521 + +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display +just a single line showing the forward conversion: + + $ units --compact 23ft m + 7.0104 + 0.14264521 + + $ units --compact m 'ft;in' + 3;3.3700787 + + $ units --one-line 23ft m + * 7.0104 + + $ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + + $ units --one-line 23ft kg + conformability error + 7.0104 m + 1 kg + +Note that when converting to a unit list, the '--compact' option +displays a semicolon separated list of results. Also be aware that the +'one-line' option doesn't live up to its name if you execute a +reciprocal conversion or if you get a conformability error. The former +case can be prevented using the '--strict' option, which suppresses +reciprocal conversions. Similarly you can suppress unit list conversion +using '--nolists'. It is impossible to prevent the three line error +output. + + $ units --compact --nolists m 'ft;in' + Error in 'ft;in': Parse error + + $ units --one-line --strict 23ft 1/m + +The various style options can be combined appropriately. The ultimate +combination is the '--terse' option, which combines '--strict', +'--quiet', '--one-line', and '--compact' to produce the minimal output, +just a single number for regular conversions and a semicolon separated +list for conversion to unit lists. This will likely be the best choice +for programs that want to call 'units' and then process its result. + + $ units --terse 23ft m + 7.0104 + + $ units --terse m 'ft;in' + 3;3.3700787 + + $ units --terse 23ft 1/m + conformability error + 7.0104 m + 1 / m + + +File: units.info, Node: Defining Your Own Units, Next: Numeric Output Format, Prev: Output Styles, Up: Top + +12 Adding Your Own Definitions ****************************** * Menu: @@ -1868,7 +1987,7 @@  File: units.info, Node: Units Data Files, Next: Defining New Units, Up: Defining Your Own Units -11.1 Units Data Files +12.1 Units Data Files ===================== The units and prefixes that 'units' can convert are defined in the units @@ -1916,7 +2035,7 @@  File: units.info, Node: Defining New Units, Next: Defining Nonlinear Units, Prev: Units Data Files, Up: Defining Your Own Units -11.2 Defining New Units and Prefixes +12.2 Defining New Units and Prefixes ==================================== A unit is specified on a single line by giving its name and an @@ -1994,13 +2113,13 @@ A unit that ends with a '-' character is a prefix. If a prefix definition contains any '/' characters, be sure they are protected by -parentheses. If you define 'half- 1/2' then 'halfmeter' would be +parentheses. If you define 'half- 1/2', then 'halfmeter' would be equivalent to '1 / (2 meter)'.  File: units.info, Node: Defining Nonlinear Units, Next: Piecewise Linear Units, Prev: Defining New Units, Up: Defining Your Own Units -11.3 Defining Nonlinear Units +12.3 Defining Nonlinear Units ============================= Some unit conversions of interest are nonlinear; for example, @@ -2123,7 +2242,7 @@ comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If you give other values without -units then the definition will be ignored and you will get an error +units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, @@ -2172,7 +2291,7 @@  File: units.info, Node: Piecewise Linear Units, Next: Defining Unit List Aliases, Prev: Defining Nonlinear Units, Up: Defining Your Own Units -11.4 Defining Piecewise Linear Units +12.4 Defining Piecewise Linear Units ==================================== Sometimes you may be interested in a piecewise linear unit such as many @@ -2263,7 +2382,7 @@  File: units.info, Node: Defining Unit List Aliases, Prev: Piecewise Linear Units, Up: Defining Your Own Units -11.5 Defining Unit List Aliases +12.5 Defining Unit List Aliases =============================== Unit list aliases are treated differently from unit definitions, because @@ -2290,7 +2409,7 @@  File: units.info, Node: Numeric Output Format, Next: Localization, Prev: Defining Your Own Units, Up: Top -12 Numeric Output Format +13 Numeric Output Format ************************ * Menu: @@ -2317,7 +2436,7 @@  File: units.info, Node: Format Specification, Next: Flags, Up: Numeric Output Format -12.1 Format Specification +13.1 Format Specification ========================= The format specification recognized with the '--output-format' option is @@ -2354,7 +2473,7 @@  File: units.info, Node: Flags, Next: Field Width, Prev: Format Specification, Up: Numeric Output Format -12.2 Flags +13.2 Flags ========== The '+' flag causes the output to have a sign ('+' or '-'). The space @@ -2405,7 +2524,7 @@  File: units.info, Node: Field Width, Next: Precision, Prev: Flags, Up: Numeric Output Format -12.3 Field Width +13.3 Field Width ================ By default, the output value is left aligned and shown with the minimum @@ -2434,7 +2553,7 @@  File: units.info, Node: Precision, Prev: Field Width, Up: Numeric Output Format -12.4 Precision +13.4 Precision ============== The meaning of "precision" depends on the format type. With 'g' or 'G', @@ -2490,7 +2609,7 @@  File: units.info, Node: Localization, Next: Environment Vars, Prev: Numeric Output Format, Up: Top -13 Localization +14 Localization *************** * Menu: @@ -2505,7 +2624,7 @@  File: units.info, Node: Locale, Next: Additional Localization, Up: Localization -13.1 Locale +14.1 Locale =========== A locale is a subset of a user's environment that indicates the user's @@ -2552,7 +2671,7 @@  File: units.info, Node: Additional Localization, Prev: Locale, Up: Localization -13.2 Additional Localization +14.2 Additional Localization ============================ Sometimes the locale isn't sufficient to determine unit preferences. @@ -2608,7 +2727,7 @@ When 'units' reads the above definitions it will check the environment variable 'INCH_UNIT' and load only the definitions for the appropriate section. If 'INCH_UNIT' is unset or is not set to one of the four -values listed then 'units' will run the last block. In this case that +values listed, then 'units' will run the last block. In this case that block uses the '!message' command to display a warning message. Alternatively that block could set default values. @@ -2616,7 +2735,7 @@ settings the data file can use the '!set' command, which sets an environment variable _only if it is not already set_; these settings are only for the current 'units' invocation and do not persist. So if the -example above were preceded by '!set INCH_UNIT france' then this would +example above were preceded by '!set INCH_UNIT france', then this would make 'france' the default value for 'INCH_UNIT'. If the user had set the variable in the environment before invoking 'units', then 'units' would use the user's value. @@ -2645,7 +2764,7 @@ default setting comes last so that it only applies when 'INCH_UNIT' was not set by one of the other commands or by the user. - If the variable given after '!var' or '!varnot' is undefined then + If the variable given after '!var' or '!varnot' is undefined, then 'units' prints an error message and ignores the definitions that follow. Use '!set' to create defaults to prevent this situation from arising. The '-c' option only checks the definitions that are active for the @@ -2655,7 +2774,7 @@  File: units.info, Node: Environment Vars, Next: Data Files, Prev: Localization, Up: Top -14 Environment Variables +15 Environment Variables ************************ The 'units' program uses the following environment variables: @@ -2716,7 +2835,7 @@  File: units.info, Node: Data Files, Next: Unicode Support, Prev: Environment Vars, Up: Top -15 Data Files +16 Data Files ************* The 'units' program uses two default data files: 'definitions.units' and @@ -2757,7 +2876,7 @@  File: units.info, Node: Unicode Support, Next: Readline Support, Prev: Data Files, Up: Top -16 Unicode Support +17 Unicode Support ****************** The standard units data file is in Unicode, using UTF-8 encoding. Most @@ -2765,28 +2884,35 @@ U+007F); definitions using non-ASCII characters appear in blocks beginning with '!utf8' and ending with '!endutf8'. - When 'units' starts, it checks the locale to determine the character -set. If 'units' is compiled with Unicode support and definitions; -otherwise these definitions are ignored. When Unicode support is -active, 'units' will check every line of all of the units data files for -invalid or non-printing UTF-8 sequences; if such sequences occur, -'units' ignores the entire line. In addition to checking validity, -'units' determines the display width of non-ASCII characters to ensure -proper positioning of the pointer in some error messages and to align -columns for the 'search' and '?' commands. - - At present, 'units' does not support Unicode under Microsoft Windows. -The UTF-16 and UTF-32 encodings are not supported on any systems. - - If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within '!utf8' ... -'!endutf8' to ensure that they are only loaded when Unicode support is -available. As usual, the '!' must appear as the first character on the -line. As discussed in *note Units Data Files::, it's usually best to -put such definitions in supplemental data files linked by an '!include' -command or in a personal units data file. + The non-ASCII definitions are loaded only if the platform and the +locale support UTF-8. Platform support is determined when 'units' is +compiled; the locale is checked at every invocation of 'units'. To see +if your version of 'units' includes Unicode support, invoke the program +with the '--version' option. + + When Unicode support is available, 'units' checks every line within +UTF-8 blocks in all of the units data files for invalid or non-printing +UTF-8 sequences; if such sequences occur, 'units' ignores the entire +line. In addition to checking validity, 'units' determines the display +width of non-ASCII characters to ensure proper positioning of the +pointer in some error messages and to align columns for the 'search' and +'?' commands. + + As of early 2019, Microsoft Windows provides limited support for +UTF-8 in console applications, and accordingly, 'units' does not support +Unicode on Windows. The UTF-16 and UTF-32 encodings are not supported +on any platforms. + + If Unicode support is available and definitions that contain +non-ASCII UTF-8 characters are added to a units data file, those +definitions should be enclosed within '!utf8' ... '!endutf8' to ensure +that they are only loaded when Unicode support is available. As usual, +the '!' must appear as the first character on the line. As discussed in +*note Units Data Files::, it's usually best to put such definitions in +supplemental data files linked by an '!include' command or in a personal +units data file. - When Unicode support is not active, 'units' makes no assumptions + When Unicode support is not available, 'units' makes no assumptions about character encoding, except that characters in the range 00-7F hexadecimal correspond to ASCII encoding. Non-ASCII characters are simply sequences of bytes, and have no special meanings; for definitions @@ -2794,11 +2920,13 @@ with this assumption. For example, if you wish to use non-ASCII characters in definitions when running 'units' under Windows, you can use a character set such as Windows "ANSI" (code page 1252 in the US and -Western Europe). You can even use UTF-8, though some messages may be -improperly aligned, and 'units' will not detect invalid UTF-8 sequences. -If you use UTF-8 encoding when Unicode support is not active, you should -place any definitions with non-ASCII characters _outside_ '!utf8' ... -'!endutf8' blocks--otherwise, they will be ignored. +Western Europe); if this is done, the console code page must be set to +the same encoding for the characters to display properly. You can even +use UTF-8, though some messages may be improperly aligned, and 'units' +will not detect invalid UTF-8 sequences. If you use UTF-8 encoding when +Unicode support is not available, you should place any definitions with +non-ASCII characters _outside_ '!utf8' ... '!endutf8' blocks--otherwise, +they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) used @@ -2811,7 +2939,7 @@  File: units.info, Node: Readline Support, Next: Currency, Prev: Unicode Support, Up: Top -17 Readline Support +18 Readline Support ******************* If the 'readline' package has been compiled in, then when 'units' is @@ -2824,7 +2952,7 @@ allow editing in the style of emacs. Of particular use with 'units' are the completion commands. - If you type a few characters and then hit followed by '?' then + If you type a few characters and then hit followed by '?', then 'units' will display a list of all the units that start with the characters typed. For example, if you type 'metr' and then request completion, you will see something like this: @@ -2855,7 +2983,7 @@  File: units.info, Node: Currency, Next: Database Syntax, Prev: Readline Support, Up: Top -18 Updating Currency Exchange Rates +19 Updating Currency Exchange Rates *********************************** The units program database includes currency exchange rates and prices @@ -2957,7 +3085,7 @@  File: units.info, Node: Database Syntax, Next: GNU Free Documentation License, Prev: Currency, Up: Top -19 Database Command Syntax +20 Database Command Syntax ************************** UNIT DEFINITION @@ -2993,12 +3121,12 @@ !message TEXT Display TEXT when the database is read unless the quiet option - ('-q') is enabled. If you omit TEXT then units will display a + ('-q') is enabled. If you omit TEXT, then units will display a blank line. Messages will also appear in the log file. !prompt TEXT Prefix the 'You have:' prompt with the specified text. If you omit - TEXT then any existing prefix is canceled. + TEXT, then any existing prefix is canceled. !set VARIABLE VALUE Sets the environment variable, VARIABLE, to the specified value @@ -3026,7 +3154,7 @@  File: units.info, Node: GNU Free Documentation License, Next: Index, Prev: Database Syntax, Up: Top -20 GNU Free Documentation License +21 GNU Free Documentation License ********************************* Version 1.3, 3 November 2008 @@ -3530,52 +3658,52 @@ (line 17) * - as subtraction operator: Sums and Differences of Units. (line 6) -* --check (option for units): Invoking Units. (line 50) -* --check-verbose (option for units): Invoking Units. (line 59) -* --compact (option for units): Invoking Units. (line 170) -* --digits (option for units): Invoking Units. (line 67) -* --exponential (option for units): Invoking Units. (line 84) -* --file (option for units): Invoking Units. (line 115) -* --file (option for units) <1>: Invoking Units. (line 137) -* --help (option for units): Invoking Units. (line 146) -* --info (option for units): Invoking Units. (line 256) -* --locale (option for units): Invoking Units. (line 279) -* --log (option for units): Invoking Units. (line 127) -* --minus (option for units): Invoking Units. (line 150) -* --newstar (option for units): Invoking Units. (line 165) -* --oldstar (option for units): Invoking Units. (line 161) -* --one-line (option for units): Invoking Units. (line 218) -* --output-format (option for units): Invoking Units. (line 93) -* --product (option for units): Invoking Units. (line 155) -* --quiet (option for units): Invoking Units. (line 176) -* --silent (option for units): Invoking Units. (line 176) -* --strict (option for units): Invoking Units. (line 209) -* --terse (option for units): Invoking Units. (line 225) -* --units (option for units): Invoking Units. (line 275) -* --unitsfile (option for units): Invoking Units. (line 270) -* --verbose (option for units): Invoking Units. (line 234) -* --verbose-check (option for units): Invoking Units. (line 59) -* --version (option for units): Invoking Units. (line 241) -* -1 (option for units): Invoking Units. (line 218) -* -c (option for units): Invoking Units. (line 50) -* -d (option for units): Invoking Units. (line 67) -* -e (option for units): Invoking Units. (line 84) -* -f (option for units): Invoking Units. (line 115) -* -f (option for units) <1>: Invoking Units. (line 137) -* -h (option for units): Invoking Units. (line 146) -* -I (option for units): Invoking Units. (line 256) -* -L (option for units): Invoking Units. (line 127) -* -l (option for units): Invoking Units. (line 279) -* -m (option for units): Invoking Units. (line 150) -* -o (option for units): Invoking Units. (line 93) -* -p (option for units): Invoking Units. (line 155) -* -q (option for units): Invoking Units. (line 176) -* -s (option for units): Invoking Units. (line 209) -* -t (option for units): Invoking Units. (line 225) -* -U (option for units): Invoking Units. (line 270) -* -u (option for units): Invoking Units. (line 275) -* -v (option for units): Invoking Units. (line 234) -* -V (option for units): Invoking Units. (line 241) +* --check (option for units): Invoking Units. (line 52) +* --check-verbose (option for units): Invoking Units. (line 61) +* --compact (option for units): Invoking Units. (line 276) +* --digits (option for units): Invoking Units. (line 69) +* --exponential (option for units): Invoking Units. (line 86) +* --file (option for units): Invoking Units. (line 117) +* --file (option for units) <1>: Invoking Units. (line 139) +* --help (option for units): Invoking Units. (line 148) +* --info (option for units): Invoking Units. (line 219) +* --locale (option for units): Invoking Units. (line 242) +* --log (option for units): Invoking Units. (line 129) +* --minus (option for units): Invoking Units. (line 152) +* --newstar (option for units): Invoking Units. (line 167) +* --oldstar (option for units): Invoking Units. (line 163) +* --one-line (option for units): Invoking Units. (line 262) +* --output-format (option for units): Invoking Units. (line 95) +* --product (option for units): Invoking Units. (line 157) +* --quiet (option for units): Invoking Units. (line 285) +* --silent (option for units): Invoking Units. (line 285) +* --strict (option for units): Invoking Units. (line 253) +* --terse (option for units): Invoking Units. (line 268) +* --units (option for units): Invoking Units. (line 238) +* --unitsfile (option for units): Invoking Units. (line 233) +* --verbose (option for units): Invoking Units. (line 197) +* --verbose-check (option for units): Invoking Units. (line 61) +* --version (option for units): Invoking Units. (line 204) +* -1 (option for units): Invoking Units. (line 262) +* -c (option for units): Invoking Units. (line 52) +* -d (option for units): Invoking Units. (line 69) +* -e (option for units): Invoking Units. (line 86) +* -f (option for units): Invoking Units. (line 117) +* -f (option for units) <1>: Invoking Units. (line 139) +* -h (option for units): Invoking Units. (line 148) +* -I (option for units): Invoking Units. (line 219) +* -L (option for units): Invoking Units. (line 129) +* -l (option for units): Invoking Units. (line 242) +* -m (option for units): Invoking Units. (line 152) +* -o (option for units): Invoking Units. (line 95) +* -p (option for units): Invoking Units. (line 157) +* -q (option for units): Invoking Units. (line 285) +* -s (option for units): Invoking Units. (line 253) +* -t (option for units): Invoking Units. (line 268) +* -U (option for units): Invoking Units. (line 233) +* -u (option for units): Invoking Units. (line 238) +* -v (option for units): Invoking Units. (line 197) +* -V (option for units): Invoking Units. (line 204) * ? for unit completion with readline: Readline Support. (line 16) * ? to show conformable units: Interactive Use. (line 130) * _ to use result of previous conversion: Previous Result. (line 6) @@ -3588,6 +3716,7 @@ * backwards compatibility: Backwards Compatibility. (line 6) * British Imperial measure: Unit Definitions. (line 37) +* built-in functions: Built-in Functions. (line 6) * CGS Units Systems: CGS Units Systems. (line 6) * CGS units, prompt prefix: Prompt Prefix. (line 6) * CGS units, specifying: Specifying CGS Units. @@ -3843,52 +3972,53 @@  Tag Table: Node: Top842 -Node: Overview2387 -Ref: Overview-Footnote-14151 -Node: Interactive Use4345 -Node: Command Line Use10147 -Node: Unit Definitions11393 -Node: Unit Expressions17603 -Node: Operators18216 -Node: Sums and Differences of Units23583 -Node: Numbers as Units25625 -Node: Built-in Functions26430 -Node: Previous Result28446 -Node: Complicated Unit Expressions30772 -Node: Backwards Compatibility32405 -Node: Nonlinear Conversions34306 -Node: Temperature Conversions34745 -Node: Other Nonlinear Units36810 -Node: Unit Lists39947 -Node: Using CGS Units48714 -Node: Specifying CGS Units51372 -Node: CGS Units Systems53376 -Node: Conversions Between Systems54950 -Node: Prompt Prefix58644 -Node: Logging Calculations59528 -Node: Invoking Units62193 -Ref: Invoking Units-Footnote-175035 -Node: Defining Your Own Units75289 -Node: Units Data Files75827 -Node: Defining New Units78315 -Node: Defining Nonlinear Units82663 -Node: Piecewise Linear Units90840 -Node: Defining Unit List Aliases94597 -Node: Numeric Output Format95757 -Node: Format Specification97030 -Node: Flags98992 -Node: Field Width101075 -Node: Precision102110 -Node: Localization104567 -Node: Locale105010 -Node: Additional Localization107023 -Node: Environment Vars111476 -Node: Data Files114254 -Node: Unicode Support116127 -Node: Readline Support119087 -Node: Currency121232 -Node: Database Syntax125499 -Node: GNU Free Documentation License127802 -Node: Index152934 +Node: Overview2454 +Ref: Overview-Footnote-14218 +Node: Interactive Use4412 +Node: Command Line Use10215 +Node: Unit Definitions11648 +Node: Unit Expressions17859 +Node: Operators18472 +Node: Sums and Differences of Units23839 +Node: Numbers as Units25881 +Node: Built-in Functions26686 +Node: Previous Result28702 +Node: Complicated Unit Expressions31028 +Node: Backwards Compatibility32661 +Node: Nonlinear Conversions34563 +Node: Temperature Conversions35002 +Node: Other Nonlinear Units37067 +Node: Unit Lists40204 +Node: Using CGS Units48971 +Node: Specifying CGS Units51629 +Node: CGS Units Systems53633 +Node: Conversions Between Systems55207 +Node: Prompt Prefix58901 +Node: Logging Calculations59785 +Node: Invoking Units62450 +Ref: Invoking Units-Footnote-175733 +Node: Output Styles75987 +Node: Defining Your Own Units79066 +Node: Units Data Files79603 +Node: Defining New Units82091 +Node: Defining Nonlinear Units86440 +Node: Piecewise Linear Units94618 +Node: Defining Unit List Aliases98375 +Node: Numeric Output Format99535 +Node: Format Specification100808 +Node: Flags102770 +Node: Field Width104853 +Node: Precision105888 +Node: Localization108345 +Node: Locale108788 +Node: Additional Localization110801 +Node: Environment Vars115257 +Node: Data Files118035 +Node: Unicode Support119908 +Node: Readline Support123271 +Node: Currency125417 +Node: Database Syntax129684 +Node: GNU Free Documentation License131989 +Node: Index157121  End Tag Table diff -Nru units-2.18/units.man units-2.19/units.man --- units-2.18/units.man 2018-10-20 14:02:29.000000000 +0000 +++ units-2.19/units.man 2019-05-29 00:32:20.000000000 +0000 @@ -1,65 +1,169 @@ .\"Do not edit this file. It was created from units.texinfo -.\"using texi2man version 1.01u on Sat Oct 20 10:02:29 EDT 2018 +.\"using texi2man version 1.01w on Tue 28 May 2019 08:32:20 PM EDT .\"This manual is for GNU Units (version 2.18), .\"which performs units conversions and units calculations. .\" .\"Copyright \(co 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007, -.\"2011\-2018 Free Software Foundation, Inc. +.\"2011\-2019 Free Software Foundation, Inc. .\" .\"Permission is granted to copy, distribute and/or modify this document .\"under the terms of the GNU Free Documentation License, Version 1.3 or .\"any later version published by the Free Software Foundation; with no .\"Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\"Texts. -.TH UNITS 1 "20 October 2018" +.TH UNITS 1 "19 March 2019" .\" -.\" ensure that ASCII circumflex U+005E (^) is not remapped with groff -.if \n(.g .tr ^\(ha +.if \n(.g \{\ +. \" ensure that ASCII circumflex U+005E (^) is not remapped +. tr ^\(ha +. \" override translation in troffrc +. ie '\*[.T]'utf8' .tr `\(oq'\(cq +. \" override mapping of ` to 60h with Tascii; assume +. \" we don't need a backquote for an example +. el .if n .tr `' +.\} .\" ellipsis: space periods with troff but not with nroff .if n .ds El \&... .if t .ds El \&.\ .\ . +.if n \{\ +. tr \(bu* +. \" override translation to MIDDLE DOT +. if \n(.g .if '\*(.T'utf8' .tr \(bu\(bu +. if \n(.g .if '\*(.T'cp1252' .tr \(bu\(bu +. if \n(.g .if '\*(.T'ansi' .tr \(bu\(bu +.\} .\" .\" Extensions to man macros .\" +.\" set handling of single quotes: 0=>straight, >0=>left and right +.nr tQ 0 +.\" groff only +.if '\*(.T'utf8' .nr tQ 1 +.\" non-standard devices: Windows code page 1252 +.if '\*(.T'cp1252' .nr tQ 1 +.if '\*(.T'ansi' .nr tQ 1 .\" Constant-width font .de CW .hy 0 +.\" nroff can't show CW font, so enclose in single quotes .if n \{\ -.ie \\n(.$>2 \&\\$1'\\$2'\\$3 -.el \&'\\$1'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ>0 \{\ +. ie \\n(.$>2 \&\\$1\(oq\\$2\(cq\\$3 +. el \&\(oq\\$1\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\\$2\(aq\\$3 +. el \&\(aq\\$1\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{\ +. ie \\n(.$>2 \&\\$1'\\$2'\\$3 +. el \&'\\$1'\\$2 +. \} .\} +.\" troff can change fonts, so no need for quotes .if t \{\ -.ie \\n(.$>2 \&\\$1\f(CW\\$2\fR\\$3 -.el \&\f(CW\\$1\fR\\$2 +. ie \\n(.$>2 \&\\$1\f(CW\\$2\fR\\$3 +. el \&\f(CW\\$1\fR\\$2 .\} .hy 14 .. .\" Constant-width oblique font .de CI .hy 0 +.\" nroff can't show CW font, so enclose in single quotes .if n \{\ -.ie \\n(.$>2 \&\\$1'\fI\\$2\fR'\\$3 -.el \&'\fI\\$1\fR'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ \{\ +. ie \\n(.$>2 \&\\$1\(oq\fI\\$2\fR\(cq\\$3 +. el \&\(oq\fI\\$1\fR\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\fI\\$2\fR\(aq\\$3 +. el \&\(aq\fI\\$1\fR\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{ +. ie \\n(.$>2 \&\\$1'\fI\\$2\fR'\\$3 +. el \&'\fI\\$1\fR'\\$2 +. \} .\} +.\" troff can change fonts, so no need for quotes .if t \{\ -.ie \\n(.$>2 \&\\$1\f(CI\\$2\fR\\$3 -.el \&\f(CI\\$1\fR\\$2 +. ie \\n(.$>2 \&\\$1\f(CI\\$2\fR\\$3 +. el \&\f(CI\\$1\fR\\$2 .\} .hy 14 .. -.\" Constant-width font with quotes +.\" Constant-width font with quotes with nroff and troff .de CQ .hy 0 .if n \{\ -.ie \\n(.$>2 \&\\$1'\\$2'\\$3 -.el \&'\\$1'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ \{\ +. ie \\n(.$>2 \&\\$1\(oq\\$2\(cq\\$3 +. el \&\(oq\\$1\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\\$2\(aq\\$3 +. el \&\(aq\\$1\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{\ +. ie \\n(.$>2 \&\\$1'\\$2'\\$3 +. el \&'\\$1'\\$2 +. \} .\} .if t \{\ -.ie \\n(.$>2 \&\\$1`\f(CW\\$2\fR'\\$3 -.el \&`\f(CW\\$1\fR'\\$2 +. ie \\n(.g \{\ +. ie \\n(.$>2 \&\\$1\(oq\f(CW\\$2\fR\(cq\\$3 +. el \&\(oq\f(CW\\$1\fR\(cq\\$2 +. \} +. \" legacy troff doesn't have 'oq' or 'cq' +. el \{\ +. ie \\n(.$>2 \&\\$1`\f(CW\\$2\fR'\\$3 +. el \&`\f(CW\\$1\fR'\\$2 +. \} .\} .hy 14 .. +.\" equivalent of @set codequoteundirected +.de aQ +.if \\n(.g .tr '\(aq +.. +.\" equivalent of @clear codequoteundirected +.de aE +.if \\n(.g \{ .ie \\n(tQ>0 .tr '\(cq +.el .tr '' \} +.. +.\" opening and closing double quotes +.\" groff: true opening and closing quotes +.ie \n(.g \{\ +. ds lQ \(lq +. ds rQ \(rq +.\} +.el \{\ +.\" legacy nroff: ASCII neutral double quotes +. ie n \{\ +. ds lQ "" +. ds rQ "" +. \} +.\" legacy troff: adjacent opening and closing single quotes +. el \{\ +. ds lQ `` +. ds rQ '' +. \} +.\} .\" Display start .de DS .hy 0 @@ -96,7 +200,6 @@ .. .SH NAME units \(em unit conversion and calculation program -.if n .tr \(bu* .\" hack to prevent very thick fraction bars with gropdf .\" '-1' makes thickness proportional to type size .if \n(.g .if t \Z@\D't -1'@ @@ -178,7 +281,7 @@ .CI "feet" . If the .CW "readline" -library was compiled in then \fItab\fP will +library was compiled in, then \fItab\fP will complete unit names. See \fIReadline Support\fP for more information about .CW "readline" . @@ -397,18 +500,28 @@ The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. .PP +.CW "units" +does not require a space between a numerical value and +the unit, so the previous example can be given as +.PP +.ES +units 2liters quarts +.EE +.PP +to avoid having to quote the first argument. +.PP If the conversion is successful, then .CW "units" will return success (zero) to the calling environment. If you enter non-conformable -units then +units, then .CW "units" will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. .PP When you invoke .CW "units" -with only one argument, it will print out +with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. .PP @@ -536,7 +649,7 @@ .CQ "en_US" locale you will get the US volume measures. In other locales the default values are the US -definitions. If you wish to force different definitions then set the +definitions. If you wish to force different definitions, then set the environment variable .CW "UNITS_ENGLISH" to either @@ -1164,14 +1277,14 @@ .CQ "_" before a conversion has been performed (e.g., immediately after invocation) generates an error: +.aQ .PP -.if \n(.g .tr '\(aq .ES You have: _ ^ No previous result; '_' not set .EE -.if \n(.g .tr '' +.aE .PP Accordingly, .CQ "_" @@ -1365,7 +1478,7 @@ appears after .CQ "(" or after -.CQ "+" +.CQ "+" , then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering .CQ "20\ degrees + -12\ arcmin" . @@ -1504,7 +1617,7 @@ .EE .PP The last example shows the conversion from P graded sand paper, -which is the European standard and may be marked ``P600'' on the back, +which is the European standard and may be marked \*(lQP600\*(rQ on the back, to the USA standard. .PP You can compute the area of a circle using the nonlinear unit, @@ -1810,8 +1923,8 @@ This result might be fine for a baker who has a 1\ 1/2-cup measure (and recognizes the equivalence), but it may not be as useful to someone with more limited set of measures, who does want to do -additional calculations, and only wants to know ``How many 1/2-cup -measures to I need to add?'' After all, that's what was actually +additional calculations, and only wants to know \*(lQHow many 1/2-cup +measures to I need to add?\*(rQ After all, that's what was actually asked. With the .CQ "--show-factor" option, the factor will not be @@ -2395,7 +2508,11 @@ display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group -them into two arguments. See \fICommand Line Use\fP. +them into two arguments. Note also that the +.CQ "--quiet" +option +is enabled by default if you specify \fIfrom-unit\fP on the command line. +See \fICommand Line Use\fP. .PP The default behavior of .CW "units" @@ -2461,7 +2578,6 @@ exponential format with the default eight significant digits). .PP The following options are available: -.PP .TP .BR "-\^c" ", " "-\^-\^check" Check that all units and prefixes defined in the units data file reduce @@ -2471,7 +2587,6 @@ in the current locale are checked. You should always run .CW "units" with this option after modifying a units data file. -.PP .TP .BR "-\^-\^check-verbose" ", " "-\^-\^verbose-check" Like the @@ -2484,7 +2599,6 @@ .CW "units" hangs, then the last unit to be printed has a bad definition. Only definitions active in the current locale are checked. -.PP .TP .BR "-\^d \fIndigits\fP" ", " "-\^-\^digits \fIndigits\fP" Set the number of significant digits in the output to the value @@ -2507,14 +2621,13 @@ (e.g., .CQ "-d\ max" ). Be aware, of course, that -``significant'' here refers only to the \fIdisplay\fP of numbers; if +\*(lQsignificant\*(rQ here refers only to the \fIdisplay\fP of numbers; if results depend on physical constants not known to this precision, the physically meaningful precision may be less than that shown. The .CQ "--digits" option conflicts with the .CQ "--output-format" option. -.PP .TP .BR "-\^e" ", " "-\^-\^exponential" Set the numeric output format to exponential (i.e., scientific @@ -2529,7 +2642,6 @@ option conflicts with the .CQ "--output-format" option. -.PP .TP .BR "-\^o \fIformat\fP" ", " "-\^-\^output-format \fIformat\fP" This option affords complete control over the numeric output format @@ -2589,7 +2701,6 @@ and .CQ "--digits" options. -.PP .TP .BR "-\^f \fIfilename\fP" ", " "-\^-\^file \fIfilename\fP" Instruct @@ -2609,7 +2720,6 @@ will be loaded in addition to any others specified with .CQ "-f" . -.PP .TP .BR "-\^L \fIlogfile\fP" ", " "-\^-\^log \fIlogfile\fP" Save the results of calculations in the file \fIlogfile\fP; this can be @@ -2622,7 +2732,6 @@ is used non-interactively. See \fILogging Calculations\fP for a more detailed description and some examples. -.PP .TP .BR "-\^H \fIfilename\fP" ", " "-\^-\^history \fIfilename\fP" Instruct @@ -2635,19 +2744,16 @@ .CQ ( "-H\ """"" ). This option has no effect if readline is not available. -.PP .TP .BR "-\^h" ", " "-\^-\^help" Print out a summary of the options for .CW "units" . -.PP .TP .BR "-\^m" ", " "-\^-\^minus" Causes .CQ "-" to be interpreted as a subtraction operator. This is the default behavior. -.PP .TP .BR "-\^p" ", " "-\^-\^product" Causes @@ -2660,7 +2766,6 @@ .CQ "-" is treated as a subtraction operator. -.PP .TP .BR "-\^-\^oldstar" Causes @@ -2670,7 +2775,6 @@ .CQ "1/2*3" will equal .CQ "1/6" . -.PP .TP .BR "-\^-\^newstar" Forces @@ -2685,28 +2789,10 @@ .CQ "1/2*3" will equal .CQ "3/2" . -.PP -.TP -.BR "-\^-\^compact" -Give compact output featuring only the conversion factor. This turns -off the -.CQ "--verbose" -option. -.PP -.TP -.BR "-\^q" ", " "-\^-\^quiet" ", " "-\^-\^silent" -Suppress prompting of the user for units and the display of statistics -about the number of units loaded. -.PP -.TP -.BR "-\^n" ", " "-\^-\^nolists" -Disable conversion to unit lists. -.PP .TP .BR "-\^r" ", " "-\^-\^round" When converting to a combination of units given by a unit list, round the value of the last unit in the list to the nearest integer. -.PP .TP .BR "-\^S" ", " "-\^-\^show-factor" When converting to a combination of units specified in a list, @@ -2740,43 +2826,7 @@ whether or not the .CQ "--show-factor" option is given. -.PP -.TP -.BR "-\^s" ", " "-\^-\^strict" -Suppress conversion of units to their reciprocal units. For -example, -.CW "units" -will normally convert hertz to seconds -because these units are reciprocals of each other. The strict option -requires that units be strictly conformable to perform a conversion, and -will give an error if you attempt to convert hertz to seconds. -.PP -.TP -.BR "-\^1" ", " "-\^-\^one-line" -Give only one line of output (the forward conversion). Do not print -the reverse conversion. If a reciprocal conversion is -performed then -.CW "units" -will still print the ``reciprocal -conversion'' line. -.PP -.TP -.BR "-\^t" ", " "-\^-\^terse" -Give terse output when converting units. This option can be used when -calling -.CW "units" -from another program so that the output is easy to -parse. This option has the combined -effect of these options: -.CQ "--strict" -.CQ "--quiet" -.CQ "--one-line" -.CQ "--compact" . -When combined with -.CQ "--version" -it produces -a display showing only the program name and version number. -.PP +.IP .TP .BR "-\^v" ", " "-\^-\^verbose" Give slightly more verbose output when converting units. When combined @@ -2789,7 +2839,6 @@ produces a more detailed output, equivalent to the .CQ "--info" option. -.PP .TP .BR "-\^V" ", " "-\^-\^version" Print the program version number, tell whether the @@ -2798,12 +2847,12 @@ give the locale, the location of the default units data file, and the location of the personal units data file; indicate if the personal units data file does not exist. -.PP +.IP When given in combination with the .CQ "--terse" option, the program prints only the version number and exits. -.PP +.IP When given in combination with the .CQ "--verbose" option, the @@ -2812,7 +2861,6 @@ option has the same effect as the .CQ "--info" option below. -.PP .TP .BR "-\^I" ", " "-\^-\^info" Print the information given with the @@ -2832,7 +2880,7 @@ variable and information about the related locale map are also given. This option is usually of interest only to developers and administrators, but it can sometimes be useful for troubleshooting. -.PP +.IP Combining the .CQ "--version" and @@ -2840,27 +2888,214 @@ options has the same effect as giving .CQ "--info" . -.PP .TP .BR "-\^U" ", " "-\^-\^unitsfile" Print the location of the default units data file and exit; if the file -cannot be found, print ``Units data file not found''. -.PP +cannot be found, print \*(lQUnits data file not found\*(rQ. .TP .BR "-\^u (gauss[ian]|esu|emu)" ", " "-\^-\^units (gauss[ian]|esu|emu)" Specify a CGS units system: Gaussian, ESU, or EMU. -.PP .TP .BR "-\^l \fIlocale\fP" ", " "-\^-\^locale \fIlocale\fP" -Print the information given with the -.CQ "--version" -option, show the Force a specified locale such as .CQ "en_GB" to get British definitions by default. This overrides the locale determined from system settings or environment variables. See \fILocale\fP for a description of locale format. +.TP +.BR "-\^n" ", " "-\^-\^nolists" +Disable conversion to unit lists. +.TP +.BR "-\^s" ", " "-\^-\^strict" +Suppress conversion of units to their reciprocal units. For +example, +.CW "units" +will normally convert hertz to seconds +because these units are reciprocals of each other. The strict option +requires that units be strictly conformable to perform a conversion, and +will give an error if you attempt to convert hertz to seconds. +.TP +.BR "-\^1" ", " "-\^-\^one-line" +Give only one line of output (the forward conversion); do not print +the reverse conversion. If a reciprocal conversion is +performed, then +.CW "units" +will still print the \*(lQreciprocal +conversion\*(rQ line. +.TP +.BR "-\^t" ", " "-\^-\^terse" +Print only a single conversion factor. This option can be used when +calling +.CW "units" +from another program so that the output is easy to +parse. This option has the combined +effect of these options: +.CQ "--strict" +.CQ "--quiet" +.CQ "--one-line" +.CQ "--compact" . +When combined with +.CQ "--version" +it produces +a display showing only the program name and version number. +.TP +.BR "-\^-\^compact" +Give compact output featuring only the conversion factor; the +multiplication and division signs are not shown, and there is no leading +whitespace. If you convert to a unit list, then the output is a +semicolon separated list of factors. +This turns off the +.CQ "--verbose" +option. +.TP +.BR "-\^q" ", " "-\^-\^quiet" ", " "-\^-\^silent" +Suppress the display of statistics about the number of units loaded, +any messages printed by the units database, +and the prompting of the user for units. This option does not +affect how +.CW "units" +displays the results. This option is +turned on by default if you invoke +.CW "units" +with a unit +expression on the command line. +.IP +.SH OUTPUT STYLES +The output can be tweaked in various ways using command line options. +With no options, the output looks like this +.PP +.ES +$ units +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23ft +You want: m + * 7.0104 + / 0.14264521 +You have: m +You want: ft;in + 3 ft + 3.3700787 in +.EE +.PP +This is arguably a bit cryptic; the +.CQ "--verbose" +option makes clear what the output means: +.PP +.ES +$ units --verbose +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23 ft +You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m +You have: meter +You want: ft;in + meter = 3 ft + 3.3700787 in +.EE +.PP +The +.CQ "--quiet" +option suppresses the clutter displayed when +.CW "units" +starts, as well as the prompts to the user. +This option is enabled by default when you +give units on the command line. +.PP +.ES +$ units --quiet +23 ft +m + * 7.0104 + / 0.14264521 + +$ units 23ft m + * 7.0104 + / 0.14264521 +.EE +.PP +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display just a +single line showing the forward conversion: +.aQ +.PP +.ES +$ units --compact 23ft m +7.0104 +0.14264521 + +$ units --compact m 'ft;in' +3;3.3700787 + +$ units --one-line 23ft m + * 7.0104 + +$ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + +$ units --one-line 23ft kg +conformability error + 7.0104 m + 1 kg +.EE +.PP +Note that when converting to a unit list, the +.CQ "--compact" +option displays a semicolon separated list of results. Also be aware +that the +.CQ "one-line" +option doesn't live up to its name if you +execute a reciprocal conversion or if you get a conformability error. +The former case can be prevented using the +.CQ "--strict" +option, +which suppresses reciprocal conversions. +Similarly you can suppress unit list conversion using +.CQ "--nolists" . +It is impossible to prevent +the three line error output. +.PP +.ES +$ units --compact --nolists m 'ft;in' +Error in 'ft;in': Parse error + +$ units --one-line --strict 23ft 1/m +.EE +.PP +The various style options can be combined appropriately. The ultimate +combination is the +.CQ "--terse" +option, which combines +.CQ "--strict" , +.CQ "--quiet" , +.CQ "--one-line" , +and +.CQ "--compact" +to produce the minimal output, +just a single number for regular conversions and a semicolon +separated list for conversion to unit lists. This will likely be the +best choice for programs that want to call +.CW "units" +and then +process its result. +.PP +.ES +$ units --terse 23ft m +7.0104 + +$ units --terse m 'ft;in' +3;3.3700787 + +$ units --terse 23ft 1/m +conformability error +7.0104 m +1 / m +.EE +.aE .PP .SH ADDING YOUR OWN DEFINITIONS .SS Units Data Files @@ -3101,7 +3336,7 @@ .CQ "/" characters, be sure they are protected by parentheses. If you define -.CQ "half- 1/2" +.CQ "half- 1/2" , then .CQ "halfmeter" would be equivalent to @@ -3282,7 +3517,7 @@ parameter value of 900\ mm for comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If -you give other values without units then the definition will be ignored +you give other values without units, then the definition will be ignored and you will get an error message. .PP Although the units, domain, and range specifications are optional, it's @@ -3432,6 +3667,7 @@ arbitrary combination of units, as well as the square and cube of that combination; a warning is given if any of these tests fail. For example, +.aQ .PP .ES Warning: function 'squirt(x)' defined as 'sqrt(x)' @@ -3439,6 +3675,7 @@ squirt(7(kg K)^1): Unit not a root squirt(7(kg K)^3): Unit not a root .EE +.aE .PP Running .CW "units\ --check" @@ -3458,10 +3695,12 @@ Running .CW "units\ --check" would give the error message +.aQ .PP .ES Table 'ansicoated' lacks unique inverse around entry 800 .EE +.aE .PP Although the inverse is not well defined in this region, it's not really an error. Viewing such error messages can be tedious, and if there are @@ -3787,7 +4026,7 @@ .EE .PP .SS Precision -The meaning of ``precision'' depends on the format type. With +The meaning of \*(lQprecision\*(rQ depends on the format type. With .CQ "g" or .CQ "G" , @@ -3997,7 +4236,7 @@ environment variable does \fInot\fP equal any of the list values. .PP The inch has long been a customary measure of length in many places. -The word comes from the Latin \fIuncia\fP meaning ``one twelfth,'' +The word comes from the Latin \fIuncia\fP meaning \*(lQone twelfth,\*(rQ referring to its relationship with the foot. By the 20th century, the inch was officially defined in English-speaking countries relative to the yard, but until 1959, the yard differed slightly among those @@ -4038,7 +4277,7 @@ the appropriate section. If .CW "INCH_UNIT" is unset or is not set to -one of the four values listed then +one of the four values listed, then .CW "units" will run the last block. In this case that block uses the @@ -4055,7 +4294,7 @@ .CW "units" invocation and do not persist. So if the example above were preceded by -.CQ "!set INCH_UNIT france" +.CQ "!set INCH_UNIT france" , then this would make .CQ "france" the @@ -4106,7 +4345,7 @@ .CQ "!var" or .CQ "!varnot" -is undefined +is undefined, then .CW "units" prints an error message and ignores the @@ -4123,7 +4362,6 @@ The .CW "units" program uses the following environment variables: -.PP .TP .BR "HOME" Specifies the location of your home directory; it is used by @@ -4151,7 +4389,6 @@ Vista and Windows\ 7) or .CQ "C:\eDocuments\ and\ Settings\e\fIusername\fP" (Windows\ XP). -.PP .TP .BR "LC_CTYPE, LANG" Checked to determine the locale if @@ -4159,7 +4396,6 @@ cannot obtain it from the operating system. Sections of the standard units data file are specific to certain locales. -.PP .TP .BR "MYUNITSFILE" Specifies your personal units data file. If this variable exists, @@ -4171,7 +4407,6 @@ loaded if any data files are given using the .CQ "-f" option. -.PP .TP .BR "PAGER" Specifies the pager to use for help and for displaying the conformable @@ -4189,7 +4424,6 @@ .CW "emacs" , or .CW "vi" . -.PP .TP .BR "UNITS_ENGLISH" Set to either @@ -4198,7 +4432,6 @@ .CQ "GB" to choose United States or British volume definitions, overriding the default from your locale. -.PP .TP .BR "UNITSFILE" Specifies the units data file to use (instead of the default). @@ -4212,7 +4445,6 @@ .CQ "-f" option is given with the empty string .CQ ( "units\ -f\ """"" ). -.PP .TP .BR "UNITSLOCALEMAP" Windows only; this variable has no effect on Unix-like systems. @@ -4225,7 +4457,6 @@ .CW "UNITSFILE" environment variable, and that location does not also contain the locale map file. -.PP .TP .BR "UNITS_SYSTEM" This environment variable is used in the standard data file to select @@ -4237,7 +4468,7 @@ .CQ "si" . The default is .CQ "si" . -.PP +.IP .SH DATA FILES The .CW "units" @@ -4320,53 +4551,58 @@ and ending with .CQ "!endutf8" . .PP -When +The non-ASCII definitions are loaded only if the platform and the locale +support UTF-8. Platform support is determined when .CW "units" -starts, it checks the locale to determine the -character set. If +is compiled; the locale is checked at every invocation of +.CW "units" . +To see if your version of .CW "units" -is compiled with Unicode support and -definitions; otherwise these definitions are ignored. When Unicode -support is active, -.CW "units" -will check every line of all of the -units data files for invalid or non-printing UTF-8 sequences; if such -sequences occur, -.CW "units" -ignores the entire line. In addition -to checking validity, -.CW "units" -determines the display width of -non-ASCII characters to ensure proper positioning of the pointer in some -error messages and to align columns for the +includes +Unicode support, invoke the program with the +.CQ "--version" +option. +.PP +When Unicode support is available, +.CW "units" +checks every line +within UTF-8 blocks in all of the units data files for invalid or +non-printing UTF-8 sequences; if such sequences occur, +.CW "units" +ignores the entire line. In addition to checking validity, +.CW "units" +determines the display width of non-ASCII characters to +ensure proper positioning of the pointer in some error messages and to +align columns for the .CQ "search" and .CQ "?" commands. .PP -At present, +As of early 2019, Microsoft Windows provides limited support for UTF-8 +in console applications, and accordingly, .CW "units" -does not support Unicode under Microsoft -Windows. The UTF-16 and UTF-32 encodings are not supported on any -systems. -.PP -If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within +does not +support Unicode on Windows. The UTF-16 and UTF-32 encodings are not +supported on any platforms. +.PP +If Unicode support is available and definitions that contain non-ASCII +UTF-8 characters are added to a units data file, those definitions +should be enclosed within .CQ "!utf8" \*(El .CQ "!endutf8" -to ensure that they are only loaded when -Unicode support is available. As usual, the +to ensure +that they are only loaded when Unicode support is available. As usual, +the .CQ "!" -must appear as -the first character on the line. As discussed in -\fIUnits Data Files\fP, it's usually best to put such definitions in -supplemental data files linked by an +must appear as the first character on the line. As +discussed in \fIUnits Data Files\fP, it's usually best to put such +definitions in supplemental data files linked by an .CQ "!include" -command or in a -personal units data file. +command or in a personal units data file. .PP -When Unicode support is not active, +When Unicode support is not available, .CW "units" makes no assumptions about character encoding, except that characters in the range 00\-7F @@ -4377,14 +4613,15 @@ characters in definitions when running .CW "units" under Windows, -you can use a character set such as Windows ``ANSI'' (code page 1252 in -the US and Western Europe). You can even use UTF-8, though some -messages may be improperly aligned, and -.CW "units" -will not detect -invalid UTF-8 sequences. If you use UTF-8 encoding when Unicode support -is not active, you should place any definitions with non-ASCII -characters \fIoutside\fP +you can use a character set such as Windows \*(lQANSI\*(rQ (code page 1252 in +the US and Western Europe); if this is done, the console code page must +be set to the same encoding for the characters to display properly. +You can even use UTF-8, though some messages may be improperly aligned, +and +.CW "units" +will not detect invalid UTF-8 sequences. If you use +UTF-8 encoding when Unicode support is not available, you should place any +definitions with non-ASCII characters \fIoutside\fP .CQ "!utf8" \*(El .CQ "!endutf8" @@ -4430,7 +4667,7 @@ commands. .PP If you type a few characters and then hit \fIESC\fP followed by -.CI "?" +.CI "?" , then .CW "units" will display a list of all the units that @@ -4569,23 +4806,19 @@ write to standard output. .PP The following options are available: -.PP .TP .BR "-\^h" ", " "-\^-\^help" Print a summary of the options for .CW "units_cur" . -.PP .TP .BR "-\^V" ", " "-\^-\^version" Print the .CW "units_cur" version number. -.PP .TP .BR "-\^v" ", " "-\^-\^verbose" Give slightly more verbose output when attempting to update currency exchange rates. -.PP .TP .BR "-\^s \fIsource\fP" ", " "-\^-\^source \fIsource\fP" Specify the source for currency exchange rates; currently supported @@ -4602,7 +4835,6 @@ an API key to be given with the .CQ "-k" option. -.PP .TP .BR "-\^b \fIbase\fP" ", " "-\^-\^base \fIbase\fP" Set the base currency (when allowed by the site providing the data). @@ -4617,20 +4849,17 @@ prompt. This option is ignored if the source does not allow specifying the base currency. (Currently only floatrates supports this option.) -.PP .TP .BR "-\^k \fIkey\fP" ", " "-\^-\^key \fIkey\fP" Set the API key to \fIkey\fP for sources that require it. -.PP +.IP .SH DATABASE COMMAND SYNTAX .TP .BR "\fIunit\fP \fIdefinition\fP" Define a regular unit. -.PP .TP .BR "\fIprefix\fP- \fIdefinition\fP" Define a prefix. -.PP .TP .BR "\fIfuncname\fP(\fIvar\fP) noerror units=[\fIin-\^units\fP,\fIout-units\fP] domain=[\fIx1\fP,\fIx2\fP] range=[\fIy1\fP,\fIy2\fP] \fIdefinition(var)\fP ; \fIinverse(funcname)\fP" Define a nonlinear unit or unit function. The four optional keywords @@ -4641,7 +4870,6 @@ .CW "domain=" can appear in any order. The definition of the inverse is optional. -.PP .TP .BR "\fItabname\fP[\fIout-\^units\fP] noerror \fIpair-list\fP" Define a piecewise linear unit. The pair list gives the points on the @@ -4649,65 +4877,54 @@ .CW "noerror" keyword is optional. -.PP .TP .BR "!endlocale" End a block of definitions beginning with .CQ "!locale" -.PP .TP .BR "!endutf8" End a block of definitions begun with .CQ "!utf8" -.PP .TP .BR "!endvar" End a block of definitions begun with .CQ "!var" or .CQ "!varnot" -.PP .TP .BR "!include \fIfile\fP" Include the specified file. -.PP .TP .BR "!locale \fIvalue\fP" Load the following definitions only of the locale is set to \fIvalue\fP. -.PP .TP .BR "!message \fItext\fP" Display \fItext\fP when the database is read unless the quiet option .CQ ( "-q" ) -is enabled. If you omit \fItext\fP then units +is enabled. If you omit \fItext\fP, then units will display a blank line. Messages will also appear in the log file. -.PP .TP .BR "!prompt \fItext\fP" Prefix the .CQ "You\ have:" prompt with the specified text. If -you omit \fItext\fP then any existing prefix is canceled. -.PP +you omit \fItext\fP, then any existing prefix is canceled. .TP .BR "!set \fIvariable\fP \fIvalue\fP" Sets the environment variable, \fIvariable\fP, to the specified value \fIonly if\fP it is not already set. -.PP .TP .BR "!unitlist \fIalias\fP \fIdefinition\fP" Define a unit list alias. -.PP .TP .BR "!utf8" Load the following definitions only if .CW "units" is running with UTF-8 enabled. -.PP .TP .BR "!var \fIenvar\fP \fIvalue-\^list\fP" Load the block of definitions that follows only if the environment @@ -4716,7 +4933,6 @@ .CW "units" prints an error message and ignores the block of definitions. -.PP .TP .BR "!varnot \fIenvar\fP \fIvalue-\^list\fP" Load the block of definitions that follows only if the environment @@ -4724,8 +4940,9 @@ space-separated value list. If \fIenvar\fP is not set, .CW "units" prints an error message and ignores the block of definitions. -.PP -.SH GNU FREE DOCUMENTATION LICENSE +.IP .SH FILES @DATAFILE@ \(em the standard units data file .SH AUTHOR +.I units +was written by Adrian Mariano Binary files /tmp/tmpgq6Yn7/Td5U3S8vc7/units-2.18/units.pdf and /tmp/tmpgq6Yn7/9r9O8hnvol/units-2.19/units.pdf differ diff -Nru units-2.18/units.texinfo units-2.19/units.texinfo --- units-2.18/units.texinfo 2018-10-20 14:02:15.000000000 +0000 +++ units-2.19/units.texinfo 2019-05-29 00:16:22.000000000 +0000 @@ -9,13 +9,16 @@ @set VERSION 2.18 @c %**end of header +@c for AUTHOR section +@c man program units + @c ifman .\" @copying This manual is for GNU Units (version @value{VERSION}), which performs units conversions and units calculations. Copyright @copyright{} 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007, -2011--2018 Free Software Foundation, Inc. +2011--2019 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -41,11 +44,9 @@ @end direntry @c end noman -@c man .TH UNITS 1 "20 October 2018" +@c man .TH UNITS 1 "19 March 2019" @c man .SH NAME @c man units \(em unit conversion and calculation program -@c nroff uses 'o' for bullets -@c man .if n .tr \(bu* @c man .\" hack to prevent very thick fraction bars with gropdf @c man .\" '-1' makes thickness proportional to type size @c man .if \n(.g .if t \Z@\D't -1'@ @@ -88,6 +89,7 @@ * Using CGS Units:: Using CGS units: Gaussian, ESU, or EMU * Logging Calculations:: Logging conversions and calculations in a file. * Invoking Units:: Command line options. +* Output Styles:: Different ways units can print the output. * Defining Your Own Units:: Adding your own unit definitions * Numeric Output Format:: How to change the output format * Localization:: How to define and use regional unit names. @@ -189,7 +191,7 @@ meters to feet, type @kbd{10 meters}. Next, @command{units} will print @w{@samp{You want:}}. You should type the units you want to convert @emph{to}. To convert to feet, you would type @kbd{feet}. If the -@command{readline} library was compiled in then @key{tab} will +@command{readline} library was compiled in, then @key{tab} will complete unit names. @xref{Readline Support}, for more information about @command{readline}. To quit the program type @kbd{quit} or @kbd{exit} at either prompt. @@ -412,12 +414,22 @@ The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. +@command{units} does not require a space between a numerical value and +the unit, so the previous example can be given as + +@example +units 2liters quarts +@end example + +@noindent +to avoid having to quote the first argument. + If the conversion is successful, then @command{units} will return success (zero) to the calling environment. If you enter non-conformable -units then @command{units} will print a message giving the reduced form of +units, then @command{units} will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. -When you invoke @command{units} with only one argument, it will print out +When you invoke @command{units} with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. @@ -507,7 +519,7 @@ the @samp{en_GB} locale you will get the British volume measures. If it runs in the @samp{en_US} locale you will get the US volume measures. In other locales the default values are the US -definitions. If you wish to force different definitions then set the +definitions. If you wish to force different definitions, then set the environment variable @env{UNITS_ENGLISH} to either @samp{US} or @samp{GB} to set the desired definitions independent of the locale. @@ -914,6 +926,7 @@ @node Built-in Functions @section Built-in Functions @cindex functions, built in +@cindex built-in functions Several built-in functions are provided: @samp{sin}, @samp{cos}, @samp{tan}, @samp{ln}, @samp{log}, @samp{exp}, @samp{acos}, @@ -1079,7 +1092,6 @@ immediately after invocation) generates an error: @set codequoteundirected -@c man .if \n(.g .tr '\(aq @example @group You have: _ @@ -1087,7 +1099,6 @@ No previous result; '_' not set @end group @end example -@c man .if \n(.g .tr '' @clear codequoteundirected @noindent @@ -1309,7 +1320,7 @@ When @samp{-} is used as a unary operator it negates its operand. Regardless of the @command{units} options, if @samp{-} appears after @samp{(} or after -@samp{+} then it will act as a negation operator. So you can always compute 20 +@samp{+}, then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering @samp{20@tie{}degrees + -12@tie{}arcmin}. You must use this construction when you define new units because you cannot know what options will be in force when your definition is @@ -2443,7 +2454,9 @@ display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group -them into two arguments. @xref{Command Line Use}. +them into two arguments. Note also that the @option{--quiet} option +is enabled by default if you specify @var{from-unit} on the command line. +@xref{Command Line Use}. The default behavior of @command{units} can be changed by various options given on the command line. In most cases, the options may be @@ -2633,24 +2646,6 @@ the usual rules of algebra: the precedence of @samp{*} is the same as the precedence of @samp{/}, so that @samp{1/2*3} will equal @samp{3/2}. -@item --compact -@opindex --compact @r{(option for} @command{units}@r{)} -Give compact output featuring only the conversion factor. This turns -off the @option{--verbose} option. - -@item -q -@itemx --quiet -@itemx --silent -@opindex -q @r{(option for} @command{units}@r{)} -@opindex --quiet @r{(option for} @command{units}@r{)} -@opindex --silent @r{(option for} @command{units}@r{)} -Suppress prompting of the user for units and the display of statistics -about the number of units loaded. - -@item -n -@itemx --nolists -Disable conversion to unit lists. - @item -r @itemx --round When converting to a combination of units given by a unit list, round @@ -2675,35 +2670,6 @@ will always be shown as @samp{2 * 3|4@tie{}cup} whether or not the @option{--show-factor} option is given. -@item -s -@itemx --strict -@opindex -s @r{(option for} @command{units}@r{)} -@opindex --strict @r{(option for} @command{units}@r{)} -Suppress conversion of units to their reciprocal units. For -example, @command{units} will normally convert hertz to seconds -because these units are reciprocals of each other. The strict option -requires that units be strictly conformable to perform a conversion, and -will give an error if you attempt to convert hertz to seconds. - -@item -1 -@itemx --one-line -@opindex -1 @r{(option for} @command{units}@r{)} -@opindex --one-line @r{(option for} @command{units}@r{)} -Give only one line of output (the forward conversion). Do not print -the reverse conversion. If a reciprocal conversion is -performed then @command{units} will still print the ``reciprocal -conversion'' line. - -@item -t -@itemx --terse -@opindex -t @r{(option for} @command{units}@r{)} -@opindex --terse @r{(option for} @command{units}@r{)} -Give terse output when converting units. This option can be used when -calling @command{units} from another program so that the output is easy to -parse. This option has the combined -effect of these options: @option{--strict} @option{--quiet} @option{--one-line} -@option{--compact}. When combined with @option{--version} it produces -a display showing only the program name and version number. @item -v @itemx --verbose @@ -2763,7 +2729,6 @@ @item -l @var{locale} @itemx --locale @var{locale} -Print the information given with the @option{--version} option, show the @opindex --locale @r{(option for} @command{units}@r{)} @opindex -l @r{(option for} @command{units}@r{)} Force a specified locale such as @samp{en_GB} to get British @@ -2771,8 +2736,202 @@ system settings or environment variables. @xref{Locale}, for a description of locale format. +@item -n +@itemx --nolists +Disable conversion to unit lists. + +@item -s +@itemx --strict +@opindex -s @r{(option for} @command{units}@r{)} +@opindex --strict @r{(option for} @command{units}@r{)} +Suppress conversion of units to their reciprocal units. For +example, @command{units} will normally convert hertz to seconds +because these units are reciprocals of each other. The strict option +requires that units be strictly conformable to perform a conversion, and +will give an error if you attempt to convert hertz to seconds. + +@item -1 +@itemx --one-line +@opindex -1 @r{(option for} @command{units}@r{)} +@opindex --one-line @r{(option for} @command{units}@r{)} +Give only one line of output (the forward conversion); do not print +the reverse conversion. If a reciprocal conversion is +performed, then @command{units} will still print the ``reciprocal +conversion'' line. + +@item -t +@itemx --terse +@opindex -t @r{(option for} @command{units}@r{)} +@opindex --terse @r{(option for} @command{units}@r{)} +Print only a single conversion factor. This option can be used when +calling @command{units} from another program so that the output is easy to +parse. This option has the combined +effect of these options: @option{--strict} @option{--quiet} @option{--one-line} +@option{--compact}. When combined with @option{--version} it produces +a display showing only the program name and version number. + +@item --compact +@opindex --compact @r{(option for} @command{units}@r{)} +Give compact output featuring only the conversion factor; the +multiplication and division signs are not shown, and there is no leading +whitespace. If you convert to a unit list, then the output is a +semicolon separated list of factors. +This turns off the @option{--verbose} option. + +@item -q +@itemx --quiet +@itemx --silent +@opindex -q @r{(option for} @command{units}@r{)} +@opindex --quiet @r{(option for} @command{units}@r{)} +@opindex --silent @r{(option for} @command{units}@r{)} +Suppress the display of statistics about the number of units loaded, +any messages printed by the units database, +and the prompting of the user for units. This option does not +affect how @command{units} displays the results. This option is +turned on by default if you invoke @command{units} with a unit +expression on the command line. + @end table +@node Output Styles +@chapter Output Styles +The output can be tweaked in various ways using command line options. +With no options, the output looks like this + +@example +@group +$ units +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23ft +You want: m + * 7.0104 + / 0.14264521 +You have: m +You want: ft;in + 3 ft + 3.3700787 in +@end group +@end example + +@noindent +This is arguably a bit cryptic; the @option{--verbose} +option makes clear what the output means: + +@example +@group +$ units --verbose +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23 ft +You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m +You have: meter +You want: ft;in + meter = 3 ft + 3.3700787 in +@end group +@end example + +@noindent +The @option{--quiet} option suppresses the clutter displayed when +@command{units} starts, as well as the prompts to the user. +This option is enabled by default when you +give units on the command line. + +@example +@group +$ units --quiet +23 ft +m + * 7.0104 + / 0.14264521 + +$ units 23ft m + * 7.0104 + / 0.14264521 +@end group +@end example + +@noindent +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display just a +single line showing the forward conversion: + +@set codequoteundirected +@example +@group +$ units --compact 23ft m +7.0104 +0.14264521 + +$ units --compact m 'ft;in' +3;3.3700787 + +$ units --one-line 23ft m + * 7.0104 + +$ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + +$ units --one-line 23ft kg +conformability error + 7.0104 m + 1 kg +@end group +@end example + +@noindent +Note that when converting to a unit list, the @option{--compact} +option displays a semicolon separated list of results. Also be aware +that the +@option{one-line} option doesn't live up to its name if you +execute a reciprocal conversion or if you get a conformability error. +The former case can be prevented using the @option{--strict} option, +which suppresses reciprocal conversions. +Similarly you can suppress unit list conversion using +@option{--nolists}. +It is impossible to prevent +the three line error output. + +@example +@group +$ units --compact --nolists m 'ft;in' +Error in 'ft;in': Parse error + +$ units --one-line --strict 23ft 1/m +@end group +@end example + +@noindent +The various style options can be combined appropriately. The ultimate +combination is the @option{--terse} option, which combines +@option{--strict}, @option{--quiet}, @option{--one-line}, +and @option{--compact} to produce the minimal output, +just a single number for regular conversions and a semicolon +separated list for conversion to unit lists. This will likely be the +best choice for programs that want to call @command{units} and then +process its result. + +@example +@group +$ units --terse 23ft m +7.0104 + +$ units --terse m 'ft;in' +3;3.3700787 + +$ units --terse 23ft 1/m +conformability error +7.0104 m +1 / m +@end group +@end example +@clear codequoteundirected + + @node Defining Your Own Units @chapter Adding Your Own Definitions @@ -2958,7 +3117,7 @@ @noindent A unit that ends with a @samp{-} character is a prefix. If a prefix definition contains any @samp{/} characters, be sure they are protected -by parentheses. If you define @samp{half- 1/2} then @samp{halfmeter} +by parentheses. If you define @samp{half- 1/2}, then @samp{halfmeter} would be equivalent to @samp{1 / (2@tie{}meter)}. @node Defining Nonlinear Units @@ -3129,7 +3288,7 @@ parameter value of 900@tie{}mm for comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If -you give other values without units then the definition will be ignored +you give other values without units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, it's @@ -3839,7 +3998,7 @@ When @command{units} reads the above definitions it will check the environment variable @env{INCH_UNIT} and load only the definitions for the appropriate section. If @env{INCH_UNIT} is unset or is not set to -one of the four values listed then @command{units} will run the last +one of the four values listed, then @command{units} will run the last block. In this case that block uses the @samp{!message} command to display a warning message. Alternatively that block could set default values. @@ -3849,7 +4008,7 @@ environment variable @emph{only if it is not already set}; these settings are only for the current @command{units} invocation and do not persist. So if the example above were preceded by -@samp{!set INCH_UNIT france} then this would make @samp{france} the +@samp{!set INCH_UNIT france}, then this would make @samp{france} the default value for @env{INCH_UNIT}. If the user had set the variable in the environment before invoking @command{units}, then @command{units} would use the user's value. @@ -3884,7 +4043,7 @@ @env{INCH_UNIT} was not set by one of the other commands or by the user. -If the variable given after @samp{!var} or @samp{!varnot} is undefined +If the variable given after @samp{!var} or @samp{!varnot} is undefined, then @command{units} prints an error message and ignores the definitions that follow. Use @samp{!set} to create defaults to prevent this situation from arising. The @option{-c} @@ -4035,31 +4194,35 @@ U+007F); definitions using non-ASCII characters appear in blocks beginning with @samp{!utf8} and ending with @samp{!endutf8}. -When @command{units} starts, it checks the locale to determine the -character set. If @command{units} is compiled with Unicode support and -definitions; otherwise these definitions are ignored. When Unicode -support is active, @command{units} will check every line of all of the -units data files for invalid or non-printing UTF-8 sequences; if such -sequences occur, @command{units} ignores the entire line. In addition -to checking validity, @command{units} determines the display width of -non-ASCII characters to ensure proper positioning of the pointer in some -error messages and to align columns for the @samp{search} and @samp{?} -commands. - -At present, @command{units} does not support Unicode under Microsoft -Windows. The UTF-16 and UTF-32 encodings are not supported on any -systems. - -If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within @samp{!utf8} -@dots{} @samp{!endutf8} to ensure that they are only loaded when -Unicode support is available. As usual, the @samp{!} must appear as -the first character on the line. As discussed in -@ref{Units Data Files}, it's usually best to put such definitions in -supplemental data files linked by an @samp{!include} command or in a -personal units data file. +The non-ASCII definitions are loaded only if the platform and the locale +support @w{UTF-8}. Platform support is determined when @command{units} +is compiled; the locale is checked at every invocation of +@command{units}. To see if your version of @command{units} includes +Unicode support, invoke the program with the @option{--version} option. + +When Unicode support is available, @command{units} checks every line +within UTF-8 blocks in all of the units data files for invalid or +non-printing UTF-8 sequences; if such sequences occur, @command{units} +ignores the entire line. In addition to checking validity, +@command{units} determines the display width of non-ASCII characters to +ensure proper positioning of the pointer in some error messages and to +align columns for the @samp{search} and @samp{?} commands. + +As of early 2019, Microsoft Windows provides limited support for UTF-8 +in console applications, and accordingly, @command{units} does not +support Unicode on Windows. The UTF-16 and UTF-32 encodings are not +supported on any platforms. + +If Unicode support is available and definitions that contain non-ASCII +UTF-8 characters are added to a units data file, those definitions +should be enclosed within @samp{!utf8} @dots{} @samp{!endutf8} to ensure +that they are only loaded when Unicode support is available. As usual, +the @samp{!} must appear as the first character on the line. As +discussed in @ref{Units Data Files}, it's usually best to put such +definitions in supplemental data files linked by an @samp{!include} +command or in a personal units data file. -When Unicode support is not active, @command{units} makes no assumptions +When Unicode support is not available, @command{units} makes no assumptions about character encoding, except that characters in the range 00--7F hexadecimal correspond to ASCII encoding. Non-ASCII characters are simply sequences of bytes, and have no special meanings; for definitions @@ -4067,12 +4230,13 @@ with this assumption. For example, if you wish to use non-ASCII characters in definitions when running @command{units} under Windows, you can use a character set such as Windows ``ANSI'' (code page 1252 in -the US and Western Europe). You can even use UTF-8, though some -messages may be improperly aligned, and @command{units} will not detect -invalid UTF-8 sequences. If you use UTF-8 encoding when Unicode support -is not active, you should place any definitions with non-ASCII -characters @emph{outside} @samp{!utf8} @dots{} @samp{!endutf8} -blocks---otherwise, they will be ignored. +the US and Western Europe); if this is done, the console code page must +be set to the same encoding for the characters to display properly. +You can even use UTF-8, though some messages may be improperly aligned, +and @command{units} will not detect invalid UTF-8 sequences. If you use +UTF-8 encoding when Unicode support is not available, you should place any +definitions with non-ASCII characters @emph{outside} @samp{!utf8} +@dots{} @samp{!endutf8} blocks---otherwise, they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) used in @@ -4102,7 +4266,7 @@ @cindex unit completion using @samp{?} (@command{readline} only) @cindex completion, unit, using @samp{?} (@command{readline} only) If you type a few characters and then hit @key{ESC} followed by -@kbd{?} then @command{units} will display a list of all the units that +@kbd{?}, then @command{units} will display a list of all the units that start with the characters typed. For example, if you type @kbd{metr} and then request completion, you will see something like this: @cindex unit name completion @@ -4300,13 +4464,13 @@ @item !message @var{text} Display @var{text} when the database is read unless the quiet -option (@option{-q}) is enabled. If you omit @var{text} then units +option (@option{-q}) is enabled. If you omit @var{text}, then units will display a blank line. Messages will also appear in the log file. @item !prompt @var{text} Prefix the @w{@samp{You have:}} prompt with the specified text. If -you omit @var{text} then any existing prefix is canceled. +you omit @var{text}, then any existing prefix is canceled. @item !set @var{variable} @var{value} Sets the environment variable, @var{variable}, to the specified diff -Nru units-2.18/units.txt units-2.19/units.txt --- units-2.18/units.txt 2018-10-20 14:03:43.000000000 +0000 +++ units-2.19/units.txt 2019-05-29 00:32:32.000000000 +0000 @@ -53,7 +53,7 @@ converting from. For example, if you want to convert ten meters to feet, type '10 meters'. Next, 'units' will print 'You want:'. You should type the units you want to convert to. To convert to feet, you - would type 'feet'. If the 'readline' library was compiled in then tab + would type 'feet'. If the 'readline' library was compiled in, then tab will complete unit names. See Readline Support for more information about 'readline'. To quit the program type 'quit' or 'exit' at either prompt. @@ -166,7 +166,7 @@ contexts. They cannot be used as exponents so for example, 'meter^radian' is forbidden. - If you want a list of options you can type '?' at the 'You want:' + If you want a list of options you can type '?' at the 'You want:' prompt. The program will display a list of named units that are con- formable with the unit that you entered at the 'You have:' prompt above. Conformable unit combinations will not appear on this list. @@ -202,14 +202,22 @@ and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. - If the conversion is successful, then 'units' will return success - (zero) to the calling environment. If you enter non-conformable units - then 'units' will print a message giving the reduced form of each unit - and it will return failure (nonzero) to the calling environment. - - When you invoke 'units' with only one argument, it will print out the - definition of the specified unit. It will return failure if the unit - is not defined and success if the unit is defined. + 'units' does not require a space between a numerical value and the + unit, so the previous example can be given as + + units 2liters quarts + + to avoid having to quote the first argument. + + If the conversion is successful, then 'units' will return success + (zero) to the calling environment. If you enter non-conformable + units, then 'units' will print a message giving the reduced form of + each unit and it will return failure (nonzero) to the calling environ- + ment. + + When you invoke 'units' with only one argument, it will print the defi- + nition of the specified unit. It will return failure if the unit is + not defined and success if the unit is defined. UNIT DEFINITIONS The conversion information is read from a units data file that is @@ -277,9 +285,9 @@ twenty percent. By default if 'units' runs in the 'en_GB' locale you will get the British volume measures. If it runs in the 'en_US' locale you will get the US volume measures. In other locales the default val- - ues are the US definitions. If you wish to force different definitions - then set the environment variable 'UNITS_ENGLISH' to either 'US' or - 'GB' to set the desired definitions independent of the locale. + ues are the US definitions. If you wish to force different defini- + tions, then set the environment variable 'UNITS_ENGLISH' to either 'US' + or 'GB' to set the desired definitions independent of the locale. Before 1959, the value of a yard (and other units of measure defined in terms of it) differed slightly among English-speaking countries. In @@ -719,8 +727,8 @@ it a higher precedence than division. When '-' is used as a unary operator it negates its operand. Regard- - less of the 'units' options, if '-' appears after '(' or after '+' then - it will act as a negation operator. So you can always compute 20 + less of the 'units' options, if '-' appears after '(' or after '+', + then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You must use this construction when you define new units because you cannot know what options will be in force when your definition is processed. @@ -817,7 +825,7 @@ 342.76923 The last example shows the conversion from P graded sand paper, which - is the European standard and may be marked ``P600'' on the back, to the + is the European standard and may be marked "P600" on the back, to the USA standard. You can compute the area of a circle using the nonlinear unit, @@ -873,9 +881,9 @@ UNIT LISTS: CONVERSION TO SUMS OF UNITS Outside of the SI, it is sometimes desirable to convert a single unit - to a sum of units--for example, feet to feet plus inches. The - conversion from sums of units was described in Sums and Differences of - Units, and is a simple matter of adding the units with the '+' sign: + to a sum of units--for example, feet to feet plus inches. The conver- + sion from sums of units was described in Sums and Differences of Units, + and is a simple matter of adding the units with the '+' sign: You have: 12 ft + 3 in + 3|8 in You want: ft @@ -941,10 +949,10 @@ You want: ft;in;1|8 in; 12 ft + 3 in + 3|8 in + 0.00096 * 1|8 in - in effect separating the integer and fractional parts of the - coefficient for the last unit. If you instead prefer to round the last - coefficient to an integer you can do this with the '--round' ('-r') - option. With the previous example, the result is + in effect separating the integer and fractional parts of the coeffi- + cient for the last unit. If you instead prefer to round the last coef- + ficient to an integer you can do this with the '--round' ('-r') option. + With the previous example, the result is You have: 12.28126 ft You want: ft;in;1|8 in @@ -1032,10 +1040,10 @@ This result might be fine for a baker who has a 1 1/2-cup measure (and recognizes the equivalence), but it may not be as useful to someone with more limited set of measures, who does want to do additional cal- - culations, and only wants to know ``How many 1/2-cup measures to I need - to add?'' After all, that's what was actually asked. With the - '--show-factor' option, the factor will not be combined with a unity - numerator, so that you get + culations, and only wants to know "How many 1/2-cup measures to I need + to add?" After all, that's what was actually asked. With the '--show- + factor' option, the factor will not be combined with a unity numerator, + so that you get You have: (5+1|4) cup / 3 You want: 1|2 cup;1|3 cup;1|4 cup @@ -1213,15 +1221,14 @@ Conversions Between Different Systems The CGS systems define units that measure the same thing but may have - conflicting dimensions. Furthermore, the dimensions of the - electromagnetic CGS units are never compatible with SI. But if you - measure charge in two different systems you have measured the same - physical thing, so there is a correspondence between the units in the - different systems, and 'units' supports conversions between correspond- - ing units. When running with SI, 'units' defines all of the CGS units - in terms of SI. When you select a CGS system, 'units' defines the SI - units and the other CGS system units in terms of the system you have - selected. + conflicting dimensions. Furthermore, the dimensions of the electromag- + netic CGS units are never compatible with SI. But if you measure + charge in two different systems you have measured the same physical + thing, so there is a correspondence between the units in the different + systems, and 'units' supports conversions between corresponding units. + When running with SI, 'units' defines all of the CGS units in terms of + SI. When you select a CGS system, 'units' defines the SI units and the + other CGS system units in terms of the system you have selected. (Gaussian) You have: statA You want: abA @@ -1233,28 +1240,28 @@ 2.9979246e+10 sqrt_cm^3 sqrt_g / s^2 1 sqrt_cm sqrt_g / s - In the above example, 'units' converts between the current units statA - and abA even though the abA, from the EMU system, has incompatible + In the above example, 'units' converts between the current units statA + and abA even though the abA, from the EMU system, has incompatible dimensions. This works because in Gaussian mode, the abA is defined in terms of the statA, so it does not have the correct definition for EMU; consequently, you cannot convert the abA to its EMU definition. - One challenge of conversion is that because the CGS system has fewer - base units, quantities that have different dimensions in SI may have - the same dimension in a CGS system. And yet, they may not have the - same conversion factor. For example, the unit for the E field and B - fields are the same in the Gaussian system, but the conversion factors - to SI are quite different. This means that correct conversion is only - possible if you keep track of what quantity is being measured. You - cannot convert statV/cm to SI without indicating which type of field - the unit measures. To aid in dimensional analysis, 'units' defines - various dimension units such as LENGTH, TIME, and CHARGE to be the - appropriate dimension in SI. The electromagnetic dimensions such as - B_FIELD or E_FIELD may be useful aids both for conversion and dimen- - sional analysis in CGS. You can convert them to or from CGS in order + One challenge of conversion is that because the CGS system has fewer + base units, quantities that have different dimensions in SI may have + the same dimension in a CGS system. And yet, they may not have the + same conversion factor. For example, the unit for the E field and B + fields are the same in the Gaussian system, but the conversion factors + to SI are quite different. This means that correct conversion is only + possible if you keep track of what quantity is being measured. You + cannot convert statV/cm to SI without indicating which type of field + the unit measures. To aid in dimensional analysis, 'units' defines + various dimension units such as LENGTH, TIME, and CHARGE to be the + appropriate dimension in SI. The electromagnetic dimensions such as + B_FIELD or E_FIELD may be useful aids both for conversion and dimen- + sional analysis in CGS. You can convert them to or from CGS in order to perform SI conversions that in some cases will not work directly due - to dimensional incompatibilities. This example shows how the Gaussian - system uses the same units for all of the fields, but they all have + to dimensional incompatibilities. This example shows how the Gaussian + system uses the same units for all of the fields, but they all have different conversion factors with SI. (Gaussian) You have: statV/cm @@ -1275,9 +1282,9 @@ / 3767303.1 The next example shows that the oersted cannot be converted directly to - the SI unit of magnetic field, A/m, because the dimensions conflict. - We cannot redefine the ampere to make this work because then it would - not convert with the statampere. But you can still do this conversion + the SI unit of magnetic field, A/m, because the dimensions conflict. + We cannot redefine the ampere to make this work because then it would + not convert with the statampere. But you can still do this conversion as shown below. (Gaussian) You have: oersted @@ -1291,8 +1298,8 @@ / 0.012566371 Prompt Prefix - If a unit system is specified with the '--units' option, the selected - system's name is prepended to the 'You have:' prompt as a reminder, + If a unit system is specified with the '--units' option, the selected + system's name is prepended to the 'You have:' prompt as a reminder, e.g., (Gaussian) You have: stC @@ -1304,23 +1311,23 @@ !prompt with no argument in a site or personal units data file. The prompt can - be conditionally suppressed by including such a line within '!var' + be conditionally suppressed by including such a line within '!var' '!endvar' constructs, e.g., !var UNITS_SYSTEM gaussian gauss !prompt !endvar - This might be appropriate if you normally use Gaussian units and find + This might be appropriate if you normally use Gaussian units and find the prefix distracting but want to be reminded when you have selected a different CGS system. LOGGING CALCULATIONS - The '--log' option allows you to save the results of calculations in a - file; this can be useful if you need a permanent record of your work. + The '--log' option allows you to save the results of calculations in a + file; this can be useful if you need a permanent record of your work. For example, the fluid-flow conversion in Complicated Unit Expressions, is lengthy, and if you were to use it in designing a piping system, you - might want a record of it for the project file. If the interactive + might want a record of it for the project file. If the interactive session # Conversion factor A1 for pressure drop @@ -1343,11 +1350,11 @@ The time is written to the log file when the file is opened. - The use of comments can help clarify the meaning of calculations for - the log. The log includes conformability errors between the units at - the 'You have:' and 'You want:' prompts, but not other errors, includ- - ing lack of conformability of items in sums or differences or among - items in a unit list. For example, a conversion between zenith angle + The use of comments can help clarify the meaning of calculations for + the log. The log includes conformability errors between the units at + the 'You have:' and 'You want:' prompts, but not other errors, includ- + ing lack of conformability of items in sums or differences or among + items in a unit list. For example, a conversion between zenith angle and elevation angle could involve You have: 90 deg - (5 deg + 22 min + 9 sec) @@ -1372,15 +1379,15 @@ * 84.630833 / 0.011816024 - The initial entry error (forgetting that minutes have dimension of - time, and that arcminutes must be used for dimensions of angle) does - not appear in the output. When converting to a unit list alias, + The initial entry error (forgetting that minutes have dimension of + time, and that arcminutes must be used for dimensions of angle) does + not appear in the output. When converting to a unit list alias, 'units' expands the alias in the log file. - The 'From:' and 'To:' tags are written to the log file even if the - '--quiet' option is given. If the log file exists when 'units' is - invoked, the new results are appended to the log file. The time is - written to the log file each time the file is opened. The '--log' + The 'From:' and 'To:' tags are written to the log file even if the + '--quiet' option is given. If the log file exists when 'units' is + invoked, the new results are appended to the log file. The time is + written to the log file each time the file is opened. The '--log' option is ignored when 'units' is used non-interactively. INVOKING UNITS @@ -1389,129 +1396,131 @@ units [options] [from-unit [to-unit]] If the from-unit and to-unit are omitted, the program will use interac- - tive prompts to determine which conversions to perform. See Interac- - tive Use. If both from-unit and to-unit are given, 'units' will print - the result of that single conversion and then exit. If only from-unit - appears on the command line, 'units' will display the definition of + tive prompts to determine which conversions to perform. See Interac- + tive Use. If both from-unit and to-unit are given, 'units' will print + the result of that single conversion and then exit. If only from-unit + appears on the command line, 'units' will display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group them into - two arguments. See Command Line Use. + two arguments. Note also that the '--quiet' option is enabled by + default if you specify from-unit on the command line. See Command Line + Use. The default behavior of 'units' can be changed by various options given on the command line. In most cases, the options may be given in either - short form (a single '-' followed by a single character) or long form - ('--' followed by a word or hyphen-separated words). Short-form - options are cryptic but require less typing; long-form options require - more typing but are more explanatory and may be more mnemonic. With + short form (a single '-' followed by a single character) or long form + ('--' followed by a word or hyphen-separated words). Short-form + options are cryptic but require less typing; long-form options require + more typing but are more explanatory and may be more mnemonic. With long-form options you need only enter sufficient characters to uniquely identify the option to the program. For example, '--out %f' works, but - '--o %f' fails because 'units' has other long options beginning with - 'o'. However, '--q' works because '--quiet' is the only long option + '--o %f' fails because 'units' has other long options beginning with + 'o'. However, '--q' works because '--quiet' is the only long option beginning with 'q'. - Some options require arguments to specify a value (e.g., '-d 12' or - '--digits 12'). Short-form options that do not take arguments may be - concatenated (e.g., '-erS' is equivalent to '-e -r -S'); the last - option in such a list may be one that takes an argument (e.g., - '-ed 12'). With short-form options, the space between an option and - its argument is optional (e.g., '-d12' is equivalent to '-d 12'). - Long-form options may not be concatenated, and the space between a - long-form option and its argument is required. Short-form and long- - form options may be intermixed on the command line. Options may be - given in any order, but when incompatible options (e.g., '--output- + Some options require arguments to specify a value (e.g., '-d 12' or + '--digits 12'). Short-form options that do not take arguments may be + concatenated (e.g., '-erS' is equivalent to '-e -r -S'); the last + option in such a list may be one that takes an argument (e.g., + '-ed 12'). With short-form options, the space between an option and + its argument is optional (e.g., '-d12' is equivalent to '-d 12'). + Long-form options may not be concatenated, and the space between a + long-form option and its argument is required. Short-form and long- + form options may be intermixed on the command line. Options may be + given in any order, but when incompatible options (e.g., '--output- format' and '--exponential') are given in combination, behavior is con- - trolled by the last option given. For example, '-o%.12f -e' gives + trolled by the last option given. For example, '-o%.12f -e' gives exponential format with the default eight significant digits). The following options are available: -c, --check Check that all units and prefixes defined in the units data file - reduce to primitive units. Print a list of all units that can- - not be reduced. Also display some other diagnostics about sus- - picious definitions in the units data file. Only definitions + reduce to primitive units. Print a list of all units that can- + not be reduced. Also display some other diagnostics about sus- + picious definitions in the units data file. Only definitions active in the current locale are checked. You should always run 'units' with this option after modifying a units data file. --check-verbose, --verbose-check - Like the '--check' option, this option prints a list of units + Like the '--check' option, this option prints a list of units that cannot be reduced. But to help find unit definitions that cause endless loops, it lists the units as they are checked. If - 'units' hangs, then the last unit to be printed has a bad defi- - nition. Only definitions active in the current locale are + 'units' hangs, then the last unit to be printed has a bad defi- + nition. Only definitions active in the current locale are checked. -d ndigits, --digits ndigits - Set the number of significant digits in the output to the value - specified (which must be greater than zero). For example, + Set the number of significant digits in the output to the value + specified (which must be greater than zero). For example, '-d 12' sets the number of significant digits to 12. With expo- - nential output 'units' displays one digit to the left of the - decimal point and eleven digits to the right of the decimal - point. On most systems, the maximum number of internally mean- - ingful digits is 15; if you specify a greater number than your - system's maximum, 'units' will print a warning and set the num- - ber to the largest meaningful value. To directly set the maxi- - mum value, give an argument of 'max' (e.g., '-d max'). Be - aware, of course, that ``significant'' here refers only to the - display of numbers; if results depend on physical constants not + nential output 'units' displays one digit to the left of the + decimal point and eleven digits to the right of the decimal + point. On most systems, the maximum number of internally mean- + ingful digits is 15; if you specify a greater number than your + system's maximum, 'units' will print a warning and set the num- + ber to the largest meaningful value. To directly set the maxi- + mum value, give an argument of 'max' (e.g., '-d max'). Be + aware, of course, that "significant" here refers only to the + display of numbers; if results depend on physical constants not known to this precision, the physically meaningful precision may - be less than that shown. The '--digits' option conflicts with + be less than that shown. The '--digits' option conflicts with the '--output-format' option. -e, --exponential - Set the numeric output format to exponential (i.e., scientific - notation), like that used in the Unix 'units' program. The - default precision is eight significant digits (seven digits to - the right of the decimal point); this can be changed with the - '--digits' option. The '--exponential' option conflicts with + Set the numeric output format to exponential (i.e., scientific + notation), like that used in the Unix 'units' program. The + default precision is eight significant digits (seven digits to + the right of the decimal point); this can be changed with the + '--digits' option. The '--exponential' option conflicts with the '--output-format' option. -o format, --output-format format - This option affords complete control over the numeric output + This option affords complete control over the numeric output format using the specified format. The format is a single float- - ing point numeric format for the 'printf()' function in the C - programming language. All compilers support the format types - 'g' and 'G' to specify significant digits, 'e' and 'E' for sci- - entific notation, and 'f' for fixed-point decimal. The ISO C99 + ing point numeric format for the 'printf()' function in the C + programming language. All compilers support the format types + 'g' and 'G' to specify significant digits, 'e' and 'E' for sci- + entific notation, and 'f' for fixed-point decimal. The ISO C99 standard introduced the 'F' type for fixed-point decimal and the - 'a' and 'A' types for hexadecimal floating point; these types - are allowed with compilers that support them. The default for- - mat is '%.8g'; for greater precision, you could specify + 'a' and 'A' types for hexadecimal floating point; these types + are allowed with compilers that support them. The default for- + mat is '%.8g'; for greater precision, you could specify '-o %.15g'. See Numeric Output Format and the documentation for 'printf()' for more detailed descriptions of the format specifi- - cation. The '--output-format' option affords the greatest con- + cation. The '--output-format' option affords the greatest con- trol of the output appearance, but requires at least rudimentary knowledge of the 'printf()' format syntax. If you don't want to - bother with the 'printf()' syntax, you can specify greater pre- + bother with the 'printf()' syntax, you can specify greater pre- cision more simply with the '--digits' option or select exponen- - tial format with '--exponential'. The '--output-format' option + tial format with '--exponential'. The '--output-format' option is incompatible with the '--exponential' and '--digits' options. -f filename, --file filename Instruct 'units' to load the units file filename. You can spec- ify up to 25 units files on the command line. When you use this option, 'units' will load only the files you list on the command - line; it will not load the standard file or your personal units - file unless you explicitly list them. If filename is the empty - string ('-f ""'), the default units file (or that specified by - 'UNITSFILE') will be loaded in addition to any others specified + line; it will not load the standard file or your personal units + file unless you explicitly list them. If filename is the empty + string ('-f ""'), the default units file (or that specified by + 'UNITSFILE') will be loaded in addition to any others specified with '-f'. -L logfile, --log logfile - Save the results of calculations in the file logfile; this can - be useful if it is important to have a record of unit conver- - sions or other calculations that are to be used extensively or - in a critical activity such as a program or design project. If - logfile exits, the new results are appended to the file. This - option is ignored when 'units' is used non-interactively. See - Logging Calculations for a more detailed description and some + Save the results of calculations in the file logfile; this can + be useful if it is important to have a record of unit conver- + sions or other calculations that are to be used extensively or + in a critical activity such as a program or design project. If + logfile exits, the new results are appended to the file. This + option is ignored when 'units' is used non-interactively. See + Logging Calculations for a more detailed description and some examples. -H filename, --history filename - Instruct 'units' to save history to filename, so that a record - of your commands is available for retrieval across different - 'units' invocations. To prevent the history from being saved - set filename to the empty string ('-H ""'). This option has no + Instruct 'units' to save history to filename, so that a record + of your commands is available for retrieval across different + 'units' invocations. To prevent the history from being saved + set filename to the empty string ('-H ""'). This option has no effect if readline is not available. -h, --help @@ -1522,13 +1531,13 @@ the default behavior. -p, --product - Causes '-' to be interpreted as a multiplication operator when + Causes '-' to be interpreted as a multiplication operator when it has two operands. It will act as a negation operator when it - has only one operand: '(-3)'. By default '-' is treated as a + has only one operand: '(-3)'. By default '-' is treated as a subtraction operator. --oldstar - Causes '*' to have the old-style precedence, higher than the + Causes '*' to have the old-style precedence, higher than the precedence of division so that '1/2*3' will equal '1/6'. --newstar @@ -1536,61 +1545,28 @@ usual rules of algebra: the precedence of '*' is the same as the precedence of '/', so that '1/2*3' will equal '3/2'. - --compact - Give compact output featuring only the conversion factor. This - turns off the '--verbose' option. - - -q, --quiet, --silent - Suppress prompting of the user for units and the display of sta- - tistics about the number of units loaded. - - -n, --nolists - Disable conversion to unit lists. - -r, --round - When converting to a combination of units given by a unit list, - round the value of the last unit in the list to the nearest + When converting to a combination of units given by a unit list, + round the value of the last unit in the list to the nearest integer. -S, --show-factor - When converting to a combination of units specified in a list, - always show a non-unity factor before a unit that begins with a + When converting to a combination of units specified in a list, + always show a non-unity factor before a unit that begins with a fraction with a unity denominator. By default, if the unit in a - list begins with fraction of the form 1|x and its multiplier is + list begins with fraction of the form 1|x and its multiplier is an integer other than 1, the fraction is given as the product of - the multiplier and the numerator (e.g., '3|8 in' rather than '3 - * 1|8 in'). In some cases, this is not what is wanted; for - example, the results for a cooking recipe might show '3 * - 1|2 cup' as '3|2 cup'. With the '--show-factor' option, a - result equivalent to 1.5 cups will display as '3 * 1|2 cup' - rather than '3|2 cup'. A user-specified fractional unit with a - numerator other than 1 is never overridden, however--if a unit - list specifies '3|4 cup;1|2 cup', a result equivalent to 1 1/2 - cups will always be shown as '2 * 3|4 cup' whether or not the + the multiplier and the numerator (e.g., '3|8 in' rather than '3 + * 1|8 in'). In some cases, this is not what is wanted; for + example, the results for a cooking recipe might show '3 * + 1|2 cup' as '3|2 cup'. With the '--show-factor' option, a + result equivalent to 1.5 cups will display as '3 * 1|2 cup' + rather than '3|2 cup'. A user-specified fractional unit with a + numerator other than 1 is never overridden, however--if a unit + list specifies '3|4 cup;1|2 cup', a result equivalent to 1 1/2 + cups will always be shown as '2 * 3|4 cup' whether or not the '--show-factor' option is given. - -s, --strict - Suppress conversion of units to their reciprocal units. For - example, 'units' will normally convert hertz to seconds because - these units are reciprocals of each other. The strict option - requires that units be strictly conformable to perform a conver- - sion, and will give an error if you attempt to convert hertz to - seconds. - - -1, --one-line - Give only one line of output (the forward conversion). Do not - print the reverse conversion. If a reciprocal conversion is - performed then 'units' will still print the ``reciprocal conver- - sion'' line. - - -t, --terse - Give terse output when converting units. This option can be - used when calling 'units' from another program so that the out- - put is easy to parse. This option has the combined effect of - these options: '--strict' '--quiet' '--one-line' '--compact'. - When combined with '--version' it produces a display showing - only the program name and version number. - -v, --verbose Give slightly more verbose output when converting units. When combined with the '-c' option this gives the same effect as @@ -1604,107 +1580,246 @@ data file, and the location of the personal units data file; indicate if the personal units data file does not exist. - When given in combination with the '--terse' option, the program prints - only the version number and exits. + When given in combination with the '--terse' option, the program + prints only the version number and exits. - When given in combination with the '--verbose' option, the program, the - '--version' option has the same effect as the '--info' option below. + When given in combination with the '--verbose' option, the pro- + gram, the '--version' option has the same effect as the '--info' + option below. -I, --info - Print the information given with the '--version' option, show - the pathname of the units program, show the status of the - 'UNITSFILE' and 'MYUNITSFILE' environment variables, and addi- - tional information about how 'units' locates the related files. - On systems running Microsoft Windows, the status of the - 'UNITSLOCALE' environment variable and information about the - related locale map are also given. This option is usually of + Print the information given with the '--version' option, show + the pathname of the units program, show the status of the + 'UNITSFILE' and 'MYUNITSFILE' environment variables, and addi- + tional information about how 'units' locates the related files. + On systems running Microsoft Windows, the status of the + 'UNITSLOCALE' environment variable and information about the + related locale map are also given. This option is usually of interest only to developers and administrators, but it can some- times be useful for troubleshooting. - Combining the '--version' and '--verbose' options has the same effect - as giving '--info'. + Combining the '--version' and '--verbose' options has the same + effect as giving '--info'. -U, --unitsfile - Print the location of the default units data file and exit; if - the file cannot be found, print ``Units data file not found''. + Print the location of the default units data file and exit; if + the file cannot be found, print "Units data file not found". -u (gauss[ian]|esu|emu), --units (gauss[ian]|esu|emu) Specify a CGS units system: Gaussian, ESU, or EMU. -l locale, --locale locale - Print the information given with the '--version' option, show - the Force a specified locale such as 'en_GB' to get British def- - initions by default. This overrides the locale determined from + Force a specified locale such as 'en_GB' to get British defini- + tions by default. This overrides the locale determined from system settings or environment variables. See Locale for a description of locale format. + -n, --nolists + Disable conversion to unit lists. + + -s, --strict + Suppress conversion of units to their reciprocal units. For + example, 'units' will normally convert hertz to seconds because + these units are reciprocals of each other. The strict option + requires that units be strictly conformable to perform a conver- + sion, and will give an error if you attempt to convert hertz to + seconds. + + -1, --one-line + Give only one line of output (the forward conversion); do not + print the reverse conversion. If a reciprocal conversion is + performed, then 'units' will still print the "reciprocal conver- + sion" line. + + -t, --terse + Print only a single conversion factor. This option can be used + when calling 'units' from another program so that the output is + easy to parse. This option has the combined effect of these + options: '--strict' '--quiet' '--one-line' '--compact'. When + combined with '--version' it produces a display showing only the + program name and version number. + + --compact + Give compact output featuring only the conversion factor; the + multiplication and division signs are not shown, and there is no + leading whitespace. If you convert to a unit list, then the + output is a semicolon separated list of factors. This turns off + the '--verbose' option. + + -q, --quiet, --silent + Suppress the display of statistics about the number of units + loaded, any messages printed by the units database, and the + prompting of the user for units. This option does not affect + how 'units' displays the results. This option is turned on by + default if you invoke 'units' with a unit expression on the com- + mand line. + +OUTPUT STYLES + The output can be tweaked in various ways using command line options. + With no options, the output looks like this + + $ units + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23ft + You want: m + * 7.0104 + / 0.14264521 + You have: m + You want: ft;in + 3 ft + 3.3700787 in + + This is arguably a bit cryptic; the '--verbose' option makes clear what + the output means: + + $ units --verbose + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23 ft + You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m + You have: meter + You want: ft;in + meter = 3 ft + 3.3700787 in + + The '--quiet' option suppresses the clutter displayed when 'units' + starts, as well as the prompts to the user. This option is enabled by + default when you give units on the command line. + + $ units --quiet + 23 ft + m + * 7.0104 + / 0.14264521 + + $ units 23ft m + * 7.0104 + / 0.14264521 + + The remaining style options allow you to display only numerical values + without the tab or the multiplication and division signs, or to display + just a single line showing the forward conversion: + + $ units --compact 23ft m + 7.0104 + 0.14264521 + + $ units --compact m 'ft;in' + 3;3.3700787 + + $ units --one-line 23ft m + * 7.0104 + + $ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + + $ units --one-line 23ft kg + conformability error + 7.0104 m + 1 kg + + Note that when converting to a unit list, the '--compact' option dis- + plays a semicolon separated list of results. Also be aware that the + 'one-line' option doesn't live up to its name if you execute a recipro- + cal conversion or if you get a conformability error. The former case + can be prevented using the '--strict' option, which suppresses recipro- + cal conversions. Similarly you can suppress unit list conversion using + '--nolists'. It is impossible to prevent the three line error output. + + $ units --compact --nolists m 'ft;in' + Error in 'ft;in': Parse error + + $ units --one-line --strict 23ft 1/m + + The various style options can be combined appropriately. The ultimate + combination is the '--terse' option, which combines '--strict', + '--quiet', '--one-line', and '--compact' to produce the minimal output, + just a single number for regular conversions and a semicolon separated + list for conversion to unit lists. This will likely be the best choice + for programs that want to call 'units' and then process its result. + + $ units --terse 23ft m + 7.0104 + + $ units --terse m 'ft;in' + 3;3.3700787 + + $ units --terse 23ft 1/m + conformability error + 7.0104 m + 1 / m + ADDING YOUR OWN DEFINITIONS Units Data Files - The units and prefixes that 'units' can convert are defined in the - units data file, typically '/usr/share/units/definitions.units'. If - you can't find this file, run 'units --version' to get information on - the file locations for your installation. Although you can extend or - modify this data file if you have appropriate user privileges, it's - usually better to put extensions in separate files so that the defini- + The units and prefixes that 'units' can convert are defined in the + units data file, typically '/usr/share/units/definitions.units'. If + you can't find this file, run 'units --version' to get information on + the file locations for your installation. Although you can extend or + modify this data file if you have appropriate user privileges, it's + usually better to put extensions in separate files so that the defini- tions will be preserved if you update 'units'. - You can include additional data files in the units database using the + You can include additional data files in the units database using the '!include' command in the standard units data file. For example !include /usr/local/share/units/local.units might be appropriate for a site-wide supplemental data file. The loca- - tion of the '!include' statement in the standard units data file is - important; later definitions replace earlier ones, so any definitions - in an included file will override definitions before the '!include' - statement in the standard units data file. With normal invocation, no - warning is given about redefinitions; to ensure that you don't have an - unintended redefinition, run 'units -c' after making changes to any + tion of the '!include' statement in the standard units data file is + important; later definitions replace earlier ones, so any definitions + in an included file will override definitions before the '!include' + statement in the standard units data file. With normal invocation, no + warning is given about redefinitions; to ensure that you don't have an + unintended redefinition, run 'units -c' after making changes to any units data file. - If you want to add your own units in addition to or in place of stan- - dard or site-wide supplemental units data files, you can include them + If you want to add your own units in addition to or in place of stan- + dard or site-wide supplemental units data files, you can include them in the '.units' file in your home directory. If this file exists it is - read after the standard units data file, so that any definitions in - this file will replace definitions of the same units in the standard - data file or in files included from the standard data file. This file - will not be read if any units files are specified on the command line. + read after the standard units data file, so that any definitions in + this file will replace definitions of the same units in the standard + data file or in files included from the standard data file. This file + will not be read if any units files are specified on the command line. (Under Windows the personal units file is named 'unitdef.units'.) Run- - ning 'units -V' will display the location and name of your personal + ning 'units -V' will display the location and name of your personal units file. - The 'units' program first tries to determine your home directory from + The 'units' program first tries to determine your home directory from the 'HOME' environment variable. On systems running Microsoft Windows, - if 'HOME' does not exist, 'units' attempts to find your home directory - from 'HOMEDRIVE', 'HOMEPATH' and 'USERPROFILE'. You can specify an - arbitrary file as your personal units data file with the 'MYUNITSFILE' - environment variable; if this variable exists, its value is used with- - out searching your home directory. The default units data files are + if 'HOME' does not exist, 'units' attempts to find your home directory + from 'HOMEDRIVE', 'HOMEPATH' and 'USERPROFILE'. You can specify an + arbitrary file as your personal units data file with the 'MYUNITSFILE' + environment variable; if this variable exists, its value is used with- + out searching your home directory. The default units data files are described in more detail in Data Files. Defining New Units and Prefixes - A unit is specified on a single line by giving its name and an equiva- - lence. Comments start with a '#' character, which can appear anywhere - in a line. The backslash character ('\') acts as a continuation char- + A unit is specified on a single line by giving its name and an equiva- + lence. Comments start with a '#' character, which can appear anywhere + in a line. The backslash character ('\') acts as a continuation char- acter if it appears as the last character on a line, making it possible to spread definitions out over several lines if desired. A file can be - included by giving the command '!include' followed by the file's name. - The '!' must be the first character on the line. The file will be - sought in the same directory as the parent file unless you give a full + included by giving the command '!include' followed by the file's name. + The '!' must be the first character on the line. The file will be + sought in the same directory as the parent file unless you give a full path. The name of the file to be included cannot contain spaces or the comment character '#'. - Unit names must not contain any of the operator characters '+', '-', - '*', '/', '|', '^', ';', '~', the comment character '#', or parenthe- - ses. They cannot begin or end with an underscore ('_'), a comma (',') - or a decimal point ('.'). The figure dash (U+2012), typographical - minus (`-'; U+2212), and en dash (`-'; U+2013) are converted to the - operator '-', so none of these characters can appear in unit names. - Names cannot begin with a digit, and if a name ends in a digit other - than zero, the digit must be preceded by a string beginning with an - underscore, and afterwards consisting only of digits, decimal points, - or commas. For example, 'foo_2', 'foo_2,1', or 'foo_3.14' are valid - names but 'foo2' or 'foo_a2' are invalid. You could define nitrous + Unit names must not contain any of the operator characters '+', '-', + '*', '/', '|', '^', ';', '~', the comment character '#', or parenthe- + ses. They cannot begin or end with an underscore ('_'), a comma (',') + or a decimal point ('.'). The figure dash (U+2012), typographical + minus ('-'; U+2212), and en dash ('-'; U+2013) are converted to the + operator '-', so none of these characters can appear in unit names. + Names cannot begin with a digit, and if a name ends in a digit other + than zero, the digit must be preceded by a string beginning with an + underscore, and afterwards consisting only of digits, decimal points, + or commas. For example, 'foo_2', 'foo_2,1', or 'foo_3.14' are valid + names but 'foo2' or 'foo_a2' are invalid. You could define nitrous oxide as N2O nitrogen 2 + oxygen @@ -1714,33 +1829,33 @@ NO_2 nitrogen + oxygen 2 Be careful to define new units in terms of old ones so that a reduction - leads to the primitive units, which are marked with '!' characters. - Dimensionless units are indicated by using the string '!dimensionless' + leads to the primitive units, which are marked with '!' characters. + Dimensionless units are indicated by using the string '!dimensionless' for the unit definition. When adding new units, be sure to use the '-c' option to check that the - new units reduce properly. If you create a loop in the units defini- - tions, then 'units' will hang when invoked with the '-c' option. You - will need to use the '--check-verbose' option, which prints out each - unit as it is checked. The program will still hang, but the last unit + new units reduce properly. If you create a loop in the units defini- + tions, then 'units' will hang when invoked with the '-c' option. You + will need to use the '--check-verbose' option, which prints out each + unit as it is checked. The program will still hang, but the last unit printed will be the unit that caused the infinite loop. - If you define any units that contain '+' characters in their defini- + If you define any units that contain '+' characters in their defini- tions, carefully check them because the '-c' option will not catch non- conformable sums. Be careful with the '-' operator as well. When used - as a binary operator, the '-' character can perform addition or multi- - plication depending on the options used to invoke 'units'. To ensure - consistent behavior use '-' only as a unary negation operator when - writing units definitions. To multiply two units leave a space or use - the '*' operator with care, recalling that it has two possible prece- + as a binary operator, the '-' character can perform addition or multi- + plication depending on the options used to invoke 'units'. To ensure + consistent behavior use '-' only as a unary negation operator when + writing units definitions. To multiply two units leave a space or use + the '*' operator with care, recalling that it has two possible prece- dence values and may require parentheses to ensure consistent behavior. To compute the difference of 'foo' and 'bar' write 'foo+(-bar)' or even 'foo+-bar'. - You may wish to intentionally redefine a unit. When you do this, and - use the '-c' option, 'units' displays a warning message about the - redefinition. You can suppress these warnings by redefining a unit - using a '+' at the beginning of the unit name. Do not include any + You may wish to intentionally redefine a unit. When you do this, and + use the '-c' option, 'units' displays a warning message about the + redefinition. You can suppress these warnings by redefining a unit + using a '+' at the beginning of the unit name. Do not include any white space between the '+' and the redefined unit name. Here is an example of a short data file that defines some basic units: @@ -1757,26 +1872,26 @@ +inch 0.0254 m # Correct redefinition, warning suppressed A unit that ends with a '-' character is a prefix. If a prefix defini- - tion contains any '/' characters, be sure they are protected by paren- - theses. If you define 'half- 1/2' then 'halfmeter' would be equivalent - to '1 / (2 meter)'. + tion contains any '/' characters, be sure they are protected by paren- + theses. If you define 'half- 1/2', then 'halfmeter' would be equiva- + lent to '1 / (2 meter)'. Defining Nonlinear Units - Some unit conversions of interest are nonlinear; for example, tempera- - ture conversions between the Fahrenheit and Celsius scales cannot be + Some unit conversions of interest are nonlinear; for example, tempera- + ture conversions between the Fahrenheit and Celsius scales cannot be done by simply multiplying by conversion factors. - When you give a linear unit definition such as 'inch 2.54 cm' you are - providing information that 'units' uses to convert values in inches - into primitive units of meters. For nonlinear units, you give a func- + When you give a linear unit definition such as 'inch 2.54 cm' you are + providing information that 'units' uses to convert values in inches + into primitive units of meters. For nonlinear units, you give a func- tional definition that provides the same information. - Nonlinear units are represented using a functional notation. It is - best to regard this notation not as a function call but as a way of - adding units to a number, much the same way that writing a linear unit - name after a number adds units to that number. Internally, nonlinear - units are defined by a pair of functions that convert to and from lin- - ear units in the database, so that an eventual conversion to primitive + Nonlinear units are represented using a functional notation. It is + best to regard this notation not as a function call but as a way of + adding units to a number, much the same way that writing a linear unit + name after a number adds units to that number. Internally, nonlinear + units are defined by a pair of functions that convert to and from lin- + ear units in the database, so that an eventual conversion to primitive units is possible. Here is an example nonlinear unit definition: @@ -1784,50 +1899,50 @@ tempF(x) units=[1;K] domain=[-459.67,) range=[0,) \ (x+(-32)) degF + stdtemp ; (tempF+(-stdtemp))/degF + 32 - A nonlinear unit definition comprises a unit name, a formal parameter + A nonlinear unit definition comprises a unit name, a formal parameter name, two functions, and optional specifications for units, the domain, and the range (the domain of the inverse function). The functions tell - 'units' how to convert to and from the new unit. To produce valid - results, the arguments of these functions need to have the correct - dimensions and be within the domains for which the functions are + 'units' how to convert to and from the new unit. To produce valid + results, the arguments of these functions need to have the correct + dimensions and be within the domains for which the functions are defined. - The definition begins with the unit name followed immediately (with no + The definition begins with the unit name followed immediately (with no spaces) by a '(' character. In the parentheses is the name of the for- mal parameter. Next is an optional specification of the units required - by the functions in the definition. In the example above, the - 'units=[1;K]' specification indicates that the 'tempF' function - requires an input argument conformable with '1' (i.e., the argument is - dimensionless), and that the inverse function requires an input argu- - ment conformable with 'K'. For normal nonlinear units definition, the + by the functions in the definition. In the example above, the + 'units=[1;K]' specification indicates that the 'tempF' function + requires an input argument conformable with '1' (i.e., the argument is + dimensionless), and that the inverse function requires an input argu- + ment conformable with 'K'. For normal nonlinear units definition, the forward function will always take a dimensionless argument; in general, - the inverse function will need units that match the quantity measured - by your nonlinear unit. Specifying the units enables 'units' to per- - form error checking on function arguments, and also to assign units to + the inverse function will need units that match the quantity measured + by your nonlinear unit. Specifying the units enables 'units' to per- + form error checking on function arguments, and also to assign units to domain and range specifications, which are described later. - Next the function definitions appear. In the example above, the + Next the function definitions appear. In the example above, the 'tempF' function is defined by tempF(x) = (x+(-32)) degF + stdtemp - This gives a rule for converting 'x' in the units 'tempF' to linear - units of absolute temperature, which makes it possible to convert from + This gives a rule for converting 'x' in the units 'tempF' to linear + units of absolute temperature, which makes it possible to convert from tempF to other units. - To enable conversions to Fahrenheit, you must give a rule for the + To enable conversions to Fahrenheit, you must give a rule for the inverse conversions. The inverse will be 'x(tempF)' and its definition appears after a ';' character. In our example, the inverse is x(tempF) = (tempF+(-stdtemp))/degF + 32 - This inverse definition takes an absolute temperature as its argument - and converts it to the Fahrenheit temperature. The inverse can be - omitted by leaving out the ';' character and the inverse definition, - but then conversions to the unit will not be possible. If the inverse + This inverse definition takes an absolute temperature as its argument + and converts it to the Fahrenheit temperature. The inverse can be + omitted by leaving out the ';' character and the inverse definition, + but then conversions to the unit will not be possible. If the inverse definition is omitted, the '--check' option will display a warning. It - is up to you to calculate and enter the correct inverse function to - obtain proper conversions; the '--check' option tests the inverse at + is up to you to calculate and enter the correct inverse function to + obtain proper conversions; the '--check' option tests the inverse at one point and prints an error if it is not valid there, but this is not a guarantee that your inverse is correct. @@ -1835,9 +1950,9 @@ square(x) x^2 - can have any arbitrary units, and can also take dimensionless argu- - ments. In such a case, you should not specify units. If a definition - takes a root of its arguments, the definition is valid only for units + can have any arbitrary units, and can also take dimensionless argu- + ments. In such a case, you should not specify units. If a definition + takes a root of its arguments, the definition is valid only for units that yield such a root. For example, squirt(x) sqrt(x) @@ -1846,67 +1961,67 @@ ers of units. Some definitions may not be valid for all real numbers. In such cases, - 'units' can handle errors better if you specify an appropriate domain + 'units' can handle errors better if you specify an appropriate domain and range. You specify the domain and range as shown below: baume(d) units=[1;g/cm^3] domain=[0,130.5] range=[1,10] \ (145/(145-d)) g/cm^3 ; (baume+-g/cm^3) 145 / baume - In this example the domain is specified after 'domain=' with the end- - points given in brackets. In accord with mathematical convention, - square brackets indicate a closed interval (one that includes its end- - points), and parentheses indicate an open interval (one that does not - include its endpoints). An interval can be open or closed on one or - both ends; an interval that is unbounded on either end is indicated by + In this example the domain is specified after 'domain=' with the end- + points given in brackets. In accord with mathematical convention, + square brackets indicate a closed interval (one that includes its end- + points), and parentheses indicate an open interval (one that does not + include its endpoints). An interval can be open or closed on one or + both ends; an interval that is unbounded on either end is indicated by omitting the limit on that end. For example, a quantity to which deci- - bel (dB) is applied may have any value greater than zero, so the range + bel (dB) is applied may have any value greater than zero, so the range is indicated by '(0,)': decibel(x) units=[1;1] range=(0,) 10^(x/10); 10 log(decibel) - If the domain or range is given, the second endpoint must be greater + If the domain or range is given, the second endpoint must be greater than the first. The domain and range specifications can appear independently and in any - order along with the units specification. The values for the domain + order along with the units specification. The values for the domain and range endpoints are attached to the units given in the units speci- fication, and if necessary, the parameter value is adjusted for compar- - ison with the endpoints. For example, if a definition includes - 'units=[1;ft]' and 'range=[3,)', the range will be taken as 3 ft to - infinity. If the function is passed a parameter of '900 mm', that - value will be adjusted to 2.9527559 ft, which is outside the specified - range. If you omit the units specification from the previous example, - 'units' can not tell whether you intend the lower endpoint to be 3 ft - or 3 microfurlongs, and can not adjust the parameter value of 900 mm - for comparison. Without units, numerical values other than zero or - plus or minus infinity for domain or range endpoints are meaningless, + ison with the endpoints. For example, if a definition includes + 'units=[1;ft]' and 'range=[3,)', the range will be taken as 3 ft to + infinity. If the function is passed a parameter of '900 mm', that + value will be adjusted to 2.9527559 ft, which is outside the specified + range. If you omit the units specification from the previous example, + 'units' can not tell whether you intend the lower endpoint to be 3 ft + or 3 microfurlongs, and can not adjust the parameter value of 900 mm + for comparison. Without units, numerical values other than zero or + plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If you give other values without - units then the definition will be ignored and you will get an error + units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, it's - best to give them when they are applicable; doing so allows 'units' to - perform better error checking and give more helpful error messages. + best to give them when they are applicable; doing so allows 'units' to + perform better error checking and give more helpful error messages. Giving the domain and range also enables the '--check' option to find a - point in the domain to use for its point check of your inverse defini- + point in the domain to use for its point check of your inverse defini- tion. You can make synonyms for nonlinear units by providing both the forward - and inverse functions; inverse functions can be obtained using the '~' + and inverse functions; inverse functions can be obtained using the '~' operator. So to create a synonym for 'tempF' you could write fahrenheit(x) units=[1;K] tempF(x); ~tempF(fahrenheit) - This is useful for creating a nonlinear unit definition that differs + This is useful for creating a nonlinear unit definition that differs slightly from an existing definition without having to repeat the orig- inal functions. For example, dBW(x) units=[1;W] range=[0,) dB(x) W ; ~dB(dBW/W) - If you wish a synonym to refer to an existing nonlinear unit without - modification, you can do so more simply by adding the synonym with - appended parentheses as a new unit, with the existing nonlinear unit-- - without parentheses--as the definition. So to create a synonym for + If you wish a synonym to refer to an existing nonlinear unit without + modification, you can do so more simply by adding the synonym with + appended parentheses as a new unit, with the existing nonlinear unit-- + without parentheses--as the definition. So to create a synonym for 'tempF' you could write fahrenheit() tempF @@ -1917,38 +2032,38 @@ will result in an error message when 'units' starts. - You may occasionally wish to define a function that operates on units. - This can be done using a nonlinear unit definition. For example, the - definition below provides conversion between radius and the area of a - circle. This definition requires a length as input and produces an + You may occasionally wish to define a function that operates on units. + This can be done using a nonlinear unit definition. For example, the + definition below provides conversion between radius and the area of a + circle. This definition requires a length as input and produces an area as output, as indicated by the 'units=' specification. Specifying - the range as the nonnegative numbers can prevent cryptic error mes- + the range as the nonnegative numbers can prevent cryptic error mes- sages. circlearea(r) units=[m;m^2] range=[0,) pi r^2 ; sqrt(circlearea/pi) Defining Piecewise Linear Units Sometimes you may be interested in a piecewise linear unit such as many - wire gauges. Piecewise linear units can be defined by specifying con- - versions to linear units on a list of points. Conversion at other - points will be done by linear interpolation. A partial definition of + wire gauges. Piecewise linear units can be defined by specifying con- + versions to linear units on a list of points. Conversion at other + points will be done by linear interpolation. A partial definition of zinc gauge is zincgauge[in] 1 0.002, 10 0.02, 15 0.04, 19 0.06, 23 0.1 - In this example, 'zincgauge' is the name of the piecewise linear unit. - The definition of such a unit is indicated by the embedded '[' charac- - ter. After the bracket, you should indicate the units to be attached + In this example, 'zincgauge' is the name of the piecewise linear unit. + The definition of such a unit is indicated by the embedded '[' charac- + ter. After the bracket, you should indicate the units to be attached to the numbers in the table. No spaces can appear before the ']' char- - acter, so a definition like 'foo[kg meters]' is invalid; instead write - 'foo[kg*meters]'. The definition of the unit consists of a list of + acter, so a definition like 'foo[kg meters]' is invalid; instead write + 'foo[kg*meters]'. The definition of the unit consists of a list of pairs optionally separated by commas. This list defines a function for - converting from the piecewise linear unit to linear units. The first - item in each pair is the function argument; the second item is the - value of the function at that argument (in the units specified in + converting from the piecewise linear unit to linear units. The first + item in each pair is the function argument; the second item is the + value of the function at that argument (in the units specified in brackets). In this example, we define 'zincgauge' at five points. For - example, we set 'zincgauge(1)' equal to '0.002 in'. Definitions like - this may be more readable if written using continuation characters + example, we set 'zincgauge(1)' equal to '0.002 in'. Definitions like + this may be more readable if written using continuation characters as zincgauge[in] \ @@ -1958,7 +2073,7 @@ 19 0.06 \ 23 0.1 - With the preceding definition, the following conversion can be per- + With the preceding definition, the following conversion can be per- formed: You have: zincgauge(10) @@ -1969,14 +2084,14 @@ You want: zincgauge 5 - If you define a piecewise linear unit that is not strictly monotonic, + If you define a piecewise linear unit that is not strictly monotonic, then the inverse will not be well defined. If the inverse is requested for such a unit, 'units' will return the smallest inverse. - After adding nonlinear units definitions, you should normally run - 'units --check' to check for errors. If the 'units' keyword is not - given, the '--check' option checks a nonlinear unit definition using a - dimensionless argument, and then checks using an arbitrary combination + After adding nonlinear units definitions, you should normally run + 'units --check' to check for errors. If the 'units' keyword is not + given, the '--check' option checks a nonlinear unit definition using a + dimensionless argument, and then checks using an arbitrary combination of units, as well as the square and cube of that combination; a warning is given if any of these tests fail. For example, @@ -1985,9 +2100,9 @@ squirt(7(kg K)^1): Unit not a root squirt(7(kg K)^3): Unit not a root - Running 'units --check' will print a warning if a non-monotonic piece- + Running 'units --check' will print a warning if a non-monotonic piece- wise linear unit is encountered. For example, the relationship between - ANSI coated abrasive designation and mean particle size is non-mono- + ANSI coated abrasive designation and mean particle size is non-mono- tonic in the vicinity of 800 grit: ansicoated[micron] \ @@ -2000,9 +2115,9 @@ Table 'ansicoated' lacks unique inverse around entry 800 - Although the inverse is not well defined in this region, it's not - really an error. Viewing such error messages can be tedious, and if - there are enough of them, they can distract from true errors. Error + Although the inverse is not well defined in this region, it's not + really an error. Viewing such error messages can be tedious, and if + there are enough of them, they can distract from true errors. Error checking for nonlinear unit definitions can be suppressed by giving the 'noerror' keyword; for the examples above, this could be done as @@ -2010,16 +2125,16 @@ ansicoated[micron] noerror \ . . . - Use the 'noerror' keyword with caution. The safest approach after - adding a nonlinear unit definition is to run 'units --check' and con- - firm that there are no actual errors before adding the 'noerror' key- + Use the 'noerror' keyword with caution. The safest approach after + adding a nonlinear unit definition is to run 'units --check' and con- + firm that there are no actual errors before adding the 'noerror' key- word. Defining Unit List Aliases - Unit list aliases are treated differently from unit definitions, - because they are a data entry shorthand rather than a true definition - for a new unit. A unit list alias definition begins with '!unitlist' - and includes the alias and the definition; for example, the aliases + Unit list aliases are treated differently from unit definitions, + because they are a data entry shorthand rather than a true definition + for a new unit. A unit list alias definition begins with '!unitlist' + and includes the alias and the definition; for example, the aliases included in the standard units data file are !unitlist hms hr;min;sec @@ -2029,74 +2144,74 @@ !unitlist usvol cup;3|4 cup;2|3 cup;1|2 cup;1|3 cup;1|4 cup;\ tbsp;tsp;1|2 tsp;1|4 tsp;1|8 tsp - Unit list aliases are only for unit lists, so the definition must - include a ';'. Unit list aliases can never be combined with units or - other unit list aliases, so the definition of 'time' shown above could + Unit list aliases are only for unit lists, so the definition must + include a ';'. Unit list aliases can never be combined with units or + other unit list aliases, so the definition of 'time' shown above could not have been shortened to 'year;day;hms'. - As usual, be sure to run 'units --check' to ensure that the units + As usual, be sure to run 'units --check' to ensure that the units listed in unit list aliases are conformable. NUMERIC OUTPUT FORMAT - By default, 'units' shows results to eight significant digits. You can + By default, 'units' shows results to eight significant digits. You can change this with the '--exponential', '--digits', and '--output-format' - options. The first sets an exponential format (i.e., scientific nota- - tion) like that used in the original Unix 'units' program, the second + options. The first sets an exponential format (i.e., scientific nota- + tion) like that used in the original Unix 'units' program, the second allows you to specify a different number of significant digits, and the - last allows you to control the output appearance using the format for - the 'printf()' function in the C programming language. If you only - want to change the number of significant digits or specify exponential - format type, use the '--digits' and '--exponential' options. The - '--output-format' option affords the greatest control of the output - appearance, but requires at least rudimentary knowledge of the - 'printf()' format syntax. See Invoking Units for descriptions of these + last allows you to control the output appearance using the format for + the 'printf()' function in the C programming language. If you only + want to change the number of significant digits or specify exponential + format type, use the '--digits' and '--exponential' options. The + '--output-format' option affords the greatest control of the output + appearance, but requires at least rudimentary knowledge of the + 'printf()' format syntax. See Invoking Units for descriptions of these options. Format Specification - The format specification recognized with the '--output-format' option - is a subset of that for 'printf()'. The format specification has the - form '%'[flags][width]['.'precision]type; it must begin with '%', and - must end with a floating-point type specifier: 'g' or 'G' to specify - the number of significant digits, 'e' or 'E' for scientific notation, - and 'f' for fixed-point decimal. The ISO C99 standard added the 'F' - type for fixed-point decimal and the 'a' and 'A' types for hexadecimal - floating point; these types are allowed with compilers that support - them. Type length modifiers (e.g., 'L' to indicate a long double) are + The format specification recognized with the '--output-format' option + is a subset of that for 'printf()'. The format specification has the + form '%'[flags][width]['.'precision]type; it must begin with '%', and + must end with a floating-point type specifier: 'g' or 'G' to specify + the number of significant digits, 'e' or 'E' for scientific notation, + and 'f' for fixed-point decimal. The ISO C99 standard added the 'F' + type for fixed-point decimal and the 'a' and 'A' types for hexadecimal + floating point; these types are allowed with compilers that support + them. Type length modifiers (e.g., 'L' to indicate a long double) are inapplicable and are not allowed. - The default format for 'units' is '%.8g'; for greater precision, you + The default format for 'units' is '%.8g'; for greater precision, you could specify '-o %.15g'. The 'g' and 'G' format types use exponential - format whenever the exponent would be less than -4, so the value - 0.000013 displays as '1.3e-005'. These types also use exponential - notation when the exponent is greater than or equal to the precision, - so with the default format, the value 5e7 displays as '50000000' and + format whenever the exponent would be less than -4, so the value + 0.000013 displays as '1.3e-005'. These types also use exponential + notation when the exponent is greater than or equal to the precision, + so with the default format, the value 5e7 displays as '50000000' and the value 5e8 displays as '5e+008'. If you prefer fixed-point display, - you might specify '-o %.8f'; however, small numbers will display very - few significant digits, and values less than 0.5e-8 will show nothing + you might specify '-o %.8f'; however, small numbers will display very + few significant digits, and values less than 0.5e-8 will show nothing but zeros. - The format specification may include one or more optional flags: '+', - ' ' (space), '#', '-', or '0' (the digit zero). The digit-grouping + The format specification may include one or more optional flags: '+', + ' ' (space), '#', '-', or '0' (the digit zero). The digit-grouping flag ''' is allowed with compilers that support it. Flags are followed - by an optional value for the minimum field width, and an optional pre- + by an optional value for the minimum field width, and an optional pre- cision specification that begins with a period (e.g., '.6'). The field width includes the digits, decimal point, the exponent, thousands sepa- rators (with the digit-grouping flag), and the sign if any of these are shown. Flags - The '+' flag causes the output to have a sign ('+' or '-'). The space + The '+' flag causes the output to have a sign ('+' or '-'). The space flag ' ' is similar to the '+' flag, except that when the value is pos- - itive, it is prefixed with a space rather than a plus sign; this flag + itive, it is prefixed with a space rather than a plus sign; this flag is ignored if the '+' flag is also given. The '+' or ' ' flag could be - useful if conversions might include positive and negative results, and - you wanted to align the decimal points in exponential notation. The - '#' flag causes the output value to contain a decimal point in all - cases; by default, the output contains a decimal point only if there - are digits (which can be trailing zeros) to the right of the point. - With the 'g' or 'G' types, the '#' flag also prevents the suppression + useful if conversions might include positive and negative results, and + you wanted to align the decimal points in exponential notation. The + '#' flag causes the output value to contain a decimal point in all + cases; by default, the output contains a decimal point only if there + are digits (which can be trailing zeros) to the right of the point. + With the 'g' or 'G' types, the '#' flag also prevents the suppression of trailing zeros. The digit-grouping flag ''' shows a thousands sepa- - rator in digits to the left of the decimal point. This can be useful + rator in digits to the left of the decimal point. This can be useful when displaying large numbers in fixed-point decimal; for example, with the format '%f', @@ -2105,9 +2220,9 @@ * 8000000.000000 / 0.000000 - the magnitude of the first result may not be immediately obvious with- + the magnitude of the first result may not be immediately obvious with- out counting the digits to the left of the decimal point. If the thou- - sands separator is the comma (','), the output with the format '%'f' + sands separator is the comma (','), the output with the format '%'f' might be You have: mile @@ -2115,13 +2230,13 @@ * 8,000,000.000000 / 0.000000 - making the magnitude readily apparent. Unfortunately, few compilers + making the magnitude readily apparent. Unfortunately, few compilers support the digit-grouping flag. - With the '-' flag, the output value is left aligned within the - specified field width. If a field width greater than needed to show - the output value is specified, the '0' (zero) flag causes the output - value to be left padded with zeros until the specified field width is + With the '-' flag, the output value is left aligned within the speci- + fied field width. If a field width greater than needed to show the + output value is specified, the '0' (zero) flag causes the output value + to be left padded with zeros until the specified field width is reached; for example, with the format '%011.6f', You have: troypound @@ -2133,13 +2248,13 @@ Field Width By default, the output value is left aligned and shown with the minimum - width necessary for the specified (or default) precision. If a field + width necessary for the specified (or default) precision. If a field width greater than this is specified, the value shown is right aligned, - and padded on the left with enough spaces to provide the specified - field width. A width specification is typically used with fixed-point - decimal to have columns of numbers align at the decimal point; this - arguably is less useful with 'units' than with long columnar output, - but it may nonetheless assist in quickly assessing the relative magni- + and padded on the left with enough spaces to provide the specified + field width. A width specification is typically used with fixed-point + decimal to have columns of numbers align at the decimal point; this + arguably is less useful with 'units' than with long columnar output, + but it may nonetheless assist in quickly assessing the relative magni- tudes of results. For example, with the format '%12.6f', You have: km @@ -2156,28 +2271,28 @@ / 0.201168 Precision - The meaning of ``precision'' depends on the format type. With 'g' or + The meaning of "precision" depends on the format type. With 'g' or 'G', it specifies the number of significant digits (like the '--digits' option); with 'e', 'E', 'f', or 'F', it specifies the maximum number of digits to be shown after the decimal point. - With the 'g' and 'G' format types, trailing zeros are suppressed, so - the results may sometimes have fewer digits than the specified preci- + With the 'g' and 'G' format types, trailing zeros are suppressed, so + the results may sometimes have fewer digits than the specified preci- sion (as indicated above, the '#' flag causes trailing zeros to be dis- played). - The default precision is 6, so '%g' is equivalent to '%.6g', and would - show the output to six significant digits. Similarly, '%e' or '%f' + The default precision is 6, so '%g' is equivalent to '%.6g', and would + show the output to six significant digits. Similarly, '%e' or '%f' would show the output with six digits after the decimal point. The C 'printf()' function allows a precision of arbitrary size, whether or not all of the digits are meaningful. With most compilers, the max- - imum internal precision with 'units' is 15 decimal digits (or 13 hexa- - decimal digits). With the '--digits' option, you are limited to the - maximum internal precision; with the '--output-format' option, you may - specify a precision greater than this, but it may not be meaningful. + imum internal precision with 'units' is 15 decimal digits (or 13 hexa- + decimal digits). With the '--digits' option, you are limited to the + maximum internal precision; with the '--output-format' option, you may + specify a precision greater than this, but it may not be meaningful. In some cases, specifying excess precision can result in rounding arti- - facts. For example, a pound is exactly 7000 grains, but with the for- + facts. For example, a pound is exactly 7000 grains, but with the for- mat '%.18g', the output might be You have: pound @@ -2191,20 +2306,20 @@ You want: Definition: 0.333333333333333314829616256247 - In this case the displayed value includes a series of digits that rep- - resent the underlying binary floating-point approximation to 1/3 but + In this case the displayed value includes a series of digits that rep- + resent the underlying binary floating-point approximation to 1/3 but are not meaningful for the desired computation. In general, the result - with excess precision is system dependent. The precision affects only - the display of numbers; if a result relies on physical constants that - are not known to the specified precision, the number of physically + with excess precision is system dependent. The precision affects only + the display of numbers; if a result relies on physical constants that + are not known to the specified precision, the number of physically meaningful digits may be less than the number of digits shown. - See the documentation for 'printf()' for more detailed descriptions of + See the documentation for 'printf()' for more detailed descriptions of the format specification. - The '--output-format' option is incompatible with the '--exponential' - or '--digits' options; if the former is given in combination with - either of the latter, the format is controlled by the last option + The '--output-format' option is incompatible with the '--exponential' + or '--digits' options; if the former is given in combination with + either of the latter, the format is controlled by the last option given. LOCALIZATION @@ -2213,41 +2328,41 @@ definitions that depend on the user's locale. Locale - A locale is a subset of a user's environment that indicates the user's - language and country, and some attendant preferences, such as the for- + A locale is a subset of a user's environment that indicates the user's + language and country, and some attendant preferences, such as the for- matting of dates. The 'units' program attempts to determine the locale - from the POSIX setlocale function; if this cannot be done, 'units' - examines the environment variables 'LC_CTYPE' and 'LANG'. On POSIX - systems, a locale is of the form language'_'country, where language is - the two-character code from ISO 639-1 and country is the two-character + from the POSIX setlocale function; if this cannot be done, 'units' + examines the environment variables 'LC_CTYPE' and 'LANG'. On POSIX + systems, a locale is of the form language'_'country, where language is + the two-character code from ISO 639-1 and country is the two-character code from ISO 3166-1; language is lower case and country is upper case. For example, the POSIX locale for the United Kingdom is 'en_GB'. On systems running Microsoft Windows, the value returned by setlocale() - is different from that on POSIX systems; 'units' attempts to map the - Windows value to a POSIX value by means of a table in the file - 'locale_map.txt' in the same directory as the other data files. The - file includes entries for many combinations of language and country, + is different from that on POSIX systems; 'units' attempts to map the + Windows value to a POSIX value by means of a table in the file + 'locale_map.txt' in the same directory as the other data files. The + file includes entries for many combinations of language and country, and can be extended to include other combinations. The - 'locale_map.txt' file comprises two tab-separated columns; each entry + 'locale_map.txt' file comprises two tab-separated columns; each entry is of the form Windows-locale POSIX-locale - where POSIX-locale is as described above, and Windows-locale typically - spells out both the language and country. For example, the entry for + where POSIX-locale is as described above, and Windows-locale typically + spells out both the language and country. For example, the entry for the United States is English_United States en_US - You can force 'units' to run in a desired locale by using the '-l' + You can force 'units' to run in a desired locale by using the '-l' option. In order to create unit definitions for a particular locale you begin a - block of definitions in a unit datafile with '!locale' followed by a - locale name. The '!' must be the first character on the line. The - 'units' program reads the following definitions only if the current - locale matches. You end the block of localized units with + block of definitions in a unit datafile with '!locale' followed by a + locale name. The '!' must be the first character on the line. The + 'units' program reads the following definitions only if the current + locale matches. You end the block of localized units with '!endlocale'. Here is an example, which defines the British gallon. !locale en_GB @@ -2255,31 +2370,31 @@ !endlocale Additional Localization - Sometimes the locale isn't sufficient to determine unit preferences. - There could be regional preferences, or a company could have specific - preferences. Though probably uncommon, such differences could arise - with the choice of English customary units outside of English-speaking + Sometimes the locale isn't sufficient to determine unit preferences. + There could be regional preferences, or a company could have specific + preferences. Though probably uncommon, such differences could arise + with the choice of English customary units outside of English-speaking countries. To address this, 'units' allows specifying definitions that depend on environment variable settings. The environment variables can - be controled based on the current locale, or the user can set them to + be controled based on the current locale, or the user can set them to force a particular group of definitions. - A conditional block of definitions in a units data file begins with - either '!var' or '!varnot' following by an environment variable name - and then a space separated list of values. The leading '!' must - appear in the first column of a units data file, and the conditional - block is terminated by '!endvar'. Definitions in blocks beginning with - '!var' are executed only if the environment variable is exactly equal - to one of the listed values. Definitions in blocks beginning with - '!varnot' are executed only if the environment variable does not equal - any of the list values. - - The inch has long been a customary measure of length in many places. - The word comes from the Latin uncia meaning ``one twelfth,'' referring - to its relationship with the foot. By the 20th century, the inch was - officially defined in English-speaking countries relative to the yard, - but until 1959, the yard differed slightly among those countries. In - France the customary inch, which was displaced in 1799 by the meter, + A conditional block of definitions in a units data file begins with + either '!var' or '!varnot' following by an environment variable name + and then a space separated list of values. The leading '!' must appear + in the first column of a units data file, and the conditional block is + terminated by '!endvar'. Definitions in blocks beginning with '!var' + are executed only if the environment variable is exactly equal to one + of the listed values. Definitions in blocks beginning with '!varnot' + are executed only if the environment variable does not equal any of the + list values. + + The inch has long been a customary measure of length in many places. + The word comes from the Latin uncia meaning "one twelfth," referring to + its relationship with the foot. By the 20th century, the inch was + officially defined in English-speaking countries relative to the yard, + but until 1959, the yard differed slightly among those countries. In + France the customary inch, which was displaced in 1799 by the meter, had a different length based on a french foot. These customary defini- tions could be accommodated as follows: @@ -2305,24 +2420,24 @@ !message Unknown value for INCH_UNIT !endvar - When 'units' reads the above definitions it will check the environment - variable 'INCH_UNIT' and load only the definitions for the appropriate + When 'units' reads the above definitions it will check the environment + variable 'INCH_UNIT' and load only the definitions for the appropriate section. If 'INCH_UNIT' is unset or is not set to one of the four val- - ues listed then 'units' will run the last block. In this case that + ues listed, then 'units' will run the last block. In this case that block uses the '!message' command to display a warning message. Alter- natively that block could set default values. - In order to create default values that are overridden by user settings - the data file can use the '!set' command, which sets an environment - variable only if it is not already set; these settings are only for - the current 'units' invocation and do not persist. So if the example - above were preceded by '!set INCH_UNIT france' then this would make - 'france' the default value for 'INCH_UNIT'. If the user had set the + In order to create default values that are overridden by user settings + the data file can use the '!set' command, which sets an environment + variable only if it is not already set; these settings are only for + the current 'units' invocation and do not persist. So if the example + above were preceded by '!set INCH_UNIT france', then this would make + 'france' the default value for 'INCH_UNIT'. If the user had set the variable in the environment before invoking 'units', then 'units' would use the user's value. To link these settings to the user's locale you combine the '!set' com- - mand with the '!locale' command. If you wanted to combine the above + mand with the '!locale' command. If you wanted to combine the above example with suitable locales you could do by preceding the above defi- nition with the following: @@ -2340,106 +2455,106 @@ !endlocale !set INCH_UNIT france - These definitions set the overall default for 'INCH_UNIT' to 'france' - and set default values for four locales appropriately. The overall + These definitions set the overall default for 'INCH_UNIT' to 'france' + and set default values for four locales appropriately. The overall default setting comes last so that it only applies when 'INCH_UNIT' was not set by one of the other commands or by the user. - If the variable given after '!var' or '!varnot' is undefined then - 'units' prints an error message and ignores the definitions that fol- - low. Use '!set' to create defaults to prevent this situation from - arising. The '-c' option only checks the definitions that are active - for the current environment and locale, so when adding new definitions - take care to check that all cases give rise to a well defined set of + If the variable given after '!var' or '!varnot' is undefined, then + 'units' prints an error message and ignores the definitions that fol- + low. Use '!set' to create defaults to prevent this situation from + arising. The '-c' option only checks the definitions that are active + for the current environment and locale, so when adding new definitions + take care to check that all cases give rise to a well defined set of definitions. ENVIRONMENT VARIABLES The 'units' program uses the following environment variables: - HOME Specifies the location of your home directory; it is used by + HOME Specifies the location of your home directory; it is used by 'units' to find a personal units data file '.units'. On systems - running Microsoft Windows, the file is 'unitdef.units', and if - 'HOME' does not exist, 'units' tries to determine your home - directory from the 'HOMEDRIVE' and 'HOMEPATH' environment vari- - ables; if these variables do not exist, units finally tries - 'USERPROFILE'--typically 'C:\Users\username' (Windows Vista and + running Microsoft Windows, the file is 'unitdef.units', and if + 'HOME' does not exist, 'units' tries to determine your home + directory from the 'HOMEDRIVE' and 'HOMEPATH' environment vari- + ables; if these variables do not exist, units finally tries + 'USERPROFILE'--typically 'C:\Users\username' (Windows Vista and Windows 7) or 'C:\Documents and Settings\username' (Windows XP). LC_CTYPE, LANG Checked to determine the locale if 'units' cannot obtain it from - the operating system. Sections of the standard units data file + the operating system. Sections of the standard units data file are specific to certain locales. MYUNITSFILE - Specifies your personal units data file. If this variable - exists, 'units' uses its value rather than searching your home - directory for '.units'. The personal units file will not be + Specifies your personal units data file. If this variable + exists, 'units' uses its value rather than searching your home + directory for '.units'. The personal units file will not be loaded if any data files are given using the '-f' option. - PAGER Specifies the pager to use for help and for displaying the con- - formable units. The help function browses the units database + PAGER Specifies the pager to use for help and for displaying the con- + formable units. The help function browses the units database and calls the pager using the '+n'n syntax for specifying a line - number. The default pager is 'more'; 'PAGER' can be used to + number. The default pager is 'more'; 'PAGER' can be used to specify alternatives such as 'less', 'pg', 'emacs', or 'vi'. UNITS_ENGLISH - Set to either 'US' or 'GB' to choose United States or British + Set to either 'US' or 'GB' to choose United States or British volume definitions, overriding the default from your locale. UNITSFILE - Specifies the units data file to use (instead of the default). - You can only specify a single units data file using this envi- - ronment variable. If units data files are given using the '-f' - option, the file specified by 'UNITSFILE' will be not be loaded - unless the '-f' option is given with the empty string + Specifies the units data file to use (instead of the default). + You can only specify a single units data file using this envi- + ronment variable. If units data files are given using the '-f' + option, the file specified by 'UNITSFILE' will be not be loaded + unless the '-f' option is given with the empty string ('units -f ""'). UNITSLOCALEMAP - Windows only; this variable has no effect on Unix-like systems. - Specifies the units locale map file to use (instead of the + Windows only; this variable has no effect on Unix-like systems. + Specifies the units locale map file to use (instead of the default). This variable seldom needs to be set, but you can use it to ensure that the locale map file will be found if you spec- - ify a location for the units data file using either the '-f' - option or the 'UNITSFILE' environment variable, and that loca- + ify a location for the units data file using either the '-f' + option or the 'UNITSFILE' environment variable, and that loca- tion does not also contain the locale map file. UNITS_SYSTEM - This environment variable is used in the standard data file to + This environment variable is used in the standard data file to select CGS measurement systems. Currently supported systems are 'esu', 'emu', 'gauss[ian]', and 'si'. The default is 'si'. DATA FILES - The 'units' program uses two default data files: 'definitions.units' - and 'currency.units'. The program can also use an optional personal + The 'units' program uses two default data files: 'definitions.units' + and 'currency.units'. The program can also use an optional personal units data file '.units' ('unitdef.units' under Windows) located in the - user's home directory. The personal units data file is described in + user's home directory. The personal units data file is described in more detail in Units Data Files. - On Unix-like systems, the data files are typically located in + On Unix-like systems, the data files are typically located in '/usr/share/units' if 'units' is provided with the operating system, or in '/usr/local/share/units' if 'units' is compiled from the source dis- - tribution. Note that the currency file 'currency.units' is a symbolic + tribution. Note that the currency file 'currency.units' is a symbolic link to another location. - On systems running Microsoft Windows, the files may be in the same - locations if Unix-like commands are available, a Unix-like file struc- - ture is present (e.g., 'C:/usr/local'), and 'units' is compiled from - the source distribution. If Unix-like commands are not available, a - more common location is 'C:\Program Files (x86)\GNU\units' (for 64-bit + On systems running Microsoft Windows, the files may be in the same + locations if Unix-like commands are available, a Unix-like file struc- + ture is present (e.g., 'C:/usr/local'), and 'units' is compiled from + the source distribution. If Unix-like commands are not available, a + more common location is 'C:\Program Files (x86)\GNU\units' (for 64-bit Windows installations) or 'C:\Program Files\GNU\units' (for 32-bit installations). - If 'units' is obtained from the GNU Win32 Project + If 'units' is obtained from the GNU Win32 Project (http://gnuwin32.sourceforge.net/), the files are commonly in 'C:\Program Files\GnuWin32\share\units'. - If the default units data file is not an absolute pathname, 'units' - will look for the file in the directory that contains the 'units' pro- - gram; if the file is not found there, 'units' will look in a directory + If the default units data file is not an absolute pathname, 'units' + will look for the file in the directory that contains the 'units' pro- + gram; if the file is not found there, 'units' will look in a directory '../share/units' relative to the directory with the 'units' program. - You can determine the location of the files by running - 'units --version'. Running 'units --info' will give you additional + You can determine the location of the files by running + 'units --version'. Running 'units --info' will give you additional information about the files, how 'units' will attempt to find them, and the status of the related environment variables. @@ -2449,40 +2564,49 @@ U+007F); definitions using non-ASCII characters appear in blocks begin- ning with '!utf8' and ending with '!endutf8'. - When 'units' starts, it checks the locale to determine the character - set. If 'units' is compiled with Unicode support and definitions; oth- - erwise these definitions are ignored. When Unicode support is active, - 'units' will check every line of all of the units data files for - invalid or non-printing UTF-8 sequences; if such sequences occur, - 'units' ignores the entire line. In addition to checking validity, - 'units' determines the display width of non-ASCII characters to ensure - proper positioning of the pointer in some error messages and to align - columns for the 'search' and '?' commands. - - At present, 'units' does not support Unicode under Microsoft Windows. - The UTF-16 and UTF-32 encodings are not supported on any systems. - - If definitions that contain non-ASCII characters are added to a units - data file, those definitions should be enclosed within '!utf8' ... - '!endutf8' to ensure that they are only loaded when Unicode support is - available. As usual, the '!' must appear as the first character on - the line. As discussed in Units Data Files, it's usually best to put - such definitions in supplemental data files linked by an '!include' - command or in a personal units data file. - - When Unicode support is not active, 'units' makes no assumptions about - character encoding, except that characters in the range 00-7F hexadeci- - mal correspond to ASCII encoding. Non-ASCII characters are simply - sequences of bytes, and have no special meanings; for definitions in - supplementary units data files, you can use any encoding consistent - with this assumption. For example, if you wish to use non-ASCII char- - acters in definitions when running 'units' under Windows, you can use a - character set such as Windows ``ANSI'' (code page 1252 in the US and - Western Europe). You can even use UTF-8, though some messages may be - improperly aligned, and 'units' will not detect invalid UTF-8 - sequences. If you use UTF-8 encoding when Unicode support is not - active, you should place any definitions with non-ASCII characters out- - side '!utf8' ... '!endutf8' blocks--otherwise, they will be ignored. + The non-ASCII definitions are loaded only if the platform and the + locale support UTF-8. Platform support is determined when 'units' is + compiled; the locale is checked at every invocation of 'units'. To see + if your version of 'units' includes Unicode support, invoke the program + with the '--version' option. + + When Unicode support is available, 'units' checks every line within + UTF-8 blocks in all of the units data files for invalid or non-printing + UTF-8 sequences; if such sequences occur, 'units' ignores the entire + line. In addition to checking validity, 'units' determines the display + width of non-ASCII characters to ensure proper positioning of the + pointer in some error messages and to align columns for the 'search' + and '?' commands. + + As of early 2019, Microsoft Windows provides limited support for UTF-8 + in console applications, and accordingly, 'units' does not support Uni- + code on Windows. The UTF-16 and UTF-32 encodings are not supported on + any platforms. + + If Unicode support is available and definitions that contain non-ASCII + UTF-8 characters are added to a units data file, those definitions + should be enclosed within '!utf8' ... '!endutf8' to ensure that they + are only loaded when Unicode support is available. As usual, the '!' + must appear as the first character on the line. As discussed in Units + Data Files, it's usually best to put such definitions in supplemental + data files linked by an '!include' command or in a personal units data + file. + + When Unicode support is not available, 'units' makes no assumptions + about character encoding, except that characters in the range 00-7F + hexadecimal correspond to ASCII encoding. Non-ASCII characters are + simply sequences of bytes, and have no special meanings; for defini- + tions in supplementary units data files, you can use any encoding con- + sistent with this assumption. For example, if you wish to use non- + ASCII characters in definitions when running 'units' under Windows, you + can use a character set such as Windows "ANSI" (code page 1252 in the + US and Western Europe); if this is done, the console code page must be + set to the same encoding for the characters to display properly. You + can even use UTF-8, though some messages may be improperly aligned, and + 'units' will not detect invalid UTF-8 sequences. If you use UTF-8 + encoding when Unicode support is not available, you should place any + definitions with non-ASCII characters outside '!utf8' ... '!endutf8' + blocks--otherwise, they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) @@ -2503,7 +2627,7 @@ allow editing in the style of emacs. Of particular use with 'units' are the completion commands. - If you type a few characters and then hit ESC followed by '?' then + If you type a few characters and then hit ESC followed by '?', then 'units' will display a list of all the units that start with the char- acters typed. For example, if you type 'metr' and then request comple- tion, you will see something like this: @@ -2659,12 +2783,12 @@ !message text Display text when the database is read unless the quiet option - ('-q') is enabled. If you omit text then units will display a + ('-q') is enabled. If you omit text, then units will display a blank line. Messages will also appear in the log file. !prompt text Prefix the 'You have:' prompt with the specified text. If you - omit text then any existing prefix is canceled. + omit text, then any existing prefix is canceled. !set variable value Sets the environment variable, variable, to the specified value @@ -2688,10 +2812,13 @@ space-separated value list. If envar is not set, 'units' prints an error message and ignores the block of definitions. -GNU FREE DOCUMENTATION LICENSE FILES /usr/local/share/units/definitions.units -- the standard units data file AUTHOR - 20 October 2018 UNITS(1) + units was written by Adrian Mariano + + + + 19 March 2019 UNITS(1)