@matheusbsbs / matheus-bagliano / commits / 344c52aee5
Fork 0

Avoid C99 initializers

In a handful places, we use C99 structure and array initializers, which some compilers do not support. This can be handy when you are trying to compile GIT on a Solaris system that has an older C compiler, for example. Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Jul 8, 2006 at 14:34 UTC 344c52aee5f2dfaad2a065f8dcc8566d52d0d6c9
3 files changed +16 -24
builtin-read-tree.c
+8 -10
@@ -43,10 +43,7 @@ struct tree_entry_list {
43 const unsigned char *sha1;
44 };
45
46 -static struct tree_entry_list df_conflict_list = {
47 - .name = NULL,
48 - .next = &df_conflict_list
49 -};
46 +static struct tree_entry_list df_conflict_list;
47
48 typedef int (*merge_fn_t)(struct cache_entry **src);
49
@@ -333,14 +330,9 @@ static void setup_progress_signal(void)
330 setitimer(ITIMER_REAL, &v, NULL);
331 }
332
333 +static struct checkout state;
334 static void check_updates(struct cache_entry **src, int nr)
335 {
338 - static struct checkout state = {
339 - .base_dir = "",
340 - .force = 1,
341 - .quiet = 1,
342 - .refresh_cache = 1,
343 - };
336 unsigned short mask = htons(CE_UPDATE);
337 unsigned last_percent = 200, cnt = 0, total = 0;
338
@@ -884,6 +876,12 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
876 unsigned char sha1[20];
877 merge_fn_t fn = NULL;
878
879 + df_conflict_list.next = &df_conflict_list;
880 + state.base_dir = "";
881 + state.force = 1;
882 + state.quiet = 1;
883 + state.refresh_cache = 1;
884 +
885 setup_git_directory();
886 git_config(git_default_config);
887
checkout-index.c
+2 -8
@@ -49,14 +49,7 @@ static int checkout_stage; /* default to checkout stage0 */
49 static int to_tempfile;
50 static char topath[4][MAXPATHLEN+1];
51
52 -static struct checkout state = {
53 - .base_dir = "",
54 - .base_dir_len = 0,
55 - .force = 0,
56 - .quiet = 0,
57 - .not_new = 0,
58 - .refresh_cache = 0,
59 -};
52 +static struct checkout state;
53
54 static void write_tempfile_record (const char *name)
55 {
@@ -177,6 +170,7 @@ int main(int argc, char **argv)
170 int all = 0;
171 int read_from_stdin = 0;
172
173 + state.base_dir = "";
174 prefix = setup_git_directory();
175 git_config(git_default_config);
176 prefix_length = prefix ? strlen(prefix) : 0;
diff.c
+6 -6
@@ -44,12 +44,12 @@ enum color_diff {
44 #define COLOR_WHITE "\033[37m"
45
46 static const char *diff_colors[] = {
47 - [DIFF_RESET] = COLOR_RESET,
48 - [DIFF_PLAIN] = COLOR_NORMAL,
49 - [DIFF_METAINFO] = COLOR_BOLD,
50 - [DIFF_FRAGINFO] = COLOR_CYAN,
51 - [DIFF_FILE_OLD] = COLOR_RED,
52 - [DIFF_FILE_NEW] = COLOR_GREEN,
47 + COLOR_RESET,
48 + COLOR_NORMAL,
49 + COLOR_BOLD,
50 + COLOR_CYAN,
51 + COLOR_RED,
52 + COLOR_GREEN
53 };
54
55 static int parse_diff_color_slot(const char *var, int ofs)