Merge branch 'ff/c99'
authorJunio C Hamano <junkio@cox.net>
Thu, 22 Jun 2006 09:18:51 +0000 (02:18 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 22 Jun 2006 09:18:51 +0000 (02:18 -0700)
* ff/c99:
Remove all void-pointer arithmetic.
Change types used in bitfields to be `int's.
Don't use empty structure initializers.
Cast pointers to `void *' when used in a format.
Don't instantiate structures with FAMs.
Initialize FAMs using `FLEX_ARRAY'.
Remove ranges from switch statements.

1  2 
diff-lib.c
http-push.c
tag.c
diff --combined diff-lib.c
index d93cd55510d702ae6c5104ae9f896264ddc98f80,fdc11732dfbe201119182ff701f7fd40d74d1017..116b5a9d6834c9517ccc2202510b37a1e1d863a5
@@@ -34,21 -34,23 +34,23 @@@ int run_diff_files(struct rev_info *rev
                        continue;
  
                if (ce_stage(ce)) {
-                       struct {
-                               struct combine_diff_path p;
-                               struct combine_diff_parent filler[5];
-                       } combine;
+                       struct combine_diff_path *dpath;
                        int num_compare_stages = 0;
+                       size_t path_len;
  
-                       combine.p.next = NULL;
-                       combine.p.len = ce_namelen(ce);
-                       combine.p.path = xmalloc(combine.p.len + 1);
-                       memcpy(combine.p.path, ce->name, combine.p.len);
-                       combine.p.path[combine.p.len] = 0;
-                       combine.p.mode = 0;
-                       memset(combine.p.sha1, 0, 20);
-                       memset(&combine.p.parent[0], 0,
-                              sizeof(combine.filler));
+                       path_len = ce_namelen(ce);
+                       dpath = xmalloc (combine_diff_path_size (5, path_len));
+                       dpath->path = (char *) &(dpath->parent[5]);
+                       dpath->next = NULL;
+                       dpath->len = path_len;
+                       memcpy(dpath->path, ce->name, path_len);
+                       dpath->path[path_len] = '\0';
+                       dpath->mode = 0;
+                       memset(dpath->sha1, 0, 20);
+                       memset(&(dpath->parent[0]), 0,
+                                       sizeof(struct combine_diff_parent)*5);
  
                        while (i < entries) {
                                struct cache_entry *nce = active_cache[i];
                                if (2 <= stage) {
                                        int mode = ntohl(nce->ce_mode);
                                        num_compare_stages++;
-                                       memcpy(combine.p.parent[stage-2].sha1,
+                                       memcpy(dpath->parent[stage-2].sha1,
                                               nce->sha1, 20);
-                                       combine.p.parent[stage-2].mode =
+                                       dpath->parent[stage-2].mode =
                                                canon_mode(mode);
-                                       combine.p.parent[stage-2].status =
+                                       dpath->parent[stage-2].status =
                                                DIFF_STATUS_MODIFIED;
                                }
  
                        i--;
  
                        if (revs->combine_merges && num_compare_stages == 2) {
-                               show_combined_diff(&combine.p, 2,
+                               show_combined_diff(dpath, 2,
                                                   revs->dense_combined_merges,
                                                   revs);
-                               free(combine.p.path);
+                               free(dpath);
                                continue;
                        }
-                       free(combine.p.path);
+                       free(dpath);
+                       dpath = NULL;
  
                        /*
                         * Show the diff for the 'ce' if we found the one
@@@ -329,8 -332,8 +332,8 @@@ int run_diff_index(struct rev_info *rev
        }
        mark_merge_entries();
  
 -      ent = revs->pending_objects->item;
 -      tree_name = revs->pending_objects->name;
 +      ent = revs->pending.objects[0].item;
 +      tree_name = revs->pending.objects[0].name;
        tree = parse_tree_indirect(ent->sha1);
        if (!tree)
                return error("bad tree object %s", tree_name);
diff --combined http-push.c
index 0f02a55ddf15ad86f9e3e9e2629fe2d9ca1ff78c,9853619687a25501d1dee052f39ebeedcbd8dc69..8d472f0202827db726ede451be3fd63940c38c96
@@@ -196,7 -196,7 +196,7 @@@ static size_t fwrite_sha1_file(void *pt
        struct transfer_request *request = (struct transfer_request *)data;
        do {
                ssize_t retval = write(request->local_fileno,
-                                      ptr + posn, size - posn);
+                                      (char *) ptr + posn, size - posn);
                if (retval < 0)
                        return posn;
                posn += retval;
@@@ -1077,13 -1077,14 +1077,14 @@@ static int fetch_indices(void
  
  static inline int needs_quote(int ch)
  {
-       switch (ch) {
-       case '/': case '-': case '.':
-       case 'A'...'Z': case 'a'...'z': case '0'...'9':
+       if (((ch >= 'A') && (ch <= 'Z'))
+                       || ((ch >= 'a') && (ch <= 'z'))
+                       || ((ch >= '0') && (ch <= '9'))
+                       || (ch == '/')
+                       || (ch == '-')
+                       || (ch == '.'))
                return 0;
-       default:
-               return 1;
-       }
+       return 1;
  }
  
  static inline int hex(int v)
@@@ -1171,7 -1172,7 +1172,7 @@@ static void one_remote_object(const cha
  
        obj->flags |= REMOTE;
        if (!object_list_contains(objects, obj))
 -              add_object(obj, &objects, NULL, "");
 +              object_list_insert(obj, &objects);
  }
  
  static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
@@@ -1699,15 -1700,6 +1700,15 @@@ static int locking_available(void
        return lock_flags;
  }
  
 +struct object_list **add_one_object(struct object *obj, struct object_list **p)
 +{
 +      struct object_list *entry = xmalloc(sizeof(struct object_list));
 +      entry->item = obj;
 +      entry->next = *p;
 +      *p = entry;
 +      return &entry->next;
 +}
 +
  static struct object_list **process_blob(struct blob *blob,
                                         struct object_list **p,
                                         struct name_path *path,
                return p;
  
        obj->flags |= SEEN;
 -      name = strdup(name);
 -      return add_object(obj, p, path, name);
 +      return add_one_object(obj, p);
  }
  
  static struct object_list **process_tree(struct tree *tree,
  
        obj->flags |= SEEN;
        name = strdup(name);
 -      p = add_object(obj, p, NULL, name);
 +      p = add_one_object(obj, p);
        me.up = path;
        me.elem = name;
        me.elem_len = strlen(name);
  
  static int get_delta(struct rev_info *revs, struct remote_lock *lock)
  {
 +      int i;
        struct commit *commit;
 -      struct object_list **p = &objects, *pending;
 +      struct object_list **p = &objects;
        int count = 0;
  
        while ((commit = get_revision(revs)) != NULL) {
                        count += add_send_request(&commit->object, lock);
        }
  
 -      for (pending = revs->pending_objects; pending; pending = pending->next) {
 -              struct object *obj = pending->item;
 -              const char *name = pending->name;
 +      for (i = 0; i < revs->pending.nr; i++) {
 +              struct object_array_entry *entry = revs->pending.objects + i;
 +              struct object *obj = entry->item;
 +              const char *name = entry->name;
  
                if (obj->flags & (UNINTERESTING | SEEN))
                        continue;
                if (obj->type == TYPE_TAG) {
                        obj->flags |= SEEN;
 -                      p = add_object(obj, p, NULL, name);
 +                      p = add_one_object(obj, p);
                        continue;
                }
                if (obj->type == TYPE_TREE) {
diff --combined tag.c
index 5f70a5b8104078b139d2ec87b7aebc6791b4d253,bee8a09cbf5fec119e9b2555beb4cb8b38d8057e..74d0dabe5d8c1f06a3f67475368c34e3b4046456
--- 1/tag.c
--- 2/tag.c
+++ b/tag.c
@@@ -19,7 -19,7 +19,7 @@@ struct tag *lookup_tag(const unsigned c
  {
          struct object *obj = lookup_object(sha1);
          if (!obj) {
 -                struct tag *ret = xcalloc(1, sizeof(struct tag));
 +                struct tag *ret = alloc_tag_node();
                  created_object(sha1, &ret->object);
                  ret->object.type = TYPE_TAG;
                  return ret;
@@@ -47,10 -47,10 +47,10 @@@ int parse_tag_buffer(struct tag *item, 
  
        if (size < 64)
                return -1;
-       if (memcmp("object ", data, 7) || get_sha1_hex(data + 7, object))
+       if (memcmp("object ", data, 7) || get_sha1_hex((char *) data + 7, object))
                return -1;
  
-       type_line = data + 48;
+       type_line = (char *) data + 48;
        if (memcmp("\ntype ", type_line-1, 6))
                return -1;