Home | History | Annotate | Line # | Download | only in lint1
      1  1.3  rillig /*	$NetBSD: msg_369.c,v 1.3 2024/08/31 06:57:31 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_369.c"
      3  1.1  rillig 
      4  1.1  rillig // Test for message: bit position '%.*s' in '%.*s' should be escaped as octal or hex [369]
      5  1.1  rillig 
      6  1.1  rillig /*
      7  1.1  rillig  * To distinguish bit positions 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(unsigned u32, uint64_t u64)
     22  1.1  rillig {
     23  1.1  rillig 	char buf[64];
     24  1.1  rillig 
     25  1.1  rillig 	/* expect+8: warning: bit position ' ' in ' space' should be escaped as octal or hex [369] */
     26  1.1  rillig 	/* expect+7: warning: bit position '\t' in '\ttab' should be escaped as octal or hex [369] */
     27  1.1  rillig 	/* expect+6: warning: bit position '\n' in '\nnewline' should be escaped as octal or hex [369] */
     28  1.1  rillig 	snprintb(buf, sizeof(buf),
     29  1.1  rillig 	    "\020"
     30  1.1  rillig 	    " space"
     31  1.1  rillig 	    "\ttab"
     32  1.1  rillig 	    "\nnewline",
     33  1.1  rillig 	    u32);
     34  1.1  rillig 
     35  1.1  rillig 	/* expect+8: warning: bit position ' ' in 'b space\0' should be escaped as octal or hex [369] */
     36  1.1  rillig 	/* expect+7: warning: bit position '\t' in 'b\ttab\0' should be escaped as octal or hex [369] */
     37  1.1  rillig 	/* expect+6: warning: bit position '\n' in 'b\nnewline\0' should be escaped as octal or hex [369] */
     38  1.1  rillig 	snprintb(buf, sizeof(buf),
     39  1.1  rillig 	    "\177\020"
     40  1.1  rillig 	    "b space\0"
     41  1.1  rillig 	    "b\ttab\0"
     42  1.1  rillig 	    "b\nnewline\0",
     43  1.1  rillig 	    u64);
     44  1.1  rillig 
     45  1.2  rillig 	/* expect+6: warning: bit position '\t' in 'f\t\001tab\0' should be escaped as octal or hex [369] */
     46  1.2  rillig 	/* expect+5: warning: bit position '\n' in 'F\n\001newline\0' should be escaped as octal or hex [369] */
     47  1.1  rillig 	snprintb(buf, sizeof(buf),
     48  1.1  rillig 	    "\177\020"
     49  1.2  rillig 	    "f\t\001tab\0"
     50  1.2  rillig 	    "F\n\001newline\0",
     51  1.1  rillig 	    u64);
     52  1.1  rillig }
     53