From 0ce97bdf81ccce1dd8b10f8b760902e45f112028 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Sat, 5 Jul 2014 03:25:26 +0000 Subject: [PATCH] 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. --- usr.bin/units/units.1 | 2 +- usr.bin/units/units.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/units/units.1 b/usr.bin/units/units.1 index 4b73da4eb09..a7173a5c586 100644 --- a/usr.bin/units/units.1 +++ b/usr.bin/units/units.1 @@ -149,7 +149,7 @@ The program will not detect infinite loops that could be caused by careless unit definitions. Comments in the unit definition file -begin with a '/' character at the beginning of a line. +begin with a '#' or '/' character at the beginning of a line. .Pp Prefixes are defined in the same was as standard units, but with a trailing dash at the end of the prefix name. diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c index f8e4f11bb24..94a976f98ce 100644 --- a/usr.bin/units/units.c +++ b/usr.bin/units/units.c @@ -166,7 +166,7 @@ readunits(const char *userfile) break; linenum++; lineptr = line; - if (*lineptr == '/') + if (*lineptr == '/' || *lineptr == '#') continue; lineptr += strspn(lineptr, " \n\t"); len = strcspn(lineptr, " \n\t");