History log of /openbsd-current/usr.bin/units/units.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.23 26-Dec-2022 florian

Implement support for personal units library.

With -f one could read an alternative library but it would replace the
standard units library, not add to it. Allow passing -f multiple times
to read all files and merge them together. Passing the empty string,
i.e. -f '' reads the default units library.

This is implemented in at least FreeBSD and Linux.

OK miod


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.22 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.21 06-Oct-2015 deraadt

tame "stdio rpath" before opening the file, tame "stdio" after that


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.20 27-Nov-2013 deraadt

unsigned char for ctype
ok okan


# 1.19 17-Nov-2013 okan

Include unistd.h as it is the standard location for getopt().

OK millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.18 04-Jan-2013 jmc

an undocumented feature of units was the ability to specify a prefix
in non-interactive mode. document that now, but also allow for the
prefix to be given without a need to quote it;

code lifted from atatat (netbsd -r1.10); otto helped me paste it in.

ok otto millert


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.17 07-Oct-2011 jmc

do not search PATH for a units datafile; from pjanzen


# 1.16 06-Oct-2011 jmc

just define UNITSFILE directly, and do away with the need for pathnames.h;
ok deraadt


# 1.15 06-Oct-2011 jmc

from pjanzen:
Bump MAXPREFIXES (and a few string lengths) prior to units.lib
commit of more prefixes. Add FreeBSD fixes (circa 2001) to prefix
and other units.lib parsing. Do minor obvious code tidying.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 29-Mar-2007 jmc

sync usage(); from Igor Sobrado


Revision tags: OPENBSD_4_1_BASE
# 1.13 24-Feb-2007 ray

- Don't access buffers with negative indexes.
- Save a ton of strlen calls.
- Return NULL pointer, not 0.

``boy there is a lot of strlen()'' millert@ and OK moritz@.


# 1.12 20-Feb-2007 ray

Change hard coded numbers to sizeof(buf). Also change some
sizeof(buf) - 1 to sizeof(buf), since fgets takes the whole buffer size.

Based on diff from Charles Longeau <chl at tuxfamily dot org> long ago.

OK millert@.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.11 02-Dec-2004 pat

* fix the duplicate prefix and duplicate unit parsing

with suggestion & ok millert


# 1.10 01-Dec-2004 pat

* plug memory leaks in the file parser and in the interactive mode parser

ok otto


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 02-Jul-2003 deraadt

cleanup


# 1.8 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.7 17-Jan-2001 deraadt

use more strlcpy()


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.6 13-Jun-1999 pjanzen

typo


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.5 08-Jul-1997 millert

- replace some strn?cpy/strn?cat pairs w/ snprintf
- strcpy() -> strncpy()


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.4 11-Aug-1996 deraadt

two fixes from freebsd plus some more by me


# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.22 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.21 06-Oct-2015 deraadt

tame "stdio rpath" before opening the file, tame "stdio" after that


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.20 27-Nov-2013 deraadt

unsigned char for ctype
ok okan


# 1.19 17-Nov-2013 okan

Include unistd.h as it is the standard location for getopt().

OK millert@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.18 04-Jan-2013 jmc

an undocumented feature of units was the ability to specify a prefix
in non-interactive mode. document that now, but also allow for the
prefix to be given without a need to quote it;

code lifted from atatat (netbsd -r1.10); otto helped me paste it in.

ok otto millert


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.17 07-Oct-2011 jmc

do not search PATH for a units datafile; from pjanzen


# 1.16 06-Oct-2011 jmc

just define UNITSFILE directly, and do away with the need for pathnames.h;
ok deraadt


# 1.15 06-Oct-2011 jmc

from pjanzen:
Bump MAXPREFIXES (and a few string lengths) prior to units.lib
commit of more prefixes. Add FreeBSD fixes (circa 2001) to prefix
and other units.lib parsing. Do minor obvious code tidying.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 29-Mar-2007 jmc

sync usage(); from Igor Sobrado


Revision tags: OPENBSD_4_1_BASE
# 1.13 24-Feb-2007 ray

- Don't access buffers with negative indexes.
- Save a ton of strlen calls.
- Return NULL pointer, not 0.

``boy there is a lot of strlen()'' millert@ and OK moritz@.


# 1.12 20-Feb-2007 ray

Change hard coded numbers to sizeof(buf). Also change some
sizeof(buf) - 1 to sizeof(buf), since fgets takes the whole buffer size.

Based on diff from Charles Longeau <chl at tuxfamily dot org> long ago.

OK millert@.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.11 02-Dec-2004 pat

* fix the duplicate prefix and duplicate unit parsing

with suggestion & ok millert


# 1.10 01-Dec-2004 pat

* plug memory leaks in the file parser and in the interactive mode parser

ok otto


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 02-Jul-2003 deraadt

cleanup


# 1.8 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.7 17-Jan-2001 deraadt

use more strlcpy()


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.6 13-Jun-1999 pjanzen

typo


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.5 08-Jul-1997 millert

- replace some strn?cpy/strn?cat pairs w/ snprintf
- strcpy() -> strncpy()


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.4 11-Aug-1996 deraadt

two fixes from freebsd plus some more by me


# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 21-Apr-1996 deraadt

sync to netbsd 960418


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision