Commit ff65e272a8f8e647a3db5187e5c4594ff01cbd34
1 parent
be21ede7
Fix printf formatting for newer msvc
Use autoconf rather than ifdefs to determine what format string to use for long long.
Showing
9 changed files
with
107 additions
and
19 deletions
autofiles.sums
| 1 | -be950d7be6b0aa2c9c926ac43ca9478ef864b1cb2c8184fd393c9ce4c0972bcc configure.ac | 1 | +055e54a34d94a0c2ed9451042a1c747e47b29259a9035af9e7327401a5c3fbd1 configure.ac |
| 2 | d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4 | 2 | d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4 |
| 3 | -b0ce6d1dba8effa47d25154b2bb56eddafc997254a0f3f903cf9b6abffc03616 libqpdf/qpdf/qpdf-config.h.in | 3 | +cf2c764639c4c94abc183a0976eca6ae500b80790ea25e3d0af97b23587363b7 libqpdf/qpdf/qpdf-config.h.in |
| 4 | 5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4 | 4 | 5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4 |
| 5 | 35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4 | 5 | 35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4 |
| 6 | 6a1e4f8aa2902d7993300660c43e6ee479b4b6781ed7d5ef9c9f9f1cc46623b7 m4/libtool.m4 | 6 | 6a1e4f8aa2902d7993300660c43e6ee479b4b6781ed7d5ef9c9f9f1cc46623b7 m4/libtool.m4 |
configure
| @@ -17694,6 +17694,63 @@ $as_echo "no" >&6; } | @@ -17694,6 +17694,63 @@ $as_echo "no" >&6; } | ||
| 17694 | fi | 17694 | fi |
| 17695 | fi | 17695 | fi |
| 17696 | 17696 | ||
| 17697 | +LL_FMT="" | ||
| 17698 | +oCFLAGS=$CFLAGS | ||
| 17699 | +CFLAGS="$WFLAGS $CFLAGS" | ||
| 17700 | +for fmt in "%lld" "%I64d" "%I64lld"; do | ||
| 17701 | + if test "$LL_FMT" = ""; then | ||
| 17702 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking printf format for long long: $fmt" >&5 | ||
| 17703 | +$as_echo_n "checking printf format for long long: $fmt... " >&6; } | ||
| 17704 | + if test "$cross_compiling" = yes; then : | ||
| 17705 | + LL_FMT="%lld" | ||
| 17706 | +else | ||
| 17707 | + cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 17708 | +/* end confdefs.h. */ | ||
| 17709 | + | ||
| 17710 | + #define _CRT_SECURE_NO_WARNINGS | ||
| 17711 | + #include <stdio.h> | ||
| 17712 | + #include <string.h> | ||
| 17713 | + | ||
| 17714 | +int | ||
| 17715 | +main () | ||
| 17716 | +{ | ||
| 17717 | + | ||
| 17718 | + long long int a = 123456789012345ll; | ||
| 17719 | + char s[30]; | ||
| 17720 | + sprintf(s, "$fmt", a); | ||
| 17721 | + return (strcmp(s, "123456789012345") == 0) ? 0 : 1 | ||
| 17722 | + | ||
| 17723 | + | ||
| 17724 | + ; | ||
| 17725 | + return 0; | ||
| 17726 | +} | ||
| 17727 | +_ACEOF | ||
| 17728 | +if ac_fn_c_try_run "$LINENO"; then : | ||
| 17729 | + LL_FMT=$fmt | ||
| 17730 | +fi | ||
| 17731 | +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ | ||
| 17732 | + conftest.$ac_objext conftest.beam conftest.$ac_ext | ||
| 17733 | +fi | ||
| 17734 | + | ||
| 17735 | + if test "$LL_FMT" != ""; then | ||
| 17736 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | ||
| 17737 | +$as_echo "yes" >&6; } | ||
| 17738 | + else | ||
| 17739 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | ||
| 17740 | +$as_echo "no" >&6; } | ||
| 17741 | + fi | ||
| 17742 | + fi | ||
| 17743 | +done | ||
| 17744 | +CFLAGS=$oCFLAGS | ||
| 17745 | +if test "LL_FMT" = ""; then | ||
| 17746 | + LL_FMT="%lld%" | ||
| 17747 | +fi | ||
| 17748 | + | ||
| 17749 | +cat >>confdefs.h <<_ACEOF | ||
| 17750 | +#define LL_FMT "$LL_FMT" | ||
| 17751 | +_ACEOF | ||
| 17752 | + | ||
| 17753 | + | ||
| 17697 | 17754 | ||
| 17698 | 17755 | ||
| 17699 | if test "$BUILDRULES" = "msvc"; then | 17756 | if test "$BUILDRULES" = "msvc"; then |
configure.ac
| @@ -505,6 +505,39 @@ if test "$BUILDRULES" != "msvc"; then | @@ -505,6 +505,39 @@ if test "$BUILDRULES" != "msvc"; then | ||
| 505 | fi | 505 | fi |
| 506 | fi | 506 | fi |
| 507 | 507 | ||
| 508 | +LL_FMT="" | ||
| 509 | +oCFLAGS=$CFLAGS | ||
| 510 | +CFLAGS="$WFLAGS $CFLAGS" | ||
| 511 | +for fmt in "%lld" "%I64d" "%I64lld"; do | ||
| 512 | + if test "$LL_FMT" = ""; then | ||
| 513 | + AC_MSG_CHECKING(printf format for long long: $fmt) | ||
| 514 | + AC_RUN_IFELSE([AC_LANG_PROGRAM( | ||
| 515 | + [[ | ||
| 516 | + #define _CRT_SECURE_NO_WARNINGS | ||
| 517 | + #include <stdio.h> | ||
| 518 | + #include <string.h> | ||
| 519 | + ]], | ||
| 520 | + [[ | ||
| 521 | + long long int a = 123456789012345ll; | ||
| 522 | + char s[30]; | ||
| 523 | + sprintf(s, "]$fmt[", a); | ||
| 524 | + return (strcmp(s, "123456789012345") == 0) ? 0 : 1 | ||
| 525 | + ]] | ||
| 526 | + )], | ||
| 527 | + [LL_FMT=$fmt],[],[LL_FMT="%lld"]) | ||
| 528 | + if test "$LL_FMT" != ""; then | ||
| 529 | + AC_MSG_RESULT(yes) | ||
| 530 | + else | ||
| 531 | + AC_MSG_RESULT(no) | ||
| 532 | + fi | ||
| 533 | + fi | ||
| 534 | +done | ||
| 535 | +CFLAGS=$oCFLAGS | ||
| 536 | +if test "LL_FMT" = ""; then | ||
| 537 | + LL_FMT="%lld%" | ||
| 538 | +fi | ||
| 539 | +AC_DEFINE_UNQUOTED([LL_FMT], ["$LL_FMT"], [printf format for long long]) | ||
| 540 | + | ||
| 508 | AC_SUBST(WINDOWS_WMAIN_XLINK_FLAGS) | 541 | AC_SUBST(WINDOWS_WMAIN_XLINK_FLAGS) |
| 509 | AC_SUBST(WINDOWS_MAIN_XLINK_FLAGS) | 542 | AC_SUBST(WINDOWS_MAIN_XLINK_FLAGS) |
| 510 | if test "$BUILDRULES" = "msvc"; then | 543 | if test "$BUILDRULES" = "msvc"; then |
libqpdf/qpdf/qpdf-config.h.in
| @@ -51,6 +51,9 @@ | @@ -51,6 +51,9 @@ | ||
| 51 | /* Define to 1 if you have the <unistd.h> header file. */ | 51 | /* Define to 1 if you have the <unistd.h> header file. */ |
| 52 | #undef HAVE_UNISTD_H | 52 | #undef HAVE_UNISTD_H |
| 53 | 53 | ||
| 54 | +/* printf format for long long */ | ||
| 55 | +#undef LL_FMT | ||
| 56 | + | ||
| 54 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ | 57 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ |
| 55 | #undef LT_OBJDIR | 58 | #undef LT_OBJDIR |
| 56 | 59 |
make/libtool.mk
| @@ -47,10 +47,10 @@ define compile | @@ -47,10 +47,10 @@ define compile | ||
| 47 | -c $(1) -o $(call src_to_obj,$(1)) | 47 | -c $(1) -o $(call src_to_obj,$(1)) |
| 48 | endef | 48 | endef |
| 49 | 49 | ||
| 50 | -# 1 2 | ||
| 51 | -# Usage: $(call c_compile,src,includes) | 50 | +# 1 2 3 |
| 51 | +# Usage: $(call c_compile,src,includes,xflags) | ||
| 52 | define c_compile | 52 | define c_compile |
| 53 | - $(CC) $(CFLAGS) \ | 53 | + $(CC) $(CFLAGS) $(3) \ |
| 54 | $(call depflags,$(basename $(call c_src_to_obj,$(1)))) \ | 54 | $(call depflags,$(basename $(call c_src_to_obj,$(1)))) \ |
| 55 | $(foreach I,$(2),-I$(I)) \ | 55 | $(foreach I,$(2),-I$(I)) \ |
| 56 | $(CPPFLAGS) \ | 56 | $(CPPFLAGS) \ |
make/mingw.mk
| @@ -24,10 +24,10 @@ define compile | @@ -24,10 +24,10 @@ define compile | ||
| 24 | -c $(1) -o $(call src_to_obj,$(1)) | 24 | -c $(1) -o $(call src_to_obj,$(1)) |
| 25 | endef | 25 | endef |
| 26 | 26 | ||
| 27 | -# 1 2 | ||
| 28 | -# Usage: $(call c_compile,src,includes) | 27 | +# 1 2 3 |
| 28 | +# Usage: $(call c_compile,src,includes,xflags) | ||
| 29 | define c_compile | 29 | define c_compile |
| 30 | - $(CC) $(CPPFLAGS) $(CFLAGS) \ | 30 | + $(CC) $(CPPFLAGS) $(CFLAGS) $(3) \ |
| 31 | $(call depflags,$(basename $(call src_to_obj,$(1)))) \ | 31 | $(call depflags,$(basename $(call src_to_obj,$(1)))) \ |
| 32 | $(foreach I,$(2),-I$(I)) \ | 32 | $(foreach I,$(2),-I$(I)) \ |
| 33 | -c $(1) -o $(call c_src_to_obj,$(1)) | 33 | -c $(1) -o $(call c_src_to_obj,$(1)) |
make/msvc.mk
| @@ -32,10 +32,10 @@ define compile | @@ -32,10 +32,10 @@ define compile | ||
| 32 | -c $(1) -Fo$(call src_to_obj,$(1)) | 32 | -c $(1) -Fo$(call src_to_obj,$(1)) |
| 33 | endef | 33 | endef |
| 34 | 34 | ||
| 35 | -# 1 2 | ||
| 36 | -# Usage: $(call c_compile,src,includes) | 35 | +# 1 2 3 |
| 36 | +# Usage: $(call c_compile,src,includes,xflags) | ||
| 37 | define c_compile | 37 | define c_compile |
| 38 | - cl -nologo -O2 -Zi -Gy -EHsc -MD $(CPPFLAGS) $(CFLAGS) \ | 38 | + cl -nologo -O2 -Zi -Gy -EHsc -MD $(CPPFLAGS) $(CFLAGS) $(3) \ |
| 39 | $(foreach I,$(2),-I$(I)) \ | 39 | $(foreach I,$(2),-I$(I)) \ |
| 40 | -c $(1) -Fo$(call c_src_to_obj,$(1)) | 40 | -c $(1) -Fo$(call c_src_to_obj,$(1)) |
| 41 | endef | 41 | endef |
qpdf/build.mk
| @@ -48,7 +48,7 @@ $(foreach B,$(BINS_qpdf),$(eval \ | @@ -48,7 +48,7 @@ $(foreach B,$(BINS_qpdf),$(eval \ | ||
| 48 | 48 | ||
| 49 | $(foreach B,$(CBINS_qpdf),$(eval \ | 49 | $(foreach B,$(CBINS_qpdf),$(eval \ |
| 50 | $(OBJS_$(B)): qpdf/$(OUTPUT_DIR)/%.$(OBJ): qpdf/$(B).c ; \ | 50 | $(OBJS_$(B)): qpdf/$(OUTPUT_DIR)/%.$(OBJ): qpdf/$(B).c ; \ |
| 51 | - $(call c_compile,qpdf/$(B).c,$(INCLUDES_qpdf)))) | 51 | + $(call c_compile,qpdf/$(B).c,$(INCLUDES_qpdf),$(XCFLAGS_qpdf_$(B))))) |
| 52 | 52 | ||
| 53 | $(foreach B,$(BINS_qpdf) $(CBINS_qpdf),$(eval \ | 53 | $(foreach B,$(BINS_qpdf) $(CBINS_qpdf),$(eval \ |
| 54 | qpdf/$(OUTPUT_DIR)/$(call binname,$(B)): $(OBJS_$(B)) ; \ | 54 | qpdf/$(OUTPUT_DIR)/$(call binname,$(B)): $(OBJS_$(B)) ; \ |
qpdf/qpdf-ctest.c
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
| 5 | #include <string.h> | 5 | #include <string.h> |
| 6 | #include <errno.h> | 6 | #include <errno.h> |
| 7 | +#include "../libqpdf/qpdf/qpdf-config.h" // for LL_FMT | ||
| 7 | 8 | ||
| 8 | static char* whoami = 0; | 9 | static char* whoami = 0; |
| 9 | static qpdf_data qpdf = 0; | 10 | static qpdf_data qpdf = 0; |
| @@ -36,13 +37,7 @@ static FILE* safe_fopen(char const* filename, char const* mode) | @@ -36,13 +37,7 @@ static FILE* safe_fopen(char const* filename, char const* mode) | ||
| 36 | 37 | ||
| 37 | static void report_errors() | 38 | static void report_errors() |
| 38 | { | 39 | { |
| 39 | -#ifdef _WIN32 | ||
| 40 | -# define POS_FMT " pos : %I64d\n" | ||
| 41 | -#else | ||
| 42 | -/* If your compiler doesn't support lld, change to ld and lose | ||
| 43 | - precision on offsets in error messages. */ | ||
| 44 | -# define POS_FMT " pos : %lld\n" | ||
| 45 | -#endif | 40 | +#define POS_FMT " pos : " LL_FMT "\n" |
| 46 | qpdf_error e = 0; | 41 | qpdf_error e = 0; |
| 47 | while (qpdf_more_warnings(qpdf)) | 42 | while (qpdf_more_warnings(qpdf)) |
| 48 | { | 43 | { |