mirror of https://github.com/qpdf/qpdf.git
Fix printf formatting for newer msvc
Use autoconf rather than ifdefs to determine what format string to use for long long.
This commit is contained in:
parent
be21ede7ba
commit
ff65e272a8
|
@ -1,6 +1,6 @@
|
|||
be950d7be6b0aa2c9c926ac43ca9478ef864b1cb2c8184fd393c9ce4c0972bcc configure.ac
|
||||
055e54a34d94a0c2ed9451042a1c747e47b29259a9035af9e7327401a5c3fbd1 configure.ac
|
||||
d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4
|
||||
b0ce6d1dba8effa47d25154b2bb56eddafc997254a0f3f903cf9b6abffc03616 libqpdf/qpdf/qpdf-config.h.in
|
||||
cf2c764639c4c94abc183a0976eca6ae500b80790ea25e3d0af97b23587363b7 libqpdf/qpdf/qpdf-config.h.in
|
||||
5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4
|
||||
35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4
|
||||
6a1e4f8aa2902d7993300660c43e6ee479b4b6781ed7d5ef9c9f9f1cc46623b7 m4/libtool.m4
|
||||
|
|
|
@ -17694,6 +17694,63 @@ $as_echo "no" >&6; }
|
|||
fi
|
||||
fi
|
||||
|
||||
LL_FMT=""
|
||||
oCFLAGS=$CFLAGS
|
||||
CFLAGS="$WFLAGS $CFLAGS"
|
||||
for fmt in "%lld" "%I64d" "%I64lld"; do
|
||||
if test "$LL_FMT" = ""; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking printf format for long long: $fmt" >&5
|
||||
$as_echo_n "checking printf format for long long: $fmt... " >&6; }
|
||||
if test "$cross_compiling" = yes; then :
|
||||
LL_FMT="%lld"
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
long long int a = 123456789012345ll;
|
||||
char s[30];
|
||||
sprintf(s, "$fmt", a);
|
||||
return (strcmp(s, "123456789012345") == 0) ? 0 : 1
|
||||
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
LL_FMT=$fmt
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
if test "$LL_FMT" != ""; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
fi
|
||||
done
|
||||
CFLAGS=$oCFLAGS
|
||||
if test "LL_FMT" = ""; then
|
||||
LL_FMT="%lld%"
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define LL_FMT "$LL_FMT"
|
||||
_ACEOF
|
||||
|
||||
|
||||
|
||||
|
||||
if test "$BUILDRULES" = "msvc"; then
|
||||
|
|
33
configure.ac
33
configure.ac
|
@ -505,6 +505,39 @@ if test "$BUILDRULES" != "msvc"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
LL_FMT=""
|
||||
oCFLAGS=$CFLAGS
|
||||
CFLAGS="$WFLAGS $CFLAGS"
|
||||
for fmt in "%lld" "%I64d" "%I64lld"; do
|
||||
if test "$LL_FMT" = ""; then
|
||||
AC_MSG_CHECKING(printf format for long long: $fmt)
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||
[[
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
]],
|
||||
[[
|
||||
long long int a = 123456789012345ll;
|
||||
char s[30];
|
||||
sprintf(s, "]$fmt[", a);
|
||||
return (strcmp(s, "123456789012345") == 0) ? 0 : 1
|
||||
]]
|
||||
)],
|
||||
[LL_FMT=$fmt],[],[LL_FMT="%lld"])
|
||||
if test "$LL_FMT" != ""; then
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
CFLAGS=$oCFLAGS
|
||||
if test "LL_FMT" = ""; then
|
||||
LL_FMT="%lld%"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([LL_FMT], ["$LL_FMT"], [printf format for long long])
|
||||
|
||||
AC_SUBST(WINDOWS_WMAIN_XLINK_FLAGS)
|
||||
AC_SUBST(WINDOWS_MAIN_XLINK_FLAGS)
|
||||
if test "$BUILDRULES" = "msvc"; then
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* printf format for long long */
|
||||
#undef LL_FMT
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ define compile
|
|||
-c $(1) -o $(call src_to_obj,$(1))
|
||||
endef
|
||||
|
||||
# 1 2
|
||||
# Usage: $(call c_compile,src,includes)
|
||||
# 1 2 3
|
||||
# Usage: $(call c_compile,src,includes,xflags)
|
||||
define c_compile
|
||||
$(CC) $(CFLAGS) \
|
||||
$(CC) $(CFLAGS) $(3) \
|
||||
$(call depflags,$(basename $(call c_src_to_obj,$(1)))) \
|
||||
$(foreach I,$(2),-I$(I)) \
|
||||
$(CPPFLAGS) \
|
||||
|
|
|
@ -24,10 +24,10 @@ define compile
|
|||
-c $(1) -o $(call src_to_obj,$(1))
|
||||
endef
|
||||
|
||||
# 1 2
|
||||
# Usage: $(call c_compile,src,includes)
|
||||
# 1 2 3
|
||||
# Usage: $(call c_compile,src,includes,xflags)
|
||||
define c_compile
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) \
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(3) \
|
||||
$(call depflags,$(basename $(call src_to_obj,$(1)))) \
|
||||
$(foreach I,$(2),-I$(I)) \
|
||||
-c $(1) -o $(call c_src_to_obj,$(1))
|
||||
|
|
|
@ -32,10 +32,10 @@ define compile
|
|||
-c $(1) -Fo$(call src_to_obj,$(1))
|
||||
endef
|
||||
|
||||
# 1 2
|
||||
# Usage: $(call c_compile,src,includes)
|
||||
# 1 2 3
|
||||
# Usage: $(call c_compile,src,includes,xflags)
|
||||
define c_compile
|
||||
cl -nologo -O2 -Zi -Gy -EHsc -MD $(CPPFLAGS) $(CFLAGS) \
|
||||
cl -nologo -O2 -Zi -Gy -EHsc -MD $(CPPFLAGS) $(CFLAGS) $(3) \
|
||||
$(foreach I,$(2),-I$(I)) \
|
||||
-c $(1) -Fo$(call c_src_to_obj,$(1))
|
||||
endef
|
||||
|
|
|
@ -48,7 +48,7 @@ $(foreach B,$(BINS_qpdf),$(eval \
|
|||
|
||||
$(foreach B,$(CBINS_qpdf),$(eval \
|
||||
$(OBJS_$(B)): qpdf/$(OUTPUT_DIR)/%.$(OBJ): qpdf/$(B).c ; \
|
||||
$(call c_compile,qpdf/$(B).c,$(INCLUDES_qpdf))))
|
||||
$(call c_compile,qpdf/$(B).c,$(INCLUDES_qpdf),$(XCFLAGS_qpdf_$(B)))))
|
||||
|
||||
$(foreach B,$(BINS_qpdf) $(CBINS_qpdf),$(eval \
|
||||
qpdf/$(OUTPUT_DIR)/$(call binname,$(B)): $(OBJS_$(B)) ; \
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "../libqpdf/qpdf/qpdf-config.h" // for LL_FMT
|
||||
|
||||
static char* whoami = 0;
|
||||
static qpdf_data qpdf = 0;
|
||||
|
@ -36,13 +37,7 @@ static FILE* safe_fopen(char const* filename, char const* mode)
|
|||
|
||||
static void report_errors()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
# define POS_FMT " pos : %I64d\n"
|
||||
#else
|
||||
/* If your compiler doesn't support lld, change to ld and lose
|
||||
precision on offsets in error messages. */
|
||||
# define POS_FMT " pos : %lld\n"
|
||||
#endif
|
||||
#define POS_FMT " pos : " LL_FMT "\n"
|
||||
qpdf_error e = 0;
|
||||
while (qpdf_more_warnings(qpdf))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue