mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-06 00:20:29 +00:00
Fix the handling of negative hexadecimal numbers in integer formats.
Note that this bug is unrelated to recent work in this area; it seems to have been present since revision 1.1. Obtained from: NetBSD
This commit is contained in:
parent
26518e8d8c
commit
ff81345642
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125282
|
@ -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 @@ again: c = *fmt++;
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue