-.\" $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)
.\" 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
.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.
-/* $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 $ */
/*
int len, linenum, i;
FILE *unitfile;
- unitcount = 0;
linenum = 0;
if (userfile) {
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;
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;
if (argc != 3 && argc != 2 && argc != 0)
usage();
- readunits(userfile);
+ if (!units_read)
+ readunits(NULL);
if (pledge("stdio", NULL) == -1)
err(1, "pledge");