- int opt;
-
- while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
- switch (opt) {
- case 'b':
- case 'c':
- case 'f':
- /* make sure they didn't ask for two types of lists */
- if (part != 0) {
- error_msg_and_die("only one type of list may be specified");
- }
- part = (char)opt;
- parse_lists(optarg);
- break;
- case 'd':
- if (strlen(optarg) > 1) {
- error_msg_and_die("the delimiter must be a single character");
- }
- delim = optarg[0];
- break;
- case 'n':
- /* no-op */
- break;
- case 's':
- supress_non_delimited_lines++;
- break;
+ unsigned long opt;
+ char *sopt, *sdopt;
+
+ bb_opt_complementaly = "b~bcf:c~bcf:f~bcf";
+ opt = bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &sdopt);
+ part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
+ if(part == 0)
+ bb_error_msg_and_die("you must specify a list of bytes, characters, or fields");
+ if(opt & 0x80000000UL)
+ bb_error_msg_and_die("only one type of list may be specified");
+ parse_lists(sopt);
+ if((opt & (OPT_DELIM_FLGS))) {
+ if (strlen(sdopt) > 1) {
+ bb_error_msg_and_die("the delimiter must be a single character");