From 9ac6418218448836bc7fe17d16be175d6da218fb Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sat, 18 Apr 2009 17:05:52 +0000 Subject: [PATCH] Add long long support for printf-style functions. --- CHANGES | 3 ++- config.h.in | 9 +++++++- configure | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 16 ++++++++++++- mxml-string.c | 7 +++++- vcnet/config.h | 11 +++++++-- 6 files changed, 101 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 11b69a0..263b88c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,10 @@ -CHANGES - 2009-03-20 +CHANGES - 2009-04-18 -------------------- CHANGES IN Mini-XML 2.6 - Documentation fixes (STR #91, STR #92) + - Added support for "long long" printf formats. - The XML parser now rejects UTF-8 XML files that start with a BOM (STR #89) - The mxmldoc program now supports generating Xcode documentation diff --git a/config.h.in b/config.h.in index 8d4d3b7..7f43c27 100644 --- a/config.h.in +++ b/config.h.in @@ -3,7 +3,7 @@ * * Configuration file for Mini-XML, a small XML-like file parsing library. * - * Copyright 2003-2007 by Michael Sweet. + * Copyright 2003-2009 by Michael Sweet. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -41,6 +41,13 @@ #define inline +/* + * Long long support... + */ + +#undef HAVE_LONG_LONG + + /* * Do we have the snprintf() and vsnprintf() functions? */ diff --git a/configure b/configure index abd17c0..a10a168 100755 --- a/configure +++ b/configure @@ -3756,6 +3756,67 @@ done fi +{ echo "$as_me:$LINENO: checking for long long int" >&5 +echo $ECHO_N "checking for long long int... $ECHO_C" >&6; } +if test "${ac_cv_c_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$GCC" = yes; then + ac_cv_c_long_long=yes + else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +long long int i; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_long_long=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_long_long" >&5 +echo "${ECHO_T}$ac_cv_c_long_long" >&6; } + +if test $ac_cv_c_long_long = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_LONG_LONG 1 +_ACEOF + +fi + # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then enableval=$enable_threads; diff --git a/configure.in b/configure.in index f72136a..497f9dd 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,7 @@ dnl "$Id$" dnl dnl Configuration script for Mini-XML, a small XML-like file parsing library. dnl -dnl Copyright 2003-2008 by Michael Sweet. +dnl Copyright 2003-2009 by Michael Sweet. dnl dnl This program is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Library General Public @@ -106,6 +106,20 @@ if test "x$use_vsnprintf" != xyes; then AC_CHECK_FUNCS(snprintf vsnprintf) fi +dnl Check for "long long" support... +AC_CACHE_CHECK(for long long int, ac_cv_c_long_long, + [if test "$GCC" = yes; then + ac_cv_c_long_long=yes + else + AC_TRY_COMPILE(,[long long int i;], + ac_cv_c_long_long=yes, + ac_cv_c_long_long=no) + fi]) + +if test $ac_cv_c_long_long = yes; then + AC_DEFINE(HAVE_LONG_LONG) +fi + dnl Threading support AC_ARG_ENABLE(threads, [ --enable-threads enable multi-threading support]) diff --git a/mxml-string.c b/mxml-string.c index bf21aec..91d9161 100644 --- a/mxml-string.c +++ b/mxml-string.c @@ -3,7 +3,7 @@ * * String functions for Mini-XML, a small XML-like file parsing library. * - * Copyright 2003-2007 by Michael Sweet. + * Copyright 2003-2009 by Michael Sweet. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -287,6 +287,11 @@ _mxml_vsnprintf(char *buffer, /* O - Output buffer */ if ((width + 2) > sizeof(temp)) break; +#ifdef HAVE_LONG_LONG + if (size == 'L') + sprintf(temp, tformat, va_arg(ap, long long)); + else +#endif /* HAVE_LONG_LONG */ sprintf(temp, tformat, va_arg(ap, int)); bytes += strlen(temp); diff --git a/vcnet/config.h b/vcnet/config.h index 9097836..103d79a 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -3,7 +3,7 @@ * * Configuration file for Mini-XML, a small XML-like file parsing library. * - * Copyright 2003-2008 by Michael Sweet. + * Copyright 2003-2009 by Michael Sweet. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -66,7 +66,7 @@ * Version number... */ -#define MXML_VERSION "Mini-XML v2.4.1" +#define MXML_VERSION "Mini-XML v2.6" /* @@ -76,6 +76,13 @@ #define inline _inline +/* + * Long long support... + */ + +#define HAVE_LONG_LONG 1 + + /* * Do we have the snprintf() and vsnprintf() functions? */