You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sc...@apache.org on 2017/08/06 18:09:44 UTC
svn commit: r1804250 - in /xerces/c/trunk: cmake/XercesFunctions.cmake
config.h.cmake.in configure.ac src/xercesc/util/XMLDateTime.cpp
Author: scantor
Date: Sun Aug 6 18:09:44 2017
New Revision: 1804250
URL: http://svn.apache.org/viewvc?rev=1804250&view=rev
Log:
XERCESC-2111 - Accomodate lack of snprintf
Modified:
xerces/c/trunk/cmake/XercesFunctions.cmake
xerces/c/trunk/config.h.cmake.in
xerces/c/trunk/configure.ac
xerces/c/trunk/src/xercesc/util/XMLDateTime.cpp
Modified: xerces/c/trunk/cmake/XercesFunctions.cmake
URL: http://svn.apache.org/viewvc/xerces/c/trunk/cmake/XercesFunctions.cmake?rev=1804250&r1=1804249&r2=1804250&view=diff
==============================================================================
--- xerces/c/trunk/cmake/XercesFunctions.cmake (original)
+++ xerces/c/trunk/cmake/XercesFunctions.cmake Sun Aug 6 18:09:44 2017
@@ -38,6 +38,7 @@ check_function_exists(memset HAVE_MEMSET
check_function_exists(nl_langinfo HAVE_NL_LANGINFO)
check_function_exists(setlocale HAVE_SETLOCALE)
check_function_exists(localeconv HAVE_LOCALECONV)
+check_function_exists(snprintf HAVE_SNPRINTF)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(strncasecmp HAVE_STRNCASECMP)
check_function_exists(stricmp HAVE_STRICMP)
Modified: xerces/c/trunk/config.h.cmake.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/config.h.cmake.in?rev=1804250&r1=1804249&r2=1804250&view=diff
==============================================================================
--- xerces/c/trunk/config.h.cmake.in (original)
+++ xerces/c/trunk/config.h.cmake.in Sun Aug 6 18:09:44 2017
@@ -171,6 +171,9 @@
/* Define to 1 if you have the `setlocale' function. */
#cmakedefine HAVE_SETLOCALE 1
+/* Define to 1 if you have the `snprintf' function. */
+#cmakedefine HAVE_SNPRINTF 1
+
/* Define to 1 if you have the `socket' function. */
#cmakedefine HAVE_SOCKET 1
Modified: xerces/c/trunk/configure.ac
URL: http://svn.apache.org/viewvc/xerces/c/trunk/configure.ac?rev=1804250&r1=1804249&r2=1804250&view=diff
==============================================================================
--- xerces/c/trunk/configure.ac (original)
+++ xerces/c/trunk/configure.ac Sun Aug 6 18:09:44 2017
@@ -137,7 +137,7 @@ AC_CHECK_FUNCS([getcwd pathconf realpath
clock_gettime ftime gettimeofday timegm gmtime_r \
memmove memset nl_langinfo setlocale localeconv \
strcasecmp strncasecmp stricmp strnicmp strchr strdup \
- strrchr strstr strtol strtoul \
+ strrchr strstr strtol strtoul snprintf \
towupper towlower mblen \
wcsupr wcslwr wcsnicmp wcsicmp \
])
Modified: xerces/c/trunk/src/xercesc/util/XMLDateTime.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLDateTime.cpp?rev=1804250&r1=1804249&r2=1804250&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLDateTime.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLDateTime.cpp Sun Aug 6 18:09:44 2017
@@ -23,7 +23,6 @@
// Includes
// ---------------------------------------------------------------------------
#include <stdlib.h>
-#include <stdio.h>
#include <assert.h>
#include <errno.h>
@@ -476,9 +475,15 @@ XMLDateTime::XMLDateTime(time_t epoch, b
epoch %= 60;
unsigned long seconds = epoch;
+ // These should just be replaced with an ostringstream but there's no STL usage anywhere else.
+ // Modern compilers have snprintf. Anything older should accomodate unsigned longs of
+ // 20 characters each, and this accomodates over 50.
char timebuf[256];
+#ifdef HAVE_SNPRINTF
snprintf(timebuf, 256, "%sP%luDT%luH%luM%luS", neg ? "-" : "", days, hours, minutes, seconds);
-
+#else
+ sprintf(timebuf, "%sP%luDT%luH%luM%luS", neg ? "-" : "", days, hours, minutes, seconds);
+#endif
XMLCh* timeptr = XMLString::transcode(timebuf);
setBuffer(timeptr);
XMLString::release(&timeptr);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org