Skip to content
This repository was archived by the owner on Jul 2, 2019. It is now read-only.

Commit 6c2f207

Browse files
spearceJunio C Hamano
authored andcommitted
Remove unsupported C99 style struct initializers in git-archive.
At least one older version of the Solaris C compiler doesn't support the newer C99 style struct initializers. To allow Git to compile on those systems use an archive description struct which is easier to initialize without the C99 struct initializer syntax. Also since the archives array is not used by anyone other than archive.c we can make it static. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af8ffbe commit 6c2f207

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

archive.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ struct archiver {
2525
parse_extra_args_fn_t parse_extra;
2626
};
2727

28-
extern struct archiver archivers[];
29-
3028
extern int parse_archive_args(int argc,
3129
const char **argv,
3230
struct archiver *ar);

builtin-archive.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
static const char archive_usage[] = \
1616
"git-archive --format=<fmt> [--prefix=<prefix>/] [--verbose] [<extra>] <tree-ish> [path...]";
1717

18-
struct archiver archivers[] = {
19-
{
20-
.name = "tar",
21-
.write_archive = write_tar_archive,
22-
},
23-
{
24-
.name = "zip",
25-
.write_archive = write_zip_archive,
26-
.parse_extra = parse_extra_zip_args,
27-
},
18+
static struct archiver_desc
19+
{
20+
const char *name;
21+
write_archive_fn_t write_archive;
22+
parse_extra_args_fn_t parse_extra;
23+
} archivers[] = {
24+
{ "tar", write_tar_archive, NULL },
25+
{ "zip", write_zip_archive, parse_extra_zip_args },
2826
};
2927

3028
static int run_remote_archiver(const char *remote, int argc,
@@ -88,7 +86,10 @@ static int init_archiver(const char *name, struct archiver *ar)
8886

8987
for (i = 0; i < ARRAY_SIZE(archivers); i++) {
9088
if (!strcmp(name, archivers[i].name)) {
91-
memcpy(ar, &archivers[i], sizeof(struct archiver));
89+
memset(ar, 0, sizeof(*ar));
90+
ar->name = archivers[i].name;
91+
ar->write_archive = archivers[i].write_archive;
92+
ar->parse_extra = archivers[i].parse_extra;
9293
rv = 0;
9394
break;
9495
}

0 commit comments

Comments
 (0)