summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/units/units.19
-rw-r--r--usr.bin/units/units.c12
2 files changed, 13 insertions, 8 deletions
diff --git a/usr.bin/units/units.1 b/usr.bin/units/units.1
index d7a45f729b3..d9178d4a534 100644
--- a/usr.bin/units/units.1
+++ b/usr.bin/units/units.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: units.1,v 1.27 2022/02/18 10:24:33 jsg Exp $
+.\" $OpenBSD: units.1,v 1.28 2022/12/26 18:52:10 florian Exp $
.\" converted to new format by deraadt@openbsd.org
.\"
.\" Copyright (c) 1993 by Adrian Mariano (adrian@cam.cornell.edu)
@@ -16,7 +16,7 @@
.\" I would appreciate (though I do not require) receiving a copy of any
.\" improvements you might make to this program.
.\"
-.Dd $Mdocdate: February 18 2022 $
+.Dd $Mdocdate: December 26 2022 $
.Dt UNITS 1
.Os
.Sh NAME
@@ -79,6 +79,11 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl f Ar filename
Specifies the name of the units data file to load.
+This option may be specified multiple times.
+The standard units library is read if
+.Ar filename
+is the empty string.
+This allows extending the standard units library with a personal library.
.It Fl q
Suppresses prompting of the user for units and the display of statistics
about the number of units loaded.
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index 98af5031fb1..8f93c3ad50b 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: units.c,v 1.22 2015/10/09 01:37:09 deraadt Exp $ */
+/* $OpenBSD: units.c,v 1.23 2022/12/26 18:52:10 florian Exp $ */
/* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */
/*
@@ -100,7 +100,6 @@ readunits(char *userfile)
int len, linenum, i;
FILE *unitfile;
- unitcount = 0;
linenum = 0;
if (userfile) {
@@ -626,8 +625,7 @@ main(int argc, char **argv)
struct unittype have, want;
char havestr[81], wantstr[81];
int optchar;
- char *userfile = 0;
- int quiet = 0;
+ int quiet = 0, units_read = 0;
extern char *optarg;
extern int optind;
@@ -638,7 +636,8 @@ main(int argc, char **argv)
while ((optchar = getopt(argc, argv, "vqf:")) != -1) {
switch (optchar) {
case 'f':
- userfile = optarg;
+ units_read = 1;
+ readunits(*optarg == '\0' ? NULL : optarg);
break;
case 'q':
quiet = 1;
@@ -662,7 +661,8 @@ main(int argc, char **argv)
if (argc != 3 && argc != 2 && argc != 0)
usage();
- readunits(userfile);
+ if (!units_read)
+ readunits(NULL);
if (pledge("stdio", NULL) == -1)
err(1, "pledge");