From 041505126720c3e477c79745abd3512e8c799bc9 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 6 Sep 2006 11:46:36 +0000 Subject: [PATCH] On Windows/mingw32, scanf only accepts %I64d for long long integers. Reference that gave me this hint: http://acm.pku.edu.cn/JudgeOnline/faq.htm git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14806 57a11ea4-9604-0410-9ed3-97b8803252fd --- configure.in | 5 ++++- lib/libqof/qof/qofutil.h | 6 +++++- macros/legacy_macros.m4 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index c462402cbc..eda026fd58 100644 --- a/configure.in +++ b/configure.in @@ -135,7 +135,10 @@ if test x$am_cv_scanf_lld = "xno"; then SCANF_QD_CHECK if test x$am_cv_scanf_qd = "xno"; then - AC_MSG_ERROR([cannot continue, no long long conversion support in scanf]) + SCANF_I64D_CHECK + if test x$am_cv_scanf_i64d = "xno"; then + AC_MSG_ERROR([Cannot continue, no long long conversion support in scanf.]) + fi fi fi diff --git a/lib/libqof/qof/qofutil.h b/lib/libqof/qof/qofutil.h index 094fa9e725..11423656d4 100644 --- a/lib/libqof/qof/qofutil.h +++ b/lib/libqof/qof/qofutil.h @@ -48,7 +48,11 @@ # if HAVE_SCANF_QD # define QOF_SCANF_LLD "%qd" # else -# error "No scanf format string is known for LLD. Fix your ./configure so that the correct one is detected!" +# if HAVE_SCANF_I64D +# define QOF_SCANF_LLD "%I64d" +# else +# error "No scanf format string is known for LLD. Fix your ./configure so that the correct one is detected!" +# endif # endif #endif diff --git a/macros/legacy_macros.m4 b/macros/legacy_macros.m4 index 6a9b60f5be..1941477eca 100644 --- a/macros/legacy_macros.m4 +++ b/macros/legacy_macros.m4 @@ -153,6 +153,36 @@ int main () fi ]) +AC_DEFUN([SCANF_I64D_CHECK], +[ + AC_CACHE_CHECK([if scanf supports %I64d conversions], + am_cv_scanf_i64d, + AC_TRY_RUN([ +#include +#include + +int main () +{ + long long int d; + long long int e; + + d = 0; + e = 100000; + e *= 100000; + if ((sscanf ("10000000000", "%I64d", &d) != 1) || (d != e)) + exit (1); + + exit (0); +} +], + am_cv_scanf_i64d=yes, + am_cv_scanf_i64d=no)) + if test $am_cv_scanf_i64d = yes; then + AC_DEFINE(HAVE_SCANF_I64D, 1, + [Define if scanf supports %I64d conversions.]) + fi +]) + AC_DEFUN([LANGINFO_D_FMT_CHECK], [ AC_CACHE_CHECK([for nl_langinfo and D_FMT], am_cv_langinfo_dfmt,