Check for PRIuMAX rather than NO_C99_FORMAT in fast-import.c.
Thanks to Simon 'corecode' Schubert <corecode@fs.ei.tum.de> for the clean-up. Defining the C99 standard PRIuMAX when necessary replaces UM_FMT and the awkward UM10_FMT. There are no direct C99 translations for other uses of NO_C99_FORMAT in git, alas. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jason Riedy committed
Feb 20, 2007 at 17:34 UTC
3efb1f343a9d6214a59a814029cab96638e9b915
1 file changed
+16
-21
fast-import.c
+16
-21
@@ -133,13 +133,8 @@ 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"
136
+#ifndef PRIuMAX
137
+#define PRIuMAX "llu"
138
#endif
139
140
struct object_entry
@@ -484,7 +479,7 @@ static struct object_entry *find_mark(uintmax_t idnum)
479
oe = s->data.marked[idnum];
480
}
481
if (!oe)
487
- die("mark :" UM_FMT " not declared", orig_idnum);
482
+ die("mark :%" PRIuMAX " not declared", orig_idnum);
483
return oe;
484
}
485
@@ -1370,7 +1365,7 @@ static void dump_marks_helper(FILE *f,
1365
} else {
1366
for (k = 0; k < 1024; k++) {
1367
if (m->data.marked[k])
1373
- fprintf(f, ":" UM_FMT " %s\n", base + k,
1368
+ fprintf(f, ":%" PRIuMAX " %s\n", base + k,
1369
sha1_to_hex(m->data.marked[k]->sha1));
1370
}
1371
}
@@ -1696,7 +1691,7 @@ static void cmd_from(struct branch *b)
1691
unsigned long size;
1692
char *buf;
1693
if (oe->type != OBJ_COMMIT)
1699
- die("Mark :" UM_FMT " not a commit", idnum);
1694
+ die("Mark :%" PRIuMAX " not a commit", idnum);
1695
hashcpy(b->sha1, oe->sha1);
1696
buf = gfi_unpack_entry(oe, &size);
1697
if (!buf || size < 46)
@@ -1749,7 +1744,7 @@ static struct hash_list *cmd_merge(unsigned int *count)
1744
uintmax_t idnum = strtoumax(from + 1, NULL, 10);
1745
struct object_entry *oe = find_mark(idnum);
1746
if (oe->type != OBJ_COMMIT)
1752
- die("Mark :" UM_FMT " not a commit", idnum);
1747
+ die("Mark :%" PRIuMAX " not a commit", idnum);
1748
hashcpy(n->sha1, oe->sha1);
1749
} else if (get_sha1(from, n->sha1))
1750
die("Invalid ref name or SHA1 expression: %s", from);
@@ -1893,7 +1888,7 @@ static void cmd_new_tag(void)
1888
from_mark = strtoumax(from + 1, NULL, 10);
1889
oe = find_mark(from_mark);
1890
if (oe->type != OBJ_COMMIT)
1896
- die("Mark :" UM_FMT " not a commit", from_mark);
1891
+ die("Mark :%" PRIuMAX " not a commit", from_mark);
1892
hashcpy(sha1, oe->sha1);
1893
} else if (!get_sha1(from, sha1)) {
1894
unsigned long size;
@@ -2068,18 +2063,18 @@ int main(int argc, const char **argv)
2063
2064
fprintf(stderr, "%s statistics:\n", argv[0]);
2065
fprintf(stderr, "---------------------------------------------------------------------\n");
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]);
2066
+ fprintf(stderr, "Alloc'd objects: %10" PRIuMAX "\n", alloc_count);
2067
+ fprintf(stderr, "Total objects: %10" PRIuMAX " (%10" PRIuMAX " duplicates )\n", total_count, duplicate_count);
2068
+ fprintf(stderr, " blobs : %10" PRIuMAX " (%10" PRIuMAX " duplicates %10" PRIuMAX " deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
2069
+ fprintf(stderr, " trees : %10" PRIuMAX " (%10" PRIuMAX " duplicates %10" PRIuMAX " deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
2070
+ fprintf(stderr, " commits: %10" PRIuMAX " (%10" PRIuMAX " duplicates %10" PRIuMAX " deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
2071
+ fprintf(stderr, " tags : %10" PRIuMAX " (%10" PRIuMAX " duplicates %10" PRIuMAX " deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
2072
fprintf(stderr, "Total branches: %10lu (%10lu loads )\n", branch_count, branch_load_count);
2078
- fprintf(stderr, " marks: " UM10_FMT " (" UM10_FMT " unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2073
+ fprintf(stderr, " marks: %10" PRIuMAX " (%10" PRIuMAX " unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2074
fprintf(stderr, " atoms: %10u\n", atom_cnt);
2080
- fprintf(stderr, "Memory total: " UM10_FMT " KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2075
+ fprintf(stderr, "Memory total: %10" PRIuMAX " KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2076
fprintf(stderr, " pools: %10lu KiB\n", (unsigned long)(total_allocd/1024));
2082
- fprintf(stderr, " objects: " UM10_FMT " KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2077
+ fprintf(stderr, " objects: %10" PRIuMAX " KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2078
fprintf(stderr, "---------------------------------------------------------------------\n");
2079
pack_report();
2080
fprintf(stderr, "---------------------------------------------------------------------\n");