Commit Graph

42 Commits

Author SHA1 Message Date
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Eitan Adler
943a127c89 units: fix some nits
- prefer braces to abusing the `,` operator
- mark dead function as dead
- remove dead break
2018-06-16 21:07:46 +00:00
Eitan Adler
9cd768a177 units(1): units(1) free savescr in error condition too
CID:		978392
Reviewed by:	des
MFC After:	1 week
2018-01-15 17:27:43 +00:00
Eitan Adler
21dc7ae75b units(1): add missing ':' for two short arguments
PR:		209850
MFC After:	3 days
2018-01-05 07:24:43 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Eitan Adler
c706c470e4 Bring a little more compability with GNU units 2.12
- notionally support a 'history file' flag. This doesn't do much now,
  but is there to prevent scripts written against GNU units from
  breaking
- correctly gracefully quit rather than exit (this will make it easier
  to support a history file in the future)
- remove the "t" flag from fopen which was there to support windows. We
  have not supported windows since at the latest, the introduction of
  capsicum.
2016-04-21 05:24:47 +00:00
Eitan Adler
3851177de0 Rename units.lib -> definitions.units
- this matches GNU units 2.12
add ISO country codes from units 2.12
2016-04-19 05:17:59 +00:00
Eitan Adler
8ae87993ed Remove pathnames.h
- it only holds a single constant
- it doesn't exist in the GNU variant
2016-04-19 05:04:39 +00:00
Edward Tomasz Napierala
840a09d240 Fix interaction between libedit initialization and Capsicum
in units(1). The most visible is the removal of libedit warnings
about being unable to open termcap database.

Reviewed by:	eadler@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3322
2015-08-08 10:38:37 +00:00
Julio Merino
619e4f78fe Only initialize libedit when necessary
The code path to support units conversions from the command line
need not initialize neither libedit nor the history.  Therefore, only do
that when in interactive mode.

This hides the issue reported in PR bin/201167 whereby running commands
of the form 'echo "$(units ft in)"' would corrupt the terminal.  The real
issue causing the corruption most likely still remains somewhere.

PR:		bin/201167
Differential Revision:	D2935
Reviewed by:	eadler
2015-06-28 16:43:07 +00:00
Eitan Adler
cae148478c units(1): Add support for output-format
Add support for the output-format argument.  This also exposes subtle
	rounding differences between GNU units and our units.
2014-07-17 06:54:12 +00:00
Eitan Adler
1dd5886f98 units(1): Clean up
Remove unused constant.  Add 'static' where able.
2014-07-05 03:49:20 +00:00
Eitan Adler
0ce97bdf81 units: Support start of line comments with '#'
Modern GNU units(1) supports comments anywhere with '#' but take the easy route for now and at least support start of line # comments.
2014-07-05 03:25:26 +00:00
Eitan Adler
8d61f393a3 units(1): Add 'terse' support
terse output is used when calling units from another script.
2014-07-05 03:17:57 +00:00
Eitan Adler
a913717b0d units(1): Add 'help' flag
- Add support for --help for compatibility
	- Make usage() static
2014-07-04 22:19:21 +00:00
Eitan Adler
5192ff4547 units(1): add long options
Things brings additional compatibility with units 2.10

Discussed with:	wblock (man page)
2014-07-04 21:21:05 +00:00
Eitan Adler
87ddbe8241 units(1): Fix minor typos
Obtained From:	DragonflyBSD
2014-05-15 05:35:00 +00:00
Eitan Adler
373ca6f9ff units(1): call el_end()
Add missing el_end() call
2014-05-12 07:14:09 +00:00
Eitan Adler
db9def8b0a units(1): unbreak -f option, fix some style, increase compatibility.
- Unbreak the -f option: it was missing a ':'
- gunits -V spits out more information than just its version: attempt to do so
  as well.
2014-05-12 06:14:14 +00:00
Eitan Adler
cfa8c23640 units(1): use common functions
No need to replicate strdup
2014-05-12 05:44:55 +00:00
Eitan Adler
956c78c92b units(1): don't compare pointers with 0
For better readability, don't compare pointers with 0 or assign 0
to them. Use NULL instead.

