Skip to content

Commit 5a4069a

Browse files
committed
Merge branch 'jc/c99-var-decl-in-for-loop'
Weather balloon to find compilers that do not grok variable declaration in the for() loop. * jc/c99-var-decl-in-for-loop: revision: use C99 declaration of variable in for() loop
2 parents a0f5ca9 + 44ba10d commit 5a4069a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ endif
12061206
# Set CFLAGS, LDFLAGS and other *FLAGS variables. These might be
12071207
# tweaked by config.* below as well as the command-line, both of
12081208
# which'll override these defaults.
1209+
# Older versions of GCC may require adding "-std=gnu99" at the end.
12091210
CFLAGS = -g -O2 -Wall
12101211
LDFLAGS =
12111212
CC_LD_DYNPATH = -Wl,-rpath,

revision.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ static inline int want_ancestry(const struct rev_info *revs);
4444

4545
void show_object_with_name(FILE *out, struct object *obj, const char *name)
4646
{
47-
const char *p;
48-
4947
fprintf(out, "%s ", oid_to_hex(&obj->oid));
50-
for (p = name; *p && *p != '\n'; p++)
48+
/*
49+
* This "for (const char *p = ..." is made as a first step towards
50+
* making use of such declarations elsewhere in our codebase. If
51+
* it causes compilation problems on your platform, please report
52+
* it to the Git mailing list at [email protected]. In the meantime,
53+
* adding -std=gnu99 to CFLAGS may help if you are with older GCC.
54+
*/
55+
for (const char *p = name; *p && *p != '\n'; p++)
5156
fputc(*p, out);
5257
fputc('\n', out);
5358
}

0 commit comments

Comments
 (0)