Added SDL_vsscanf().
authorRyan C. Gordon <icculus@icculus.org>
Sun, 24 Nov 2013 23:35:38 -0500
changeset 8089 de8b6fdf6544
parent 8088 e5d77d5e0fe2
child 8090 0098d4459b7a
Added SDL_vsscanf().
CMakeLists.txt
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_config_android.h
include/SDL_config_iphoneos.h
include/SDL_config_macosx.h
include/SDL_config_pandora.h
include/SDL_config_psp.h
include/SDL_config_windows.h
include/SDL_config_wiz.h
include/SDL_stdinc.h
premake/Linux/SDL_config_premake.h
premake/MinGW/SDL_config_premake.h
premake/VisualC/VS2008/SDL_config_premake.h
premake/VisualC/VS2010/SDL_config_premake.h
premake/VisualC/VS2012/SDL_config_premake.h
premake/Xcode-iOS/SDL_config_premake.h
premake/Xcode/Xcode3/SDL_config_premake.h
premake/Xcode/Xcode4/SDL_config_premake.h
premake/config/SDL_config_cygwin.template.h
premake/config/SDL_config_iphoneos.template.h
premake/config/SDL_config_linux.template.h
premake/config/SDL_config_macosx.template.h
premake/config/SDL_config_windows.template.h
src/stdlib/SDL_string.c
--- a/CMakeLists.txt	Sun Nov 24 21:04:51 2013 -0500
+++ b/CMakeLists.txt	Sun Nov 24 23:35:38 2013 -0500
@@ -503,13 +503,14 @@
     check_c_source_compiles("#include <sys/types.h>
                              #include <sys/mman.h>
                              int main() { }" HAVE_MPROTECT)
+    # FIXME: we don't care if you have snprintf, etc, any more. We only care if you have vsnprintf. Clean this up.
     foreach(_FN
             strtod malloc calloc realloc free getenv setenv putenv unsetenv
             qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
             strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
             _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
             atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
-            sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp
+            vsscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp
             nanosleep sysconf sysctlbyname
             )
       string(TOUPPER ${_FN} _UPPER)
--- a/configure	Sun Nov 24 21:04:51 2013 -0500
+++ b/configure	Sun Nov 24 23:35:38 2013 -0500
@@ -16581,7 +16581,7 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
-    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname
+        for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
--- a/configure.in	Sun Nov 24 21:04:51 2013 -0500
+++ b/configure.in	Sun Nov 24 23:35:38 2013 -0500
@@ -268,7 +268,8 @@
         AC_DEFINE(HAVE_MPROTECT, 1, [ ])
         ]),
     )
-    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname)
+    dnl FIXME: we don't care if you have snprintf, etc, any more. We only care if you have vsnprintf. Clean this up.
+    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname)
 
     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
     AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
--- a/include/SDL_config.h.cmake	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config.h.cmake	Sun Nov 24 23:35:38 2013 -0500
@@ -124,7 +124,7 @@
 #cmakedefine HAVE_STRCASECMP 1
 #cmakedefine HAVE__STRNICMP 1
 #cmakedefine HAVE_STRNCASECMP 1
-#cmakedefine HAVE_SSCANF 1
+#cmakedefine HAVE_VSSCANF 1
 #cmakedefine HAVE_SNPRINTF 1
 #cmakedefine HAVE_VSNPRINTF 1
 #cmakedefine HAVE_M_PI 1
--- a/include/SDL_config.h.in	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config.h.in	Sun Nov 24 23:35:38 2013 -0500
@@ -128,6 +128,7 @@
 #undef HAVE__STRNICMP
 #undef HAVE_STRNCASECMP
 #undef HAVE_SSCANF
+#undef HAVE_VSSCANF
 #undef HAVE_SNPRINTF
 #undef HAVE_VSNPRINTF
 #undef HAVE_M_PI
--- a/include/SDL_config_android.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_android.h	Sun Nov 24 23:35:38 2013 -0500
@@ -81,7 +81,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_M_PI   1
--- a/include/SDL_config_iphoneos.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_iphoneos.h	Sun Nov 24 23:35:38 2013 -0500
@@ -79,7 +79,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_M_PI   1
--- a/include/SDL_config_macosx.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_macosx.h	Sun Nov 24 23:35:38 2013 -0500
@@ -82,7 +82,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_CEIL   1
--- a/include/SDL_config_pandora.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_pandora.h	Sun Nov 24 23:35:38 2013 -0500
@@ -81,7 +81,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF 1
 #define HAVE_VSNPRINTF 1
 #define HAVE_M_PI 1
--- a/include/SDL_config_psp.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_psp.h	Sun Nov 24 23:35:38 2013 -0500
@@ -79,7 +79,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_M_PI   1
--- a/include/SDL_config_windows.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_windows.h	Sun Nov 24 23:35:38 2013 -0500
@@ -132,7 +132,7 @@
 #define HAVE_SQRT 1
 #if _MSC_VER >= 1800
 #define HAVE_STRTOLL 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_COPYSIGN 1
 #define HAVE_SCALBN 1
 #endif
--- a/include/SDL_config_wiz.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_config_wiz.h	Sun Nov 24 23:35:38 2013 -0500
@@ -75,7 +75,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF 1
 #define HAVE_VSNPRINTF 1
 #define HAVE_M_PI 1
--- a/include/SDL_stdinc.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/include/SDL_stdinc.h	Sun Nov 24 23:35:38 2013 -0500
@@ -331,6 +331,7 @@
 extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len);
 
 extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
+extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap);
 extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
 extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
 
--- a/premake/Linux/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/Linux/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -128,7 +128,7 @@
 #define HAVE_STRCASECMP 1
 /* #undef HAVE__STRNICMP */
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF 1
 #define HAVE_VSNPRINTF 1
 #define HAVE_M_PI /**/
--- a/premake/MinGW/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/MinGW/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -118,7 +118,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE__STRICMP 1
 #define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_M_PI 1
 #define HAVE_ATAN 1
 #define HAVE_ATAN2 1
--- a/premake/VisualC/VS2008/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/VisualC/VS2008/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -118,7 +118,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE__STRICMP 1
 #define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_M_PI 1
 #define HAVE_ATAN 1
 #define HAVE_ATAN2 1
--- a/premake/VisualC/VS2010/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/VisualC/VS2010/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -118,7 +118,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE__STRICMP 1
 #define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_M_PI 1
 #define HAVE_ATAN 1
 #define HAVE_ATAN2 1
--- a/premake/VisualC/VS2012/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/VisualC/VS2012/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -118,7 +118,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE__STRICMP 1
 #define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_M_PI 1
 #define HAVE_ATAN 1
 #define HAVE_ATAN2 1
--- a/premake/Xcode-iOS/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/Xcode-iOS/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -79,7 +79,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_M_PI   1
--- a/premake/Xcode/Xcode3/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/Xcode/Xcode3/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -85,7 +85,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_CEIL   1
--- a/premake/Xcode/Xcode4/SDL_config_premake.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/Xcode/Xcode4/SDL_config_premake.h	Sun Nov 24 23:35:38 2013 -0500
@@ -85,7 +85,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_CEIL   1
--- a/premake/config/SDL_config_cygwin.template.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/config/SDL_config_cygwin.template.h	Sun Nov 24 23:35:38 2013 -0500
@@ -124,7 +124,7 @@
 #define HAVE_STRCASECMP 1
 /* #undef HAVE__STRNICMP */
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF 1
 #define HAVE_VSNPRINTF 1
 #define HAVE_M_PI /**/
--- a/premake/config/SDL_config_iphoneos.template.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/config/SDL_config_iphoneos.template.h	Sun Nov 24 23:35:38 2013 -0500
@@ -79,7 +79,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_M_PI   1
--- a/premake/config/SDL_config_linux.template.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/config/SDL_config_linux.template.h	Sun Nov 24 23:35:38 2013 -0500
@@ -128,7 +128,7 @@
 #define HAVE_STRCASECMP 1
 /* #undef HAVE__STRNICMP */
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF 1
 #define HAVE_VSNPRINTF 1
 #define HAVE_M_PI /**/
--- a/premake/config/SDL_config_macosx.template.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/config/SDL_config_macosx.template.h	Sun Nov 24 23:35:38 2013 -0500
@@ -85,7 +85,7 @@
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
 #define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_SNPRINTF   1
 #define HAVE_VSNPRINTF  1
 #define HAVE_CEIL   1
--- a/premake/config/SDL_config_windows.template.h	Sun Nov 24 21:04:51 2013 -0500
+++ b/premake/config/SDL_config_windows.template.h	Sun Nov 24 23:35:38 2013 -0500
@@ -118,7 +118,7 @@
 #define HAVE_STRNCMP 1
 #define HAVE__STRICMP 1
 #define HAVE__STRNICMP 1
-#define HAVE_SSCANF 1
+#define HAVE_VSSCANF 1
 #define HAVE_M_PI 1
 #define HAVE_ATAN 1
 #define HAVE_ATAN2 1
--- a/src/stdlib/SDL_string.c	Sun Nov 24 21:04:51 2013 -0500
+++ b/src/stdlib/SDL_string.c	Sun Nov 24 23:35:38 2013 -0500
@@ -43,7 +43,7 @@
         return 0;
 }
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL)
+#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL)
 static size_t
 SDL_ScanLong(const char *text, int radix, long *valuep)
 {
@@ -84,7 +84,7 @@
 }
 #endif
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
+#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
 static size_t
 SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
 {
@@ -116,7 +116,7 @@
 }
 #endif
 
-#ifndef HAVE_SSCANF
+#ifndef HAVE_VSSCANF
 static size_t
 SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep)
 {
@@ -148,7 +148,7 @@
 }
 #endif
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL)
+#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOLL)
 static size_t
 SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep)
 {
@@ -189,7 +189,7 @@
 }
 #endif
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOULL)
+#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOULL)
 static size_t
 SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 * valuep)
 {
@@ -221,7 +221,7 @@
 }
 #endif
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
+#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOD)
 static size_t
 SDL_ScanFloat(const char *text, double *valuep)
 {
@@ -967,25 +967,29 @@
 #endif /* HAVE_STRNCASECMP */
 }
 
-#ifdef HAVE_SSCANF
 int
 SDL_sscanf(const char *text, const char *fmt, ...)
 {
     int rc;
     va_list ap;
     va_start(ap, fmt);
-    rc = vsscanf(text, fmt, ap);
+    rc = SDL_vsscanf(text, fmt, ap);
     va_end(ap);
     return rc;
 }
+
+#ifdef HAVE_VSSCANF
+int
+SDL_vsscanf(const char *text, const char *fmt, va_list ap)
+{
+    return vsscanf(text, fmt, ap);
+}
 #else
 int
-SDL_sscanf(const char *text, const char *fmt, ...)
+SDL_vsscanf(const char *text, const char *fmt, ...)
 {
-    va_list ap;
     int retval = 0;
 
-    va_start(ap, fmt);
     while (*fmt) {
         if (*fmt == ' ') {
             while (SDL_isspace((unsigned char) *text)) {
@@ -1239,11 +1243,10 @@
         /* Text didn't match format specifier */
         break;
     }
-    va_end(ap);
 
     return retval;
 }
-#endif /* HAVE_SSCANF */
+#endif /* HAVE_VSSCANF */
 
 int
 SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)