git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Check for PRIuMAX rather than NO_C99_FORMAT in fast-import.c.
@ 2007-02-21  1:34 Jason Riedy
  2011-03-16  5:12 ` [PATCH 0/2] fix NO_C99_FORMAT on 64-bit systems Jonathan Nieder
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Riedy @ 2007-02-21  1:34 UTC (permalink / raw)
  To: git

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>
---
 fast-import.c |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 8720090..1ae125a 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -133,13 +133,8 @@ Format of STDIN stream:
 #define PACK_ID_BITS 16
 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
 
-#if !defined(NO_C99_FORMAT)
-#define UM_FMT "%ju"
-#define UM10_FMT "%10ju"
-#else
-/* Assumes unsigned long long exists. */
-#define UM_FMT "%llu"
-#define UM10_FMT "%10llu"
+#ifndef PRIuMAX
+#define PRIuMAX "llu"
 #endif
 
 struct object_entry
@@ -484,7 +479,7 @@ static struct object_entry *find_mark(uintmax_t idnum)
 			oe = s->data.marked[idnum];
 	}
 	if (!oe)
-		die("mark :" UM_FMT " not declared", orig_idnum);
+		die("mark :%" PRIuMAX " not declared", orig_idnum);
 	return oe;
 }
 
@@ -1370,7 +1365,7 @@ static void dump_marks_helper(FILE *f,
 	} else {
 		for (k = 0; k < 1024; k++) {
 			if (m->data.marked[k])
-				fprintf(f, ":" UM_FMT " %s\n", base + k,
+				fprintf(f, ":%" PRIuMAX " %s\n", base + k,
 					sha1_to_hex(m->data.marked[k]->sha1));
 		}
 	}
@@ -1696,7 +1691,7 @@ static void cmd_from(struct branch *b)
 		unsigned long size;
 		char *buf;
 		if (oe->type != OBJ_COMMIT)
-			die("Mark :" UM_FMT " not a commit", idnum);
+			die("Mark :%" PRIuMAX " not a commit", idnum);
 		hashcpy(b->sha1, oe->sha1);
 		buf = gfi_unpack_entry(oe, &size);
 		if (!buf || size < 46)
@@ -1749,7 +1744,7 @@ static struct hash_list *cmd_merge(unsigned int *count)
 			uintmax_t idnum = strtoumax(from + 1, NULL, 10);
 			struct object_entry *oe = find_mark(idnum);
 			if (oe->type != OBJ_COMMIT)
-				die("Mark :" UM_FMT " not a commit", idnum);
+				die("Mark :%" PRIuMAX " not a commit", idnum);
 			hashcpy(n->sha1, oe->sha1);
 		} else if (get_sha1(from, n->sha1))
 			die("Invalid ref name or SHA1 expression: %s", from);
@@ -1893,7 +1888,7 @@ static void cmd_new_tag(void)
 		from_mark = strtoumax(from + 1, NULL, 10);
 		oe = find_mark(from_mark);
 		if (oe->type != OBJ_COMMIT)
-			die("Mark :" UM_FMT " not a commit", from_mark);
+			die("Mark :%" PRIuMAX " not a commit", from_mark);
 		hashcpy(sha1, oe->sha1);
 	} else if (!get_sha1(from, sha1)) {
 		unsigned long size;
@@ -2068,18 +2063,18 @@ int main(int argc, const char **argv)
 
 		fprintf(stderr, "%s statistics:\n", argv[0]);
 		fprintf(stderr, "---------------------------------------------------------------------\n");
-		fprintf(stderr, "Alloc'd objects: " UM10_FMT "\n", alloc_count);
-		fprintf(stderr, "Total objects:   " UM10_FMT " (" UM10_FMT " duplicates                  )\n", total_count, duplicate_count);
-		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]);
-		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]);
-		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]);
-		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]);
+		fprintf(stderr, "Alloc'd objects: %10" PRIuMAX "\n", alloc_count);
+		fprintf(stderr, "Total objects:   %10" PRIuMAX " (%10" PRIuMAX " duplicates                  )\n", total_count, duplicate_count);
+		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]);
+		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]);
+		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]);
+		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]);
 		fprintf(stderr, "Total branches:  %10lu (%10lu loads     )\n", branch_count, branch_load_count);
-		fprintf(stderr, "      marks:     " UM10_FMT " (" UM10_FMT " unique    )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
+		fprintf(stderr, "      marks:     %10" PRIuMAX " (%10" PRIuMAX " unique    )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
 		fprintf(stderr, "      atoms:     %10u\n", atom_cnt);
-		fprintf(stderr, "Memory total:    " UM10_FMT " KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
+		fprintf(stderr, "Memory total:    %10" PRIuMAX " KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
 		fprintf(stderr, "       pools:    %10lu KiB\n", (unsigned long)(total_allocd/1024));
-		fprintf(stderr, "     objects:    " UM10_FMT " KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
+		fprintf(stderr, "     objects:    %10" PRIuMAX " KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
 		fprintf(stderr, "---------------------------------------------------------------------\n");
 		pack_report();
 		fprintf(stderr, "---------------------------------------------------------------------\n");
-- 
1.5.0.1.4.gd41a

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 0/2] fix NO_C99_FORMAT on 64-bit systems
  2007-02-21  1:34 [PATCH] Check for PRIuMAX rather than NO_C99_FORMAT in fast-import.c Jason Riedy
@ 2011-03-16  5:12 ` Jonathan Nieder
  2011-03-16  5:14   ` [PATCH 1/2] mktag: avoid %td in format string Jonathan Nieder
  2011-03-16  5:15   ` [PATCH 2/2] unbreak and eliminate NO_C99_FORMAT Jonathan Nieder
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Nieder @ 2011-03-16  5:12 UTC (permalink / raw)
  To: git; +Cc: Jason Riedy, Ramsay Jones, Junio C Hamano

