citrus_prop.c: do not ignore sign
In _citrus_prop_read_TYPE_func_ generated functions, do not ignore parsed '-' sign, negate the value as appropriate. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33146
This commit is contained in:
parent
a64a3b7988
commit
181751a8b6
@ -79,7 +79,7 @@ static const char *xdigit = "0123456789ABCDEF";
|
|||||||
#define _CITRUS_PROP_READ_UINT_COMMON(_func_, _type_, _max_) \
|
#define _CITRUS_PROP_READ_UINT_COMMON(_func_, _type_, _max_) \
|
||||||
static int \
|
static int \
|
||||||
_citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms, \
|
_citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms, \
|
||||||
_type_ * __restrict result, int base) \
|
_type_ * __restrict result, int base, int neg) \
|
||||||
{ \
|
{ \
|
||||||
_type_ acc, cutoff; \
|
_type_ acc, cutoff; \
|
||||||
int ch, cutlim, n; \
|
int ch, cutlim, n; \
|
||||||
@ -99,7 +99,7 @@ _citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms, \
|
|||||||
acc += n; \
|
acc += n; \
|
||||||
} \
|
} \
|
||||||
_memstream_ungetc(ms, ch); \
|
_memstream_ungetc(ms, ch); \
|
||||||
*result = acc; \
|
*result = neg ? -acc : acc; \
|
||||||
return (0); \
|
return (0); \
|
||||||
}
|
}
|
||||||
_CITRUS_PROP_READ_UINT_COMMON(chr, int, UCHAR_MAX)
|
_CITRUS_PROP_READ_UINT_COMMON(chr, int, UCHAR_MAX)
|
||||||
@ -139,7 +139,7 @@ _citrus_prop_read_##_func_(struct _memstream * __restrict ms, \
|
|||||||
return (EINVAL); \
|
return (EINVAL); \
|
||||||
_memstream_ungetc(ms, ch); \
|
_memstream_ungetc(ms, ch); \
|
||||||
return (_citrus_prop_read_##_func_##_common \
|
return (_citrus_prop_read_##_func_##_common \
|
||||||
(ms, &obj->u._func_, base)); \
|
(ms, &obj->u._func_, base, neg)); \
|
||||||
}
|
}
|
||||||
_CITRUS_PROP_READ_INT(chr, int)
|
_CITRUS_PROP_READ_INT(chr, int)
|
||||||
_CITRUS_PROP_READ_INT(num, uint64_t)
|
_CITRUS_PROP_READ_INT(num, uint64_t)
|
||||||
@ -185,7 +185,8 @@ _citrus_prop_read_character_common(struct _memstream * __restrict ms,
|
|||||||
base -= 8;
|
base -= 8;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
case 'x':
|
case 'x':
|
||||||
return (_citrus_prop_read_chr_common(ms, result, base));
|
return (_citrus_prop_read_chr_common(ms, result,
|
||||||
|
base, 0));
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
default:
|
default:
|
||||||
/* unknown escape */
|
/* unknown escape */
|
||||||
|
Loading…
Reference in New Issue
Block a user