X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fargp.h;h=0c65a4cbd309eaf21be5062dad2a4b693ca33470;hb=02eb9acbac6b05f1d5f3acb89bcc4bbc45215e2a;hp=5694da4f5bb1b33952dc3d0781bb301648dbe0f2;hpb=a82fdff58064e24994117ed668ae13362253be46;p=gnulib.git diff --git a/lib/argp.h b/lib/argp.h index 5694da4f5..0c65a4cbd 100644 --- a/lib/argp.h +++ b/lib/argp.h @@ -1,5 +1,5 @@ /* Hierarchial argument parsing, layered over getopt. - Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc. + Copyright (C) 1995-1999,2003,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -34,6 +34,34 @@ #ifndef __THROW # define __THROW #endif +#ifndef __NTH +# define __NTH(fct) fct __THROW +#endif + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__ +# define __format__ format +# define __printf__ printf +# endif +#endif + +/* GCC 2.95 and later have "__restrict"; C99 compilers have + "restrict", and "configure" may have defined "restrict". */ +#ifndef __restrict +# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) +# if defined restrict || 199901L <= __STDC_VERSION__ +# define __restrict restrict +# else +# define __restrict +# endif +# endif +#endif #ifndef __error_t_defined typedef int error_t; @@ -98,11 +126,12 @@ struct argp_option should be displayed in much the same manner as the options. If this flag is set, then the option NAME field is displayed unmodified (e.g., no `--' prefix is added) at the left-margin (where a *short* option would normally - be displayed), and the documentation string in the normal place. For - purposes of sorting, any leading whitespace and punctuation is ignored, - except that if the first non-whitespace character is not `-', this entry - is displayed after all options (and OPTION_DOC entries with a leading `-') - in the same group. */ + be displayed), and the documentation string in the normal place. The NAME + field will be translated using gettext, unless OPTION_NO_TRANS is set (see + below). For purposes of sorting, any leading whitespace and punctuation is + ignored, except that if the first non-whitespace character is not `-', this + entry is displayed after all options (and OPTION_DOC entries with a leading + `-') in the same group. */ #define OPTION_DOC 0x8 /* This option shouldn't be included in `long' usage messages (but is still @@ -113,6 +142,11 @@ struct argp_option distinguish these two cases, -x should probably be marked OPTION_NO_USAGE. */ #define OPTION_NO_USAGE 0x10 + +/* Valid only in conjunction with OPTION_DOC. This option disables translation + of option name. */ +#define OPTION_NO_TRANS 0x20 + struct argp; /* fwd declare this type */ struct argp_state; /* " */ @@ -379,11 +413,11 @@ struct argp_state extern error_t argp_parse (__const struct argp *__restrict __argp, int __argc, char **__restrict __argv, unsigned __flags, int *__restrict __arg_index, - void *__restrict __input) __THROW; + void *__restrict __input); extern error_t __argp_parse (__const struct argp *__restrict __argp, int __argc, char **__restrict __argv, unsigned __flags, int *__restrict __arg_index, - void *__restrict __input) __THROW; + void *__restrict __input); /* Global variables. */ @@ -447,10 +481,10 @@ extern error_t argp_err_exit_status; ARGP_HELP_*. */ extern void argp_help (__const struct argp *__restrict __argp, FILE *__restrict __stream, - unsigned __flags, char *__restrict __name) __THROW; + unsigned __flags, char *__restrict __name); extern void __argp_help (__const struct argp *__restrict __argp, FILE *__restrict __stream, unsigned __flags, - char *__name) __THROW; + char *__name); /* The following routines are intended to be called from within an argp parsing routine (thus taking an argp_state structure as the first @@ -464,23 +498,23 @@ extern void __argp_help (__const struct argp *__restrict __argp, from the set ARGP_HELP_*. */ extern void argp_state_help (__const struct argp_state *__restrict __state, FILE *__restrict __stream, - unsigned int __flags) __THROW; + unsigned int __flags); extern void __argp_state_help (__const struct argp_state *__restrict __state, FILE *__restrict __stream, - unsigned int __flags) __THROW; + unsigned int __flags); /* Possibly output the standard usage message for ARGP to stderr and exit. */ -extern void argp_usage (__const struct argp_state *__state) __THROW; -extern void __argp_usage (__const struct argp_state *__state) __THROW; +extern void argp_usage (__const struct argp_state *__state); +extern void __argp_usage (__const struct argp_state *__state); /* If appropriate, print the printf string FMT and following args, preceded by the program name and `:', to stderr, and followed by a `Try ... --help' message, then exit (1). */ extern void argp_error (__const struct argp_state *__restrict __state, - __const char *__restrict __fmt, ...) __THROW + __const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern void __argp_error (__const struct argp_state *__restrict __state, - __const char *__restrict __fmt, ...) __THROW + __const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); /* Similar to the standard gnu error-reporting function error(), but will @@ -493,11 +527,11 @@ extern void __argp_error (__const struct argp_state *__restrict __state, parsing but don't reflect a (syntactic) problem with the input. */ extern void argp_failure (__const struct argp_state *__restrict __state, int __status, int __errnum, - __const char *__restrict __fmt, ...) __THROW + __const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 4, 5))); extern void __argp_failure (__const struct argp_state *__restrict __state, int __status, int __errnum, - __const char *__restrict __fmt, ...) __THROW + __const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 4, 5))); /* Returns true if the option OPT is a valid short option. */ @@ -532,13 +566,13 @@ extern void *__argp_input (__const struct argp *__restrict __argp, # endif ARGP_EI void -__argp_usage (__const struct argp_state *__state) __THROW +__NTH (__argp_usage (__const struct argp_state *__state)) { __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); } ARGP_EI int -__option_is_short (__const struct argp_option *__opt) __THROW +__NTH (__option_is_short (__const struct argp_option *__opt)) { if (__opt->flags & OPTION_DOC) return 0; @@ -550,7 +584,7 @@ __option_is_short (__const struct argp_option *__opt) __THROW } ARGP_EI int -__option_is_end (__const struct argp_option *__opt) __THROW +__NTH (__option_is_end (__const struct argp_option *__opt)) { return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; }