Changeset 3bacee1 in mainline for uspace/lib/c/generic/getopt.c
- Timestamp:
- 2018-04-12T16:27:17Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/getopt.c
r76d0981d r3bacee1 132 132 133 133 for (i = 0; i < ncycle; i++) { 134 cstart = panonopt_end +i;134 cstart = panonopt_end + i; 135 135 pos = cstart; 136 136 for (j = 0; j < cyclelen; j++) { … … 181 181 optind, nargv); 182 182 optind -= nonopt_end - nonopt_start; 183 } 184 else if (nonopt_start != -1) { 183 } else if (nonopt_start != -1) { 185 184 /* 186 185 * If we skipped non-options, set optind … … 192 191 return -1; 193 192 } 194 if ((*(place = nargv[optind]) != '-') 195 ||(place[1] == '\0')) { /* found non-option */193 if ((*(place = nargv[optind]) != '-') || 194 (place[1] == '\0')) { /* found non-option */ 196 195 place = EMSG; 197 196 if (IN_ORDER) { … … 289 288 * Parse argc/argv argument vector. 290 289 */ 291 int getopt(int nargc, char * 290 int getopt(int nargc, char *const *nargv, const char *options) 292 291 { 293 292 int retval; … … 305 304 if (nonopt_end != -1) { 306 305 permute_args(nonopt_start, nonopt_end, optind, 307 306 (char **)nargv); 308 307 optind -= nonopt_end - nonopt_start; 309 308 } … … 318 317 * Parse argc/argv argument vector. 319 318 */ 320 int getopt_long(int nargc, char * 319 int getopt_long(int nargc, char *const *nargv, const char *options, 321 320 const struct option *long_options, int *idx) 322 321 { … … 389 388 if (PRINT_ERROR) 390 389 printf(ambig, (int)current_argv_len, 391 390 current_argv); 392 391 optopt = 0; 393 392 return BADCH; 394 393 } 395 394 if (match != -1) { /* option found */ 396 if (long_options[match].has_arg == no_argument397 &&has_equal) {395 if (long_options[match].has_arg == no_argument && 396 has_equal) { 398 397 if (PRINT_ERROR) 399 398 printf(noarg, (int)current_argv_len, 400 399 current_argv); 401 400 /* 402 401 * XXX: GNU sets optopt to val regardless of … … 422 421 } 423 422 } 424 if ((long_options[match].has_arg == required_argument) 425 &&(optarg == NULL)) {423 if ((long_options[match].has_arg == required_argument) && 424 (optarg == NULL)) { 426 425 /* 427 426 * Missing argument; leading ':'
Note:
See TracChangeset
for help on using the changeset viewer.