Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/units Improve previous slightly; while we accept e.g...



details:   https://anonhg.NetBSD.org/src/rev/494a9739e6e0
branches:  trunk
changeset: 343454:494a9739e6e0
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Feb 05 03:32:49 2016 +0000

description:
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.

diffstat:

 usr.bin/units/units.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (19 lines):

diff -r 8a6926fd2224 -r 494a9739e6e0 usr.bin/units/units.c
--- a/usr.bin/units/units.c     Fri Feb 05 03:30:08 2016 +0000
+++ b/usr.bin/units/units.c     Fri Feb 05 03:32:49 2016 +0000
@@ -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 (adrian%cam.cornell.edu@localhost)
@@ -455,7 +455,8 @@
                                        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--;
                                        }



Home | Main Index | Thread Index | Old Index