Hi,

Jason Riedy wrote:

> There are no direct
> C99 translations for other uses of NO_C99_FORMAT in git, alas.

So here's an indirect one. :)

The goal of this series is to unbreak "make CC=c89 NO_C99_FORMAT=yeah"
on my amd64 machine.  Side-effects include uglifying mktag a little
and eliminating the NO_C99_FORMAT knob.

Thoughts welcome, as always.

Jonathan Nieder (2):
  mktag: avoid %td in format string
  unbreak and eliminate NO_C99_FORMAT

 Makefile        |   14 --------------
 alloc.c         |   11 ++---------
 builtin/mktag.c |   48 ++++++++++++++++++++++--------------------------
 config.mak.in   |    1 -
 configure.ac    |   24 ------------------------
 sha1_file.c     |    9 ++-------
 6 files changed, 26 insertions(+), 81 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] mktag: avoid %td in format string
  2011-03-16  5:12 ` [PATCH 0/2] fix NO_C99_FORMAT on 64-bit systems Jonathan Nieder
@ 2011-03-16  5:14   ` Jonathan Nieder
  2011-03-20  6:03     ` Junio C Hamano
  2011-03-16  5:15   ` [PATCH 2/2] unbreak and eliminate NO_C99_FORMAT Jonathan Nieder
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Nieder @ 2011-03-16  5:14 UTC (permalink / raw)
  To: git; +Cc: Jason Riedy, Ramsay Jones, Junio C Hamano

Since v1.7.0-rc0~34 (make "mktag" a built-in, 2010-01-22), git mktag
uses the C99-style %td format to print ptrdiff_t values.  It falls
back to %d when NO_C99_FORMAT is set, on the assumption that pre-C99
systems probably are using 32-bit pointers.

But many modern systems are 64-bit and

 * sometimes one wants to test the NO_C99_FORMAT fallbacks using a
   modern development platform;
 * some platforms (I'm looking at you, msvc) have not gotten with the
   program and are still C89-only.

These ptrdiff_t values are offsets from the beginning of a buffer, so
a size_t or uintmax_t would work about as well.  Use the latter so we
can take advantage of the PRIuMAX fallback in git-compat-util.h, even
on C99-challenged systems with 64-bit pointers.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
These two patches apply to maint.

 builtin/mktag.c |   48 ++++++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/builtin/mktag.c b/builtin/mktag.c
index 1cb0f3f..bc05227 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -35,12 +35,6 @@ static int verify_object(const unsigned char *sha1, const char *expected_type)
 	return ret;
 }
 
