Module Name:    src
Committed By:   rillig
Date:           Sun Jan 21 21:31:23 UTC 2024

Modified Files:
        src/lib/libutil: snprintb.3

Log Message:
snprintb.3: fix examples

The first example broke the format string at boundaries that didn't
highlight the structure of the format string and also didn't make it
clear that a few bits were omitted from having descriptions.

The second example contained an off-by-one error for SIXTEEN, which was
actually FIFTEEN.

The snprintb_m example repeated the above off-by-one error, and its
output was shown wrong, due to concatenated escape sequences.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libutil/snprintb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.24 src/lib/libutil/snprintb.3:1.25
--- src/lib/libutil/snprintb.3:1.24	Thu Jul 30 21:23:36 2020
+++ src/lib/libutil/snprintb.3	Sun Jan 21 21:31:23 2024
@@ -1,4 +1,4 @@
-.\"     $NetBSD: snprintb.3,v 1.24 2020/07/30 21:23:36 uwe Exp $
+.\"     $NetBSD: snprintb.3,v 1.25 2024/01/21 21:31:23 rillig Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 6, 2019
+.Dd January 21, 2024
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -246,21 +246,25 @@ snprintb(buf, buflen, "\e10\e2BITTWO\e1B
 \(rA "03<BITTWO,BITONE>"
 
 snprintb(buf, buflen,
-       "\e20\ex10NOTBOOT\ex0f" "FPP\ex0eSDVMA\ex0cVIDEO"
-       "\ex0bLORES\ex0a" "FPA\ex09" "DIAG\ex07" "CACHE"
-       "\ex06IOCACHE\ex05LOOPBACK\ex04" "DBGCACHE",
-       0xe860)
+    "\e20"
+    "\ex10NOTBOOT" "\ex0fFPP" "\ex0eSDVMA" ""
+    "\ex0cVIDEO" "\ex0bLORES" "\ex0aFPA" "\ex09DIAG"
+    "" "\ex07CACHE" "\ex06IOCACHE" "\ex05LOOPBACK"
+    "\ex04DBGCACHE",
+    0xe860)
 \(rA "0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"
 .Ed
 .Pp
 An example of the new formatting style:
 .Bd -literal -offset indent
 snprintb(buf, buflen,
-       "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0"
-       "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
-       "b\ex1fMSB\e0\e0",
-       0x800f0701)
-\(rA "0x800f0701<LSB,NIBBLE2=0x0,BURST=0xf=SIXTEEN,MSB>"
+    "\e177\e020"
+    "b\e0LSB\e0" "b\e1BITONE\e0"
+    "f\e4\e4NIBBLE2\e0"
+    "f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
+    "b\ex1fMSB\e0" "\e0",
+    0x800f0701)
+\(rA "0x800f0701<LSB,NIBBLE2=0x0,BURST=0xf=FIFTEEN,MSB>"
 .Ed
 .Pp
 A more complex example from
@@ -320,11 +324,14 @@ snprintb(buf, buflen, MAP_FMT, 0x2e00000
 An example using snprintb_m:
 .Bd -literal -offset indent
 snprintb_m(buf, buflen,
-       "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0"
-       "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
-       "b\ex1fMSB\e0\e0",
-       0x800f0701, 34)
-\(rA "0x800f0701<LSB,NIBBLE2=0x0>\e00x800f0701<BURST=0xf=SIXTEEN,MSB>\e0"
+    "\e177\e020"
+    "b\e0LSB\e0" "b\e1BITONE\e0" "f\e4\e4NIBBLE2\e0"
+    "f\ex10\e4BURST\e0" "=\e4FOUR\e0" "=\exfFIFTEEN\e0"
+    "b\ex1fMSB\e0" "\e0",
+    0x800f0701, 34)
+\(rA "0x800f0701<LSB,NIBBLE2=0x0>\e0"
+   "0x800f0701<BURST=0xf=FIFTEEN,MSB>\e0"
+   ""
 .Ed
 .Sh ERRORS
 .Fn snprintb

Reply via email to