units-2.02/ 0000777 0001750 0001750 00000000000 12167664614 012076 5 ustar adrian adrian units-2.02/Makefile.in 0000664 0001750 0001750 00000017051 12167664474 014151 0 ustar adrian adrian # Makefile for units, a program for units conversion
#
# Copyright (C) 1996, 1997, 1999, 2005, 2006, 2012
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# This program was written by Adrian Mariano (adrian@cam.cornell.edu)
#
SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
CC = @CC@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
TEXI2PDF = texi2pdf
LDFLAGS = @LDFLAGS@
LIBS= @LIBS@
VPATH = @srcdir@
datarootdir = @datarootdir@
datadir = @datadir@
bindir = @bindir@
infodir = @infodir@
mandir = @mandir@
transform=@program_transform_name@
DEFS=-DUNITSFILE=\"@UDAT@definitions.units\" -DLOCALEMAP=\"@UDAT@locale.map\" \
@DEFIS@ @DEFS@
CFLAGS = @CFLAGS@
OBJECTS = units.@OBJEXT@ parse.tab.@OBJEXT@ getopt.@OBJEXT@ getopt1.@OBJEXT@ @STRFUNC@
.SUFFIXES:
.SUFFIXES: .c .@OBJEXT@
.c.@OBJEXT@:
$(CC) $(DEFS) $(CFLAGS) -I$(srcdir) -c $<
# %.@OBJEXT@: %.c
# $(CC) $(DEFS) $(CFLAGS) -I$(srcdir) -c %.c
DISTFILES = README ChangeLog units.info units.txt getopt1.c units.dvi \
Makefile.in units.c getopt.c getopt.h definitions.units units.texinfo \
configure.ac configure strfunc.c COPYING Makefile.dos install-sh units.man \
mkinstalldirs NEWS texi2man INSTALL units.pdf units_cur currency.units \
parse.tab.c parse.y units.h Makefile.OS2 makeobjs.cmd README.OS2 \
README.MKS locale.map fdl-1.3.texi
all: units@EXEEXT@ units.1 units.info units_cur_inst
units.@OBJEXT@: units.c
parse.tab.c: parse.y
bison parse.y
parse.tab.@OBJEXT@: parse.tab.c
units@EXEEXT@: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o units@EXEEXT@ $(OBJECTS) $(LIBS)
units_cur_inst: units_cur
sed -e "s:outfile = 'currency.units':outfile='@UDAT@currency.units':" units_cur > units_cur_inst
install-support: definitions.units currency.units units_cur_inst
$(srcdir)/mkinstalldirs $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir)
$(INSTALL_DATA) $(srcdir)/definitions.units $(DESTDIR)@UDAT@definitions.units
$(INSTALL_DATA) $(srcdir)/currency.units $(DESTDIR)@UDAT@currency.units
$(INSTALL_DATA) $(srcdir)/locale.map $(DESTDIR)@UDAT@locale.map
$(INSTALL_PROGRAM) units_cur_inst $(DESTDIR)$(bindir)/`echo units_cur|sed '$(transform)'`
install: units@EXEEXT@ install-doc install-support
$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) units@EXEEXT@ $(DESTDIR)$(bindir)/`echo units@EXEEXT@|sed '$(transform)'`
install-strip: units@EXEEXT@ install-doc install-support
$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -s units@EXEEXT@ $(DESTDIR)$(bindir)/`echo units@EXEEXT@|sed '$(transform)'`
install-doc: install-man install-info
install-man: units.1
$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) units.1 $(DESTDIR)$(mandir)/man1/`echo units|sed '$(transform)'`.1
units.man: units.texinfo texi2man
./texi2man units.texinfo > units.man
units.1: units.man
sed s!@DATAFILE@!@UDAT@definitions.units! $(srcdir)/units.man > units.1
install-info: $(DESTDIR)$(infodir)/units.info
$(DESTDIR)$(infodir)/units.info: units.info
$(POST_INSTALL)
$(srcdir)/mkinstalldirs $(DESTDIR)$(infodir)
# There may be a newer info file in . than in srcdir.
-if test -f units.info; then d=.; \
else d=$(srcdir); fi; \
$(INSTALL_DATA) $$d/units.info $@; \
# Run install-info only if it exists.
# Use `if' instead of just prepending `-' to the
# line so we notice real errors from install-info.
# We use `$(SHELL) -c' because some shells do not
# fail gracefully when there is an unknown command.
if test -f $(DESTDIR)$(infodir)/dir; then \
if $(SHELL) -c 'install-info --version' \
>/dev/null 2>&1; then \
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(DESTDIR)$(infodir)/units.info; \
else true; fi \
else true; fi
Makefile: Makefile.in config.status
./config.status
uninstall:
-rm -f $(DESTDIR)$(bindir)/`echo units@EXEEXT@|sed '$(transform)'` \
$(DESTDIR)$(mandir)/man1/`echo units|sed '$(transform)'`.1 \
$(DESTDIR)$(infodir)/units.info \
$(DESTDIR)@UDAT@definitions.units \
$(DESTDIR)@UDAT@currency.units \
@if test -f $(DESTDIR)$(infodir)/dir; then \
echo You may need to remove units.info from $(DESTDIR)$(infodir)/dir; \
else true; fi
clean mostlyclean:
-rm -f *.@OBJEXT@ units@EXEEXT@ units.fn units.ky units.pg units.tp \
units.vr units.log units.dvi units.1 units.cp distname .chk \
units.toc units.aux units.cps units.op units_cur_inst
distclean: clean
-rm -f config.* Makefile TAGS
maintainer-clean: clean
-rm -f units.txt units.info units.pdf units.dvi \
units-*.tar.gz parse.tab.c currency.units
currency.units:
./units_cur
sig:
echo units-`sed -n -e '/#.*VERSION/s/.*"\(.*\)"/\1/gp' \
$(srcdir)/units.c`.tar.gz > distname
echo 'version: 1.1' > `cat distname`.directive
echo 'directory: units' >> `cat distname`.directive
echo 'filename: '`cat distname` >> `cat distname`.directive
gpg --clearsign `cat distname`.directive
gpg -b `cat distname`
-rm -f `cat distname`.directive distname
dist: $(DISTFILES)
./units_cur
echo units-`sed -n -e '/#.*VERSION/s/.*"\(.*\)"/\1/gp' \
$(srcdir)/units.c` > distname
-rm -r `cat distname` `cat distname`.tar `cat distname`.tar.gz
mkdir `cat distname`
dst=`cat distname`; for f in $(DISTFILES); do \
ln $(srcdir)/$$f $$dst/$$f || { echo copying $$f; \
cp -p $(srcdir)/$$f $$dst/$$f ; } \
done
chmod 777 `cat distname`
tar cf `cat distname`.tar `cat distname`
gzip `cat distname`.tar
-rm -rf `cat distname` distname
dvi: units.dvi
pdf: units.pdf
units.dvi: units.texinfo
$(TEXI2DVI) $(srcdir)/units.texinfo
units.pdf: units.texinfo
$(TEXI2PDF) $(srcdir)/units.texinfo
info: units.info
units.info: units.texinfo
$(MAKEINFO) $(srcdir)/units.texinfo
units.txt: units.1
nroff -man $(srcdir)/units.1 | col -b > units.txt
doc: units.dvi units.info units.txt units.pdf
check: all
@echo Checking units
@./units -f $(srcdir)/definitions.units \
'(((square(kiloinch)+2.84m2) /0.5) meters^2)^(1|4)' m \
| sed -n -e 's/ \* //p' > .chk
@if [ "`cat .chk`" = 6 ]; then echo Units seems to work; \
else echo Something is wrong: units failed the check: ;cat .chk; fi
@rm -f .chk
configure: configure.ac
autoconf
TAGS: units.c
etags $(srcdir)/units.c $(srcdir)/parse.y
smalldist: units.c units.h parse.y parse.tab.c
echo units-`sed -n -e '/#.*VERSION/s/.*"\(.*\)"/\1/gp' \
$(srcdir)/units.c` > distname
-rm -r `cat distname` `cat distname`.tar `cat distname`.tar.gz
tar cf `cat distname`.tar units.c units.h parse.y parse.tab.c\
getopt1.c getopt.c getopt.h
gzip `cat distname`.tar
#
# Not very portable code to compile into library (written for Linux)
#
libunits.a: $(OBJECTS)
ar -r libunits.a $^
libunits.so: $(OBJECTS)
$(CC) $(LDFLAGS) -shared -o $@ $^
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
units-2.02/COPYING 0000664 0001750 0001750 00000104513 10642156735 013127 0 ustar adrian adrian GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
units-2.02/strfunc.c 0000664 0001750 0001750 00000004231 10641165333 013711 0 ustar adrian adrian /*
* Copyright (C) 1996 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#define NULL 0
#define size_t int
#ifdef NO_STRTOK
/* Find the first ocurrence in S of any character in ACCEPT. */
char *
strpbrk(char *s, char *accept)
{
while (*s != '\0')
if (strchr(accept, *s) == NULL)
++s;
else
return (char *) s;
return NULL;
}
static char *olds = NULL;
char *
strtok(char *s, char *delim)
{
char *token;
if (s == NULL)
{
if (olds == NULL)
{
/*errno = EINVAL; Wonder where errno is defined....*/
return NULL;
}
else
s = olds;
}
/* Scan leading delimiters. */
s += strspn(s, delim);
if (*s == '\0')
{
olds = NULL;
return NULL;
}
/* Find the end of the token. */
token = s;
s = strpbrk(token, delim);
if (s == NULL)
/* This token finishes the string. */
olds = NULL;
else
{
/* Terminate the token and make OLDS point past it. */
*s = '\0';
olds = s + 1;
}
return token;
}
#endif /* NO_STRTOK */
#ifdef NO_STRSPN
/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
size_t
strspn(char *s, char *accept)
{
register char *p;
register char *a;
register size_t count = 0;
for (p = s; *p != '\0'; ++p)
{
for (a = accept; *a != '\0'; ++a)
if (*p == *a)
break;
if (*a == '\0')
return count;
else
++count;
}
return count;
}
#endif NO_STRSPN
units-2.02/README.MKS 0000600 0001750 0001750 00000002664 12041216471 013364 0 ustar adrian adrian This comments in this file are based on MKS Toolkit for developers,
version 9.4, running on Windows XP Professional, SP3. The configure
script was generated by GNU Autoconf 2.68.
The most recent build of units with the Toolkit (using Microsoft Visual
C/C++ 6.0) was for version 2.00b on 21 October 2012.
Configure
---------
Configure will fail unless invoked as
PATH_SEPARATOR=';' configure
Compilation
-----------
The MKS version of make ignores suffix rules in Makefile unless the line
.POSIX
appears in Makefile before any suffix rules. This can also be
accomplished by setting and exporting
TK_USE_SFX_RULE=1
but this will cause any existing Makefile that depends on the default
behavior of MKS make to fail.
Behavior of PAGER
-----------------
The MKS versions of more and less do not recognize '+n' as an option to
display a file beginning at line n, so help from within units
will fail. To avoid this problem, add
-D_MKS_TOOLKIT
to the DEFS in Makefile.
Install Program
---------------
If the PATH at shell invocation uses the backslash as the path
separator, and you have a BSD-compatible install program, the Makefile
may have the incorrect entry
INSTALL = c:usrlocalbin/install.exe -c
Add the slashes to get
INSTALL = c:/usr/local/bin/install.exe -c
Giving a PATH with forward slashes in a file given by ENV will have no
effect because configure unsets that variable, and the file will not be
read.
units-2.02/units.info 0000664 0001750 0001750 00000420470 12166761265 014121 0 ustar adrian adrian This is units.info, produced by makeinfo version 4.13 from
./units.texinfo.
This manual is for GNU Units (version 2.02), which performs units
conversions and units calculations.
Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007,
2011, 2012, 2013 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. A copy of the license is included
in the section entitled "GNU Free Documentation License".
INFO-DIR-SECTION Science
START-INFO-DIR-ENTRY
* Units: (units). Units conversion and scientific calculation.
END-INFO-DIR-ENTRY
File: units.info, Node: Top, Next: Overview, Up: (dir)
Units Conversion
****************
This manual describes the `units' command for units conversion and how
you can use it as a powerful scientific calculator that keeps track of
units. This is Edition 2.02 of `The Units Conversion Manual' for
`units' Version 2.02.
* Menu:
* Overview:: What does `units' do?
* Interactive Use:: How to use `units'.
* Command Line Use:: How to use `units' noninteractively.
* Unit Definitions:: What units are defined?
* Unit Expressions:: Forming compound units.
* Nonlinear Conversions:: Nonlinear unit conversions (e.g., temperature)
* Unit Lists:: Conversion to sums of units (e.g., feet and inches)
* Invoking Units:: Command line options.
* 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.
* Environment Vars:: Environment variables used by `units'.
* Unicode Support:: Support for Unicode (UTF-8).
* Readline Support:: Unit name completion and editing.
* Currency:: Updating currency exchange rates.
* Database Syntax:: Summary of database command syntax.
* GNU Free Documentation License:: License.
* Index:: General index.
File: units.info, Node: Overview, Next: Interactive Use, Prev: Top, Up: Top
1 Overview of `units'
*********************
The `units' program converts quantities expressed in various systems of
measurement to their equivalents in other systems of measurement. Like
many similar programs, it can handle multiplicative scale changes. It
can also handle nonlinear conversions such as Fahrenheit to Celsius.(1)
*Note Temperature Conversions::. The program can also perform
conversions from and to sums of units, such as converting between
meters and feet plus inches.
Beyond simple unit conversions, `units' can be used as a
general-purpose scientific calculator that keeps track of units in its
calculations. You can form arbitrary complex mathematical expressions
of dimensions including sums, products, quotients, powers, and even
roots of dimensions. Thus you can ensure accuracy and dimensional
consistency when working with long expressions that involve many
different units that may combine in complex ways.
The units are defined in an external data file. You can use the
extensive data file that comes with this program, or you can provide
your own data file to suit your needs. You can also use your own data
file to supplement the standard data file.
Basic operation is simple: you enter the units that you want to
convert _from_ and the units that you want to convert _to_. You can
use the program interactively with prompts, or you can use it from the
command line.
You can change the default behavior of `units' with various options
given on the command line. *Note Invoking Units::, for a description of
the available options.
---------- Footnotes ----------
(1) But Fahrenheit to Celsius is linear, you insist. Not so. A
transformation T is linear if T(x+y)=T(x)+T(y) and this fails for
T(x)=ax+b. This transformation is affine, but not linear.
File: units.info, Node: Interactive Use, Next: Command Line Use, Prev: Overview, Up: Top
2 Interacting with `units'
**************************
To invoke units for interactive use, type `units' at your shell prompt.
The program will print something like this:
Currency exchange rates from 04/23/12
2516 units, 85 prefixes, 65 nonlinear units
You have:
At the `You have:' prompt, type the quantity and units that you are
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
the tab key can be used to complete unit names. *Note Readline
Support::, for more information about `readline'. To quit the program
press Ctrl-C or Ctrl-D under Unix. Under Windows press Ctrl-Z.
The answer will be displayed in two ways. The first line of output,
which is marked with a `*' to indicate multiplication, gives the result
of the conversion you have asked for. The second line of output, which
is marked with a `/' to indicate division, gives the inverse of the
conversion factor. If you convert 10 meters to feet, `units' will print
* 32.808399
/ 0.03048
which tells you that 10 meters equals about 32.8 feet. The second
number gives the conversion in the opposite direction. In this case,
it tells you that 1 foot is equal to about 0.03 dekameters since the
dekameter is 10 meters. It also tells you that 1/32.8 is about 0.03.
The `units' program prints the inverse because sometimes it is a
more convenient number. In the example above, for example, the inverse
value is an exact conversion: a foot is exactly 0.03048 dekameters.
But the number given the other direction is inexact.
If you convert grains to pounds, you will see the following:
You have: grains
You want: pounds
* 0.00014285714
/ 7000
From the second line of the output you can immediately see that a grain
is equal to a seven thousandth of a pound. This is not so obvious from
the first line of the output. If you find the output format
confusing, try using the `--verbose' option:
You have: grain
You want: aeginamina
grain = 0.00010416667 aeginamina
grain = (1 / 9600) aeginamina
If you request a conversion between units that measure reciprocal
dimensions, then `units' will display the conversion results with an
extra note indicating that reciprocal conversion has been done:
You have: 6 ohms
You want: siemens
reciprocal conversion
* 0.16666667
/ 6
Reciprocal conversion can be suppressed by using the `--strict' option.
As usual, use the `--verbose' option to get more comprehensible output:
You have: tex
You want: typp
reciprocal conversion
1 / tex = 496.05465 typp
1 / tex = (1 / 0.0020159069) typp
You have: 20 mph
You want: sec/mile
reciprocal conversion
1 / 20 mph = 180 sec/mile
1 / 20 mph = (1 / 0.0055555556) sec/mile
If you enter incompatible unit types, the `units' program will print a
message indicating that the units are not conformable and it will
display the reduced form for each unit:
You have: ergs/hour
You want: fathoms kg^2 / day
conformability error
2.7777778e-11 kg m^2 / sec^3
2.1166667e-05 kg^2 m / sec
If you only want to find the reduced form or definition of a unit,
simply press at the `You want:' prompt. Here is an example:
You have: jansky
You want:
Definition: fluxunit = 1e-26 W/m^2 Hz = 1e-26 kg / s^2
The output from `units' indicates that the jansky is defined to be
equal to a fluxunit which in turn is defined to be a certain combination
of watts, meters, and hertz. The fully reduced (and in this case
somewhat more cryptic) form appears on the far right.
Some named units are treated as dimensionless in some situations.
These units include the radian and steradian. These units will be
treated as equal to 1 in units conversions. Power is equal to torque
times angular velocity. This conversion can only be performed if the
radian is dimensionless.
You have: (14 ft lbf) (12 radians/sec)
You want: watts
* 227.77742
/ 0.0043902509
Named dimensionless units are not treated as dimensionless in other
contexts. They cannot be used as exponents so for example,
`meter^radian' is not allowed.
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
conformable with the unit that you entered at the `You have:' prompt
above. Conformable unit _combinations_ will not appear on this list.
Typing `help' at either prompt displays a short help message. You
can also type `help' followed by a unit name. This will invoke a pager
on the units data base at the point where that unit is defined. You
can read the definition and comments that may give more details or
historical information about the unit. (You can generally quit out of
the page by pressing `q'.)
Typing `search' TEXT will display a list of all of the units whose
names contain TEXT as a substring along with their definitions. This
may help in the case where you aren't sure of the right unit name.
File: units.info, Node: Command Line Use, Next: Unit Definitions, Prev: Interactive Use, Up: Top
3 Using `units' Non-Interactively
*********************************
The `units' program can perform units conversions non-interactively
from the command line. To do this, type the command, type the original
unit expression, and type the new units you want. If a units
expression contains non-alphanumeric characters, you may need to protect
it from interpretation by the shell using single or double quote
characters.
If you type
units "2 liters" quarts
then `units' will print
* 2.1133764
/ 0.47317647
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.
File: units.info, Node: Unit Definitions, Next: Unit Expressions, Prev: Command Line Use, Up: Top
4 Unit Definitions
******************
The conversion information is read from a units data file that is
called `definitions.units' and is usually located in the
`/usr/share/units' directory. If you invoke `units' with the `-V'
option, it will print the location of this file. The default file
includes definitions for all familiar units, abbreviations and metric
prefixes. It also includes many obscure or archaic units.
Many constants of nature are defined, including these:
pi ratio of circumference to diameter
c speed of light
e charge on an electron
force acceleration of gravity
mole Avogadro's number
water pressure per unit height of water
Hg pressure per unit height of mercury
au astronomical unit
k Boltzman's constant
mu0 permeability of vacuum
epsilon0 permittivity of vacuum
G Gravitational constant
mach speed of sound
The standard data file includes atomic masses for all of the elements
and numerous other constants. Also included are the densities of
various ingredients used in baking so that `2 cups flour_sifted' can be
converted to `grams'. This is not an exhaustive list. Consult the
units data file to see the complete list, or to see the definitions
that are used.
The `pound' is a unit of mass. To get force, multiply by the force
conversion unit `force' or use the shorthand `lbf'. (Note that `g' is
already taken as the standard abbreviation for the gram.) The unit
`ounce' is also a unit of mass. The fluid ounce is `fluidounce' or
`floz'. British capacity units that differ from their US counterparts,
such as the British Imperial gallon, are prefixed with `br'. Currency
is prefixed with its country name: `belgiumfranc', `britainpound'.
When searching for a unit, if the specified string does not appear
exactly as a unit name, then the `units' program will try to remove a
trailing `s', `es'. Next units will replace a trailing `ies' with `y'.
If that fails, `units' will check for a prefix. The database includes
all of the standard metric prefixes. Only one prefix is permitted per
unit, so `micromicrofarad' will fail. However, prefixes can appear
alone with no unit following them, so `micro*microfarad' will work, as
will `micro microfarad'.
To find out which units and prefixes are available, read the standard
units data file, which is extensively annotated.
4.1 English Customary Units
===========================
English customary units differ in various ways in different regions.
In Britain a complex system of volume measurements featured different
gallons for different materials such as a wine gallon and ale gallon
that different by twenty percent. This complexity was swept away in
1824 by a reform that created an entirely new gallon, the British
Imperial gallon defined as the volume occupied by ten pounds of water.
Meanwhile in the USA the gallon is derived from the 1707 Winchester
wine gallon, which is 231 cubic inches. These gallons differ by about
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
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.
Before 1959, the value of a yard (and other units of measure defined
in terms of it) differed slightly among English-speaking countries. In
1959, Australia, Canada, New Zealand, the United Kingdom, the United
States, and South Africa adopted the Canadian value of 1 yard =
0.9144 m (exactly), which was approximately halfway between the values
used by the UK and the US; it had the additional advantage of making
1 inch = 2.54 cm (exactly). This new standard was termed the
"International Yard". Australia, Canada, and the UK then defined all
customary lengths in terms of the International Yard (Australia did not
define the furlong or rod); because many US land surveys were in terms
of the pre-1959 units, the US continued to define customary surveyors'
units (furlong, chain, rod, and link) in terms of the previous value
for the foot, which was termed the "US survey foot". The US defined a
"US survey mile" as 5280 US survey feet, and defined a "statute mile"
as a US survey mile. The US values for these units differ from the
international values by about 2 ppm.
The `units' program uses the international values for these units;
the US values can be obtained by using either the `US' or the `survey'
prefix. In either case, the simple familiar relationships among the
units are maintained, e.g., 1 `furlong' = 660 `ft', and 1 `USfurlong' =
660 `USft', though the metric equivalents differ slightly between the
two cases. The `US' prefix or the `survey' prefix can also be used to
obtain the US survey mile and the value of the US yard prior to 1959,
e.g., `USmile' or `surveymile' (but _not_ `USsurveymile'). To get the
US value of the statute mile, use either `USstatutemile' or `USmile'.
Except for distances that extend over hundreds of miles (such as in
the US State Plane Coordinate System), the differences in the miles are
usually insignificant:
You have: 100 surveymile - 100 mile
You want: inch
* 12.672025
/ 0.078913984
The pre-1959 UK values for these units can be obtained with the prefix
`UK'.
In the US, the acre is officially defined in terms of the US survey
foot, but `units' uses a definition based on the international foot.
If you want the official US acre use `USacre' and similarly use
`USacrefoot' for the official US version of that unit. The difference
between these units is about 4 parts per million.
File: units.info, Node: Unit Expressions, Next: Nonlinear Conversions, Prev: Unit Definitions, Up: Top
5 Unit Expressions
******************
* Menu:
* Operators:: The usual arithmetic operators, with a few extras
* Sums and Differences of Units:: Adding and subtracting units
* Numbers as Units:: A number is a dimensionless unit
* Built-in Functions:: Trigonometric functions, logarithms, roots
* Complicated Unit Expressions:: A complicated example
* Backwards Compatibility:: Alternate behavior for `*' and `-'
File: units.info, Node: Operators, Next: Sums and Differences of Units, Up: Unit Expressions
5.1 Operators
=============
You can enter more complicated units by combining units with operations
such as powers, multiplication, division, addition, subtraction, and
parentheses for grouping. You can use the customary symbols for these
operators when `units' is invoked with its default options.
Additionally, `units' supports some extensions, including high priority
multiplication using a space, and a high priority numerical division
operator (`|') that can simplify some expressions.
Powers of units can be specified using the `^' character as shown in
the following example, or by simple concatenation of a unit and its
exponent: `cm3' is equivalent to `cm^3'; if the exponent is more than
one digit, the `^' is required. An exponent like `2^3^2' is evaluated
right to left as usual. The `^' operator has the second highest
precedence. You can also use `**' as an exponent operator.
You have: cm^3
You want: gallons
* 0.00026417205
/ 3785.4118
You have: arabicfoot * arabictradepound * force
You want: ft lbf
* 0.7296
/ 1.370614
You multiply units using a space or an asterisk (`*'). The example
above shows both forms. You can divide units using the slash (`/') or
with `per'.
You have: furlongs per fortnight
You want: m/s
* 0.00016630986
/ 6012.8727
When a unit includes a prefix, exponent operators apply to the
combination, so `centimeter^3' gives cubic centimeters. If you separate
the prefix from the unit with any multiplication operator, such as
`centi meter^3', then the prefix is treated as a separate unit, so the
exponent does not apply. The second example would be a hundredth of a
cubic meter, not a centimeter.
Multiplication using a space has a higher precedence than division
using a slash and is evaluated left to right; in effect, the first `/'
character marks the beginning of the denominator of a unit expression.
This makes it simple to enter a quotient with several terms in the
denominator: `W / m^2 Hz'. If you multiply with `*' then you must
group the terms in the denominator with parentheses: `W / (m^2 * Hz)'.
The higher precedence of the space operator may not always be
advantageous. For example, `m/s s/day' is equivalent to `m / s s day'
and has dimensions of length per time cubed. Similarly, `1/2 meter'
refers to a unit of reciprocal length equivalent to 0.5/meter, perhaps
not what you would intend if you entered that expression. The `*'
operator is convenient for multiplying a sequence of quotients. With
the `*' operator, the example above becomes `m/s * s/day', which is
equivalent to `m/day'. Similarly, you could write `1/2 * meter' to get
half a meter. Alternatively, parentheses can be used for grouping: you
could write `(1/2) meter' to get half a meter. *Note Complicated Unit
Expressions::, for an illustration of the various options.
The `units' program supports another option for numerical fractions.
You can indicate division of _numbers_ with the vertical bar (`|'), so
if you wanted half a meter you could write `1|2 meter'. This operator
has the highest precedence, so you can write the square root of two
thirds `2|3^1|2'. You cannot use the vertical bar to indicate division
of non-numerical units (e.g., `m|s' results in an error message).
You have: 1|2 inch
You want: cm
* 1.27
/ 0.78740157
You can use parentheses for grouping:
You have: (1/2) kg / (kg/meter)
You want: league
* 0.00010356166
/ 9656.0833
File: units.info, Node: Sums and Differences of Units, Next: Numbers as Units, Prev: Operators, Up: Unit Expressions
5.2 Sums and Differences of Units
=================================
You may sometimes want to add values of different units that are
outside the SI. You may also wish to use `units' as a calculator that
keeps track of units. Sums of conformable units are written with the
`+' character, and differences with the `-' character.
You have: 2 hours + 23 minutes + 32 seconds
You want: seconds
* 8612
/ 0.00011611705
You have: 12 ft + 3 in
You want: cm
* 373.38
/ 0.0026782366
You have: 2 btu + 450 ft lbf
You want: btu
* 2.5782804
/ 0.38785542
The expressions that are added or subtracted must reduce to identical
expressions in primitive units, or an error message will be displayed:
You have: 12 printerspoint - 4 heredium
^
Illegal sum of non-conformable units
As usual, the precedence for `+' and `-' is lower than that of the
other operators. A fractional quantity such as 2 1/2 cups can be given
as `(2+1|2) cups'; the parentheses are necessary because multiplication
has higher precedence than addition. If you omit the parentheses,
`units' attempts to add `2' and `1|2 cups', and you get an error
message:
You have: 2+1|2 cups
^
Illegal sum or difference of non-conformable units
The expression could also be correctly written as `(2+1/2) cups'. If
you write `2 1|2 cups' the space is interpreted as _multiplication_ so
the result is the same as `1 cup'.
The `+' and `-' characters sometimes appears in exponents like
`3.43e+8'. This leads to an ambiguity in an expression like `3e+2 yC'.
The unit `e' is a small unit of charge, so this can be regarded as
equivalent to `(3e+2) yC' or `(3 e)+(2 yC)'. This ambiguity is
resolved by always interpreting `+' and `-' as part of an exponent if
possible.
File: units.info, Node: Numbers as Units, Next: Built-in Functions, Prev: Sums and Differences of Units, Up: Unit Expressions
5.3 Numbers as Units
====================
For `units', numbers are just another kind of unit. They can appear as
many times as you like and in any order in a unit expression. For
example, to find the volume of a box that is 2 ft by 3 ft by 12 ft in
steres, you could do the following:
You have: 2 ft 3 ft 12 ft
You want: stere
* 2.038813
/ 0.49048148
You have: $ 5 / yard
You want: cents / inch
* 13.888889
/ 0.072
And the second example shows how the dollar sign in the units conversion
can precede the five. Be careful: `units' will interpret `$5' with no
space as equivalent to `dollar^5'.
File: units.info, Node: Built-in Functions, Next: Complicated Unit Expressions, Prev: Numbers as Units, Up: Unit Expressions
5.4 Built-in Functions
======================
Several built-in functions are provided: `sin', `cos', `tan', `ln',
`log', `log2', `exp', `acos', `atan' and `asin'. The `sin', `cos', and
`tan' functions require either a dimensionless argument or an argument
with dimensions of angle.
You have: sin(30 degrees)
You want:
Definition: 0.5
You have: sin(pi/2)
You want:
Definition: 1
You have: sin(3 kg)
^
Unit not dimensionless
The other functions on the list require dimensionless arguments. The
inverse trigonometric functions return arguments with dimensions of
angle.
If you wish to take roots of units, you may use the `sqrt' or
`cuberoot' functions. These functions require that the argument have
the appropriate root. You can obtain higher roots by using fractional
exponents:
You have: sqrt(acre)
You want: feet
* 208.71074
/ 0.0047913202
You have: (400 W/m^2 / stefanboltzmann)^(1/4)
You have:
Definition: 289.80882 K
You have: cuberoot(hectare)
^
Unit not a root
File: units.info, Node: Complicated Unit Expressions, Next: Backwards Compatibility, Prev: Built-in Functions, Up: Unit Expressions
5.5 Complicated Unit Expressions
================================
The `units' program is especially helpful in ensuring accuracy and
dimensional consistency when converting lengthy unit expressions. For
example, one form of the Darcy-Weisbach fluid-flow equation is
Delta P = (8/pi^2) rho f L (Q^2 / d^5)
where \Delta P is the pressure drop, \rho is the mass density, f is
the (dimensionless) friction factor, L is the length of the pipe, Q is
the volumetric flow rate, and d is the pipe diameter. It might be
desired to have the equation in the form
Delta P = A1 rho f L (Q^2 / d^5)
that accepted the user's normal units; for typical units used in the US,
the required conversion could be something like
You have: (8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)
You want: psi
* 43.533969
/ 0.022970568
The parentheses allow individual terms in the expression to be entered
naturally, as they might be read from the formula. Alternatively, the
multiplication could be done with the `*' rather than a space; then
parentheses are needed only around `ft^3/s' because of its exponent:
You have: 8/pi^2 * lbm/ft^3 * ft * (ft^3/s)^2 /in^5
You want: psi
* 43.533969
/ 0.022970568
Without parentheses, and using spaces for multiplication, the previous
conversion would need to be entered as
You have: 8 lb ft ft^3 ft^3 / pi^2 ft^3 s^2 in^5
You want: psi
* 43.533969
/ 0.022970568
File: units.info, Node: Backwards Compatibility, Prev: Complicated Unit Expressions, Up: Unit Expressions
5.6 Backwards Compatibility: `*' and `-'
========================================
The original `units' assigned multiplication a higher precedence than
division using the slash. This differs from the usual precedence
rules, which give multiplication and division equal precedence, and can
be confusing for people who think of units as a calculator.
The star operator (`*') included in this `units' program has, by
default, the same precedence as division, and hence follows the usual
precedence rules. For backwards compatibility you can invoke `units'
with the `--oldstar' option. Then `*' has a higher precedence than
division, and the same precedence as multiplication using the space.
Historically, the hyphen (`-') has been used in technical
publications to indicate products of units, and the original `units'
program treated it as a multiplication operator. Because `units'
provides several other ways to obtain unit products, and because `-' is
a subtraction operator in general algebraic expressions, `units' treats
the binary `-' as a subtraction operator by default. For backwards
compatibility use the `--product' option, which causes `units' to treat
the binary `-' operator as a product operator. When `-' is a
multiplication operator it has the same precedence as multiplication
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
must use this construction when you define new units because you cannot
know what options will be in force when your definition is processed.
File: units.info, Node: Nonlinear Conversions, Next: Unit Lists, Prev: Unit Expressions, Up: Top
6 Nonlinear Unit Conversions
****************************
Nonlinear units are represented using functional notation. They make
possible nonlinear unit conversions such as temperature.
* Menu:
* Temperature Conversions:: Conversion between temperature scales
* Other Nonlinear Units:: Ring size, wire gauge, abrasive grit size
File: units.info, Node: Temperature Conversions, Next: Other Nonlinear Units, Up: Nonlinear Conversions
6.1 Temperature Conversions
===========================
Conversions between temperatures are different from linear conversions
between temperature _increments_--see the example below. The absolute
temperature conversions are handled by units starting with `temp', and
you must use functional notation. The temperature-increment
conversions are done using units starting with `deg' and they do not
require functional notation.
You have: tempF(45)
You want: tempC
7.2222222
You have: 45 degF
You want: degC
* 25
/ 0.04
Think of `tempF(X)' not as a function but as a notation that indicates
that X should have units of `tempF' attached to it. *Note Defining
Nonlinear Units::. The first conversion shows that if it's 45 degrees
Fahrenheit outside, it's 7.2 degrees Celsius. The second conversion
indicates that a change of 45 degrees Fahrenheit corresponds to a
change of 25 degrees Celsius. The conversion from `tempF(X)' is to
absolute temperature, so that
You have: tempF(45)
You want: degR
* 504.67
/ 0.0019814929
gives the same result as
You have: tempF(45)
You want: tempR
* 504.67
/ 0.0019814929
But if you convert `tempF(X)' to `degC', the output is probably not
what you expect:
You have: tempF(45)
You want: degC
* 280.37222
/ 0.0035666871
The result is the temperature in K, because `degC' is defined as `K',
the Kelvin. For consistent results, use the `tempX' units when
converting to a temperature rather than converting a temperature
increment.
File: units.info, Node: Other Nonlinear Units, Prev: Temperature Conversions, Up: Nonlinear Conversions
6.2 Other Nonlinear Units
=========================
Some other examples of nonlinear units are numerous different ring
sizes and wire gauges, the grit sizes used for abrasives, the decibel
scale, shoe size, scales for the density of sugar (e.g. baume). The
standard data file also supplies units for computing the area of a
circle and the volume of a sphere. See the standard units data file
for more details. Wire gauges with multiple zeroes are signified using
negative numbers where two zeroes is `-1'. Alternatively, you can use
the synonyms `g00', `g000', and so on that are defined in the standard
units data file.
You have: wiregauge(11)
You want: inches
* 0.090742002
/ 11.020255
You have: brwiregauge(g00)
You want: inches
* 0.348
/ 2.8735632
You have: 1 mm
You want: wiregauge
18.201919
You have: grit_P(600)
You want: grit_ansicoated
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
USA standard.
You can compute the area of a circle using the nonlinear unit,
`circlearea'. You can also do this using the circularinch or
circleinch. The next example shows two ways to compute the area of a
circle with a five inch radius and one way to compute the volume of a
sphere with a radius of one meter.
You have: circlearea(5 in)
You want: in2
* 78.539816
/ 0.012732395
You have: 10^2 circleinch
You want: in2
* 78.539816
/ 0.012732395
You have: spherevol(meter)
You want: ft3
* 147.92573
/ 0.0067601492
File: units.info, Node: Unit Lists, Next: Invoking Units, Prev: Nonlinear Conversions, Up: Top
7 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 *note 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
* 12.28125
/ 0.081424936
Although you can similarly write a sum of units to convert _to_, the
result will not be the conversion to the units in the sum, but rather
the conversion to the particular sum that you have entered:
You have: 12.28125 ft
You want: ft + in + 1|8 in
* 11.228571
/ 0.089058524
The unit expression given at the `You want:' prompt is equivalent to
asking for conversion to multiples of `1 ft + 1 in + 1|8 in', which is
1.09375 ft, so the conversion in the previous example is equivalent to
You have: 12.28125 ft
You want: 1.09375 ft
* 11.228571
/ 0.089058524
In converting to a sum of units like miles, feet and inches, you
typically want the largest integral value for the first unit, followed
by the largest integral value for the next, and the remainder converted
to the last unit. You can do this conversion easily with `units' using
a special syntax for lists of units. You must list the desired units
in order from largest to smallest, separated by the semicolon (`;')
character:
You have: 12.28125 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3|8 in
The conversion always gives integer coefficients on the units in the
list, except possibly the last unit when the conversion is not exact:
You have: 12.28126 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3.00096 * 1|8 in
The order in which you list the units is important:
You have: 3 kg
You want: oz;lb
105 oz + 0.051367866 lb
You have: 3 kg
You want: lb;oz
6 lb + 9.8218858 oz
Listing ounces before pounds produces a technically correct result, but
not a very useful one. You must list the units in descending order of
size in order to get the most useful result.
Ending a unit list with the separator `;' has the same effect as
repeating the last unit on the list, so `ft;in;1|8 in;' is equivalent to
`ft;in;1|8 in;1|8 in'. With the example above, this gives
You have: 12.28126 ft
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
You have: 12.28126 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3|8 in (rounded down to nearest 1|8 in)
When you use the `-r' option, repeating the last unit on the list has
no effect (e.g., `ft;in;1|8 in;1|8 in' is equivalent to `ft;in;1|8
in'), and hence neither does ending a list with a `;'. With a single
unit and the `-r' option, a terminal `;' _does_ have an effect: it
causes `units' to treat the single unit as a list and produce a rounded
value for the single unit. Without the extra `;', the `-r' option has
no effect on single unit conversions. This example shows the output
using the `-r' option:
You have: 12.28126 ft
You want: in
* 147.37512
/ 0.0067854058
You have: 12.28126 ft
You want: in;
147 in (rounded down to nearest in)
Each unit that appears in the list must be conformable with the first
unit on the list, and of course the listed units must also be
conformable with the _You have_ unit that you enter.
You have: meter
You want: ft;kg
^
conformability error
ft = 0.3048 m
kg = 1 kg
You have: meter
You want: lb;oz
conformability error
1 m
0.45359237 kg
In the first case, `units' reports the disagreement between units
appearing on the list. In the second case, `units' reports
disagreement between the unit you entered and the desired conversion.
This conformability error is based on the first unit on the unit list.
Other common candidates for conversion to sums of units are angles
and time:
You have: 23.437754 deg
You want; deg;arcmin;arcsec
23 deg + 26 arcmin + 15.9144 arcsec
You have: 7.2319 hr
You want: hr;min;sec
7 hr + 13 min + 54.84 sec
In North America, recipes for cooking typically measure ingredients by
volume, and use units that are not always convenient multiples of each
other. Suppose that you have a recipe for 6 and you wish to make a
portion for 1. If the recipe calls for 2 1/2 cups of an ingredient,
you might wish to know the measurements in terms of measuring devices
you have available, you could use `units' and enter
You have: (2+1|2) cup / 6
You want: cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp
1|3 cup + 1 tbsp + 1 tsp
By default, if a unit in a list begins with fraction of the form 1|X
and its multiplier is an integer, the fraction is given as the product
of the multiplier and the numerator; for example,
You have: 12.28125 ft
You want: ft;in;1|8 in;
12 ft + 3 in + 3|8 in
In many cases, such as the example above, this is what is wanted, but
sometimes it is not. For example, a cooking recipe for 6 might call
for 5 1/4 cup of an ingredient, but you want a portion for 2, and your
1-cup measure is not available; you might try
You have: (5+1|4) cup / 3
You want: 1|2 cup;1|3 cup;1|4 cup
3|2 cup + 1|4 cup
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 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
3 * 1|2 cup + 1|4 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.
Some applications for unit lists may be less obvious. Suppose that
you have a postal scale and wish to ensure that it's accurate at 1 oz,
but have only metric calibration weights. You might try
You have: 1 oz
You want: 100 g;50 g; 20 g;10 g;5 g;2 g;1 g;
20 g + 5 g + 2 g + 1 g + 0.34952312 * 1 g
You might then place one each of the 20 g, 5 g, 2 g, and 1 g weights on
the scale and hope that it indicates close to
You have: 20 g + 5 g + 2 g + 1 g
You want: oz;
0.98767093 oz
Appending `;' to `oz' forces a one-line display that includes the unit;
here the integer part of the result is zero, so it is not displayed.
A unit list such as
cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp
can be tedious to enter. The `units' program provides shorthand names
for some common combinations:
hms hours, minutes, seconds
dms angle: degrees, minutes, seconds
time years, days, hours, minutes and seconds
usvol US cooking volume: cups and smaller
Using these shorthands, or "unit list aliases", you can do the
following conversions:
You have: anomalisticyear
You want: time
1 year + 25 min + 3.4653216 sec
You have: 1|6 cup
You want: usvol
2 tbsp + 2 tsp
You cannot combine a unit list alias with other units: it must appear
alone at the `You want:' prompt.
You can display the definition of a unit list alias by entering it at
the `You have:' prompt:
You have: dms
Definition: unit list, deg;arcmin;arcsec
When you specify compact output with `--compact', `--terse' or `-t' and
perform conversion to a unit list, `units' lists the conversion factors
for each unit in the list, separated by semicolons.
You have: year
You want: day;min;sec
365;348;45.974678
Unlike the case of regular output, zeros _are_ included in this output
list:
You have: liter
You want: cup;1|2 cup;1|4 cup;tbsp
4;0;0;3.6280454
File: units.info, Node: Invoking Units, Next: Defining Your Own Units, Prev: Unit Lists, Up: Top
8 Invoking `units'
******************
You invoke `units' like this:
units [OPTIONS] [FROM-UNIT [TO-UNIT]]
If the FROM-UNIT and TO-UNIT are omitted, the program will use
interactive prompts to determine which conversions to perform. *Note
Interactive 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. *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
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
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
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-format' and `--exponential') are given in combination,
behavior is controlled 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 cannot
be reduced. Also display some other diagnostics about suspicious
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 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 definition.
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, `-d 12'
sets the number of significant digits to 12. With exponential
output `units' displays one digit to the left of the decimal
point(1) and eleven digits to the right of the decimal point. On
most systems, the maximum number of internally meaningful digits is
15; if you specify a greater number than your system's maximum,
`units' will print a warning and set the number to the largest
meaningful value. To directly set the maximum 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 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 the
`--output-format' option.
`-o FORMAT'
`--output-format FORMAT'
This option affords complete control over the numeric output format
using the specified FORMAT. The format is a single floating 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 scientific 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 format is `%.8g'; for greater
precision, you could specify `-o %.15g'. *Note Numeric Output
Format::, and the documentation for `printf()' for more detailed
descriptions of the format specification. The `--output-format'
option affords the greatest control 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 precision more simply with the `--digits'
option or select exponential 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
specify 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
with `-f'.
`-h'
`--help'
Print out a summary of the options for `units'.
`-m'
`--minus'
Causes `-' to be interpreted as a subtraction operator. This is
the default behavior.
`-p'
`--product'
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
subtraction operator.
`--oldstar'
Causes `*' to have the old-style precedence, higher than the
precedence of division so that `1/2*3' will equal `1/6'.
`--newstar'
Forces `*' to have the new (default) precedence that follows the
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,
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
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 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 `--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'.
`-v'
`--verbose'
Give slightly more verbose output when converting units. When
combined with the `-c' option this gives the same effect as
`--check-verbose'.
`-V'
`--version'
Print program version number, tell whether the `readline' library
has been included, and give the location of the default units data
file.
`-l LOCALE'
`--locale LOCALE'
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.
---------- Footnotes ----------
(1) This document refers to "decimal point," but strictly, the
"radix" separates the integer and fractional parts of a floating-point
number; in English-speaking countries, the radix is a point (`.'), but
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
9 Adding Your Own Definitions
*****************************
* Menu:
* Units Data Files:: Where are units defined?
* Defining New Units:: Writing your own unit and prefix definitions
* Defining Nonlinear Units:: Writing your own nonlinear unit definitions
* Defining Unit List Aliases:: Writing your own unit list aliases
File: units.info, Node: Units Data Files, Next: Defining New Units, Up: Defining Your Own Units
9.1 Units Data Files
====================
The units and prefixes that `units' can convert are defined in the units
data file, typically `/usr/share/units/definitions.units'. 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 definitions will be preserved when you update `units'.
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
location 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
standard 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.
(Under Windows the personal units file is named `unitdef.units'.)
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' and `HOMEPATH'. Running `units -V' will
display the location and name of your personal units file.
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 without searching your home directory.
File: units.info, Node: Defining New Units, Next: Defining Nonlinear Units, Prev: Units Data Files, Up: Defining Your Own Units
9.2 Defining New Units and Prefixes
===================================
A unit is specified on a single line by giving its name and an
equivalence. Comments start with a `#' character, which can appear
anywhere in a line. The backslash character (`\') acts as a
continuation character 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 path. The name of the file to be included
cannot contain the comment character `#'.
Unit names must not contain any of the operator characters `+', `-',
`*', `/', `|', `^', `;', `~', the comment character `#', or
parentheses. 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' would be valid names but `foo2' or `foo_a2' would be invalid.
You could define nitrous oxide as
N2O nitrogen 2 + oxygen
but would need to define nitrogen dioxide as
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'
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
definitions, 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, 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 multiplication 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 precedence values and may require
parentheses to ensure consistent behavior. To compute the difference
of `foo' and `bar' write `foo+(-bar)' or even `foo+-bar'.
Here is an example of a short data file that defines some basic
units:
m ! # The meter is a primitive unit
sec ! # The second is a primitive unit
rad !dimensionless # A dimensionless primitive unit
micro- 1e-6 # Define a prefix
minute 60 sec # A minute is 60 seconds
hour 60 min # An hour is 60 minutes
inch 0.0254 m # Inch defined in terms of meters
ft 12 inches # The foot defined in terms of inches
mile 5280 ft # And the mile
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
equivalent to `1 / (2 meter)'.
File: units.info, Node: Defining Nonlinear Units, Next: Defining Unit List Aliases, Prev: Defining New Units, Up: Defining Your Own Units
9.3 Defining Nonlinear Units
============================
Some unit conversions of interest are nonlinear; for example,
temperature 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
functional 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
linear units in the data file, so that an eventual conversion to
primitive units is possible.
Here is an example nonlinear unit definition:
tempF(x) units=[1;K] (x+(-32)) degF + stdtemp ; \
(tempF+(-stdtemp))/degF + 32
A nonlinear unit definition comprises a unit name, a dummy parameter
name, two functions, and two corresponding units. The functions tell
`units' how to convert to and from the new unit. In order to produce
valid results, the arguments of these functions need to have the
correct dimensions. To facilitate error checking, you may optionally
indicate units for these arguments.
The definition begins with the unit name followed immediately (with
no spaces) by a `(' character. In parentheses is the name of the
parameter. Next is an optional specification of the units required by
the functions in this definition. In the example above, the `tempF'
function requires an input argument conformable with `1'. For normal
nonlinear units definitions the forward function will always take a
dimensionless argument. The inverse function requires an input
argument conformable with `K'. In general the inverse function will
need units that match the quantity measured by your nonlinear unit.
The purpose of the expression in brackets to enable `units' to perform
error checking on function arguments, and also to assign units to range
and domain specifications, which are described later.
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
tempF to other units.
In order to make conversions to Fahrenheit possible, 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, but then conversions to the
unit will be impossible. If the inverse is omitted then 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 one point and prints an error if
it is not valid there, but this is not a guarantee that your inverse is
correct.
If you wish to make synonyms for nonlinear units, you still need to
define both the forward 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)
You may define a function whose range and domain do not cover all of
the real numbers. In this case `units' can handle errors better if you
specify an appropriate range and domain. You specify the range and
domain 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 the `domain=' with the
endpoints given in brackets. One of the end points can be omitted to
get an interval that goes to infinity. So the range could be specified
as nonnegative by writing `range=[0,]'. Both the range and domain are
optional and can appear independently and in any order along with the
`units' specification. The values in the range and domain are attached
to the units given in the `units' specification. If you don't specify
the units then the parameter inputs are reduced to primitive units for
the numeric comparison to the values you give in the range or domain.
In this case you should only use `range' or `domain' if the endpoints
are zero and infinity.
Specifying the range and domain allows `units' to perform better
error checking and give more helpful error messages when you invoke
nonlinear units conversions outside of their bounds. It also enables
the `-c' option to find a point in the domain to use for its point
check of your inverse definition.
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 messages.
circlearea(r) units=[m;m^2] range=[0,] pi r^2 ; sqrt(circlearea/pi)
Sometimes you may be interested in a piecewise linear unit such as many
wire gauges. Piecewise linear units can be defined by specifying
conversions 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 `['
character. After the bracket, you should indicate the units to be
attached to the numbers in the table. No spaces can appear before the
`]' character, so a definition like `foo[kg meters]' is illegal;
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 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 as
zincgauge[in] \
1 0.002 \
10 0.02 \
15 0.04 \
19 0.06 \
23 0.1
With the preceding definition, the following conversion can be
performed:
You have: zincgauge(10)
You want: in
* 0.02
/ 50
You have: .01 inch
You want: zincgauge
5
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. The
`--check' option will print a warning if a non-monotonic piecewise
linear unit is encountered.
File: units.info, Node: Defining Unit List Aliases, Prev: Defining Nonlinear Units, Up: Defining Your Own Units
9.4 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
included in the standard units data file are
!unitlist hms hr;min;sec
!unitlist time year;day;hr;min;sec
!unitlist dms deg;arcmin;arcsec
!unitlist ftin ft;in;1|8 in
!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
_not_ have been shortened to `year;day;hms'. As usual, be sure to run
`units --check' to ensure that the units listed in unit list aliases
are conformable.
File: units.info, Node: Numeric Output Format, Next: Localization, Prev: Defining Your Own Units, Up: Top
10 Numeric Output Format
************************
* Menu:
* Format Specification:: The output format specification
* Flags:: Optional format flags
* Field Width:: Specifying output field width
* Precision:: Specifying output precision
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 notation) 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. *Note
Invoking Units::, for descriptions of these options.
File: units.info, Node: Format Specification, Next: Flags, Up: Numeric Output Format
10.1 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
inapplicable and are not allowed.
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
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
but zeros.
The format specification may include one or more optional flags:
`+', ` ' (space), `#', `-', or `0' (the digit zero). The
digit-grouping flag
`'' (apostrophe)
is allowed with compilers that support it. Flags are followed by an
optional value for the minimum field width, and an optional precision
specification that begins with a period (e.g., `.6'). The field width
includes the digits, decimal point, the exponent, thousands separators
(with the digit-grouping flag), and the sign if any of these are shown.
File: units.info, Node: Flags, Next: Field Width, Prev: Format Specification, Up: Numeric Output Format
10.2 Flags
==========
The `+' flag causes the output to have a sign (`+' or `-'). The space
flag ` ' is similar to the `+' flag, except that when the value is
positive, 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 of trailing zeros. The digit-grouping flag
`''
shows a thousands separator 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',
You have: mile
You want: microfurlong
* 8000000.000000
/ 0.000000
the magnitude of the first result may not be immediately obvious without
counting the digits to the left of the decimal point. If the thousands
separator is the comma (`,'), the output with the format
`%'f'
might be
You have: mile
You want: microfurlong
* 8,000,000.000000
/ 0.000000
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
reached; for example, with the format `%011.6f',
You have: troypound
You want: grain
* 5760.000000
/ 0000.000174
The `0' flag has no effect if the `-' (left align) flag is given.
File: units.info, Node: Field Width, Next: Precision, Prev: Flags, Up: Numeric Output Format
10.3 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 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 magnitudes of
results. For example, with the format `%12.6f',
You have: km
You want: in
* 39370.078740
/ 0.000025
You have: km
You want: rod
* 198.838782
/ 0.005029
You have: km
You want: furlong
* 4.970970
/ 0.201168
File: units.info, Node: Precision, Prev: Field Width, Up: Numeric Output Format
10.4 Precision
==============
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
precision (as indicated above, the `#' flag causes trailing zeros to be
displayed).
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 maximum internal precision with `units' is 15 decimal digits (or 13
hexadecimal 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 artifacts. For example, a pound is exactly 7000 grains, but
with the format `%.18g', the output might be
You have: pound
You want: grain
* 6999.9999999999991
/ 0.00014285714285714287
With the format `%.25g' you might get the following:
You have: 1/3
You want:
Definition: 0.333333333333333314829616256247
In this case the displayed value includes a series of digits that
represent 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
meaningful digits may be less than the number of digits shown.
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 given.
File: units.info, Node: Localization, Next: Environment Vars, Prev: Numeric Output Format, Up: Top
11 Localization
***************
* Menu:
* Locale:: What is a locale?
* Additional Localization:: When the locale isn't enough
Some units have different values in different locations. The
localization feature accommodates this by allowing a units data file to
specify definitions that depend on the user's locale.
File: units.info, Node: Locale, Next: Additional Localization, Up: Localization
11.1 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
formatting 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 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' in the same directory, typically
`/usr/local/share/units', as the default units data files. The file
includes entries for many combinations of language and country, and can
be extended to include other combinations. The `locale.map' 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
the United States is
English_United States en_US
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
`!endlocale'. Here is an example, which defines the British gallon.
!locale en_GB
gallon 4.54609 liter
!endlocale
File: units.info, Node: Additional Localization, Prev: Locale, Up: Localization
11.2 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
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
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,
had a different length based on a french foot. These customary
definitions could be accommodated as follows:
!var INCH_UNIT usa
yard 3600|3937 m
!endvar
!var INCH_UNIT canada
yard 0.9144 meter
!endvar
!var INCH_UNIT uk
yard 0.91439841 meter
!endvar
!var INCH_UNIT canada uk usa
foot 1|3 yard
inch 1|12 foot
!endvar
!var INCH_UNIT france
foot 144|443.296 m
inch 1|12 foot
line 1|12 inch
!endvar
!varnot INCH_UNIT usa uk france canada
!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
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
block uses the `!message' command to display a warning message.
Alternatively 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 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'
command with the `!locale' command. If you wanted to combine the above
example with suitable locales you could do by _preceding_ the above
definition with the following:
!locale en_US
!set INCH_UNIT usa
!endlocale
!locale en_GB
!set INCH_UNIT uk
!endlocale
!locale en_CA
!set INCH_UNIT canada
!endlocale
!locale fr_FR
!set INCH_UNIT france
!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
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
follow. 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.
File: units.info, Node: Environment Vars, Next: Unicode Support, Prev: Localization, Up: Top
12 Environment Variables
************************
The `units' program uses the following environment variables:
`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, `units' tries to determine your home
directory from the `HOMEDRIVE' and `HOMEPATH' environment
variables if `HOME' does not exist.
`LC_CTYPE, LANG'
Checked to determine the locale if `units' cannot obtain it from
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 loaded if any
data files are given using the `-f' option.
`PAGER'
Specifies the pager to use for help and for displaying the
conformable 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
specify alternatives such as `less', `pg', `emacs', or `vi'.
`UNITS_ENGLISH'
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
environment 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 ""').
File: units.info, Node: Unicode Support, Next: Readline Support, Prev: Environment Vars, Up: Top
13 Unicode Support
******************
The standard units data file is in Unicode, using UTF-8 encoding. Most
definitions use only ASCII characters (i.e., code points U+0000 through
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 if the character
set is UTF-8, `units' reads the UTF-8 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.
When Unicode support is not active, `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
in supplementary units data files, you can use any encoding consistent
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.
Typeset material other than code examples usually uses the Unicode
minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D)
used in `units'; the figure dash (U+2012) and en dash (U+2013) are also
occasionally used. To allow such material to be copied and pasted for
interactive use or in units data files, `units' converts these
characters to U+002D before further processing. Because of this, none
of these characters can appear in unit names.
File: units.info, Node: Readline Support, Next: Currency, Prev: Unicode Support, Up: Top
14 Readline Support
*******************
If the `readline' package has been compiled in, then when `units' is
used interactively, numerous command line editing features are
available. To check if your version of `units' includes `readline',
invoke the program with the `--version' option.
For complete information about `readline', consult the documentation
for the `readline' package. Without any configuration, `units' will
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
`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:
You have: metr
metre metriccup metrichorsepower metrictenth
metretes metricfifth metricounce metricton
metriccarat metricgrain metricquart metricyarncount
You have: metr
If there is a unique way to complete a unitname, you can hit the
key and `units' will provide the rest of the unit name. If `units'
beeps, it means that there is no unique completion. Pressing the
key a second time will print the list of all completions.
File: units.info, Node: Currency, Next: Database Syntax, Prev: Readline Support, Up: Top
15 Updating Currency Exchange Rates
***********************************
The units program includes currency exchange rates and prices for some
precious metals in the database. Of course, these values change over
time, sometimes very rapidly, and `units' cannot provide real time
values. To update the exchange rates run the `units_cur', which
rewrites the files containing the currency rates, typically
`/usr/local/share/units/currency.units'. This program must be run with
suitable permissions to write the file. To keep the rates updated
automatically, it could be run by a cron job on a Unix-like system, or
a similar scheduling program on a different system. Currency exchange
rates are taken from Time Genie (`http://www.timegenie.com') and
precious metals pricing from Packetizer (`www.packetizer.com'). These
sites update once per day, so there is no benefit in running the update
script more often than daily. You can run `units_cur' with a filename
specified on the command line and it will write the data to that file.
If you give `-' for the file it will write to standard output.
File: units.info, Node: Database Syntax, Next: GNU Free Documentation License, Prev: Currency, Up: Top
16 Database Command Syntax
**************************
UNIT DEFINITION
Define a regular unit.
PREFIX- DEFINITION
Define a prefix.
FUNCNAME(VAR) units=[IN-UNITS,OUT-UNITS] domain=[X1,X2] range=[Y1,Y2] DEFINITION(VAR) ; INVERSE(FUNCNAME)
Define a nonlinear unit or unit function. The three optional
keywords `units=', `range=' and `domain=' can appear in any order.
The definition of the inverse is optional.
TABNAME[OUT-UNITS] PAIR-LIST
Define a piecewise linear unit. The pair list gives the points on
the table listed in ascending order.
!endlocale
End a block of definitions beginning with `!locale'
!endutf8
End a block of definitions begun with `!utf8'
!endvar
End a block of definitions begun with `!var' or `!varnot'
!include FILE
Include the specified file.
!locale VALUE
Load the following definitions only of the locale is set to VALUE.
!message TEXT
Display TEXT when the database is read unless the quiet option
(`-q') is enabled.
!set VARIABLE VALUE
Sets the environment variable, VARIABLE, to the specified value
_only if_ it is not already set.
!unitlist ALIAS DEFINITION
Define a unit list alias.
!utf8
Load the following definitions only if `units' is running with
UTF-8 enabled.
!var VARIABLE VALUE-LIST
Load the following definitions only if the environment variable,
VARIABLE is set to one of the values listed on the space separated
value list. If VARIABLE is not set then `units' prints an error
message and ignores the following definitions.
!varnot VARIABLE VALUE-LIST
Load the following definitions only if the environment variable,
VARIABLE is NOT set to one of the values listed on the space
separated value list. If VARIABLE is not set then `units' prints
an error message and ignores the following definitions.
File: units.info, Node: GNU Free Documentation License, Next: Index, Prev: Database Syntax, Up: Top
17 GNU Free Documentation License
*********************************
Version 1.3, 3 November 2008
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
`http://fsf.org/'
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or
noncommercially. Secondarily, this License preserves for the
author and publisher a way to get credit for their work, while not
being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense.
It complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for
free software, because free software needs free documentation: a
free program should come with manuals providing the same freedoms
that the software does. But this License is not limited to
software manuals; it can be used for any textual work, regardless
of subject matter or whether it is published as a printed book.
We recommend this License principally for works whose purpose is
instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium,
that contains a notice placed by the copyright holder saying it
can be distributed under the terms of this License. Such a notice
grants a world-wide, royalty-free license, unlimited in duration,
to use that work under the conditions stated herein. The
"Document", below, refers to any such manual or work. Any member
of the public is a licensee, and is addressed as "you". You
accept the license if you copy, modify or distribute the work in a
way requiring permission under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could
fall directly within that overall subject. (Thus, if the Document
is in part a textbook of mathematics, a Secondary Section may not
explain any mathematics.) The relationship could be a matter of
historical connection with the subject or with related matters, or
of legal, commercial, philosophical, ethical or political position
regarding them.
The "Invariant Sections" are certain Secondary Sections whose
titles are designated, as being those of Invariant Sections, in
the notice that says that the Document is released under this
License. If a section does not fit the above definition of
Secondary then it is not allowed to be designated as Invariant.
The Document may contain zero Invariant Sections. If the Document
does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are
listed, as Front-Cover Texts or Back-Cover Texts, in the notice
that says that the Document is released under this License. A
Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images
composed of pixels) generic paint programs or (for drawings) some
widely available drawing editor, and that is suitable for input to
text formatters or for automatic translation to a variety of
formats suitable for input to text formatters. A copy made in an
otherwise Transparent file format whose markup, or absence of
markup, has been arranged to thwart or discourage subsequent
modification by readers is not Transparent. An image format is
not Transparent if used for any substantial amount of text. A
copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format,
SGML or XML using a publicly available DTD, and
standard-conforming simple HTML, PostScript or PDF designed for
human modification. Examples of transparent image formats include
PNG, XCF and JPG. Opaque formats include proprietary formats that
can be read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are not generally
available, and the machine-generated HTML, PostScript or PDF
produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the
material this License requires to appear in the title page. For
works in formats which do not have any title page as such, "Title
Page" means the text near the most prominent appearance of the
work's title, preceding the beginning of the body of the text.
The "publisher" means any person or entity that distributes copies
of the Document to the public.
A section "Entitled XYZ" means a named subunit of the Document
whose title either is precisely XYZ or contains XYZ in parentheses
following text that translates XYZ in another language. (Here XYZ
stands for a specific section name mentioned below, such as
"Acknowledgements", "Dedications", "Endorsements", or "History".)
To "Preserve the Title" of such a section when you modify the
Document means that it remains a section "Entitled XYZ" according
to this definition.
The Document may include Warranty Disclaimers next to the notice
which states that this License applies to the Document. These
Warranty Disclaimers are considered to be included by reference in
this License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and
has no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License
applies to the Document are reproduced in all copies, and that you
add no other conditions whatsoever to those of this License. You
may not use technical measures to obstruct or control the reading
or further copying of the copies you make or distribute. However,
you may accept compensation in exchange for copies. If you
distribute a large enough number of copies you must also follow
the conditions in section 3.
You may also lend copies, under the same conditions stated above,
and you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly
have printed covers) of the Document, numbering more than 100, and
the Document's license notice requires Cover Texts, you must
enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and
Back-Cover Texts on the back cover. Both covers must also clearly
and legibly identify you as the publisher of these copies. The
front cover must present the full title with all words of the
title equally prominent and visible. You may add other material
on the covers in addition. Copying with changes limited to the
covers, as long as they preserve the title of the Document and
satisfy these conditions, can be treated as verbatim copying in
other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto
adjacent pages.
If you publish or distribute Opaque copies of the Document
numbering more than 100, you must either include a
machine-readable Transparent copy along with each Opaque copy, or
state in or with each Opaque copy a computer-network location from
which the general network-using public has access to download
using public-standard network protocols a complete Transparent
copy of the Document, free of added material. If you use the
latter option, you must take reasonably prudent steps, when you
begin distribution of Opaque copies in quantity, to ensure that
this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you
distribute an Opaque copy (directly or through your agents or
retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of
the Document well before redistributing any large number of
copies, to give them a chance to provide you with an updated
version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document
under the conditions of sections 2 and 3 above, provided that you
release the Modified Version under precisely this License, with
the Modified Version filling the role of the Document, thus
licensing distribution and modification of the Modified Version to
whoever possesses a copy of it. In addition, you must do these
things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title
distinct from that of the Document, and from those of
previous versions (which should, if there were any, be listed
in the History section of the Document). You may use the
same title as a previous version if the original publisher of
that version gives permission.
B. List on the Title Page, as authors, one or more persons or
entities responsible for authorship of the modifications in
the Modified Version, together with at least five of the
principal authors of the Document (all of its principal
authors, if it has fewer than five), unless they release you
from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license
notice giving the public permission to use the Modified
Version under the terms of this License, in the form shown in
the Addendum below.
G. Preserve in that license notice the full lists of Invariant
Sections and required Cover Texts given in the Document's
license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title,
and add to it an item stating at least the title, year, new
authors, and publisher of the Modified Version as given on
the Title Page. If there is no section Entitled "History" in
the Document, create one stating the title, year, authors,
and publisher of the Document as given on its Title Page,
then add an item describing the Modified Version as stated in
the previous sentence.
J. Preserve the network location, if any, given in the Document
for public access to a Transparent copy of the Document, and
likewise the network locations given in the Document for
previous versions it was based on. These may be placed in
the "History" section. You may omit a network location for a
work that was published at least four years before the
Document itself, or if the original publisher of the version
it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the
section all the substance and tone of each of the contributor
acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section
titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled
"Endorsements" or to conflict in title with any Invariant
Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no
material copied from the Document, you may at your option
designate some or all of these sections as invariant. To do this,
add their titles to the list of Invariant Sections in the Modified
Version's license notice. These titles must be distinct from any
other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text
has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text,
and a passage of up to 25 words as a Back-Cover Text, to the end
of the list of Cover Texts in the Modified Version. Only one
passage of Front-Cover Text and one of Back-Cover Text may be
added by (or through arrangements made by) any one entity. If the
Document already includes a cover text for the same cover,
previously added by you or by arrangement made by the same entity
you are acting on behalf of, you may not add another; but you may
replace the old one, on explicit permission from the previous
publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this
License give permission to use their names for publicity for or to
assert or imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under
this License, under the terms defined in section 4 above for
modified versions, provided that you include in the combination
all of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your
combined work in its license notice, and that you preserve all
their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name
but different contents, make the title of each such section unique
by adding at the end of it, in parentheses, the name of the
original author or publisher of that section if known, or else a
unique number. Make the same adjustment to the section titles in
the list of Invariant Sections in the license notice of the
combined work.
In the combination, you must combine any sections Entitled
"History" in the various original documents, forming one section
Entitled "History"; likewise combine any sections Entitled
"Acknowledgements", and any sections Entitled "Dedications". You
must delete all sections Entitled "Endorsements."
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the
rules of this License for verbatim copying of each of the
documents in all other respects.
You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert
a copy of this License into the extracted document, and follow
this License in all other respects regarding verbatim copying of
that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other
separate and independent documents or works, in or on a volume of
a storage or distribution medium, is called an "aggregate" if the
copyright resulting from the compilation is not used to limit the
legal rights of the compilation's users beyond what the individual
works permit. When the Document is included in an aggregate, this
License does not apply to the other works in the aggregate which
are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half
of the entire aggregate, the Document's Cover Texts may be placed
on covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic
form. Otherwise they must appear on printed covers that bracket
the whole aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section
4. Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also
include the original English version of this License and the
original versions of those notices and disclaimers. In case of a
disagreement between the translation and the original version of
this License or a notice or disclaimer, the original version will
prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to
Preserve its Title (section 1) will typically require changing the
actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void,
and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly
and finally terminates your license, and (b) permanently, if the
copyright holder fails to notify you of the violation by some
reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from
that copyright holder, and you cure the violation prior to 30 days
after your receipt of the notice.
Termination of your rights under this section does not terminate
the licenses of parties who have received copies or rights from
you under this License. If your rights have been terminated and
not permanently reinstated, receipt of a copy of some or all of
the same material does not give you any rights to use it.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of
the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
`http://www.gnu.org/copyleft/'.
Each version of the License is given a distinguishing version
number. If the Document specifies that a particular numbered
version of this License "or any later version" applies to it, you
have the option of following the terms and conditions either of
that specified version or of any later version that has been
published (not as a draft) by the Free Software Foundation. If
the Document does not specify a version number of this License,
you may choose any version ever published (not as a draft) by the
Free Software Foundation. If the Document specifies that a proxy
can decide which future versions of this License can be used, that
proxy's public statement of acceptance of a version permanently
authorizes you to choose that version for the Document.
11. RELICENSING
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server.
A "Massive Multiauthor Collaboration" (or "MMC") contained in the
site means any set of copyrightable works thus published on the MMC
site.
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
"Incorporate" means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this
License somewhere other than this MMC, and subsequently
incorporated in whole or in part into the MMC, (1) had no cover
texts or invariant sections, and (2) were thus incorporated prior
to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the
site under CC-BY-SA on the same site at any time before August 1,
2009, provided the MMC is eligible for relicensing.
ADDENDUM: How to use this License for your documents
====================================================
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and license
notices just after the title page:
Copyright (C) YEAR YOUR NAME.
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, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with
the Front-Cover Texts being LIST, and with the Back-Cover Texts
being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License, to
permit their use in free software.
File: units.info, Node: Index, Prev: GNU Free Documentation License, Up: Top
Index
*****
[index ]
* Menu:
* ! to indicate primitive units: Defining New Units. (line 6)
* !endlocale: Localization. (line 6)
* !endutf8: Unicode Support. (line 6)
* !include: Units Data Files. (line 6)
* !locale: Localization. (line 6)
* !unitlist: Defining Unit List Aliases.
(line 6)
* !utf8: Unicode Support. (line 6)
* * operator: Operators. (line 33)
* ** operator: Operators. (line 19)
* + operator: Sums and Differences of Units.
(line 6)
* - as multiplication operator: Backwards Compatibility.
(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 150)
* --digits (option for units): Invoking Units. (line 67)
* --exponential (option for units): Invoking Units. (line 84)
* --file (option for units): Invoking Units. (line 115)
* --help (option for units): Invoking Units. (line 126)
* --locale (option for units): Invoking Units. (line 223)
* --minus (option for units): Invoking Units. (line 130)
* --newstar (option for units): Invoking Units. (line 145)
* --oldstar (option for units): Invoking Units. (line 141)
* --one-line (option for units): Invoking Units. (line 197)
* --output-format (option for units): Invoking Units. (line 93)
* --product (option for units): Invoking Units. (line 135)
* --quiet (option for units): Invoking Units. (line 156)
* --silent (option for units): Invoking Units. (line 156)
* --strict (option for units): Invoking Units. (line 188)
* --terse (option for units): Invoking Units. (line 204)
* --verbose (option for units): Invoking Units. (line 211)
* --verbose-check (option for units): Invoking Units. (line 59)
* --version (option for units): Invoking Units. (line 217)
* -1 (option for units): Invoking Units. (line 197)
* -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)
* -h (option for units): Invoking Units. (line 126)
* -l (option for units): Invoking Units. (line 223)
* -m (option for units): Invoking Units. (line 130)
* -o (option for units): Invoking Units. (line 93)
* -p (option for units): Invoking Units. (line 135)
* -q (option for units): Invoking Units. (line 156)
* -s (option for units): Invoking Units. (line 188)
* -t (option for units): Invoking Units. (line 204)
* -V (option for units): Invoking Units. (line 217)
* -v (option for units): Invoking Units. (line 211)
* ? for unit completion with readline: Readline Support. (line 16)
* ? to show conformable units: Interactive Use. (line 121)
* abrasive grit size: Other Nonlinear Units.
(line 36)
* addition of units: Sums and Differences of Units.
(line 9)
* additional units data files: Units Data Files. (line 6)
* backwards compatibility: Backwards Compatibility.
(line 6)
* British Imperial measure: Unit Definitions. (line 36)
* circle, area of: Other Nonlinear Units.
(line 42)
* command, ! to indicate primitive units: Defining New Units. (line 6)
* command, !endlocale: Localization. (line 6)
* command, !endutf8: Unicode Support. (line 6)
* command, !endvar: Localization. (line 6)
* command, !include: Units Data Files. (line 6)
* command, !locale: Localization. (line 6)
* command, !message: Localization. (line 6)
* command, !set: Localization. (line 6)
* command, !unitlist: Defining Unit List Aliases.
(line 6)
* command, !utf8: Unicode Support. (line 6)
* command, !var: Localization. (line 6)
* command, !varnot: Localization. (line 6)
* command-line options: Invoking Units. (line 6)
* command-line unit conversion: Command Line Use. (line 6)
* commands in units database: Database Syntax. (line 6)
* compatibility: Backwards Compatibility.
(line 6)
* compatibility with earlier versions: Backwards Compatibility.
(line 6)
* completion, unit, using ? (readline only): Readline Support.
(line 16)
* conformable units, ? to show: Interactive Use. (line 121)
* currency, updating: Currency. (line 6)
* Darcy-Weisbach equation: Complicated Unit Expressions.
(line 7)
* data files, additional: Units Data Files. (line 6)
* database syntax summary: Database Syntax. (line 6)
* defining nonlinear units: Defining Nonlinear Units.
(line 6)
* defining prefixes: Defining New Units. (line 6)
* defining units: Defining New Units. (line 6)
* defining units with `-': Backwards Compatibility.
(line 33)
* differences of units: Sums and Differences of Units.
(line 9)
* dimensionless units: Interactive Use. (line 119)
* dimensionless units, defining: Defining New Units. (line 39)
* division of numbers: Operators. (line 71)
* division of units: Operators. (line 33)
* environment dependent definitions: Localization. (line 6)
* environment variable, HOME: Environment Vars. (line 9)
* environment variable, LANG: Environment Vars. (line 16)
* environment variable, LC_CTYPE: Environment Vars. (line 16)
* environment variable, MYUNITSFILE <1>: Environment Vars. (line 21)
* environment variable, MYUNITSFILE: Units Data Files. (line 41)
* environment variable, PAGER: Environment Vars. (line 27)
* environment variable, UNITS_ENGLISH: Environment Vars. (line 34)
* environment variable, UNITSFILE: Environment Vars. (line 38)
* environment variables: Environment Vars. (line 6)
* exchange rates, updating: Currency. (line 6)
* exponent operator: Operators. (line 19)
* flags, output format: Flags. (line 6)
* format specification, output: Format Specification.
(line 6)
* fractions, numerical: Operators. (line 71)
* functions of units: Defining Nonlinear Units.
(line 107)
* functions, built in: Built-in Functions. (line 6)
* help <1>: Environment Vars. (line 27)
* help: Interactive Use. (line 126)
* HOME environment variable: Environment Vars. (line 9)
* hyphen as multiplication operator: Backwards Compatibility.
(line 17)
* Imperial measure: Unit Definitions. (line 36)
* include files: Defining New Units. (line 15)
* including additional units data files: Units Data Files. (line 6)
* incompatible units: Interactive Use. (line 86)
* interactive use: Interactive Use. (line 6)
* international mile: Unit Definitions. (line 74)
* international yard: Unit Definitions. (line 74)
* invoking units: Invoking Units. (line 6)
* LANG environment variable: Environment Vars. (line 16)
* LC_CTYPE environment variable: Environment Vars. (line 16)
* length measure, English customary: Unit Definitions. (line 74)
* length measure, UK: Unit Definitions. (line 74)
* linear interpolation: Defining Nonlinear Units.
(line 117)
* locale: Locale. (line 6)
* locale.map: Locale. (line 17)
* localization: Localization. (line 6)
* measure, Imperial: Unit Definitions. (line 36)
* mile, international: Unit Definitions. (line 74)
* minus (-) operator, subtraction: Sums and Differences of Units.
(line 6)
* multiplication of units: Operators. (line 33)
* multiplication, hyphen: Backwards Compatibility.
(line 17)
* MYUNITSFILE environment variable <1>: Environment Vars. (line 21)
* MYUNITSFILE environment variable: Units Data Files. (line 41)
* non-conformable units: Interactive Use. (line 86)
* non-interactive unit conversion: Command Line Use. (line 6)
* nonlinear unit conversions <1>: Defining Nonlinear Units.
(line 6)
* nonlinear unit conversions: Nonlinear Conversions.
(line 6)
* nonlinear units, defining: Defining Nonlinear Units.
(line 6)
* nonlinear units, other: Other Nonlinear Units.
(line 6)
* numbers as units: Numbers as Units. (line 6)
* numeric output format: Numeric Output Format.
(line 6)
* numerical fractions: Operators. (line 71)
* operator precedence: Operators. (line 40)
* operator, (**): Operators. (line 19)
* operator, caret (^): Operators. (line 19)
* operator, hyphen (-) as multiplication: Backwards Compatibility.
(line 17)
* operator, hyphen (-) as subtraction: Sums and Differences of Units.
(line 6)
* operator, minus (-): Sums and Differences of Units.
(line 6)
* operator, per: Operators. (line 33)
* operator, plus (+): Sums and Differences of Units.
(line 6)
* operator, slash (/): Operators. (line 33)
* operator, solidus (/): Operators. (line 33)
* operator, space: Operators. (line 33)
* operator, star (*): Operators. (line 33)
* operator, vertical bar (|): Operators. (line 71)
* operators: Operators. (line 6)
* output field width: Field Width. (line 6)
* output format: Numeric Output Format.
(line 6)
* output format flags: Flags. (line 6)
* output format specification: Format Specification.
(line 6)
* output precision: Precision. (line 6)
* PAGER environment variable: Environment Vars. (line 27)
* parentheses <1>: Defining Nonlinear Units.
(line 35)
* parentheses <2>: Defining New Units. (line 48)
* parentheses <3>: Complicated Unit Expressions.
(line 27)
* parentheses <4>: Sums and Differences of Units.
(line 33)
* parentheses: Operators. (line 19)
* per operator: Operators. (line 33)
* personal units data file: Units Data Files. (line 26)
* piecewise linear units: Defining Nonlinear Units.
(line 117)
* plus (+) operator: Sums and Differences of Units.
(line 6)
* powers: Operators. (line 19)
* precision, output: Precision. (line 6)
* prefixes: Unit Definitions. (line 53)
* prefixes and exponents: Operators. (line 40)
* prefixes, definition of: Defining New Units. (line 6)
* primitive units: Defining New Units. (line 6)
* products of units: Operators. (line 33)
* quotients of units: Operators. (line 33)
* readline, use with units: Readline Support. (line 6)
* reciprocal conversion: Interactive Use. (line 61)
* roots: Built-in Functions. (line 27)
* setlocale function: Locale. (line 17)
* slash (/) operator: Operators. (line 33)
* solidus (/) operator: Operators. (line 33)
* sphere, volume of: Other Nonlinear Units.
(line 42)
* square roots: Built-in Functions. (line 27)
* star (*) operator: Operators. (line 33)
* State Plane Coordinate System, US: Unit Definitions. (line 74)
* strict conversion: Interactive Use. (line 70)
* subtraction of units: Sums and Differences of Units.
(line 9)
* sums and differences of units: Sums and Differences of Units.
(line 6)
* sums of units <1>: Unit Lists. (line 6)
* sums of units: Sums and Differences of Units.
(line 9)
* survey foot, US: Unit Definitions. (line 74)
* survey measure, US: Unit Definitions. (line 74)
* survey mile, US: Unit Definitions. (line 74)
* syntax of units database: Database Syntax. (line 6)
* temperature conversions: Temperature Conversions.
(line 6)
* Unicode support: Unicode Support. (line 6)
* unit completion using ? (readline only): Readline Support. (line 16)
* unit definitions: Unit Definitions. (line 6)
* unit expressions: Unit Expressions. (line 6)
* unit expressions, complicated: Complicated Unit Expressions.
(line 6)
* unit list aliases, defining: Defining Unit List Aliases.
(line 6)
* unit lists: Unit Lists. (line 6)
* unit name completion: Readline Support. (line 19)
* units data file, personal: Units Data Files. (line 26)
* units data files, additional: Units Data Files. (line 6)
* units definitions, adding: Defining New Units. (line 6)
* units definitions, changing: Defining New Units. (line 6)
* units functions: Defining Nonlinear Units.
(line 107)
* units quotients: Operators. (line 33)
* units, definition of: Defining New Units. (line 6)
* units, lookup method: Unit Definitions. (line 44)
* units, piecewise linear: Defining Nonlinear Units.
(line 117)
* units, primitive: Defining New Units. (line 6)
* units, sums and differences: Sums and Differences of Units.
(line 6)
* units, sums of: Unit Lists. (line 6)
* UNITS_ENGLISH environment variable: Environment Vars. (line 34)
* UNITSFILE environment variable: Environment Vars. (line 38)
* US State Plane Coordinate System: Unit Definitions. (line 74)
* US survey foot: Unit Definitions. (line 74)
* US survey measure: Unit Definitions. (line 74)
* US survey mile: Unit Definitions. (line 74)
* UTF-8: Unicode Support. (line 6)
* verbose output: Interactive Use. (line 52)
* vertical bar (|) operator: Operators. (line 71)
* volume measure, English customary: Unit Definitions. (line 59)
* wire gauge: Other Nonlinear Units.
(line 14)
* yard, international: Unit Definitions. (line 74)
* | operator: Operators. (line 71)
Tag Table:
Node: Top853
Node: Overview2187
Ref: Overview-Footnote-13890
Node: Interactive Use4084
Node: Command Line Use9592
Node: Unit Definitions10839
Node: Unit Expressions16873
Node: Operators17418
Node: Sums and Differences of Units21124
Node: Numbers as Units23169
Node: Built-in Functions23975
Node: Complicated Unit Expressions25271
Node: Backwards Compatibility26910
Node: Nonlinear Conversions28813
Node: Temperature Conversions29252
Node: Other Nonlinear Units31001
Node: Unit Lists32871
Node: Invoking Units41633
Ref: Invoking Units-Footnote-151909
Node: Defining Your Own Units52163
Node: Units Data Files52622
Node: Defining New Units54900
Node: Defining Nonlinear Units58815
Node: Defining Unit List Aliases66502
Node: Numeric Output Format67660
Node: Format Specification68935
Node: Flags70906
Node: Field Width73005
Node: Precision74040
Node: Localization76497
Node: Locale76943
Node: Additional Localization78988
Node: Environment Vars83444
Node: Unicode Support85308
Node: Readline Support88331
Node: Currency89737
Node: Database Syntax90934
Node: GNU Free Documentation License92937
Node: Index118089
End Tag Table
units-2.02/parse.y 0000600 0001750 0001750 00000030115 12156460475 013363 0 ustar adrian adrian /*
* parse.y: the parser for GNU units, a program for units conversion
* Copyright (C) 1999, 2000, 2001, 2002, 2007, 2009 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* This program was written by Adrian Mariano (adrianm@gnu.org)
*/
%{
#define YYPARSE_PARAM comm
#define YYLEX_PARAM comm
#define COMM ((struct commtype *)comm)
#include "units.h"
int yylex();
void yyerror(char *);
static int err; /* value used by parser to store return values */
#define CHECK if (err) { COMM->errorcode=err; YYABORT; }
#define MEMSIZE 100
struct unittype *memtable[MEMSIZE];
int nextunit=0;
int maxunit=0;
struct commtype {
int location;
char *data;
struct unittype *result;
int errorcode;
char *paramname;
struct unittype *paramvalue;
};
struct function {
char *name;
double (*func)(double);
int type;
};
#define DIMENSIONLESS 0
#define ANGLEIN 1
#define ANGLEOUT 2
struct unittype *
getnewunit()
{
if (nextunit>=MEMSIZE)
return 0;
memtable[nextunit] = (struct unittype *)
mymalloc(sizeof(struct unittype),"(getnewunit)");
if (!memtable[nextunit])
return 0;
initializeunit(memtable[nextunit]);
return memtable[nextunit++];
}
struct unittype *
makenumunit(double num,int *myerr)
{
struct unittype *ret;
ret=getnewunit();
if (!ret){
*myerr = E_PARSEMEM;
return 0;
}
ret->factor = num;
*myerr = 0;
return ret;
}
double
logb2(double x)
{
return log(x)/log(2.0);
}
int
funcunit(struct unittype *theunit, struct function *fun)
{
struct unittype angleunit;
if (fun->type==ANGLEIN){
err=unit2num(theunit);
if (err==E_NOTANUMBER){
initializeunit(&angleunit);
angleunit.denominator[0] = dupstr("radian");
angleunit.denominator[1] = 0;
err = multunit(theunit, &angleunit);
freeunit(&angleunit);
if (!err)
err = unit2num(theunit);
}
if (err)
return err;
} else if (fun->type==ANGLEOUT || fun->type == DIMENSIONLESS) {
if ((err=unit2num(theunit)))
return err;
} else
return E_BADFUNCTYPE;
errno = 0;
theunit->factor = (*(fun->func))(theunit->factor);
if (errno)
return E_FUNC;
if (fun->type==ANGLEOUT) {
theunit->numerator[0] = dupstr("radian");
theunit->numerator[1] = 0;
}
return 0;
}
%}
%pure_parser
%name-prefix="units"
%union {
double number;
int integer;
struct unittype *utype;
struct function *dfunc;
struct func *ufunc;
}
%token REAL
%token UNIT
%token RFUNC
%token UFUNC
%token EXPONENT
%token MULTIPLY
%token MULTSTAR
%token DIVIDE
%token NUMDIV
%token SQRT
%token CUBEROOT
%token MULTMINUS
%token EOL
%token FUNCINV
%token MEMERROR
%token BADNUMBER
%token UNITEND
%type numexpr
%type expr
%type list
%type pexpr
%type unitexpr
%left ADD MINUS
%left UNARY
%left DIVIDE MULTSTAR
%left MULTIPLY MULTMINUS
%nonassoc '(' SQRT CUBEROOT RFUNC UNIT REAL UFUNC FUNCINV MEMERROR BADNUMBER UNITEND
%right EXPONENT
%left NUMDIV
%%
input: EOL { COMM->result = makenumunit(1,&err); CHECK; YYACCEPT; }
| unitexpr EOL { COMM->result = $1; YYACCEPT; }
| error { YYABORT; }
;
unitexpr: expr {$$ = $1;}
| DIVIDE list { invertunit($2); $$=$2;}
;
expr: list { $$ = $1; }
| MULTMINUS list %prec UNARY { $$ = $2; $$->factor *= -1; }
| MINUS list %prec UNARY { $$ = $2; $$->factor *= -1; }
| expr ADD expr { err = addunit($1,$3); CHECK; $$=$1;}
| expr MINUS expr { $3->factor *= -1; err = addunit($1,$3);
CHECK; $$=$1;}
| expr DIVIDE expr { err = divunit($1, $3); CHECK; $$=$1;}
| expr MULTIPLY expr { err = multunit($1,$3); CHECK; $$=$1;}
| expr MULTSTAR expr { err = multunit($1,$3); CHECK; $$=$1;}
;
numexpr: REAL { $$ = $1; }
| numexpr NUMDIV numexpr { $$ = $1 / $3; }
;
pexpr: '(' expr ')' { $$ = $2; }
;
/* list is a list of units, possibly raised to powers, to be multiplied
together. */
list: numexpr { $$ = makenumunit($1,&err); CHECK;}
| UNIT { $$ = $1; }
| list EXPONENT list { err = unitpower($1,$3); CHECK; $$=$1;}
| list MULTMINUS list { err = multunit($1,$3); CHECK; $$=$1;}
| list list %prec MULTIPLY { err = multunit($1,$2); CHECK; $$=$1;}
| pexpr { $$=$1; }
| SQRT pexpr { err = rootunit($2,2); CHECK; $$=$2;}
| CUBEROOT pexpr { err = rootunit($2,3); CHECK; $$=$2;}
| RFUNC pexpr { err = funcunit($2,$1); CHECK; $$=$2;}
| UFUNC pexpr { err = evalfunc($2,$1,0); CHECK; $$=$2;}
| FUNCINV UFUNC pexpr { err = evalfunc($3,$2,1); CHECK; $$=$3;}
| list EXPONENT MULTMINUS list %prec EXPONENT
{ $4->factor *= -1;
err = unitpower($1,$4); CHECK; $$=$1;}
| list EXPONENT MINUS list %prec EXPONENT
{ $4->factor *= -1;
err = unitpower($1,$4); CHECK; $$=$1;}
| BADNUMBER { err = E_BADNUM; CHECK; }
| MEMERROR { err = E_PARSEMEM; CHECK; }
| UNITEND { err = E_UNITEND; CHECK; }
;
%%
#ifndef strchr
# ifdef NO_STRCHR
# define strchr(a,b) index((a),(b))
# else
char *strchr();
# endif
#endif /* !strchr */
double strtod();
struct function
realfunctions[] = { {"sin", sin, ANGLEIN},
{"cos", cos, ANGLEIN},
{"tan", tan, ANGLEIN},
{"ln", log, DIMENSIONLESS},
{"log", log10, DIMENSIONLESS},
{"log2", logb2, DIMENSIONLESS},
{"exp", exp, DIMENSIONLESS},
{"acos", acos, ANGLEOUT},
{"atan", atan, ANGLEOUT},
{"asin", asin, ANGLEOUT},
{0, 0, 0}};
struct {
char op;
int value;
} optable[] = { {'*', MULTIPLY},
{'/', DIVIDE},
{'|', NUMDIV},
{'+', ADD},
{'(', '('},
{')', ')'},
{'^', EXPONENT},
{'~', FUNCINV},
{0, 0}};
struct {
char *name;
int value;
} strtable[] = { {"sqrt", SQRT},
{"cuberoot", CUBEROOT},
{"per" , DIVIDE},
{0, 0}};
int yylex(YYSTYPE *lvalp, struct commtype *comm)
{
int length, count;
struct unittype *output;
char *inptr;
char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name */
char *nonunitends = ".,_"; /* Can't start or end a unit */
char *number_start = ".,0123456789"; /* Can be first char of a number */
if (comm->location==-1) return 0;
inptr = comm->data + comm->location; /* Point to start of data */
/* Skip white space */
while( *inptr && strchr(WHITE,*inptr)) inptr++, comm->location++;
if (*inptr==0) {
comm->location = -1;
return EOL; /* Return failure if string has ended */
}
/* Check for **, an exponent operator. */
if (0==strncmp("**",inptr,2)){
comm->location += 2;
return EXPONENT;
}
/* Check for '-' and '*' which get special handling */
if (*inptr=='-'){
comm->location++;
if (parserflags.minusminus)
return MINUS;
return MULTMINUS;
}
if (*inptr=='*'){
comm->location++;
if (parserflags.oldstar)
return MULTIPLY;
return MULTSTAR;
}
/* Look for single character ops */
for(count=0; optable[count].op; count++){
if (*inptr==optable[count].op) {
comm->location++;
return optable[count].value;
}
}
/* Look for numbers */
if (strchr(number_start,*inptr)){ /* prevent "nan" from being recognized */
char *endloc;
lvalp->number = strtod(inptr, &endloc);
if (inptr != endloc) {
comm->location += (endloc-inptr);
if (*endloc && strchr(number_start,*endloc))
return BADNUMBER;
else
return REAL;
}
}
/* Look for a word (function name or unit name) */
length = strcspn(inptr,nonunitchars);
if (!length){ /* Next char is not a valid unit char */
comm->location++;
return 0;
}
/* Check that unit name doesn't start or end with forbidden chars */
if (strchr(nonunitends,*inptr)){
comm->location++;
return 0;
}
if (strchr(nonunitends, inptr[length-1])){
comm->location+=length;
return 0;
}
/* Look for string operators */
for(count=0;strtable[count].name;count++){
if (length==strlen(strtable[count].name) &&
0==strncmp(strtable[count].name,inptr,length)){
comm->location += length;
return strtable[count].value;
}
}
/* Look for real function names */
for(count=0;realfunctions[count].name;count++){
if (length==strlen(realfunctions[count].name) &&
0==strncmp(realfunctions[count].name,inptr,length)){
lvalp->dfunc = realfunctions+count;
comm->location += length;
return RFUNC;
}
}
/* Look for function parameter */
if (function_parameter && length==strlen(function_parameter) &&
0==strncmp(function_parameter, inptr, length)){
output = getnewunit();
if (!output)
return MEMERROR;
unitcopy(output, parameter_value);
lvalp->utype = output;
comm->location += length;
return UNIT;
}
/* Look for user defined function */
lvalp->ufunc = fnlookup(inptr,length);
if (lvalp->ufunc){
comm->location += length;
return UFUNC;
}
/* Didn't find a special string, so treat it as unit name */
comm->location+=length;
if (strchr("23456789",inptr[length-1]) &&
!hassubscript(inptr,length)) { /* do exponent handling like m3 */
count = inptr[length-1] - '0';
length--;
if (strchr(number_start, inptr[length-1])){
return UNITEND;
}
} else count=1;
output = getnewunit();
if (!output)
return MEMERROR;
output->numerator[count]=0;
for(;count;count--){
output->numerator[count-1] = mymalloc(length+1,"(yylex)");
strncpy(output->numerator[count-1], inptr, length);
output->numerator[count-1][length]=0;
}
lvalp->utype=output;
return UNIT;
}
void yyerror(char *s){}
void
freelist(int startunit)
{
if (nextunit>maxunit)
maxunit = nextunit;
while(nextunit>startunit){
freeunit(memtable[--nextunit]);
free(memtable[nextunit]);
}
}
int
parseunit(struct unittype *output, char *input,char **errstr,int *errloc)
{
struct commtype comm;
int startunit;
startunit = nextunit;
initializeunit(output);
comm.location = 0;
comm.data = input;
comm.errorcode = E_PARSE; /* Assume parse error */
if (yyparse(&comm)){
if (comm.location==-1)
comm.location = strlen(input);
if (errstr){
if (smarterror && comm.errorcode==E_FUNC)
*errstr = strerror(errno);
else
*errstr=errormsg[comm.errorcode];
}
if (errloc)
*errloc = comm.location;
freelist(startunit);
return comm.errorcode;
} else {
if (errstr)
*errstr = 0;
multunit(output,comm.result);
freeunit(comm.result);
freelist(startunit);
return 0;
}
}
units-2.02/fdl-1.3.texi 0000664 0001750 0001750 00000055607 12007313547 014035 0 ustar adrian adrian @c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, La@TeX{} input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
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, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.''@: line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:
units-2.02/Makefile.dos 0000664 0001750 0001750 00000001115 10232761036 014301 0 ustar adrian adrian # edit these lines to suit
CC = cl
CFLAGS = -O2 -G5 -W3 -Za -nologo
OBJS = units.obj getopt.obj getopt1.obj parse.obj
# Uncomment this line and edit to suit
# UDEFINES = -D'UNITSFILE="c:/usr/local/share/units.dat"'
units.exe: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LIBS)
getopt.obj: getopt.c
$(CC) $(CFLAGS) $(CDEFINES) -c getopt.c
getopt1.obj: getopt1.c
$(CC) $(CFLAGS) $(CDEFINES) -c getopt1.c
units.obj: units.c
$(CC) $(CFLAGS) $(UDEFINES) $(CDEFINES) -c units.c
parse.obj: parse.tab.c
$(CC) $(CFLAGS) $(CDEFINES) -c parse.tab.c
mv parse.tab.obj parse.obj
clean:
rm -f $(OBJS)
units-2.02/locale.map 0000664 0001750 0001750 00000012706 11747125613 014032 0 ustar adrian adrian Afrikaans_South Africa af_ZA
Albanian_Albania sq_AL
Alsatian_France gsw_FR
Amharic_Ethiopia am_ET
Arabic_Algeria ar_DZ
Arabic_Bahrain ar_BH
Arabic_Egypt ar_EG
Arabic_Iraq ar_IQ
Arabic_Jordan ar_JO
Arabic_Kuwait ar_KW
Arabic_Lebanon ar_LB
Arabic_Libya ar_LY
Arabic_Morocco ar_MA
Arabic_Oman ar_OM
Arabic_Qatar ar_QA
Arabic_Saudi Arabia ar_SA
Arabic_Syria ar_SY
Arabic_Tunisia ar_TN
Arabic_U.A.E. ar_AE
Arabic_Yemen ar_YE
Armenian_Armenia hy_AM
Assamese_India as_IN
Azeri_Azerbaijan, Cyrillic az_AZ
Azeri_Azerbaijan, Latin az_AZ
Bashkir_Russia ba_RU
Basque_Basque eu_ES
Belarusian_Belarus be_BY
Bengali_Bangladesh bn_??
Bengali_India bn_IN
Bosnian_Neutral bs_??
Bosnian_Bosnia and Herzegovina, Cyrillic bs_BA
Bosnian_Bosnia and Herzegovina, Latin bs_BA
Breton_France br_FR
Bulgarian_Bulgaria bg_BG
Central Kurdish_Iraq ku_IQ
Cherokee_Cherokee chr_Cher
Catalan_Spain ca_ES
Chinese_Hong Kong SAR, PRC zh_HK
Chinese_Macao SAR zh_MO
Chinese_Singapore zh_SG
Chinese_Simplified zh_Hans
Chinese_Traditional zh_Hant
Corsican_France co_FR
Croatian_Neutral hr_??
Croatian_Bosnia and Herzegovina, Latin hr_BA
Croatian_Croatia hr_HR
Czech_Czech Republic cs_CZ
Danish_Denmark da_DK
Dari_Afghanistan prs_AF
Divehi_Maldives dv_MV
Dutch_Belgium nl_BE
Dutch_Netherlands nl_NL
English_Australia en_AU
English_Belize en_BZ
English_Canada en_CA
English_Caribbean en_029
English_India en_IN
English_Ireland en_IE
English_Ireland en_IE
English_Jamaica en_JM
English_Malaysia en_MY
English_New Zealand en_NZ
English_Philippines en_PH
English_Singapore en_SG
English_South Africa en_ZA
English_Trinidad and Tobago en_TT
English_United Kingdom en_GB
English_United States en_US
English_Zimbabwe en_ZW
Estonian_Estonia et_EE
Faroese_Faroe Islands fo_FO
Filipino_Philippines fil_PH
Finnish_Finland fi_FI
French_Belgium fr_BE
French_Canada fr_CA
French_France fr_FR
French_Luxembourg fr_LU
French_Monaco fr_MC
French_Switzerland fr_CH
Frisian_Netherlands fy_NL
Galician_Spain gl_ES
Georgian_Georgia ka_GE
German_Austria de_AT
German_Germany de_DE
German_Liechtenstein de_LI
German_Luxembourg de_LU
German_Switzerland de_CH
Greek_Greece el_GR
Greenlandic_Greenland kl_GL
Gujarati_India gu_IN
Hausa_Nigeria ha_NG
Hawiian_United States haw_US
Hebrew_Israel he_IL
Hindi_India hi_IN
Hungarian_Hungary hu_HU
Icelandic_Iceland is_IS
Igbo_Nigeria ig_NG
Indonesian_Indonesia id_ID
Inuktitut_Canada iu_CA, Latin
Inuktitut_Canada iu_CA, Canadian Syllabics
Irish_Ireland ga_IE
isiXhosa_South Africa xh_ZA
isiZulu_South Africa zu_ZA
Italian_Italy it_IT
Italian_Switzerland it_CH
Japanese_Japan ja_JP
Kannada_India kn_IN
Kazakh_Kazakhstan kk_KZ
Khmer_Cambodia kh_KH
K'iche_Guatemala qut_GT
Kinyarwanda_Rwanda rw_RW
Konkani_India kok_IN
Korean_Korea ko_KR
Kyrgyz_Kyrgyzstan ky_KG
Lao_Lao PDR lo_LA
Latvian_Latvia lv_LV
Lithuanian_Lithuanian lt_LT
Lower Sorbian_Germany dsb_DE
Luxembourgish_Luxembourg lb_LU
Macedonian_Macedonia, FYROM mk_MK
Malay_Brunei Darassalam ms_BN
Malay_Malaysia ms_MY
Malayalam_India ml_IN
Maltese_Malta mt_MT
Maori_New Zealand mi_NZ
Mapudungun_Chile arn_CL
Marathi_India mr_IN
Mohawk_Canada moh_CA
Mongolian_Mongolia, Cyrillic mn_MN
Mongolian_Mongolia, Mong mn_MN
Nepali_Nepal ne_NP
Nepali_India ne_IN
Norwegian_Bokmål, Norway no_NO
Norwegian_Nynorsk, Norway no_NO
Occitan_France oc_FR
Oriya_India or_IN
Pashto_Afghanistan ps_AF
Persian_Iran fa_IR
Polish_Poland pl_PL
Portuguese_Brazil pt_BR
Portuguese_Portugal pt_PT
Pular_Senegal ff_SN
Punjabi_India, Gurmukhi script pa_IN
Punjabi_Pakistan, Arabic script pa_PK
Quechua_Bolivia quz_BO
Quechua_Ecuador quz_EC
Quechua_Peru quz_PE
Romanian_Romania ro_RO
Romansh_Switzerland rm_CH
Russian_Russia ru_RU
Sakha_Russia sah_RU
Sami_Inari, Finland smn_FI
Sami_Lule, Norway smj_NO
Sami_Lule, Sweden smj_SE
Sami_Northern, Finland se_FI
Sami_Northern, Norway se_NO
Sami_Northern, Sweden se_SE
Sami_Skolt, Finland sms_FI
Sami_Southern, Norway sma_NO
Sami_Southern, Sweden sma_SE
Sanskrit_India sa_IN
Serbian_Neutral sr_??
Serbian_Bosnia and Herzegovina, Cyrillic sr_BA
Serbian_Bosnia and Herzegovina, Latin sr_BA
Serbian_Croatia sr_HR
Serbian_Serbia and Montenegro, Former, Cyrillic sr_CS
Serbian_Serbia and Montenegro, Former, Latin sr_CS
Sesotho sa Leboa_South Africa nso_ZA
Setswana / Tswana_Botswana tn_BW
Setswana / Tswana_South Africa tn_ZA
Sindhi_Pakistan sd_PK
Sinhala_Sri Lanka si_LK
Slovak_Slovakia sk_SK
Slovenian_Slovenia sl_SI
Spanish_Argentina es_AR
Spanish_Bolivia es_BO
Spanish_Chile es_CL
Spanish_Colombia es_CO
Spanish_Costa Rica es_CR
Spanish_Dominican Republic es_DO
Spanish_Ecuador es_EC
Spanish_El Salvador es_SV
Spanish_Guatemala es_GT
Spanish_Honduras es_HN
Spanish_Mexico es_MX
Spanish_Nicaragua es_NI
Spanish_Panama es_PA
Spanish_Paraguay es_PY
Spanish_Peru es_PE
Spanish_Puerto Rico es_PR
Spanish_Spain, Modern Sort es_ES
Spanish_Spain, Traditional Sort es_ES
Spanish_United States es_US
Spanish_Uruguay es_UY
Spanish_Venezuela es_VE
Swahili_Kenya sw_KE
Swedish_Finland sv_FI
Swedish_Sweden sv_SE
Swedish_Sweden sv_SE
Syriac_Syria syr_SY
Tajik_Tajikistan, Cyrillic tg_TJ
Tamazight_Algeria, Latin tzm_DZ
Tamil_India ta_IN
Tamil_Sri Lanka ta_LK
Tatar_Russia tt_RU
Telugu_India te_IN
Thai_Thailand th_TH
Tibetan_PRC bo_CN
Tigrinya_Eritrea ti_ER
Tigrinya_Ethiopia ti_ET
Turkish_Turkey tr_TR
Turkmen_Turkmenistan tk_TM
Ukrainian_Ukraine uk_UA
Upper Sorbian_Germany hsb_DE
Urdu_(reserved) ur_??
Urdu_Pakistan ur_PK
Uyghur_PRC ug_CN
Uzbek_Uzbekistan, Cyrillic uz_UZ
Uzbek_Uzbekistan, Latin uz_UZ
Valencian_Valencia ca_ES-Valencia
Vietnamese_Vietnam vi_VN
Welsh_United Kingdom cy_GB
Wolof_Senegal wo_SN
Yi_PRC ii_CN
Yoruba_Nigeria yo_NG
units-2.02/parse.tab.c 0000664 0001750 0001750 00000173477 12156460651 014133 0 ustar adrian adrian /* A Bison parser, made by GNU Bison 2.5. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.5"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 0
/* Substitute the variable and function names. */
#define yyparse unitsparse
#define yylex unitslex
#define yyerror unitserror
#define yylval unitslval
#define yychar unitschar
#define yydebug unitsdebug
#define yynerrs unitsnerrs
/* Copy the first part of user declarations. */
/* Line 268 of yacc.c */
#line 24 "parse.y"
#define YYPARSE_PARAM comm
#define YYLEX_PARAM comm
#define COMM ((struct commtype *)comm)
#include "units.h"
int yylex();
void yyerror(char *);
static int err; /* value used by parser to store return values */
#define CHECK if (err) { COMM->errorcode=err; YYABORT; }
#define MEMSIZE 100
struct unittype *memtable[MEMSIZE];
int nextunit=0;
int maxunit=0;
struct commtype {
int location;
char *data;
struct unittype *result;
int errorcode;
char *paramname;
struct unittype *paramvalue;
};
struct function {
char *name;
double (*func)(double);
int type;
};
#define DIMENSIONLESS 0
#define ANGLEIN 1
#define ANGLEOUT 2
struct unittype *
getnewunit()
{
if (nextunit>=MEMSIZE)
return 0;
memtable[nextunit] = (struct unittype *)
mymalloc(sizeof(struct unittype),"(getnewunit)");
if (!memtable[nextunit])
return 0;
initializeunit(memtable[nextunit]);
return memtable[nextunit++];
}
struct unittype *
makenumunit(double num,int *myerr)
{
struct unittype *ret;
ret=getnewunit();
if (!ret){
*myerr = E_PARSEMEM;
return 0;
}
ret->factor = num;
*myerr = 0;
return ret;
}
double
logb2(double x)
{
return log(x)/log(2.0);
}
int
funcunit(struct unittype *theunit, struct function *fun)
{
struct unittype angleunit;
if (fun->type==ANGLEIN){
err=unit2num(theunit);
if (err==E_NOTANUMBER){
initializeunit(&angleunit);
angleunit.denominator[0] = dupstr("radian");
angleunit.denominator[1] = 0;
err = multunit(theunit, &angleunit);
freeunit(&angleunit);
if (!err)
err = unit2num(theunit);
}
if (err)
return err;
} else if (fun->type==ANGLEOUT || fun->type == DIMENSIONLESS) {
if ((err=unit2num(theunit)))
return err;
} else
return E_BADFUNCTYPE;
errno = 0;
theunit->factor = (*(fun->func))(theunit->factor);
if (errno)
return E_FUNC;
if (fun->type==ANGLEOUT) {
theunit->numerator[0] = dupstr("radian");
theunit->numerator[1] = 0;
}
return 0;
}
/* Line 268 of yacc.c */
#line 195 "parse.tab.c"
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
REAL = 258,
UNIT = 259,
RFUNC = 260,
UFUNC = 261,
EXPONENT = 262,
MULTIPLY = 263,
MULTSTAR = 264,
DIVIDE = 265,
NUMDIV = 266,
SQRT = 267,
CUBEROOT = 268,
MULTMINUS = 269,
EOL = 270,
FUNCINV = 271,
MEMERROR = 272,
BADNUMBER = 273,
UNITEND = 274,
MINUS = 275,
ADD = 276,
UNARY = 277
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 293 of yacc.c */
#line 142 "parse.y"
double number;
int integer;
struct unittype *utype;
struct function *dfunc;
struct func *ufunc;
/* Line 293 of yacc.c */
#line 263 "parse.tab.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */
#line 275 "parse.tab.c"
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
#else
# define YYUSE(e) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
YYID (int yyi)
#else
static int
YYID (yyi)
int yyi;
#endif
{
return yyi;
}
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 32
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 171
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 25
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 7
/* YYNRULES -- Number of rules. */
#define YYNRULES 33
/* YYNRULES -- Number of states. */
#define YYNSTATES 57
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 277
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
23, 24, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22
};
#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 8, 10, 12, 15, 17, 20,
23, 27, 31, 35, 39, 43, 45, 49, 53, 55,
57, 61, 65, 68, 70, 73, 76, 79, 82, 86,
91, 96, 98, 100
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
26, 0, -1, 15, -1, 27, 15, -1, 1, -1,
28, -1, 10, 31, -1, 31, -1, 14, 31, -1,
20, 31, -1, 28, 21, 28, -1, 28, 20, 28,
-1, 28, 10, 28, -1, 28, 8, 28, -1, 28,
9, 28, -1, 3, -1, 29, 11, 29, -1, 23,
28, 24, -1, 29, -1, 4, -1, 31, 7, 31,
-1, 31, 14, 31, -1, 31, 31, -1, 30, -1,
12, 30, -1, 13, 30, -1, 5, 30, -1, 6,
30, -1, 16, 6, 30, -1, 31, 7, 14, 31,
-1, 31, 7, 20, 31, -1, 18, -1, 17, -1,
19, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 187, 187, 188, 189, 192, 193, 196, 197, 198,
199, 200, 202, 203, 204, 207, 208, 211, 217, 218,
219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
231, 234, 235, 236
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "REAL", "UNIT", "RFUNC", "UFUNC",
"EXPONENT", "MULTIPLY", "MULTSTAR", "DIVIDE", "NUMDIV", "SQRT",
"CUBEROOT", "MULTMINUS", "EOL", "FUNCINV", "MEMERROR", "BADNUMBER",
"UNITEND", "MINUS", "ADD", "UNARY", "'('", "')'", "$accept", "input",
"unitexpr", "expr", "numexpr", "pexpr", "list", 0
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
token YYLEX-NUM. */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 40, 41
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 25, 26, 26, 26, 27, 27, 28, 28, 28,
28, 28, 28, 28, 28, 29, 29, 30, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 2, 1, 1, 2, 1, 2, 2,
3, 3, 3, 3, 3, 1, 3, 3, 1, 1,
3, 3, 2, 1, 2, 2, 2, 2, 3, 4,
4, 1, 1, 1
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
0, 4, 15, 19, 0, 0, 0, 0, 0, 0,
2, 0, 32, 31, 33, 0, 0, 0, 0, 5,
18, 23, 7, 26, 27, 6, 24, 25, 8, 0,
9, 0, 1, 3, 0, 0, 0, 0, 0, 0,
0, 0, 22, 28, 17, 13, 14, 12, 11, 10,
16, 0, 0, 20, 21, 29, 30
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 17, 18, 19, 20, 21, 42
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -17
static const yytype_int16 yypact[] =
{
43, -17, -17, -17, -16, -16, 148, -16, -16, 148,
-17, 7, -17, -17, -17, 148, 64, 8, -1, 65,
16, -17, 85, -17, -17, 85, -17, -17, 85, -16,
85, 9, -17, -17, 64, 64, 64, 64, 64, 17,
106, 148, 127, -17, -17, -17, 20, 20, 2, 2,
-17, 148, 148, 24, 127, 24, 24
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-17, -17, -17, -13, -7, -3, 0
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
22, 23, 24, 31, 26, 27, 25, 16, 32, 28,
34, 35, 36, 29, 33, 30, 22, 34, 35, 36,
2, 45, 46, 47, 48, 49, 43, 39, 34, 37,
38, 40, 50, 44, 22, 22, 22, 22, 22, 0,
53, 54, 0, 0, 1, 0, 2, 3, 4, 5,
0, 55, 56, 6, 0, 7, 8, 9, 10, 11,
12, 13, 14, 15, 0, 0, 16, 2, 3, 4,
5, 0, 0, 34, 35, 36, 7, 8, 9, 0,
11, 12, 13, 14, 15, 37, 38, 16, 2, 3,
4, 5, 40, 0, 0, 0, 0, 7, 8, 41,
0, 11, 12, 13, 14, 0, 0, 0, 16, 2,
3, 4, 5, 0, 0, 0, 0, 0, 7, 8,
51, 0, 11, 12, 13, 14, 52, 0, 0, 16,
2, 3, 4, 5, 40, 0, 0, 0, 0, 7,
8, 0, 0, 11, 12, 13, 14, 0, 0, 0,
16, 2, 3, 4, 5, 0, 0, 0, 0, 0,
7, 8, 0, 0, 11, 12, 13, 14, 0, 0,
0, 16
};
#define yypact_value_is_default(yystate) \
((yystate) == (-17))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
{
0, 4, 5, 16, 7, 8, 6, 23, 0, 9,
8, 9, 10, 6, 15, 15, 16, 8, 9, 10,
3, 34, 35, 36, 37, 38, 29, 11, 8, 20,
21, 7, 39, 24, 34, 35, 36, 37, 38, -1,
40, 41, -1, -1, 1, -1, 3, 4, 5, 6,
-1, 51, 52, 10, -1, 12, 13, 14, 15, 16,
17, 18, 19, 20, -1, -1, 23, 3, 4, 5,
6, -1, -1, 8, 9, 10, 12, 13, 14, -1,
16, 17, 18, 19, 20, 20, 21, 23, 3, 4,
5, 6, 7, -1, -1, -1, -1, 12, 13, 14,
-1, 16, 17, 18, 19, -1, -1, -1, 23, 3,
4, 5, 6, -1, -1, -1, -1, -1, 12, 13,
14, -1, 16, 17, 18, 19, 20, -1, -1, 23,
3, 4, 5, 6, 7, -1, -1, -1, -1, 12,
13, -1, -1, 16, 17, 18, 19, -1, -1, -1,
23, 3, 4, 5, 6, -1, -1, -1, -1, -1,
12, 13, -1, -1, 16, 17, 18, 19, -1, -1,
-1, 23
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 1, 3, 4, 5, 6, 10, 12, 13, 14,
15, 16, 17, 18, 19, 20, 23, 26, 27, 28,
29, 30, 31, 30, 30, 31, 30, 30, 31, 6,
31, 28, 0, 15, 8, 9, 10, 20, 21, 11,
7, 14, 31, 30, 24, 28, 28, 28, 28, 28,
29, 14, 20, 31, 31, 31, 31
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. However,
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
YYFAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, YYLEX_PARAM)
#else
# define YYLEX yylex (&yylval)
#endif
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (YYID (0))
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value); \
YYFPRINTF (stderr, "\n"); \
} \
} while (YYID (0))
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
#endif
{
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
YYUSE (yyoutput);
# endif
switch (yytype)
{
default:
break;
}
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
#endif
{
if (yytype < YYNTOKENS)
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
yy_symbol_value_print (yyoutput, yytype, yyvaluep);
YYFPRINTF (yyoutput, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (yybottom, yytop)
yytype_int16 *yybottom;
yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (YYID (0))
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
#else
static void
yy_reduce_print (yyvsp, yyrule)
YYSTYPE *yyvsp;
int yyrule;
#endif
{
int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyvsp, Rule); \
} while (YYID (0))
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
const char *yystr;
#endif
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
char *yydest;
const char *yysrc;
#endif
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider. See
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
}
}
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yymsg, yytype, yyvaluep)
const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
#endif
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
default:
break;
}
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
/*----------.
| yyparse. |
`----------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
#else
int
yyparse ()
#endif
#endif
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
`yyss': related to states.
`yyvs': related to semantic values.
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
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;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# 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));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
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. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
/* Line 1806 of yacc.c */
#line 187 "parse.y"
{ COMM->result = makenumunit(1,&err); CHECK; YYACCEPT; }
break;
case 3:
/* Line 1806 of yacc.c */
#line 188 "parse.y"
{ COMM->result = (yyvsp[(1) - (2)].utype); YYACCEPT; }
break;
case 4:
/* Line 1806 of yacc.c */
#line 189 "parse.y"
{ YYABORT; }
break;
case 5:
/* Line 1806 of yacc.c */
#line 192 "parse.y"
{(yyval.utype) = (yyvsp[(1) - (1)].utype);}
break;
case 6:
/* Line 1806 of yacc.c */
#line 193 "parse.y"
{ invertunit((yyvsp[(2) - (2)].utype)); (yyval.utype)=(yyvsp[(2) - (2)].utype);}
break;
case 7:
/* Line 1806 of yacc.c */
#line 196 "parse.y"
{ (yyval.utype) = (yyvsp[(1) - (1)].utype); }
break;
case 8:
/* Line 1806 of yacc.c */
#line 197 "parse.y"
{ (yyval.utype) = (yyvsp[(2) - (2)].utype); (yyval.utype)->factor *= -1; }
break;
case 9:
/* Line 1806 of yacc.c */
#line 198 "parse.y"
{ (yyval.utype) = (yyvsp[(2) - (2)].utype); (yyval.utype)->factor *= -1; }
break;
case 10:
/* Line 1806 of yacc.c */
#line 199 "parse.y"
{ err = addunit((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 11:
/* Line 1806 of yacc.c */
#line 200 "parse.y"
{ (yyvsp[(3) - (3)].utype)->factor *= -1; err = addunit((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype));
CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 12:
/* Line 1806 of yacc.c */
#line 202 "parse.y"
{ err = divunit((yyvsp[(1) - (3)].utype), (yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 13:
/* Line 1806 of yacc.c */
#line 203 "parse.y"
{ err = multunit((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 14:
/* Line 1806 of yacc.c */
#line 204 "parse.y"
{ err = multunit((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 15:
/* Line 1806 of yacc.c */
#line 207 "parse.y"
{ (yyval.number) = (yyvsp[(1) - (1)].number); }
break;
case 16:
/* Line 1806 of yacc.c */
#line 208 "parse.y"
{ (yyval.number) = (yyvsp[(1) - (3)].number) / (yyvsp[(3) - (3)].number); }
break;
case 17:
/* Line 1806 of yacc.c */
#line 211 "parse.y"
{ (yyval.utype) = (yyvsp[(2) - (3)].utype); }
break;
case 18:
/* Line 1806 of yacc.c */
#line 217 "parse.y"
{ (yyval.utype) = makenumunit((yyvsp[(1) - (1)].number),&err); CHECK;}
break;
case 19:
/* Line 1806 of yacc.c */
#line 218 "parse.y"
{ (yyval.utype) = (yyvsp[(1) - (1)].utype); }
break;
case 20:
/* Line 1806 of yacc.c */
#line 219 "parse.y"
{ err = unitpower((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 21:
/* Line 1806 of yacc.c */
#line 220 "parse.y"
{ err = multunit((yyvsp[(1) - (3)].utype),(yyvsp[(3) - (3)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (3)].utype);}
break;
case 22:
/* Line 1806 of yacc.c */
#line 221 "parse.y"
{ err = multunit((yyvsp[(1) - (2)].utype),(yyvsp[(2) - (2)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (2)].utype);}
break;
case 23:
/* Line 1806 of yacc.c */
#line 222 "parse.y"
{ (yyval.utype)=(yyvsp[(1) - (1)].utype); }
break;
case 24:
/* Line 1806 of yacc.c */
#line 223 "parse.y"
{ err = rootunit((yyvsp[(2) - (2)].utype),2); CHECK; (yyval.utype)=(yyvsp[(2) - (2)].utype);}
break;
case 25:
/* Line 1806 of yacc.c */
#line 224 "parse.y"
{ err = rootunit((yyvsp[(2) - (2)].utype),3); CHECK; (yyval.utype)=(yyvsp[(2) - (2)].utype);}
break;
case 26:
/* Line 1806 of yacc.c */
#line 225 "parse.y"
{ err = funcunit((yyvsp[(2) - (2)].utype),(yyvsp[(1) - (2)].dfunc)); CHECK; (yyval.utype)=(yyvsp[(2) - (2)].utype);}
break;
case 27:
/* Line 1806 of yacc.c */
#line 226 "parse.y"
{ err = evalfunc((yyvsp[(2) - (2)].utype),(yyvsp[(1) - (2)].ufunc),0); CHECK; (yyval.utype)=(yyvsp[(2) - (2)].utype);}
break;
case 28:
/* Line 1806 of yacc.c */
#line 227 "parse.y"
{ err = evalfunc((yyvsp[(3) - (3)].utype),(yyvsp[(2) - (3)].ufunc),1); CHECK; (yyval.utype)=(yyvsp[(3) - (3)].utype);}
break;
case 29:
/* Line 1806 of yacc.c */
#line 229 "parse.y"
{ (yyvsp[(4) - (4)].utype)->factor *= -1;
err = unitpower((yyvsp[(1) - (4)].utype),(yyvsp[(4) - (4)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (4)].utype);}
break;
case 30:
/* Line 1806 of yacc.c */
#line 232 "parse.y"
{ (yyvsp[(4) - (4)].utype)->factor *= -1;
err = unitpower((yyvsp[(1) - (4)].utype),(yyvsp[(4) - (4)].utype)); CHECK; (yyval.utype)=(yyvsp[(1) - (4)].utype);}
break;
case 31:
/* Line 1806 of yacc.c */
#line 234 "parse.y"
{ err = E_BADNUM; CHECK; }
break;
case 32:
/* Line 1806 of yacc.c */
#line 235 "parse.y"
{ err = E_PARSEMEM; CHECK; }
break;
case 33:
/* Line 1806 of yacc.c */
#line 236 "parse.y"
{ err = E_UNITEND; CHECK; }
break;
/* Line 1806 of yacc.c */
#line 1788 "parse.tab.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* 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];
goto yynewstate;
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| 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;
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
*++yyvsp = yylval;
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
/* Make sure YYID is used. */
return YYID (yyresult);
}
/* Line 2067 of yacc.c */
#line 242 "parse.y"
#ifndef strchr
# ifdef NO_STRCHR
# define strchr(a,b) index((a),(b))
# else
char *strchr();
# endif
#endif /* !strchr */
double strtod();
struct function
realfunctions[] = { {"sin", sin, ANGLEIN},
{"cos", cos, ANGLEIN},
{"tan", tan, ANGLEIN},
{"ln", log, DIMENSIONLESS},
{"log", log10, DIMENSIONLESS},
{"log2", logb2, DIMENSIONLESS},
{"exp", exp, DIMENSIONLESS},
{"acos", acos, ANGLEOUT},
{"atan", atan, ANGLEOUT},
{"asin", asin, ANGLEOUT},
{0, 0, 0}};
struct {
char op;
int value;
} optable[] = { {'*', MULTIPLY},
{'/', DIVIDE},
{'|', NUMDIV},
{'+', ADD},
{'(', '('},
{')', ')'},
{'^', EXPONENT},
{'~', FUNCINV},
{0, 0}};
struct {
char *name;
int value;
} strtable[] = { {"sqrt", SQRT},
{"cuberoot", CUBEROOT},
{"per" , DIVIDE},
{0, 0}};
int yylex(YYSTYPE *lvalp, struct commtype *comm)
{
int length, count;
struct unittype *output;
char *inptr;
char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name */
char *nonunitends = ".,_"; /* Can't start or end a unit */
char *number_start = ".,0123456789"; /* Can be first char of a number */
if (comm->location==-1) return 0;
inptr = comm->data + comm->location; /* Point to start of data */
/* Skip white space */
while( *inptr && strchr(WHITE,*inptr)) inptr++, comm->location++;
if (*inptr==0) {
comm->location = -1;
return EOL; /* Return failure if string has ended */
}
/* Check for **, an exponent operator. */
if (0==strncmp("**",inptr,2)){
comm->location += 2;
return EXPONENT;
}
/* Check for '-' and '*' which get special handling */
if (*inptr=='-'){
comm->location++;
if (parserflags.minusminus)
return MINUS;
return MULTMINUS;
}
if (*inptr=='*'){
comm->location++;
if (parserflags.oldstar)
return MULTIPLY;
return MULTSTAR;
}
/* Look for single character ops */
for(count=0; optable[count].op; count++){
if (*inptr==optable[count].op) {
comm->location++;
return optable[count].value;
}
}
/* Look for numbers */
if (strchr(number_start,*inptr)){ /* prevent "nan" from being recognized */
char *endloc;
lvalp->number = strtod(inptr, &endloc);
if (inptr != endloc) {
comm->location += (endloc-inptr);
if (*endloc && strchr(number_start,*endloc))
return BADNUMBER;
else
return REAL;
}
}
/* Look for a word (function name or unit name) */
length = strcspn(inptr,nonunitchars);
if (!length){ /* Next char is not a valid unit char */
comm->location++;
return 0;
}
/* Check that unit name doesn't start or end with forbidden chars */
if (strchr(nonunitends,*inptr)){
comm->location++;
return 0;
}
if (strchr(nonunitends, inptr[length-1])){
comm->location+=length;
return 0;
}
/* Look for string operators */
for(count=0;strtable[count].name;count++){
if (length==strlen(strtable[count].name) &&
0==strncmp(strtable[count].name,inptr,length)){
comm->location += length;
return strtable[count].value;
}
}
/* Look for real function names */
for(count=0;realfunctions[count].name;count++){
if (length==strlen(realfunctions[count].name) &&
0==strncmp(realfunctions[count].name,inptr,length)){
lvalp->dfunc = realfunctions+count;
comm->location += length;
return RFUNC;
}
}
/* Look for function parameter */
if (function_parameter && length==strlen(function_parameter) &&
0==strncmp(function_parameter, inptr, length)){
output = getnewunit();
if (!output)
return MEMERROR;
unitcopy(output, parameter_value);
lvalp->utype = output;
comm->location += length;
return UNIT;
}
/* Look for user defined function */
lvalp->ufunc = fnlookup(inptr,length);
if (lvalp->ufunc){
comm->location += length;
return UFUNC;
}
/* Didn't find a special string, so treat it as unit name */
comm->location+=length;
if (strchr("23456789",inptr[length-1]) &&
!hassubscript(inptr,length)) { /* do exponent handling like m3 */
count = inptr[length-1] - '0';
length--;
if (strchr(number_start, inptr[length-1])){
return UNITEND;
}
} else count=1;
output = getnewunit();
if (!output)
return MEMERROR;
output->numerator[count]=0;
for(;count;count--){
output->numerator[count-1] = mymalloc(length+1,"(yylex)");
strncpy(output->numerator[count-1], inptr, length);
output->numerator[count-1][length]=0;
}
lvalp->utype=output;
return UNIT;
}
void yyerror(char *s){}
void
freelist(int startunit)
{
if (nextunit>maxunit)
maxunit = nextunit;
while(nextunit>startunit){
freeunit(memtable[--nextunit]);
free(memtable[nextunit]);
}
}
int
parseunit(struct unittype *output, char *input,char **errstr,int *errloc)
{
struct commtype comm;
int startunit;
startunit = nextunit;
initializeunit(output);
comm.location = 0;
comm.data = input;
comm.errorcode = E_PARSE; /* Assume parse error */
if (yyparse(&comm)){
if (comm.location==-1)
comm.location = strlen(input);
if (errstr){
if (smarterror && comm.errorcode==E_FUNC)
*errstr = strerror(errno);
else
*errstr=errormsg[comm.errorcode];
}
if (errloc)
*errloc = comm.location;
freelist(startunit);
return comm.errorcode;
} else {
if (errstr)
*errstr = 0;
multunit(output,comm.result);
freeunit(comm.result);
freelist(startunit);
return 0;
}
}
units-2.02/configure 0000775 0001750 0001750 00000425251 12157322210 013772 0 ustar adrian adrian #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for GNU units 2.02.
#
# Report bugs to .
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
# Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
# is contrary to our usage. Disable this feature.
alias -g '\${1+\"\$@\"}'='\"\$@\"'
setopt NO_GLOB_SUBST
else
case \`(set -o) 2>/dev/null\` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
"
as_required="as_fn_return () { (exit \$1); }
as_fn_success () { as_fn_return 0; }
as_fn_failure () { as_fn_return 1; }
as_fn_ret_success () { return 0; }
as_fn_ret_failure () { return 1; }
exitcode=0
as_fn_success || { exitcode=1; echo as_fn_success failed.; }
as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
test \$(( 1 + 1 )) = 2 || exit 1"
if (eval "$as_required") 2>/dev/null; then :
as_have_required=yes
else
as_have_required=no
fi
if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_found=false
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
as_found=:
case $as_dir in #(
/*)
for as_base in sh bash ksh sh5; do
# Try only shells that exist, to save several forks.
as_shell=$as_dir/$as_base
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
CONFIG_SHELL=$as_shell as_have_required=yes
if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
break 2
fi
fi
done;;
esac
as_found=false
done
$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
CONFIG_SHELL=$SHELL as_have_required=yes
fi; }
IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
fi
if test x$as_have_required = xno; then :
$as_echo "$0: This script requires a shell more modern than all"
$as_echo "$0: the shells that I found on your system."
if test x${ZSH_VERSION+set} = xset ; then
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org and adrianm@gnu.org
$0: about your system, including any error possibly output
$0: before this message. Then install a modern shell, or
$0: manually run the script under such a shell if you do
$0: have one."
fi
exit 1
fi
fi
fi
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
# Unset more variables known to interfere with behavior of common tools.
CLICOLOR_FORCE= GREP_OPTIONS=
unset CLICOLOR_FORCE GREP_OPTIONS
## --------------------- ##
## M4sh Shell Functions. ##
## --------------------- ##
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_lineno_1=$LINENO as_lineno_1a=$LINENO
as_lineno_2=$LINENO as_lineno_2a=$LINENO
eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
# Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
test -n "$DJDIR" || exec 7<&0 &1
# Name of the host.
# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GNU units'
PACKAGE_TARNAME='units'
PACKAGE_VERSION='2.02'
PACKAGE_STRING='GNU units 2.02'
PACKAGE_BUGREPORT='adrianm@gnu.org'
PACKAGE_URL='http://www.gnu.org/software/units/'
# Factoring default headers for most tests.
ac_includes_default="\
#include
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_SYS_STAT_H
# include
#endif
#ifdef STDC_HEADERS
# include
# include
#else
# ifdef HAVE_STDLIB_H
# include
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include
# endif
# include
#endif
#ifdef HAVE_STRINGS_H
# include
#endif
#ifdef HAVE_INTTYPES_H
# include
#endif
#ifdef HAVE_STDINT_H
# include
#endif
#ifdef HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='LTLIBOBJS
LIBOBJS
EGREP
GREP
CPP
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
UDAT
STRFUNC
DEFIS
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_URL
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_path_search
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*=) ac_optarg= ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) as_fn_error $? "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information"
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
case $ac_envvar in #(
'' | [0-9]* | *[!_$as_cr_alnum]* )
as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
esac
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
as_fn_error $? "missing argument to $ac_option"
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
as_fn_error $? "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
as_fn_error $? "pwd does not report name of working directory"
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then the parent directory.
ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_myself" : 'X\(//\)[^/]' \| \
X"$as_myself" : 'X\(//\)$' \| \
X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r "$srcdir/$ac_unique_file"; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
eval ac_env_${ac_var}_set=\${${ac_var}+set}
eval ac_env_${ac_var}_value=\$${ac_var}
eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
eval ac_cv_env_${ac_var}_value=\$${ac_var}
done
#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
# 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.02 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print \`checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/units]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_ACEOF
cat <<\_ACEOF
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
_ACEOF
fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of GNU units 2.02:";;
esac
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-path-search search path for units database (default is NO)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to .
GNU units home page: .
General help using GNU software: .
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested configure.
if test -f "$ac_srcdir/configure.gnu"; then
echo &&
$SHELL "$ac_srcdir/configure.gnu" --help=recursive
elif test -f "$ac_srcdir/configure"; then
echo &&
$SHELL "$ac_srcdir/configure" --help=recursive
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
GNU units configure 2.02
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit
fi
## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##
# ac_fn_c_try_compile LINENO
# --------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_cpp ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } > conftest.i && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
# the include files in INCLUDES and setting the cache variable VAR
# accordingly.
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if eval \${$3+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
$as_echo_n "checking $2 usability... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_header_compiler=yes
else
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
$as_echo_n "checking $2 presence... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <$2>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_header_preproc=yes
else
ac_header_preproc=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
yes:no: )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
no:yes:* )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## ------------------------------ ##
## Report this to adrianm@gnu.org ##
## ------------------------------ ##"
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case declares $2.
For example, HP-UX 11i declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
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.02, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*\'*)
ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
2)
as_fn_append ac_configure_args1 " '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
as_fn_append ac_configure_args " '$ac_arg'"
;;
esac
done
done
{ ac_configure_args0=; unset ac_configure_args0;}
{ ac_configure_args1=; unset ac_configure_args1;}
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
$as_echo "## ---------------- ##
## Cache variables. ##
## ---------------- ##"
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
$as_echo "## ----------------- ##
## Output variables. ##
## ----------------- ##"
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
$as_echo "## ------------------- ##
## File substitutions. ##
## ------------------- ##"
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
$as_echo "## ----------- ##
## confdefs.h. ##
## ----------- ##"
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
$as_echo "/* confdefs.h */" > confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_URL "$PACKAGE_URL"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
# We do not want a PATH search for config.site.
case $CONFIG_SITE in #((
-*) ac_site_file1=./$CONFIG_SITE;;
*/*) ac_site_file1=$CONFIG_SITE;;
*) ac_site_file1=./$CONFIG_SITE;;
esac
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file" \
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
See \`config.log' for more details" "$LINENO" 5; }
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special files
# actually), so we avoid doing that. DJGPP emulates it as a regular file.
if test /dev/null != "$cache_file" && test -f "$cache_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val=\$ac_cv_env_${ac_var}_value
eval ac_new_val=\$ac_env_${ac_var}_value
case $ac_old_set,$ac_new_set in
set,)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) as_fn_append ac_configure_args " '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
## -------------------- ##
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
test "$program_prefix" != NONE &&
program_transform_name="s&^&$program_prefix&;$program_transform_name"
# Use a double $ so make ignores it.
test "$program_suffix" != NONE &&
program_transform_name="s&\$&$program_suffix&;$program_transform_name"
# Double any \ or $.
# By default was `s,x,x', remove it if useless.
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
saveCFLAGS=$CFLAGS
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
for ac_prog in gcc cc egcs cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in gcc cc egcs cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { { ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
if test -z "$ac_file"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
ac_exeext=$ac_cv_exeext
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
int
main ()
{
FILE *f = fopen ("conftest.out", "w");
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
ac_clean_files="$ac_clean_files conftest.out"
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
if test "$cross_compiling" != yes; then
{ { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
if { ac_try='./conftest$ac_cv_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if ${ac_cv_objext+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if ${ac_cv_c_compiler_gnu+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_compiler_gnu=yes
else
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if ${ac_cv_prog_cc_g+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
else
CFLAGS=""
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if ${ac_cv_prog_cc_c89+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
if ${ac_cv_prog_cc_c99+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c99=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
#include
// Check varargs macros. These examples are taken from C99 6.10.3.5.
#define debug(...) fprintf (stderr, __VA_ARGS__)
#define showlist(...) puts (#__VA_ARGS__)
#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
static void
test_varargs_macros (void)
{
int x = 1234;
int y = 5678;
debug ("Flag");
debug ("X = %d\n", x);
showlist (The first, second, and third items.);
report (x>y, "x is %d but y is %d", x, y);
}
// Check long long types.
#define BIG64 18446744073709551615ull
#define BIG32 4294967295ul
#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
#if !BIG_OK
your preprocessor is broken;
#endif
#if BIG_OK
#else
your preprocessor is broken;
#endif
static long long int bignum = -9223372036854775807LL;
static unsigned long long int ubignum = BIG64;
struct incomplete_array
{
int datasize;
double data[];
};
struct named_init {
int number;
const wchar_t *name;
double average;
};
typedef const char *ccp;
static inline int
test_restrict (ccp restrict text)
{
// See if C++-style comments work.
// Iterate through items via the restricted pointer.
// Also check for declarations in for loops.
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
continue;
return 0;
}
// Check varargs and va_copy.
static void
test_varargs (const char *format, ...)
{
va_list args;
va_start (args, format);
va_list args_copy;
va_copy (args_copy, args);
const char *str;
int number;
float fnumber;
while (*format)
{
switch (*format++)
{
case 's': // string
str = va_arg (args_copy, const char *);
break;
case 'd': // int
number = va_arg (args_copy, int);
break;
case 'f': // float
fnumber = va_arg (args_copy, double);
break;
default:
break;
}
}
va_end (args_copy);
va_end (args);
}
int
main ()
{
// Check bool.
_Bool success = false;
// Check restrict.
if (test_restrict ("String literal") == 0)
success = true;
char *restrict newvar = "Another string";
// Check varargs.
test_varargs ("s, d' f .", "string", 65, 34.234);
test_varargs_macros ();
// Check flexible array members.
struct incomplete_array *ia =
malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
ia->datasize = 10;
for (int i = 0; i < ia->datasize; ++i)
ia->data[i] = i * 1.234;
// Check named initializers.
struct named_init ni = {
.number = 34,
.name = L"Test wide string",
.average = 543.34343,
};
ni.number = 58;
int dynamic_array[ni.number];
dynamic_array[ni.number - 1] = 543;
// work around unused variable warnings
return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
|| dynamic_array[ni.number - 1] != 543);
;
return 0;
}
_ACEOF
for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
do
CC="$ac_save_CC $ac_arg"
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_c99=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c99" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c99" in
x)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c99"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c99" != xno; then :
fi
if test "$CC" = cl.exe -a -z "$saveCFLAGS" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: setting special CFLAGS value for cl" >&5
$as_echo "$as_me: setting special CFLAGS value for cl" >&6;}
CFLAGS="-G6 -O2 -Za -W3 -nologo"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
if ${ac_cv_c_const+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
/* FIXME: Include the comments suggested by Paul. */
#ifndef __cplusplus
/* Ultrix mips cc rejects this. */
typedef int charset[2];
const charset cs;
/* SunOS 4.1.1 cc rejects this. */
char const *const *pcpcc;
char **ppc;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in
an arm of an if-expression whose if-part is not a constant
expression */
const char *g = "string";
pcpcc = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++pcpcc;
ppc = (char**) pcpcc;
pcpcc = (char const *const *) ppc;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
if (s) return 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
if (!foo) return 0;
}
return !cs[0] && !zero.x;
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_const=yes
else
ac_cv_c_const=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
$as_echo "$ac_cv_c_const" >&6; }
if test $ac_cv_c_const = no; then
$as_echo "#define const /**/" >>confdefs.h
fi
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
if test -f "$ac_dir/install-sh"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c"
break
elif test -f "$ac_dir/install.sh"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install.sh -c"
break
elif test -f "$ac_dir/shtool"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/shtool install -c"
break
fi
done
if test -z "$ac_aux_dir"; then
as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
fi
# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if ${ac_cv_path_install+:} false; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
# Account for people who put trailing slashes in PATH elements.
case $as_dir/ in #((
./ | .// | /[cC]/* | \
/etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
/usr/ucb/* ) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
elif test $ac_prog = install &&
grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# program-specific install script used by HP pwplus--don't use.
:
else
rm -rf conftest.one conftest.two conftest.dir
echo one > conftest.one
echo two > conftest.two
mkdir conftest.dir
if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
test -s conftest.one && test -s conftest.two &&
test -s conftest.dir/conftest.one &&
test -s conftest.dir/conftest.two
then
ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
break 3
fi
fi
fi
done
done
;;
esac
done
IFS=$as_save_IFS
rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
# As a last resort, use the slow shell script. Don't cache a
# value for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the value is a relative name.
INSTALL=$ac_install_sh
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sin" >&5
$as_echo_n "checking for library containing sin... " >&6; }
if ${ac_cv_search_sin+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sin ();
int
main ()
{
return sin ();
;
return 0;
}
_ACEOF
for ac_lib in '' m; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_sin=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_sin+:} false; then :
break
fi
done
if ${ac_cv_search_sin+:} false; then :
else
ac_cv_search_sin=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sin" >&5
$as_echo "$ac_cv_search_sin" >&6; }
ac_res=$ac_cv_search_sin
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
{ ac_cv_lib_readline_readline=; unset ac_cv_lib_readline_readline;}
for termlib in "" -ltermcap -lncurses -lcurses; do
if test "$ac_cv_lib_readline_readline" != yes ; then
{ ac_cv_lib_readline_readline=; unset ac_cv_lib_readline_readline;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
$as_echo_n "checking for readline in -lreadline... " >&6; }
if ${ac_cv_lib_readline_readline+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline $termlib $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char readline ();
int
main ()
{
return readline ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_readline=yes
else
ac_cv_lib_readline_readline=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
$as_echo "$ac_cv_lib_readline_readline" >&6; }
if test "x$ac_cv_lib_readline_readline" = xyes; then :
LIBS="-lreadline $termlib $LIBS";DEFIS="$DEFIS -DREADLINE"
fi
fi
done
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if ${ac_cv_prog_CPP+:} false; then :
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then :
:
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
if test "x$ac_cv_header_string_h" = xyes; then :
else
DEFIS="$DEFIS -DSTRINGS_H"
fi
ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
if test "x$ac_cv_header_stdlib_h" = xyes; then :
else
DEFIS="$DEFIS -DNO_STDLIB_H"
fi
ac_fn_c_check_func "$LINENO" "strchr" "ac_cv_func_strchr"
if test "x$ac_cv_func_strchr" = xyes; then :
else
DEFIS="$DEFIS -DNO_STRCHR"
fi
ac_fn_c_check_func "$LINENO" "strspn" "ac_cv_func_strspn"
if test "x$ac_cv_func_strspn" = xyes; then :
else
DEFIS="$DEFIS -DNO_STRSPN";STRFUNC="strfunc.$OBJEXT"
fi
ac_fn_c_check_func "$LINENO" "strtok" "ac_cv_func_strtok"
if test "x$ac_cv_func_strtok" = xyes; then :
else
DEFIS="$DEFIS -DNO_STRTOK";STRFUNC="strfunc.$OBJEXT"
fi
ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv"
if test "x$ac_cv_func_setenv" = xyes; then :
else
DEFIS="$DEFIS -DNO_SETENV"
fi
ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale"
if test "x$ac_cv_func_setlocale" = xyes; then :
else
DEFIS="$DEFIS -DNO_SETLOCALE"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale and UTF-8 support" >&5
$as_echo_n "checking for locale and UTF-8 support... " >&6; }
if ${am_cv_utf8+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _XOPEN_SOURCE 600
#include
#include
#include
int
main ()
{
wchar_t *out;char *in;char *res;
res=setlocale(LC_CTYPE,"");res=in;
mbsrtowcs(out, &res, 2, NULL);
wcswidth(out,2);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
am_cv_utf8=yes
else
am_cv_utf8=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_utf8" >&5
$as_echo "$am_cv_utf8" >&6; }
if test $am_cv_utf8 = yes; then
DEFIS="$DEFIS -DSUPPORT_UTF8"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isfinite" >&5
$as_echo_n "checking for isfinite... " >&6; }
if ${am_cv_isfinite+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _XOPEN_SOURCE 600
#include
int
main ()
{
float a;a=1;isfinite(a);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
am_cv_isfinite=yes
else
am_cv_isfinite=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_isfinite" >&5
$as_echo "$am_cv_isfinite" >&6; }
if test $am_cv_isfinite = no; then
DEFIS="$DEFIS -DNO_ISFINITE"
fi
# Check whether --enable-path-search was given.
if test "${enable_path_search+set}" = set; then :
enableval=$enable_path_search; UDAT=""
else
UDAT="$datadir/units/"
fi
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
# `set' does not quote correctly, so add quotes: double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \.
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;; #(
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
if test "x$cache_file" != "x/dev/null"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
if test ! -f "$cache_file" || test -h "$cache_file"; then
cat confcache >"$cache_file"
else
case $cache_file in #(
*/* | ?:*)
mv -f confcache "$cache_file"$$ &&
mv -f "$cache_file"$$ "$cache_file" ;; #(
*)
mv -f confcache "$cache_file" ;;
esac
fi
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
#
# If the first sed substitution is executed (which looks for macros that
# take arguments), then branch to the quote section. Otherwise,
# look for a macro that doesn't take arguments.
ac_script='
:mline
/\\$/{
N
s,\\\n,,
b mline
}
t clear
:clear
s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
t quote
s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
t quote
b any
:quote
s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\[/\\&/g
s/\]/\\&/g
s/\$/$$/g
H
:any
${
g
s/^\n//
s/\n/ /g
p
}
'
DEFS=`sed -n "$ac_script" confdefs.h`
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
as_write_fail=0
cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
export SHELL
_ASEOF
cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
_ASEOF
test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Save the log message, to keep $0 and so on meaningful, and to
# 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.02, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration. Unless the files
and actions are specified as TAGs, all are instantiated by default.
Usage: $0 [OPTION]... [TAG]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
--config print configuration, then exit
-q, --quiet, --silent
do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
Configuration files:
$config_files
Report bugs to .
GNU units home page: .
General help using GNU software: ."
_ACEOF
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.02
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
Copyright (C) 2010 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=?*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
--*=)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--config | --confi | --conf | --con | --co | --c )
$as_echo "$ac_cs_config"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
'') as_fn_error $? "missing file argument" ;;
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h | --help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;
*) as_fn_append ac_config_targets " $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp= ac_tmp=
trap 'exit_status=$?
: "${ac_tmp:=$tmp}"
{ test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
|| as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF
# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
h
s///
s/^/:/
s/[ ]*$/:/
s/:\$(srcdir):/:/g
s/:\${srcdir}:/:/g
s/:@srcdir@:/:/g
s/^:*//
s/:*$//
x
s/\(=[ ]*\).*/\1/
G
s/\n//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
eval set X " :F $CONFIG_FILES "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$ac_tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$ac_tmp/stdin" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
as_dir="$ac_dir"; as_fn_mkdir_p
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
*) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
esac
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_datarootdir_hack='
s&@datadir@&$datadir&g
s&@docdir@&$docdir&g
s&@infodir@&$infodir&g
s&@localedir@&$localedir&g
s&@mandir@&$mandir&g
s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
>$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
"$ac_tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&2;}
rm -f "$ac_tmp/stdin"
case $ac_file in
-) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
*) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
esac \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
esac
done # for ac_tag
as_fn_exit 0
_ACEOF
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || as_fn_exit 1
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
units-2.02/units.h 0000600 0001750 0001750 00000010463 12156460500 013363 0 ustar adrian adrian /*
* units, a program for units conversion
* Copyright (C) 1996, 1997, 1999, 2000, 2001 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* This program was written by Adrian Mariano (adrianm@gnu.org)
*/
#include
#include
/* Apparently popen and pclose require leading _ under windows */
#if defined(_MSC_VER) || defined(__MINGW32__)
# define popen(c,m) _popen(c,m)
# define pclose(p) _pclose(p)
#endif
#ifdef NO_ISFINITE
# if defined _WIN32 && defined _MSC_VER
# define isfinite(x) (!_isnan(x) && _finite(x))
# else
# define isfinite(x) ( -DBL_MAX <= (x) && (x) <= DBL_MAX )
# endif
#endif
#ifdef STRINGS_H
# include
#else
# include
#endif
#ifndef NO_STDLIB_H
# include
#else
char *malloc(), *realloc(), *getenv();
#endif
#ifndef strchr
# ifdef NO_STRCHR
# define strchr(a,b) index((a),(b))
# else
char *strchr();
# endif
#endif /* !strchr */
#ifndef strerror
# define smarterror 0
#else
# define smarterror 1
#endif
char *strtok();
double strtod();
#ifndef __STDC__
# define void int
#endif
#define E_NORMAL 0
#define E_PARSE 1
#define E_PRODOVERFLOW 2
#define E_REDUCE 3
#define E_BADSUM 4
#define E_NOTANUMBER 5
#define E_NOTROOT 6
#define E_UNKNOWNUNIT 7
#define E_FUNC 8 /* If errno is set after calling a function */
#define E_BADFUNCTYPE 9
#define E_BADFUNCARG 10
#define E_NOTINDOMAIN 11
#define E_BADTABLE 12
#define E_NOINVERSE 13
#define E_PARSEMEM 14
#define E_FUNARGDEF 15
#define E_FILE 16
#define E_BADFILE 17
#define E_MEMORY 18
#define E_BADNUM 19
#define E_UNITEND 20
#define WHITE " \t\n"
extern char *errormsg[];
/*
Data type used to store a single unit being operated on.
The numerator and denominator arrays contain lists of units
(strings) which are terminated by a null pointer. The special
string NULLUNIT is used to mark blank units that occur in the
middle of the list.
*/
extern char *NULLUNIT;
#define MAXSUBUNITS 100 /* Size of internal unit reduction buffer */
struct unittype {
char *numerator[MAXSUBUNITS];
char *denominator[MAXSUBUNITS];
double factor;
};
struct functype {
char *param;
char *def;
char *dimen;
double *domain_min, *domain_max;
};
struct pair {
double location, value;
};
struct func {
char *name;
struct functype forward;
struct functype inverse;
struct pair *table;
int tablelen;
char *tableunit;
struct func *next;
int linenumber;
char *file; /* file where defined */
};
struct parseflag {
int oldstar; /* Does '*' have higher precedence than '/' */
int minusminus; /* Does '-' character give subtraction */
};
extern struct parseflag parserflags;
extern struct unittype *parameter_value;
extern char *function_parameter;
void *mymalloc(int bytes,char *mesg);
int hassubscript(const char *str, int length);
void initializeunit(struct unittype *theunit);
void freeunit(struct unittype *theunit);
void unitcopy(struct unittype *dest, struct unittype *src);
int divunit(struct unittype *left, struct unittype *right);
void invertunit(struct unittype *theunit);
int multunit(struct unittype *left, struct unittype *right);
int expunit(struct unittype *theunit, int power);
int addunit(struct unittype *unita, struct unittype *unitb);
int rootunit(struct unittype *inunit,int n);
int unitpower(struct unittype *base, struct unittype *exponent);
char *dupstr(char *str);
int unit2num(struct unittype *input);
struct func *fnlookup(const char *str, int length);
int evalfunc(struct unittype *theunit, struct func *infunc, int inverse);
int parseunit(struct unittype *output, char *input,char **errstr,int *errloc);
units-2.02/units.texinfo 0000600 0001750 0001750 00000323544 12157471367 014635 0 ustar adrian adrian \input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename units.info
@settitle Units: A Unit Conversion Program and Scientific Calculator
@finalout
@setchapternewpage off
@firstparagraphindent none
@set EDITION 2.02
@set VERSION 2.02
@c %**end of header
@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, 2012, 2013 Free Software Foundation, Inc.
@quotation
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.
@c end ifman
@c noman
A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end quotation
@end copying
@c end noman
@defcodeindex op
@syncodeindex op cp
@c noman
@dircategory Science
@direntry
* Units: (units). Units conversion and scientific calculation.
@end direntry
@c end noman
@c man .TH UNITS 1 "7 June 2013"
@c man .SH NAME
@c man units \(em unit conversion and calculation program
@titlepage
@title Units Conversion
@subtitle Edition @value{EDITION} for @command{units} Version @value{VERSION}
@author Adrian Mariano
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@iftex
@headings off
@everyheading Units Conversion @| @| @thispage
@end iftex
@ifnottex
@node Top
@top Units Conversion
@c noman
This manual describes the @command{units} command for units conversion and
how you can use it as a powerful scientific calculator that keeps
track of units.
This is Edition @value{EDITION} of @cite{The Units Conversion Manual}
for @command{units} Version @value{VERSION}.
@c end noman
@end ifnottex
@menu
* Overview:: What does @command{units} do?
* Interactive Use:: How to use @command{units}.
* Command Line Use:: How to use @command{units} noninteractively.
* Unit Definitions:: What units are defined?
* Unit Expressions:: Forming compound units.
* Nonlinear Conversions:: Nonlinear unit conversions (e.g., temperature)
* Unit Lists:: Conversion to sums of units (e.g., feet and inches)
* Invoking Units:: Command line options.
* 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.
* Environment Vars:: Environment variables used by @command{units}.
* Unicode Support:: Support for Unicode (UTF-8).
* Readline Support:: Unit name completion and editing.
* Currency:: Updating currency exchange rates.
* Database Syntax:: Summary of database command syntax.
* GNU Free Documentation License:: License.
* Index:: General index.
@end menu
@c noman
@node Overview
@chapter Overview of @command{units}
@c end noman
@c ifman
@ignore
@c '.PP' for consistency with spacing before other sections.
.PP
.SH SYNOPSIS
.PP
.CW units
.RI [ options ]
.RI [ from-unit
.RI [ to-unit ]]
.PP
.SH DESCRIPTION
@end ignore
@c end ifman
The @command{units} program converts quantities expressed in various
systems of measurement to their equivalents in other systems of
measurement. Like many similar programs, it can handle multiplicative
scale changes. It can also handle nonlinear conversions such as
Fahrenheit to
@c man Celsius.
@c noman
Celsius.@footnote{But Fahrenheit to
Celsius is linear, you insist. Not so. A transformation @math{T} is linear if
@math{T(x+y)=T(x)+T(y)} and this fails for @math{T(x)=ax+b}. This transformation is
affine, but not linear. }
@xref{Temperature Conversions}.
@c end noman
@c man See the examples below.
The program can also perform conversions from and to sums of
units, such as converting between meters and feet plus inches.
Beyond simple unit conversions, @command{units} can be used as a
general-purpose scientific calculator that keeps track of units in its
calculations. You can form arbitrary complex mathematical expressions
of dimensions including sums, products, quotients, powers, and even roots
of dimensions. Thus you can ensure accuracy and dimensional consistency
when working with long expressions that involve many different units
that may combine in complex ways.
The units are defined in an external data file. You can use the
extensive data file that comes with this program, or you can
provide your own data file to suit your needs. You can also use your
own data file to supplement the standard data file.
Basic operation is simple: you enter the units that you want to convert
@emph{from} and the units that you want to convert @emph{to}.
You can use the program interactively with prompts, or you can use it
from the command line.
You can change the default behavior of @command{units} with various
options given on the command line. @xref{Invoking Units}, for a
description of the available options.
@node Interactive Use
@chapter Interacting with @command{units}
@cindex interactive use
To invoke units for interactive use, type @kbd{units} at your shell
prompt. The program will print something like this:
@example
@group
Currency exchange rates from 04/23/12
2516 units, 85 prefixes, 65 nonlinear units
You have:
@end group
@end example
@noindent
At the @samp{You have:} prompt, type the quantity and units that
you are converting @emph{from}. For example, if you want to convert ten
meters to feet, type @kbd{10 meters}. Next, @command{units} will print
@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 the tab key can be
used to complete unit names. @xref{Readline Support}, for more
information about @command{readline}. To quit the program press
Ctrl-C or Ctrl-D under Unix. Under Windows press Ctrl-Z.
The answer will be displayed in two ways. The first line of output,
which is marked with a @samp{*} to indicate multiplication,
gives the result of the conversion you have asked for. The second line
of output, which is marked with a @samp{/} to indicate division, gives
the inverse of the conversion factor. If you convert 10 meters to feet,
@command{units} will print
@example
@group
* 32.808399
/ 0.03048
@end group
@end example
@noindent
which tells you that 10 meters equals about 32.8 feet.
The second number gives the conversion in the opposite direction.
In this case, it tells you that 1 foot is equal to about
0.03 dekameters since the dekameter is 10 meters.
It also tells you that 1/32.8 is about 0.03.
The @command{units} program prints the inverse because sometimes it is a
more convenient number. In the example above, for example, the inverse
value is an exact conversion: a foot is exactly 0.03048 dekameters.
But the number given the other direction is inexact.
If you convert grains to pounds, you will see the following:
@example
@group
You have: grains
You want: pounds
* 0.00014285714
/ 7000
@end group
@end example
@noindent
From the second line of the output you can immediately see that a grain
is equal to a seven thousandth of a pound. This is not so obvious from
the first line of the output.
If you find the output format confusing, try using the
@option{--verbose} option:
@cindex verbose output
@example
@group
You have: grain
You want: aeginamina
grain = 0.00010416667 aeginamina
grain = (1 / 9600) aeginamina
@end group
@end example
@noindent
If you request a conversion between units that measure reciprocal
dimensions, then @command{units} will display the conversion results with an extra
note indicating that reciprocal conversion has been done:
@cindex reciprocal conversion
@example
@group
You have: 6 ohms
You want: siemens
reciprocal conversion
* 0.16666667
/ 6
@end group
@end example
@noindent
Reciprocal conversion can be suppressed by using the @option{--strict} option.
As usual, use
the @option{--verbose} option to get more comprehensible output:
@cindex verbose output
@cindex strict conversion
@example
@group
You have: tex
You want: typp
reciprocal conversion
1 / tex = 496.05465 typp
1 / tex = (1 / 0.0020159069) typp
You have: 20 mph
You want: sec/mile
reciprocal conversion
1 / 20 mph = 180 sec/mile
1 / 20 mph = (1 / 0.0055555556) sec/mile
@end group
@end example
@noindent
If you enter incompatible unit types, the @command{units} program will
print a message indicating that the units are not conformable and
it will display the reduced form for each unit:
@cindex incompatible units
@cindex non-conformable units
@example
@group
You have: ergs/hour
You want: fathoms kg^2 / day
conformability error
2.7777778e-11 kg m^2 / sec^3
2.1166667e-05 kg^2 m / sec
@end group
@end example
@noindent
If you only want to find the reduced form or definition of a unit,
simply press @key{Enter} at the @samp{You want:} prompt. Here is an example:
@example
@group
You have: jansky
You want:
Definition: fluxunit = 1e-26 W/m^2 Hz = 1e-26 kg / s^2
@end group
@end example
@noindent
The output from @command{units} indicates that the jansky is defined to be
equal to a fluxunit which in turn is defined to be a certain combination
of watts, meters, and hertz. The fully reduced (and in this case
somewhat more cryptic) form appears on the far right.
Some named units are treated as dimensionless in some situations.
These units include the radian and steradian. These units will be
treated as equal to 1 in units conversions. Power is equal to torque
times angular velocity. This conversion can only be performed if the
radian is dimensionless.
@example
@group
You have: (14 ft lbf) (12 radians/sec)
You want: watts
* 227.77742
/ 0.0043902509
@end group
@end example
@noindent
Named dimensionless units are not treated as dimensionless
in other contexts. They cannot be used as exponents
so for example, @samp{meter^radian} is not allowed.
@cindex dimensionless units
@cindex @samp{?} to show conformable units
@cindex conformable units, @samp{?} to show
If you want a list of options you can type @kbd{?} at the
@samp{You want:} prompt. The program will display a list of named
units that are conformable with the unit that you entered at
the @samp{You have:} prompt above. Conformable unit
@emph{combinations} will not appear on this list.
@cindex help
Typing @kbd{help} at either prompt displays a short help message.
You can also type @kbd{help} followed by a unit name. This will
invoke a pager on the units data base at the point where that unit
is defined. You can read the definition and comments that may
give more details or historical information about the unit. (You
can generally quit out of the page by pressing @samp{q}.)
Typing @kbd{search} @var{text} will display a list of all of the units
whose names contain @var{text} as a substring along with their definitions.
This may help in the case where you aren't sure of the right unit name.
@node Command Line Use
@chapter Using @command{units} Non-Interactively
@cindex command-line unit conversion
@cindex non-interactive unit conversion
The @command{units} program can perform units conversions non-interactively
from the command line. To do this, type the command, type the original
unit expression, and type the new units you want. If a units
expression contains non-alphanumeric characters, you may need to protect
it from interpretation by the shell using single or double quote
characters.
If you type
@example
units "2 liters" quarts
@end example
@noindent
then @command{units} will print
@example
@group
* 2.1133764
/ 0.47317647
@end group
@end example
@noindent
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 @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
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
the definition of the specified unit. It will return failure if the
unit is not defined and success if the unit is defined.
@node Unit Definitions
@chapter Unit Definitions
@cindex unit definitions
The conversion information is read from a units data file that
is called @file{definitions.units} and is usually located in
the @file{/usr/share/units} directory.
If you invoke @command{units} with the @option{-V} option, it will print
the location of this file.
The default
file includes definitions for all familiar units, abbreviations and
metric prefixes. It also includes many obscure or archaic units.
Many constants of nature are defined, including these:
@example
pi @r{ratio of circumference to diameter}
c @r{speed of light}
e @r{charge on an electron}
force @r{acceleration of gravity}
mole @r{Avogadro's number}
water @r{pressure per unit height of water}
Hg @r{pressure per unit height of mercury}
au @r{astronomical unit}
k @r{Boltzman's constant}
mu0 @r{permeability of vacuum}
epsilon0 @r{permittivity of vacuum}
G @r{Gravitational constant}
mach @r{speed of sound}
@end example
@noindent
The standard data file includes atomic masses for all of the elements
and numerous other constants. Also included are the densities of
various ingredients used in baking so that @samp{2 cups flour_sifted}
can be converted to @samp{grams}. This is not an exhaustive list.
Consult the units data file to see the complete list, or to see the
definitions that are used.
@cindex measure, Imperial
@cindex Imperial measure
@cindex British Imperial measure
The @samp{pound} is a unit of mass. To get force, multiply by the
force conversion unit @samp{force} or use the shorthand @samp{lbf}.
(Note that @samp{g} is already taken as the standard abbreviation for
the gram.) The unit @samp{ounce} is also a unit of mass. The fluid
ounce is @samp{fluidounce} or @samp{floz}. British capacity units that
differ from their US counterparts, such as the British Imperial gallon,
are prefixed with @samp{br}. Currency is prefixed with its country
name: @samp{belgiumfranc}, @samp{britainpound}.
@cindex units, lookup method
When searching for a unit, if the specified string does not appear
exactly as a unit name, then the @command{units} program will try to
remove a trailing @samp{s}, @samp{es}. Next units will replace a
trailing @samp{ies} with @samp{y}. If that fails,
@command{units} will check for a prefix. The database includes all
of the standard metric prefixes. Only one prefix is permitted per
unit, so @samp{micromicrofarad} will fail. However, prefixes can
appear alone with no unit following them, so
@samp{micro*microfarad} will work, as will @samp{micro microfarad}.
@cindex prefixes
To find out which units and prefixes are available, read the standard
units data file, which is extensively annotated.
@comment @node English Customary Units
@section English Customary Units
@cindex volume measure, English customary
English customary units differ in various ways in different
regions. In Britain a complex system of volume measurements featured
different gallons for different materials such as a wine gallon and
ale gallon that different by twenty percent. This complexity was
swept away in 1824 by a reform that created an entirely new gallon,
the British Imperial gallon defined as the volume occupied by ten
pounds of water. Meanwhile in the USA the gallon is derived from the
1707 Winchester wine gallon, which is 231 cubic inches. These gallons
differ by about twenty percent. By default if @command{units} runs in
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
environment variable @env{UNITS_ENGLISH} to either @samp{US} or
@samp{GB} to set the desired definitions independent of the locale.
@cindex length measure, English customary
@cindex length measure, UK
@cindex survey measure, US
@cindex US survey measure
@cindex survey mile, US
@cindex US survey foot
@cindex State Plane Coordinate System, US
@cindex US State Plane Coordinate System
@cindex survey foot, US
@cindex US survey mile
@cindex mile, international
@cindex international mile
@cindex yard, international
@cindex international yard
Before 1959, the value of a yard (and other units of measure defined in
terms of it) differed slightly among English-speaking countries. In
1959, Australia, Canada, New Zealand, the United Kingdom, the United
States, and South Africa adopted the Canadian value of 1@tie{}yard =
0.9144@tie{}m (exactly), which was approximately halfway between the
values used by the UK and the US; it had the additional advantage of
making 1@tie{}inch = 2.54@tie{}cm (exactly). This new standard was
termed the @dfn{International Yard}. Australia, Canada, and the UK
then defined all customary lengths in terms of the International Yard
(Australia did not define the furlong or rod); because many US land
surveys were in terms of the pre-1959 units, the US continued to define
customary surveyors' units (furlong, chain, rod, and link) in terms of
the previous value for the foot, which was termed the
@dfn{US survey foot}. The US defined a @dfn{US survey mile} as 5280 US
survey feet, and defined a @dfn{statute mile} as a US survey mile. The
US values for these units differ from the international values by about
2@tie{}ppm.
The @command{units} program uses the international values for these
units; the US values can be obtained by using either the @samp{US} or
the @samp{survey} prefix. In either case, the simple familiar
relationships among the units are maintained, e.g., 1 @samp{furlong} =
660 @samp{ft}, and 1 @samp{USfurlong} = 660 @samp{USft}, though the
metric equivalents differ slightly between the two cases.
The @samp{US} prefix or the @samp{survey} prefix can also be used to
obtain the US survey mile and the value of the US yard prior to 1959,
e.g., @samp{USmile} or @samp{surveymile} (but @emph{not}
@samp{USsurveymile}). To get the US value of the statute mile, use
either @samp{USstatutemile} or @samp{USmile}.
Except for distances that extend over hundreds of miles (such as in the
US State Plane Coordinate System), the differences in the miles are
usually insignificant:
@example
@group
You have: 100 surveymile - 100 mile
You want: inch
* 12.672025
/ 0.078913984
@end group
@end example
@noindent
The pre-1959 UK values for these units can be obtained with the prefix
@samp{UK}.
In the US, the acre is officially defined in terms of the US survey
foot, but @command{units} uses a definition based on the international
foot. If you want the official US acre use @samp{USacre} and
similarly use @samp{USacrefoot} for the official US version of that
unit. The difference between these units is about 4 parts per million.
@node Unit Expressions
@chapter Unit Expressions
@cindex unit expressions
@menu
* Operators:: The usual arithmetic operators, with a few extras
* Sums and Differences of Units:: Adding and subtracting units
* Numbers as Units:: A number is a dimensionless unit
* Built-in Functions:: Trigonometric functions, logarithms, roots
* Complicated Unit Expressions:: A complicated example
* Backwards Compatibility:: Alternate behavior for @samp{*} and @samp{-}
@end menu
@node Operators
@section Operators
@cindex operators
You can enter more complicated units by combining units
with operations
such as powers, multiplication, division, addition, subtraction, and
parentheses for grouping.
You can use the customary symbols for these operators when
@command{units} is invoked with its default options. Additionally,
@command{units} supports some extensions, including high
priority multiplication using a
space, and a high priority numerical
division operator (@samp{|}) that can simplify
some expressions.
Powers of units can be specified using the @samp{^} character as shown in
the following example, or by simple concatenation of a unit and its
exponent: @samp{cm3} is equivalent to @samp{cm^3};
if the exponent is more than one digit, the @samp{^} is required.
An
exponent like @samp{2^3^2} is evaluated right to left as usual.
The @samp{^}
operator has the second highest precedence. You can also use @samp{**} as
an exponent operator.
@cindex powers
@cindex exponent operator
@cindex operator, caret (@samp{^})
@cindex operator, (@samp{**})
@cindex @samp{**} operator
@cindex parentheses
@example
@group
You have: cm^3
You want: gallons
* 0.00026417205
/ 3785.4118
You have: arabicfoot * arabictradepound * force
You want: ft lbf
* 0.7296
/ 1.370614
@end group
@end example
@noindent
You multiply units using a space or an asterisk (@samp{*}).
The example above shows both forms. You can divide units using the
slash (@samp{/}) or with @samp{per}.
@cindex products of units
@cindex quotients of units
@cindex units quotients
@cindex multiplication of units
@cindex division of units
@cindex operator, @samp{per}
@cindex @samp{per} operator
@cindex operator, space
@cindex operator, star (@samp{*})
@cindex star (@samp{*}) operator
@cindex @samp{*} operator
@cindex operator, slash (@samp{/})
@cindex slash (@samp{/}) operator
@cindex operator, solidus (@samp{/})
@cindex solidus (@samp{/}) operator
@example
@group
You have: furlongs per fortnight
You want: m/s
* 0.00016630986
/ 6012.8727
@end group
@end example
@noindent
@cindex operator precedence
@cindex parentheses
@cindex prefixes and exponents
When a unit includes a prefix, exponent operators apply to the
combination, so @samp{centimeter^3} gives cubic centimeters. If you separate
the prefix from the unit with any multiplication operator, such as
@samp{centi meter^3}, then the prefix is treated as a separate unit, so
the exponent does not apply. The second example would be a hundredth
of a cubic meter, not a centimeter.
Multiplication using a space has a higher precedence
than division using a slash and is evaluated left to right;
in effect, the first @samp{/} character marks the beginning of the
denominator of a unit expression.
This makes it simple to
enter a quotient with several terms in the denominator: @samp{W / m^2 Hz}.
If you multiply with @samp{*} then you must group the terms in the
denominator with parentheses: @samp{W / (m^2 * Hz)}.
The higher precedence of the space operator may not always be advantageous.
For example, @samp{m/s s/day} is equivalent to
@samp{m / s s day} and has dimensions of length per time cubed.
Similarly, @samp{1/2 meter} refers to a unit of reciprocal length
equivalent to 0.5/meter, perhaps not what you would intend if
you entered that expression.
The @samp{*} operator is convenient for multiplying a sequence of quotients.
With the @samp{*} operator, the example above becomes @samp{m/s * s/day}, which is
equivalent to @samp{m/day}. Similarly, you could write
@samp{1/2 * meter} to get half a meter.
Alternatively, parentheses can be used for grouping: you could write
@samp{(1/2) meter} to get half a meter.
@xref{Complicated Unit Expressions}, for an illustration of the various
options.
The @command{units} program supports another option for numerical fractions.
You can indicate division of @emph{numbers} with the vertical bar
(@samp{|}), so if you wanted half a meter you could write
@samp{1|2 meter}. This operator has the highest precedence, so you can
write the square root of two thirds @samp{2|3^1|2}.
You cannot use the vertical bar to indicate division of non-numerical
units (e.g., @samp{m|s} results in an error message).
@cindex fractions, numerical
@cindex numerical fractions
@cindex division of numbers
@cindex operator, vertical bar (@samp{|})
@cindex vertical bar (@samp{|}) operator
@cindex @samp{|} operator
@example
@group
You have: 1|2 inch
You want: cm
* 1.27
/ 0.78740157
@end group
@end example
@cindex parentheses
@noindent
You can use parentheses for grouping:
@example
@group
You have: (1/2) kg / (kg/meter)
You want: league
* 0.00010356166
/ 9656.0833
@end group
@end example
@node Sums and Differences of Units
@section Sums and Differences of Units
@cindex sums and differences of units
@cindex units, sums and differences
@cindex operator, plus (@samp{+})
@cindex plus (@samp{+}) operator
@cindex @samp{+} operator
@cindex operator, minus (@samp{-})
@cindex minus (@samp{-}) operator, subtraction
@cindex operator, hyphen (@samp{-}) as subtraction
@cindex @samp{-} as subtraction operator
@noindent
You may sometimes want to add values of
different units that are outside the SI.
You may also wish to use @command{units} as a
calculator that keeps track of units. Sums of conformable units are written with
the @samp{+} character, and differences with the @samp{-} character.
@cindex sums of units
@cindex addition of units
@cindex subtraction of units
@cindex differences of units
@example
@group
You have: 2 hours + 23 minutes + 32 seconds
You want: seconds
* 8612
/ 0.00011611705
@end group
@group
You have: 12 ft + 3 in
You want: cm
* 373.38
/ 0.0026782366
@end group
@group
You have: 2 btu + 450 ft lbf
You want: btu
* 2.5782804
/ 0.38785542
@end group
@end example
@noindent
The expressions that are added or subtracted must reduce to identical
expressions in primitive units, or an error message will be displayed:
@example
@group
You have: 12 printerspoint - 4 heredium
^
Illegal sum of non-conformable units
@end group
@end example
@cindex parentheses
@noindent
As usual, the precedence for @samp{+} and @samp{-} is lower than that of
the other operators.
A fractional quantity such as 2@tie{}1/2 cups can be given as
@samp{(2+1|2) cups}; the parentheses are necessary because
multiplication has higher precedence than addition. If you omit the
parentheses, @command{units} attempts to add @samp{2} and
@samp{1|2 cups}, and you get an error message:
@example
@group
You have: 2+1|2 cups
^
Illegal sum or difference of non-conformable units
@end group
@end example
@noindent
The expression could also be correctly written as @samp{(2+1/2) cups}. If you write @samp{2 1|2 cups} the space is interpreted as @emph{multiplication} so the result is the same as @samp{1 cup}.
The @samp{+} and @samp{-} characters sometimes appears in exponents like
@samp{3.43e+8}. This leads to an ambiguity in an expression like
@samp{3e+2 yC}. The unit @samp{e} is a small unit of charge, so this
can be regarded as equivalent to @samp{(3e+2) yC} or @samp{(3 e)+(2 yC)}.
This ambiguity is resolved by always interpreting @samp{+} and @samp{-} as part
of an exponent if possible.
@node Numbers as Units
@section Numbers as Units
@cindex numbers as units
For @command{units}, numbers are just another kind of unit. They can
appear as many times as you like and in any order in a unit expression.
For example, to find the volume of a box that is 2 ft by 3 ft by 12 ft
in steres, you could do the following:
@example
@group
You have: 2 ft 3 ft 12 ft
You want: stere
* 2.038813
/ 0.49048148
You have: $ 5 / yard
You want: cents / inch
* 13.888889
/ 0.072
@end group
@end example
@noindent
And the second example shows how the dollar sign in the units conversion
can precede the five. Be careful: @command{units} will interpret
@samp{$5} with no space as equivalent to @samp{dollar^5}.
@node Built-in Functions
@section Built-in Functions
@cindex functions, built in
Several built-in functions are provided: @samp{sin}, @samp{cos},
@samp{tan}, @samp{ln}, @samp{log}, @samp{log2}, @samp{exp}, @samp{acos},
@samp{atan} and @samp{asin}. The @samp{sin}, @samp{cos}, and @samp{tan}
functions require either a dimensionless argument or an argument with
dimensions of angle.
@example
@group
You have: sin(30 degrees)
You want:
Definition: 0.5
You have: sin(pi/2)
You want:
Definition: 1
You have: sin(3 kg)
^
Unit not dimensionless
@end group
@end example
@noindent
The other functions on the list require dimensionless arguments. The
inverse trigonometric functions return arguments with dimensions of
angle.
@cindex roots
@cindex square roots
If you wish to take roots of units, you may use the @samp{sqrt} or
@samp{cuberoot} functions. These functions require that the argument
have the appropriate root. You can obtain higher roots by using
fractional exponents:
@example
@group
You have: sqrt(acre)
You want: feet
* 208.71074
/ 0.0047913202
You have: (400 W/m^2 / stefanboltzmann)^(1/4)
You have:
Definition: 289.80882 K
You have: cuberoot(hectare)
^
Unit not a root
@end group
@end example
@node Complicated Unit Expressions
@section Complicated Unit Expressions
@cindex unit expressions, complicated
@noindent
The @command{units} program is especially helpful in ensuring accuracy
and dimensional consistency when converting lengthy unit expressions.
@c noman
@cindex Darcy--Weisbach equation
For example, one form of the Darcy--Weisbach fluid-flow equation is
@tex
$$
@Delta P = {8 @over @pi^2} @rho fL { Q^2 @over d^5}
$$
@end tex
@ifnottex
@example
Delta P = (8/pi^2) rho f L (Q^2 / d^5)
@end example
@end ifnottex
@noindent
where @math{ \Delta P} is the pressure drop, @math{\rho} is the mass density,
@math{f} is the (dimensionless) friction factor, @math{L} is the length
of the pipe, @math{Q} is the volumetric flow rate, and @math{d}
is the pipe diameter.
It might be desired to have the equation in the form
@tex
$$
@Delta P = A_1 @rho fL {Q^2 @over d^5}
$$
@end tex
@ifnottex
@example
Delta P = A1 rho f L (Q^2 / d^5)
@end example
@end ifnottex
@c end noman
@c -----------------------------------
@c nroff--assume neqn is not available
@c -----------------------------------
@c man .if t .ig ++
@c man For example, one form of the Darcy-Weisbach fluid-flow equation is
@c man .RS 5n
@c man .PP
@c man Delta \fIP\fP = (8 / pi)^2 (rho \fIfLQ\fP^2) / \fId\fP^5,
@c man .RE
@c man .PP
@c man where Delta \fIP\fP is the pressure drop, rho is the mass density,
@c man \fIf\fP is the (dimensionless) friction factor, \fIL\fP is the length
@c man of the pipe, \fIQ\fP is the volumetric flow rate, and \fId\fP
@c man is the pipe diameter.
@c man It might be desired to have the equation in the form
@c man .RS 5n
@c man .PP
@c man Delta \fIP\fP = A1 rho \fIfLQ\fP^2 / \fId\fP^5
@c man .RE
@c man .PP
@c man .++
@c -----
@c troff
@c -----
@c man .if n .ig ++
@c man .EQ
@c man delim $$
@c man .EN
@c dont assume en dash is available
@c man For example, one form of the Darcy\-Weisbach fluid-flow equation is
@c man .RS 5n
@c man .PP
@c man .EQ
@c man DELTA P = 8 over pi sup 2 rho fL Q sup 2 over d sup 5 ,
@c man .EN
@c man .RE
@c man .PP
@c man where $DELTA P$ is the pressure drop, $rho$ is the mass density,
@c man $f$ is the (dimensionless) friction factor, $L$ is the length
@c man of the pipe, $Q$ is the volumetric flow rate, and $d$
@c man is the pipe diameter.
@c man It might be desired to have the equation in the form
@c man .RS 5n
@c man .PP
@c man .EQ
@c man DELTA P = A sub 1 rho fL Q sup 2 over d sup 5
@c man .EN
@c man .RE
@c man .PP
@c man .EQ
@c man delim off
@c man .EN
@c man .++
@c
@noindent
that accepted the user's normal units; for typical units used in the US,
the required conversion could be something like
@example
@group
You have: (8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)
You want: psi
* 43.533969
/ 0.022970568
@end group
@end example
@cindex parentheses
@noindent
The parentheses allow individual terms in the expression to be entered naturally,
as they might be read from the formula. Alternatively, the
multiplication could be done with the @samp{*} rather than a space;
then parentheses are needed only around @samp{ft^3/s} because of its
exponent:
@example
@group
You have: 8/pi^2 * lbm/ft^3 * ft * (ft^3/s)^2 /in^5
You want: psi
* 43.533969
/ 0.022970568
@end group
@end example
@noindent
Without parentheses, and using spaces for multiplication, the previous
conversion would need to be entered as
@example
@group
You have: 8 lb ft ft^3 ft^3 / pi^2 ft^3 s^2 in^5
You want: psi
* 43.533969
/ 0.022970568
@end group
@end example
@node Backwards Compatibility
@section Backwards Compatibility: @samp{*} and @samp{-}
@cindex backwards compatibility
@cindex compatibility
@cindex compatibility with earlier versions
The original @command{units} assigned multiplication a higher
precedence than division using the slash. This differs from the
usual precedence rules, which give multiplication and division equal
precedence, and can be confusing for people who think
of units as a calculator.
The star operator (@samp{*}) included in this @command{units} program
has, by default, the same precedence as division,
and hence follows the usual precedence rules. For backwards
compatibility you can invoke @command{units}
with the @option{--oldstar}
option. Then @samp{*} has a higher precedence than
division, and the same precedence as multiplication using the space.
@cindex @samp{-} as multiplication operator
@cindex operator, hyphen (@samp{-}) as multiplication
@cindex multiplication, hyphen
@cindex hyphen as multiplication operator
Historically, the hyphen (@samp{-}) has been used in technical
publications to indicate products of units, and the original
@command{units} program treated it as a multiplication operator.
Because @command{units} provides
several other ways to obtain unit products, and because @samp{-} is a
subtraction operator in general algebraic expressions, @command{units}
treats the binary @samp{-} as a subtraction operator by default.
For backwards compatibility use the @option{--product} option, which
causes @command{units} to treat the binary @samp{-} operator as a
product operator. When @samp{-} is a multiplication operator
it has the same precedence as multiplication with a space, giving it a
higher precedence than division.
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
degrees minus 12 minutes by entering @samp{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.
@cindex defining units with `-'
@node Nonlinear Conversions
@chapter Nonlinear Unit Conversions
@cindex nonlinear unit conversions
Nonlinear units are represented using functional notation. They make
possible nonlinear unit conversions such as temperature.
@menu
* Temperature Conversions:: Conversion between temperature scales
* Other Nonlinear Units:: Ring size, wire gauge, abrasive grit size
@end menu
@node Temperature Conversions
@section Temperature Conversions
@cindex temperature conversions
Conversions between temperatures are different from linear conversions
between temperature @emph{increments}---see the example below. The
absolute temperature conversions are handled by units starting with
@samp{temp}, and you must use functional notation.
The temperature-increment conversions are done using units starting
with @samp{deg} and they do not require functional notation.
@example
@group
You have: tempF(45)
You want: tempC
7.2222222
You have: 45 degF
You want: degC
* 25
/ 0.04
@end group
@end example
@noindent
Think of @samp{tempF(@var{x})} not as a function but as a notation that
indicates that @var{x} should have units of @samp{tempF} attached to
it. @xref{Defining Nonlinear Units}. The first conversion shows that if it's 45
degrees Fahrenheit outside, it's 7.2 degrees Celsius. The second
conversion indicates that a change of 45 degrees Fahrenheit corresponds
to a change of 25 degrees Celsius. The conversion from
@samp{tempF(@var{x})} is to absolute temperature, so that
@example
@group
You have: tempF(45)
You want: degR
* 504.67
/ 0.0019814929
@end group
@end example
@noindent
gives the same result as
@example
@group
You have: tempF(45)
You want: tempR
* 504.67
/ 0.0019814929
@end group
@end example
@noindent
But if you convert @samp{tempF(@var{x})} to @samp{degC}, the output is
probably not what you expect:
@example
@group
You have: tempF(45)
You want: degC
* 280.37222
/ 0.0035666871
@end group
@end example
@noindent
The result is the temperature in K, because @samp{degC} is defined as
@samp{K}, the Kelvin. For consistent results, use the @samp{temp@var{X}} units
when converting to a temperature rather than converting a temperature
increment.
@node Other Nonlinear Units
@section Other Nonlinear Units
@cindex nonlinear units, other
Some other examples of nonlinear units are numerous different ring
sizes and wire gauges, the grit sizes used for abrasives, the decibel
scale, shoe size, scales for the density of sugar (e.g. baume).
The standard data file also supplies units for computing the area of a
circle and the volume of a sphere. See the standard units data file
for more details.
Wire gauges
with multiple zeroes are signified using negative numbers where two
zeroes is @samp{-1}. Alternatively, you can use the synonyms @samp{g00},
@samp{g000}, and so on that are defined in the standard units data file.
@cindex wire gauge
@example
@group
You have: wiregauge(11)
You want: inches
* 0.090742002
/ 11.020255
You have: brwiregauge(g00)
You want: inches
* 0.348
/ 2.8735632
You have: 1 mm
You want: wiregauge
18.201919
You have: grit_P(600)
You want: grit_ansicoated
342.76923
@end group
@end example
@noindent
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 USA standard.
@cindex abrasive grit size
You can compute the area of a circle using the nonlinear unit,
@samp{circlearea}. You can also do this using the circularinch or
circleinch. The next example shows two ways to compute the area of a
circle with a five inch radius and one way to compute the volume of a
sphere with a radius of one meter.
@cindex circle, area of
@cindex sphere, volume of
@example
@group
You have: circlearea(5 in)
You want: in2
* 78.539816
/ 0.012732395
You have: 10^2 circleinch
You want: in2
* 78.539816
/ 0.012732395
You have: spherevol(meter)
You want: ft3
* 147.92573
/ 0.0067601492
@end group
@end example
@node Unit Lists
@chapter Unit Lists: Conversion to Sums of Units
@cindex sums of units
@cindex unit lists
@cindex units, sums of
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 @emph{from} sums of units was described in
@ref{Sums and Differences of Units}, and is a simple matter of adding
the units with the @samp{+} sign:
@example
@group
You have: 12 ft + 3 in + 3|8 in
You want: ft
* 12.28125
/ 0.081424936
@end group
@end example
@noindent
Although you can similarly write a sum of units to convert @emph{to},
the result will not be the conversion to the units in the sum, but
rather the conversion to the particular sum that you have entered:
@example
@group
You have: 12.28125 ft
You want: ft + in + 1|8 in
* 11.228571
/ 0.089058524
@end group
@end example
@noindent
The unit expression given at the @samp{You want:} prompt is equivalent
to asking for conversion to multiples of @samp{1 ft + 1 in + 1|8 in},
which is 1.09375 ft, so the conversion in the previous example is
equivalent to
@example
@group
You have: 12.28125 ft
You want: 1.09375 ft
* 11.228571
/ 0.089058524
@end group
@end example
@noindent
In converting to a sum of units like miles, feet and inches, you
typically want the largest integral value for the first unit, followed
by the largest integral value for the next, and the remainder converted
to the last unit.
You can do this conversion easily with @command{units} using a special
syntax for lists of units. You must list the desired units in order
from largest to smallest, separated by the semicolon (@samp{;})
character:
@example
@group
You have: 12.28125 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3|8 in
@end group
@end example
@noindent
The conversion always gives integer coefficients on the units in the
list, except possibly the last unit when the conversion is not exact:
@example
@group
You have: 12.28126 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3.00096 * 1|8 in
@end group
@end example
@noindent
The order in which you list the units is important:
@example
@group
You have: 3 kg
You want: oz;lb
105 oz + 0.051367866 lb
You have: 3 kg
You want: lb;oz
6 lb + 9.8218858 oz
@end group
@end example
@noindent
Listing ounces before pounds produces a technically correct result,
but not a very useful one. You must list the units in descending
order of size in order to get the most useful result.
Ending a unit list with the separator @samp{;}
has the same effect as repeating the last
unit on the list, so @samp{ft;in;1|8 in;} is equivalent to
@samp{ft;in;1|8 in;1|8 in}. With the example above, this gives
@example
@group
You have: 12.28126 ft
You want: ft;in;1|8 in;
12 ft + 3 in + 3|8 in + 0.00096 * 1|8 in
@end group
@end example
@noindent
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 @option{--round} (@option{-r}) option.
With the previous example, the result is
@example
@group
You have: 12.28126 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3|8 in (rounded down to nearest 1|8 in)
@end group
@end example
@noindent
When you use the @option{-r} option, repeating the last unit on the
list has no effect (e.g., @samp{ft;in;1|8 in;1|8 in} is equivalent to
@samp{ft;in;1|8 in}), and hence neither does ending a list with a
@samp{;}. With a single unit and the @option{-r} option, a terminal @samp{;}
@emph{does} have an effect: it causes @command{units} to treat the
single unit as a list and produce a rounded value for the single unit.
Without the extra @samp{;}, the @option{-r} option has no effect on
single unit conversions. This example shows the output using the
@option{-r} option:
@example
@group
You have: 12.28126 ft
You want: in
* 147.37512
/ 0.0067854058
You have: 12.28126 ft
You want: in;
147 in (rounded down to nearest in)
@end group
@end example
@noindent
Each unit that appears in the list must be conformable with the first
unit on the list, and of course the listed units must also
be conformable with the @emph{You have} unit that you enter.
@example
@group
You have: meter
You want: ft;kg
^
conformability error
ft = 0.3048 m
kg = 1 kg
@end group
@group
You have: meter
You want: lb;oz
conformability error
1 m
0.45359237 kg
@end group
@end example
@noindent
In the first case, @command{units} reports the disagreement between
units appearing on the list. In the second case, @command{units}
reports disagreement between the unit you entered and the desired
conversion. This conformability error is based on the first
unit on the unit list.
Other common candidates for conversion to sums of units are
angles and time:
@example
@group
You have: 23.437754 deg
You want; deg;arcmin;arcsec
23 deg + 26 arcmin + 15.9144 arcsec
@end group
@group
You have: 7.2319 hr
You want: hr;min;sec
7 hr + 13 min + 54.84 sec
@end group
@end example
@noindent
In North America, recipes for cooking typically measure ingredients by
volume, and use units that are not always convenient multiples of each
other. Suppose that you have a recipe for 6 and you wish to make a
portion for 1. If the recipe calls for 2@tie{}1/2 cups of an
ingredient, you might wish to know the measurements in terms of
measuring devices you have available, you could use @command{units} and
enter
@example
@group
You have: (2+1|2) cup / 6
You want: cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp
1|3 cup + 1 tbsp + 1 tsp
@end group
@end example
@noindent
By default, if a unit in a list begins with fraction of the form
1|@var{x} and its multiplier is an integer, the fraction is given as
the product of the multiplier and the numerator; for example,
@example
@group
You have: 12.28125 ft
You want: ft;in;1|8 in;
12 ft + 3 in + 3|8 in
@end group
@end example
@noindent
In many cases, such as the example above, this is what is wanted, but
sometimes it is not. For example, a cooking recipe for 6 might call
for 5@tie{}1/4 cup of an ingredient, but you want a portion for 2, and
your 1-cup measure is not available; you might try
@example
@group
You have: (5+1|4) cup / 3
You want: 1|2 cup;1|3 cup;1|4 cup
3|2 cup + 1|4 cup
@end group
@end example
@noindent
This result might be fine for a baker who has a 1@tie{}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
asked. With the @option{--show-factor} option, the factor will not be
combined with a unity numerator, so that you get
@example
@group
You have: (5+1|4) cup / 3
You want: 1|2 cup;1|3 cup;1|4 cup
3 * 1|2 cup + 1|4 cup
@end group
@end example
@noindent
A user-specified fractional unit with a numerator other than 1 is never
overridden, however---if a unit list specifies @samp{3|4 cup;1|2 cup},
a result equivalent to 1@tie{}1/2 cups will always be shown as
@samp{2 * 3|4 cup} whether or not the @option{--show-factor} option is
given.
Some applications for unit lists may be less obvious. Suppose that you
have a postal scale and wish to ensure that it's accurate at 1@tie{}oz,
but have only metric calibration weights. You might try
@example
@group
You have: 1 oz
You want: 100 g;50 g; 20 g;10 g;5 g;2 g;1 g;
20 g + 5 g + 2 g + 1 g + 0.34952312 * 1 g
@end group
@end example
@noindent
You might then place one each of the 20@tie{}g, 5@tie{}g, 2@tie{}g, and
1@tie{}g weights on the scale and hope that it indicates close to
@example
@group
You have: 20 g + 5 g + 2 g + 1 g
You want: oz;
0.98767093 oz
@end group
@end example
@noindent
Appending @samp{;} to @samp{oz} forces a one-line display that includes
the unit; here the integer part of the result is zero, so it is not
displayed.
A unit list such as
@example
cup;1|2@tie{}cup;1|3@tie{}cup;1|4@tie{}cup;tbsp;tsp;1|2@tie{}tsp;1|4@tie{}tsp
@end example
@noindent
can be tedious to enter. The @command{units} program provides shorthand names
for some common combinations:
@example
hms @r{hours, minutes, seconds}
dms @r{angle: degrees, minutes, seconds}
time @r{years, days, hours, minutes and seconds}
usvol @r{US cooking volume: cups and smaller}
@end example
@noindent
Using these shorthands, or @dfn{unit list aliases},
you can do the following conversions:
@example
@group
You have: anomalisticyear
You want: time
1 year + 25 min + 3.4653216 sec
You have: 1|6 cup
You want: usvol
2 tbsp + 2 tsp
@end group
@end example
@noindent
You cannot combine a unit list alias with other units: it must appear
alone at the @samp{You want:} prompt.
You can display the definition of a unit list alias by entering it at
the @samp{You have:} prompt:
@example
@group
You have: dms
Definition: unit list, deg;arcmin;arcsec
@end group
@end example
@noindent
When you specify compact output with @option{--compact},
@option{--terse} or @option{-t} and perform conversion to a unit list,
@command{units} lists the conversion factors for each unit in the
list, separated by semicolons.
@example
@group
You have: year
You want: day;min;sec
365;348;45.974678
@end group
@end example
@noindent
Unlike the case of regular
output, zeros @emph{are} included in this output list:
@example
@group
You have: liter
You want: cup;1|2 cup;1|4 cup;tbsp
4;0;0;3.6280454
@end group
@end example
@node Invoking Units
@chapter Invoking @command{units}
@cindex invoking units
@cindex command-line options
You invoke @command{units} like this:
@example
units [@var{options}] [@var{from-unit} [@var{to-unit}]]
@end example
@noindent
If the @var{from-unit} and @var{to-unit} are omitted, the program
will use interactive prompts to determine which conversions to perform.
@xref{Interactive Use}.
If both @var{from-unit} and @var{to-unit} are given, @command{units} will
print the result of that single conversion and then exit.
If only @var{from-unit} appears on the command line, @command{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. @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
given in either short form (a single @samp{-} followed by a single
character)
or long form (@samp{--} 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, @samp{--out@tie{}%f} works, but
@samp{--o@tie{}%f} fails because @command{units} has other long options
beginning with @samp{o}. However, @samp{--q} works because
@samp{--quiet} is the only long option beginning with @samp{q}.
Some options require
arguments to specify a value (e.g., @samp{-d@tie{}12} or
@samp{--digits@tie{}12}). Short-form options that do not take
arguments may be concatenated (e.g., @samp{-erS} is equivalent to
@samp{-e@tie{}-r@tie{}-S}); the last option in such a list may be one
that takes an argument (e.g., @samp{-ed@tie{}12}). With short-form
options, the space between an option and its argument is optional (e.g.,
@samp{-d12} is equivalent to @samp{-d@tie{}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., @option{--output-format} and
@option{--exponential}) are given in combination, behavior is controlled
by the last option given. For example, @samp{-o%.12f@tie{}-e} gives
exponential format with the default eight significant digits).
The following options are available:
@table @env
@item -c
@itemx --check
@opindex -c @r{(option for} @command{units}@r{)}
@opindex --check @r{(option for} @command{units}@r{)}
Check that all units and prefixes defined in the units data file reduce
to primitive units. Print a list of all units that
cannot be reduced. Also display some other diagnostics about
suspicious definitions in the units data file. Only definitions active
in the current locale are checked. You should always run
@command{units} with this option after modifying a units data file.
@item --check-verbose
@itemx --verbose-check
@opindex --check-verbose @r{(option for} @command{units}@r{)}
@opindex --verbose-check @r{(option for} @command{units}@r{)}
Like the @option{--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 @command{units} hangs, then the last unit to be printed has a bad
definition. Only definitions active in the current locale are checked.
@item -d @var{ndigits}
@itemx --digits @var{ndigits}
@opindex -d @r{(option for} @command{units}@r{)}
@opindex --digits @r{(option for} @command{units}@r{)}
Set the number of significant digits in the output to the value
specified (which must be greater than zero). For example,
@samp{-d@tie{}12} sets the number of significant digits to 12.
With exponential output @command{units} displays one digit to the left
of the decimal
@c man point
@c noman
point@footnote{This document refers to ``decimal point,'' but strictly,
the @dfn{radix} separates the integer and fractional parts of a
floating-point number; in English-speaking countries, the radix is a
point (@samp{.}), but in most other countries it is a comma (@samp{,}).}
@c end noman
and eleven digits to the right of the decimal point.
On most systems, the maximum number of internally meaningful digits is
15; if you specify a greater number than your system's maximum, @command{units}
will print a warning and set the number to the largest meaningful
value. To directly set the maximum value, give an argument
of @code{max} (e.g., @samp{-d@tie{}max}). Be aware, of course, that
``significant'' here refers only to the @emph{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
@option{--digits} option conflicts with the @option{--output-format}
option.
@item -e
@itemx --exponential
@opindex -e @r{(option for} @command{units}@r{)}
@opindex --exponential @r{(option for} @command{units}@r{)}
Set the numeric output format to exponential (i.e., scientific
notation), like that used in the Unix @command{units} program.
The default precision is eight significant digits (seven digits to the
right of the decimal point); this can be changed with the
@option{--digits} option. The @option{--exponential}
option conflicts with the @option{--output-format} option.
@item -o @var{format}
@itemx --output-format @var{format}
@opindex -o @r{(option for} @command{units}@r{)}
@opindex --output-format @r{(option for} @command{units}@r{)}
This option affords complete control over the numeric output format
using the specified @var{format}. The format is a single floating
point numeric format for the @code{printf()} function in the
C programming language. All compilers support the format types @samp{g}
and @samp{G} to specify significant digits, @samp{e} and @samp{E} for
scientific notation, and @samp{f} for fixed-point decimal.
The ISO C99 standard introduced the @samp{F} type for fixed-point
decimal and the @samp{a} and @samp{A} types for hexadecimal
floating point; these types are allowed with compilers that support
them. The default format is @samp{%.8g}; for greater precision, you
could specify @samp{-o@tie{}%.15g}. @xref{Numeric Output Format}, and
the documentation for @code{printf()} for more detailed descriptions of the
format specification. The @option{--output-format} option affords the
greatest control of the output appearance, but requires at least
rudimentary knowledge of the @code{printf()} format syntax. If you
don't want to bother with the @code{printf()} syntax, you can specify
greater precision more simply with the @option{--digits} option or
select exponential format with @option{--exponential}. The
@option{--output-format} option is incompatible with the
@option{--exponential} and @option{--digits} options.
@item -f @var{filename}
@itemx --file @var{filename}
@opindex -f @r{(option for} @command{units}@r{)}
@opindex --file @r{(option for} @command{units}@r{)}
Instruct @command{units} to load the units file @code{filename}. You
can specify up to 25 units files on the command line. When you use
this option, @command{units} will load @emph{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 @var{filename}
is the empty string (@samp{-f ""}), the default units file (or that
specified by @env{UNITSFILE}) will be loaded in addition to any others
specified with @samp{-f}.
@item -h
@itemx --help
@opindex -h @r{(option for} @command{units}@r{)}
@opindex --help @r{(option for} @command{units}@r{)}
Print out a summary of the options for @command{units}.
@item -m
@itemx --minus
@opindex -m @r{(option for} @command{units}@r{)}
@opindex --minus @r{(option for} @command{units}@r{)}
Causes @samp{-} to be interpreted as a subtraction operator. This is
the default behavior.
@item -p
@itemx --product
@opindex -p @r{(option for} @command{units}@r{)}
@opindex --product @r{(option for} @command{units}@r{)}
Causes @samp{-} 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: @samp{(-3)}. By default @samp{-} is treated as a
subtraction operator.
@item --oldstar
@opindex --oldstar @r{(option for} @command{units}@r{)}
Causes @samp{*} to have the old-style precedence, higher than the
precedence of division so that @samp{1/2*3} will equal @samp{1/6}.
@item --newstar
@opindex --newstar @r{(option for} @command{units}@r{)}
Forces @samp{*} to have the new (default) precedence that follows
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
the value of the last unit in the list to the nearest integer.
@item -S
@itemx --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 fraction with a unity denominator. By default, if the
unit in a list begins with fraction of the form 1|@var{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., @samp{3|8 in} rather
than @samp{3 * 1|8 in}). In some cases, this is not what is wanted;
for example, the results for a cooking recipe might show
@samp{3 * 1|2 cup} as @samp{3|2 cup}.
With the @option{--show-factor} option, a
result equivalent to 1.5 cups will display as @samp{3 * 1|2 cup} rather
than @samp{3|2 cup}. A user-specified fractional unit with a numerator
other than 1 is never overridden, however---if a unit list specifies
@samp{3|4 cup;1|2 cup}, a result equivalent to 1@tie{}1/2 cups will
always be shown as @samp{2 * 3|4 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}.
@item -v
@itemx --verbose
@opindex -v @r{(option for} @command{units}@r{)}
@opindex --verbose @r{(option for} @command{units}@r{)}
Give slightly more verbose output when converting units. When combined
with the @option{-c} option this gives the same effect as
@option{--check-verbose}.
@item -V
@itemx --version
@opindex -V @r{(option for} @command{units}@r{)}
@opindex --version @r{(option for} @command{units}@r{)}
Print program version number, tell whether the @command{readline}
library has been included, and give the location of the default units
data file.
@item -l @var{locale}
@itemx --locale @var{locale}
@opindex -l @r{(option for} @command{units}@r{)}
@opindex --locale @r{(option for} @command{units}@r{)}
Force a specified locale such as @samp{en_GB} to get British
definitions by default. This overrides the locale determined from
system settings or environment variables.
@xref{Locale}, for a description of locale format.
@end table
@node Defining Your Own Units
@chapter Adding Your Own Definitions
@menu
* Units Data Files:: Where are units defined?
* Defining New Units:: Writing your own unit and prefix definitions
* Defining Nonlinear Units:: Writing your own nonlinear unit definitions
* Defining Unit List Aliases:: Writing your own unit list aliases
@end menu
@node Units Data Files
@section Units Data Files
@cindex additional units data files
@cindex data files, additional
@cindex units data files, additional
@cindex @samp{!include}
@cindex command, @samp{!include}
@cindex including additional units data files
The units and prefixes that @command{units} can convert are
defined in the units
data file, typically @file{/usr/share/units/definitions.units}.
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 definitions will be
preserved when you update @command{units}.
You can include additional data files in the units database using
the @samp{!include} command in the standard units data file. For
example
@example
!include /usr/local/share/units/local.units
@end example
@noindent
might be appropriate for a site-wide supplemental data file.
The location of the @samp{!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 @samp{!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
@samp{units@tie{}-c} after making changes to any units data file.
@cindex personal units data file
@cindex units data file, personal
If you want to add your own units in addition to or in place of
standard or site-wide supplemental units data files, you can include
them in the @file{.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. (Under Windows the personal units file is
named @file{unitdef.units}.)
The @command{units} program first tries to determine your home
directory from the @env{HOME} environment variable. On systems running
Microsoft Windows, if @env{HOME} does not exist, @command{units}
attempts to find your home directory from @env{HOMEDRIVE} and
@env{HOMEPATH}. Running @command{units -V} will display the location
and name of your personal units file.
@cindex MYUNITSFILE environment variable
@cindex environment variable, MYUNITSFILE
You can specify an arbitrary file as your personal units data file with
the @env{MYUNITSFILE} environment variable; if this variable exists, its
value is used without searching your home directory.
@node Defining New Units
@section Defining New Units and Prefixes
@cindex defining units
@cindex units, definition of
@cindex units definitions, adding
@cindex units definitions, changing
@cindex prefixes, definition of
@cindex defining prefixes
@cindex primitive units
@cindex units, primitive
@cindex @samp{!} to indicate primitive units
@cindex command, @samp{!} to indicate primitive units
A unit is specified on a single line by giving its name and an
equivalence. Comments start with a @samp{#} character, which can appear
anywhere in a line. The backslash character (@samp{\})
acts as a continuation
character 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 @samp{!include} followed by
the file's name. The @samp{!} 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 the comment character @samp{#}.
@cindex include files
Unit names must not contain any of the operator characters @samp{+},
@samp{-}, @samp{*}, @samp{/}, @samp{|}, @samp{^}, @samp{;}, @samp{~},
the comment character @samp{#}, or parentheses. They cannot begin or
end with an underscore (@samp{_}), a comma (@samp{,}) or a decimal point
(@samp{.}). The figure dash (U+2012), typographical minus (`@minus{}';
U+2212), and en dash (`--'; U+2013) are converted to the operator
@samp{-}, 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, @samp{foo_2}, @samp{foo_2,1}, or @samp{foo_3.14}
would be valid names but @samp{foo2} or @samp{foo_a2} would be invalid.
You could define nitrous oxide as
@example
N2O nitrogen 2 + oxygen
@end example
@noindent
but would need to define nitrogen dioxide as
@example
NO_2 nitrogen + oxygen 2
@end example
@noindent
Be careful to define new units in terms of old ones so that a
reduction leads to the primitive units, which are marked with @samp{!}
characters. Dimensionless units are indicated by using the string
@samp{!dimensionless} for the unit definition.
@cindex dimensionless units, defining
When adding new units, be sure to use the @option{-c} option to check that
the new units reduce properly.
If you create a loop in the units definitions, then @command{units} will
hang when invoked with the @option{-c} option. You will need to
use the @option{--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.
@cindex parentheses
If you define any units that contain
@samp{+} characters, carefully check them because the @option{-c} option
will not catch non-conformable sums. Be careful with the @samp{-}
operator as well. When used as a binary operator, the @samp{-}
character can perform addition or multiplication
depending on the options used to invoke @command{units}.
To ensure consistent behavior use @samp{-} only as a unary negation
operator when writing units definitions. To multiply two units leave a
space or use the @samp{*} operator with care, recalling that it has
two possible precedence values and may require parentheses to ensure
consistent behavior. To compute the difference
of @samp{foo} and @samp{bar} write @samp{foo+(-bar)} or even @samp{foo+-bar}.
Here is an example of a short data file that defines some basic
units:
@example
@group
m ! # The meter is a primitive unit
sec ! # The second is a primitive unit
rad !dimensionless # A dimensionless primitive unit
micro- 1e-6 # Define a prefix
minute 60 sec # A minute is 60 seconds
hour 60 min # An hour is 60 minutes
inch 0.0254 m # Inch defined in terms of meters
ft 12 inches # The foot defined in terms of inches
mile 5280 ft # And the mile
@end group
@end example
@cindex parentheses
@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}
would be equivalent to @samp{1 / (2 meter)}.
@node Defining Nonlinear Units
@section Defining Nonlinear Units
@cindex defining nonlinear units
@cindex nonlinear units, defining
@cindex nonlinear unit conversions
Some unit conversions of interest are nonlinear; for
example, temperature 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 @samp{inch 2.54 cm} you
are providing information that @command{units} uses to convert values in
inches into primitive units of meters. For nonlinear units, you give
a functional 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 linear units in the data file, so that
an eventual conversion to primitive units is possible.
Here is an example nonlinear unit definition:
@example
@group
tempF(x) units=[1;K] (x+(-32)) degF + stdtemp ; \
(tempF+(-stdtemp))/degF + 32
@end group
@end example
@noindent
A nonlinear unit definition comprises a unit name, a dummy parameter
name, two functions, and two corresponding units. The functions tell
@command{units} how to convert to and from the new unit. In order to
produce valid results, the arguments of these functions need to have
the correct dimensions. To facilitate error checking, you may
optionally indicate units for these arguments.
@cindex parentheses
The definition begins with the unit name followed immediately (with no
spaces) by a @samp{(} character. In parentheses is the name of the
parameter. Next is an optional specification of the units required by
the functions in this definition. In the example above, the
@samp{tempF} function requires an input argument conformable with
@samp{1}. For normal nonlinear units definitions the forward
function will always take a dimensionless argument.
The inverse function requires an input argument conformable
with @samp{K}. In general the inverse function will need units
that match the quantity measured by your nonlinear unit.
The purpose of the expression in brackets to enable
@command{units} to perform error checking on function arguments, and
also to assign units to range and domain specifications, which are
described later.
Next the function definitions appear. In the example above, the
@samp{tempF} function is defined by
@example
@group
tempF(x) = (x+(-32)) degF + stdtemp
@end group
@end example
@noindent
This gives a rule for converting @samp{x} in the units @samp{tempF}
to linear units of absolute temperature, which makes it possible to
convert from tempF to other units.
In order to make conversions to Fahrenheit possible, you must give
a rule for the inverse conversions. The inverse will be @samp{x(tempF)}
and its definition appears after a @samp{;} character.
In our example, the inverse is
@example
@group
x(tempF) = (tempF+(-stdtemp))/degF + 32
@end group
@end example
@noindent
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 @samp{;} character, but then conversions to
the unit will be impossible. If the inverse is omitted then the
@option{--check} option will display a warning. It is up to you to
calculate and enter the correct inverse function to obtain proper
conversions. The @option{--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.
If you wish to make synonyms for nonlinear units, you still need to define
both the forward and inverse functions. Inverse functions can be
obtained using the @samp{~} operator. So to create a synonym
for @samp{tempF} you could write
@example
@group
fahrenheit(x) units=[1;K] tempF(x); ~tempF(fahrenheit)
@end group
@end example
@noindent
You may define a function whose range and domain do not cover all of
the real numbers. In this case @command{units} can handle errors
better if you specify an appropriate range and domain. You specify
the range and domain as shown below.
@example
@group
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
@end group
@end example
@noindent
In this example the domain is specified after the @samp{domain=} with
the endpoints given in brackets. One of the end points can be omitted
to get an interval that goes to infinity. So the range could be
specified as nonnegative by writing @samp{range=[0,]}. Both the range
and domain are optional and can appear independently and in any order
along with the @samp{units} specification. The values in the range
and domain are attached to the units given in the @samp{units}
specification. If you don't specify the units then the parameter
inputs are reduced to primitive units for the numeric comparison to
the values you give in the range or domain. In this case you should only
use @samp{range} or @samp{domain} if the endpoints are zero and
infinity.
Specifying the range and domain allows @command{units} to
perform better error checking and give more helpful error messages
when you invoke nonlinear units conversions outside of their bounds.
It also enables the @option{-c} option to find a point in the domain
to use for its point check of your inverse definition.
@cindex units functions
@cindex functions of units
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 @samp{units=} specification.
Specifying the range as the nonnegative numbers can prevent cryptic
error messages.
@example
@group
circlearea(r) units=[m;m^2] range=[0,] pi r^2 ; sqrt(circlearea/pi)
@end group
@end example
@cindex linear interpolation
@cindex units, piecewise linear
@cindex piecewise linear units
@noindent
Sometimes you may be interested in a piecewise linear unit such as
many wire gauges. Piecewise linear units can be defined by specifying
conversions 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
@example
@group
zincgauge[in] 1 0.002, 10 0.02, 15 0.04, 19 0.06, 23 0.1
@end group
@end example
@noindent
In this example, @samp{zincgauge} is the name of the piecewise linear
unit. The definition of such a unit is indicated by the
embedded @samp{[} character. After the bracket, you should indicate the
units to be attached to the numbers in the table.
No spaces can appear before the
@samp{]} character, so a definition like @samp{foo[kg meters]} is
illegal; instead write @samp{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 brackets).
In this example,
we define @samp{zincgauge} at five points. For example, we set
@samp{zincgauge(1)} equal to @samp{0.002 in}. Definitions like this
may be more readable if written using continuation characters as
@example
@group
zincgauge[in] \
1 0.002 \
10 0.02 \
15 0.04 \
19 0.06 \
23 0.1
@end group
@end example
@noindent
With the preceding definition, the following conversion can be
performed:
@example
@group
You have: zincgauge(10)
You want: in
* 0.02
/ 50
You have: .01 inch
You want: zincgauge
5
@end group
@end example
@noindent
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, @command{units} will return the smallest
inverse. The @option{--check} option will print a warning if a
non-monotonic piecewise linear unit is encountered.
@node Defining Unit List Aliases
@section Defining Unit List Aliases
@cindex unit list aliases, defining
@cindex @samp{!unitlist}
@cindex command, @samp{!unitlist}
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 @samp{!unitlist} and includes the
alias and the definition; for example, the aliases included in the
standard units data file are
@example
@group
!unitlist hms hr;min;sec
!unitlist time year;day;hr;min;sec
!unitlist dms deg;arcmin;arcsec
!unitlist ftin ft;in;1|8 in
!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
@end group
@end example
@noindent
Unit list aliases are only for unit lists, so the definition must
include a @samp{;}. Unit list aliases can never be combined with
units or other unit list aliases, so the definition of @samp{time}
shown above could @emph{not} have been shortened to
@samp{year;day;hms}. As usual, be sure to run @command{units --check}
to ensure that the units listed in unit list aliases are conformable.
@node Numeric Output Format
@chapter Numeric Output Format
@cindex numeric output format
@cindex output format
@menu
* Format Specification:: The output format specification
* Flags:: Optional format flags
* Field Width:: Specifying output field width
* Precision:: Specifying output precision
@end menu
By default, @code{units} shows results to eight significant
digits. You can change this with the @option{--exponential},
@option{--digits}, and @option{--output-format} options. The first
sets an exponential format (i.e., scientific notation) like that used
in the original Unix @command{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
@code{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 @option{--digits} and @option{--exponential}
options. The @option{--output-format} option affords the greatest
control of the output appearance, but requires at least rudimentary
knowledge of the @code{printf()} format syntax. @xref{Invoking Units},
for descriptions of these options.
@node Format Specification
@section Format Specification
@cindex output format specification
@cindex format specification, output
The format specification recognized with the @option{--output-format}
option is a subset of that for @code{printf()}. The format specification has
the form
@c noman
@code{%}[@i{flags}][@i{width}][@code{.}@i{precision}]@i{type};
@c end noman
@c ifman
@ignore
.\".CW "%\fR[\fP\fIflags\fP\fR][\fP\fIwidth\fP\fR][\fP.\fIprecision\fP\fR]\fP\fItype\fP" ;
@code{%}[@i{flags}][@i{width}][\c
@code{.}@i{precision}]@i{type};
@end ignore
@c end ifman
it must begin with @samp{%}, and must end with a floating-point type
specifier:
@samp{g} or @samp{G} to specify the number of significant digits,
@samp{e} or @samp{E} for scientific notation, and @samp{f} for
fixed-point decimal. The ISO C99 standard added the @samp{F} type for
fixed-point decimal and the @samp{a} and @samp{A} types for hexadecimal
floating point; these types are allowed with compilers that support
them. Type length modifiers (e.g., @samp{L} to indicate a long double)
are inapplicable and are not allowed.
The default format for @command{units} is @samp{%.8g};
for greater precision, you could specify @samp{-o@tie{}%.15g}.
The @samp{g} and @samp{G} format types use exponential format whenever
the exponent would be less than @minus{}4, so the value 0.000013
displays as @samp{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
@c
@tex
$5\times 10^7$
@end tex
@ifnottex
@c noman
5e7
@c end noman
@c man .if t .ig ++
@c man 5e7
@c man .++
@c man .if n .ig ++
@c man .EQ
@c man 5 times 10 sup 7
@c man .EN
@c man .++
@end ifnottex
displays as @samp{50000000} and the value
@tex
$5\times 10^8$
@end tex
@ifnottex
@c noman
5e8
@c end noman
@c man .if t .ig ++
@c man 5e8
@c man .++
@c man .if n .ig ++
@c man .EQ
@c man 5 times 10 sup 8
@c man .EN
@c man .++
@end ifnottex
displays as @samp{5e+008}. If you prefer fixed-point display, you might
specify @samp{-o@tie{}%.8f}; however, small numbers will display very
few significant digits, and values less than
@tex
$0.5\times10^{-8}$
@end tex
@ifnottex
@c noman
0.5e@minus{}8
@c end noman
@c man .if t .ig ++
@c man 0.5e\-8
@c man .++
@c man .if n .ig ++
@c man .EQ
@c man 0.5 times 10 sup -8
@c man .EN
@c man .++
@end ifnottex
will show nothing but zeros.
The format specification may include one or more optional flags:
@samp{+}, @samp{@tie{}} (space), @samp{#}, @samp{-}, or @samp{0} (the
digit zero). The digit-grouping flag
@c noman
@set codequoteundirected
@samp{'} (apostrophe)
@clear codequoteundirected
@c end noman
@c if the troff formatter is groff, ensure an ASCII single quote
@c man .ie \n(.g .CQ "\(aq"
@c man .el .CQ "'"
is allowed with compilers that support it. Flags are followed by an
optional value for the minimum field width, and an optional precision
specification that begins with a period (e.g., @samp{.6}). The field
width includes the digits, decimal point, the exponent, thousands
separators (with the digit-grouping flag), and the sign if any of these
are shown.
@node Flags
@section Flags
@cindex output format flags
@cindex flags, output format
The @samp{+} flag causes the output to have a sign (@samp{+} or @samp{-}).
The space flag @samp{@tie{}} is similar to the @samp{+} flag, except
that when the value is positive, it is prefixed with a space rather than
a plus sign; this flag is ignored if the @samp{+} flag is also given.
The @samp{+} or @samp{@tie{}} flag could be useful if conversions might
include positive and negative results, and you wanted to align
the decimal points in exponential notation.
@c
The @samp{#} 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 @samp{g} or @samp{G} types, the @samp{#} flag also prevents the
suppression of trailing zeros.
@c
The digit-grouping flag
@c noman
@set codequoteundirected
@samp{'}
@clear codequoteundirected
@c end noman
@c if the troff formatter is groff, ensure an ASCII single quote
@c man .ie \n(.g .CQ "\(aq"
@c man .el .CQ "'"
shows a thousands separator in digits to the left of the decimal point.
@c (e.g., @samp{1,234.56}).
This can be useful when displaying large numbers in fixed-point decimal;
for example, with the format @samp{%f},
@example
You have: mile
You want: microfurlong
* 8000000.000000
/ 0.000000
@end example
@noindent
the magnitude of the first result may not be immediately obvious without
counting the digits to the left of the decimal point. If the thousands
separator is the comma (@samp{,}), the output with the format
@c noman
@set codequoteundirected
@samp{%'f}
@clear codequoteundirected
@c end noman
@c if the troff formatter is groff, ensure an ASCII single quote
@c man .ie \n(.g .CQ "%\(aqf"
@c man .el .CQ "%'f"
might be
@example
You have: mile
You want: microfurlong
* 8,000,000.000000
/ 0.000000
@end example
@noindent
making the magnitude readily apparent. Unfortunately, few compilers
support the digit-grouping flag.
@c
With the @samp{-} 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 @samp{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 @samp{%011.6f},
@example
You have: troypound
You want: grain
* 5760.000000
/ 0000.000174
@end example
@noindent
The @samp{0} flag has no effect if the @samp{-} (left align) flag is
given.
@node Field Width
@section Field Width
@cindex output 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 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 @command{units} than with long columnar output, but it
may nonetheless assist in quickly assessing the relative magnitudes of
results. For example, with the format @samp{%12.6f},
@example
@group
You have: km
You want: in
* 39370.078740
/ 0.000025
@end group
@group
You have: km
You want: rod
* 198.838782
/ 0.005029
@end group
@group
You have: km
You want: furlong
* 4.970970
/ 0.201168
@end group
@end example
@node Precision
@section Precision
@cindex output precision
@cindex precision, output
The meaning of ``precision'' depends on the format type. With @samp{g}
or @samp{G}, it specifies the number of significant digits (like the
@option{--digits} option); with @samp{e}, @samp{E}, @samp{f}, or
@samp{F}, it specifies the maximum number of digits to be shown after
the decimal point.
@c
With the @samp{g} and @samp{G} format types, trailing zeros are
suppressed, so the results may sometimes have fewer digits than the
specified precision (as indicated above, the @samp{#} flag causes
trailing zeros to be displayed).
The default precision is 6, so @samp{%g} is equivalent to @samp{%.6g},
and would show the output to six significant digits. Similarly,
@samp{%e} or @samp{%f} would show the output with six digits after the
decimal point.
The C @code{printf()} function allows a precision of arbitrary size, whether or
not all of the digits are meaningful. With most compilers, the maximum
internal precision with @command{units} is 15 decimal digits (or 13
hexadecimal digits).
With the @samp{--digits} option, you are limited
to the maximum internal precision; with the @option{--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 artifacts. For example, a pound is exactly 7000 grains, but
with the format @samp{%.18g}, the output might be
@example
You have: pound
You want: grain
* 6999.9999999999991
/ 0.00014285714285714287
@end example
@noindent
With the format @samp{%.25g} you might get the following:
@example
You have: 1/3
You want:
Definition: 0.333333333333333314829616256247
@end example
@noindent
In this case the displayed value includes a series of digits that represent 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.
@c
The precision affects only the @emph{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 @code{printf()} for more detailed descriptions of the
format specification.
The @option{--output-format} option is incompatible with the
@option{--exponential} or @option{--digits} options; if the former is
given in combination with either of the latter, the format is controlled
by the last option given.
@node Localization
@chapter Localization
@cindex environment dependent definitions
@cindex localization
@cindex @samp{!locale}
@cindex command, @samp{!locale}
@cindex @samp{!endlocale}
@cindex command, @samp{!endlocale}
@cindex command, @samp{!endvar}
@cindex command, @samp{!var}
@cindex command, @samp{!varnot}
@cindex command, @samp{!set}
@cindex command, @samp{!message}
@menu
* Locale:: What is a locale?
* Additional Localization:: When the locale isn't enough
@end menu
Some units have different values in different locations. The
localization feature accommodates this by allowing a units data file to
specify definitions that depend on the user's locale.
@node Locale
@section Locale
@cindex 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
formatting of dates. The @command{units} program attempts to determine
the locale from the POSIX setlocale function; if this cannot be done,
@command{units} examines the environment
variables @env{LC_CTYPE} and @env{LANG}.
On POSIX systems, a locale is of the form
@var{language}@code{_}@var{country}, where @var{language} is the
two-character code from ISO 639-1 and @var{country} is the two-character
code from ISO 3166-1; @var{language} is lower case and @var{country} is
upper case. For example, the POSIX locale for the United Kingdom is @code{en_GB}.
@cindex @file{locale.map}
@cindex setlocale function
On systems running Microsoft Windows, the value returned by setlocale()
is different from that on POSIX systems; @command{units} attempts to map
the Windows value to a POSIX value by means of a table in the file
@file{locale.map} in the same directory, typically
@file{/usr/local/share/units}, as the default units data files. The
file includes entries for many combinations of language and country, and
can be extended to include other combinations. The @file{locale.map}
comprises two tab-separated columns; each entry is of the form
@display
@var{Windows-locale}@ @ @ @var{POSIX-locale}
@end display
@noindent
where @var{POSIX-locale} is as described above, and @var{Windows-locale}
typically spells out both the language and country. For example, the
entry for the United States is
@example
English_United States en_US
@end example
@noindent
You can force @command{units} to run in a desired locale by using the
@option{-l} option.
In order to create unit definitions for a particular locale you begin
a block of definitions in a unit datafile with @samp{!locale} followed
by a locale name. The @samp{!} must be the first character on the
line. The @command{units} program reads the following
definitions only if the current locale matches. You end the block of
localized units with @samp{!endlocale}. Here is an example, which
defines the British gallon.
@example
@group
!locale en_GB
gallon 4.54609 liter
!endlocale
@end group
@end example
@node Additional Localization
@section 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
countries. To address this, @command{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 force a particular group of definitions.
A conditional block of definitions in a units data file begins with
either @samp{!var} or @samp{!varnot} following by an environment
variable name and then a space separated
list of values. The leading @samp{!} must appear in the first column of a units
data file, and the conditional block is terminated by @samp{!endvar}.
Definitions in blocks beginning with @samp{!var} are executed only if the
environment variable is exactly equal to one of the listed values.
Definitions in blocks beginning with @samp{!varnot} are executed only if the
environment variable does @emph{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 @emph{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 definitions could be accommodated as follows:
@example
@group
!var INCH_UNIT usa
yard 3600|3937 m
!endvar
@end group
@group
!var INCH_UNIT canada
yard 0.9144 meter
!endvar
@end group
@group
!var INCH_UNIT uk
yard 0.91439841 meter
!endvar
@end group
@group
!var INCH_UNIT canada uk usa
foot 1|3 yard
inch 1|12 foot
!endvar
@end group
@group
!var INCH_UNIT france
foot 144|443.296 m
inch 1|12 foot
line 1|12 inch
!endvar
@end group
@group
!varnot INCH_UNIT usa uk france canada
!message Unknown value for INCH_UNIT
!endvar
@end group
@end example
@noindent
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
block. In this case that block uses the
@samp{!message} command to display a warning message. Alternatively
that block could set default values.
In order to create default values that are overridden by user settings
the data file can use the @samp{!set} command, which sets an
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
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.
To link these settings to the user's locale you combine the @samp{!set}
command with the @samp{!locale} command.
If you wanted to combine the above example with suitable locales you
could do by @emph{preceding} the above definition with the following:
@example
@group
!locale en_US
!set INCH_UNIT usa
!endlocale
!locale en_GB
!set INCH_UNIT uk
!endlocale
!locale en_CA
!set INCH_UNIT canada
!endlocale
!locale fr_FR
!set INCH_UNIT france
!endlocale
!set INCH_UNIT france
@end group
@end example
@noindent
These definitions set the overall default for @env{INCH_UNIT} to
@samp{france} and set default values for four locales appropriately.
The overall default setting comes last so that it only applies when
@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
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}
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.
@node Environment Vars
@chapter Environment Variables
@cindex environment variables
The @command{units} program uses the following environment variables:
@table @env
@item HOME
@cindex HOME environment variable
@cindex environment variable, HOME
Specifies the location of your home directory; it is used by
@command{units} to find a personal units data file @samp{.units}.
On systems running Microsoft Windows, @command{units} tries to
determine your home directory from the @env{HOMEDRIVE} and
@env{HOMEPATH} environment variables if @env{HOME} does not exist.
@item LC_CTYPE, LANG
@cindex LANG environment variable
@cindex LC_CTYPE environment variable
@cindex environment variable, LANG
@cindex environment variable, LC_CTYPE
Checked to determine the locale if @command{units} cannot obtain it
from the operating system. Sections of the
standard units data file are specific to certain locales.
@item MYUNITSFILE
@cindex MYUNITSFILE environment variable
@cindex environment variable, MYUNITSFILE
Specifies your personal units data file. If this variable exists,
@command{units} uses its value rather than searching your home
directory for @samp{.units}. The personal units file will not be
loaded if any data files are given using the @samp{-f} option.
@item PAGER
@cindex PAGER environment variable
@cindex environment variable, PAGER
@cindex help
Specifies the pager to use for help and for displaying the conformable
units. The help function browses the units database and calls
the pager using the @samp{+n}@var{n} syntax for specifying a line
number. The default pager is @command{more}; @env{PAGER} can be used
to specify alternatives such as @command{less}, @command{pg},
@command{emacs}, or @command{vi}.
@item UNITS_ENGLISH
@cindex UNITS_ENGLISH environment variable
@cindex environment variable, UNITS_ENGLISH
Set to either @samp{US} or
@samp{GB} to choose United States or British volume definitions,
overriding the default from your locale.
@item UNITSFILE
@cindex UNITSFILE environment variable
@cindex environment variable, UNITSFILE
Specifies the units data file to use (instead of the default).
You can only specify a single units data file using this
environment variable. If units data files are given using the @samp{-f}
option, the file specified by @env{UNITSFILE} will be not be loaded
unless the @option{-f} option is given with the empty string
(@samp{units@tie{}-f@tie{}""}).
@end table
@node Unicode Support
@chapter Unicode Support
@cindex Unicode support
@cindex UTF-8
@cindex @samp{!utf8}
@cindex command, @samp{!utf8}
@cindex @samp{!endutf8}
@cindex command, @samp{!endutf8}
The standard units data file is in Unicode, using UTF-8 encoding. Most
definitions use only ASCII characters (i.e., code points U+0000 through
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
if the character set is UTF-8, @command{units} reads the UTF-8
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.
When Unicode support is not active, @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
in supplementary units data files, you can use any encoding consistent
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.
Typeset material other than code examples usually uses the Unicode minus
(U+2212) rather than the ASCII hyphen-minus operator (U+002D) used in
@command{units}; the figure dash (U+2012) and en dash (U+2013) are also
occasionally used. To allow such material to be copied and pasted for
interactive use or in units data files, @command{units} converts these
characters to U+002D before further processing. Because of this, none
of these characters can appear in unit names.
@node Readline Support
@chapter Readline Support
@cindex @command{readline}, use with @command{units}
If the @command{readline} package has been compiled in, then when
@command{units} is used interactively, numerous command line editing
features are available. To check if your version of @command{units}
includes @command{readline}, invoke the program with the
@option{--version} option.
For complete information about @command{readline}, consult the
documentation for the @command{readline} package. Without any
configuration, @command{units} will allow editing in the style of
emacs. Of particular use with @command{units} are the completion
commands.
@cindex @samp{?} for unit completion with @command{readline}
@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
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
@example
@group
You have: metr
metre metriccup metrichorsepower metrictenth
metretes metricfifth metricounce metricton
metriccarat metricgrain metricquart metricyarncount
You have: metr
@end group
@end example
@noindent
If there is a unique way to complete a unitname, you can hit the @key{TAB} key
and @command{units} will provide the rest of the unit name. If @command{units}
beeps, it means that there is no unique completion. Pressing the @key{TAB}
key a second time will print the list of all completions.
@node Currency
@chapter Updating Currency Exchange Rates
@cindex currency, updating
@cindex exchange rates, updating
The units program includes currency exchange rates and prices for some
precious metals in the database. Of course, these values change over
time, sometimes very rapidly, and @command{units} cannot provide real
time values. To update the exchange rates run the
@command{units_cur}, which rewrites the files containing the currency
rates, typically @file{/usr/local/share/units/currency.units}. This program
must be run with suitable permissions to write the file. To keep the
rates updated automatically, it could be run by a cron job on a
Unix-like system, or a similar scheduling program on a different system.
Currency exchange rates are taken from Time Genie
(@uref{http://www.timegenie.com}) and precious metals pricing from
Packetizer (@uref{www.packetizer.com}). These sites update once per
day, so there is no benefit in running the update script more often than
daily. You can run @command{units_cur} with a filename specified on the
command line and it will write the data to that file. If you give
@samp{-} for the file it will write to standard output.
@node Database Syntax
@chapter Database Command Syntax
@cindex database syntax summary
@cindex syntax of units database
@cindex commands in units database
@table @t
@item @var{unit} @var{definition}
Define a regular unit.
@item @var{prefix}- @var{definition}
Define a prefix.
@item @var{funcname}(@var{var}) units=[@var{in-units},@var{out-units}] domain=[@var{x1},@var{x2}] range=[@var{y1},@var{y2}] @var{definition(var)} ; @var{inverse(funcname)}
Define a nonlinear unit or unit function. The three optional keywords
@command{units=}, @command{range=} and @command{domain=} can appear in
any order. The definition of the inverse is optional.
@item @var{tabname}[@var{out-units}] @var{pair-list}
Define a piecewise linear unit. The pair list gives the points on the
table listed in ascending order.
@item !endlocale
End a block of definitions beginning with @samp{!locale}
@item !endutf8
End a block of definitions begun with @samp{!utf8}
@item !endvar
End a block of definitions begun with @samp{!var} or @samp{!varnot}
@item !include @var{file}
Include the specified file.
@item !locale @var{value}
Load the following definitions only of the locale is set to
@var{value}.
@item !message @var{text}
Display @var{text} when the database is read unless the quiet
option (@option{-q}) is enabled.
@item !set @var{variable} @var{value}
Sets the environment variable, @var{variable}, to the specified
value @emph{only if} it is not already set.
@item !unitlist @var{alias} @var{definition}
Define a unit list alias.
@item !utf8
Load the following definitions only if @command{units} is running with
UTF-8 enabled.
@item !var @var{variable} @var{value-list}
Load the following definitions only if the environment variable,
@var{variable} is set to one of the values listed on the space
separated value list. If @var{variable} is not set then
@command{units} prints an error message and ignores the following
definitions.
@item !varnot @var{variable} @var{value-list}
Load the following definitions only if the environment variable,
@var{variable} is @var{not} set to one of the values listed on the space
separated value list. If @var{variable} is not set then
@command{units} prints an error message and ignores the following
definitions.
@end table
@node GNU Free Documentation License
@chapter GNU Free Documentation License
@include fdl-1.3.texi
@node Index
@unnumbered Index
@printindex cp
@bye
@c man .SH FILES
@c man @DATAFILE@ \(em the standard units data file
@c man .SH AUTHOR
units-2.02/texi2man 0000711 0001750 0001750 00000027255 12156244702 013540 0 ustar adrian adrian #!/usr/bin/perl
# $Id: $
# Written by Adrian Mariano, additional features by Eric Backus. A few
# additional features by Jeff Conrad to give better formatting with
# troff.
# Script to translate a texinfo file into an nroff/troff manual page.
# last revision: 2 June 2013 Jeff Conrad
$version="1.01p";
$html=0;
$example=0;
$ignore=0;
$tex=0;
$doman=0;
$title=0;
$diditem=0;
$justdidlp=1;
$noman=0;
$manprefix="";
$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`);
while(<>)
{
# use font CW in tables
if (/\@c man\s+l\s/)
{
s/\@c man //;
s/l/lfCWp-1/;
print;
next;
}
if (s/\@c man //)
{
print;
if (/\.TH/) { add_extensions(); }
next;
}
if (/\@c noman/) { $noman=1; next; }
if (/\@c end noman/) { $noman=0; next; }
if ($noman) { next; }
if (/\@c ifman\s*(.*)/) { $doman=1; $manprefix = $1; next; }
if (/\@c end ifman/) { $doman=0; $manprefix = ""; next; }
if (/^\\input/) { next; }
if (/^\*/) { next; }
if (/^START-INFO-DIR-ENTRY/) { next; }
if (/^END-INFO-DIR-ENTRY/) { next; }
if (/\@titlepage/) { $title=1; next; }
if (/\@end titlepage/) { $title=0; next; }
if (/\@tex/) { $tex=1; next; }
if (/\@end tex/) { $tex=0; next; }
if (/\@ignore/) { $ignore=1; next; }
if (/\@end ignore/) { $ignore=0; next; }
if (/\@ifhtml/) { $html=1; next; }
if (/\@end ifhtml/) { $html=0; next; }
if (!$doman && ($ignore || $html || $title || $tex)) { next; }
if (/\@codequoteundirected/) { next; }
s/\@\*$/\n\.br/g;
s/^\@\*/.br/g;
s/\@\*$/\n.br/g;
s/\@tie\{}/\@no_break\{}/g;
s/\@ / /g;
s/\@w\{}/\@no_break\{}/g;
# ellipsis, defined in extensions
s/\@dots\{}/\\*(El/g;
s/\@cite\{([^}]*)}/\@in_sgl_quotes\{$1}/g;
s/\@url\{([^}]*)}/\@in_sgl_quotes\{$1}/g;
s/\@email\{([^}]*)}/\@in_sgl_quotes\{$1}/g;
s/\@dfn\{([^}]*)}/\@in_italics\{$1}/g;
s/\@emph\{([^}]*)}/\@in_italics\{$1}/g;
s/\@i\{([^}]*)}/\@in_italics\{$1}/g;
s/\@r\{([^}]*)}/\@in_roman\{$1}/g;
s/\@var\{([^}]*)}/\@in_italics\{$1}/g;
s/\@b\{([^}]*)}/\@in_bold\{$1}/g;
s/\@strong\{([^}]*)}/\@in_bold\{$1}/g;
# remove trailing comma from xref because man won't include the page number
s/\@xref\{([^}]*)},/\@xref\{$1}/g;
s/\@xref\{([^}]*)}/See \@in_italics\{$1}/g;
s/\@ref\{([^}]*)}/\@ref\{$1}/g;
s/\@ref\{([^}]*)}/\@in_italics\{$1}/g;
s/\@pxref\{([^}]*)}/see \@in_italics\{$1}/g;
s/\@uref\{([^}]*)}/\@in_roman\{$1}/g;
if (/\@chapter.*\@command/)
{
s/\@command\{([^}]*)}/\@in_italics\{$1}/g;
}
# show in constant-width font
s/\@code\{([^}]*)}/\@constwid\{$1}/g;
s/\@command\{([^}]*)}/\@constwid\{$1}/g;
s/\@env\{([^}]*)}/\@constwid\{$1}/g;
# show in constant-width oblique font
s/\@kbd\{([^}]*)}/\@constwidI\{$1}/g;
# show in constant-width font with single quotes
s/\@file\{([^}]*)}/\@constwidQ\{$1}/g;
s/\@option\{([^}]*)}/\@constwidQ\{$1}/g;
# Pass ASCII double quotes to .CQ encoded as two double quotes
# disallow single quotes here because groff converts them to
# typographical closing quotes.
# This substitution works only in very limited circumstances, and
# needs extension to handle the general case of ASCII quotes in
# sample text
s/\@samp\{([^}]*)["']{2,2}}/\@samp\{$1""""}/g;
s/\@samp\{(.*\@(tie|no_break)\{})["']{2,2}}/\@samp\{$1""""}/g;
s/\@samp\{([^}]*)}/\@constwidQ\{$1}/g;
s/\@sc\{([^}]*)}/\@to_upper\{$1}/g;
s/\@key\{([^}]*)}/\@in_italics\{$1}/g;
s/\@footnote\{([^}]*)}/\@in_square_br\{$1}/g;
s/\@math\{([^}]*)}/\@no_decoration\{$1}/g;
s/\@w\{([^}]*)}/\@no_decoration\{$1}/g;
s/\@minus\{}/\\-/g;
s/\@copyright\{}/\\(co/g;
s/\@noindent//;
s/\@\{/{/g;
s/\@}/}/g;
s/\@\@/@/g;
s/---/\\(em/g;
s/\@in_sgl_quotes\{([^}]+)}/`$1'/g;
s/\@in_dbl_quotes\{([^}]+)}/\"$1\"/g;
s/\@in_italics\{([^}]+)}/\\fI$1\\fP/g;
s/\@in_roman\{([^}]+)}/\\fR$1\\fP/g;
s/\@in_bold\{([^}]+)}/\\fB$1\\fP/g;
s/\@to_upper\{([^}]*)}/\U$1\E/g;
s/\@no_decoration\{([^}]*)}/$1/g;
s/\@no_break\{}/\\ /g;
s/\@[ ]/ /g;
s/\@in_angle_br\{([^}]*)}/<$1>/g;
s/\@in_square_br\{([^}]*)}/[$1]/g;
# set up to use CW, CI, and CQ macros
# put every instance on a new line
# ensure that prepended and appended macros go on separate lines
# separate concatenated commands with spaces
s/([}])(\@constwid[IQ]*)/$1 $2/g;
s/(\@constwid[IQ]*\{[^}]+})(\@)/$1 $2/g;
# space before -> newline
s/\s+(\S*\@constwid[IQ]*\{[^}]+}\S*)/\n$1/g;
# space after -> newline
s/(\S*\@constwid[IQ]*\{[^}]+}\S*)\s+/$1\n/g;
if (/(\S*)\@constwidI\{([^}]+)}(\S*)/) {
$_ = CW_macro("$_", '@constwidI', ".CI");
}
if (/(\S*)\@constwidQ\{([^}]+)}(\S*)/) {
$_ = CW_macro("$_", '@constwidQ', ".CQ");
}
if (/(\S*)\@constwid\{([^}]+)}(\S*)/) {
$_ = CW_macro("$_", '@constwid', ".CW");
}
# handle backslash character in sample
s/(\.C[IQW]\s+\S+\s+)"\\"/$1"\\e"/g;
s/(\.C[IQW]\s+)"\\"/$1"\\e"/g;
# some versions of n/troff don't have \(en, so use \-
# don't replace double hyphens in C[IQW] macros; assume true en
# dashes will be closed up to previous word
s/([^" ]+)--/$1\\-/g;
s/\@value\{([^\s]+)}/$value{$1}/eg;
if (/\@set\s+([^\s]+)\s+(.*)$/) { $value{$1} = $2; next; }
if (/\@clear\s+([^\s]+)\s+(.*)$/) { delete $value{$1}; next; }
# works only for @item and @itemx as used in units(1)
if (/\@itemx (.*)/)
{
$samp = $1;
# add hair space to visually separate the hyphens in roman type
$samp =~ s/--/-\\^-/;
$samp =~ s/-([[:alnum:]])/-\\^$1/;
if (!$diditem)
{ printf(".TP\n.BR \"$samp\""); }
else
{ printf(" \", \" \"$samp\""); }
$diditem=1; next;
}
elsif ($diditem) { printf("\n"); $diditem=0; }
if (/\@item (.*)/)
{
$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;
next;
}
if (s/\@chapter (.*)/.SH \U$1\E/)
{
# restore proper case on font switches
s/\\FR/\\fR/g;
s/\\FI/\\f(BI/g; # chapter headings (SH in man) are bold
s/\\FP/\\fP/g;
printf("%s%s", $manprefix, $_);
$justdidlp=1;
next;
}
if (s/\@section (.*)/$1/)
{
printf("%s.SS %s", $manprefix, $_);
next;
}
# FIXME? why do we need $manprefix for these?
# input/output example macros
if (/\@example/) { printf("%s.ES\n", $manprefix); $example=1; next; }
if (/\@end example/) { printf("%s.EE\n", $manprefix); $example=0; $justdidlp=0; next; }
if (/\@smallexample/) { printf("%s.ES S\n", $manprefix); $example=1; next; }
if (/\@end smallexample/) { printf("%s.EE\n", $manprefix); $example=0; $justdidlp=0; next; }
# no CW font
if (/\@display/) { printf("%s.DS\n", $manprefix, $manprefix); $example=1; next; }
if (/\@end display/) { printf("%s.DE\n", $manprefix, $manprefix); $example=0; next; }
# no CW font, no indent
if (/\@format/) { printf("%s.nf\n", $manprefix); $example=1; next; }
if (/\@end format/) { printf("%s.fi\n", $manprefix); $example=0; next; }
if ($example) { s/\\\s*$/\\e\n/ };
if (!$example && /^\s*$/ && !$doman)
{
if ($justdidlp) { next; }
printf(".PP\n");
$justdidlp=1;
next;
}
if (/^\@/) { next; }
printf("%s%s", $manprefix, $_);
if (!$doman) { $justdidlp=0; }
}
# Extensions to legacy man macro package. groff loads the man macro file
# after the call of TH, so these definitions must likewise follow that
# call of TH if they are overwrite any groff extensions with the same
# names that might be added in the future.
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");
# 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
printf(".\\\"\n");
printf(".\\\" Extensions to man macros\n");
printf(".\\\"\n");
printf(".\\\" Constant-width font\n");
printf(".de CW\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(".\\}\n");
# constant-width font with troff
printf(".if t \\{\\\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(".if n \\{\\\n");
printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\fI\\\\\$2\\fR'\\\\\$3\n");
printf(".el \\&'\\fI\\\\\$1\\fR'\\\\\$2\n");
printf(".\\}\n");
# constant-width oblique font with troff
printf(".if t \\{\\\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(".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(".\\}\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(".\\}\n");
printf(".hy 14\n");
printf("..\n");
# Display Start--indent, no fill
printf(".\\\" Display start\n");
printf(".de DS\n");
printf(".hy 0\n");
printf(".if t .in +4n\n");
printf(".if n .in +3n\n");
printf(".nf\n");
printf("..\n");
# Display End
printf(".\\\" Display end\n");
printf(".de DE\n");
printf(".fi\n");
printf(".in\n");
printf(".hy 14\n");
printf("..\n");
# Example Start--like display, but with font CW
printf(".\\\" Example start\n");
printf(".de ES\n");
# call before size or font change to get consistent indent
printf(".DS\n");
# CW font with troff; optionally reduce size
printf(".if t \\{\\\n");
printf(".if '\\\\\$1'S' \\{\\\n");
printf(".nr Ex 1\n");
printf(".ps -1\n");
printf(".\\}\n");
printf(".el .nr Ex 0\n");
printf(".nr mE \\\\n(.f\n");
printf(".ft CW\n");
printf(".\\}\n");
printf("..\n");
# Example End
printf(".\\\" Example end\n");
printf(".de EE\n");
# restore font and size with troff
printf(".if t \\{\\\n");
printf(".ft \\\\n(mE\n");
printf(".if \\\\n(Ex=1 .ps\n");
printf(".\\}\n");
printf(".DE\n");
printf("..\n");
}
# convert texinfo commands to .C[IQW] macros
sub CW_macro
{
my $line = shift;
my $from = shift;
my $to = shift;
# prepended and appended punctuation
$line =~ s/(\S+)$from\{([^}]+)}(\S+)/$to $1 "$2" $3/g;
# prepended punctuation
$line =~ s/(\S+)$from\{([^}]+)}/$to $1 "$2" ""/g;
# appended punctuation
$line =~ s/$from\{([^}]+)}(\S+)/$to "$1" $2/g;
# just the argument
$line =~ s/$from\{([^}]+)}/$to "$1"/g;
return $line;
}
units-2.02/NEWS 0000600 0001750 0001750 00000016542 12161022133 012543 0 ustar adrian adrian GNU units NEWS - User visible changes.
Copyright (C) 1996, 1997, 1999-2007, 2010-2013 Free Software Foundation, Inc.
Version 2.02
* Added support for %a and %A output formats (hexadecimal floating point), and
eliminated the restriction on the number of displayed digits when specifying
an output format with the --output-format (-o) option. Improved error
handling for formats specified with --output-format.
* Added --digits (-d) to specify the number of digits to display. Giving
'--digits max' (-dmax) will use the full available precision.
* Added support for various Unicode minus sign symbols. Units now treats the
figure dash (U+2012), the en dash (U+2013), and the minus (U+2212) as
identical to the ASCII hyphen/minus symbol (U+002D).
* The !message command in units data files has been fixed so it does not
produce output when the --quiet option is given.
* Improved error handling when unit names end with numbers without a '_'.
* Removed six unicode entries from definition.units that were flagged as
invalid under MacOS.
* Modified units_cur to work with XML format as the txt format disappeared.
* Corrected error in definition of the nat.
* Improved manual.
Version 2.01 - 24 October 2012 (bug fix release)
* Fixed error in electronmass
* New definition for au
* Fixed DESTDIR support for installation
* Changed configure script for success with Solaris
* Small changes to manual
Version 2.00 - 6 June 2012
General changes:
* Unit lists provide conversion to sums of units (e.g. feet and inches).
* Added --round (-r) and --show-factor (-S) options for use with unit lists.
* Added unit lists aliases (e.g. time, usvol).
* A python script, units_cur, can update currency data.
* Units now flushes its output so you can talk to it with a pipe.
* Units now works in UTF-8 if the system supports it.
* Added --locale (-l) option to set the locale.
* English units such as the gallon are defined in all locales, with US
definitions by default except in the en_BG locale. You can force
the desired definition (Great Britain or US) by setting the
environment variable UNITS_ENGLISH to GB or US.
* Revised and extended the documentation, with more examples.
* Added locale mapping to address Windows locale names.
* Updated and revised units database, including UTF-8 definitions and
the 2010 CODATA.
* Fixed parsing bug for "1..2" or "1.2.3". These now give an error.
* Unit names can end with a number in the form of a subscript that
starts with a '_', as in 'X_3'.
* Units now performs error checking on the printf format specified with the
--output-format (-o) option.
Changes for units definition files:
* Changed location and names of unit database, splitting off currency
Files are /usr/local/share/units/{definitions,currency}.units and
the personal units file is $HOME/.units instead of $HOME/units.dat.
(Under windows personal unit file is unitdef.units.)
* Personal units filename can be changed with MYUNITSFILE environment variable.
* Prefixes can be defined in any order: it is no longer necessary to
define longer ones before shorter ones.
* New definitions replace previous ones. Personal units file is read
after the system file rather than before.
* Changed syntax for function definitions. Instead of [in-unit,out-unit]
you must now write units=[in-unit,out-unit]. Use 'units -c' to find
places in your personal data files that need to be updated.
* Add optional domain and range to function definitions with syntax
domain=[min,max] and range=[min,max]. Either min or max can be
omitted to signal infinity.
* Unit list aliases can be defined with !unitlist command.
* Added !var and !varnot and !endvar to include definitions based on
environment variable settings.
* Added !set to set environment variables (if they aren't already set).
* Added !message to display a message
* Data files are in UTF-8, with !utf8 and !endutf8 commands to mark
definitions that require UTF-8 support.
* Improved error handling when reading units.dat.
Version 1.88 - 15 Feb 2010
* Updated units.dat
* Fixed bug involving readline version 4.2
Version 1.87 - 25 Sep 2007
* Units reads ~/.units.dat if it exists before reading the standard
units database.
* Added support for ** as an exponent operator.
* Type 'search text' to list units that contain 'text' in their name.
* Precedence of '*' changed to match precedence of '/'.
(Multiplication by juxtaposition retains a higher precedence than
'/'.) The --oldstar option selects the old precedence and --newstar
forces the new precedence.
Version 1.86 - 10 Nov 2006
* Added --one-line (-1) option which causes the program to print only
one line of output.
* Added --compact option which causes the program to print only the
conversion factors and a newline on output.
* Added build support for DESTDIR.
* Made minor changes that allow the program to be compiled into a
library and linked with other programs.
* Fixed bug that caused bus error on Intel Mac.
Version 1.85 - 20 May 2005
* The '-' character by default indicates subtraction. Multiplication can be
obtained by '*' or ' '. The --product (-p) option selects the old behavior
where '-' acts as a multiplication operator. The --minus (-m) option forces
the default behavior where '-' indicates subtraction.
* Handing of radian and steradian changed. These units are now treated as
conformable with 1 for units conversions. This is indicated by the
"!dimensionless" tag in units.dat.
* Unit files can be included using !include.
* Multiple -f (--file) options can appear on the command line; giving
a null filename (-f '') causes the default units database to be loaded.
* Added -t (--terse) option.
* Improved error checking for units.dat.
* Corrected and extended units.dat.
Version 1.81 - October 28, 2002
* Fixed missing definition of "au" in units.dat.
Version 1.80 - June 16, 2002
* Rewritten parser supports
- () for grouping
- noninteger powers of numbers (e.g. 3^0.25)
- functions with dimensionless arguments (log, ln, log2, sin, cos, tan, exp)
- roots of units: sqrt(unit), cuberoot(unit), and higher roots as unit^(1|4)
* Functions can be defined in units.dat, and conversion to a function
performed by specifying the function name alone as the "want" item.
* Unit conversions can be specified as tables with linear interpolation.
* The "help" command summarizes operations, and "help unit" browses the units
database at the definition of the specified unit.
* Specifying "?" for the want unit gets a list of all conformable units.
* Support for locales added.
* Units file extended and corrected.
Version 1.55 - July 30, 1999
* Added over 600 new units and corrected errors in the units data file.
* Minor bug fix affecting unit name completion.
Version 1.54 - July 15, 1997
* Switched order of prefix and plural handling (plurals are now done first)
* Added reciprocal unit conversion and --strict (-s) option
* Fixed some erroneous unit definitions, added currency codes and other units
* Improved Makefile (exec-prefix, program-transform-name supported)
* Bug fixes
Version 1.53 - Jan 13, 1997
* Added units containing ISO 8859-1 characters
* Bug fixes
Version 1.52 - Dec 18, 1996
* Sums of conformable units
* Printing of unit definitions
* Unitname completion with readline
* Added --verbose (-v) option and moved --version to -V
* Improved portability, old style C support, improved Makefile
units-2.02/units.txt 0000664 0001750 0001750 00000263152 12167664611 014005 0 ustar adrian adrian UNITS(1) UNITS(1)
NAME
units — unit conversion and calculation program
SYNOPSIS
'units' [options] [from-unit [to-unit]]
DESCRIPTION
The 'units' program converts quantities expressed in various systems of
measurement to their equivalents in other systems of measurement. Like
many similar programs, it can handle multiplicative scale changes. It
can also handle nonlinear conversions such as Fahrenheit to Celsius.
See the examples below. The program can also perform conversions from
and to sums of units, such as converting between meters and feet plus
inches.
Beyond simple unit conversions, 'units' can be used as a general-pur‐
pose scientific calculator that keeps track of units in its calcula‐
tions. You can form arbitrary complex mathematical expressions of
dimensions including sums, products, quotients, powers, and even roots
of dimensions. Thus you can ensure accuracy and dimensional consis‐
tency when working with long expressions that involve many different
units that may combine in complex ways.
The units are defined in an external data file. You can use the exten‐
sive data file that comes with this program, or you can provide your
own data file to suit your needs. You can also use your own data file
to supplement the standard data file.
Basic operation is simple: you enter the units that you want to convert
from and the units that you want to convert to. You can use the pro‐
gram interactively with prompts, or you can use it from the command
line.
You can change the default behavior of 'units' with various options
given on the command line. See Invoking Units for a description of the
available options.
INTERACTING WITH UNITS
To invoke units for interactive use, type 'units' at your shell prompt.
The program will print something like this:
Currency exchange rates from 04/23/12
2516 units, 85 prefixes, 65 nonlinear units
You have:
At the 'You have:' prompt, type the quantity and units that you are
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 the
tab key can be used to complete unit names. See Readline Support for
more information about 'readline'. To quit the program press Ctrl-C or
Ctrl-D under Unix. Under Windows press Ctrl-Z.
The answer will be displayed in two ways. The first line of output,
which is marked with a '*' to indicate multiplication, gives the result
of the conversion you have asked for. The second line of output, which
is marked with a '/' to indicate division, gives the inverse of the
conversion factor. If you convert 10 meters to feet, 'units' will
print
* 32.808399
/ 0.03048
which tells you that 10 meters equals about 32.8 feet. The second num‐
ber gives the conversion in the opposite direction. In this case, it
tells you that 1 foot is equal to about 0.03 dekameters since the
dekameter is 10 meters. It also tells you that 1/32.8 is about 0.03.
The 'units' program prints the inverse because sometimes it is a more
convenient number. In the example above, for example, the inverse
value is an exact conversion: a foot is exactly 0.03048 dekameters.
But the number given the other direction is inexact.
If you convert grains to pounds, you will see the following:
You have: grains
You want: pounds
* 0.00014285714
/ 7000
From the second line of the output you can immediately see that a
grain is equal to a seven thousandth of a pound. This is not so obvi‐
ous from the first line of the output. If you find the output format
confusing, try using the '--verbose' option:
You have: grain
You want: aeginamina
grain = 0.00010416667 aeginamina
grain = (1 / 9600) aeginamina
If you request a conversion between units that measure reciprocal
dimensions, then 'units' will display the conversion results with an
extra note indicating that reciprocal conversion has been done:
You have: 6 ohms
You want: siemens
reciprocal conversion
* 0.16666667
/ 6
Reciprocal conversion can be suppressed by using the '--strict' option.
As usual, use the '--verbose' option to get more comprehensible output:
You have: tex
You want: typp
reciprocal conversion
1 / tex = 496.05465 typp
1 / tex = (1 / 0.0020159069) typp
You have: 20 mph
You want: sec/mile
reciprocal conversion
1 / 20 mph = 180 sec/mile
1 / 20 mph = (1 / 0.0055555556) sec/mile
If you enter incompatible unit types, the 'units' program will print a
message indicating that the units are not conformable and it will dis‐
play the reduced form for each unit:
You have: ergs/hour
You want: fathoms kg^2 / day
conformability error
2.7777778e-11 kg m^2 / sec^3
2.1166667e-05 kg^2 m / sec
If you only want to find the reduced form or definition of a unit,
simply press Enter at the 'You want:' prompt. Here is an example:
You have: jansky
You want:
Definition: fluxunit = 1e-26 W/m^2 Hz = 1e-26 kg / s^2
The output from 'units' indicates that the jansky is defined to be
equal to a fluxunit which in turn is defined to be a certain combina‐
tion of watts, meters, and hertz. The fully reduced (and in this case
somewhat more cryptic) form appears on the far right.
Some named units are treated as dimensionless in some situations.
These units include the radian and steradian. These units will be
treated as equal to 1 in units conversions. Power is equal to torque
times angular velocity. This conversion can only be performed if the
radian is dimensionless.
You have: (14 ft lbf) (12 radians/sec)
You want: watts
* 227.77742
/ 0.0043902509
Named dimensionless units are not treated as dimensionless in other
contexts. They cannot be used as exponents so for example,
'meter^radian' is not allowed.
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.
Typing 'help' at either prompt displays a short help message. You can
also type 'help' followed by a unit name. This will invoke a pager on
the units data base at the point where that unit is defined. You can
read the definition and comments that may give more details or histori‐
cal information about the unit. (You can generally quit out of the
page by pressing 'q'.)
Typing 'search' text will display a list of all of the units whose
names contain text as a substring along with their definitions. This
may help in the case where you aren't sure of the right unit name.
USING UNITS NON-INTERACTIVELY
The 'units' program can perform units conversions non-interactively
from the command line. To do this, type the command, type the original
unit expression, and type the new units you want. If a units expres‐
sion contains non-alphanumeric characters, you may need to protect it
from interpretation by the shell using single or double quote charac‐
ters.
If you type
units "2 liters" quarts
then 'units' will print
* 2.1133764
/ 0.47317647
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.
UNIT DEFINITIONS
The conversion information is read from a units data file that is
called 'definitions.units' and is usually located in the
'/usr/share/units' directory. If you invoke 'units' with the '-V'
option, it will print the location of this file. The default file
includes definitions for all familiar units, abbreviations and metric
prefixes. It also includes many obscure or archaic units.
Many constants of nature are defined, including these:
pi ratio of circumference to diameter
c speed of light
e charge on an electron
force acceleration of gravity
mole Avogadro's number
water pressure per unit height of water
Hg pressure per unit height of mercury
au astronomical unit
k Boltzman's constant
mu0 permeability of vacuum
epsilon0 permittivity of vacuum
G Gravitational constant
mach speed of sound
The standard data file includes atomic masses for all of the elements
and numerous other constants. Also included are the densities of vari‐
ous ingredients used in baking so that '2 cups flour_sifted' can be
converted to 'grams'. This is not an exhaustive list. Consult the
units data file to see the complete list, or to see the definitions
that are used.
The 'pound' is a unit of mass. To get force, multiply by the force
conversion unit 'force' or use the shorthand 'lbf'. (Note that 'g' is
already taken as the standard abbreviation for the gram.) The unit
'ounce' is also a unit of mass. The fluid ounce is 'fluidounce' or
'floz'. British capacity units that differ from their US counterparts,
such as the British Imperial gallon, are prefixed with 'br'. Currency
is prefixed with its country name: 'belgiumfranc', 'britainpound'.
When searching for a unit, if the specified string does not appear
exactly as a unit name, then the 'units' program will try to remove a
trailing 's', 'es'. Next units will replace a trailing 'ies' with 'y'.
If that fails, 'units' will check for a prefix. The database includes
all of the standard metric prefixes. Only one prefix is permitted per
unit, so 'micromicrofarad' will fail. However, prefixes can appear
alone with no unit following them, so 'micro*microfarad' will work, as
will 'micro microfarad'.
To find out which units and prefixes are available, read the standard
units data file, which is extensively annotated.
English Customary Units
English customary units differ in various ways in different regions.
In Britain a complex system of volume measurements featured different
gallons for different materials such as a wine gallon and ale gallon
that different by twenty percent. This complexity was swept away in
1824 by a reform that created an entirely new gallon, the British Impe‐
rial gallon defined as the volume occupied by ten pounds of water.
Meanwhile in the USA the gallon is derived from the 1707 Winchester
wine gallon, which is 231 cubic inches. These gallons differ by about
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.
Before 1959, the value of a yard (and other units of measure defined in
terms of it) differed slightly among English-speaking countries. In
1959, Australia, Canada, New Zealand, the United Kingdom, the United
States, and South Africa adopted the Canadian value of 1 yard =
0.9144 m (exactly), which was approximately halfway between the values
used by the UK and the US; it had the additional advantage of making
1 inch = 2.54 cm (exactly). This new standard was termed the Interna‐
tional Yard. Australia, Canada, and the UK then defined all customary
lengths in terms of the International Yard (Australia did not define
the furlong or rod); because many US land surveys were in terms of the
pre-1959 units, the US continued to define customary surveyors' units
(furlong, chain, rod, and link) in terms of the previous value for the
foot, which was termed the US survey foot. The US defined a US survey
mile as 5280 US survey feet, and defined a statute mile as a US survey
mile. The US values for these units differ from the international val‐
ues by about 2 ppm.
The 'units' program uses the international values for these units; the
US values can be obtained by using either the 'US' or the 'survey' pre‐
fix. In either case, the simple familiar relationships among the units
are maintained, e.g., 1 'furlong' = 660 'ft', and 1 'USfurlong' = 660
'USft', though the metric equivalents differ slightly between the two
cases. The 'US' prefix or the 'survey' prefix can also be used to
obtain the US survey mile and the value of the US yard prior to 1959,
e.g., 'USmile' or 'surveymile' (but not 'USsurveymile'). To get the US
value of the statute mile, use either 'USstatutemile' or 'USmile'.
Except for distances that extend over hundreds of miles (such as in the
US State Plane Coordinate System), the differences in the miles are
usually insignificant:
You have: 100 surveymile - 100 mile
You want: inch
* 12.672025
/ 0.078913984
The pre-1959 UK values for these units can be obtained with the prefix
'UK'.
In the US, the acre is officially defined in terms of the US survey
foot, but 'units' uses a definition based on the international foot.
If you want the official US acre use 'USacre' and similarly use
'USacrefoot' for the official US version of that unit. The difference
between these units is about 4 parts per million.
UNIT EXPRESSIONS
Operators
You can enter more complicated units by combining units with operations
such as powers, multiplication, division, addition, subtraction, and
parentheses for grouping. You can use the customary symbols for these
operators when 'units' is invoked with its default options. Addition‐
ally, 'units' supports some extensions, including high priority multi‐
plication using a space, and a high priority numerical
division operator ('|') that can simplify some expressions.
Powers of units can be specified using the '^' character as shown in
the following example, or by simple concatenation of a unit and its
exponent: 'cm3' is equivalent to 'cm^3'; if the exponent is more than
one digit, the '^' is required. An exponent like '2^3^2' is evaluated
right to left as usual. The '^' operator has the second highest
precedence. You can also use '**' as an exponent operator.
You have: cm^3
You want: gallons
* 0.00026417205
/ 3785.4118
You have: arabicfoot * arabictradepound * force
You want: ft lbf
* 0.7296
/ 1.370614
You multiply units using a space or an asterisk ('*'). The example
above shows both forms. You can divide units using the slash ('/') or
with 'per'.
You have: furlongs per fortnight
You want: m/s
* 0.00016630986
/ 6012.8727
When a unit includes a prefix, exponent operators apply to the combina‐
tion, so 'centimeter^3' gives cubic centimeters. If you separate the
prefix from the unit with any multiplication operator, such as 'centi
meter^3', then the prefix is treated as a separate unit, so the expo‐
nent does not apply. The second example would be a hundredth of a
cubic meter, not a centimeter.
Multiplication using a space has a higher precedence than division
using a slash and is evaluated left to right; in effect, the first '/'
character marks the beginning of the denominator of a unit expression.
This makes it simple to enter a quotient with several terms in the
denominator: 'W / m^2 Hz'. If you multiply with '*' then you must
group the terms in the denominator with parentheses: 'W / (m^2 * Hz)'.
The higher precedence of the space operator may not always be advanta‐
geous. For example, 'm/s s/day' is equivalent to 'm / s s day' and has
dimensions of length per time cubed. Similarly, '1/2 meter' refers to
a unit of reciprocal length equivalent to 0.5/meter, perhaps not what
you would intend if you entered that expression. The '*' operator is
convenient for multiplying a sequence of quotients. With the '*' oper‐
ator, the example above becomes 'm/s * s/day', which is equivalent to
'm/day'. Similarly, you could write '1/2 * meter' to get half a meter.
Alternatively, parentheses can be used for grouping: you could write
'(1/2) meter' to get half a meter. See Complicated Unit Expressions
for an illustration of the various options.
The 'units' program supports another option for numerical fractions.
You can indicate division of numbers with the vertical bar ('|'), so if
you wanted half a meter you could write '1|2 meter'. This operator has
the highest precedence, so you can write the square root of two thirds
'2|3^1|2'. You cannot use the vertical bar to indicate division of
non-numerical units (e.g., 'm|s' results in an error message).
You have: 1|2 inch
You want: cm
* 1.27
/ 0.78740157
You can use parentheses for grouping:
You have: (1/2) kg / (kg/meter)
You want: league
* 0.00010356166
/ 9656.0833
Sums and Differences of Units
You may sometimes want to add values of different units that are out‐
side the SI. You may also wish to use 'units' as a calculator that
keeps track of units. Sums of conformable units are written with the
'+' character, and differences with the '-' character.
You have: 2 hours + 23 minutes + 32 seconds
You want: seconds
* 8612
/ 0.00011611705
You have: 12 ft + 3 in
You want: cm
* 373.38
/ 0.0026782366
You have: 2 btu + 450 ft lbf
You want: btu
* 2.5782804
/ 0.38785542
The expressions that are added or subtracted must reduce to identical
expressions in primitive units, or an error message will be displayed:
You have: 12 printerspoint - 4 heredium
^
Illegal sum of non-conformable units
As usual, the precedence for '+' and '-' is lower than that of the
other operators. A fractional quantity such as 2 1/2 cups can be given
as '(2+1|2) cups'; the parentheses are necessary because multiplication
has higher precedence than addition. If you omit the parentheses,
'units' attempts to add '2' and '1|2 cups', and you get an error mes‐
sage:
You have: 2+1|2 cups
^
Illegal sum or difference of non-conformable units
The expression could also be correctly written as '(2+1/2) cups'. If
you write '2 1|2 cups' the space is interpreted as multiplication so
the result is the same as '1 cup'.
The '+' and '-' characters sometimes appears in exponents like
'3.43e+8'. This leads to an ambiguity in an expression like '3e+2 yC'.
The unit 'e' is a small unit of charge, so this can be regarded as
equivalent to '(3e+2) yC' or '(3 e)+(2 yC)'. This ambiguity is
resolved by always interpreting '+' and '-' as part of an exponent if
possible.
Numbers as Units
For 'units', numbers are just another kind of unit. They can appear as
many times as you like and in any order in a unit expression. For
example, to find the volume of a box that is 2 ft by 3 ft by 12 ft in
steres, you could do the following:
You have: 2 ft 3 ft 12 ft
You want: stere
* 2.038813
/ 0.49048148
You have: $ 5 / yard
You want: cents / inch
* 13.888889
/ 0.072
And the second example shows how the dollar sign in the units conver‐
sion can precede the five. Be careful: 'units' will interpret '$5'
with no space as equivalent to 'dollar^5'.
Built-in Functions
Several built-in functions are provided: 'sin', 'cos', 'tan', 'ln',
'log', 'log2', 'exp', 'acos', 'atan' and 'asin'. The 'sin', 'cos', and
'tan' functions require either a dimensionless argument or an argument
with dimensions of angle.
You have: sin(30 degrees)
You want:
Definition: 0.5
You have: sin(pi/2)
You want:
Definition: 1
You have: sin(3 kg)
^
Unit not dimensionless
The other functions on the list require dimensionless arguments. The
inverse trigonometric functions return arguments with dimensions of
angle.
If you wish to take roots of units, you may use the 'sqrt' or
'cuberoot' functions. These functions require that the argument have
the appropriate root. You can obtain higher roots by using fractional
exponents:
You have: sqrt(acre)
You want: feet
* 208.71074
/ 0.0047913202
You have: (400 W/m^2 / stefanboltzmann)^(1/4)
You have:
Definition: 289.80882 K
You have: cuberoot(hectare)
^
Unit not a root
Complicated Unit Expressions
The 'units' program is especially helpful in ensuring accuracy and
dimensional consistency when converting lengthy unit expressions. For
example, one form of the Darcy-Weisbach fluid-flow equation is
Delta P = (8 / pi)^2 (rho fLQ^2) / d^5,
where Delta P is the pressure drop, rho is the mass density, f is the
(dimensionless) friction factor, L is the length of the pipe, Q is the
volumetric flow rate, and d is the pipe diameter. It might be desired
to have the equation in the form
Delta P = A1 rho fLQ^2 / d^5
that accepted the user's normal units; for typical units used in the
US, the required conversion could be something like
You have: (8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)
You want: psi
* 43.533969
/ 0.022970568
The parentheses allow individual terms in the expression to be entered
naturally, as they might be read from the formula. Alternatively, the
multiplication could be done with the '*' rather than a space; then
parentheses are needed only around 'ft^3/s' because of its exponent:
You have: 8/pi^2 * lbm/ft^3 * ft * (ft^3/s)^2 /in^5
You want: psi
* 43.533969
/ 0.022970568
Without parentheses, and using spaces for multiplication, the previous
conversion would need to be entered as
You have: 8 lb ft ft^3 ft^3 / pi^2 ft^3 s^2 in^5
You want: psi
* 43.533969
/ 0.022970568
Backwards Compatibility:
'*' and '-' The original 'units' assigned multiplication a higher
precedence than division using the slash. This differs from the usual
precedence rules, which give multiplication and division equal prece‐
dence, and can be confusing for people who think of units as a calcula‐
tor.
The star operator ('*') included in this 'units' program has, by
default, the same precedence as division, and hence follows the usual
precedence rules. For backwards compatibility you can invoke 'units'
with the '--oldstar' option. Then '*' has a higher precedence than
division, and the same precedence as multiplication using the space.
Historically, the hyphen ('-') has been used in technical publications
to indicate products of units, and the original 'units' program treated
it as a multiplication operator. Because 'units' provides several
other ways to obtain unit products, and because '-' is a subtraction
operator in general algebraic expressions, 'units' treats the binary
'-' as a subtraction operator by default. For backwards compatibility
use the '--product' option, which causes 'units' to treat the binary
'-' operator as a product operator. When '-' is a multiplication oper‐
ator it has the same precedence as multiplication with a space, giving
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
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.
NONLINEAR UNIT CONVERSIONS
Nonlinear units are represented using functional notation. They make
possible nonlinear unit conversions such as temperature.
Temperature Conversions
Conversions between temperatures are different from linear conversions
between temperature increments—see the example below. The absolute
temperature conversions are handled by units starting with 'temp', and
you must use functional notation. The temperature-increment conver‐
sions are done using units starting with 'deg' and they do not require
functional notation.
You have: tempF(45)
You want: tempC
7.2222222
You have: 45 degF
You want: degC
* 25
/ 0.04
Think of 'tempF(x)' not as a function but as a notation that indicates
that x should have units of 'tempF' attached to it. See Defining Non‐
linear Units. The first conversion shows that if it's 45 degrees
Fahrenheit outside, it's 7.2 degrees Celsius. The second conversion
indicates that a change of 45 degrees Fahrenheit corresponds to a
change of 25 degrees Celsius. The conversion from 'tempF(x)' is to
absolute temperature, so that
You have: tempF(45)
You want: degR
* 504.67
/ 0.0019814929
gives the same result as
You have: tempF(45)
You want: tempR
* 504.67
/ 0.0019814929
But if you convert 'tempF(x)' to 'degC', the output is probably not
what you expect:
You have: tempF(45)
You want: degC
* 280.37222
/ 0.0035666871
The result is the temperature in K, because 'degC' is defined as 'K',
the Kelvin. For consistent results, use the 'tempX' units when convert‐
ing to a temperature rather than converting a temperature increment.
Other Nonlinear Units
Some other examples of nonlinear units are numerous different ring
sizes and wire gauges, the grit sizes used for abrasives, the decibel
scale, shoe size, scales for the density of sugar (e.g. baume). The
standard data file also supplies units for computing the area of a cir‐
cle and the volume of a sphere. See the standard units data file for
more details. Wire gauges with multiple zeroes are signified using
negative numbers where two zeroes is '-1'. Alternatively, you can use
the synonyms 'g00', 'g000', and so on that are defined in the standard
units data file.
You have: wiregauge(11)
You want: inches
* 0.090742002
/ 11.020255
You have: brwiregauge(g00)
You want: inches
* 0.348
/ 2.8735632
You have: 1 mm
You want: wiregauge
18.201919
You have: grit_P(600)
You want: grit_ansicoated
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
USA standard.
You can compute the area of a circle using the nonlinear unit,
'circlearea'. You can also do this using the circularinch or cir‐
cleinch. The next example shows two ways to compute the area of a cir‐
cle with a five inch radius and one way to compute the volume of a
sphere with a radius of one meter.
You have: circlearea(5 in)
You want: in2
* 78.539816
/ 0.012732395
You have: 10^2 circleinch
You want: in2
* 78.539816
/ 0.012732395
You have: spherevol(meter)
You want: ft3
* 147.92573
/ 0.0067601492
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 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
* 12.28125
/ 0.081424936
Although you can similarly write a sum of units to convert to, the
result will not be the conversion to the units in the sum, but rather
the conversion to the particular sum that you have entered:
You have: 12.28125 ft
You want: ft + in + 1|8 in
* 11.228571
/ 0.089058524
The unit expression given at the 'You want:' prompt is equivalent to
asking for conversion to multiples of '1 ft + 1 in + 1|8 in', which is
1.09375 ft, so the conversion in the previous example is equivalent to
You have: 12.28125 ft
You want: 1.09375 ft
* 11.228571
/ 0.089058524
In converting to a sum of units like miles, feet and inches, you typi‐
cally want the largest integral value for the first unit, followed by
the largest integral value for the next, and the remainder converted to
the last unit. You can do this conversion easily with 'units' using a
special syntax for lists of units. You must list the desired units in
order from largest to smallest, separated by the semicolon (';') char‐
acter:
You have: 12.28125 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3|8 in
The conversion always gives integer coefficients on the units in the
list, except possibly the last unit when the conversion is not exact:
You have: 12.28126 ft
You want: ft;in;1|8 in
12 ft + 3 in + 3.00096 * 1|8 in
The order in which you list the units is important:
You have: 3 kg
You want: oz;lb
105 oz + 0.051367866 lb
You have: 3 kg
You want: lb;oz
6 lb + 9.8218858 oz
Listing ounces before pounds produces a technically correct result, but
not a very useful one. You must list the units in descending order of
size in order to get the most useful result.
Ending a unit list with the separator ';' has the same effect as
repeating the last unit on the list, so 'ft;in;1|8 in;' is equivalent
to 'ft;in;1|8 in;1|8 in'. With the example above, this gives
You have: 12.28126 ft
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 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
12 ft + 3 in + 3|8 in (rounded down to nearest 1|8 in)
When you use the '-r' option, repeating the last unit on the list has
no effect (e.g., 'ft;in;1|8 in;1|8 in' is equivalent to 'ft;in;1|8
in'), and hence neither does ending a list with a ';'. With a single
unit and the '-r' option, a terminal ';' does have an effect: it causes
'units' to treat the single unit as a list and produce a rounded value
for the single unit. Without the extra ';', the '-r' option has no
effect on single unit conversions. This example shows the output using
the '-r' option:
You have: 12.28126 ft
You want: in
* 147.37512
/ 0.0067854058
You have: 12.28126 ft
You want: in;
147 in (rounded down to nearest in)
Each unit that appears in the list must be conformable with the first
unit on the list, and of course the listed units must also be conform‐
able with the You have unit that you enter.
You have: meter
You want: ft;kg
^
conformability error
ft = 0.3048 m
kg = 1 kg
You have: meter
You want: lb;oz
conformability error
1 m
0.45359237 kg
In the first case, 'units' reports the disagreement between units
appearing on the list. In the second case, 'units' reports disagree‐
ment between the unit you entered and the desired conversion. This
conformability error is based on the first unit on the unit list.
Other common candidates for conversion to sums of units are angles and
time:
You have: 23.437754 deg
You want; deg;arcmin;arcsec
23 deg + 26 arcmin + 15.9144 arcsec
You have: 7.2319 hr
You want: hr;min;sec
7 hr + 13 min + 54.84 sec
In North America, recipes for cooking typically measure ingredients by
volume, and use units that are not always convenient multiples of each
other. Suppose that you have a recipe for 6 and you wish to make a
portion for 1. If the recipe calls for 2 1/2 cups of an ingredient,
you might wish to know the measurements in terms of measuring devices
you have available, you could use 'units' and enter
You have: (2+1|2) cup / 6
You want: cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp
1|3 cup + 1 tbsp + 1 tsp
By default, if a unit in a list begins with fraction of the form 1|x
and its multiplier is an integer, the fraction is given as the product
of the multiplier and the numerator; for example,
You have: 12.28125 ft
You want: ft;in;1|8 in;
12 ft + 3 in + 3|8 in
In many cases, such as the example above, this is what is wanted, but
sometimes it is not. For example, a cooking recipe for 6 might call
for 5 1/4 cup of an ingredient, but you want a portion for 2, and your
1-cup measure is not available; you might try
You have: (5+1|4) cup / 3
You want: 1|2 cup;1|3 cup;1|4 cup
3|2 cup + 1|4 cup
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
You have: (5+1|4) cup / 3
You want: 1|2 cup;1|3 cup;1|4 cup
3 * 1|2 cup + 1|4 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.
Some applications for unit lists may be less obvious. Suppose that you
have a postal scale and wish to ensure that it's accurate at 1 oz, but
have only metric calibration weights. You might try
You have: 1 oz
You want: 100 g;50 g; 20 g;10 g;5 g;2 g;1 g;
20 g + 5 g + 2 g + 1 g + 0.34952312 * 1 g
You might then place one each of the 20 g, 5 g, 2 g, and 1 g weights on
the scale and hope that it indicates close to
You have: 20 g + 5 g + 2 g + 1 g
You want: oz;
0.98767093 oz
Appending ';' to 'oz' forces a one-line display that includes the unit;
here the integer part of the result is zero, so it is not displayed.
A unit list such as
cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp
can be tedious to enter. The 'units' program provides shorthand names
for some common combinations:
hms hours, minutes, seconds
dms angle: degrees, minutes, seconds
time years, days, hours, minutes and seconds
usvol US cooking volume: cups and smaller
Using these shorthands, or unit list aliases, you can do the following
conversions:
You have: anomalisticyear
You want: time
1 year + 25 min + 3.4653216 sec
You have: 1|6 cup
You want: usvol
2 tbsp + 2 tsp
You cannot combine a unit list alias with other units: it must appear
alone at the 'You want:' prompt.
You can display the definition of a unit list alias by entering it at
the 'You have:' prompt:
You have: dms
Definition: unit list, deg;arcmin;arcsec
When you specify compact output with '--compact', '--terse' or '-t' and
perform conversion to a unit list, 'units' lists the conversion factors
for each unit in the list, separated by semicolons.
You have: year
You want: day;min;sec
365;348;45.974678
Unlike the case of regular output, zeros are included in this output
list:
You have: liter
You want: cup;1|2 cup;1|4 cup;tbsp
4;0;0;3.6280454
INVOKING UNITS
You invoke 'units' like this:
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
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.
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
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
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-
format' and '--exponential') are given in combination, behavior is con‐
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
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
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
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,
'-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
known to this precision, the physically meaningful precision may
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
the '--output-format' option.
-o format, --output-format format
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
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
'-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‐
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‐
cision more simply with the '--digits' option or select exponen‐
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
specify 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 per‐
sonal 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 oth‐
ers specified with '-f'.
-h, --help
Print out a summary of the options for 'units'.
-m, --minus
Causes '-' to be interpreted as a subtraction operator. This is
the default behavior.
-p, --product
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
subtraction operator.
--oldstar
Causes '*' to have the old-style precedence, higher than the
precedence of division so that '1/2*3' will equal '1/6'.
--newstar
Forces '*' to have the new (default) precedence that follows the
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
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
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
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 speci‐
fies '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'.
-v, --verbose
Give slightly more verbose output when converting units. When
combined with the '-c' option this gives the same effect as
'--check-verbose'.
-V, --version
Print program version number, tell whether the 'readline'
library has been included, and give the location of the default
units data file.
-l locale, --locale locale
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.
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'.
Although you can extend or modify this data file if you have appropri‐
ate user privileges, it's usually better to put extensions in separate
files so that the definitions will be preserved when you update
'units'.
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
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
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.
(Under Windows the personal units file is named 'unitdef.units'.)
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' and 'HOMEPATH'. Running 'units -V' will display the
location and name of your personal units file.
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 without searching your home directory.
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‐
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
path. The name of the file to be included cannot contain 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' would be
valid names but 'foo2' or 'foo_a2' would be invalid. You could define
nitrous oxide as
N2O nitrogen 2 + oxygen
but would need to define nitrogen dioxide as
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'
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
printed will be the unit that caused the infinite loop.
If you define any units that contain '+' characters, 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 multiplication 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 precedence values and may require
parentheses to ensure consistent behavior. To compute the difference
of 'foo' and 'bar' write 'foo+(-bar)' or even 'foo+-bar'.
Here is an example of a short data file that defines some basic units:
m ! # The meter is a primitive unit
sec ! # The second is a primitive unit
rad !dimensionless # A dimensionless primitive unit
micro- 1e-6 # Define a prefix
minute 60 sec # A minute is 60 seconds
hour 60 min # An hour is 60 minutes
inch 0.0254 m # Inch defined in terms of meters
ft 12 inches # The foot defined in terms of inches
mile 5280 ft # And the mile
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)'.
Defining Nonlinear Units
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‐
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 data file, so that an eventual conversion to primitive
units is possible.
Here is an example nonlinear unit definition:
tempF(x) units=[1;K] (x+(-32)) degF + stdtemp ; \
(tempF+(-stdtemp))/degF + 32
A nonlinear unit definition comprises a unit name, a dummy parameter
name, two functions, and two corresponding units. The functions tell
'units' how to convert to and from the new unit. In order to produce
valid results, the arguments of these functions need to have the cor‐
rect dimensions. To facilitate error checking, you may optionally
indicate units for these arguments.
The definition begins with the unit name followed immediately (with no
spaces) by a '(' character. In parentheses is the name of the parame‐
ter. Next is an optional specification of the units required by the
functions in this definition. In the example above, the 'tempF' func‐
tion requires an input argument conformable with '1'. For normal non‐
linear units definitions the forward function will always take a dimen‐
sionless argument. The inverse function requires an input argument
conformable with 'K'. In general the inverse function will need units
that match the quantity measured by your nonlinear unit. The purpose
of the expression in brackets to enable 'units' to perform error check‐
ing on function arguments, and also to assign units to range and domain
specifications, which are described later.
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
tempF to other units.
In order to make conversions to Fahrenheit possible, 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, but then conversions to the
unit will be impossible. If the inverse is omitted then 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 one point and prints an error if
it is not valid there, but this is not a guarantee that your inverse is
correct.
If you wish to make synonyms for nonlinear units, you still need to
define both the forward 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)
You may define a function whose range and domain do not cover all of
the real numbers. In this case 'units' can handle errors better if you
specify an appropriate range and domain. You specify the range and
domain 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 the 'domain=' with the
endpoints given in brackets. One of the end points can be omitted to
get an interval that goes to infinity. So the range could be specified
as nonnegative by writing 'range=[0,]'. Both the range and domain are
optional and can appear independently and in any order along with the
'units' specification. The values in the range and domain are attached
to the units given in the 'units' specification. If you don't specify
the units then the parameter inputs are reduced to primitive units for
the numeric comparison to the values you give in the range or domain.
In this case you should only use 'range' or 'domain' if the endpoints
are zero and infinity.
Specifying the range and domain allows 'units' to perform better error
checking and give more helpful error messages when you invoke nonlinear
units conversions outside of their bounds. It also enables the '-c'
option to find a point in the domain to use for its point check of your
inverse definition.
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‐
sages.
circlearea(r) units=[m;m^2] range=[0,] pi r^2 ; sqrt(circlearea/pi)
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
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
to the numbers in the table. No spaces can appear before the ']' char‐
acter, so a definition like 'foo[kg meters]' is illegal; 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
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
as
zincgauge[in] \
1 0.002 \
10 0.02 \
15 0.04 \
19 0.06 \
23 0.1
With the preceding definition, the following conversion can be per‐
formed:
You have: zincgauge(10)
You want: in
* 0.02
/ 50
You have: .01 inch
You want: zincgauge
5
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. The
'--check' option will print a warning if a non-monotonic piecewise lin‐
ear unit is encountered.
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
included in the standard units data file are
!unitlist hms hr;min;sec
!unitlist time year;day;hr;min;sec
!unitlist dms deg;arcmin;arcsec
!unitlist ftin ft;in;1|8 in
!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
not have been shortened to 'year;day;hms'. 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
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
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
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
inapplicable and are not allowed.
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
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
but zeros.
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‐
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
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
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
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
when displaying large numbers in fixed-point decimal; for example, with
the format '%f',
You have: mile
You want: microfurlong
* 8000000.000000
/ 0.000000
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'
might be
You have: mile
You want: microfurlong
* 8,000,000.000000
/ 0.000000
making the magnitude readily apparent. Unfortunately, few compilers
support the digit-grouping flag.
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
You want: grain
* 5760.000000
/ 0000.000174
The '0' flag has no effect if the '-' (left align) flag is given.
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 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‐
tudes of results. For example, with the format '%12.6f',
You have: km
You want: in
* 39370.078740
/ 0.000025
You have: km
You want: rod
* 198.838782
/ 0.005029
You have: km
You want: furlong
* 4.970970
/ 0.201168
Precision
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‐
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'
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.
In some cases, specifying excess precision can result in rounding arti‐
facts. For example, a pound is exactly 7000 grains, but with the for‐
mat '%.18g', the output might be
You have: pound
You want: grain
* 6999.9999999999991
/ 0.00014285714285714287
With the format '%.25g' you might get the following:
You have: 1/3
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
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
meaningful digits may be less than the number of digits shown.
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
given.
LOCALIZATION
Some units have different values in different locations. The localiza‐
tion feature accommodates this by allowing a units data file to specify
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‐
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
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' in the same directory, typically '/usr/local/share/units',
as the default units data files. The file includes entries for many
combinations of language and country, and can be extended to include
other combinations. The 'locale.map' comprises two tab-separated col‐
umns; 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
the United States is
English_United States en_US
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
'!endlocale'. Here is an example, which defines the British gallon.
!locale en_GB
gallon 4.54609 liter
!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
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
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,
had a different length based on a french foot. These customary defini‐
tions could be accommodated as follows:
!var INCH_UNIT usa
yard 3600|3937 m
!endvar
!var INCH_UNIT canada
yard 0.9144 meter
!endvar
!var INCH_UNIT uk
yard 0.91439841 meter
!endvar
!var INCH_UNIT canada uk usa
foot 1|3 yard
inch 1|12 foot
!endvar
!var INCH_UNIT france
foot 144|443.296 m
inch 1|12 foot
line 1|12 inch
!endvar
!varnot INCH_UNIT usa uk france canada
!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
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
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
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
example with suitable locales you could do by preceding the above defi‐
nition with the following:
!locale en_US
!set INCH_UNIT usa
!endlocale
!locale en_GB
!set INCH_UNIT uk
!endlocale
!locale en_CA
!set INCH_UNIT canada
!endlocale
!locale fr_FR
!set INCH_UNIT france
!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
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
definitions.
ENVIRONMENT VARIABLES
The 'units' program uses the following environment variables:
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, 'units' tries to determine your home
directory from the 'HOMEDRIVE' and 'HOMEPATH' environment vari‐
ables if 'HOME' does not exist.
LC_CTYPE, LANG
Checked to determine the locale if 'units' cannot obtain it from
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
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
and calls the pager using the '+n'n syntax for specifying a line
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
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
('units -f ""').
UNICODE SUPPORT
The standard units data file is in Unicode, using UTF-8 encoding. Most
definitions use only ASCII characters (i.e., code points U+0000 through
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 if the character
set is UTF-8, 'units' reads the UTF-8 definitions; otherwise these def‐
initions 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.
Typeset material other than code examples usually uses the Unicode
minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D)
used in 'units'; the figure dash (U+2012) and en dash (U+2013) are also
occasionally used. To allow such material to be copied and pasted for
interactive use or in units data files, 'units' converts these charac‐
ters to U+002D before further processing. Because of this, none of
these characters can appear in unit names.
READLINE SUPPORT
If the 'readline' package has been compiled in, then when 'units' is
used interactively, numerous command line editing features are avail‐
able. To check if your version of 'units' includes 'readline', invoke
the program with the '--version' option.
For complete information about 'readline', consult the documentation
for the 'readline' package. Without any configuration, 'units' will
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
'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:
You have: metr
metre metriccup metrichorsepower metrictenth
metretes metricfifth metricounce metricton
metriccarat metricgrain metricquart metricyarncount
You have: metr
If there is a unique way to complete a unitname, you can hit the TAB
key and 'units' will provide the rest of the unit name. If 'units'
beeps, it means that there is no unique completion. Pressing the TAB
key a second time will print the list of all completions.
UPDATING CURRENCY EXCHANGE RATES
The units program includes currency exchange rates and prices for some
precious metals in the database. Of course, these values change over
time, sometimes very rapidly, and 'units' cannot provide real time val‐
ues. To update the exchange rates run the 'units_cur', which rewrites
the files containing the currency rates, typically
'/usr/local/share/units/currency.units'. This program must be run with
suitable permissions to write the file. To keep the rates updated
automatically, it could be run by a cron job on a Unix-like system, or
a similar scheduling program on a different system. Currency exchange
rates are taken from Time Genie (http://www.timegenie.com) and precious
metals pricing from Packetizer (www.packetizer.com). These sites
update once per day, so there is no benefit in running the update
script more often than daily. You can run 'units_cur' with a filename
specified on the command line and it will write the data to that file.
If you give '-' for the file it will write to standard output.
DATABASE COMMAND SYNTAX
unit definition
Define a regular unit.
prefix- definition
Define a prefix.
funcname(var) units=[in-units,out-units] domain=[x1,x2] range=[y1,y2]
definition(var) ; inverse(funcname)
Define a nonlinear unit or unit function. The three optional
keywords 'units=', 'range=' and 'domain=' can appear in any
order. The definition of the inverse is optional.
tabname[out-units] pair-list
Define a piecewise linear unit. The pair list gives the points
on the table listed in ascending order.
!endlocale
End a block of definitions beginning with '!locale'
!endutf8
End a block of definitions begun with '!utf8'
!endvar
End a block of definitions begun with '!var' or '!varnot'
!include file
Include the specified file.
!locale value
Load the following definitions only of the locale is set to
value.
!message text
Display text when the database is read unless the quiet option
('-q') is enabled.
!set variable value
Sets the environment variable, variable, to the specified value
only if it is not already set.
!unitlist alias definition
Define a unit list alias.
!utf8 Load the following definitions only if 'units' is running with
UTF-8 enabled.
!var variable value-list
Load the following definitions only if the environment variable,
variable is set to one of the values listed on the space sepa‐
rated value list. If variable is not set then 'units' prints an
error message and ignores the following definitions.
!varnot variable value-list
Load the following definitions only if the environment variable,
variable is not set to one of the values listed on the space
separated value list. If variable is not set then 'units'
prints an error message and ignores the following definitions.
GNU FREE DOCUMENTATION LICENSE
FILES
/usr/local/share/units/definitions.units — the standard units data file
AUTHOR
7 June 2013 UNITS(1)
units-2.02/INSTALL 0000664 0001750 0001750 00000017051 10232761036 013114 0 ustar adrian adrian Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
units-2.02/getopt.h 0000664 0001750 0001750 00000010661 12040123025 013523 0 ustar adrian adrian /* Declarations for getopt.
Copyright (C) 1989, 90, 91, 92, 93, 94 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 the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */
#ifdef STRINGS_H
# include
#else
# include
#endif
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#if defined (__STDC__) && __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */
units-2.02/units.dvi 0000664 0001750 0001750 00000643754 12167664613 013764 0 ustar adrian adrian ; TeX output 2013.07.11:2227 33GGN j cmbx12GUnitsƧConZversionG 2K`y
3
cmr10Editionf2.02for3