-#ifdef NO_C99_FORMAT
-#define PD_FMT "%d"
-#else
-#define PD_FMT "%td"
-#endif
-
 static int verify_tag(char *buffer, unsigned long size)
 {
 	int typelen;
@@ -70,15 +64,18 @@ static int verify_tag(char *buffer, unsigned long size)
 	/* Verify tag-line */
 	tag_line = strchr(type_line, '\n');
 	if (!tag_line)
-		return error("char" PD_FMT ": could not find next \"\\n\"", type_line - buffer);
+		return error("char%"PRIuMAX": could not find next \"\\n\"",
+				(uintmax_t) (type_line - buffer));
 	tag_line++;
 	if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
-		return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);
+		return error("char%"PRIuMAX": no \"tag \" found",
+				(uintmax_t) (tag_line - buffer));
 
 	/* Get the actual type */
 	typelen = tag_line - type_line - strlen("type \n");
 	if (typelen >= sizeof(type))
-		return error("char" PD_FMT ": type too long", type_line+5 - buffer);
+		return error("char%"PRIuMAX": type too long",
+				(uintmax_t) (type_line+5 - buffer));
 
 	memcpy(type, type_line+5, typelen);
 	type[typelen] = 0;
@@ -95,15 +92,16 @@ static int verify_tag(char *buffer, unsigned long size)
 			break;
 		if (c > ' ')
 			continue;
-		return error("char" PD_FMT ": could not verify tag name", tag_line - buffer);
+		return error("char%"PRIuMAX": could not verify tag name",
+				(uintmax_t) (tag_line - buffer));
 	}
 
 	/* Verify the tagger line */
 	tagger_line = tag_line;
 
 	if (memcmp(tagger_line, "tagger ", 7))
-		return error("char" PD_FMT ": could not find \"tagger \"",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": could not find \"tagger \"",
+			(uintmax_t) (tagger_line - buffer));
 
 	/*
 	 * Check for correct form for name and email
@@ -115,44 +113,42 @@ static int verify_tag(char *buffer, unsigned long size)
 	if (!(lb = strstr(tagger_line, " <")) || !(rb = strstr(lb+2, "> ")) ||
 		strpbrk(tagger_line, "<>\n") != lb+1 ||
 		strpbrk(lb+2, "><\n ") != rb)
-		return error("char" PD_FMT ": malformed tagger field",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": malformed tagger field",
+			(uintmax_t) (tagger_line - buffer));
 
 	/* Check for author name, at least one character, space is acceptable */
 	if (lb == tagger_line)
-		return error("char" PD_FMT ": missing tagger name",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": missing tagger name",
+			(uintmax_t) (tagger_line - buffer));
 
 	/* timestamp, 1 or more digits followed by space */
 	tagger_line = rb + 2;
 	if (!(len = strspn(tagger_line, "0123456789")))
-		return error("char" PD_FMT ": missing tag timestamp",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": missing tag timestamp",
+			(uintmax_t) (tagger_line - buffer));
 	tagger_line += len;
 	if (*tagger_line != ' ')
-		return error("char" PD_FMT ": malformed tag timestamp",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": malformed tag timestamp",
+			(uintmax_t) (tagger_line - buffer));
 	tagger_line++;
 
 	/* timezone, 5 digits [+-]hhmm, max. 1400 */
 	if (!((tagger_line[0] == '+' || tagger_line[0] == '-') &&
 	      strspn(tagger_line+1, "0123456789") == 4 &&
 	      tagger_line[5] == '\n' && atoi(tagger_line+1) <= 1400))
-		return error("char" PD_FMT ": malformed tag timezone",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": malformed tag timezone",
+			(uintmax_t) (tagger_line - buffer));
 	tagger_line += 6;
 
 	/* Verify the blank line separating the header from the body */
 	if (*tagger_line != '\n')
-		return error("char" PD_FMT ": trailing garbage in tag header",
-			tagger_line - buffer);
+		return error("char%"PRIuMAX": trailing garbage in tag header",
+			(uintmax_t) (tagger_line - buffer));
 
 	/* The actual stuff afterwards we don't care about.. */
 	return 0;
 }
 
