Module Name: src Committed By: rillig Date: Sat Feb 24 12:40:00 UTC 2024
Modified Files: src/common/lib/libutil: snprintb.c src/tests/lib/libutil: t_snprintb.c Log Message: snprintb: allow non-ASCII descriptions on all platforms Previously, these descriptions were only allowed on platforms where plain 'char' is unsigned. On platforms where plain 'char' is signed, they invoked undefined behavior or terminated the output early. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/common/lib/libutil/snprintb.c cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libutil/t_snprintb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/common/lib/libutil/snprintb.c diff -u src/common/lib/libutil/snprintb.c:1.39 src/common/lib/libutil/snprintb.c:1.40 --- src/common/lib/libutil/snprintb.c:1.39 Thu Feb 22 21:04:23 2024 +++ src/common/lib/libutil/snprintb.c Sat Feb 24 12:40:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: snprintb.c,v 1.39 2024/02/22 21:04:23 rillig Exp $ */ +/* $NetBSD: snprintb.c,v 1.40 2024/02/24 12:40:00 rillig Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ # include <sys/cdefs.h> # if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: snprintb.c,v 1.39 2024/02/22 21:04:23 rillig Exp $"); +__RCSID("$NetBSD: snprintb.c,v 1.40 2024/02/24 12:40:00 rillig Exp $"); # endif # include <sys/types.h> @@ -51,7 +51,7 @@ __RCSID("$NetBSD: snprintb.c,v 1.39 2024 # include <errno.h> # else /* ! _KERNEL */ # include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.39 2024/02/22 21:04:23 rillig Exp $"); +__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.40 2024/02/24 12:40:00 rillig Exp $"); # include <sys/param.h> # include <sys/inttypes.h> # include <sys/systm.h> @@ -142,11 +142,11 @@ old_style(state *s) return -1; if (s->val & (1U << (bit - 1))) { put_sep(s); - while (*++s->bitfmt > ' ') + while ((uint8_t)*++s->bitfmt > ' ') store(s, *s->bitfmt); wrap_if_necessary(s, cur_bitfmt); } else - while (*++s->bitfmt > ' ') + while ((uint8_t)*++s->bitfmt > ' ') continue; } return 0; Index: src/tests/lib/libutil/t_snprintb.c diff -u src/tests/lib/libutil/t_snprintb.c:1.27 src/tests/lib/libutil/t_snprintb.c:1.28 --- src/tests/lib/libutil/t_snprintb.c:1.27 Thu Feb 22 21:04:24 2024 +++ src/tests/lib/libutil/t_snprintb.c Sat Feb 24 12:40:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_snprintb.c,v 1.27 2024/02/22 21:04:24 rillig Exp $ */ +/* $NetBSD: t_snprintb.c,v 1.28 2024/02/24 12:40:00 rillig Exp $ */ /* * Copyright (c) 2002, 2004, 2008, 2010, 2024 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008, 2010, 2024\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_snprintb.c,v 1.27 2024/02/22 21:04:24 rillig Exp $"); +__RCSID("$NetBSD: t_snprintb.c,v 1.28 2024/02/24 12:40:00 rillig Exp $"); #include <stdio.h> #include <string.h> @@ -300,9 +300,10 @@ ATF_TC_BODY(snprintb, tc) h_snprintb( "\020" "\001least significant" - "\002horizontal\ttab", + "\002horizontal\ttab" + "\003\xC3\xA4", 0xff, - "0xff<least,horizontal>"); + "0xff<least,horizontal,\xC3\xA4>"); // old style, empty description //