summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinear cannon <dev@linear.network>2021-12-19 00:20:43 -0800
committerlinear cannon <dev@linear.network>2021-12-19 01:07:40 -0800
commit9a6a8e772df0c79ef26ec18af042acd12f1f66cf (patch)
tree9a31c50f820a8355cc02d78985a0ffb327660c99
parentfdb493d9789c3426d603d15d0c438e4b273f4ec8 (diff)
downloadlibarchive-9a6a8e772df0c79ef26ec18af042acd12f1f66cf.tar.gz
define printf format specifiers if not present
-rw-r--r--configure.ac3
-rw-r--r--libarchive/archive_platform.h22
2 files changed, 25 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index cb89c3ee..526f313b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -633,6 +633,9 @@ AC_CHECK_TYPE([wchar_t],
AC_CHECK_SIZEOF([wchar_t])],
[])
+AX_COMPILE_CHECK_SIZEOF(int)
+AX_COMPILE_CHECK_SIZEOF(long)
+
AC_HEADER_TIME
# Checks for library functions.
diff --git a/libarchive/archive_platform.h b/libarchive/archive_platform.h
index 9fef68fa..3426975d 100644
--- a/libarchive/archive_platform.h
+++ b/libarchive/archive_platform.h
@@ -163,6 +163,28 @@
#define INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
#endif
+/* Some platforms lack the standard PRIxN/PRIdN definitions. */
+#if !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+#ifndef PRIx32
+#if SIZEOF_INT == 4
+#define PRIx32 "x"
+#elif SIZEOF_LONG == 4
+#define PRIx32 "lx"
+#else
+#error No suitable 32-bit unsigned integer type found for this platform
+#endif
+#endif // PRIx32
+#ifndef PRId32
+#if SIZEOF_INT == 4
+#define PRId32 "d"
+#elif SIZEOF_LONG == 4
+#define PRId32 "ld"
+#else
+#error No suitable 32-bit signed integer type found for this platform
+#endif
+#endif // PRId32
+#endif // !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+
/*
* If we can't restore metadata using a file descriptor, then
* for compatibility's sake, close files before trying to restore metadata.