aboutsummaryrefslogtreecommitdiff
path: root/argp
diff options
context:
space:
mode:
Diffstat (limited to 'argp')
-rw-r--r--argp/Makefile2
-rw-r--r--argp/argp-ba.c2
-rw-r--r--argp/argp-eexst.c29
-rw-r--r--argp/argp-help.c8
-rw-r--r--argp/argp-pv.c2
-rw-r--r--argp/argp.h8
6 files changed, 42 insertions, 9 deletions
diff --git a/argp/Makefile b/argp/Makefile
index 68fab3cd14..c151569913 100644
--- a/argp/Makefile
+++ b/argp/Makefile
@@ -24,7 +24,7 @@ subdir := argp
headers = argp.h
distribute = argp-fmtstream.h argp-namefrob.h
routines = $(addprefix argp-, ba fmtstream fs-xinl help parse pv \
- pvh xinl)
+ pvh xinl eexst)
tests = argp-test
diff --git a/argp/argp-ba.c b/argp/argp-ba.c
index 61efc3466a..5d58cc6c51 100644
--- a/argp/argp-ba.c
+++ b/argp/argp-ba.c
@@ -23,4 +23,4 @@
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */
-char *argp_program_bug_address = 0;
+const char *argp_program_bug_address = 0;
diff --git a/argp/argp-eexst.c b/argp/argp-eexst.c
new file mode 100644
index 0000000000..676d1ec517
--- /dev/null
+++ b/argp/argp-eexst.c
@@ -0,0 +1,29 @@
+/* Default definition for ARGP_ERR_EXIT_STATUS
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "argp.h"
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to 1. */
+error_t argp_err_exit_status = 1;
diff --git a/argp/argp-help.c b/argp/argp-help.c
index e954beb5a9..b3d8b36418 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -156,7 +156,7 @@ fill_in_uparams (const struct argp_state *state)
arg++;
SKIPWS (arg);
}
-
+
if (unspec)
if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
{
@@ -878,7 +878,7 @@ arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
/* Helper functions for hol_entry_help. */
/* State used during the execution of hol_help. */
-struct hol_help_state
+struct hol_help_state
{
/* PREV_ENTRY should contain the previous entry printed, or 0. */
struct hol_entry *prev_entry;
@@ -1600,7 +1600,7 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
if (!state || ! (state->flags & ARGP_NO_EXIT))
{
if (flags & ARGP_HELP_EXIT_ERR)
- exit (1);
+ exit (argp_err_exit_status);
if (flags & ARGP_HELP_EXIT_OK)
exit (0);
}
@@ -1612,7 +1612,7 @@ weak_alias (__argp_state_help, argp_state_help)
/* 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). */
+ message, then exit (ARGP_ERR_EXIT_STATUS). */
void
__argp_error (const struct argp_state *state, const char *fmt, ...)
{
diff --git a/argp/argp-pv.c b/argp/argp-pv.c
index 59e6f8d07b..27d714b361 100644
--- a/argp/argp-pv.c
+++ b/argp/argp-pv.c
@@ -22,4 +22,4 @@
--version is added (unless the ARGP_NO_HELP flag is used), which will
print this this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
-char *argp_program_version = 0;
+const char *argp_program_version = 0;
diff --git a/argp/argp.h b/argp/argp.h
index cdb32b799a..d418253692 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -240,7 +240,7 @@ struct argp
TEXT is NULL for this key. */
/* Explanatory note emitted when duplicate option arguments have been
suppressed. */
-#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
+#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
/* When an argp has a non-zero CHILDREN field, it should point to a vector of
argp_child structures, each of which describes a subsidiary argp. */
@@ -379,7 +379,7 @@ extern error_t __argp_parse __P ((__const struct argp *__argp,
option --version is added (unless the ARGP_NO_HELP flag is used), which
will print this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
-extern const char *argp_program_version;
+extern __const char *argp_program_version;
/* If defined or set by the user program to a non-zero value, then a default
option --version is added (unless the ARGP_NO_HELP flag is used), which
@@ -395,6 +395,10 @@ extern void (*argp_program_version_hook) __P ((FILE *__stream,
standard help messages), embedded in a sentence that says something like
`Report bugs to ADDR.'. */
__const extern char *argp_program_bug_address;
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to 1. */
+extern error_t argp_err_exit_status;
/* Flags for argp_help. */
#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */