summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2004-01-31 23:16:09 +0000
committerDavid Schultz <das@FreeBSD.org>2004-01-31 23:16:09 +0000
commitff81345642975c97a2f7ecf37920b94df4921369 (patch)
treef6a61d0c8b46b5a894d75d341e48c86f111732cd /lib/libc
parent26518e8d8ca5a10bf3f7a9214416328b6dfcdeff (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdio/vfscanf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index a6c8d0ec0711..dabf16ec633e 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$");
#define NDIGITS 0x80 /* no digits detected */
#define PFXOK 0x100 /* 0x prefix is (still) legal */
#define NZDIGITS 0x200 /* no zero digits detected */
+#define HAVESIGN 0x10000 /* sign detected */
/*
* Conversion types.
@@ -679,13 +680,18 @@ literal:
case '+': case '-':
if (flags & SIGNOK) {
flags &= ~SIGNOK;
+ flags |= HAVESIGN;
goto ok;
}
break;
-
- /* x ok iff flag still set & 2nd char */
+
+ /*
+ * x ok iff flag still set & 2nd char (or
+ * 3rd char if we have a sign).
+ */
case 'x': case 'X':
- if (flags & PFXOK && p == buf + 1) {
+ if (flags & PFXOK && p ==
+ buf + 1 + !!(flags & HAVESIGN)) {
base = 16; /* if %i */
flags &= ~PFXOK;
goto ok;