Module Name: src
Committed By: rillig
Date: Mon Feb 19 23:30:56 UTC 2024
Modified Files:
src/common/lib/libutil: snprintb.c
src/tests/lib/libutil: t_snprintb.c
Log Message:
snprintb: fix how named bit-fields are split into multiple lines
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/common/lib/libutil/snprintb.c
cvs rdiff -u -r1.21 -r1.22 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.35 src/common/lib/libutil/snprintb.c:1.36
--- src/common/lib/libutil/snprintb.c:1.35 Sat Feb 17 10:23:30 2024
+++ src/common/lib/libutil/snprintb.c Mon Feb 19 23:30:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: snprintb.c,v 1.35 2024/02/17 10:23:30 rillig Exp $ */
+/* $NetBSD: snprintb.c,v 1.36 2024/02/19 23:30:56 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.35 2024/02/17 10:23:30 rillig Exp $");
+__RCSID("$NetBSD: snprintb.c,v 1.36 2024/02/19 23:30:56 rillig Exp $");
# endif
# include <sys/types.h>
@@ -51,7 +51,7 @@ __RCSID("$NetBSD: snprintb.c,v 1.35 2024
# include <errno.h>
# else /* ! _KERNEL */
# include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.35 2024/02/17 10:23:30 rillig Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.36 2024/02/19 23:30:56 rillig Exp $");
# include <sys/param.h>
# include <sys/inttypes.h>
# include <sys/systm.h>
@@ -233,7 +233,8 @@ new_style(state *s)
matched = 1;
if (kind == '=')
put_chr(s, '=');
- put_bitfmt(s);
+ if (s->restart == 0)
+ put_bitfmt(s);
break;
case '*':
s->bitfmt--;
Index: src/tests/lib/libutil/t_snprintb.c
diff -u src/tests/lib/libutil/t_snprintb.c:1.21 src/tests/lib/libutil/t_snprintb.c:1.22
--- src/tests/lib/libutil/t_snprintb.c:1.21 Mon Feb 19 23:22:03 2024
+++ src/tests/lib/libutil/t_snprintb.c Mon Feb 19 23:30:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: t_snprintb.c,v 1.21 2024/02/19 23:22:03 rillig Exp $ */
+/* $NetBSD: t_snprintb.c,v 1.22 2024/02/19 23:30:56 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.21 2024/02/19 23:22:03 rillig Exp $");
+__RCSID("$NetBSD: t_snprintb.c,v 1.22 2024/02/19 23:30:56 rillig Exp $");
#include <stdio.h>
#include <string.h>
@@ -1462,7 +1462,7 @@ ATF_TC_BODY(snprintb_m, tc)
0xff,
24,
"0xff<lo=0xf>\0"
- "0xfff=match\0"); // FIXME: incomplete
+ "0xff<low-bits=0xf=match>\0");
// new style, line_max exceeded by unnamed bit-field number in line 1
h_snprintb_m(
@@ -1567,10 +1567,7 @@ ATF_TC_BODY(snprintb_m, tc)
0x800f0701,
34,
"0x800f0701<LSB,NIBBLE2=0>\0"
- // FIXME: The '\020\004' is wrong.
- // FIXME: The '=0xf' is missing.
- // FIXME: The '<' is in the wrong place.
- "0x800f0701f\020\004BURST=FIFTEEN<MSB>\0");
+ "0x800f0701<BURST=0xf=FIFTEEN,MSB>\0");
// new style, buffer too small for complete number in line 2
h_snprintb_m_len(