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