From: Bruno Haible Date: Sun, 23 Sep 2001 14:42:25 +0000 (+0000) Subject: Reorganize the option checking. X-Git-Tag: v0.11~479 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc19220e14166d6e291d59c842a7286a36aa1f48;p=thirdparty%2Fgettext.git Reorganize the option checking. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1eced767c..6706d7910 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-09-08 Bruno Haible + + * msgcat.c (main): Move the option checking after the handling of + --version and --help, but before opening of any file. + * msgcomm.c (main): Move the option checking after the handling of + --version and --help. + * msguniq.c (main): Likewise. + * xgettext.c (main): Likewise. + * msgconv.c (main): Additional option checking for --sort-by-file. + * msgen.c (main): Likewise. + * msgexec.c (main): Likewise. + * msggrep.c (main): Likewise. + * msgmerge.c (main): Likewise. + 2001-09-08 Bruno Haible * dir-list.c: Include specification header before all other headers. diff --git a/src/msgcat.c b/src/msgcat.c index 7e6f0d30e..c1d7a1629 100644 --- a/src/msgcat.c +++ b/src/msgcat.c @@ -220,15 +220,6 @@ main (argc, argv) /* NOTREACHED */ } - /* Verify selected options. */ - if (!line_comment && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--no-location", "--sort-by-file"); - - if (sort_by_msgid && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--sort-output", "--sort-by-file"); - /* Version information requested. */ if (do_version) { @@ -247,6 +238,21 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ if (do_help) usage (EXIT_SUCCESS); + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + + if (sort_by_msgid && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--sort-output", "--sort-by-file"); + + /* Check the message selection criteria for sanity. */ + if (more_than >= less_than || less_than < 2) + error (EXIT_FAILURE, 0, + _("impossible selection criteria specified (%d < n < %d)"), + more_than, less_than); + /* Determine list of files we have to process. */ if (files_from != NULL) file_list = read_names_from_file (files_from); @@ -256,12 +262,6 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ for (cnt = optind; cnt < argc; ++cnt) string_list_append_unique (file_list, argv[cnt]); - /* Check the message selection criteria for sanity. */ - if (more_than >= less_than || less_than < 2) - error (EXIT_FAILURE, 0, - _("impossible selection criteria specified (%d < n < %d)"), - more_than, less_than); - /* Read input files, then filter, convert and merge messages. */ result = catenate_msgdomain_list (file_list, to_code); diff --git a/src/msgcomm.c b/src/msgcomm.c index 9abd81998..9382f1538 100644 --- a/src/msgcomm.c +++ b/src/msgcomm.c @@ -223,15 +223,6 @@ main (argc, argv) /* NOTREACHED */ } - /* Verify selected options. */ - if (!line_comment && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--no-location", "--sort-by-file"); - - if (sort_by_msgid && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--sort-output", "--sort-by-file"); - /* Version information requested. */ if (do_version) { @@ -250,6 +241,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ if (do_help) usage (EXIT_SUCCESS); + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + + if (sort_by_msgid && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--sort-output", "--sort-by-file"); + /* Determine list of files we have to process. */ if (files_from != NULL) file_list = read_names_from_file (files_from); diff --git a/src/msgconv.c b/src/msgconv.c index 8da868521..4ec75162f 100644 --- a/src/msgconv.c +++ b/src/msgconv.c @@ -202,6 +202,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ usage (EXIT_FAILURE); } + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + if (sort_by_msgid && sort_by_filepos) error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--sort-output", "--sort-by-file"); diff --git a/src/msgen.c b/src/msgen.c index e8b711089..e4526b959 100644 --- a/src/msgen.c +++ b/src/msgen.c @@ -191,6 +191,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ usage (EXIT_FAILURE); } + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + if (sort_by_msgid && sort_by_filepos) error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--sort-output", "--sort-by-file"); diff --git a/src/msgexec.c b/src/msgexec.c index b56aaf453..0445866ea 100644 --- a/src/msgexec.c +++ b/src/msgexec.c @@ -248,6 +248,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ error (EXIT_FAILURE, 0, _("missing filter name")); sub_name = argv[optind]; + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + + if (sort_by_msgid && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--sort-output", "--sort-by-file"); + /* Build argument list for the program. */ sub_argc = argc - optind; sub_argv = (char **) xmalloc ((sub_argc + 1) * sizeof (char *)); @@ -279,10 +288,6 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ } } - if (sort_by_msgid && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--sort-output", "--sort-by-file"); - /* By default, input comes from standard input. */ if (input_file == NULL) input_file = "-"; diff --git a/src/msggrep.c b/src/msggrep.c index a75b73440..de1ab4f56 100644 --- a/src/msggrep.c +++ b/src/msggrep.c @@ -295,6 +295,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ usage (EXIT_FAILURE); } + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + if (sort_by_msgid && sort_by_filepos) error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--sort-output", "--sort-by-file"); diff --git a/src/msgmerge.c b/src/msgmerge.c index 0143ee77e..da5003ac7 100644 --- a/src/msgmerge.c +++ b/src/msgmerge.c @@ -244,9 +244,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ usage (EXIT_FAILURE); } + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + if (sort_by_msgid && sort_by_filepos) error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--sort-output", "--sort-by-file"); + "--sort-output", "--sort-by-file"); /* merge the two files */ result = merge (argv[optind], argv[optind + 1]); diff --git a/src/msguniq.c b/src/msguniq.c index c3d80900d..ebaae5f27 100644 --- a/src/msguniq.c +++ b/src/msguniq.c @@ -198,15 +198,6 @@ main (argc, argv) /* NOTREACHED */ } - /* Verify selected options. */ - if (!line_comment && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--no-location", "--sort-by-file"); - - if (sort_by_msgid && sort_by_filepos) - error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), - "--sort-output", "--sort-by-file"); - /* Version information requested. */ if (do_version) { @@ -236,6 +227,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ usage (EXIT_FAILURE); } + /* Verify selected options. */ + if (!line_comment && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--no-location", "--sort-by-file"); + + if (sort_by_msgid && sort_by_filepos) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--sort-output", "--sort-by-file"); + /* Determine list of files we have to process: a single file. */ file_list = string_list_alloc (); string_list_append (file_list, input_file); diff --git a/src/xgettext.c b/src/xgettext.c index 2a61815ca..890362e71 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -346,10 +346,29 @@ main (argc, argv) /* NOTREACHED */ } + /* Version information requested. */ + if (do_version) + { + printf ("%s (GNU %s) %s\n", basename (program_name), PACKAGE, VERSION); + /* xgettext: no-wrap */ + printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ +"), + "1995-1998, 2000, 2001"); + printf (_("Written by %s.\n"), "Ulrich Drepper"); + exit (EXIT_SUCCESS); + } + + /* Help is requested. */ + if (do_help) + usage (EXIT_SUCCESS); + /* Normalize selected options. */ if (omit_header != 0 && line_comment < 0) line_comment = 0; + /* Verify selected options. */ if (!line_comment && sort_by_filepos) error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--no-location", "--sort-by-file"); @@ -369,24 +388,6 @@ xgettext cannot work without keywords to look for")); usage (EXIT_FAILURE); } - /* Version information requested. */ - if (do_version) - { - printf ("%s (GNU %s) %s\n", basename (program_name), PACKAGE, VERSION); - /* xgettext: no-wrap */ - printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), - "1995-1998, 2000, 2001"); - printf (_("Written by %s.\n"), "Ulrich Drepper"); - exit (EXIT_SUCCESS); - } - - /* Help is requested. */ - if (do_help) - usage (EXIT_SUCCESS); - /* Test whether we have some input files given. */ if (files_from == NULL && optind >= argc) {