* autogen.sh (GNULIB_MODULES_RUNTIME_FOR_SRC, GNULIB_MODULES_TOOLS_FOR_SRC): Add
'options'. Remove 'getopt-gnu'.
* gettext-runtime/src/envsubst.c: Include options.h instead of <getopt.h>.
(long_options): Remove variable.
(main): Define options array here. Call start_options, get_next_option instead
of getopt_long().
* gettext-runtime/src/gettext.c: Likewise.
* gettext-runtime/src/ngettext.c: Likewise.
* gettext-runtime/src/printf_gettext.c: Likewise.
* gettext-runtime/src/printf_ngettext.c: Likewise.
* gettext-tools/src/cldr-plurals.c: Likewise.
* gettext-tools/src/hostname.c: Likewise.
* gettext-tools/src/msgattrib.c: Likewise.
* gettext-tools/src/msgcat.c: Likewise.
* gettext-tools/src/msgcmp.c: Likewise.
* gettext-tools/src/msgcomm.c: Likewise.
* gettext-tools/src/msgconv.c: Likewise.
* gettext-tools/src/msgen.c: Likewise.
* gettext-tools/src/msgexec.c: Likewise.
* gettext-tools/src/msgfilter.c: Likewise.
* gettext-tools/src/msgfmt.c: Likewise.
* gettext-tools/src/msggrep.c: Likewise.
* gettext-tools/src/msginit.c: Likewise.
* gettext-tools/src/msgmerge.c: Likewise.
* gettext-tools/src/msgunfmt.c: Likewise.
* gettext-tools/src/msguniq.c: Likewise.
* gettext-tools/src/recode-sr-latin.c: Likewise.
* gettext-tools/src/urlget.c: Likewise.
* gettext-tools/src/xgettext.c: Likewise.
* gettext-tools/tests/tstgettext.c: Likewise.
* gettext-tools/tests/tstngettext.c: Likewise.
closeout
error
fzprintf-posix
- getopt-gnu
gettext-h
havelib
mbrtoc32
mbszero
memmove
noreturn
+ options
progname
propername
quote
gcd
getaddrinfo
getline
- getopt-gnu
getrusage
gettext-h
gocomp-script
open
opendir
openmp-init
+ options
pipe-filter-ii
progname
propername
#endif
#include <errno.h>
-#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <error.h>
+#include "options.h"
#include "attribute.h"
#include "noreturn.h"
#include "closeout.h"
/* If true, substitution shall be performed on all variables. */
static bool all_variables;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "help", no_argument, NULL, 'h' },
- { "variables", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
static void print_variables (const char *string);
bool do_help = false;
bool do_version = false;
- int opt;
-
/* Set program name for message texts. */
set_program_name (argv[0]);
atexit (close_stdout);
/* Parse command line options. */
- while ((opt = getopt_long (argc, argv, "hvV", long_options, NULL)) != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "help", 'h', no_argument },
+ { "variables", 'v', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'h':
do_help = true;
# include <config.h>
#endif
-#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <error.h>
+#include "options.h"
#include "attribute.h"
#include "noreturn.h"
#include "closeout.h"
message catalog. */
static bool do_expand;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "context", required_argument, NULL, 'c' },
- { "domain", required_argument, NULL, 'd' },
- { "help", no_argument, NULL, 'h' },
- { "shell-script", no_argument, NULL, 's' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
const char *msgid;
/* Default values for command line options. */
atexit (close_stdout);
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "+c:d:eEhnsV", long_options, NULL))
- != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "context", 'c', required_argument },
+ { "domain", 'd', required_argument },
+ { "help", 'h', no_argument },
+ { "shell-script", 's', no_argument },
+ { "version", 'V', no_argument },
+ { NULL, 'e', no_argument },
+ { NULL, 'E', no_argument },
+ { NULL, 'n', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'c':
context = optarg;
# include <config.h>
#endif
-#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <error.h>
+#include "options.h"
#include "attribute.h"
#include "noreturn.h"
#include "closeout.h"
message catalog. */
static int do_expand;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "context", required_argument, NULL, 'c' },
- { "domain", required_argument, NULL, 'd' },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
const char *msgid;
const char *msgid_plural;
const char *count;
atexit (close_stdout);
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "+c:d:eEhV", long_options, NULL))
- != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "context", 'c', required_argument },
+ { "domain", 'd', required_argument },
+ { "help", 'h', no_argument },
+ { "version", 'V', no_argument },
+ { NULL, 'e', no_argument },
+ { NULL, 'E', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'c':
context = optarg;
# include <config.h>
#endif
-#include <getopt.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
+#include "options.h"
#include "printf-command.h"
#include "noreturn.h"
#include "closeout.h"
/* Parse command line options. */
{
- /* Long options. */
- static const struct option long_options[] =
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
{
- { "context", required_argument, NULL, 'c' },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
+ { "context", 'c', required_argument },
+ { "help", 'h', no_argument },
+ { "version", 'V', no_argument },
};
-
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
int optchar;
-
- while ((optchar = getopt_long (argc, argv, "+c:hV", long_options, NULL))
- != EOF)
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'c':
context = optarg;
#include <ctype.h>
#include <errno.h>
-#include <getopt.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
+#include "options.h"
#include "printf-command.h"
#include "noreturn.h"
#include "closeout.h"
/* Parse command line options. */
{
- /* Long options. */
- static const struct option long_options[] =
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
{
- { "context", required_argument, NULL, 'c' },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
+ { "context", 'c', required_argument },
+ { "help", 'h', no_argument },
+ { "version", 'V', no_argument },
};
-
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
int optchar;
-
- while ((optchar = getopt_long (argc, argv, "+c:hV", long_options, NULL))
- != EOF)
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'c':
context = optarg;
#include "c-ctype.h"
#include <errno.h>
#include <error.h>
-#include <getopt.h>
+#include "options.h"
#include "gettext.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
exit (status);
}
-/* Long options. */
-static const struct option long_options[] =
-{
- { "cldr", no_argument, NULL, 'c' },
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
int
main (int argc, char **argv)
{
bool opt_cldr_format = false;
bool do_help = false;
bool do_version = false;
- int optchar;
/* Set program name for messages. */
set_program_name (argv[0]);
/* Ensure that write errors on stdout are detected. */
atexit (close_stdout);
- while ((optchar = getopt_long (argc, argv, "chV", long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "cldr", 'c', no_argument },
+ { "help", 'h', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'c':
#endif
#include <errno.h>
-#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "error-progname.h"
/* Output format. */
static enum { default_format, short_format, long_format, ip_format } format;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "fqdn", no_argument, NULL, 'f' },
- { "help", no_argument, NULL, 'h' },
- { "ip-address", no_argument, NULL, 'i' },
- { "long", no_argument, NULL, 'f' },
- { "short", no_argument, NULL, 's' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
bool do_help;
bool do_version;
format = default_format;
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "fhisV", long_options, NULL))
- != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "fqdn", 'f', no_argument },
+ { "help", 'h', no_argument },
+ { "ip-address", 'i', no_argument },
+ { "long", 'f', no_argument },
+ { "short", 's', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'f':
format = long_format;
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
};
static int to_change;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "clear-fuzzy", no_argument, NULL, CHAR_MAX + 8 },
- { "clear-obsolete", no_argument, NULL, CHAR_MAX + 10 },
- { "clear-previous", no_argument, NULL, CHAR_MAX + 18 },
- { "empty", no_argument, NULL, CHAR_MAX + 23 },
- { "color", optional_argument, NULL, CHAR_MAX + 19 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "fuzzy", no_argument, NULL, CHAR_MAX + 11 },
- { "help", no_argument, NULL, 'h' },
- { "ignore-file", required_argument, NULL, CHAR_MAX + 15 },
- { "indent", no_argument, NULL, 'i' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-fuzzy", no_argument, NULL, CHAR_MAX + 3 },
- { "no-location", no_argument, NULL, CHAR_MAX + 22 },
- { "no-obsolete", no_argument, NULL, CHAR_MAX + 5 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 13 },
- { "obsolete", no_argument, NULL, CHAR_MAX + 12 },
- { "only-file", required_argument, NULL, CHAR_MAX + 14 },
- { "only-fuzzy", no_argument, NULL, CHAR_MAX + 4 },
- { "only-obsolete", no_argument, NULL, CHAR_MAX + 6 },
- { "output-file", required_argument, NULL, 'o' },
- { "previous", no_argument, NULL, CHAR_MAX + 21 },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "set-fuzzy", no_argument, NULL, CHAR_MAX + 7 },
- { "set-obsolete", no_argument, NULL, CHAR_MAX + 9 },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 16 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 17 },
- { "strict", no_argument, NULL, 'S' },
- { "style", required_argument, NULL, CHAR_MAX + 20 },
- { "translated", no_argument, NULL, CHAR_MAX + 1 },
- { "untranslated", no_argument, NULL, CHAR_MAX + 2 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int optchar;
bool do_help;
bool do_version;
char *output_file;
only_file = NULL;
ignore_file = NULL;
- while ((optchar = getopt_long (argc, argv, "D:eEFhino:pPsVw:", long_options,
- NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "clear-fuzzy", CHAR_MAX + 8, no_argument },
+ { "clear-obsolete", CHAR_MAX + 10, no_argument },
+ { "clear-previous", CHAR_MAX + 18, no_argument },
+ { "empty", CHAR_MAX + 23, no_argument },
+ { "color", CHAR_MAX + 19, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "fuzzy", CHAR_MAX + 11, no_argument },
+ { "help", 'h', no_argument },
+ { "ignore-file", CHAR_MAX + 15, required_argument },
+ { "indent", 'i', no_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-fuzzy", CHAR_MAX + 3, no_argument },
+ { "no-location", CHAR_MAX + 22, no_argument },
+ { "no-obsolete", CHAR_MAX + 5, no_argument },
+ { "no-wrap", CHAR_MAX + 13, no_argument },
+ { "obsolete", CHAR_MAX + 12, no_argument },
+ { "only-file", CHAR_MAX + 14, required_argument },
+ { "only-fuzzy", CHAR_MAX + 4, no_argument },
+ { "only-obsolete", CHAR_MAX + 6, no_argument },
+ { "output-file", 'o', required_argument },
+ { "previous", CHAR_MAX + 21, no_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "set-fuzzy", CHAR_MAX + 7, no_argument },
+ { "set-obsolete", CHAR_MAX + 9, no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "stringtable-input", CHAR_MAX + 16, no_argument },
+ { "stringtable-output", CHAR_MAX + 17, no_argument },
+ { "strict", CHAR_MAX + 24, no_argument },
+ { "style", CHAR_MAX + 20, required_argument },
+ { "translated", CHAR_MAX + 1, no_argument },
+ { "untranslated", CHAR_MAX + 2, no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 24: /* --strict */
message_print_style_uniforum ();
break;
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Target encoding. */
static const char *to_code;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 5 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "files-from", required_argument, NULL, 'f' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "lang", required_argument, NULL, CHAR_MAX + 7 },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-location", no_argument, NULL, CHAR_MAX + 8 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 2 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 3 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 4 },
- { "style", required_argument, NULL, CHAR_MAX + 6 },
- { "to-code", required_argument, NULL, 't' },
- { "unique", no_argument, NULL, 'u' },
- { "use-first", no_argument, NULL, CHAR_MAX + 1 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { "more-than", required_argument, NULL, '>' },
- { "less-than", required_argument, NULL, '<' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
main (int argc, char **argv)
{
int cnt;
- int optchar;
bool do_help;
bool do_version;
char *output_file;
less_than = INT_MAX;
use_first = false;
- while ((optchar = getopt_long (argc, argv, "<:>:D:eEf:Fhino:pPst:uVw:",
- long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 5, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "files-from", 'f', required_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "lang", CHAR_MAX + 7, required_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-location", CHAR_MAX + 8, no_argument },
+ { "no-wrap", CHAR_MAX + 2, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 9, no_argument },
+ { "stringtable-input", CHAR_MAX + 3, no_argument },
+ { "stringtable-output", CHAR_MAX + 4, no_argument },
+ { "style", CHAR_MAX + 6, required_argument },
+ { "to-code", 't', required_argument },
+ { "unique", 'u', no_argument },
+ { "use-first", CHAR_MAX + 1, no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ { "more-than", '>', required_argument },
+ { "less-than", '<', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case '>':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 9: /* --strict */
message_print_style_uniforum ();
break;
# include <config.h>
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <locale.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Whether to consider untranslated messages as translations. */
static bool include_untranslated = false;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "directory", required_argument, NULL, 'D' },
- { "help", no_argument, NULL, 'h' },
- { "multi-domain", no_argument, NULL, 'm' },
- { "no-fuzzy-matching", no_argument, NULL, 'N' },
- { "properties-input", no_argument, NULL, 'P' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 1 },
- { "use-fuzzy", no_argument, NULL, CHAR_MAX + 2 },
- { "use-untranslated", no_argument, NULL, CHAR_MAX + 3 },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
bool do_help;
bool do_version;
catalog_input_format_ty input_syntax = &input_format_po;
do_help = false;
do_version = false;
- while ((optchar = getopt_long (argc, argv, "D:hmNPV", long_options, NULL))
- != EOF)
+
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "directory", 'D', required_argument },
+ { "help", 'h', no_argument },
+ { "multi-domain", 'm', no_argument },
+ { "no-fuzzy-matching", 'N', no_argument },
+ { "properties-input", 'P', no_argument },
+ { "stringtable-input", CHAR_MAX + 1, no_argument },
+ { "use-fuzzy", CHAR_MAX + 2, no_argument },
+ { "use-untranslated", CHAR_MAX + 3, no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* long option */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
# include <config.h>
#endif
-#include <getopt.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Target encoding. */
static const char *to_code;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 5 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "files-from", required_argument, NULL, 'f' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-location", no_argument, NULL, CHAR_MAX + 7 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 2 },
- { "omit-header", no_argument, NULL, CHAR_MAX + 1 },
- { "output", required_argument, NULL, 'o' }, /* for backward compatibility */
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 3 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 4 },
- { "style", required_argument, NULL, CHAR_MAX + 6 },
- { "to-code", required_argument, NULL, 't' },
- { "unique", no_argument, NULL, 'u' },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { "more-than", required_argument, NULL, '>' },
- { "less-than", required_argument, NULL, '<' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
main (int argc, char *argv[])
{
int cnt;
- int optchar;
bool do_help = false;
bool do_version = false;
msgdomain_list_ty *result;
less_than = -1;
use_first = false;
- while ((optchar = getopt_long (argc, argv, "<:>:D:eEf:Fhino:pPst:uVw:",
- long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 5, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "files-from", 'f', required_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-location", CHAR_MAX + 7, no_argument },
+ { "no-wrap", CHAR_MAX + 2, no_argument },
+ { "omit-header", CHAR_MAX + 1, no_argument },
+ { "output", 'o', required_argument }, /* for backward compatibility */
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 8, no_argument },
+ { "stringtable-input", CHAR_MAX + 3, no_argument },
+ { "stringtable-output", CHAR_MAX + 4, no_argument },
+ { "style", CHAR_MAX + 6, required_argument },
+ { "to-code", 't', required_argument },
+ { "unique", 'u', no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ { "more-than", '>', required_argument },
+ { "less-than", '<', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case '>':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 8: /* --strict */
message_print_style_uniforum ();
break;
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Target encoding. */
static const char *to_code;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 4 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-location", no_argument, NULL, CHAR_MAX + 6 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 1 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 2 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 3 },
- { "style", required_argument, NULL, CHAR_MAX + 5 },
- { "to-code", required_argument, NULL, 't' },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
output_file = NULL;
input_file = NULL;
- while ((opt = getopt_long (argc, argv, "D:eEFhino:pPst:Vw:", long_options,
- NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 4, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-location", CHAR_MAX + 6, no_argument },
+ { "no-wrap", CHAR_MAX + 1, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 7, no_argument },
+ { "stringtable-input", CHAR_MAX + 2, no_argument },
+ { "stringtable-output", CHAR_MAX + 3, no_argument },
+ { "style", CHAR_MAX + 5, required_argument },
+ { "to-code", 't', required_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 7: /* --strict */
message_print_style_uniforum ();
break;
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Force output of PO file even if empty. */
static int force_po;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 5 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "lang", required_argument, NULL, CHAR_MAX + 4 },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-location", no_argument, NULL, CHAR_MAX + 7 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 1 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 2 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 3 },
- { "style", required_argument, NULL, CHAR_MAX + 6 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
do_version = false;
output_file = NULL;
- while ((opt = getopt_long (argc, argv,
- "D:eEFhino:pPsVw:",
- long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 5, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "lang", CHAR_MAX + 4, required_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-location", CHAR_MAX + 7, no_argument },
+ { "no-wrap", CHAR_MAX + 1, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 8, no_argument },
+ { "stringtable-input", CHAR_MAX + 2, no_argument },
+ { "stringtable-output", CHAR_MAX + 3, no_argument },
+ { "style", CHAR_MAX + 6, required_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 8: /* --strict */
message_print_style_uniforum ();
break;
#endif
#include <errno.h>
-#include <getopt.h>
#include <limits.h>
#include <locale.h>
#include <signal.h>
#include <unistd.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Maximum exit code encountered. */
static int exitcode;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "directory", required_argument, NULL, 'D' },
- { "help", no_argument, NULL, 'h' },
- { "input", required_argument, NULL, 'i' },
- { "newline", no_argument, NULL, CHAR_MAX + 2 },
- { "properties-input", no_argument, NULL, 'P' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 1 },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
const char *input_file;
do_version = false;
input_file = NULL;
- /* The '+' in the options string causes option parsing to terminate when
- the first non-option, i.e. the subprogram name, is encountered. */
- while ((opt = getopt_long (argc, argv, "+D:hi:PV", long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "directory", 'D', required_argument },
+ { "help", 'h', no_argument },
+ { "input", 'i', required_argument },
+ { "newline", CHAR_MAX + 2, no_argument },
+ { "properties-input", 'P', no_argument },
+ { "stringtable-input", CHAR_MAX + 1, no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ /* The flag NON_OPTION_TERMINATES_OPTIONS causes option parsing to terminate
+ when the first non-option, i.e. the subprogram name, is encountered. */
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Filter function. */
static void (*filter) (const char *str, size_t len, char **resultp, size_t *lengthp);
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 6 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, CHAR_MAX + 1 },
- { "input", required_argument, NULL, 'i' },
- { "keep-header", no_argument, &keep_header, 1 },
- { "newline", no_argument, NULL, CHAR_MAX + 9 },
- { "no-escape", no_argument, NULL, CHAR_MAX + 2 },
- { "no-location", no_argument, NULL, CHAR_MAX + 8 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 3 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 4 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 5 },
- { "style", required_argument, NULL, CHAR_MAX + 7 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
output_file = NULL;
input_file = NULL;
- /* The '+' in the options string causes option parsing to terminate when
- the first non-option, i.e. the subprogram name, is encountered. */
- while ((opt = getopt_long (argc, argv, "+D:EFhi:no:pPsVw:", long_options,
- NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 6, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", CHAR_MAX + 1, no_argument },
+ { "input", 'i', required_argument },
+ { "keep-header", 0, no_argument, &keep_header, 1 },
+ { "newline", CHAR_MAX + 9, no_argument },
+ { "no-escape", CHAR_MAX + 2, no_argument },
+ { "no-location", CHAR_MAX + 8, no_argument },
+ { "no-wrap", CHAR_MAX + 3, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 10, no_argument },
+ { "stringtable-input", CHAR_MAX + 4, no_argument },
+ { "stringtable-output", CHAR_MAX + 5, no_argument },
+ { "style", CHAR_MAX + 7, required_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ /* The flag NON_OPTION_TERMINATES_OPTIONS causes option parsing to terminate
+ when the first non-option, i.e. the subprogram name, is encountered. */
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'D':
input_file = optarg;
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 10: /* --strict */
message_print_style_uniforum ();
break;
#endif
#include <ctype.h>
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "str-list.h"
/* If not zero print statistics about translation at the end. */
static int do_statistics;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "alignment", required_argument, NULL, 'a' },
- { "check", no_argument, NULL, 'c' },
- { "check-accelerators", optional_argument, NULL, CHAR_MAX + 1 },
- { "check-compatibility", no_argument, NULL, 'C' },
- { "check-domain", no_argument, NULL, CHAR_MAX + 2 },
- { "check-format", no_argument, NULL, CHAR_MAX + 3 },
- { "check-header", no_argument, NULL, CHAR_MAX + 4 },
- { "csharp", no_argument, NULL, CHAR_MAX + 10 },
- { "csharp-resources", no_argument, NULL, CHAR_MAX + 11 },
- { "desktop", no_argument, NULL, CHAR_MAX + 15 },
- { "directory", required_argument, NULL, 'D' },
- { "endianness", required_argument, NULL, CHAR_MAX + 13 },
- { "help", no_argument, NULL, 'h' },
- { "java", no_argument, NULL, 'j' },
- { "java2", no_argument, NULL, CHAR_MAX + 5 },
- { "keyword", optional_argument, NULL, 'k' },
- { "language", required_argument, NULL, 'L' },
- { "locale", required_argument, NULL, 'l' },
- { "no-convert", no_argument, NULL, CHAR_MAX + 17 },
- { "no-hash", no_argument, NULL, CHAR_MAX + 6 },
- { "no-redundancy", no_argument, NULL, CHAR_MAX + 18 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "qt", no_argument, NULL, CHAR_MAX + 9 },
- { "replace-text", no_argument, NULL, CHAR_MAX + 19 },
- { "resource", required_argument, NULL, 'r' },
- { "source", no_argument, NULL, CHAR_MAX + 14 },
- { "statistics", no_argument, &do_statistics, 1 },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 8 },
- { "tcl", no_argument, NULL, CHAR_MAX + 7 },
- { "template", required_argument, NULL, CHAR_MAX + 16 },
- { "use-fuzzy", no_argument, NULL, 'f' },
- { "use-untranslated", no_argument, NULL, CHAR_MAX + 12 },
- { "verbose", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { "xml", no_argument, NULL, 'x' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int opt;
bool do_help = false;
bool do_version = false;
bool strict_uniforum = false;
/* Ensure that write errors on stdout are detected. */
atexit (close_stdout);
- while ((opt = getopt_long (argc, argv, "a:cCd:D:fhjk::l:L:o:Pr:vVx",
- long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "alignment", 'a', required_argument },
+ { "check", 'c', no_argument },
+ { "check-accelerators", CHAR_MAX + 1, optional_argument },
+ { "check-compatibility", 'C', no_argument },
+ { "check-domain", CHAR_MAX + 2, no_argument },
+ { "check-format", CHAR_MAX + 3, no_argument },
+ { "check-header", CHAR_MAX + 4, no_argument },
+ { "csharp", CHAR_MAX + 10, no_argument },
+ { "csharp-resources", CHAR_MAX + 11, no_argument },
+ { "desktop", CHAR_MAX + 15, no_argument },
+ { "directory", 'D', required_argument },
+ { "endianness", CHAR_MAX + 13, required_argument },
+ { "help", 'h', no_argument },
+ { "java", 'j', no_argument },
+ { "java2", CHAR_MAX + 5, no_argument },
+ { "keyword", 'k', optional_argument },
+ { "language", 'L', required_argument },
+ { "locale", 'l', required_argument },
+ { "no-convert", CHAR_MAX + 17, no_argument },
+ { "no-hash", CHAR_MAX + 6, no_argument },
+ { "no-redundancy", CHAR_MAX + 18, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "qt", CHAR_MAX + 9, no_argument },
+ { "replace-text", CHAR_MAX + 19, no_argument },
+ { "resource", 'r', required_argument },
+ { "source", CHAR_MAX + 14, no_argument },
+ { "statistics", 0, no_argument, &do_statistics, 1 },
+ { "strict", CHAR_MAX + 20, no_argument },
+ { "stringtable-input", CHAR_MAX + 8, no_argument },
+ { "tcl", CHAR_MAX + 7, no_argument },
+ { "template", CHAR_MAX + 16, required_argument },
+ { "use-fuzzy", 'f', no_argument },
+ { "use-untranslated", CHAR_MAX + 12, no_argument },
+ { "verbose", 'v', no_argument },
+ { "version", 'V', no_argument },
+ { "xml", 'x', no_argument },
+ { NULL, 'd', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'a':
if (isdigit ((unsigned char) optarg[0]))
java_resource_name = optarg;
csharp_resource_name = optarg;
break;
- case 'S':
+ case CHAR_MAX + 20: /* --strict */
strict_uniforum = true;
break;
case 'v':
#include <assert.h>
#include <errno.h>
-#include <getopt.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
};
static struct grep_task grep_task[5];
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 9 },
- { "comment", no_argument, NULL, 'C' },
- { "directory", required_argument, NULL, 'D' },
- { "domain", required_argument, NULL, 'M' },
- { "escape", no_argument, NULL, CHAR_MAX + 1 },
- { "extended-regexp", no_argument, NULL, 'E' },
- { "extracted-comment", no_argument, NULL, 'X' },
- { "file", required_argument, NULL, 'f' },
- { "fixed-strings", no_argument, NULL, 'F' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "ignore-case", no_argument, NULL, 'i' },
- { "indent", no_argument, NULL, CHAR_MAX + 2 },
- { "invert-match", no_argument, NULL, 'v' },
- { "location", required_argument, NULL, 'N' },
- { "msgctxt", no_argument, NULL, 'J' },
- { "msgid", no_argument, NULL, 'K' },
- { "msgstr", no_argument, NULL, 'T' },
- { "no-escape", no_argument, NULL, CHAR_MAX + 3 },
- { "no-location", no_argument, NULL, CHAR_MAX + 11 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 6 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "regexp", required_argument, NULL, 'e' },
- { "sort-by-file", no_argument, NULL, CHAR_MAX + 4 },
- { "sort-output", no_argument, NULL, CHAR_MAX + 5 },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 7 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 8 },
- { "style", required_argument, NULL, CHAR_MAX + 10 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void no_pass (int opt);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
gt->case_insensitive = false;
}
- while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiJKM:nN:o:pPTvVw:X",
- long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 9, optional_argument },
+ { "comment", 'C', no_argument },
+ { "directory", 'D', required_argument },
+ { "domain", 'M', required_argument },
+ { "escape", CHAR_MAX + 1, no_argument },
+ { "extended-regexp", 'E', no_argument },
+ { "extracted-comment", 'X', no_argument },
+ { "file", 'f', required_argument },
+ { "fixed-strings", 'F', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "ignore-case", 'i', no_argument },
+ { "indent", CHAR_MAX + 2, no_argument },
+ { "invert-match", 'v', no_argument },
+ { "location", 'N', required_argument },
+ { "msgctxt", 'J', no_argument },
+ { "msgid", 'K', no_argument },
+ { "msgstr", 'T', no_argument },
+ { "no-escape", CHAR_MAX + 3, no_argument },
+ { "no-location", CHAR_MAX + 11, no_argument },
+ { "no-wrap", CHAR_MAX + 6, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "regexp", 'e', required_argument },
+ { "sort-by-file", CHAR_MAX + 4, no_argument },
+ { "sort-output", CHAR_MAX + 5, no_argument },
+ { "strict", CHAR_MAX + 12, no_argument },
+ { "stringtable-input", CHAR_MAX + 7, no_argument },
+ { "stringtable-output", CHAR_MAX + 8, no_argument },
+ { "style", CHAR_MAX + 10, required_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'C':
string_list_append (domain_names, optarg);
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
input_syntax = &input_format_properties;
break;
- case 'S':
+ case CHAR_MAX + 12: /* --strict */
message_print_style_uniforum ();
break;
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <limits.h>
#include <locale.h>
#include <stdint.h>
#include <textstyle.h>
#include <error.h>
-
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "error-progname.h"
/* If true, the user is not considered to be the translator. */
static bool no_translator;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "color", optional_argument, NULL, CHAR_MAX + 5 },
- { "help", no_argument, NULL, 'h' },
- { "input", required_argument, NULL, 'i' },
- { "locale", required_argument, NULL, 'l' },
- { "no-translator", no_argument, NULL, CHAR_MAX + 1 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 2 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 3 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 4 },
- { "style", required_argument, NULL, CHAR_MAX + 6 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
static const char *find_pot (void);
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
input_file = NULL;
locale = NULL;
- while ((opt = getopt_long (argc, argv, "hi:l:o:pPVw:", long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "color", CHAR_MAX + 5, optional_argument },
+ { "help", 'h', no_argument },
+ { "input", 'i', required_argument },
+ { "locale", 'l', required_argument },
+ { "no-translator", CHAR_MAX + 1, no_argument },
+ { "no-wrap", CHAR_MAX + 2, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "stringtable-input", CHAR_MAX + 3, no_argument },
+ { "stringtable-output", CHAR_MAX + 4, no_argument },
+ { "style", CHAR_MAX + 6, required_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'h':
#endif
#include <alloca.h>
-#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
static const char *version_control_string;
static const char *backup_suffix_string;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "backup", required_argument, NULL, CHAR_MAX + 1 },
- { "color", optional_argument, NULL, CHAR_MAX + 9 },
- { "compendium", required_argument, NULL, 'C' },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "for-msgfmt", no_argument, NULL, CHAR_MAX + 12 },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "lang", required_argument, NULL, CHAR_MAX + 8 },
- { "multi-domain", no_argument, NULL, 'm' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-fuzzy-matching", no_argument, NULL, 'N' },
- { "no-location", no_argument, NULL, CHAR_MAX + 11 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 4 },
- { "output-file", required_argument, NULL, 'o' },
- { "previous", no_argument, NULL, CHAR_MAX + 7 },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "quiet", no_argument, NULL, 'q' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "silent", no_argument, NULL, 'q' },
- { "strict", no_argument, NULL, CHAR_MAX + 2 },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 5 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 6 },
- { "style", required_argument, NULL, CHAR_MAX + 10 },
- { "suffix", required_argument, NULL, CHAR_MAX + 3 },
- { "update", no_argument, NULL, 'U' },
- { "verbose", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
struct statistics
{
int
main (int argc, char **argv)
{
- int opt;
bool do_help;
bool do_version;
char *output_file;
output_file = NULL;
color = NULL;
- while ((opt = getopt_long (argc, argv, "C:D:eEFhimnNo:pPqsUvVw:",
- long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "backup", CHAR_MAX + 1, required_argument },
+ { "color", CHAR_MAX + 9, optional_argument },
+ { "compendium", 'C', required_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "for-msgfmt", CHAR_MAX + 12, no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "lang", CHAR_MAX + 8, required_argument },
+ { "multi-domain", 'm', no_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-fuzzy-matching", 'N', no_argument },
+ { "no-location", CHAR_MAX + 11, no_argument },
+ { "no-wrap", CHAR_MAX + 4, no_argument },
+ { "output-file", 'o', required_argument },
+ { "previous", CHAR_MAX + 7, no_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "quiet", 'q', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "silent", 'q', no_argument },
+ { "strict", CHAR_MAX + 2, no_argument },
+ { "stringtable-input", CHAR_MAX + 5, no_argument },
+ { "stringtable-output", CHAR_MAX + 6, no_argument },
+ { "style", CHAR_MAX + 10, required_argument },
+ { "suffix", CHAR_MAX + 3, required_argument },
+ { "update", 'U', no_argument },
+ { "verbose", 'v', no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'C':
multi_domain_mode = true;
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
# include <config.h>
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "error-progname.h"
/* Force output of PO file even if empty. */
static int force_po;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "color", optional_argument, NULL, CHAR_MAX + 6 },
- { "csharp", no_argument, NULL, CHAR_MAX + 4 },
- { "csharp-resources", no_argument, NULL, CHAR_MAX + 5 },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "java", no_argument, NULL, 'j' },
- { "locale", required_argument, NULL, 'l' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 2 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-output", no_argument, NULL, 'p' },
- { "resource", required_argument, NULL, 'r' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 3 },
- { "style", required_argument, NULL, CHAR_MAX + 7 },
- { "tcl", no_argument, NULL, CHAR_MAX + 1 },
- { "verbose", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int optchar;
bool do_help = false;
bool do_version = false;
const char *output_file = "-";
/* Ensure that write errors on stdout are detected. */
atexit (close_stdout);
- while ((optchar = getopt_long (argc, argv, "d:eEhijl:o:pr:svVw:",
- long_options, NULL))
- != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "color", CHAR_MAX + 6, optional_argument },
+ { "csharp", CHAR_MAX + 4, no_argument },
+ { "csharp-resources", CHAR_MAX + 5, no_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "java", 'j', no_argument },
+ { "locale", 'l', required_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-wrap", CHAR_MAX + 2, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-output", 'p', no_argument },
+ { "resource", 'r', required_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 8, no_argument },
+ { "stringtable-output", CHAR_MAX + 3, no_argument },
+ { "style", CHAR_MAX + 7, required_argument },
+ { "tcl", CHAR_MAX + 1, no_argument },
+ { "verbose", 'v', no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ { NULL, 'd', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0':
- /* long option */
+ case '\0': /* Long option with key == 0. */
break;
case 'd':
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 8: /* --strict */
message_print_style_uniforum ();
break;
# include "config.h"
#endif
-#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "dir-list.h"
/* Target encoding. */
static const char *to_code;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-location", optional_argument, NULL, 'n' },
- { "color", optional_argument, NULL, CHAR_MAX + 5 },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "force-po", no_argument, &force_po, 1 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-location", no_argument, NULL, CHAR_MAX + 7 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 2 },
- { "output-file", required_argument, NULL, 'o' },
- { "properties-input", no_argument, NULL, 'P' },
- { "properties-output", no_argument, NULL, 'p' },
- { "repeated", no_argument, NULL, 'd' },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "stringtable-input", no_argument, NULL, CHAR_MAX + 3 },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 4 },
- { "style", required_argument, NULL, CHAR_MAX + 6 },
- { "to-code", required_argument, NULL, 't' },
- { "unique", no_argument, NULL, 'u' },
- { "use-first", no_argument, NULL, CHAR_MAX + 1 },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char **argv)
{
- int optchar;
bool do_help;
bool do_version;
char *output_file;
less_than = INT_MAX;
use_first = false;
- while ((optchar = getopt_long (argc, argv, "dD:eEFhino:pPst:uVw:",
- long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "color", CHAR_MAX + 5, optional_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-location", CHAR_MAX + 7, no_argument },
+ { "no-wrap", CHAR_MAX + 2, no_argument },
+ { "output-file", 'o', required_argument },
+ { "properties-input", 'P', no_argument },
+ { "properties-output", 'p', no_argument },
+ { "repeated", 'd', no_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 8, no_argument },
+ { "stringtable-input", CHAR_MAX + 3, no_argument },
+ { "stringtable-output", CHAR_MAX + 4, no_argument },
+ { "style", CHAR_MAX + 6, required_argument },
+ { "to-code", 't', required_argument },
+ { "unique", 'u', no_argument },
+ { "use-first", CHAR_MAX + 1, no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'd':
message_print_style_indent ();
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 8: /* --strict */
message_print_style_uniforum ();
break;
#endif
#include <errno.h>
-#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#endif
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "progname.h"
#define _(str) gettext (str)
-/* Long options. */
-static const struct option long_options[] =
-{
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
static void process (FILE *stream);
bool do_help = false;
bool do_version = false;
- int opt;
-
/* Set program name for message texts. */
set_program_name (argv[0]);
atexit (close_stdout);
/* Parse command line options. */
- while ((opt = getopt_long (argc, argv, "hV", long_options, NULL)) != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "help", 'h', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int opt;
+ while ((opt = get_next_option ()) != -1)
switch (opt)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'h':
do_help = true;
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "closeout.h"
#include "error-progname.h"
produces no output for more than 10 seconds for no apparent reason. */
static bool verbose = true;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "help", no_argument, NULL, 'h' },
- { "quiet", no_argument, NULL, 'q' },
- { "silent", no_argument, NULL, 'q' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
bool do_help;
bool do_version;
do_version = false;
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "hqV", long_options, NULL)) != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "help", 'h', no_argument },
+ { "quiet", 'q', no_argument },
+ { "silent", 'q', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'h': /* --help */
do_help = true;
#include <ctype.h>
#include <errno.h>
-#include <getopt.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <textstyle.h>
#include <error.h>
+#include "options.h"
#include "noreturn.h"
#include "rc-str-list.h"
#include "xg-encoding.h"
shall be ignored. */
static gl_set_t generated_files;
-/* Long options. */
-static const struct option long_options[] =
-{
- { "add-comments", optional_argument, NULL, 'c' },
- { "add-location", optional_argument, NULL, 'n' },
- { "boost", no_argument, NULL, CHAR_MAX + 11 },
- { "c++", no_argument, NULL, 'C' },
- { "check", required_argument, NULL, CHAR_MAX + 17 },
- { "color", optional_argument, NULL, CHAR_MAX + 14 },
- { "copyright-holder", required_argument, NULL, CHAR_MAX + 1 },
- { "debug", no_argument, &do_debug, 1 },
- { "default-domain", required_argument, NULL, 'd' },
- { "directory", required_argument, NULL, 'D' },
- { "escape", no_argument, NULL, 'E' },
- { "exclude-file", required_argument, NULL, 'x' },
- { "extract-all", no_argument, NULL, 'a' },
- { "files-from", required_argument, NULL, 'f' },
- { "flag", required_argument, NULL, CHAR_MAX + 8 },
- { "force-po", no_argument, &force_po, 1 },
- { "foreign-user", no_argument, NULL, CHAR_MAX + 2 },
- { "from-code", required_argument, NULL, CHAR_MAX + 3 },
- { "generated", required_argument, NULL, CHAR_MAX + 24 },
- { "help", no_argument, NULL, 'h' },
- { "indent", no_argument, NULL, 'i' },
- { "its", required_argument, NULL, CHAR_MAX + 20 },
- { "itstool", no_argument, NULL, CHAR_MAX + 19 },
- { "join-existing", no_argument, NULL, 'j' },
- { "kde", no_argument, NULL, CHAR_MAX + 10 },
- { "keyword", optional_argument, NULL, 'k' },
- { "language", required_argument, NULL, 'L' },
- { "msgid-bugs-address", required_argument, NULL, CHAR_MAX + 5 },
- { "msgstr-prefix", optional_argument, NULL, 'm' },
- { "msgstr-suffix", optional_argument, NULL, 'M' },
- { "no-escape", no_argument, NULL, 'e' },
- { "no-git", no_argument, NULL, CHAR_MAX + 23 },
- { "no-location", no_argument, NULL, CHAR_MAX + 16 },
- { "no-wrap", no_argument, NULL, CHAR_MAX + 4 },
- { "omit-header", no_argument, &xgettext_omit_header, 1 },
- { "output", required_argument, NULL, 'o' },
- { "output-dir", required_argument, NULL, 'p' },
- { "package-name", required_argument, NULL, CHAR_MAX + 12 },
- { "package-version", required_argument, NULL, CHAR_MAX + 13 },
- { "properties-output", no_argument, NULL, CHAR_MAX + 6 },
- { "qt", no_argument, NULL, CHAR_MAX + 9 },
- { "reference", required_argument, NULL, CHAR_MAX + 22 },
- { "sentence-end", required_argument, NULL, CHAR_MAX + 18 },
- { "sort-by-file", no_argument, NULL, 'F' },
- { "sort-output", no_argument, NULL, 's' },
- { "strict", no_argument, NULL, 'S' },
- { "string-limit", required_argument, NULL, 'l' },
- { "stringtable-output", no_argument, NULL, CHAR_MAX + 7 },
- { "style", required_argument, NULL, CHAR_MAX + 15 },
- { "tag", required_argument, NULL, CHAR_MAX + 21 },
- { "trigraphs", no_argument, NULL, 'T' },
- { "verbose", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
- { "width", required_argument, NULL, 'w' },
- { NULL, 0, NULL, 0 }
-};
-
/* The extractors must all be functions returning void and taking as arguments
- the file name or file stream,
int
main (int argc, char *argv[])
{
- int optchar;
bool do_help = false;
bool do_version = false;
msgdomain_list_ty *mdlp;
init_flag_table_gcc_internal ();
init_flag_table_ycp ();
- while ((optchar = getopt_long (argc, argv,
- "ac::Cd:D:eEf:Fhijk::l:L:m::M::no:p:sTvVw:x:",
- long_options, NULL)) != EOF)
+ /* Parse command line options. */
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "add-comments", 'c', optional_argument },
+ { "add-location", CHAR_MAX + 'n', optional_argument },
+ { NULL, 'n', no_argument },
+ { "boost", CHAR_MAX + 11, no_argument },
+ { "c++", 'C', no_argument },
+ { "check", CHAR_MAX + 17, required_argument },
+ { "color", CHAR_MAX + 14, optional_argument },
+ { "copyright-holder", CHAR_MAX + 1, required_argument },
+ { "debug", 0, no_argument, &do_debug, 1 },
+ { "default-domain", 'd', required_argument },
+ { "directory", 'D', required_argument },
+ { "escape", 'E', no_argument },
+ { "exclude-file", 'x', required_argument },
+ { "extract-all", 'a', no_argument },
+ { "files-from", 'f', required_argument },
+ { "flag", CHAR_MAX + 8, required_argument },
+ { "force-po", 0, no_argument, &force_po, 1 },
+ { "foreign-user", CHAR_MAX + 2, no_argument },
+ { "from-code", CHAR_MAX + 3, required_argument },
+ { "generated", CHAR_MAX + 24, required_argument },
+ { "help", 'h', no_argument },
+ { "indent", 'i', no_argument },
+ { "its", CHAR_MAX + 20, required_argument },
+ { "itstool", CHAR_MAX + 19, no_argument },
+ { "join-existing", 'j', no_argument },
+ { "kde", CHAR_MAX + 10, no_argument },
+ { "keyword", 'k', optional_argument },
+ { "language", 'L', required_argument },
+ { "msgid-bugs-address", CHAR_MAX + 5, required_argument },
+ { "msgstr-prefix", 'm', optional_argument },
+ { "msgstr-suffix", 'M', optional_argument },
+ { "no-escape", 'e', no_argument },
+ { "no-git", CHAR_MAX + 23, no_argument },
+ { "no-location", CHAR_MAX + 16, no_argument },
+ { "no-wrap", CHAR_MAX + 4, no_argument },
+ { "omit-header", 0, no_argument, &xgettext_omit_header, 1 },
+ { "output", 'o', required_argument },
+ { "output-dir", 'p', required_argument },
+ { "package-name", CHAR_MAX + 12, required_argument },
+ { "package-version", CHAR_MAX + 13, required_argument },
+ { "properties-output", CHAR_MAX + 6, no_argument },
+ { "qt", CHAR_MAX + 9, no_argument },
+ { "reference", CHAR_MAX + 22, required_argument },
+ { "sentence-end", CHAR_MAX + 18, required_argument },
+ { "sort-by-file", 'F', no_argument },
+ { "sort-output", 's', no_argument },
+ { "strict", CHAR_MAX + 25, no_argument },
+ { "string-limit", 'l', required_argument },
+ { "stringtable-output", CHAR_MAX + 7, no_argument },
+ { "style", CHAR_MAX + 15, required_argument },
+ { "tag", CHAR_MAX + 21, required_argument },
+ { "trigraphs", 'T', no_argument },
+ { "verbose", 'v', no_argument },
+ { "version", 'V', no_argument },
+ { "width", 'w', required_argument },
+ { NULL, 'W', required_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, MOVE_OPTIONS_FIRST, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'a':
msgstr_suffix = optarg == NULL ? "" : optarg;
break;
- case 'n':
+ case 'n': /* -n */
+ case CHAR_MAX + 'n': /* --add-location[={full|yes|file|never|no}] */
if (handle_filepos_comment_option (optarg))
usage (EXIT_FAILURE);
break;
sort_by_msgid = true;
break;
- case 'S':
+ case CHAR_MAX + 25: /* --strict */
message_print_style_uniforum ();
break;
/* gettext - retrieve text string from message catalog and print it.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, May 1995.
This program is free software: you can redistribute it and/or modify
# include <config.h>
#endif
-#include <getopt.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <error.h>
+#include "options.h"
#include "attribute.h"
#include "noreturn.h"
#include "closeout.h"
#define _(str) gettext (str)
-/* Long options. */
-static const struct option long_options[] =
-{
- { "domain", required_argument, NULL, 'd' },
- { "env", required_argument, NULL, '=' },
- { "help", no_argument, NULL, 'h' },
- { "shell-script", no_argument, NULL, 's' },
- { "thread", no_argument, NULL, 't' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void *worker_thread (void *arg);
_GL_NORETURN_FUNC static void usage (int status);
int
main (int argc, char *argv[])
{
- int optchar;
-
/* Default values for command line options. */
bool do_help = false;
bool do_thread = false;
atexit (close_stdout);
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "+d:eEhnstV", long_options, NULL))
- != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "domain", 'd', required_argument },
+ { "env", CHAR_MAX + 1, required_argument },
+ { "help", 'h', no_argument },
+ { "shell-script", 's', no_argument },
+ { "thread", 't', no_argument },
+ { "version", 'V', no_argument },
+ { NULL, 'e', no_argument },
+ { NULL, 'E', no_argument },
+ { NULL, 'n', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'd':
context.domain = optarg;
case 'V':
do_version = true;
break;
- case '=':
+ case CHAR_MAX + 1: /* --env */
{
/* Undocumented option --env sets an environment variable. */
char *separator = strchr (optarg, '=');
# include <config.h>
#endif
-#include <getopt.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <error.h>
+#include "options.h"
#include "attribute.h"
#include "noreturn.h"
#include "closeout.h"
#define _(str) gettext (str)
-/* Long options. */
-static const struct option long_options[] =
-{
- { "domain", required_argument, NULL, 'd' },
- { "env", required_argument, NULL, '=' },
- { "help", no_argument, NULL, 'h' },
- { "thread", no_argument, NULL, 't' },
- { "version", no_argument, NULL, 'V' },
- { NULL, 0, NULL, 0 }
-};
-
/* Forward declaration of local functions. */
_GL_NORETURN_FUNC static void *worker_thread (void *arg);
_GL_NORETURN_FUNC static void usage (int __status);
int
main (int argc, char *argv[])
{
- int optchar;
-
/* Default values for command line options. */
bool do_help = false;
bool do_thread = false;
atexit (close_stdout);
/* Parse command line options. */
- while ((optchar = getopt_long (argc, argv, "+d:htV", long_options, NULL))
- != EOF)
+ BEGIN_ALLOW_OMITTING_FIELD_INITIALIZERS
+ static const struct program_option options[] =
+ {
+ { "domain", 'd', required_argument },
+ { "env", CHAR_MAX + 1, required_argument },
+ { "help", 'h', no_argument },
+ { "thread", 't', no_argument },
+ { "version", 'V', no_argument },
+ };
+ END_ALLOW_OMITTING_FIELD_INITIALIZERS
+ start_options (argc, argv, options, NON_OPTION_TERMINATES_OPTIONS, 0);
+ int optchar;
+ while ((optchar = get_next_option ()) != -1)
switch (optchar)
{
- case '\0': /* Long option. */
+ case '\0': /* Long option with key == 0. */
break;
case 'd':
context.domain = optarg;
case 'V':
do_version = true;
break;
- case '=':
+ case CHAR_MAX + 1: /* --env */
{
/* Undocumented option --env sets an environment variable. */
char *separator = strchr (optarg, '=');