Rewrite dynamic structure initializations to runtime assignment

Unfortunately, there are still plenty of production systems with
vendor compilers that choke unless all compound declarations can be
determined statically at compile time, for example hpux10.20 (I can
provide a comprehensive list of our supported platforms that exhibit
this problem if necessary).

This patch simply breaks apart any compound declarations with dynamic
initialisation expressions, and moves the initialisation until after
the last declaration in the same block, in all the places necessary to
have the offending compilers accept the code.

Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Gary V. Vaughan
2010-05-14 09:31:33 +00:00
committed by Junio C Hamano
parent ebef827765
commit 66dbfd55e3
14 changed files with 67 additions and 45 deletions

View File

@ -261,12 +261,14 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
{
char *file = xstrdup(git_path("ADD_EDIT.patch"));
const char *apply_argv[] = { "apply", "--recount", "--cached",
file, NULL };
NULL, NULL };
struct child_process child;
struct rev_info rev;
int out;
struct stat st;
apply_argv[3] = file;
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
if (read_cache() < 0)

View File

@ -733,10 +733,11 @@ static int pass_blame_to_parent(struct scoreboard *sb,
{
int last_in_target;
mmfile_t file_p, file_o;
struct blame_chunk_cb_data d = { sb, target, parent, 0, 0 };
struct blame_chunk_cb_data d;
xpparam_t xpp;
xdemitconf_t xecfg;
memset(&d, 0, sizeof(d));
d.sb = sb; d.target = target; d.parent = parent;
last_in_target = find_last_in_target(sb, target);
if (last_in_target < 0)
return 1; /* nothing remains for this target */
@ -875,10 +876,11 @@ static void find_copy_in_blob(struct scoreboard *sb,
const char *cp;
int cnt;
mmfile_t file_o;
struct handle_split_cb_data d = { sb, ent, parent, split, 0, 0 };
struct handle_split_cb_data d;
xpparam_t xpp;
xdemitconf_t xecfg;
memset(&d, 0, sizeof(d));
d.sb = sb; d.ent = ent; d.parent = parent; d.split = split;
/*
* Prepare mmfile that contains only the lines in ent.
*/

View File

@ -118,7 +118,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
/* custom pretty-print here */
if (type == OBJ_TREE) {
const char *ls_args[3] = {"ls-tree", obj_name, NULL};
const char *ls_args[3] = { NULL };
ls_args[0] = "ls-tree";
ls_args[1] = obj_name;
return cmd_ls_tree(2, ls_args, NULL);
}

View File

@ -609,7 +609,8 @@ static int check_tracking_name(const char *refname, const unsigned char *sha1,
static const char *unique_tracking_name(const char *name)
{
struct tracking_name_data cb_data = { name, NULL, 1 };
struct tracking_name_data cb_data = { NULL, NULL, 1 };
cb_data.name = name;
for_each_ref(check_tracking_name, &cb_data);
if (cb_data.unique)
return cb_data.remote;

View File

@ -717,7 +717,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (use_editor) {
char index[PATH_MAX];
const char *env[2] = { index, NULL };
const char *env[2] = { NULL };
env[0] = index;
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
if (launch_editor(git_path(commit_editmsg), NULL, env)) {
fprintf(stderr,

View File

@ -574,9 +574,10 @@ static void find_non_local_tags(struct transport *transport,
{
struct string_list existing_refs = { NULL, 0, 0, 0 };
struct string_list remote_refs = { NULL, 0, 0, 0 };
struct tag_data data = {head, tail};
struct tag_data data;
const struct ref *ref;
struct string_list_item *item = NULL;
data.head = head; data.tail = tail;
for_each_ref(add_existing, &existing_refs);
for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
@ -778,7 +779,8 @@ static int get_remote_group(const char *key, const char *value, void *priv)
static int add_remote_or_group(const char *name, struct string_list *list)
{
int prev_nr = list->nr;
struct remote_group_data g = { name, list };
struct remote_group_data g;
g.name = name; g.list = list;
git_config(get_remote_group, &g);
if (list->nr == prev_nr) {

View File

@ -705,11 +705,14 @@ static int rm(int argc, const char **argv)
struct known_remotes known_remotes = { NULL, NULL };
struct string_list branches = { NULL, 0, 0, 1 };
struct string_list skipped = { NULL, 0, 0, 1 };
struct branches_for_remote cb_data = {
NULL, &branches, &skipped, &known_remotes
};
struct branches_for_remote cb_data;
int i, result;
memset(&cb_data, 0, sizeof(cb_data));
cb_data.branches = &branches;
cb_data.skipped = &skipped;
cb_data.keep = &known_remotes;
if (argc != 2)
usage_with_options(builtin_remote_rm_usage, options);