+2007-07-01 Bruno Haible <bruno@clisp.org>
+
+ * lib/unistdio.h: New file.
+ * lib/unistdio/u-asnprintf.h: New file.
+ * lib/unistdio/u-asprintf.h: New file.
+ * lib/unistdio/u-printf-args.c: New file.
+ * lib/unistdio/u-printf-args.h: New file.
+ * lib/unistdio/u-printf-parse.h: New file.
+ * lib/unistdio/u-snprintf.h: New file.
+ * lib/unistdio/u-sprintf.h: New file.
+ * lib/unistdio/u-vasprintf.h: New file.
+ * lib/unistdio/u-vsnprintf.h: New file.
+ * lib/unistdio/u-vsprintf.h: New file.
+ * lib/unistdio/ulc-asnprintf.c: New file.
+ * lib/unistdio/ulc-asprintf.c: New file.
+ * lib/unistdio/ulc-fprintf.c: New file, based on lib/fprintf.c.
+ * lib/unistdio/ulc-printf-parse.c: New file.
+ * lib/unistdio/ulc-snprintf.c: New file.
+ * lib/unistdio/ulc-sprintf.c: New file.
+ * lib/unistdio/ulc-vasnprintf.c: New file.
+ * lib/unistdio/ulc-vasprintf.c: New file.
+ * lib/unistdio/ulc-vfprintf.c: New file, based on lib/vfprintf.c.
+ * lib/unistdio/ulc-vsnprintf.c: New file.
+ * lib/unistdio/ulc-vsprintf.c: New file.
+ * lib/unistdio/u8-asnprintf.c: New file.
+ * lib/unistdio/u8-asprintf.c: New file.
+ * lib/unistdio/u8-printf-parse.c: New file.
+ * lib/unistdio/u8-snprintf.c: New file.
+ * lib/unistdio/u8-sprintf.c: New file.
+ * lib/unistdio/u8-vasnprintf.c: New file.
+ * lib/unistdio/u8-vasprintf.c: New file.
+ * lib/unistdio/u8-vsnprintf.c: New file.
+ * lib/unistdio/u8-vsprintf.c: New file.
+ * lib/unistdio/u8-u8-asnprintf.c: New file.
+ * lib/unistdio/u8-u8-asprintf.c: New file.
+ * lib/unistdio/u8-u8-snprintf.c: New file.
+ * lib/unistdio/u8-u8-sprintf.c: New file.
+ * lib/unistdio/u8-u8-vasnprintf.c: New file.
+ * lib/unistdio/u8-u8-vasprintf.c: New file.
+ * lib/unistdio/u8-u8-vsnprintf.c: New file.
+ * lib/unistdio/u8-u8-vsprintf.c: New file.
+ * lib/unistdio/u16-asnprintf.c: New file.
+ * lib/unistdio/u16-asprintf.c: New file.
+ * lib/unistdio/u16-printf-parse.c: New file.
+ * lib/unistdio/u16-snprintf.c: New file.
+ * lib/unistdio/u16-sprintf.c: New file.
+ * lib/unistdio/u16-vasnprintf.c: New file.
+ * lib/unistdio/u16-vasprintf.c: New file.
+ * lib/unistdio/u16-vsnprintf.c: New file.
+ * lib/unistdio/u16-vsprintf.c: New file.
+ * lib/unistdio/u16-u16-asnprintf.c: New file.
+ * lib/unistdio/u16-u16-asprintf.c: New file.
+ * lib/unistdio/u16-u16-snprintf.c: New file.
+ * lib/unistdio/u16-u16-sprintf.c: New file.
+ * lib/unistdio/u16-u16-vasnprintf.c: New file.
+ * lib/unistdio/u16-u16-vasprintf.c: New file.
+ * lib/unistdio/u16-u16-vsnprintf.c: New file.
+ * lib/unistdio/u16-u16-vsprintf.c: New file.
+ * lib/unistdio/u32-asnprintf.c: New file.
+ * lib/unistdio/u32-asprintf.c: New file.
+ * lib/unistdio/u32-printf-parse.c: New file.
+ * lib/unistdio/u32-snprintf.c: New file.
+ * lib/unistdio/u32-sprintf.c: New file.
+ * lib/unistdio/u32-vasnprintf.c: New file.
+ * lib/unistdio/u32-vasprintf.c: New file.
+ * lib/unistdio/u32-vsnprintf.c: New file.
+ * lib/unistdio/u32-vsprintf.c: New file.
+ * lib/unistdio/u32-u32-asnprintf.c: New file.
+ * lib/unistdio/u32-u32-asprintf.c: New file.
+ * lib/unistdio/u32-u32-snprintf.c: New file.
+ * lib/unistdio/u32-u32-sprintf.c: New file.
+ * lib/unistdio/u32-u32-vasnprintf.c: New file.
+ * lib/unistdio/u32-u32-vasprintf.c: New file.
+ * lib/unistdio/u32-u32-vsnprintf.c: New file.
+ * lib/unistdio/u32-u32-vsprintf.c: New file.
+ * tests/unistdio/test-ulc-asnprintf1.c: New file.
+ * tests/unistdio/test-ulc-asnprintf1.h: New file.
+ * tests/unistdio/test-ulc-printf1.h: New file.
+ * tests/unistdio/test-ulc-vasnprintf1.c: New file.
+ * tests/unistdio/test-ulc-vasnprintf2.c: New file.
+ * tests/unistdio/test-ulc-vasnprintf2.sh: New file.
+ * tests/unistdio/test-ulc-vasnprintf3.c: New file.
+ * tests/unistdio/test-ulc-vasnprintf3.sh: New file.
+ * tests/unistdio/test-ulc-vasprintf1.c: New file.
+ * tests/unistdio/test-ulc-vsnprintf1.c: New file.
+ * tests/unistdio/test-ulc-vsprintf1.c: New file.
+ * tests/unistdio/test-u8-asnprintf1.c: New file.
+ * tests/unistdio/test-u8-asnprintf1.h: New file.
+ * tests/unistdio/test-u8-printf1.h: New file.
+ * tests/unistdio/test-u8-vasnprintf1.c: New file.
+ * tests/unistdio/test-u8-vasnprintf2.c: New file.
+ * tests/unistdio/test-u8-vasnprintf2.sh: New file.
+ * tests/unistdio/test-u8-vasnprintf3.c: New file.
+ * tests/unistdio/test-u8-vasnprintf3.sh: New file.
+ * tests/unistdio/test-u8-vasprintf1.c: New file.
+ * tests/unistdio/test-u8-vsnprintf1.c: New file.
+ * tests/unistdio/test-u8-vsprintf1.c: New file.
+ * tests/unistdio/test-u16-asnprintf1.c: New file.
+ * tests/unistdio/test-u16-asnprintf1.h: New file.
+ * tests/unistdio/test-u16-printf1.h: New file.
+ * tests/unistdio/test-u16-vasnprintf1.c: New file.
+ * tests/unistdio/test-u16-vasnprintf2.c: New file.
+ * tests/unistdio/test-u16-vasnprintf2.sh: New file.
+ * tests/unistdio/test-u16-vasnprintf3.c: New file.
+ * tests/unistdio/test-u16-vasnprintf3.sh: New file.
+ * tests/unistdio/test-u16-vasprintf1.c: New file.
+ * tests/unistdio/test-u16-vsnprintf1.c: New file.
+ * tests/unistdio/test-u16-vsprintf1.c: New file.
+ * tests/unistdio/test-u32-asnprintf1.c: New file.
+ * tests/unistdio/test-u32-asnprintf1.h: New file.
+ * tests/unistdio/test-u32-printf1.h: New file.
+ * tests/unistdio/test-u32-vasnprintf1.c: New file.
+ * tests/unistdio/test-u32-vasnprintf2.c: New file.
+ * tests/unistdio/test-u32-vasnprintf2.sh: New file.
+ * tests/unistdio/test-u32-vasnprintf3.c: New file.
+ * tests/unistdio/test-u32-vasnprintf3.sh: New file.
+ * tests/unistdio/test-u32-vasprintf1.c: New file.
+ * tests/unistdio/test-u32-vsnprintf1.c: New file.
+ * tests/unistdio/test-u32-vsprintf1.c: New file.
+ * modules/unistdio/base: New file.
+ * modules/unistdio/u-printf-args: New file.
+ * modules/unistdio/ulc-asnprintf: New file.
+ * modules/unistdio/ulc-asprintf: New file.
+ * modules/unistdio/ulc-fprintf: New file.
+ * modules/unistdio/ulc-printf-parse: New file.
+ * modules/unistdio/ulc-snprintf: New file.
+ * modules/unistdio/ulc-sprintf: New file.
+ * modules/unistdio/ulc-vasnprintf: New file.
+ * modules/unistdio/ulc-vasprintf: New file.
+ * modules/unistdio/ulc-vfprintf: New file.
+ * modules/unistdio/ulc-vsnprintf: New file.
+ * modules/unistdio/ulc-vsprintf: New file.
+ * modules/unistdio/u8-asnprintf: New file.
+ * modules/unistdio/u8-asprintf: New file.
+ * modules/unistdio/u8-printf-parse: New file.
+ * modules/unistdio/u8-snprintf: New file.
+ * modules/unistdio/u8-sprintf: New file.
+ * modules/unistdio/u8-vasnprintf: New file.
+ * modules/unistdio/u8-vasprintf: New file.
+ * modules/unistdio/u8-vsnprintf: New file.
+ * modules/unistdio/u8-vsprintf: New file.
+ * modules/unistdio/u8-u8-asnprintf: New file.
+ * modules/unistdio/u8-u8-asprintf: New file.
+ * modules/unistdio/u8-u8-snprintf: New file.
+ * modules/unistdio/u8-u8-sprintf: New file.
+ * modules/unistdio/u8-u8-vasnprintf: New file.
+ * modules/unistdio/u8-u8-vasprintf: New file.
+ * modules/unistdio/u8-u8-vsnprintf: New file.
+ * modules/unistdio/u8-u8-vsprintf: New file.
+ * modules/unistdio/u16-asnprintf: New file.
+ * modules/unistdio/u16-asprintf: New file.
+ * modules/unistdio/u16-printf-parse: New file.
+ * modules/unistdio/u16-snprintf: New file.
+ * modules/unistdio/u16-sprintf: New file.
+ * modules/unistdio/u16-vasnprintf: New file.
+ * modules/unistdio/u16-vasprintf: New file.
+ * modules/unistdio/u16-vsnprintf: New file.
+ * modules/unistdio/u16-vsprintf: New file.
+ * modules/unistdio/u16-u16-asnprintf: New file.
+ * modules/unistdio/u16-u16-asprintf: New file.
+ * modules/unistdio/u16-u16-snprintf: New file.
+ * modules/unistdio/u16-u16-sprintf: New file.
+ * modules/unistdio/u16-u16-vasnprintf: New file.
+ * modules/unistdio/u16-u16-vasprintf: New file.
+ * modules/unistdio/u16-u16-vsnprintf: New file.
+ * modules/unistdio/u16-u16-vsprintf: New file.
+ * modules/unistdio/u32-asnprintf: New file.
+ * modules/unistdio/u32-asprintf: New file.
+ * modules/unistdio/u32-printf-parse: New file.
+ * modules/unistdio/u32-snprintf: New file.
+ * modules/unistdio/u32-sprintf: New file.
+ * modules/unistdio/u32-vasnprintf: New file.
+ * modules/unistdio/u32-vasprintf: New file.
+ * modules/unistdio/u32-vsnprintf: New file.
+ * modules/unistdio/u32-vsprintf: New file.
+ * modules/unistdio/u32-u32-asnprintf: New file.
+ * modules/unistdio/u32-u32-asprintf: New file.
+ * modules/unistdio/u32-u32-snprintf: New file.
+ * modules/unistdio/u32-u32-sprintf: New file.
+ * modules/unistdio/u32-u32-vasnprintf: New file.
+ * modules/unistdio/u32-u32-vasprintf: New file.
+ * modules/unistdio/u32-u32-vsnprintf: New file.
+ * modules/unistdio/u32-u32-vsprintf: New file.
+ * modules/unistdio/ulc-asnprintf-tests: New file.
+ * modules/unistdio/ulc-vasnprintf-tests: New file.
+ * modules/unistdio/ulc-vasprintf-tests: New file.
+ * modules/unistdio/ulc-vsnprintf-tests: New file.
+ * modules/unistdio/ulc-vsprintf-tests: New file.
+ * modules/unistdio/u8-asnprintf-tests: New file.
+ * modules/unistdio/u8-vasnprintf-tests: New file.
+ * modules/unistdio/u8-vasprintf-tests: New file.
+ * modules/unistdio/u8-vsnprintf-tests: New file.
+ * modules/unistdio/u8-vsprintf-tests: New file.
+ * modules/unistdio/u16-asnprintf-tests: New file.
+ * modules/unistdio/u16-vasnprintf-tests: New file.
+ * modules/unistdio/u16-vasprintf-tests: New file.
+ * modules/unistdio/u16-vsnprintf-tests: New file.
+ * modules/unistdio/u16-vsprintf-tests: New file.
+ * modules/unistdio/u32-asnprintf-tests: New file.
+ * modules/unistdio/u32-vasnprintf-tests: New file.
+ * modules/unistdio/u32-vasprintf-tests: New file.
+ * modules/unistdio/u32-vsnprintf-tests: New file.
+ * modules/unistdio/u32-vsprintf-tests: New file.
+ * MODULES.html.sh (Unicode string functions): Add the new modules.
+
2007-07-01 Bruno Haible <bruno@clisp.org>
* lib/sprintf.c (sprintf): Limit the available length estimation,
func_module uniconv/u8-strconv-to-locale
func_module uniconv/u16-strconv-to-locale
func_module uniconv/u32-strconv-to-locale
+ func_module unistdio/base
+ func_module unistdio/u-printf-args
+ func_module unistdio/ulc-asnprintf
+ func_module unistdio/ulc-asprintf
+ func_module unistdio/ulc-fprintf
+ func_module unistdio/ulc-printf-parse
+ func_module unistdio/ulc-snprintf
+ func_module unistdio/ulc-sprintf
+ func_module unistdio/ulc-vasnprintf
+ func_module unistdio/ulc-vasprintf
+ func_module unistdio/ulc-vfprintf
+ func_module unistdio/ulc-vsnprintf
+ func_module unistdio/ulc-vsprintf
+ func_module unistdio/u8-asnprintf
+ func_module unistdio/u8-asprintf
+ func_module unistdio/u8-printf-parse
+ func_module unistdio/u8-snprintf
+ func_module unistdio/u8-sprintf
+ func_module unistdio/u8-vasnprintf
+ func_module unistdio/u8-vasprintf
+ func_module unistdio/u8-vsnprintf
+ func_module unistdio/u8-vsprintf
+ func_module unistdio/u8-u8-asnprintf
+ func_module unistdio/u8-u8-asprintf
+ func_module unistdio/u8-u8-snprintf
+ func_module unistdio/u8-u8-sprintf
+ func_module unistdio/u8-u8-vasnprintf
+ func_module unistdio/u8-u8-vasprintf
+ func_module unistdio/u8-u8-vsnprintf
+ func_module unistdio/u8-u8-vsprintf
+ func_module unistdio/u16-asnprintf
+ func_module unistdio/u16-asprintf
+ func_module unistdio/u16-printf-parse
+ func_module unistdio/u16-snprintf
+ func_module unistdio/u16-sprintf
+ func_module unistdio/u16-vasnprintf
+ func_module unistdio/u16-vasprintf
+ func_module unistdio/u16-vsnprintf
+ func_module unistdio/u16-vsprintf
+ func_module unistdio/u16-u16-asnprintf
+ func_module unistdio/u16-u16-asprintf
+ func_module unistdio/u16-u16-snprintf
+ func_module unistdio/u16-u16-sprintf
+ func_module unistdio/u16-u16-vasnprintf
+ func_module unistdio/u16-u16-vasprintf
+ func_module unistdio/u16-u16-vsnprintf
+ func_module unistdio/u16-u16-vsprintf
+ func_module unistdio/u32-asnprintf
+ func_module unistdio/u32-asprintf
+ func_module unistdio/u32-printf-parse
+ func_module unistdio/u32-snprintf
+ func_module unistdio/u32-sprintf
+ func_module unistdio/u32-vasnprintf
+ func_module unistdio/u32-vasprintf
+ func_module unistdio/u32-vsnprintf
+ func_module unistdio/u32-vsprintf
+ func_module unistdio/u32-u32-asnprintf
+ func_module unistdio/u32-u32-asprintf
+ func_module unistdio/u32-u32-snprintf
+ func_module unistdio/u32-u32-sprintf
+ func_module unistdio/u32-u32-vasnprintf
+ func_module unistdio/u32-u32-vasprintf
+ func_module unistdio/u32-u32-vsnprintf
+ func_module unistdio/u32-u32-vsprintf
func_end_table
element="Executing programs"
--- /dev/null
+/* Elementary Unicode string functions.
+ Copyright (C) 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef _UNISTDIO_H
+#define _UNISTDIO_H
+
+#include "unitypes.h"
+
+/* Get size_t. */
+#include <stddef.h>
+
+/* Get FILE. */
+#include <stdio.h>
+
+/* Get va_list. */
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These work like the printf function family.
+ In the format string:
+ The format directive 'U' takes an UTF-8 string (const uint8_t *).
+ The format directive 'lU' takes an UTF-16 string (const uint16_t *).
+ The format directive 'llU' takes an UTF-32 string (const uint32_t *).
+
+ The prefix (ulc_, u8_, u16_, u16_) indicates the type of the resulting
+ string. The prefix 'ulc' stands for "locale encoded".
+
+ An infix 'v' indicates that a va_list is passed instead of multiple
+ arguments.
+
+ The functions *sprintf have a 'buf' argument that is assumed to be large
+ enough. (DANGEROUS! Overflowing the buffer will crash the program.)
+ The functions *snprintf have a 'buf' argument that is assumed to be 'size'
+ units large. (DANGEROUS! The resulting string might be truncated in the
+ middle of a multibyte character.)
+ The functions *asprintf have a 'resultp' argument. The result will be
+ freshly allocated and stored in *resultp.
+ The functions *asnprintf have a (resultbuf, lengthp) argument pair. If
+ resultbuf is not NULL and the result fits into *lengthp units, it is put
+ in resultbuf, and resultbuf is returned. Otherwise, a freshly allocated
+ string is returned. In both cases, *lengthp is set to the length (number
+ of units) of the returned string. In case of error, NULL is returned and
+ errno is set.
+ */
+
+/* ASCII format string, result in locale dependent encoded 'char *'. */
+extern int
+ ulc_sprintf (char *buf,
+ const char *format, ...);
+extern int
+ ulc_snprintf (char *buf, size_t size,
+ const char *format, ...);
+extern int
+ ulc_asprintf (char **resultp,
+ const char *format, ...);
+extern char *
+ ulc_asnprintf (char *resultbuf, size_t *lengthp,
+ const char *format, ...);
+extern int
+ ulc_vsprintf (char *buf,
+ const char *format, va_list ap);
+extern int
+ ulc_vsnprintf (char *buf, size_t size,
+ const char *format, va_list ap);
+extern int
+ ulc_vasprintf (char **resultp,
+ const char *format, va_list ap);
+extern char *
+ ulc_vasnprintf (char *resultbuf, size_t *lengthp,
+ const char *format, va_list ap);
+
+/* ASCII format string, result in UTF-8 format. */
+extern int
+ u8_sprintf (uint8_t *buf,
+ const char *format, ...);
+extern int
+ u8_snprintf (uint8_t *buf, size_t size,
+ const char *format, ...);
+extern int
+ u8_asprintf (uint8_t **resultp,
+ const char *format, ...);
+extern uint8_t *
+ u8_asnprintf (uint8_t *resultbuf, size_t *lengthp,
+ const char *format, ...);
+extern int
+ u8_vsprintf (uint8_t *buf,
+ const char *format, va_list ap);
+extern int
+ u8_vsnprintf (uint8_t *buf, size_t size,
+ const char *format, va_list ap);
+extern int
+ u8_vasprintf (uint8_t **resultp,
+ const char *format, va_list ap);
+extern uint8_t *
+ u8_vasnprintf (uint8_t *resultbuf, size_t *lengthp,
+ const char *format, va_list ap);
+
+/* UTF-8 format string, result in UTF-8 format. */
+extern int
+ u8_u8_sprintf (uint8_t *buf,
+ const uint8_t *format, ...);
+extern int
+ u8_u8_snprintf (uint8_t *buf, size_t size,
+ const uint8_t *format, ...);
+extern int
+ u8_u8_asprintf (uint8_t **resultp,
+ const uint8_t *format, ...);
+extern uint8_t *
+ u8_u8_asnprintf (uint8_t *resultbuf, size_t *lengthp,
+ const uint8_t *format, ...);
+extern int
+ u8_u8_vsprintf (uint8_t *buf,
+ const uint8_t *format, va_list ap);
+extern int
+ u8_u8_vsnprintf (uint8_t *buf, size_t size,
+ const uint8_t *format, va_list ap);
+extern int
+ u8_u8_vasprintf (uint8_t **resultp,
+ const uint8_t *format, va_list ap);
+extern uint8_t *
+ u8_u8_vasnprintf (uint8_t *resultbuf, size_t *lengthp,
+ const uint8_t *format, va_list ap);
+
+/* ASCII format string, result in UTF-16 format. */
+extern int
+ u16_sprintf (uint16_t *buf,
+ const char *format, ...);
+extern int
+ u16_snprintf (uint16_t *buf, size_t size,
+ const char *format, ...);
+extern int
+ u16_asprintf (uint16_t **resultp,
+ const char *format, ...);
+extern uint16_t *
+ u16_asnprintf (uint16_t *resultbuf, size_t *lengthp,
+ const char *format, ...);
+extern int
+ u16_vsprintf (uint16_t *buf,
+ const char *format, va_list ap);
+extern int
+ u16_vsnprintf (uint16_t *buf, size_t size,
+ const char *format, va_list ap);
+extern int
+ u16_vasprintf (uint16_t **resultp,
+ const char *format, va_list ap);
+extern uint16_t *
+ u16_vasnprintf (uint16_t *resultbuf, size_t *lengthp,
+ const char *format, va_list ap);
+
+/* UTF-16 format string, result in UTF-16 format. */
+extern int
+ u16_u16_sprintf (uint16_t *buf,
+ const uint16_t *format, ...);
+extern int
+ u16_u16_snprintf (uint16_t *buf, size_t size,
+ const uint16_t *format, ...);
+extern int
+ u16_u16_asprintf (uint16_t **resultp,
+ const uint16_t *format, ...);
+extern uint16_t *
+ u16_u16_asnprintf (uint16_t *resultbuf, size_t *lengthp,
+ const uint16_t *format, ...);
+extern int
+ u16_u16_vsprintf (uint16_t *buf,
+ const uint16_t *format, va_list ap);
+extern int
+ u16_u16_vsnprintf (uint16_t *buf, size_t size,
+ const uint16_t *format, va_list ap);
+extern int
+ u16_u16_vasprintf (uint16_t **resultp,
+ const uint16_t *format, va_list ap);
+extern uint16_t *
+ u16_u16_vasnprintf (uint16_t *resultbuf, size_t *lengthp,
+ const uint16_t *format, va_list ap);
+
+/* ASCII format string, result in UTF-32 format. */
+extern int
+ u32_sprintf (uint32_t *buf,
+ const char *format, ...);
+extern int
+ u32_snprintf (uint32_t *buf, size_t size,
+ const char *format, ...);
+extern int
+ u32_asprintf (uint32_t **resultp,
+ const char *format, ...);
+extern uint32_t *
+ u32_asnprintf (uint32_t *resultbuf, size_t *lengthp,
+ const char *format, ...);
+extern int
+ u32_vsprintf (uint32_t *buf,
+ const char *format, va_list ap);
+extern int
+ u32_vsnprintf (uint32_t *buf, size_t size,
+ const char *format, va_list ap);
+extern int
+ u32_vasprintf (uint32_t **resultp,
+ const char *format, va_list ap);
+extern uint32_t *
+ u32_vasnprintf (uint32_t *resultbuf, size_t *lengthp,
+ const char *format, va_list ap);
+
+/* UTF-32 format string, result in UTF-32 format. */
+extern int
+ u32_u32_sprintf (uint32_t *buf,
+ const uint32_t *format, ...);
+extern int
+ u32_u32_snprintf (uint32_t *buf, size_t size,
+ const uint32_t *format, ...);
+extern int
+ u32_u32_asprintf (uint32_t **resultp,
+ const uint32_t *format, ...);
+extern uint32_t *
+ u32_u32_asnprintf (uint32_t *resultbuf, size_t *lengthp,
+ const uint32_t *format, ...);
+extern int
+ u32_u32_vsprintf (uint32_t *buf,
+ const uint32_t *format, va_list ap);
+extern int
+ u32_u32_vsnprintf (uint32_t *buf, size_t size,
+ const uint32_t *format, va_list ap);
+extern int
+ u32_u32_vasprintf (uint32_t **resultp,
+ const uint32_t *format, va_list ap);
+extern uint32_t *
+ u32_u32_vasnprintf (uint32_t *resultbuf, size_t *lengthp,
+ const uint32_t *format, va_list ap);
+
+/* ASCII format string, output to FILE in locale dependent encoding. */
+extern int
+ ulc_fprintf (FILE *stream,
+ const char *format, ...);
+extern int
+ ulc_vfprintf (FILE *stream,
+ const char *format, va_list ap);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UNISTDIO_H */
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+DCHAR_T *
+ASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const FCHAR_T *format, ...)
+{
+ va_list args;
+ DCHAR_T *result;
+
+ va_start (args, format);
+ result = VASNPRINTF (resultbuf, lengthp, format, args);
+ va_end (args);
+ return result;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+int
+ASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VASPRINTF (resultp, format, args);
+ va_end (args);
+ return result;
+}
--- /dev/null
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-args.h"
+
+#include "printf-args.c"
--- /dev/null
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef _U_PRINTF_ARGS_H
+#define _U_PRINTF_ARGS_H
+
+#include "unitypes.h"
+
+/* Parametrization of printf-args.h. */
+#define ENABLE_UNISTDIO 1
+#define PRINTF_FETCHARGS u_printf_fetchargs
+#include "printf-args.h"
+
+#endif /* _U_PRINTF_ARGS_H */
--- /dev/null
+/* Parse printf format string.
+ Copyright (C) 1999, 2002, 2005, 2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef _U_PRINTF_PARSE_H
+#define _U_PRINTF_PARSE_H
+
+#include "unistdio/u-printf-args.h"
+
+/* Parametrization of printf-parse.h. */
+#undef ENABLE_UNISTDIO
+#define ENABLE_UNISTDIO 1
+#include "printf-parse.h"
+
+#endif /* _U_PRINTF_PARSE_H */
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+int
+SNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VSNPRINTF (buf, size, format, args);
+ va_end (args);
+ return result;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+int
+SPRINTF (DCHAR_T *buf, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VSPRINTF (buf, format, args);
+ va_end (args);
+ return result;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
+int
+VASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, va_list args)
+{
+ size_t length;
+ DCHAR_T *result = VASNPRINTF (NULL, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (length > INT_MAX)
+ {
+ free (result);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ *resultp = result;
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
+int
+VSNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, va_list args)
+{
+ size_t length;
+ DCHAR_T *result;
+
+ if (size == 0)
+ buf = NULL;
+ else
+ length = size;
+ result = VASNPRINTF (buf, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (result != buf)
+ {
+ if (size != 0)
+ {
+ /* The result did not fit into the buffer. Copy the initial segment
+ into the buffer, truncating it if necessary. */
+ size_t n = (length < size ? length : size - 1);
+ DCHAR_CPY (buf, result, n);
+ buf[n] = '\0';
+ }
+ free (result);
+ }
+
+ if (length > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+int
+VSPRINTF (DCHAR_T *buf, const FCHAR_T *format, va_list args)
+{
+ /* Pass an infinite length. But note that *vasnprintf may fail if the buffer
+ argument is larger than INT_MAX (if that fits into a 'size_t' at all).
+ Also note that glibc's iconv fails with E2BIG when we pass a length that
+ is so large that buf + length wraps around, i.e.
+ (uintptr_t) (buf + length) < (uintptr_t) buf. */
+ size_t length;
+ DCHAR_T *result;
+
+ /* Set length = min (SIZE_MAX, INT_MAX, - (uintptr_t) buf - 1). */
+ length = (SIZE_MAX < INT_MAX ? SIZE_MAX : INT_MAX);
+ if (length > (~ (uintptr_t) buf) / sizeof (DCHAR_T))
+ length = (~ (uintptr_t) buf) / sizeof (DCHAR_T);
+
+ result = VASNPRINTF (buf, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ /* The infinite buffer size guarantees that the result is not malloc()ed. */
+ if (result != buf)
+ {
+ /* length is near SIZE_MAX. */
+ free (result);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ if (length > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u16_asnprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u16_asprintf
+#define VASPRINTF u16_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u16_printf_parse
+#define CHAR_T uint16_t
+#define DIRECTIVE u16_directive
+#define DIRECTIVES u16_directives
+#include "printf-parse.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u16_snprintf
+#define VSNPRINTF u16_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u16_sprintf
+#define VSPRINTF u16_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u16_u16_asnprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u16_u16_asprintf
+#define VASPRINTF u16_u16_vasprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u16_u16_snprintf
+#define VSNPRINTF u16_u16_vsnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u16_u16_sprintf
+#define VSPRINTF u16_u16_vsprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to UTF-16 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DIRECTIVE u16_directive
+#define DIRECTIVES u16_directives
+#define PRINTF_PARSE u16_printf_parse
+#define DCHAR_T uint16_t
+#define DCHAR_T_IS_UINT16_T 1
+#define DCHAR_CPY u16_cpy
+#define DCHAR_SET u16_set
+#define DCHAR_MBSNLEN u16_mbsnlen
+#define DCHAR_IS_UINT16_T 1
+#define U8_TO_DCHAR u8_to_u16
+#define U32_TO_DCHAR u32_to_u16
+#define DCHAR_CONV_FROM_ENCODING u16_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u16_u16_vasprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u16_u16_vsnprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#define DCHAR_CPY u16_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u16_u16_vsprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to UTF-16 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint16_t
+#define DCHAR_T_IS_UINT16_T 1
+#define DCHAR_CPY u16_cpy
+#define DCHAR_SET u16_set
+#define DCHAR_MBSNLEN u16_mbsnlen
+#define DCHAR_IS_UINT16_T 1
+#define U8_TO_DCHAR u8_to_u16
+#define U32_TO_DCHAR u32_to_u16
+#define DCHAR_CONV_FROM_ENCODING u16_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u16_vasprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u16_vsnprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#define DCHAR_CPY u16_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u16_vsprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u32_asnprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u32_asprintf
+#define VASPRINTF u32_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u32_printf_parse
+#define CHAR_T uint32_t
+#define DIRECTIVE u32_directive
+#define DIRECTIVES u32_directives
+#include "printf-parse.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u32_snprintf
+#define VSNPRINTF u32_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u32_sprintf
+#define VSPRINTF u32_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u32_u32_asnprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u32_u32_asprintf
+#define VASPRINTF u32_u32_vasprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u32_u32_snprintf
+#define VSNPRINTF u32_u32_vsnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u32_u32_sprintf
+#define VSPRINTF u32_u32_vsprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to UTF-32 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DIRECTIVE u32_directive
+#define DIRECTIVES u32_directives
+#define PRINTF_PARSE u32_printf_parse
+#define DCHAR_T uint32_t
+#define DCHAR_T_IS_UINT32_T 1
+#define DCHAR_CPY u32_cpy
+#define DCHAR_SET u32_set
+#define DCHAR_MBSNLEN u32_mbsnlen
+#define DCHAR_IS_UINT32_T 1
+#define U8_TO_DCHAR u8_to_u32
+#define U16_TO_DCHAR u16_to_u32
+#define DCHAR_CONV_FROM_ENCODING u32_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u32_u32_vasprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u32_u32_vsnprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#define DCHAR_CPY u32_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u32_u32_vsprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to UTF-32 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint32_t
+#define DCHAR_T_IS_UINT32_T 1
+#define DCHAR_CPY u32_cpy
+#define DCHAR_SET u32_set
+#define DCHAR_MBSNLEN u32_mbsnlen
+#define DCHAR_IS_UINT32_T 1
+#define U8_TO_DCHAR u8_to_u32
+#define U16_TO_DCHAR u16_to_u32
+#define DCHAR_CONV_FROM_ENCODING u32_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u32_vasprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u32_vsnprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#define DCHAR_CPY u32_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u32_vsprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u8_asnprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u8_asprintf
+#define VASPRINTF u8_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u8_printf_parse
+#define CHAR_T uint8_t
+#define DIRECTIVE u8_directive
+#define DIRECTIVES u8_directives
+#include "printf-parse.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u8_snprintf
+#define VSNPRINTF u8_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u8_sprintf
+#define VSPRINTF u8_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u8_u8_asnprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u8_u8_asprintf
+#define VASPRINTF u8_u8_vasprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u8_u8_snprintf
+#define VSNPRINTF u8_u8_vsnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u8_u8_sprintf
+#define VSPRINTF u8_u8_vsprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to UTF-8 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DIRECTIVE u8_directive
+#define DIRECTIVES u8_directives
+#define PRINTF_PARSE u8_printf_parse
+#define DCHAR_T uint8_t
+#define DCHAR_T_IS_UINT8_T 1
+#define DCHAR_CPY u8_cpy
+#define DCHAR_SET u8_set
+#define DCHAR_MBSNLEN u8_mbsnlen
+#define DCHAR_IS_UINT8_T 1
+#define U16_TO_DCHAR u16_to_u8
+#define U32_TO_DCHAR u32_to_u8
+#define DCHAR_CONV_FROM_ENCODING u8_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u8_u8_vasprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u8_u8_vsnprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#define DCHAR_CPY u8_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u8_u8_vsprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to UTF-8 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint8_t
+#define DCHAR_T_IS_UINT8_T 1
+#define DCHAR_CPY u8_cpy
+#define DCHAR_SET u8_set
+#define DCHAR_MBSNLEN u8_mbsnlen
+#define DCHAR_IS_UINT8_T 1
+#define U16_TO_DCHAR u16_to_u8
+#define U32_TO_DCHAR u32_to_u8
+#define DCHAR_CONV_FROM_ENCODING u8_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u8_vasprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u8_vsnprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#define DCHAR_CPY u8_cpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u8_vsprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-vsprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF ulc_asnprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-asnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF ulc_asprintf
+#define VASPRINTF ulc_vasprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-asprintf.h"
--- /dev/null
+/* Formatted output to a stream.
+ Copyright (C) 2004, 2006-2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fseterr.h"
+
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
+/* Print formatted output to the stream FP.
+ Return string length of formatted string. On error, return a negative
+ value. */
+int
+ulc_fprintf (FILE *fp, const char *format, ...)
+{
+ char buf[2000];
+ char *output;
+ size_t len;
+ size_t lenbuf = sizeof (buf);
+ va_list args;
+
+ va_start (args, format);
+ output = ulc_vasnprintf (buf, &lenbuf, format, args);
+ len = lenbuf;
+ va_end (args);
+
+ if (!output)
+ {
+ fseterr (fp);
+ return -1;
+ }
+
+ if (fwrite (output, 1, len, fp) < len)
+ {
+ if (output != buf)
+ {
+ int saved_errno = errno;
+ free (output);
+ errno = saved_errno;
+ }
+ return -1;
+ }
+
+ if (len > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ fseterr (fp);
+ return -1;
+ }
+
+ return len;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE ulc_printf_parse
+#define CHAR_T char
+#define CHAR_T_ONLY_ASCII 1
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#include "printf-parse.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF ulc_snprintf
+#define VSNPRINTF ulc_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-snprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF ulc_sprintf
+#define VSPRINTF ulc_vsprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-sprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define FCHAR_T_ONLY_ASCII 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T char
+#define DCHAR_CPY memcpy
+#define DCHAR_SET memset
+#define DCHAR_MBSNLEN mbsnlen
+#define TCHAR_T char
+#define DCHAR_IS_TCHAR 1
+#include "vasnprintf.c"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF ulc_vasprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-vasprintf.h"
--- /dev/null
+/* Formatted output to a stream.
+ Copyright (C) 2004, 2006-2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fseterr.h"
+
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
+/* Print formatted output to the stream FP.
+ Return string length of formatted string. On error, return a negative
+ value. */
+int
+ulc_vfprintf (FILE *fp, const char *format, va_list args)
+{
+ char buf[2000];
+ char *output;
+ size_t len;
+ size_t lenbuf = sizeof (buf);
+
+ output = ulc_vasnprintf (buf, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ {
+ fseterr (fp);
+ return -1;
+ }
+
+ if (fwrite (output, 1, len, fp) < len)
+ {
+ if (output != buf)
+ {
+ int saved_errno = errno;
+ free (output);
+ errno = saved_errno;
+ }
+ return -1;
+ }
+
+ if (len > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ fseterr (fp);
+ return -1;
+ }
+
+ return len;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define VSNPRINTF ulc_vsnprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#define DCHAR_CPY memcpy
+#include "u-vsnprintf.h"
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF ulc_vsprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-vsprintf.h"
--- /dev/null
+Description:
+Base layer for formatted output to strings.
+
+Files:
+lib/unistdio.h
+
+Depends-on:
+unitypes
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Fetching a printf argument list.
+
+Files:
+lib/unistdio/u-printf-args.h
+lib/unistdio/u-printf-args.c
+lib/printf-args.h
+lib/printf-args.c
+m4/vasnprintf.m4
+
+Depends-on:
+unitypes
+
+configure.ac:
+gl_PREREQ_PRINTF_ARGS
+
+Makefile.am:
+lib_SOURCES += unistdio/u-printf-args.c
+
+Include:
+"unistdio/u-printf-args.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u16-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u16-asnprintf1.c
+tests/unistdio/test-u16-asnprintf1.h
+tests/unistdio/test-u16-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u16-asnprintf1
+check_PROGRAMS += test-u16-asnprintf1
+test_u16_asnprintf1_SOURCES = unistdio/test-u16-asnprintf1.c
+test_u16_asnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u16-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Parsing an UTF-16 format string.
+
+Files:
+lib/unistdio/u-printf-parse.h
+lib/unistdio/u16-printf-parse.c
+lib/printf-parse.h
+lib/printf-parse.c
+m4/vasnprintf.m4
+
+Depends-on:
+unistdio/u-printf-args
+stdint
+xsize
+
+configure.ac:
+gl_PREREQ_PRINTF_PARSE
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-printf-parse.c
+
+Include:
+"unistdio/u-printf-parse.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-16 string.
+
+Files:
+lib/unistdio/u16-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string.
+
+Files:
+lib/unistdio/u16-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u16-u16-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u16-u16-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-16 string.
+
+Files:
+lib/unistdio/u16-u16-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string.
+
+Files:
+lib/unistdio/u16-u16-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-16 strings.
+
+Files:
+lib/unistdio/u16-u16-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/u16-printf-parse
+unistdio/u-printf-args
+uniconv/u16-conv-from-enc
+unistr/u16-cpy
+unistr/u16-set
+unistr/u16-mbsnlen
+unistr/u8-to-u16
+unistr/u32-to-u16
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u16-u16-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-16 string.
+
+Files:
+lib/unistdio/u16-u16-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vasnprintf
+unistr/u16-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-16 string.
+
+Files:
+lib/unistdio/u16-u16-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-u16-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-u16-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-16 strings.
+
+Files:
+lib/unistdio/u16-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/ulc-printf-parse
+unistdio/u-printf-args
+uniconv/u16-conv-from-enc
+unistr/u16-cpy
+unistr/u16-set
+unistr/u16-mbsnlen
+unistr/u8-to-u16
+unistr/u32-to-u16
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u16-vasnprintf1.c
+tests/unistdio/test-u16-asnprintf1.h
+tests/unistdio/test-u16-printf1.h
+tests/unistdio/test-u16-vasnprintf2.sh
+tests/unistdio/test-u16-vasnprintf2.c
+tests/unistdio/test-u16-vasnprintf3.sh
+tests/unistdio/test-u16-vasnprintf3.c
+m4/locale-fr.m4
+
+Depends-on:
+unistr/u16-cmp
+unistr/u16-cpy
+unistr/u16-strcmp
+unistr/u16-strlen
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+
+Makefile.am:
+TESTS += test-u16-vasnprintf1 unistdio/test-u16-vasnprintf2.sh unistdio/test-u16-vasnprintf3.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-u16-vasnprintf1 test-u16-vasnprintf2 test-u16-vasnprintf3
+test_u16_vasnprintf1_SOURCES = unistdio/test-u16-vasnprintf1.c
+test_u16_vasnprintf1_LDADD = $(LDADD) @LIBICONV@
+test_u16_vasnprintf2_SOURCES = unistdio/test-u16-vasnprintf2.c
+test_u16_vasnprintf2_LDADD = $(LDADD) @LIBICONV@
+test_u16_vasnprintf3_SOURCES = unistdio/test-u16-vasnprintf3.c
+test_u16_vasnprintf3_LDADD = $(LDADD) @LIBICONV@
+EXTRA_DIST += unistdio/test-u16-vasnprintf2.sh unistdio/test-u16-vasnprintf3.sh
--- /dev/null
+Description:
+Formatted output to an UTF-16 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u16-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u16-vasprintf1.c
+tests/unistdio/test-u16-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u16-vasprintf1
+check_PROGRAMS += test-u16-vasprintf1
+test_u16_vasprintf1_SOURCES = unistdio/test-u16-vasprintf1.c
+test_u16_vasprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-16 string.
+
+Files:
+lib/unistdio/u16-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vasnprintf
+unistr/u16-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u16-vsnprintf1.c
+tests/unistdio/test-u16-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u16-vsnprintf1
+check_PROGRAMS += test-u16-vsnprintf1
+test_u16_vsnprintf1_SOURCES = unistdio/test-u16-vsnprintf1.c
+test_u16_vsnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-16 string.
+
+Files:
+lib/unistdio/u16-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u16-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u16-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u16-vsprintf1.c
+tests/unistdio/test-u16-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u16-vsprintf1
+check_PROGRAMS += test-u16-vsprintf1
+test_u16_vsprintf1_SOURCES = unistdio/test-u16-vsprintf1.c
+test_u16_vsprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u32-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u32-asnprintf1.c
+tests/unistdio/test-u32-asnprintf1.h
+tests/unistdio/test-u32-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u32-asnprintf1
+check_PROGRAMS += test-u32-asnprintf1
+test_u32_asnprintf1_SOURCES = unistdio/test-u32-asnprintf1.c
+test_u32_asnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u32-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Parsing an UTF-32 format string.
+
+Files:
+lib/unistdio/u-printf-parse.h
+lib/unistdio/u32-printf-parse.c
+lib/printf-parse.h
+lib/printf-parse.c
+m4/vasnprintf.m4
+
+Depends-on:
+unistdio/u-printf-args
+stdint
+xsize
+
+configure.ac:
+gl_PREREQ_PRINTF_PARSE
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-printf-parse.c
+
+Include:
+"unistdio/u-printf-parse.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-32 string.
+
+Files:
+lib/unistdio/u32-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string.
+
+Files:
+lib/unistdio/u32-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u32-u32-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u32-u32-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-32 string.
+
+Files:
+lib/unistdio/u32-u32-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string.
+
+Files:
+lib/unistdio/u32-u32-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-32 strings.
+
+Files:
+lib/unistdio/u32-u32-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/u32-printf-parse
+unistdio/u-printf-args
+uniconv/u32-conv-from-enc
+unistr/u32-cpy
+unistr/u32-set
+unistr/u32-mbsnlen
+unistr/u8-to-u32
+unistr/u16-to-u32
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u32-u32-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-32 string.
+
+Files:
+lib/unistdio/u32-u32-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vasnprintf
+unistr/u32-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-32 string.
+
+Files:
+lib/unistdio/u32-u32-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-u32-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-u32-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-32 strings.
+
+Files:
+lib/unistdio/u32-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/ulc-printf-parse
+unistdio/u-printf-args
+uniconv/u32-conv-from-enc
+unistr/u32-cpy
+unistr/u32-set
+unistr/u32-mbsnlen
+unistr/u8-to-u32
+unistr/u16-to-u32
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u32-vasnprintf1.c
+tests/unistdio/test-u32-asnprintf1.h
+tests/unistdio/test-u32-printf1.h
+tests/unistdio/test-u32-vasnprintf2.sh
+tests/unistdio/test-u32-vasnprintf2.c
+tests/unistdio/test-u32-vasnprintf3.sh
+tests/unistdio/test-u32-vasnprintf3.c
+m4/locale-fr.m4
+
+Depends-on:
+unistr/u32-cmp
+unistr/u32-cpy
+unistr/u32-strcmp
+unistr/u32-strlen
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+
+Makefile.am:
+TESTS += test-u32-vasnprintf1 unistdio/test-u32-vasnprintf2.sh unistdio/test-u32-vasnprintf3.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-u32-vasnprintf1 test-u32-vasnprintf2 test-u32-vasnprintf3
+test_u32_vasnprintf1_SOURCES = unistdio/test-u32-vasnprintf1.c
+test_u32_vasnprintf1_LDADD = $(LDADD) @LIBICONV@
+test_u32_vasnprintf2_SOURCES = unistdio/test-u32-vasnprintf2.c
+test_u32_vasnprintf2_LDADD = $(LDADD) @LIBICONV@
+test_u32_vasnprintf3_SOURCES = unistdio/test-u32-vasnprintf3.c
+test_u32_vasnprintf3_LDADD = $(LDADD) @LIBICONV@
+EXTRA_DIST += unistdio/test-u32-vasnprintf2.sh unistdio/test-u32-vasnprintf3.sh
--- /dev/null
+Description:
+Formatted output to an UTF-32 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u32-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u32-vasprintf1.c
+tests/unistdio/test-u32-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u32-vasprintf1
+check_PROGRAMS += test-u32-vasprintf1
+test_u32_vasprintf1_SOURCES = unistdio/test-u32-vasprintf1.c
+test_u32_vasprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-32 string.
+
+Files:
+lib/unistdio/u32-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vasnprintf
+unistr/u32-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u32-vsnprintf1.c
+tests/unistdio/test-u32-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u32-vsnprintf1
+check_PROGRAMS += test-u32-vsnprintf1
+test_u32_vsnprintf1_SOURCES = unistdio/test-u32-vsnprintf1.c
+test_u32_vsnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-32 string.
+
+Files:
+lib/unistdio/u32-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u32-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u32-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u32-vsprintf1.c
+tests/unistdio/test-u32-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u32-vsprintf1
+check_PROGRAMS += test-u32-vsprintf1
+test_u32_vsprintf1_SOURCES = unistdio/test-u32-vsprintf1.c
+test_u32_vsprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u8-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u8-asnprintf1.c
+tests/unistdio/test-u8-asnprintf1.h
+tests/unistdio/test-u8-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u8-asnprintf1
+check_PROGRAMS += test-u8-asnprintf1
+test_u8_asnprintf1_SOURCES = unistdio/test-u8-asnprintf1.c
+test_u8_asnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u8-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Parsing an UTF-8 format string.
+
+Files:
+lib/unistdio/u-printf-parse.h
+lib/unistdio/u8-printf-parse.c
+lib/printf-parse.h
+lib/printf-parse.c
+m4/vasnprintf.m4
+
+Depends-on:
+unistdio/u-printf-args
+stdint
+xsize
+
+configure.ac:
+gl_PREREQ_PRINTF_PARSE
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-printf-parse.c
+
+Include:
+"unistdio/u-printf-parse.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-8 string.
+
+Files:
+lib/unistdio/u8-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string.
+
+Files:
+lib/unistdio/u8-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation and
+bounded output size.
+
+Files:
+lib/unistdio/u8-u8-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u8-u8-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-8 string.
+
+Files:
+lib/unistdio/u8-u8-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string.
+
+Files:
+lib/unistdio/u8-u8-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-8 strings.
+
+Files:
+lib/unistdio/u8-u8-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/u8-printf-parse
+unistdio/u-printf-args
+uniconv/u8-conv-from-enc
+unistr/u8-cpy
+unistr/u8-set
+unistr/u8-mbsnlen
+unistr/u16-to-u8
+unistr/u32-to-u8
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u8-u8-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-8 string.
+
+Files:
+lib/unistdio/u8-u8-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vasnprintf
+unistr/u8-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to an UTF-8 string.
+
+Files:
+lib/unistdio/u8-u8-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-u8-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-u8-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to UTF-8 strings.
+
+Files:
+lib/unistdio/u8-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/ulc-printf-parse
+unistdio/u-printf-args
+uniconv/u8-conv-from-enc
+unistr/u8-cpy
+unistr/u8-set
+unistr/u8-mbsnlen
+unistr/u16-to-u8
+unistr/u32-to-u8
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u8-vasnprintf1.c
+tests/unistdio/test-u8-asnprintf1.h
+tests/unistdio/test-u8-printf1.h
+tests/unistdio/test-u8-vasnprintf2.sh
+tests/unistdio/test-u8-vasnprintf2.c
+tests/unistdio/test-u8-vasnprintf3.sh
+tests/unistdio/test-u8-vasnprintf3.c
+m4/locale-fr.m4
+
+Depends-on:
+unistr/u8-cmp
+unistr/u8-cpy
+unistr/u8-strcmp
+unistr/u8-strlen
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+
+Makefile.am:
+TESTS += test-u8-vasnprintf1 unistdio/test-u8-vasnprintf2.sh unistdio/test-u8-vasnprintf3.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-u8-vasnprintf1 test-u8-vasnprintf2 test-u8-vasnprintf3
+test_u8_vasnprintf1_SOURCES = unistdio/test-u8-vasnprintf1.c
+test_u8_vasnprintf1_LDADD = $(LDADD) @LIBICONV@
+test_u8_vasnprintf2_SOURCES = unistdio/test-u8-vasnprintf2.c
+test_u8_vasnprintf2_LDADD = $(LDADD) @LIBICONV@
+test_u8_vasnprintf3_SOURCES = unistdio/test-u8-vasnprintf3.c
+test_u8_vasnprintf3_LDADD = $(LDADD) @LIBICONV@
+EXTRA_DIST += unistdio/test-u8-vasnprintf2.sh unistdio/test-u8-vasnprintf3.sh
--- /dev/null
+Description:
+Formatted output to an UTF-8 string, with automatic memory allocation.
+
+Files:
+lib/unistdio/u8-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u8-vasprintf1.c
+tests/unistdio/test-u8-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u8-vasprintf1
+check_PROGRAMS += test-u8-vasprintf1
+test_u8_vasprintf1_SOURCES = unistdio/test-u8-vasprintf1.c
+test_u8_vasprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a fixed-length UTF-8 string.
+
+Files:
+lib/unistdio/u8-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vasnprintf
+unistr/u8-cpy
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u8-vsnprintf1.c
+tests/unistdio/test-u8-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u8-vsnprintf1
+check_PROGRAMS += test-u8-vsnprintf1
+test_u8_vsnprintf1_SOURCES = unistdio/test-u8-vsnprintf1.c
+test_u8_vsnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to an UTF-8 string.
+
+Files:
+lib/unistdio/u8-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/u8-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/u8-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-u8-vsprintf1.c
+tests/unistdio/test-u8-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-u8-vsprintf1
+check_PROGRAMS += test-u8-vsprintf1
+test_u8_vsprintf1_SOURCES = unistdio/test-u8-vsprintf1.c
+test_u8_vsprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a string, with automatic memory allocation and bounded
+output size.
+
+Files:
+lib/unistdio/ulc-asnprintf.c
+lib/unistdio/u-asnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-asnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-ulc-asnprintf1.c
+tests/unistdio/test-ulc-asnprintf1.h
+tests/unistdio/test-ulc-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-ulc-asnprintf1
+check_PROGRAMS += test-ulc-asnprintf1
+test_ulc_asnprintf1_SOURCES = unistdio/test-ulc-asnprintf1.c
+test_ulc_asnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a string, with automatic memory allocation.
+
+Files:
+lib/unistdio/ulc-asprintf.c
+lib/unistdio/u-asprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-asprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Print formatted output to a stream.
+
+Files:
+lib/unistdio/ulc-fprintf.c
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+fseterr
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-fprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Parsing an ASCII format string.
+
+Files:
+lib/unistdio/u-printf-parse.h
+lib/unistdio/ulc-printf-parse.c
+lib/printf-parse.h
+lib/printf-parse.c
+m4/vasnprintf.m4
+
+Depends-on:
+unistdio/u-printf-args
+stdint
+xsize
+c-ctype
+
+configure.ac:
+gl_PREREQ_PRINTF_PARSE
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-printf-parse.c
+
+Include:
+"unistdio/u-printf-parse.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length string.
+
+Files:
+lib/unistdio/ulc-snprintf.c
+lib/unistdio/u-snprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vsnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-snprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a string.
+
+Files:
+lib/unistdio/ulc-sprintf.c
+lib/unistdio/u-sprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-sprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-sprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to strings.
+
+Files:
+lib/unistdio/ulc-vasnprintf.c
+lib/vasnprintf.c
+m4/vasnprintf.m4
+m4/printf.m4
+m4/wchar_t.m4
+m4/wint_t.m4
+m4/longlong.m4
+m4/intmax_t.m4
+m4/stdint_h.m4
+m4/inttypes_h.m4
+m4/eoverflow.m4
+
+Depends-on:
+unistdio/base
+unistdio/ulc-printf-parse
+unistdio/u-printf-args
+uniconv/u8-conv-to-enc
+uniconv/u16-conv-to-enc
+uniconv/u32-conv-to-enc
+unistr/u8-strlen
+unistr/u8-strmblen
+unistr/u16-strlen
+unistr/u16-strmblen
+unistr/u32-strlen
+unistr/u32-strmblen
+mbsnlen
+isnan-nolibm
+isnanl-nolibm
+frexpl-nolibm
+printf-frexp
+printf-frexpl
+signbit
+fpucw
+printf-safe
+alloca-opt
+localcharset
+xsize
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_EXTRAS
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-vasnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-ulc-vasnprintf1.c
+tests/unistdio/test-ulc-asnprintf1.h
+tests/unistdio/test-ulc-printf1.h
+tests/unistdio/test-ulc-vasnprintf2.sh
+tests/unistdio/test-ulc-vasnprintf2.c
+tests/unistdio/test-ulc-vasnprintf3.sh
+tests/unistdio/test-ulc-vasnprintf3.c
+m4/locale-fr.m4
+
+Depends-on:
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+
+Makefile.am:
+TESTS += test-ulc-vasnprintf1 unistdio/test-ulc-vasnprintf2.sh unistdio/test-ulc-vasnprintf3.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-ulc-vasnprintf1 test-ulc-vasnprintf2 test-ulc-vasnprintf3
+test_ulc_vasnprintf1_SOURCES = unistdio/test-ulc-vasnprintf1.c
+test_ulc_vasnprintf1_LDADD = $(LDADD) @LIBICONV@
+test_ulc_vasnprintf2_SOURCES = unistdio/test-ulc-vasnprintf2.c
+test_ulc_vasnprintf2_LDADD = $(LDADD) @LIBICONV@
+test_ulc_vasnprintf3_SOURCES = unistdio/test-ulc-vasnprintf3.c
+test_ulc_vasnprintf3_LDADD = $(LDADD) @LIBICONV@
+EXTRA_DIST += unistdio/test-ulc-vasnprintf2.sh unistdio/test-ulc-vasnprintf3.sh
--- /dev/null
+Description:
+Formatted output to a string, with automatic memory allocation.
+
+Files:
+lib/unistdio/ulc-vasprintf.c
+lib/unistdio/u-vasprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-vasprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-ulc-vasprintf1.c
+tests/unistdio/test-ulc-printf1.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-ulc-vasprintf1
+check_PROGRAMS += test-ulc-vasprintf1
+test_ulc_vasprintf1_SOURCES = unistdio/test-ulc-vasprintf1.c
+test_ulc_vasprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Print formatted output to a stream.
+
+Files:
+lib/unistdio/ulc-vfprintf.c
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+fseterr
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-vfprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+Formatted output to a fixed-length string.
+
+Files:
+lib/unistdio/ulc-vsnprintf.c
+lib/unistdio/u-vsnprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-vsnprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-ulc-vsnprintf1.c
+tests/unistdio/test-ulc-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-ulc-vsnprintf1
+check_PROGRAMS += test-ulc-vsnprintf1
+test_ulc_vsnprintf1_SOURCES = unistdio/test-ulc-vsnprintf1.c
+test_ulc_vsnprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+Description:
+Formatted output to a string.
+
+Files:
+lib/unistdio/ulc-vsprintf.c
+lib/unistdio/u-vsprintf.h
+
+Depends-on:
+unistdio/base
+unistdio/ulc-vasnprintf
+stdint
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistdio/ulc-vsprintf.c
+
+Include:
+"unistdio.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Files:
+tests/unistdio/test-ulc-vsprintf1.c
+tests/unistdio/test-ulc-printf1.h
+
+Depends-on:
+xalloc
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-ulc-vsprintf1
+check_PROGRAMS += test-ulc-vsprintf1
+test_ulc_vsprintf1_SOURCES = unistdio/test-ulc-vsprintf1.c
+test_ulc_vsprintf1_LDADD = $(LDADD) @LIBICONV@
--- /dev/null
+/* Test of u16_asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u16-asnprintf1.h"
+
+static void
+test_asnprintf ()
+{
+ test_function (u16_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_asnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u16_[v]asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...))
+{
+ uint16_t buf[8];
+ int size;
+
+ /* Test return value convention. */
+
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length = size;
+ uint16_t *result = my_asnprintf (NULL, &length, "%d", 12345);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', '5', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ free (result);
+ }
+
+ for (size = 0; size <= 8; size++)
+ {
+ static const uint16_t initializer[] =
+ { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 };
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', '5', 0 };
+ size_t length;
+ uint16_t *result;
+
+ u16_cpy (buf, initializer, 8);
+ length = size;
+ result = my_asnprintf (buf, &length, "%d", 12345);
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ if (size < 6)
+ ASSERT (result != buf);
+ ASSERT (u16_cmp (buf + size, initializer + size, 8 - size) == 0);
+ if (result != buf)
+ free (result);
+ }
+}
--- /dev/null
+/* Test of u16_v[a]s[n]printf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...))
+{
+ /* Test support of size specifiers as in C99. */
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%ju %d", (uintmax_t) 12345671, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '1', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%zu %d", (size_t) 12345672, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '2', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%tu %d", (ptrdiff_t) 12345673, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%Lg %d", (long double) 1.5, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '.', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Hello";
+ {
+ uint16_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%010U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint16_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint16_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ uint16_t *result =
+ my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd',
+ ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e',
+ 'a', 'g', 'a', 'n', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd',
+ ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e',
+ 'a', 'g', 'a', 'n', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%a %d", 3.1416015625, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1', ' ', '3', '3', 0 };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint16_t expected3[] =
+ { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10a %d", 1.75, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { ' ', ' ', '0', 'x', '1', '.', 'c', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint16_t expected2[] =
+ { ' ', ' ', '0', 'x', '3', '.', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint16_t expected3[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', '7', 'p', '-', '2', ' ', '3', '3', 0 };
+ static const uint16_t expected4[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint16_t *result =
+ my_xasprintf ("%.10a %d", 1.75, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint16_t *result =
+ my_xasprintf ("%.50a %d", 1.75, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1',
+ ' ', '3', '3', 0
+ };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0',
+ ' ', '3', '3', 0
+ };
+ static const uint16_t expected3[] =
+ { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1',
+ ' ', '3', '3', 0
+ };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ',
+ '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10La %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { ' ', ' ', '0', 'x', '1', '.', 'c', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint16_t expected2[] =
+ { ' ', ' ', '0', 'x', '3', '.', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint16_t expected3[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', '7', 'p', '-', '2', ' ', '3', '3', 0 };
+ static const uint16_t expected4[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint16_t *result =
+ my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint16_t *result =
+ my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint16_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0
+ || u16_strcmp (result, expected3) == 0
+ || u16_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%f %d", 12.75, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10f %d", 1.75, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.f %d", 1234.0, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%Lf %d", 12.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10Lf %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.Lf %d", 1234.0L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %F format directive. */
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%F %d", 12.75, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.F %d", 1234.0, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%LF %d", 12.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.LF %d", 1234.0L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%e %d", 12.75, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '1', ' ', '3', '3', 0
+ };
+ static const uint16_t expected2[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '0', '1', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%15e %d", 1.75, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0',
+ '0', 'e', '+', '0', '0', ' ', '3', '3', 0
+ };
+ static const uint16_t expected2[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0',
+ 'e', '+', '0', '0', '0', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.e %d", 1234.0, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ static const uint16_t expected2[] =
+ { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%Le %d", 12.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '1', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0',
+ '0', 'e', '+', '0', '0', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.Le %d", 1234.0L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%g %d", 12.75, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10g %d", 1.75, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', '1', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.g %d", 1234.0, 33, 44, 55);
+ static const uint16_t expected1[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ static const uint16_t expected2[] =
+ { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected1) == 0
+ || u16_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint16_t *result =
+ my_xasprintf ("%Lg %d", 12.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%10Lg %d", 1.75L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', '1', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint16_t *result =
+ my_xasprintf ("%.Lg %d", 1234.0L, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %n format directive. */
+
+ {
+ int count = -1;
+ uint16_t *result =
+ my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+ static const uint16_t expected[] =
+ { '1', '2', '3', ' ', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (count == 4);
+ free (result);
+ }
+
+ /* Test the support of the POSIX/XSI format strings with positions. */
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%2$d %1$d", 33, 55);
+ static const uint16_t expected[] =
+ { '5', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the grouping flag. */
+
+ {
+ uint16_t *result =
+ my_xasprintf ("%'d %d", 1234567, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[u16_strlen (result) - 1] == '9');
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
+ {
+ uint16_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%20U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%020U %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint16_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint16_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint16_t *result =
+ my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint16_t *result =
+ my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint16_t *result =
+ my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test non-ASCII characters in the format string. */
+
+ {
+ uint16_t *result =
+ my_xasprintf ("\304rger", 33, 44, 55);
+ ASSERT (result == NULL && errno == EINVAL);
+ }
+}
--- /dev/null
+/* Test of u16_vasnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u16-asnprintf1.h"
+#include "test-u16-printf1.h"
+
+static uint16_t *
+my_asnprintf (uint16_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint16_t *ret;
+
+ va_start (args, format);
+ ret = u16_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static uint16_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ size_t length;
+ uint16_t *ret;
+
+ va_start (args, format);
+ ret = u16_vasnprintf (NULL, &length, format, args);
+ va_end (args);
+ if (ret != NULL)
+ ASSERT (length == u16_strlen (ret));
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u16_vasnprintf() function in an ISO-8859-1 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\304rger"; /* Ärger */
+ {
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint16_t *
+my_asnprintf (uint16_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint16_t *ret;
+
+ va_start (args, format);
+ ret = u16_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a traditional french locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+ testlocale=$LOCALE_FR
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u16-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u16-vasnprintf2${EXEEXT}
--- /dev/null
+/* Test of u16_vasnprintf() function in an UTF-8 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\303\204rger"; /* Ärger */
+ {
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint16_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint16_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u16_strcmp (result, expected) == 0);
+ ASSERT (length == u16_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint16_t *
+my_asnprintf (uint16_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint16_t *ret;
+
+ va_start (args, format);
+ ret = u16_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a french Unicode locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+ testlocale=$LOCALE_FR_UTF8
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no french Unicode locale is installed"
+ else
+ echo "Skipping test: no french Unicode locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u16-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u16-vasnprintf3${EXEEXT}
--- /dev/null
+/* Test of u16_vasprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u16-printf1.h"
+
+static uint16_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint16_t *result;
+ int retval;
+
+ va_start (args, format);
+ retval = u16_vasprintf (&result, format, args);
+ va_end (args);
+ if (retval < 0)
+ return NULL;
+ ASSERT (result != NULL);
+ return result;
+}
+
+static void
+test_vasprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u16_vsnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u16-printf1.h"
+
+static uint16_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint16_t buf[1000];
+ int retval;
+ size_t length;
+ uint16_t *result;
+
+ va_start (args, format);
+ retval = u16_vsnprintf (buf, sizeof (buf), format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u16_strlen (buf);
+ result = XNMALLOC (length + 1, uint16_t);
+ u16_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsnprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u16_vsprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u16-printf1.h"
+
+static uint16_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint16_t buf[1000];
+ int retval;
+ size_t length;
+ uint16_t *result;
+
+ va_start (args, format);
+ retval = u16_vsprintf (buf, format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u16_strlen (buf);
+ result = XNMALLOC (length + 1, uint16_t);
+ u16_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u32_asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u32-asnprintf1.h"
+
+static void
+test_asnprintf ()
+{
+ test_function (u32_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_asnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u32_[v]asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...))
+{
+ uint32_t buf[8];
+ int size;
+
+ /* Test return value convention. */
+
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length = size;
+ uint32_t *result = my_asnprintf (NULL, &length, "%d", 12345);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', '5', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ free (result);
+ }
+
+ for (size = 0; size <= 8; size++)
+ {
+ static const uint32_t initializer[] =
+ { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 };
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', '5', 0 };
+ size_t length;
+ uint32_t *result;
+
+ u32_cpy (buf, initializer, 8);
+ length = size;
+ result = my_asnprintf (buf, &length, "%d", 12345);
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ if (size < 6)
+ ASSERT (result != buf);
+ ASSERT (u32_cmp (buf + size, initializer + size, 8 - size) == 0);
+ if (result != buf)
+ free (result);
+ }
+}
--- /dev/null
+/* Test of u32_v[a]s[n]printf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...))
+{
+ /* Test support of size specifiers as in C99. */
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%ju %d", (uintmax_t) 12345671, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '1', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%zu %d", (size_t) 12345672, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '2', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%tu %d", (ptrdiff_t) 12345673, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', '5', '6', '7', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%Lg %d", (long double) 1.5, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '.', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Hello";
+ {
+ uint32_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%010U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint32_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint32_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ uint32_t *result =
+ my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd',
+ ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e',
+ 'a', 'g', 'a', 'n', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd',
+ ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e',
+ 'a', 'g', 'a', 'n', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%a %d", 3.1416015625, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1', ' ', '3', '3', 0 };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint32_t expected3[] =
+ { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10a %d", 1.75, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { ' ', ' ', '0', 'x', '1', '.', 'c', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint32_t expected2[] =
+ { ' ', ' ', '0', 'x', '3', '.', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint32_t expected3[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', '7', 'p', '-', '2', ' ', '3', '3', 0 };
+ static const uint32_t expected4[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint32_t *result =
+ my_xasprintf ("%.10a %d", 1.75, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint32_t *result =
+ my_xasprintf ("%.50a %d", 1.75, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1',
+ ' ', '3', '3', 0
+ };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0',
+ ' ', '3', '3', 0
+ };
+ static const uint32_t expected3[] =
+ { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1',
+ ' ', '3', '3', 0
+ };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ',
+ '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10La %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { ' ', ' ', '0', 'x', '1', '.', 'c', 'p', '+', '0', ' ', '3', '3', 0 };
+ static const uint32_t expected2[] =
+ { ' ', ' ', '0', 'x', '3', '.', '8', 'p', '-', '1', ' ', '3', '3', 0 };
+ static const uint32_t expected3[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', '7', 'p', '-', '2', ' ', '3', '3', 0 };
+ static const uint32_t expected4[] =
+ { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint32_t *result =
+ my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint32_t *result =
+ my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected2[] =
+ { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected3[] =
+ { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3',
+ 0
+ };
+ static const uint32_t expected4[] =
+ { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3',
+ 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0
+ || u32_strcmp (result, expected3) == 0
+ || u32_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%f %d", 12.75, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10f %d", 1.75, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.f %d", 1234.0, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%Lf %d", 12.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10Lf %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.Lf %d", 1234.0L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %F format directive. */
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%F %d", 12.75, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.F %d", 1234.0, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%LF %d", 12.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', '0', '0', '0', '0', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.LF %d", 1234.0L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', '4', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%e %d", 12.75, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '1', ' ', '3', '3', 0
+ };
+ static const uint32_t expected2[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '0', '1', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%15e %d", 1.75, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0',
+ '0', 'e', '+', '0', '0', ' ', '3', '3', 0
+ };
+ static const uint32_t expected2[] =
+ { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0',
+ 'e', '+', '0', '0', '0', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.e %d", 1234.0, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ static const uint32_t expected2[] =
+ { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%Le %d", 12.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+',
+ '0', '1', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0',
+ '0', 'e', '+', '0', '0', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.Le %d", 1234.0L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%g %d", 12.75, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10g %d", 1.75, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', '1', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.g %d", 1234.0, 33, 44, 55);
+ static const uint32_t expected1[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ static const uint32_t expected2[] =
+ { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected1) == 0
+ || u32_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint32_t *result =
+ my_xasprintf ("%Lg %d", 12.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%10Lg %d", 1.75L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', ' ', '1', '.', '7', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint32_t *result =
+ my_xasprintf ("%.Lg %d", 1234.0L, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', 'e', '+', '0', '3', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %n format directive. */
+
+ {
+ int count = -1;
+ uint32_t *result =
+ my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+ static const uint32_t expected[] =
+ { '1', '2', '3', ' ', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (count == 4);
+ free (result);
+ }
+
+ /* Test the support of the POSIX/XSI format strings with positions. */
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%2$d %1$d", 33, 55);
+ static const uint32_t expected[] =
+ { '5', '5', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the grouping flag. */
+
+ {
+ uint32_t *result =
+ my_xasprintf ("%'d %d", 1234567, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[u32_strlen (result) - 1] == '9');
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
+ {
+ uint32_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%20U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%020U %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint32_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint32_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint32_t *result =
+ my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint32_t *result =
+ my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z',
+ 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint32_t *result =
+ my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ',
+ 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test non-ASCII characters in the format string. */
+
+ {
+ uint32_t *result =
+ my_xasprintf ("\304rger", 33, 44, 55);
+ ASSERT (result == NULL && errno == EINVAL);
+ }
+}
--- /dev/null
+/* Test of u32_vasnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u32-asnprintf1.h"
+#include "test-u32-printf1.h"
+
+static uint32_t *
+my_asnprintf (uint32_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint32_t *ret;
+
+ va_start (args, format);
+ ret = u32_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static uint32_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ size_t length;
+ uint32_t *ret;
+
+ va_start (args, format);
+ ret = u32_vasnprintf (NULL, &length, format, args);
+ va_end (args);
+ if (ret != NULL)
+ ASSERT (length == u32_strlen (ret));
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u32_vasnprintf() function in an ISO-8859-1 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\304rger"; /* Ärger */
+ {
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint32_t *
+my_asnprintf (uint32_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint32_t *ret;
+
+ va_start (args, format);
+ ret = u32_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a traditional french locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+ testlocale=$LOCALE_FR
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u32-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u32-vasnprintf2${EXEEXT}
--- /dev/null
+/* Test of u32_vasnprintf() function in an UTF-8 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\303\204rger"; /* Ärger */
+ {
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint32_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint32_t expected[] =
+ { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r',
+ ' ', '3', '3', 0
+ };
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ ASSERT (length == u32_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint32_t *
+my_asnprintf (uint32_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint32_t *ret;
+
+ va_start (args, format);
+ ret = u32_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a french Unicode locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+ testlocale=$LOCALE_FR_UTF8
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no french Unicode locale is installed"
+ else
+ echo "Skipping test: no french Unicode locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u32-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u32-vasnprintf3${EXEEXT}
--- /dev/null
+/* Test of u32_vasprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u32-printf1.h"
+
+static uint32_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint32_t *result;
+ int retval;
+
+ va_start (args, format);
+ retval = u32_vasprintf (&result, format, args);
+ va_end (args);
+ if (retval < 0)
+ return NULL;
+ ASSERT (result != NULL);
+ return result;
+}
+
+static void
+test_vasprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u32_vsnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u32-printf1.h"
+
+static uint32_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint32_t buf[1000];
+ int retval;
+ size_t length;
+ uint32_t *result;
+
+ va_start (args, format);
+ retval = u32_vsnprintf (buf, sizeof (buf), format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u32_strlen (buf);
+ result = XNMALLOC (length + 1, uint32_t);
+ u32_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsnprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u32_vsprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u32-printf1.h"
+
+static uint32_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint32_t buf[1000];
+ int retval;
+ size_t length;
+ uint32_t *result;
+
+ va_start (args, format);
+ retval = u32_vsprintf (buf, format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u32_strlen (buf);
+ result = XNMALLOC (length + 1, uint32_t);
+ u32_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u8_asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u8-asnprintf1.h"
+
+static void
+test_asnprintf ()
+{
+ test_function (u8_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_asnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u8_[v]asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...))
+{
+ uint8_t buf[8];
+ int size;
+
+ /* Test return value convention. */
+
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length = size;
+ uint8_t *result = my_asnprintf (NULL, &length, "%d", 12345);
+ static const uint8_t expected[] = "12345";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ free (result);
+ }
+
+ for (size = 0; size <= 8; size++)
+ {
+ static const uint8_t initializer[] = "DEADBEEF";
+ static const uint8_t expected[] = "12345";
+ size_t length;
+ uint8_t *result;
+
+ u8_cpy (buf, initializer, 8);
+ length = size;
+ result = my_asnprintf (buf, &length, "%d", 12345);
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == 5);
+ if (size < 6)
+ ASSERT (result != buf);
+ ASSERT (u8_cmp (buf + size, initializer + size, 8 - size) == 0);
+ if (result != buf)
+ free (result);
+ }
+}
--- /dev/null
+/* Test of u8_v[a]s[n]printf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...))
+{
+ /* Test support of size specifiers as in C99. */
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%ju %d", (uintmax_t) 12345671, 33, 44, 55);
+ static const uint8_t expected[] = "12345671 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%zu %d", (size_t) 12345672, 33, 44, 55);
+ static const uint8_t expected[] = "12345672 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%tu %d", (ptrdiff_t) 12345673, 33, 44, 55);
+ static const uint8_t expected[] = "12345673 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%Lg %d", (long double) 1.5, 33, 44, 55);
+ static const uint8_t expected[] = "1.5 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Hello";
+ {
+ uint8_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%010U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint8_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ uint8_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Hello 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ uint8_t *result =
+ my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint8_t expected[] = "Mr. Ronald Reagan 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint8_t expected[] = "Mr. Ronald Reagan 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint8_t expected[] = "Mr. Ronald Reagan 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55);
+ static const uint8_t expected[] = "Mr. Ronald Reagan 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%a %d", 3.1416015625, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.922p+1 33";
+ static const uint8_t expected2[] = "0x3.244p+0 33";
+ static const uint8_t expected3[] = "0x6.488p-1 33";
+ static const uint8_t expected4[] = "0xc.91p-2 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10a %d", 1.75, 33, 44, 55);
+ static const uint8_t expected1[] = " 0x1.cp+0 33";
+ static const uint8_t expected2[] = " 0x3.8p-1 33";
+ static const uint8_t expected3[] = " 0x7p-2 33";
+ static const uint8_t expected4[] = " 0xep-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint8_t *result =
+ my_xasprintf ("%.10a %d", 1.75, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.c000000000p+0 33";
+ static const uint8_t expected2[] = "0x3.8000000000p-1 33";
+ static const uint8_t expected3[] = "0x7.0000000000p-2 33";
+ static const uint8_t expected4[] = "0xe.0000000000p-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint8_t *result =
+ my_xasprintf ("%.50a %d", 1.75, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.c0000000000000000000000000000000000000000000000000p+0 33";
+ static const uint8_t expected2[] = "0x3.80000000000000000000000000000000000000000000000000p-1 33";
+ static const uint8_t expected3[] = "0x7.00000000000000000000000000000000000000000000000000p-2 33";
+ static const uint8_t expected4[] = "0xe.00000000000000000000000000000000000000000000000000p-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.922p+1 33";
+ static const uint8_t expected2[] = "0x3.244p+0 33";
+ static const uint8_t expected3[] = "0x6.488p-1 33";
+ static const uint8_t expected4[] = "0xc.91p-2 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10La %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected1[] = " 0x1.cp+0 33";
+ static const uint8_t expected2[] = " 0x3.8p-1 33";
+ static const uint8_t expected3[] = " 0x7p-2 33";
+ static const uint8_t expected4[] = " 0xep-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ uint8_t *result =
+ my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.c000000000p+0 33";
+ static const uint8_t expected2[] = "0x3.8000000000p-1 33";
+ static const uint8_t expected3[] = "0x7.0000000000p-2 33";
+ static const uint8_t expected4[] = "0xe.0000000000p-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ uint8_t *result =
+ my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected1[] = "0x1.c0000000000000000000000000000000000000000000000000p+0 33";
+ static const uint8_t expected2[] = "0x3.80000000000000000000000000000000000000000000000000p-1 33";
+ static const uint8_t expected3[] = "0x7.00000000000000000000000000000000000000000000000000p-2 33";
+ static const uint8_t expected4[] = "0xe.00000000000000000000000000000000000000000000000000p-3 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0
+ || u8_strcmp (result, expected3) == 0
+ || u8_strcmp (result, expected4) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%f %d", 12.75, 33, 44, 55);
+ static const uint8_t expected[] = "12.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10f %d", 1.75, 33, 44, 55);
+ static const uint8_t expected[] = " 1.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.f %d", 1234.0, 33, 44, 55);
+ static const uint8_t expected[] = "1234 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%Lf %d", 12.75L, 33, 44, 55);
+ static const uint8_t expected[] = "12.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10Lf %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected[] = " 1.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.Lf %d", 1234.0L, 33, 44, 55);
+ static const uint8_t expected[] = "1234 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %F format directive. */
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%F %d", 12.75, 33, 44, 55);
+ static const uint8_t expected[] = "12.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.F %d", 1234.0, 33, 44, 55);
+ static const uint8_t expected[] = "1234 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%LF %d", 12.75L, 33, 44, 55);
+ static const uint8_t expected[] = "12.750000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.LF %d", 1234.0L, 33, 44, 55);
+ static const uint8_t expected[] = "1234 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%e %d", 12.75, 33, 44, 55);
+ static const uint8_t expected1[] = "1.275000e+01 33";
+ static const uint8_t expected2[] = "1.275000e+001 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%15e %d", 1.75, 33, 44, 55);
+ static const uint8_t expected1[] = " 1.750000e+00 33";
+ static const uint8_t expected2[] = " 1.750000e+000 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.e %d", 1234.0, 33, 44, 55);
+ static const uint8_t expected1[] = "1e+03 33";
+ static const uint8_t expected2[] = "1e+003 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%Le %d", 12.75L, 33, 44, 55);
+ static const uint8_t expected[] = "1.275000e+01 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected[] = " 1.750000e+00 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.Le %d", 1234.0L, 33, 44, 55);
+ static const uint8_t expected[] = "1e+03 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%g %d", 12.75, 33, 44, 55);
+ static const uint8_t expected[] = "12.75 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10g %d", 1.75, 33, 44, 55);
+ static const uint8_t expected[] = " 1.75 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.g %d", 1234.0, 33, 44, 55);
+ static const uint8_t expected1[] = "1e+03 33";
+ static const uint8_t expected2[] = "1e+003 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected1) == 0
+ || u8_strcmp (result, expected2) == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ uint8_t *result =
+ my_xasprintf ("%Lg %d", 12.75L, 33, 44, 55);
+ static const uint8_t expected[] = "12.75 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%10Lg %d", 1.75L, 33, 44, 55);
+ static const uint8_t expected[] = " 1.75 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ uint8_t *result =
+ my_xasprintf ("%.Lg %d", 1234.0L, 33, 44, 55);
+ static const uint8_t expected[] = "1e+03 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the %n format directive. */
+
+ {
+ int count = -1;
+ uint8_t *result =
+ my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+ static const uint8_t expected[] = "123 ";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (count == 4);
+ free (result);
+ }
+
+ /* Test the support of the POSIX/XSI format strings with positions. */
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%2$d %1$d", 33, 55);
+ static const uint8_t expected[] = "55 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+
+ /* Test the support of the grouping flag. */
+
+ {
+ uint8_t *result =
+ my_xasprintf ("%'d %d", 1234567, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[u8_strlen (result) - 1] == '9');
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
+ {
+ uint8_t *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%20U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%020U %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint8_t *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ uint8_t *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* Width. */
+ uint8_t *result =
+ my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ uint8_t *result =
+ my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ uint8_t *result =
+ my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55);
+ static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ }
+
+ /* Test non-ASCII characters in the format string. */
+
+ {
+ uint8_t *result =
+ my_xasprintf ("\304rger", 33, 44, 55);
+ ASSERT (result == NULL && errno == EINVAL);
+ }
+}
--- /dev/null
+/* Test of u8_vasnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u8-asnprintf1.h"
+#include "test-u8-printf1.h"
+
+static uint8_t *
+my_asnprintf (uint8_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint8_t *ret;
+
+ va_start (args, format);
+ ret = u8_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static uint8_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ size_t length;
+ uint8_t *ret;
+
+ va_start (args, format);
+ ret = u8_vasnprintf (NULL, &length, format, args);
+ va_end (args);
+ if (ret != NULL)
+ ASSERT (length == u8_strlen (ret));
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u8_vasnprintf() function in an ISO-8859-1 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\304rger"; /* Ärger */
+ {
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = "\303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = " \303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = "\303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = " \303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint8_t *
+my_asnprintf (uint8_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint8_t *ret;
+
+ va_start (args, format);
+ ret = u8_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a traditional french locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+ testlocale=$LOCALE_FR
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u8-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u8-vasnprintf2${EXEEXT}
--- /dev/null
+/* Test of u8_vasnprintf() function in an UTF-8 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...))
+{
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\303\204rger"; /* Ärger */
+ {
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = "\303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = " \303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = "\303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ uint8_t *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ static const uint8_t expected[] = " \303\204rger 33";
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ ASSERT (length == u8_strlen (result));
+ free (result);
+ }
+ }
+}
+
+static uint8_t *
+my_asnprintf (uint8_t *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ uint8_t *ret;
+
+ va_start (args, format);
+ ret = u8_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a french Unicode locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+ testlocale=$LOCALE_FR_UTF8
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no french Unicode locale is installed"
+ else
+ echo "Skipping test: no french Unicode locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-u8-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-u8-vasnprintf3${EXEEXT}
--- /dev/null
+/* Test of u8_vasprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u8-printf1.h"
+
+static uint8_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint8_t *result;
+ int retval;
+
+ va_start (args, format);
+ retval = u8_vasprintf (&result, format, args);
+ va_end (args);
+ if (retval < 0)
+ return NULL;
+ ASSERT (result != NULL);
+ return result;
+}
+
+static void
+test_vasprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u8_vsnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u8-printf1.h"
+
+static uint8_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint8_t buf[1000];
+ int retval;
+ size_t length;
+ uint8_t *result;
+
+ va_start (args, format);
+ retval = u8_vsnprintf (buf, sizeof (buf), format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u8_strlen (buf);
+ result = XNMALLOC (length + 1, uint8_t);
+ u8_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsnprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of u8_vsprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unistr.h"
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-u8-printf1.h"
+
+static uint8_t *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ uint8_t buf[1000];
+ int retval;
+ size_t length;
+ uint8_t *result;
+
+ va_start (args, format);
+ retval = u8_vsprintf (buf, format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (buf))
+ return NULL;
+ length = u8_strlen (buf);
+ result = XNMALLOC (length + 1, uint8_t);
+ u8_cpy (result, buf, length + 1);
+ return result;
+}
+
+static void
+test_vsprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of ulc_asnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-ulc-asnprintf1.h"
+
+static void
+test_asnprintf ()
+{
+ test_function (ulc_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_asnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of ulc_[v]asnprintf() functions.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
+{
+ char buf[8];
+ int size;
+
+ /* Test return value convention. */
+
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length = size;
+ char *result = my_asnprintf (NULL, &length, "%d", 12345);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12345") == 0);
+ ASSERT (length == 5);
+ free (result);
+ }
+
+ for (size = 0; size <= 8; size++)
+ {
+ size_t length;
+ char *result;
+
+ memcpy (buf, "DEADBEEF", 8);
+ length = size;
+ result = my_asnprintf (buf, &length, "%d", 12345);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12345") == 0);
+ ASSERT (length == 5);
+ if (size < 6)
+ ASSERT (result != buf);
+ ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ if (result != buf)
+ free (result);
+ }
+}
--- /dev/null
+/* Test of ulc_v[a]s[n]printf() functions.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+static void
+test_xfunction (char * (*my_xasprintf) (const char *, ...))
+{
+ /* Test support of size specifiers as in C99. */
+
+ {
+ char *result =
+ my_xasprintf ("%ju %d", (uintmax_t) 12345671, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12345671 33") == 0);
+ free (result);
+ }
+
+ {
+ char *result =
+ my_xasprintf ("%zu %d", (size_t) 12345672, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12345672 33") == 0);
+ free (result);
+ }
+
+ {
+ char *result =
+ my_xasprintf ("%tu %d", (ptrdiff_t) 12345673, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12345673 33") == 0);
+ free (result);
+ }
+
+ {
+ char *result =
+ my_xasprintf ("%Lg %d", (long double) 1.5, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1.5 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Hello";
+ {
+ char *result =
+ my_xasprintf ("%U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ char *result =
+ my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ char *result =
+ my_xasprintf ("%010U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ char *result =
+ my_xasprintf ("%lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ char *result =
+ my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ char *result =
+ my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 };
+ {
+ char *result =
+ my_xasprintf ("%llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ char *result =
+ my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Hello 33") == 0);
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ char *result =
+ my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Hello 33") == 0);
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ char *result =
+ my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Mr. Ronald Reagan 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Mr. Ronald Reagan 33") == 0);
+ free (result);
+ }
+
+ { /* FLAG_LEFT. */
+ char *result =
+ my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Mr. Ronald Reagan 33") == 0);
+ free (result);
+ }
+
+ { /* FLAG_ZERO: no effect. */
+ char *result =
+ my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Mr. Ronald Reagan 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%a %d", 3.1416015625, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.922p+1 33") == 0
+ || strcmp (result, "0x3.244p+0 33") == 0
+ || strcmp (result, "0x6.488p-1 33") == 0
+ || strcmp (result, "0xc.91p-2 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10a %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 0x1.cp+0 33") == 0
+ || strcmp (result, " 0x3.8p-1 33") == 0
+ || strcmp (result, " 0x7p-2 33") == 0
+ || strcmp (result, " 0xep-3 33") == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ char *result =
+ my_xasprintf ("%.10a %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0
+ || strcmp (result, "0x3.8000000000p-1 33") == 0
+ || strcmp (result, "0x7.0000000000p-2 33") == 0
+ || strcmp (result, "0xe.0000000000p-3 33") == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ char *result =
+ my_xasprintf ("%.50a %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0
+ || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0
+ || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0
+ || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.922p+1 33") == 0
+ || strcmp (result, "0x3.244p+0 33") == 0
+ || strcmp (result, "0x6.488p-1 33") == 0
+ || strcmp (result, "0xc.91p-2 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10La %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 0x1.cp+0 33") == 0
+ || strcmp (result, " 0x3.8p-1 33") == 0
+ || strcmp (result, " 0x7p-2 33") == 0
+ || strcmp (result, " 0xep-3 33") == 0);
+ free (result);
+ }
+
+ { /* Small precision. */
+ char *result =
+ my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0
+ || strcmp (result, "0x3.8000000000p-1 33") == 0
+ || strcmp (result, "0x7.0000000000p-2 33") == 0
+ || strcmp (result, "0xe.0000000000p-3 33") == 0);
+ free (result);
+ }
+
+ { /* Large precision. */
+ char *result =
+ my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0
+ || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0
+ || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0
+ || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%f %d", 12.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10f %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.f %d", 1234.0, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1234 33") == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%Lf %d", 12.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10Lf %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.Lf %d", 1234.0L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1234 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the %F format directive. */
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%F %d", 12.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.F %d", 1234.0, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1234 33") == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%LF %d", 12.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.750000 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.LF %d", 1234.0L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1234 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%e %d", 12.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1.275000e+01 33") == 0
+ || strcmp (result, "1.275000e+001 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%15e %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.750000e+00 33") == 0
+ || strcmp (result, " 1.750000e+000 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.e %d", 1234.0, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1e+03 33") == 0
+ || strcmp (result, "1e+003 33") == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%Le %d", 12.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1.275000e+01 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.750000e+00 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.Le %d", 1234.0L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1e+03 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%g %d", 12.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.75 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10g %d", 1.75, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.75 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.g %d", 1234.0, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1e+03 33") == 0
+ || strcmp (result, "1e+003 33") == 0);
+ free (result);
+ }
+
+ { /* A positive number. */
+ char *result =
+ my_xasprintf ("%Lg %d", 12.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "12.75 33") == 0);
+ free (result);
+ }
+
+ { /* Width. */
+ char *result =
+ my_xasprintf ("%10Lg %d", 1.75L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " 1.75 33") == 0);
+ free (result);
+ }
+
+ { /* Precision. */
+ char *result =
+ my_xasprintf ("%.Lg %d", 1234.0L, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "1e+03 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the %n format directive. */
+
+ {
+ int count = -1;
+ char *result =
+ my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "123 ") == 0);
+ ASSERT (count == 4);
+ free (result);
+ }
+
+ /* Test the support of the POSIX/XSI format strings with positions. */
+
+ {
+ char *result =
+ my_xasprintf ("%2$d %1$d", 33, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "55 33") == 0);
+ free (result);
+ }
+
+ /* Test the support of the grouping flag. */
+
+ {
+ char *result =
+ my_xasprintf ("%'d %d", 1234567, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[strlen (result) - 1] == '9');
+ free (result);
+ }
+}
--- /dev/null
+/* Test of ulc_vasnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-ulc-asnprintf1.h"
+#include "test-ulc-printf1.h"
+
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ char *ret;
+
+ va_start (args, format);
+ ret = ulc_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static char *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ size_t length;
+ char *ret;
+
+ va_start (args, format);
+ ret = ulc_vasnprintf (NULL, &length, format, args);
+ va_end (args);
+ if (ret != NULL)
+ ASSERT (length == strlen (ret));
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of ulc_vasnprintf() function in an ISO-8859-1 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
+{
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0
+ || strcmp (result, "Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0
+ || strcmp (result, " Rafal Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\304rger"; /* Ärger */
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "\304rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \304rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "\304rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \304rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+}
+
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ char *ret;
+
+ va_start (args, format);
+ ret = ulc_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a traditional french locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+ testlocale=$LOCALE_FR
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-ulc-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-ulc-vasnprintf2${EXEEXT}
--- /dev/null
+/* Test of ulc_vasnprintf() function in an UTF-8 locale.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <locale.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+static void
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
+{
+ /* Test the support of the 'U' conversion specifier for Unicode strings. */
+
+ {
+ static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ {
+ static const uint16_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ {
+ static const uint32_t unicode_string[] = /* Rafał Maszkowski */
+ {
+ 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
+ 's', 'k', 'i', 0
+ };
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+
+ /* Test the support of the 's' conversion specifier for strings. */
+
+ {
+ const char *locale_string = "\303\204rger"; /* Ärger */
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "\303\204rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* Width. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \303\204rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_LEFT. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "\303\204rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ { /* FLAG_ZERO: no effect. */
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " \303\204rger 33") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+ }
+}
+
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+ va_list args;
+ char *ret;
+
+ va_start (args, format);
+ ret = ulc_vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_vasnprintf ();
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Test whether a french Unicode locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+ testlocale=$LOCALE_FR_UTF8
+else
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no french Unicode locale is installed"
+ else
+ echo "Skipping test: no french Unicode locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$testlocale \
+./test-ulc-vasnprintf1${EXEEXT} \
+ || exit 1
+
+LC_ALL=$testlocale \
+./test-ulc-vasnprintf3${EXEEXT}
--- /dev/null
+/* Test of ulc_vasprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-ulc-printf1.h"
+
+static char *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ char *result;
+ int retval;
+
+ va_start (args, format);
+ retval = ulc_vasprintf (&result, format, args);
+ va_end (args);
+ if (retval < 0)
+ return NULL;
+ ASSERT (result != NULL);
+ return result;
+}
+
+static void
+test_vasprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vasprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of ulc_vsnprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-ulc-printf1.h"
+
+static char *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ char result[1000];
+ int retval;
+
+ va_start (args, format);
+ retval = ulc_vsnprintf (result, sizeof (result), format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (result))
+ return NULL;
+ return xstrdup (result);
+}
+
+static void
+test_vsnprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsnprintf ();
+ return 0;
+}
--- /dev/null
+/* Test of ulc_vsprintf() function.
+ Copyright (C) 2007 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "unistdio.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "xalloc.h"
+
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+#include "test-ulc-printf1.h"
+
+static char *
+my_xasprintf (const char *format, ...)
+{
+ va_list args;
+ char result[1000];
+ int retval;
+
+ va_start (args, format);
+ retval = ulc_vsprintf (result, format, args);
+ va_end (args);
+ if (retval < 0 || retval >= (int) sizeof (result))
+ return NULL;
+ return xstrdup (result);
+}
+
+static void
+test_vsprintf ()
+{
+ test_xfunction (my_xasprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vsprintf ();
+ return 0;
+}