| 854 | } |
| 855 | |
| 856 | int |
| 857 | main (int argc, char **argv) |
| 858 | { |
| 859 | unsigned int n_files; |
| 860 | bool old_options = false; |
| 861 | bool old_w = false; |
| 862 | bool old_s = false; |
| 863 | char **file_names; |
| 864 | |
| 865 | /* Accumulate the digits of old-style options like -99. */ |
| 866 | char *column_count_string = NULL; |
| 867 | idx_t n_digits = 0; |
| 868 | idx_t n_alloc = 0; |
| 869 | |
| 870 | initialize_main (&argc, &argv); |
| 871 | set_program_name (argv[0]); |
| 872 | setlocale (LC_ALL, ""); |
| 873 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 874 | textdomain (PACKAGE); |
| 875 | |
| 876 | atexit (close_stdout); |
| 877 | |
| 878 | n_files = 0; |
| 879 | file_names = (argc > 1 |
| 880 | ? xnmalloc (argc - 1, sizeof (char *)) |
| 881 | : NULL); |
| 882 | |
| 883 | while (true) |
| 884 | { |
| 885 | int oi = -1; |
| 886 | int c = getopt_long (argc, argv, short_options, long_options, &oi); |
| 887 | if (c == -1) |
| 888 | break; |
| 889 | |
| 890 | if (c_isdigit (c)) |
| 891 | { |
| 892 | /* Accumulate column-count digits specified via old-style options. */ |
| 893 | if (n_digits + 1 >= n_alloc) |
| 894 | column_count_string = xpalloc (column_count_string, &n_alloc, 2, -1, |
| 895 | sizeof *column_count_string); |
| 896 | column_count_string[n_digits++] = c; |
| 897 | column_count_string[n_digits] = '\0'; |
| 898 | continue; |
| 899 | } |
| 900 | |
| 901 | n_digits = 0; |
| 902 | |
| 903 | switch (c) |
| 904 | { |
| 905 | case 1: /* Non-option argument. */ |
| 906 | /* long option --page dominates old '+FIRST_PAGE ...'. */ |
| 907 | if (! (first_page_number == 0 |
| 908 | && *optarg == '+' && first_last_page (-2, '+', optarg + 1))) |
| 909 | file_names[n_files++] = optarg; |
| 910 | break; |
| 911 | |
| 912 | case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */ |
| 913 | { /* dominates old opt +... */ |
nothing calls this directly
no test coverage detected