From: Bruno Haible Date: Sun, 24 Aug 2003 18:47:20 +0000 (+0000) Subject: On Windows, use _snprintf and _snwprintf instead of snprintf, swprintf. X-Git-Tag: v0.13~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=639fc5d91dee96a0d6287ccfd247b05ede67fd0e;p=thirdparty%2Fgettext.git On Windows, use _snprintf and _snwprintf instead of snprintf, swprintf. --- diff --git a/gettext-runtime/ChangeLog b/gettext-runtime/ChangeLog index 1d7501630..289885a03 100644 --- a/gettext-runtime/ChangeLog +++ b/gettext-runtime/ChangeLog @@ -1,3 +1,11 @@ +2003-08-24 Bruno Haible + + * Makefile.am (config.h.msvc): Define HAVE__SNPRINTF, HAVE__SNWPRINTF. + +2003-08-24 Bruno Haible + + * configure.ac: Define DLL_VARIABLE in config.h through AH_BOTTOM. + 2003-08-23 Bruno Haible * Makefile.am (config.h_vms): Define HAVE_READLINK and HAVE_WCSLEN. diff --git a/gettext-runtime/Makefile.am b/gettext-runtime/Makefile.am index faf7de1c8..41a56f5ae 100644 --- a/gettext-runtime/Makefile.am +++ b/gettext-runtime/Makefile.am @@ -157,6 +157,8 @@ config.h.msvc: config.h.in ../version.sh -e 's/#undef HAVE_WCSLEN$$/#define HAVE_WCSLEN 1/' \ -e 's/#undef HAVE_WINT_T$$/#define HAVE_WINT_T 1/' \ -e 's/#undef HAVE_WPRINTF$$/#define HAVE_WPRINTF 1/' \ + -e 's/#undef HAVE__SNPRINTF$$/#define HAVE__SNPRINTF 1/' \ + -e 's/#undef HAVE__SNWPRINTF$$/#define HAVE__SNWPRINTF 1/' \ -e 's/#undef ICONV_CONST$$/#define ICONV_CONST const/' \ -e 's/#undef STACK_DIRECTION$$/#define STACK_DIRECTION -1/' \ -e 's/#undef STDC_HEADERS$$/#define STDC_HEADERS 1/' \ diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index e82a1ded7..2701721f5 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,9 @@ +2003-08-24 Bruno Haible + + * vasnprintf.c (local_wcslen): Protect against multiple definition. + (USE_SNPRINTF): Define also if only _snprintf() is available. + (SNPRINTF): Possibly define as _snprintf or _snwprintf. + 2003-08-24 Bruno Haible * libgnuintl.h.in: Use when compiling with MSVC, even though diff --git a/gettext-runtime/intl/vasnprintf.c b/gettext-runtime/intl/vasnprintf.c index 6d2c768fd..28938549f 100644 --- a/gettext-runtime/intl/vasnprintf.c +++ b/gettext-runtime/intl/vasnprintf.c @@ -63,7 +63,11 @@ # define local_wcslen wcslen # else /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid - a dependency towards this library, here is a local substitute. */ + a dependency towards this library, here is a local substitute. + Define this substitute only once, even if this file is included + twice in the same compilation unit. */ +# ifndef local_wcslen_defined +# define local_wcslen_defined 1 static size_t local_wcslen (const wchar_t *s) { @@ -73,6 +77,7 @@ local_wcslen (const wchar_t *s) ; return ptr - s; } +# endif # endif #endif @@ -83,15 +88,28 @@ local_wcslen (const wchar_t *s) # define DIRECTIVES wchar_t_directives # define PRINTF_PARSE wprintf_parse # define USE_SNPRINTF 1 -# define SNPRINTF swprintf +# if HAVE__SNWPRINTF + /* On Windows, the function swprintf() has a different signature than + on Unix; we use the _snwprintf() function instead. */ +# define SNPRINTF _snwprintf +# else + /* Unix. */ +# define SNPRINTF swprintf +# endif #else # define VASNPRINTF vasnprintf # define CHAR_T char # define DIRECTIVE char_directive # define DIRECTIVES char_directives # define PRINTF_PARSE printf_parse -# define USE_SNPRINTF HAVE_SNPRINTF -# define SNPRINTF snprintf +# define USE_SNPRINTF (HAVE__SNPRINTF || HAVE_SNPRINTF) +# if HAVE__SNPRINTF + /* Windows. */ +# define SNPRINTF _snprintf +# else + /* Unix. */ +# define SNPRINTF snprintf +# endif #endif CHAR_T * diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog index de9a64dac..9e8ce65b1 100644 --- a/gettext-runtime/libasprintf/ChangeLog +++ b/gettext-runtime/libasprintf/ChangeLog @@ -1,3 +1,10 @@ +2003-08-24 Bruno Haible + + * vasnprintf.c (local_wcslen): Protect against multiple definition. + (USE_SNPRINTF): Define also if only _snprintf() is available. + (SNPRINTF): Possibly define as _snprintf or _snwprintf. + * configure.ac: Also check for _snprintf. + 2003-08-11 Bruno Haible * vasnprintf.c (local_wcslen): New function, for Solaris 2.5.1. diff --git a/gettext-runtime/libasprintf/configure.ac b/gettext-runtime/libasprintf/configure.ac index 9bdc07887..7e9e1e6a7 100644 --- a/gettext-runtime/libasprintf/configure.ac +++ b/gettext-runtime/libasprintf/configure.ac @@ -68,7 +68,7 @@ AC_EGREP_CPP([Need own alloca], [ ALLOCA_H=) AC_SUBST([ALLOCA_H]) -AC_CHECK_FUNCS([snprintf vasprintf wcslen]) +AC_CHECK_FUNCS([snprintf vasprintf wcslen _snprintf]) gt_PRINTF_POSIX dnl Check for tools needed for formatting the documentation. diff --git a/gettext-runtime/libasprintf/vasnprintf.c b/gettext-runtime/libasprintf/vasnprintf.c index 6d2c768fd..28938549f 100644 --- a/gettext-runtime/libasprintf/vasnprintf.c +++ b/gettext-runtime/libasprintf/vasnprintf.c @@ -63,7 +63,11 @@ # define local_wcslen wcslen # else /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid - a dependency towards this library, here is a local substitute. */ + a dependency towards this library, here is a local substitute. + Define this substitute only once, even if this file is included + twice in the same compilation unit. */ +# ifndef local_wcslen_defined +# define local_wcslen_defined 1 static size_t local_wcslen (const wchar_t *s) { @@ -73,6 +77,7 @@ local_wcslen (const wchar_t *s) ; return ptr - s; } +# endif # endif #endif @@ -83,15 +88,28 @@ local_wcslen (const wchar_t *s) # define DIRECTIVES wchar_t_directives # define PRINTF_PARSE wprintf_parse # define USE_SNPRINTF 1 -# define SNPRINTF swprintf +# if HAVE__SNWPRINTF + /* On Windows, the function swprintf() has a different signature than + on Unix; we use the _snwprintf() function instead. */ +# define SNPRINTF _snwprintf +# else + /* Unix. */ +# define SNPRINTF swprintf +# endif #else # define VASNPRINTF vasnprintf # define CHAR_T char # define DIRECTIVE char_directive # define DIRECTIVES char_directives # define PRINTF_PARSE printf_parse -# define USE_SNPRINTF HAVE_SNPRINTF -# define SNPRINTF snprintf +# define USE_SNPRINTF (HAVE__SNPRINTF || HAVE_SNPRINTF) +# if HAVE__SNPRINTF + /* Windows. */ +# define SNPRINTF _snprintf +# else + /* Unix. */ +# define SNPRINTF snprintf +# endif #endif CHAR_T * diff --git a/gettext-runtime/m4/ChangeLog b/gettext-runtime/m4/ChangeLog index 10794c07d..239a383b3 100644 --- a/gettext-runtime/m4/ChangeLog +++ b/gettext-runtime/m4/ChangeLog @@ -1,3 +1,7 @@ +2003-08-24 Bruno Haible + + * gettext.m4 (AM_INTL_SUBDIR): Also check for _snprintf, _snwprintf. + 2003-08-11 Bruno Haible * gettext.m4 (AM_INTL_SUBDIR): Also check for wcslen. diff --git a/gettext-runtime/m4/gettext.m4 b/gettext-runtime/m4/gettext.m4 index f6565e422..e62c515f0 100644 --- a/gettext-runtime/m4/gettext.m4 +++ b/gettext-runtime/m4/gettext.m4 @@ -1,4 +1,4 @@ -# gettext.m4 serial 23 (gettext-0.12.2) +# gettext.m4 serial 24 (gettext-0.12.2) dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -379,8 +379,8 @@ AC_DEFUN([AM_INTL_SUBDIR], stdlib.h string.h unistd.h sys/param.h]) AC_CHECK_FUNCS([asprintf getcwd getegid geteuid getgid getuid mempcpy \ munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup strtoul \ -tsearch wcslen wprintf __argz_count __argz_stringify __argz_next \ -__fsetlocking]) +tsearch wcslen wprintf _snprintf _snwprintf __argz_count __argz_stringify \ +__argz_next __fsetlocking]) dnl Use the *_unlocked functions only if they are declared. dnl (because some of them were defined without being declared in Solaris diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index b48f16ce6..7fd6b8e74 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,11 @@ +2003-08-24 Bruno Haible + + * Makefile.am (config.h.msvc): Define HAVE__SNPRINTF, HAVE__SNWPRINTF. + +2003-08-24 Bruno Haible + + * configure.ac: Define DLL_VARIABLE in config.h through AH_BOTTOM. + 2003-08-24 Bruno Haible * windows/gettextsrc.def: Add formatstring_gcc_internal, diff --git a/gettext-tools/Makefile.am b/gettext-tools/Makefile.am index e2b8a9857..e473041cc 100644 --- a/gettext-tools/Makefile.am +++ b/gettext-tools/Makefile.am @@ -198,6 +198,8 @@ config.h.msvc: config.h.in ../version.sh -e 's/#undef HAVE_WCSLEN$$/#define HAVE_WCSLEN 1/' \ -e 's/#undef HAVE_WINT_T$$/#define HAVE_WINT_T 1/' \ -e 's/#undef HAVE_WPRINTF$$/#define HAVE_WPRINTF 1/' \ + -e 's/#undef HAVE__SNPRINTF$$/#define HAVE__SNPRINTF 1/' \ + -e 's/#undef HAVE__SNWPRINTF$$/#define HAVE__SNWPRINTF 1/' \ -e 's/#undef ICONV_CONST$$/#define ICONV_CONST const/' \ -e 's/#undef SETLOCALE_CONST$$/#define SETLOCALE_CONST const/' \ -e 's/#undef STACK_DIRECTION$$/#define STACK_DIRECTION -1/' \