git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC v2 1/2] parse-options: export opterr, optbug

From
Dmitry Ivankov <divanorama@gmail.com>
Date
Jul 3, 2011, 11:04 UTC
Message-ID
<1309691045-30180-1-git-send-email-divanorama@gmail.com>
In-Reply-To
<20110629202959.GJ22556@elie>

opterror and optbug functions are used by some of parsing routines in parse-options.c to report errors and bugs respectively.

Export these functions to allow more custom parsing routines to use them in a uniform way.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
 parse-options.c |    4 ++--
 parse-options.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index 73bd28a..37a1d3b 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -11,14 +11,14 @@ static int parse_options_usage(struct parse_opt_ctx_t *ctx,
 #define OPT_SHORT 1
 #define OPT_UNSET 2
 
-static int optbug(const struct option *opt, const char *reason)
+int optbug(const struct option *opt, const char *reason)
 {
 	if (opt->long_name)
 		return error("BUG: option '%s' %s", opt->long_name, reason);
 	return error("BUG: switch '%c' %s", opt->short_name, reason);
 }
 
-static int opterror(const struct option *opt, const char *reason, int flags)
+int opterror(const struct option *opt, const char *reason, int flags)
 {
 	if (flags & OPT_SHORT)
 		return error("switch `%c' %s", opt->short_name, reason);
diff --git a/parse-options.h b/parse-options.h
index d1b12fe..b392590 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -162,6 +162,8 @@ extern NORETURN void usage_msg_opt(const char *msg,
 				   const char * const *usagestr,
 				   const struct option *options);
 
+extern int optbug(const struct option *opt, const char *reason);
+extern int opterror(const struct option *opt, const char *reason, int flags);
 /*----- incremental advanced APIs -----*/
 
 enum {
-- 
1.7.3.4
Previous: Jonathan NiederNext: Dmitry Ivankov
Message 3 of 4 in “Reduce parse-options.o dependencies”
  1. Reduce parse-options.o dependenciesDmitry Ivankov, Jun 25, 2011
  2. Jonathan NiederJun 29, 2011
  3. 1/2 parse-options: export opterr, optbugDmitry Ivankov, Jul 3, 2011
  4. 2/2 Reduce parse-options.o dependenciesDmitry Ivankov, Jul 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.