/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2008 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
# endif
#endif
-#if !USE_SNPRINTF && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR)
+#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR)
# if HAVE_WCSLEN
# define local_wcslen wcslen
# else
# ifndef decimal_point_char_defined
# define decimal_point_char_defined 1
static char
-decimal_point_char ()
+decimal_point_char (void)
{
const char *point;
/* Determine it in a multithread-safe way. We know nl_langinfo is
Normalise [q[m-1],...,q[0]], yields q.
If m>=n>1, perform a multiple-precision division:
We have a/b < beta^(m-n+1).
- s:=intDsize-1-(hightest bit in b[n-1]), 0<=s<intDsize.
+ s:=intDsize-1-(highest bit in b[n-1]), 0<=s<intDsize.
Shift a and b left by s bits, copying them. r:=a.
r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2.
For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).}
size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
/* Convert from UTF-8 to locale encoding. */
- if (u8_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- &converted, &converted_len)
- < 0)
+ converted =
+ u8_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
/* Convert from UTF-8 to UTF-16/UTF-32. */
converted =
U8_TO_DCHAR (arg, arg_end - arg,
converted, &converted_len);
- if (converted == NULL)
# endif
+ if (converted == NULL)
{
int saved_errno = errno;
if (!(result == resultbuf || result == NULL))
size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
/* Convert from UTF-16 to locale encoding. */
- if (u16_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- &converted, &converted_len)
- < 0)
+ converted =
+ u16_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
/* Convert from UTF-16 to UTF-8/UTF-32. */
converted =
U16_TO_DCHAR (arg, arg_end - arg,
converted, &converted_len);
- if (converted == NULL)
# endif
+ if (converted == NULL)
{
int saved_errno = errno;
if (!(result == resultbuf || result == NULL))
size_t converted_len = allocated - length;
# if DCHAR_IS_TCHAR
/* Convert from UTF-32 to locale encoding. */
- if (u32_conv_to_encoding (locale_charset (),
- iconveh_question_mark,
- arg, arg_end - arg, NULL,
- &converted, &converted_len)
- < 0)
+ converted =
+ u32_conv_to_encoding (locale_charset (),
+ iconveh_question_mark,
+ arg, arg_end - arg, NULL,
+ converted, &converted_len);
# else
/* Convert from UTF-32 to UTF-8/UTF-16. */
converted =
U32_TO_DCHAR (arg, arg_end - arg,
converted, &converted_len);
- if (converted == NULL)
# endif
+ if (converted == NULL)
{
int saved_errno = errno;
if (!(result == resultbuf || result == NULL))
}
}
#endif
-#if !USE_SNPRINTF && HAVE_WCHAR_T
+#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
else if (dp->conversion == 's'
# if WIDE_CHAR_VERSION
&& a.arg[dp->arg_index].type != TYPE_WIDE_STRING
}
/* Convert from TCHAR_T[] to DCHAR_T[]. */
- tmpdst = NULL;
- tmpdst_len = 0;
- if (DCHAR_CONV_FROM_ENCODING (locale_charset (),
- iconveh_question_mark,
- tmpsrc, characters,
- NULL,
- &tmpdst, &tmpdst_len)
- < 0)
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, characters,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
{
int saved_errno = errno;
free (tmpsrc);
{
# if WIDE_CHAR_VERSION
/* ISO C says about %ls in fwprintf:
- "If the precision is not specified or is greater
+ "If the precision is not specified or is greater
than the size of the array, the array shall
contain a null wide character."
So if there is a precision, we must not use
tmp_length = local_wcslen (arg);
# else
/* ISO C says about %ls in fprintf:
- "If a precision is specified, no more than that
+ "If a precision is specified, no more than that
many bytes are written (including shift
sequences, if any), and the array shall contain
a null wide character if, to equal the
{
# if WIDE_CHAR_VERSION
/* ISO C says about %s in fwprintf:
- "If the precision is not specified or is greater
+ "If the precision is not specified or is greater
than the size of the converted array, the
converted array shall contain a null wide
character."
# else
tmpsrc = tmp;
# endif
- tmpdst = NULL;
- tmpdst_len = 0;
- if (DCHAR_CONV_FROM_ENCODING (locale_charset (),
- iconveh_question_mark,
- tmpsrc, count,
- NULL,
- &tmpdst, &tmpdst_len)
- < 0)
+ tmpdst =
+ DCHAR_CONV_FROM_ENCODING (locale_charset (),
+ iconveh_question_mark,
+ tmpsrc, count,
+ NULL,
+ NULL, &tmpdst_len);
+ if (tmpdst == NULL)
{
int saved_errno = errno;
if (!(result == resultbuf || result == NULL))
#undef TCHARS_PER_DCHAR
#undef SNPRINTF
#undef USE_SNPRINTF
+#undef DCHAR_SET
#undef DCHAR_CPY
#undef PRINTF_PARSE
#undef DIRECTIVES