-#undef PD_FMT
-
 int cmd_mktag(int argc, const char **argv, const char *prefix)
 {
 	struct strbuf buf = STRBUF_INIT;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] unbreak and eliminate NO_C99_FORMAT
  2011-03-16  5:12 ` [PATCH 0/2] fix NO_C99_FORMAT on 64-bit systems Jonathan Nieder
  2011-03-16  5:14   ` [PATCH 1/2] mktag: avoid %td in format string Jonathan Nieder
@ 2011-03-16  5:15   ` Jonathan Nieder
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Nieder @ 2011-03-16  5:15 UTC (permalink / raw)
  To: git; +Cc: Jason Riedy, Ramsay Jones, Junio C Hamano

In the spirit of v1.5.0.2~21 (Check for PRIuMAX rather than
NO_C99_FORMAT in fast-import.c, 2007-02-20), use PRIuMAX from
git-compat-util.h on all platforms instead of C99-specific formats
like %zu with dangerous fallbacks to %u or %lu.

So now C99-challenged platforms can build git without provoking
warnings or errors from printf, even if pointers do not have the same
size as an int or long.

The need for a fallback PRIuMAX is detected in git-compat-util.h with
"#ifndef PRIuMAX".  So while at it, simplify the Makefile and configure
script by eliminating the NO_C99_FORMAT knob altogether.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Makefile      |   14 --------------
 alloc.c       |   11 ++---------
 config.mak.in |    1 -
 configure.ac  |   24 ------------------------
 sha1_file.c   |    9 ++-------
 5 files changed, 4 insertions(+), 55 deletions(-)

diff --git a/Makefile b/Makefile
index 775ee83..d9243aa 100644
--- a/Makefile
+++ b/Makefile
@@ -45,11 +45,6 @@ all::
 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
 # d_type in struct dirent (Cygwin 1.5, fixed in Cygwin 1.7).
 #
-# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
-# do not support the 'size specifiers' introduced by C99, namely ll, hh,
-# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
-# some C compilers supported these specifiers prior to C99 as an extension.
-#
 # Define NO_STRCASESTR if you don't have strcasestr.
 #
 # Define NO_MEMMEM if you don't have memmem.
@@ -870,7 +865,6 @@ ifeq ($(uname_S),SunOS)
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
 		NO_STRLCPY = YesPlease
-		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 		GIT_TEST_CMP = cmp
 	endif
@@ -881,21 +875,18 @@ ifeq ($(uname_S),SunOS)
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
 		NO_STRLCPY = YesPlease
-		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 		GIT_TEST_CMP = cmp
 	endif
 	ifeq ($(uname_R),5.8)
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
-		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 		GIT_TEST_CMP = cmp
 	endif
 	ifeq ($(uname_R),5.9)
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
-		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 		GIT_TEST_CMP = cmp
 	endif
@@ -1074,7 +1065,6 @@ ifeq ($(uname_S),Windows)
 	NO_MEMMEM = YesPlease
 	# NEEDS_LIBICONV = YesPlease
 	NO_ICONV = YesPlease
-	NO_C99_FORMAT = YesPlease
 	NO_STRTOUMAX = YesPlease
 	NO_STRTOULL = YesPlease
 	NO_MKDTEMP = YesPlease
@@ -1151,7 +1141,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_MEMMEM = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	OLD_ICONV = YesPlease
-	NO_C99_FORMAT = YesPlease
 	NO_STRTOUMAX = YesPlease
 	NO_MKDTEMP = YesPlease
 	NO_MKSTEMPS = YesPlease
@@ -1354,9 +1343,6 @@ endif
 ifdef NO_NSEC
 	BASIC_CFLAGS += -DNO_NSEC
 endif
-ifdef NO_C99_FORMAT
-	BASIC_CFLAGS += -DNO_C99_FORMAT
-endif
 ifdef SNPRINTF_RETURNS_BOGUS
 	COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
 	COMPAT_OBJS += compat/snprintf.o
diff --git a/alloc.c b/alloc.c
index 6ef6753..aeae55c 100644
--- a/alloc.c
+++ b/alloc.c
@@ -51,19 +51,12 @@ DEFINE_ALLOCATOR(commit, struct commit)
 DEFINE_ALLOCATOR(tag, struct tag)
 DEFINE_ALLOCATOR(object, union any_object)
 
-#ifdef NO_C99_FORMAT
-#define SZ_FMT "%u"
-#else
-#define SZ_FMT "%zu"
-#endif
-
 static void report(const char *name, unsigned int count, size_t size)
 {
-    fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size);
+	fprintf(stderr, "%10s: %8u (%"PRIuMAX" kB)\n",
+			name, count, (uintmax_t) size);
 }
 
-#undef SZ_FMT
-
 #define REPORT(name)	\
     report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)
 
diff --git a/config.mak.in b/config.mak.in
index 9614973..e378534 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -43,7 +43,6 @@ NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@
 NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@
 NO_SOCKADDR_STORAGE=@NO_SOCKADDR_STORAGE@
 NO_IPV6=@NO_IPV6@
-NO_C99_FORMAT=@NO_C99_FORMAT@
 NO_HSTRERROR=@NO_HSTRERROR@
 NO_STRCASESTR=@NO_STRCASESTR@
 NO_STRTOK_R=@NO_STRTOK_R@
diff --git a/configure.ac b/configure.ac
index 20039c5..dd07907 100644
--- a/configure.ac
+++ b/configure.ac
@@ -686,30 +686,6 @@ AC_CHECK_TYPE([struct addrinfo],[
 ])
 AC_SUBST(NO_IPV6)
 #
-# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
-# do not support the 'size specifiers' introduced by C99, namely ll, hh,
-# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
-# some C compilers supported these specifiers prior to C99 as an extension.
-AC_CACHE_CHECK([whether formatted IO functions support C99 size specifiers],
- [ac_cv_c_c99_format],
-[# Actually git uses only %z (%zu) in alloc.c, and %t (%td) in mktag.c
-AC_RUN_IFELSE(
-	[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
-		[[char buf[64];
-		if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
-		  return 1;
-		else if (strcmp(buf, "12345"))
-		  return 2;]])],
-	[ac_cv_c_c99_format=yes],
-	[ac_cv_c_c99_format=no])
-])
-if test $ac_cv_c_c99_format = no; then
-	NO_C99_FORMAT=YesPlease
-else
-	NO_C99_FORMAT=
-fi
-AC_SUBST(NO_C99_FORMAT)
-#
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 AC_CACHE_CHECK([whether the platform regex can handle null bytes],
  [ac_cv_c_excellent_regex], [
diff --git a/sha1_file.c b/sha1_file.c
index 27730c3..ea99f6f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -25,13 +25,8 @@
 #endif
 #endif
 
-#ifdef NO_C99_FORMAT
-#define SZ_FMT "lu"
-static unsigned long sz_fmt(size_t s) { return (unsigned long)s; }
-#else
-#define SZ_FMT "zu"
-static size_t sz_fmt(size_t s) { return s; }
-#endif
+#define SZ_FMT PRIuMAX
+static inline uintmax_t sz_fmt(size_t s) { return s; }
 
 const unsigned char null_sha1[20];
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] mktag: avoid %td in format string
  2011-03-16  5:14   ` [PATCH 1/2] mktag: avoid %td in format string Jonathan Nieder
@ 2011-03-20  6:03     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2011-03-20  6:03 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Jason Riedy, Ramsay Jones, Junio C Hamano

Unfortunate but sensible and correct.  Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-20  6:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-21  1:34 [PATCH] Check for PRIuMAX rather than NO_C99_FORMAT in fast-import.c Jason Riedy
2011-03-16  5:12 ` [PATCH 0/2] fix NO_C99_FORMAT on 64-bit systems Jonathan Nieder
2011-03-16  5:14   ` [PATCH 1/2] mktag: avoid %td in format string Jonathan Nieder
2011-03-20  6:03     ` Junio C Hamano
2011-03-16  5:15   ` [PATCH 2/2] unbreak and eliminate NO_C99_FORMAT Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).