bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inconsistency in libintl_vsnprintf interface under Windows


From: Ben Pfaff
Subject: inconsistency in libintl_vsnprintf interface under Windows
Date: Sat, 17 Feb 2007 21:54:50 -0800
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

When libintl is used under Windows, it replaces the native
vsnprintf by a wrapper function, libintl_vsnprintf, to add
support for $ in format specifiers.  When $ is not present in a
format string, it falls back to the system vsnprintf.

However, under Windows, the system vsnprintf has argument, return
value, and output semantics that differ from C99 semantics and,
furthermore, from libintl_vasnprintf semantics.  The result is
that libintl_vsnprintf will have C99 semantics when a format
string contains $ (whether in a format specifier or not) and
Windows semantics otherwise.  It may be debatable which set of
semantics should be used, but it seems certain that they should
not be mixed randomly in this way.

I propose to fix it by always using the C99 semantics.  A patch
is below.

snprintf is affected similarly, but because libintl_snprintf is
defined in terms of libintl_vsnprintf, the patch also fixes
snprintf.

Comments?

--- gettext-0.16.1/gettext-runtime/intl/printf.c~
+++ gettext-0.16.1/gettext-runtime/intl/printf.c
@@ -202,9 +202,11 @@ DLL_EXPORTED
 int
 libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list 
args)
 {
+#if !(defined _WIN32 || defined __WIN32__) || defined __CYGWIN__
   if (strchr (format, '$') == NULL)
     return system_vsnprintf (resultbuf, length, format, args);
   else
+#endif
     {
       size_t maxlength = length;
       char *result = libintl_vasnprintf (resultbuf, &length, format, args);

-- 
Ben Pfaff 
address@hidden
http://benpfaff.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]