Module Name:    src
Committed By:   snj
Date:           Sat Sep 26 18:19:27 UTC 2009

Modified Files:
        src/bin/ksh [netbsd-5]: var.c

Log Message:
Pull up following revision(s) (requested by tron in ticket #889):
        bin/ksh/var.c: revision 1.15
Support 0xnn for hexadecimal constants - as well as 16#nn.
While here, make '-' only valid once, and at the start of the number.
Fixes PR/40512


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.26.1 src/bin/ksh/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/var.c
diff -u src/bin/ksh/var.c:1.14 src/bin/ksh/var.c:1.14.26.1
--- src/bin/ksh/var.c:1.14	Wed Mar 29 15:51:00 2006
+++ src/bin/ksh/var.c	Sat Sep 26 18:19:26 2009
@@ -1,9 +1,9 @@
-/*	$NetBSD: var.c,v 1.14 2006/03/29 15:51:00 christos Exp $	*/
+/*	$NetBSD: var.c,v 1.14.26.1 2009/09/26 18:19:26 snj Exp $	*/
 
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: var.c,v 1.14 2006/03/29 15:51:00 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.14.26.1 2009/09/26 18:19:26 snj Exp $");
 #endif
 
 
@@ -458,10 +458,17 @@
 	base = 10;
 	num = 0;
 	neg = 0;
+	if (*s == '-') {
+		neg = 1;
+		s++;
+	}
+	if (s[0] == '0' && s[1] == 'x') {
+		base = 16;
+		have_base = 1;
+		s += 2;
+	}
 	for (c = (unsigned char)*s++; c ; c = (unsigned char)*s++) {
-		if (c == '-') {
-			neg++;
-		} else if (c == '#') {
+		if (c == '#') {
 			base = (int) num;
 			if (have_base || base < 2 || base > 36)
 				return -1;

Reply via email to