aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/units/units.c
Commit message (Collapse)AuthorAgeFilesLines
* units(1): Refactor the manual page and update usage informationMateusz Piotrowski2020-02-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes to units.1: - Change the description to a more descriptive "conversion calculator". - Sort options. - Split the description into sections to make it easier to navigate the manual page. - Improve the description of various options. - Document the default value of the output format. - Use more mdoc macros for better readability. - Document the behavior of the PATH environmental variable. - Improve examples. - Add sections: EXIT STATUS, DIAGNOSTICS, and HISTORY. - Document that units(1) cannot convert negative values and it handles long unit lists poorly. - Update the documentation of the -V flag to match the implementation. units(1) prints its version and the units data file instead of its version and usage information. Changes to units.c: - Update usage information. - Sort longopts elements. This commit does not attempts to change the current behavior of units(1). What's left to do is probably defining a better versioning (at the moment units(1) always reports "FreeBSD units" as its version) and changing the behavior of the -V flag to only print version. Reviewed by: allanjude (earlier version), bcr Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D18977 Notes: svn path=/head/; revision=357449
* capsicum: use a new capsicum helpers in toolsMariusz Zaborski2018-11-041-2/+1
| | | | | | | Use caph_{rights,ioctls,fcntls}_limit to simplify the code. Notes: svn path=/head/; revision=340138
* Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.Mariusz Zaborski2018-06-191-3/+3
| | | | | | | No functional change intended. Notes: svn path=/head/; revision=335395
* units: fix some nitsEitan Adler2018-06-161-4/+5
| | | | | | | | | - prefer braces to abusing the `,` operator - mark dead function as dead - remove dead break Notes: svn path=/head/; revision=335265
* units(1): units(1) free savescr in error condition tooEitan Adler2018-01-151-2/+8
| | | | | | | | | CID: 978392 Reviewed by: des MFC After: 1 week Notes: svn path=/head/; revision=328008
* units(1): add missing ':' for two short argumentsEitan Adler2018-01-051-1/+1
| | | | | | | | PR: 209850 MFC After: 3 days Notes: svn path=/head/; revision=327578
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-1/+3
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326276
* Bring a little more compability with GNU units 2.12Eitan Adler2016-04-211-14/+31
| | | | | | | | | | | | | | - 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. Notes: svn path=/head/; revision=298388
* Rename units.lib -> definitions.unitsEitan Adler2016-04-191-1/+1
| | | | | | | | - this matches GNU units 2.12 add ISO country codes from units 2.12 Notes: svn path=/head/; revision=298253
* Remove pathnames.hEitan Adler2016-04-191-1/+1
| | | | | | | | - it only holds a single constant - it doesn't exist in the GNU variant Notes: svn path=/head/; revision=298251
* Fix interaction between libedit initialization and CapsicumEdward Tomasz Napierala2015-08-081-5/+7
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=286446
* Only initialize libedit when necessaryJulio Merino2015-06-281-13/+14
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=284912
* units(1): Add support for output-formatEitan Adler2014-07-171-14/+46
| | | | | | | | Add support for the output-format argument. This also exposes subtle rounding differences between GNU units and our units. Notes: svn path=/head/; revision=268792
* units(1): Clean upEitan Adler2014-07-051-18/+14
| | | | | | | Remove unused constant. Add 'static' where able. Notes: svn path=/head/; revision=268282
* units: Support start of line comments with '#'Eitan Adler2014-07-051-1/+1
| | | | | | | Modern GNU units(1) supports comments anywhere with '#' but take the easy route for now and at least support start of line # comments. Notes: svn path=/head/; revision=268278
* units(1): Add 'terse' supportEitan Adler2014-07-051-11/+20
| | | | | | | terse output is used when calling units from another script. Notes: svn path=/head/; revision=268277
* units(1): Add 'help' flagEitan Adler2014-07-041-2/+6
| | | | | | | | - Add support for --help for compatibility - Make usage() static Notes: svn path=/head/; revision=268271
* units(1): add long optionsEitan Adler2014-07-041-1/+11
| | | | | | | | | Things brings additional compatibility with units 2.10 Discussed with: wblock (man page) Notes: svn path=/head/; revision=268269
* units(1): Fix minor typosEitan Adler2014-05-151-2/+2
| | | | | | | Obtained From: DragonflyBSD Notes: svn path=/head/; revision=266117
* units(1): call el_end()Eitan Adler2014-05-121-0/+1
| | | | | | | Add missing el_end() call Notes: svn path=/head/; revision=265907
* units(1): unbreak -f option, fix some style, increase compatibility.Eitan Adler2014-05-121-6/+4
| | | | | | | | | - Unbreak the -f option: it was missing a ':' - gunits -V spits out more information than just its version: attempt to do so as well. Notes: svn path=/head/; revision=265904
* units(1): use common functionsEitan Adler2014-05-121-3/+2
| | | | | | | No need to replicate strdup Notes: svn path=/head/; revision=265903
* units(1): don't compare pointers with 0Eitan Adler2014-04-141-1/+1
| | | | | | | | | | For better readability, don't compare pointers with 0 or assign 0 to them. Use NULL instead. Inspired by: DragonflyBSD Notes: svn path=/head/; revision=264475
* units(1): Add 'static' and sort list.Eitan Adler2014-04-141-18/+18
| | | | | | | Inspired by: DragonflyBSD Notes: svn path=/head/; revision=264474
* units(1): Add v option: verboseEitan Adler2014-04-141-13/+36
| | | | | | | | | | 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. Notes: svn path=/head/; revision=264470
* units(1): Add U optionEitan Adler2014-04-141-2/+9
| | | | | | | | 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. Notes: svn path=/head/; revision=264463
* units(1): support reading multiple units filesEitan Adler2014-04-141-9/+12
| | | | | | | | GNU units(1) supports reading up to 25 -f options. We support an arbitrary number. Notes: svn path=/head/; revision=264462
* units(1): parse config file after setting defaultsEitan Adler2014-04-141-1/+1
| | | | | | | | Parse the config file after setting the defaults to permit the user to change things (e.g., editing mode) Notes: svn path=/head/; revision=264459
* units(1): add libedit supportEitan Adler2014-04-141-18/+47
| | | | | | | | | Add line editing and history support to units(1) via libedit. Reviewed by: bdrewery Notes: svn path=/head/; revision=264458
* units(1): make -V print version instead of -vEitan Adler2014-04-071-8/+4
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=264216
* add capsicum to units(1)Eitan Adler2014-03-301-0/+10
| | | | Notes: svn path=/head/; revision=263940
* Add missing static keywords to units(1)Ed Schouten2011-11-061-6/+6
| | | | Notes: svn path=/head/; revision=227194
* Add limited support for units that are related by affine ratherDavid Malone2008-08-161-17/+58
| | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=181786
* Add enough consts to keep everyone happy.David Malone2002-07-281-1/+1
| | | | Notes: svn path=/head/; revision=100826
* Add prototypes and turn on WARNS=?2.David Malone2001-06-241-0/+18
| | | | Notes: svn path=/head/; revision=78698
* Give units a bit of a cleanup:David Malone2001-02-281-32/+26
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=73229
* Don't segv when trying to add a 0-length unit name.Kris Kennaway2000-07-311-21/+20
| | | | | | | | | Some string-related cleanups inspired by OpenBSD. Reviewed by: asmodai Notes: svn path=/head/; revision=64053
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Use err(3). Cosmetic in usage(). Rewrote man page in mdoc format.Philippe Charnier1997-08-211-35/+24
| | | | Notes: svn path=/head/; revision=28502
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=23012
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=21673
* Fix exit code when used in non-interactive mode.Alexander Langer1996-06-081-3/+5
| | | | | | | Remove ';' typo attached to if statement. Notes: svn path=/head/; revision=16190
* Units conversion utility courtesy of NetBSD.Alexander Langer1996-06-081-0/+706
Submitted by: Jeremy Prior Obtained from: NetBSD Notes: svn path=/vendor/NetBSD/dist/; revision=16186