Home | History | Annotate | Line # | Download | only in lint1
msg_370.c revision 1.3
      1  1.3  rillig /*	$NetBSD: msg_370.c,v 1.3 2024/08/31 06:57:31 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_370.c"
      3  1.1  rillig 
      4  1.1  rillig // Test for message: field width '%.*s' in '%.*s' should be escaped as octal or hex [370]
      5  1.1  rillig 
      6  1.1  rillig /*
      7  1.1  rillig  * To distinguish field widths from the description text, they should use
      8  1.1  rillig  * octal or hex escape sequences.  Of these, octal escape sequences are less
      9  1.1  rillig  * error-prone, as they consist of at most 3 octal digits, whereas hex escape
     10  1.1  rillig  * sequences consume as many digits as available.
     11  1.1  rillig  */
     12  1.1  rillig 
     13  1.1  rillig /* lint1-extra-flags: -X 351 */
     14  1.1  rillig 
     15  1.1  rillig typedef typeof(sizeof(0)) size_t;
     16  1.1  rillig typedef unsigned long long uint64_t;
     17  1.1  rillig 
     18  1.3  rillig int snprintb(char *, size_t, const char *, uint64_t);
     19  1.1  rillig 
     20  1.1  rillig void
     21  1.1  rillig example(uint64_t u64)
     22  1.1  rillig {
     23  1.1  rillig 	char buf[64];
     24  1.1  rillig 
     25  1.1  rillig 	/* expect+11: warning: bit position ' ' in 'f  space\0' should be escaped as octal or hex [369] */
     26  1.1  rillig 	/* expect+10: warning: field width ' ' in 'f  space\0' should be escaped as octal or hex [370] */
     27  1.1  rillig 	/* expect+9: warning: bit position '\t' in 'f\t\ttab\0' should be escaped as octal or hex [369] */
     28  1.1  rillig 	/* expect+8: warning: field width '\t' in 'f\t\ttab\0' should be escaped as octal or hex [370] */
     29  1.1  rillig 	/* expect+7: warning: bit position '\n' in 'f\n\nnewline\0' should be escaped as octal or hex [369] */
     30  1.1  rillig 	/* expect+6: warning: field width '\n' in 'f\n\nnewline\0' should be escaped as octal or hex [370] */
     31  1.1  rillig 	snprintb(buf, sizeof(buf),
     32  1.1  rillig 	    "\177\020"
     33  1.1  rillig 	    "f  space\0"
     34  1.1  rillig 	    "f\t\ttab\0"
     35  1.1  rillig 	    "f\n\nnewline\0",
     36  1.1  rillig 	    u64);
     37  1.2  rillig 	/* expect-1: warning: 'f\n\nnewline\0' overlaps earlier 'f\t\ttab\0' on bit 10 [376] */
     38  1.1  rillig 
     39  1.1  rillig 	/* expect+11: warning: bit position ' ' in 'F  space\0' should be escaped as octal or hex [369] */
     40  1.1  rillig 	/* expect+10: warning: field width ' ' in 'F  space\0' should be escaped as octal or hex [370] */
     41  1.1  rillig 	/* expect+9: warning: bit position '\t' in 'F\t\ttab\0' should be escaped as octal or hex [369] */
     42  1.1  rillig 	/* expect+8: warning: field width '\t' in 'F\t\ttab\0' should be escaped as octal or hex [370] */
     43  1.1  rillig 	/* expect+7: warning: bit position '\n' in 'F\n\nnewline\0' should be escaped as octal or hex [369] */
     44  1.1  rillig 	/* expect+6: warning: field width '\n' in 'F\n\nnewline\0' should be escaped as octal or hex [370] */
     45  1.1  rillig 	snprintb(buf, sizeof(buf),
     46  1.1  rillig 	    "\177\020"
     47  1.1  rillig 	    "F  space\0"
     48  1.1  rillig 	    "F\t\ttab\0"
     49  1.1  rillig 	    "F\n\nnewline\0",
     50  1.1  rillig 	    u64);
     51  1.2  rillig 	/* expect-1: warning: 'F\n\nnewline\0' overlaps earlier 'F\t\ttab\0' on bit 10 [376] */
     52  1.1  rillig }
     53