| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_snprintb.c,v 1.17 2024/02/16 18:09:16 rillig Exp $ */ | | 1 | /* $NetBSD: t_snprintb.c,v 1.18 2024/02/16 18:13:47 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2002, 2004, 2008, 2010, 2024 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002, 2004, 2008, 2010, 2024 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code was contributed to The NetBSD Foundation by Christos Zoulas and | | 7 | * This code was contributed to The NetBSD Foundation by Christos Zoulas and |
8 | * Roland Illig. | | 8 | * Roland Illig. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ | | 33 | __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ |
34 | The NetBSD Foundation, inc. All rights reserved."); | | 34 | The NetBSD Foundation, inc. All rights reserved."); |
35 | __RCSID("$NetBSD: t_snprintb.c,v 1.17 2024/02/16 18:09:16 rillig Exp $"); | | 35 | __RCSID("$NetBSD: t_snprintb.c,v 1.18 2024/02/16 18:13:47 rillig Exp $"); |
36 | | | 36 | |
37 | #include <stdio.h> | | 37 | #include <stdio.h> |
38 | #include <string.h> | | 38 | #include <string.h> |
39 | #include <util.h> | | 39 | #include <util.h> |
40 | #include <vis.h> | | 40 | #include <vis.h> |
41 | | | 41 | |
42 | #include <atf-c.h> | | 42 | #include <atf-c.h> |
43 | | | 43 | |
44 | static const char * | | 44 | static const char * |
45 | vis_arr(const char *arr, size_t arrsize) | | 45 | vis_arr(const char *arr, size_t arrsize) |
46 | { | | 46 | { |
47 | static char buf[6][1024]; | | 47 | static char buf[6][1024]; |
48 | static size_t i; | | 48 | static size_t i; |
| @@ -489,27 +489,27 @@ ATF_TC_BODY(snprintb, tc) | | | @@ -489,27 +489,27 @@ ATF_TC_BODY(snprintb, tc) |
489 | "F\010\020\0" | | 489 | "F\010\020\0" |
490 | ":\377ones\0" | | 490 | ":\377ones\0" |
491 | "*other(%jx)\0", | | 491 | "*other(%jx)\0", |
492 | 0x77ff55, | | 492 | 0x77ff55, |
493 | "0x77ff55<Field=0x77ff=other(77ff),other(77ff)>"); | | 493 | "0x77ff55<Field=0x77ff=other(77ff),other(77ff)>"); |
494 | | | 494 | |
495 | // new-style format, bit-field with 8 bits | | 495 | // new-style format, bit-field with 8 bits |
496 | h_snprintb( | | 496 | h_snprintb( |
497 | "\177\020" | | 497 | "\177\020" |
498 | "F\010\010\0" | | 498 | "F\010\010\0" |
499 | ":\377all\0" | | 499 | ":\377all\0" |
500 | "*other\0", | | 500 | "*other\0", |
501 | 0xff00, | | 501 | 0xff00, |
502 | "0xff00<other>"); | | 502 | "0xff00<all>"); |
503 | | | 503 | |
504 | // new-style format, bit-fields with no match | | 504 | // new-style format, bit-fields with no match |
505 | h_snprintb( | | 505 | h_snprintb( |
506 | "\177\020" | | 506 | "\177\020" |
507 | "f\010\004Field\0" | | 507 | "f\010\004Field\0" |
508 | "=\1one\0" | | 508 | "=\1one\0" |
509 | "=\2two\0", | | 509 | "=\2two\0", |
510 | 0x301, | | 510 | 0x301, |
511 | "0x301<Field=0x3>"); | | 511 | "0x301<Field=0x3>"); |
512 | h_snprintb( | | 512 | h_snprintb( |
513 | "\177\020" | | 513 | "\177\020" |
514 | "F\010\004\0" | | 514 | "F\010\004\0" |
515 | ":\1one\0" | | 515 | ":\1one\0" |