Home | History | Annotate | Line # | Download | only in lint1
      1  1.4  rillig /*	$NetBSD: msg_339.c,v 1.4 2023/03/28 14:44:35 rillig Exp $	*/
      2  1.1  rillig # 3 "msg_339.c"
      3  1.1  rillig 
      4  1.1  rillig // Test for message: option '%c' should be listed in the options string [339]
      5  1.1  rillig 
      6  1.4  rillig /* lint1-extra-flags: -X 351 */
      7  1.4  rillig 
      8  1.1  rillig int getopt(int, char *const *, const char *);
      9  1.1  rillig extern char *optarg;
     10  1.1  rillig 
     11  1.1  rillig int
     12  1.1  rillig main(int argc, char **argv)
     13  1.1  rillig {
     14  1.1  rillig 	int o;
     15  1.1  rillig 
     16  1.3  rillig 	/* expect+2: warning: option 'c' should be handled in the switch [338] */
     17  1.3  rillig 	/* expect+1: warning: option 'd' should be handled in the switch [338] */
     18  1.3  rillig 	while ((o = getopt(argc, argv, "a:bc:d")) != -1) {
     19  1.1  rillig 		switch (o) {
     20  1.1  rillig 		case 'a':
     21  1.1  rillig 			break;
     22  1.1  rillig 		case 'b':
     23  1.1  rillig 			/*
     24  1.1  rillig 			 * The following while loop must not finish the check
     25  1.1  rillig 			 * for the getopt options.
     26  1.1  rillig 			 */
     27  1.1  rillig 			while (optarg[0] != '\0')
     28  1.1  rillig 				optarg++;
     29  1.1  rillig 			break;
     30  1.3  rillig 		case 'e':
     31  1.3  rillig 			/* expect-1: warning: option 'e' should be listed in the options string [339] */
     32  1.1  rillig 			break;
     33  1.3  rillig 		case 'f':
     34  1.3  rillig 			/* expect-1: warning: option 'f' should be listed in the options string [339] */
     35  1.1  rillig 			/*
     36  1.1  rillig 			 * The case labels in nested switch statements are
     37  1.1  rillig 			 * ignored by the check for getopt options.
     38  1.1  rillig 			 */
     39  1.1  rillig 			switch (optarg[0]) {
     40  1.1  rillig 			case 'X':
     41  1.1  rillig 				break;
     42  1.1  rillig 			}
     43  1.1  rillig 			break;
     44  1.1  rillig 		case '?':
     45  1.1  rillig 		default:
     46  1.1  rillig 			break;
     47  1.1  rillig 		}
     48  1.1  rillig 	}
     49  1.1  rillig 
     50  1.1  rillig 	return 0;
     51  1.1  rillig }
     52