| OLD | NEW |
| 1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 // | 2 // |
| 3 /// \file args.c | 3 /// \file args.c |
| 4 /// \brief Argument parsing | 4 /// \brief Argument parsing |
| 5 /// | 5 /// |
| 6 /// \note Filter-specific options parsing is in options.c. | 6 /// \note Filter-specific options parsing is in options.c. |
| 7 // | 7 // |
| 8 // Author: Lasse Collin | 8 // Author: Lasse Collin |
| 9 // | 9 // |
| 10 // This file has been put into the public domain. | 10 // This file has been put into the public domain. |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // unsigned char cast to int. Casting to int is done | 431 // unsigned char cast to int. Casting to int is done |
| 432 // automatically due to integer promotion, but we need to | 432 // automatically due to integer promotion, but we need to |
| 433 // force char to unsigned char manually. Otherwise 8-bit | 433 // force char to unsigned char manually. Otherwise 8-bit |
| 434 // characters would get promoted to wrong value if | 434 // characters would get promoted to wrong value if |
| 435 // char is signed. | 435 // char is signed. |
| 436 if (isspace((unsigned char)env[i])) { | 436 if (isspace((unsigned char)env[i])) { |
| 437 prev_was_space = true; | 437 prev_was_space = true; |
| 438 } else if (prev_was_space) { | 438 } else if (prev_was_space) { |
| 439 prev_was_space = false; | 439 prev_was_space = false; |
| 440 | 440 |
| 441 » » » // Keep argc small enough to fit into a singed int | 441 » » » // Keep argc small enough to fit into a signed int |
| 442 // and to keep it usable for memory allocation. | 442 // and to keep it usable for memory allocation. |
| 443 if (++argc == my_min( | 443 if (++argc == my_min( |
| 444 INT_MAX, SIZE_MAX / sizeof(char *))) | 444 INT_MAX, SIZE_MAX / sizeof(char *))) |
| 445 message_fatal(_("The environment variable " | 445 message_fatal(_("The environment variable " |
| 446 "%s contains too many " | 446 "%s contains too many " |
| 447 "arguments"), varname); | 447 "arguments"), varname); |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 | 450 |
| 451 // Allocate memory to hold pointers to the arguments. Add one to get | 451 // Allocate memory to hold pointers to the arguments. Add one to get |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 args->arg_count = 1; | 569 args->arg_count = 1; |
| 570 } else { | 570 } else { |
| 571 // We got at least one filename from the command line, or | 571 // We got at least one filename from the command line, or |
| 572 // --files or --files0 was specified. | 572 // --files or --files0 was specified. |
| 573 args->arg_names = argv + optind; | 573 args->arg_names = argv + optind; |
| 574 args->arg_count = argc - optind; | 574 args->arg_count = argc - optind; |
| 575 } | 575 } |
| 576 | 576 |
| 577 return; | 577 return; |
| 578 } | 578 } |
| OLD | NEW |