@matheusbsbs / matheus-bagliano / commits / e326bce65c
Fork 0

Obey NO_C99_FORMAT in fast-import.c.

Define UM_FMT and UM10_FMT and use in place of %ju and %10ju, respectively. Both format as unsigned long long, so this assumes the compiler supports long long. Signed-off-by: Jason Riedy <jason@acm.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jason Riedy committed Feb 19, 2007 at 16:27 UTC e326bce65c2a8b10f40c1869e13c7450a243b109
1 file changed +23 -14
fast-import.c
+23 -14
@@ -133,6 +133,15 @@ Format of STDIN stream:
133 #define PACK_ID_BITS 16
134 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
135
136 +#if !defined(NO_C99_FORMAT)
137 +#define UM_FMT "%ju"
138 +#define UM10_FMT "%10ju"
139 +#else
140 +/* Assumes unsigned long long exists. */
141 +#define UM_FMT "%llu"
142 +#define UM10_FMT "%10llu"
143 +#endif
144 +
145 struct object_entry
146 {
147 struct object_entry *next;
@@ -475,7 +484,7 @@ static struct object_entry *find_mark(uintmax_t idnum)
484 oe = s->data.marked[idnum];
485 }
486 if (!oe)
478 - die("mark :%ju not declared", orig_idnum);
487 + die("mark :" UM_FMT " not declared", orig_idnum);
488 return oe;
489 }
490
@@ -1361,7 +1370,7 @@ static void dump_marks_helper(FILE *f,
1370 } else {
1371 for (k = 0; k < 1024; k++) {
1372 if (m->data.marked[k])
1364 - fprintf(f, ":%ju %s\n", base + k,
1373 + fprintf(f, ":" UM_FMT " %s\n", base + k,
1374 sha1_to_hex(m->data.marked[k]->sha1));
1375 }
1376 }
@@ -1687,7 +1696,7 @@ static void cmd_from(struct branch *b)
1696 unsigned long size;
1697 char *buf;
1698 if (oe->type != OBJ_COMMIT)
1690 - die("Mark :%ju not a commit", idnum);
1699 + die("Mark :" UM_FMT " not a commit", idnum);
1700 hashcpy(b->sha1, oe->sha1);
1701 buf = gfi_unpack_entry(oe, &size);
1702 if (!buf || size < 46)
@@ -1740,7 +1749,7 @@ static struct hash_list *cmd_merge(unsigned int *count)
1749 uintmax_t idnum = strtoumax(from + 1, NULL, 10);
1750 struct object_entry *oe = find_mark(idnum);
1751 if (oe->type != OBJ_COMMIT)
1743 - die("Mark :%ju not a commit", idnum);
1752 + die("Mark :" UM_FMT " not a commit", idnum);
1753 hashcpy(n->sha1, oe->sha1);
1754 } else if (get_sha1(from, n->sha1))
1755 die("Invalid ref name or SHA1 expression: %s", from);
@@ -1884,7 +1893,7 @@ static void cmd_new_tag(void)
1893 from_mark = strtoumax(from + 1, NULL, 10);
1894 oe = find_mark(from_mark);
1895 if (oe->type != OBJ_COMMIT)
1887 - die("Mark :%ju not a commit", from_mark);
1896 + die("Mark :" UM_FMT " not a commit", from_mark);
1897 hashcpy(sha1, oe->sha1);
1898 } else if (!get_sha1(from, sha1)) {
1899 unsigned long size;
@@ -2059,18 +2068,18 @@ int main(int argc, const char **argv)
2068
2069 fprintf(stderr, "%s statistics:\n", argv[0]);
2070 fprintf(stderr, "---------------------------------------------------------------------\n");
2062 - fprintf(stderr, "Alloc'd objects: %10ju\n", alloc_count);
2063 - fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
2064 - fprintf(stderr, " blobs : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
2065 - fprintf(stderr, " trees : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
2066 - fprintf(stderr, " commits: %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
2067 - fprintf(stderr, " tags : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
2071 + fprintf(stderr, "Alloc'd objects: " UM10_FMT "\n", alloc_count);
2072 + fprintf(stderr, "Total objects: " UM10_FMT " (" UM10_FMT " duplicates )\n", total_count, duplicate_count);
2073 + fprintf(stderr, " blobs : " UM10_FMT " (" UM10_FMT " duplicates " UM10_FMT " deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
2074 + fprintf(stderr, " trees : " UM10_FMT " (" UM10_FMT " duplicates " UM10_FMT " deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
2075 + fprintf(stderr, " commits: " UM10_FMT " (" UM10_FMT " duplicates " UM10_FMT " deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
2076 + fprintf(stderr, " tags : " UM10_FMT " (" UM10_FMT " duplicates " UM10_FMT " deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
2077 fprintf(stderr, "Total branches: %10lu (%10lu loads )\n", branch_count, branch_load_count);
2069 - fprintf(stderr, " marks: %10ju (%10ju unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2078 + fprintf(stderr, " marks: " UM10_FMT " (" UM10_FMT " unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2079 fprintf(stderr, " atoms: %10u\n", atom_cnt);
2071 - fprintf(stderr, "Memory total: %10ju KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2080 + fprintf(stderr, "Memory total: " UM10_FMT " KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2081 fprintf(stderr, " pools: %10lu KiB\n", (unsigned long)(total_allocd/1024));
2073 - fprintf(stderr, " objects: %10ju KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2082 + fprintf(stderr, " objects: " UM10_FMT " KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2083 fprintf(stderr, "---------------------------------------------------------------------\n");
2084 pack_report();
2085 fprintf(stderr, "---------------------------------------------------------------------\n");