+++ /dev/null
-From 49d6cfa5c2874d78360dc4b16558bb45b5f8e003 Mon Sep 17 00:00:00 2001
-From: Jeff King <peff@peff.net>
-Date: Mon, 26 Aug 2013 17:57:18 -0400
-Subject: [PATCH] config: do not use C function names as struct members
-
-According to C99, section 7.1.4:
-
- Any function declared in a header may be additionally
- implemented as a function-like macro defined in the
- header.
-
-Therefore calling our struct member function pointer "fgetc"
-may run afoul of unwanted macro expansion when we call:
-
- char c = cf->fgetc(cf);
-
-This turned out to be a problem on uclibc, which defines
-fgetc as a macro and causes compilation failure.
-
-The standard suggests fixing this in a few ways:
-
- 1. Using extra parentheses to inhibit the function-like
- macro expansion. E.g., "(cf->fgetc)(cf)". This is
- undesirable as it's ugly, and each call site needs to
- remember to use it (and on systems without the macro,
- forgetting will compile just fine).
-
- 2. Using #undef (because a conforming implementation must
- also be providing fgetc as a function). This is
- undesirable because presumably the implementation was
- using the macro for a performance benefit, and we are
- dropping that optimization.
-
-Instead, we can simply use non-colliding names.
-
-Signed-off-by: Jeff King <peff@peff.net>
-Signed-off-by: Junio C Hamano <gitster@pobox.com>
----
- config.c | 32 ++++++++++++++++----------------
- 1 file changed, 16 insertions(+), 16 deletions(-)
-
-diff --git a/config.c b/config.c
-index 680dd6d..95f9a44 100644
---- a/config.c
-+++ b/config.c
-@@ -27,9 +27,9 @@ struct config_source {
- struct strbuf value;
- struct strbuf var;
-
-- int (*fgetc)(struct config_source *c);
-- int (*ungetc)(int c, struct config_source *conf);
-- long (*ftell)(struct config_source *c);
-+ int (*do_fgetc)(struct config_source *c);
-+ int (*do_ungetc)(int c, struct config_source *conf);
-+ long (*do_ftell)(struct config_source *c);
- };
-
- static struct config_source *cf;
-@@ -217,13 +217,13 @@ int git_config_from_parameters(config_fn_t fn, void *data)
-
- static int get_next_char(void)
- {
-- int c = cf->fgetc(cf);
-+ int c = cf->do_fgetc(cf);
-
- if (c == '\r') {
- /* DOS like systems */
-- c = cf->fgetc(cf);
-+ c = cf->do_fgetc(cf);
- if (c != '\n') {
-- cf->ungetc(c, cf);
-+ cf->do_ungetc(c, cf);
- c = '\r';
- }
- }
-@@ -982,9 +982,9 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
- top.u.file = f;
- top.name = filename;
- top.die_on_error = 1;
-- top.fgetc = config_file_fgetc;
-- top.ungetc = config_file_ungetc;
-- top.ftell = config_file_ftell;
-+ top.do_fgetc = config_file_fgetc;
-+ top.do_ungetc = config_file_ungetc;
-+ top.do_ftell = config_file_ftell;
-
- ret = do_config_from(&top, fn, data);
-
-@@ -1003,9 +1003,9 @@ int git_config_from_buf(config_fn_t fn, const char *name, const char *buf,
- top.u.buf.pos = 0;
- top.name = name;
- top.die_on_error = 0;
-- top.fgetc = config_buf_fgetc;
-- top.ungetc = config_buf_ungetc;
-- top.ftell = config_buf_ftell;
-+ top.do_fgetc = config_buf_fgetc;
-+ top.do_ungetc = config_buf_ungetc;
-+ top.do_ftell = config_buf_ftell;
-
- return do_config_from(&top, fn, data);
- }
-@@ -1186,7 +1186,7 @@ static int store_aux(const char *key, const char *value, void *cb)
- return 1;
- }
-
-- store.offset[store.seen] = cf->ftell(cf);
-+ store.offset[store.seen] = cf->do_ftell(cf);
- store.seen++;
- }
- break;
-@@ -1213,19 +1213,19 @@ static int store_aux(const char *key, const char *value, void *cb)
- * Do not increment matches: this is no match, but we
- * just made sure we are in the desired section.
- */
-- store.offset[store.seen] = cf->ftell(cf);
-+ store.offset[store.seen] = cf->do_ftell(cf);
- /* fallthru */
- case SECTION_END_SEEN:
- case START:
- if (matches(key, value)) {
-- store.offset[store.seen] = cf->ftell(cf);
-+ store.offset[store.seen] = cf->do_ftell(cf);
- store.state = KEY_SEEN;
- store.seen++;
- } else {
- if (strrchr(key, '.') - key == store.baselen &&
- !strncmp(key, store.key, store.baselen)) {
- store.state = SECTION_SEEN;
-- store.offset[store.seen] = cf->ftell(cf);
-+ store.offset[store.seen] = cf->do_ftell(cf);
- }
- }
- }
---
-1.8.3.2
-
--- a/Makefile
+++ b/Makefile
-@@ -540,16 +540,7 @@ EXTRA_PROGRAMS =
+@@ -537,16 +537,7 @@ EXTRA_PROGRAMS =
# ... and all the rest that could be moved out of bindir to gitexecdir
PROGRAMS += $(EXTRA_PROGRAMS)
# Binary suffix, set to .exe for Windows builds
X =
-@@ -996,6 +987,12 @@ BUILTIN_OBJS += builtin/var.o
+@@ -993,6 +984,12 @@ BUILTIN_OBJS += builtin/var.o
BUILTIN_OBJS += builtin/verify-pack.o
BUILTIN_OBJS += builtin/verify-tag.o
BUILTIN_OBJS += builtin/write-tree.o
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
EXTLIBS =
-@@ -1159,7 +1156,7 @@ endif
+@@ -1156,7 +1153,7 @@ endif
EXTLIBS += -lz
ifndef NO_OPENSSL
ifdef OPENSSLDIR
BASIC_CFLAGS += -I$(OPENSSLDIR)/include
OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
-@@ -2048,10 +2045,6 @@ endif
+@@ -2040,10 +2037,6 @@ endif
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
git-http-fetch$X: revision.o http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL)
-@@ -2363,24 +2356,22 @@ endif
+@@ -2355,24 +2348,22 @@ endif
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
{ test "$$bindir/" = "$$execdir/" || \
const char **user_argv;
--- a/upload-pack.c
+++ b/upload-pack.c
-@@ -788,7 +788,7 @@ static int upload_pack_config(const char
+@@ -747,7 +747,7 @@ static int upload_pack_config(const char
return parse_hide_refs_config(var, value, "uploadpack");
}