Inspired by:	DragonflyBSD
2014-04-14 21:09:47 +00:00
Eitan Adler
dc8c916dcd units(1): Add 'static' and sort list.
Inspired by:	DragonflyBSD
2014-04-14 21:07:54 +00:00
Eitan Adler
9653775e6b units(1): Add v option: verbose
For increased compatibility with GNU units: support a -v option which
produces more verbose output when spitting out the answer.
GNU -v does additional work in the version, information, and check output which
we do not (yet?) replicate.
2014-04-14 20:51:04 +00:00
Eitan Adler
114022f58e units(1): Add U option
For increased compatibility with GNU units: support a -U option which tests for the
existence of the default units file and prints it to the screen.
2014-04-14 16:55:09 +00:00
Eitan Adler
3af082017a units(1): support reading multiple units files
GNU units(1) supports reading up to 25 -f options.  We support an arbitrary
number.
2014-04-14 16:43:36 +00:00
Eitan Adler
cada55282a units(1): parse config file after setting defaults
Parse the config file after setting the defaults to permit the user to change
things (e.g., editing mode)
2014-04-14 14:40:12 +00:00
Eitan Adler
647be2c3a9 units(1): add libedit support
Add line editing and history support to units(1) via libedit.

Reviewed by:	bdrewery
2014-04-14 14:04:59 +00:00
Eitan Adler
6d12a83408 units(1): make -V print version instead of -v
The units program is likely little used.  It is even less likely that a script
will want the units program to print out its version number by passing -v.

GNU units uses -V for version and -v for verbosity.

Increase compatibility between these two versions (written by the same author)
by switching our flag as well.

Take this opportunity to remove bogus information about the version number and
just call it 'FreeBSD units'.

Discussed with:	cperciva, rwatson
2014-04-07 02:31:10 +00:00
Eitan Adler
ac117d5d7e add capsicum to units(1) 2014-03-30 16:04:47 +00:00
Ed Schouten
90a29505f5 Add missing static keywords to units(1) 2011-11-06 08:18:17 +00:00
David Malone
9c95bc1c1c Add limited support for units that are related by affine rather
than linear relations. We can now convert degC to degF.

586 units, 56 prefixes
You have: 24 degC
You want: degF
	75.2
You have: degC
You want: K
	 (-> x*1 +273.15)
	 (<- y*1 -273.15)
2008-08-16 16:27:41 +00:00
David Malone
50bb77244e Add enough consts to keep everyone happy. 2002-07-28 16:23:28 +00:00
David Malone
5386636d3e Add prototypes and turn on WARNS=?2. 2001-06-24 12:23:54 +00:00
David Malone
17ad860f81 Give units a bit of a cleanup:
1) Fix a bug where the recursion on prefixes where if recusrion failed
	then the next attempt started too far along the string.
2) Up some internal limits that we were about to hit off.
3) Change the constness and signedness of some things and complete missing
	prototypes.
4) Remove the readerror function 'cos it could print out the wrong
	wrong file name. Replace it with more useful error messages.
5) Use sizeof when passing buffers to fgets.
6) Warn about empty prefix definitions.

Reviewed by:	iedowse
2001-02-28 15:57:38 +00:00
Kris Kennaway
ffd044a699 Don't segv when trying to add a 0-length unit name.
Some string-related cleanups inspired by OpenBSD.

Reviewed by:	asmodai
2000-07-31 10:49:08 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Philippe Charnier
d4d0763a7d Use err(3). Cosmetic in usage(). Rewrote man page in mdoc format. 1997-08-21 06:49:33 +00:00
Peter Wemm
c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Alexander Langer
4c0c227d97 Fix exit code when used in non-interactive mode.
Remove ';' typo attached to if statement.
1996-06-08 04:30:06 +00:00
Alexander Langer
a303171509 Units conversion utility courtesy of NetBSD.
Submitted by:	Jeremy Prior
Obtained from:	NetBSD
1996-06-08 03:43:43 +00:00