git: f457e049940d - stable/13 - citrus_prop.c: do not ignore sign

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 00:28:09 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=f457e049940dc7a411dcd19c13a885732d109635

commit f457e049940dc7a411dcd19c13a885732d109635
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-28 03:03:49 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-12-06 00:23:45 +0000

    citrus_prop.c: do not ignore sign
    
    (cherry picked from commit 181751a8b6ef580c44d49ef3cac1c6627bfa461e)
---
 lib/libc/iconv/citrus_prop.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/libc/iconv/citrus_prop.c b/lib/libc/iconv/citrus_prop.c
index 7ac39bbee6e5..0b627f362c22 100644
--- a/lib/libc/iconv/citrus_prop.c
+++ b/lib/libc/iconv/citrus_prop.c
@@ -79,7 +79,7 @@ static const char *xdigit = "0123456789ABCDEF";
 #define _CITRUS_PROP_READ_UINT_COMMON(_func_, _type_, _max_)		\
 static int								\
 _citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms,	\
-    _type_ * __restrict result, int base)				\
+    _type_ * __restrict result, int base, int neg)			\
 {									\
 	_type_ acc, cutoff;						\
 	int ch, cutlim, n;						\
@@ -99,7 +99,7 @@ _citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms,	\
 		acc += n;						\
 	}								\
 	_memstream_ungetc(ms, ch);					\
-	*result = acc;							\
+	*result = neg ? -acc : acc;					\
 	return (0);							\
 }
 _CITRUS_PROP_READ_UINT_COMMON(chr, int, UCHAR_MAX)
@@ -139,7 +139,7 @@ _citrus_prop_read_##_func_(struct _memstream * __restrict ms,	\
 		return (EINVAL);				\
 	_memstream_ungetc(ms, ch);				\
 	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(num, uint64_t)
@@ -185,7 +185,8 @@ _citrus_prop_read_character_common(struct _memstream * __restrict ms,
 			base -= 8;
 			/*FALLTHROUGH*/
 		case 'x':
-			return (_citrus_prop_read_chr_common(ms, result, base));
+			return (_citrus_prop_read_chr_common(ms, result,
+			    base, 0));
 			/*NOTREACHED*/
 		default:
 			/* unknown escape */