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

[PATCH] grep: make callback functions static

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
May 20, 2009, 22:05 UTC
Message-ID
<4A147EA2.7050203@lsrfire.ath.cx>
In-Reply-To
<4A0E8AEF.3000704@gmail.com>

Suggested by Stephen Boyd: make the callback functions used for option parsing static.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
Patch applies to next.
 builtin-grep.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index 169a91c..5308b34 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -565,7 +565,8 @@ static int grep_object(struct grep_opt *opt, const char **paths,
 	die("unable to grep from object of type %s", typename(obj->type));
 }
 
-int context_callback(const struct option *opt, const char *arg, int unset)
+static int context_callback(const struct option *opt, const char *arg,
+			    int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	int value;
@@ -584,7 +585,7 @@ int context_callback(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
-int file_callback(const struct option *opt, const char *arg, int unset)
+static int file_callback(const struct option *opt, const char *arg, int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	FILE *patterns;
@@ -606,42 +607,43 @@ int file_callback(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
-int not_callback(const struct option *opt, const char *arg, int unset)
+static int not_callback(const struct option *opt, const char *arg, int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	append_grep_pattern(grep_opt, "--not", "command line", 0, GREP_NOT);
 	return 0;
 }
 
-int and_callback(const struct option *opt, const char *arg, int unset)
+static int and_callback(const struct option *opt, const char *arg, int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	append_grep_pattern(grep_opt, "--and", "command line", 0, GREP_AND);
 	return 0;
 }
 
-int open_callback(const struct option *opt, const char *arg, int unset)
+static int open_callback(const struct option *opt, const char *arg, int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	append_grep_pattern(grep_opt, "(", "command line", 0, GREP_OPEN_PAREN);
 	return 0;
 }
 
-int close_callback(const struct option *opt, const char *arg, int unset)
+static int close_callback(const struct option *opt, const char *arg, int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	append_grep_pattern(grep_opt, ")", "command line", 0, GREP_CLOSE_PAREN);
 	return 0;
 }
 
-int pattern_callback(const struct option *opt, const char *arg, int unset)
+static int pattern_callback(const struct option *opt, const char *arg,
+			    int unset)
 {
 	struct grep_opt *grep_opt = opt->value;
 	append_grep_pattern(grep_opt, arg, "-e option", 0, GREP_PATTERN);
 	return 0;
 }
 
-int help_callback(const struct option *opt, const char *arg, int unset)
+static int help_callback(const struct option *opt, const char *arg, int unset)
 {
 	return -1;
 }
-- 
1.6.3.1
Previous: René Scharfe
Message 10 of 10 in “grep parseopt conversion”
  1. 0/5 grep parseopt conversionRené Scharfe, May 7, 2009
  2. 1/5 parseopt: add OPT_NEGBITRené Scharfe, May 7, 2009
  3. Jeff KingMay 8, 2009
  4. 2/5 parseopt: add OPT_NUMBER_CALLBACKRené Scharfe, May 7, 2009
  5. 3/5 parseopt: add PARSE_OPT_NODASHRené Scharfe, May 7, 2009
  6. 4/5 grep: remove global variable builtin_grepRené Scharfe, May 7, 2009
  7. 5/5 grep: use parseoptRené Scharfe, May 7, 2009
  8. Stephen BoydMay 16, 2009
  9. René ScharfeMay 17, 2009
  10. grep: make callback functions staticRené Scharfe, May 20, 2009

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.