Module Name: src
Committed By: dholland
Date: Fri Feb 5 03:32:49 UTC 2016
Modified Files:
src/usr.bin/units: units.c
Log Message:
Improve previous slightly; while we accept e.g. "meter2" to mean "meter^2",
don't allow "meter-2" to be interpreted as "meter^-2" as that's very
confusing.
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/units/units.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/units/units.c
diff -u src/usr.bin/units/units.c:1.26 src/usr.bin/units/units.c:1.27
--- src/usr.bin/units/units.c:1.26 Fri Feb 5 03:30:08 2016
+++ src/usr.bin/units/units.c Fri Feb 5 03:32:49 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: units.c,v 1.26 2016/02/05 03:30:08 dholland Exp $ */
+/* $NetBSD: units.c,v 1.27 2016/02/05 03:32:49 dholland Exp $ */
/*
* units.c Copyright (c) 1993 by Adrian Mariano ([email protected])
@@ -455,7 +455,8 @@ addunit(struct unittype * theunit, const
assert(pos > 0);
}
if (pos < len) {
- if (pos > 0 && item[pos - 1] == '-') {
+ if (pos > 1 && item[pos - 1] == '-' &&
+ item[pos - 2] == '^') {
/* allow negative exponents */
pos--;
}