From fa095a4504cbe668e4244547e2c141597bea4ecf Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Mon, 14 Sep 2009 12:32:44 +0200 Subject: Imported Upstream version 0.9.1 --- lib/unistdio/u-asnprintf.h | 27 ++++++++++++++ lib/unistdio/u-asprintf.h | 27 ++++++++++++++ lib/unistdio/u-printf-args.c | 22 ++++++++++++ lib/unistdio/u-printf-args.h | 27 ++++++++++++++ lib/unistdio/u-printf-parse.h | 27 ++++++++++++++ lib/unistdio/u-snprintf.h | 27 ++++++++++++++ lib/unistdio/u-sprintf.h | 27 ++++++++++++++ lib/unistdio/u-vasprintf.h | 35 ++++++++++++++++++ lib/unistdio/u-vsnprintf.h | 52 +++++++++++++++++++++++++++ lib/unistdio/u-vsprintf.h | 58 ++++++++++++++++++++++++++++++ lib/unistdio/u16-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u16-asprintf.c | 28 +++++++++++++++ lib/unistdio/u16-printf-parse.c | 26 ++++++++++++++ lib/unistdio/u16-snprintf.c | 28 +++++++++++++++ lib/unistdio/u16-sprintf.c | 28 +++++++++++++++ lib/unistdio/u16-u16-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u16-u16-asprintf.c | 28 +++++++++++++++ lib/unistdio/u16-u16-snprintf.c | 28 +++++++++++++++ lib/unistdio/u16-u16-sprintf.c | 28 +++++++++++++++ lib/unistdio/u16-u16-vasnprintf.c | 49 ++++++++++++++++++++++++++ lib/unistdio/u16-u16-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u16-u16-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u16-u16-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/u16-vasnprintf.c | 50 ++++++++++++++++++++++++++ lib/unistdio/u16-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u16-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u16-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/u32-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u32-asprintf.c | 28 +++++++++++++++ lib/unistdio/u32-printf-parse.c | 26 ++++++++++++++ lib/unistdio/u32-snprintf.c | 28 +++++++++++++++ lib/unistdio/u32-sprintf.c | 28 +++++++++++++++ lib/unistdio/u32-u32-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u32-u32-asprintf.c | 28 +++++++++++++++ lib/unistdio/u32-u32-snprintf.c | 28 +++++++++++++++ lib/unistdio/u32-u32-sprintf.c | 28 +++++++++++++++ lib/unistdio/u32-u32-vasnprintf.c | 49 ++++++++++++++++++++++++++ lib/unistdio/u32-u32-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u32-u32-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u32-u32-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/u32-vasnprintf.c | 50 ++++++++++++++++++++++++++ lib/unistdio/u32-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u32-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u32-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/u8-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u8-asprintf.c | 28 +++++++++++++++ lib/unistdio/u8-printf-parse.c | 26 ++++++++++++++ lib/unistdio/u8-snprintf.c | 28 +++++++++++++++ lib/unistdio/u8-sprintf.c | 28 +++++++++++++++ lib/unistdio/u8-u8-asnprintf.c | 28 +++++++++++++++ lib/unistdio/u8-u8-asprintf.c | 28 +++++++++++++++ lib/unistdio/u8-u8-snprintf.c | 28 +++++++++++++++ lib/unistdio/u8-u8-sprintf.c | 28 +++++++++++++++ lib/unistdio/u8-u8-vasnprintf.c | 49 ++++++++++++++++++++++++++ lib/unistdio/u8-u8-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u8-u8-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u8-u8-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/u8-vasnprintf.c | 50 ++++++++++++++++++++++++++ lib/unistdio/u8-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/u8-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/u8-vsprintf.c | 32 +++++++++++++++++ lib/unistdio/ulc-asnprintf.c | 28 +++++++++++++++ lib/unistdio/ulc-asprintf.c | 28 +++++++++++++++ lib/unistdio/ulc-fprintf.c | 74 +++++++++++++++++++++++++++++++++++++++ lib/unistdio/ulc-printf-parse.c | 27 ++++++++++++++ lib/unistdio/ulc-snprintf.c | 28 +++++++++++++++ lib/unistdio/ulc-sprintf.c | 28 +++++++++++++++ lib/unistdio/ulc-vasnprintf.c | 46 ++++++++++++++++++++++++ lib/unistdio/ulc-vasprintf.c | 30 ++++++++++++++++ lib/unistdio/ulc-vfprintf.c | 71 +++++++++++++++++++++++++++++++++++++ lib/unistdio/ulc-vsnprintf.c | 33 +++++++++++++++++ lib/unistdio/ulc-vsprintf.c | 32 +++++++++++++++++ 72 files changed, 2371 insertions(+) create mode 100644 lib/unistdio/u-asnprintf.h create mode 100644 lib/unistdio/u-asprintf.h create mode 100644 lib/unistdio/u-printf-args.c create mode 100644 lib/unistdio/u-printf-args.h create mode 100644 lib/unistdio/u-printf-parse.h create mode 100644 lib/unistdio/u-snprintf.h create mode 100644 lib/unistdio/u-sprintf.h create mode 100644 lib/unistdio/u-vasprintf.h create mode 100644 lib/unistdio/u-vsnprintf.h create mode 100644 lib/unistdio/u-vsprintf.h create mode 100644 lib/unistdio/u16-asnprintf.c create mode 100644 lib/unistdio/u16-asprintf.c create mode 100644 lib/unistdio/u16-printf-parse.c create mode 100644 lib/unistdio/u16-snprintf.c create mode 100644 lib/unistdio/u16-sprintf.c create mode 100644 lib/unistdio/u16-u16-asnprintf.c create mode 100644 lib/unistdio/u16-u16-asprintf.c create mode 100644 lib/unistdio/u16-u16-snprintf.c create mode 100644 lib/unistdio/u16-u16-sprintf.c create mode 100644 lib/unistdio/u16-u16-vasnprintf.c create mode 100644 lib/unistdio/u16-u16-vasprintf.c create mode 100644 lib/unistdio/u16-u16-vsnprintf.c create mode 100644 lib/unistdio/u16-u16-vsprintf.c create mode 100644 lib/unistdio/u16-vasnprintf.c create mode 100644 lib/unistdio/u16-vasprintf.c create mode 100644 lib/unistdio/u16-vsnprintf.c create mode 100644 lib/unistdio/u16-vsprintf.c create mode 100644 lib/unistdio/u32-asnprintf.c create mode 100644 lib/unistdio/u32-asprintf.c create mode 100644 lib/unistdio/u32-printf-parse.c create mode 100644 lib/unistdio/u32-snprintf.c create mode 100644 lib/unistdio/u32-sprintf.c create mode 100644 lib/unistdio/u32-u32-asnprintf.c create mode 100644 lib/unistdio/u32-u32-asprintf.c create mode 100644 lib/unistdio/u32-u32-snprintf.c create mode 100644 lib/unistdio/u32-u32-sprintf.c create mode 100644 lib/unistdio/u32-u32-vasnprintf.c create mode 100644 lib/unistdio/u32-u32-vasprintf.c create mode 100644 lib/unistdio/u32-u32-vsnprintf.c create mode 100644 lib/unistdio/u32-u32-vsprintf.c create mode 100644 lib/unistdio/u32-vasnprintf.c create mode 100644 lib/unistdio/u32-vasprintf.c create mode 100644 lib/unistdio/u32-vsnprintf.c create mode 100644 lib/unistdio/u32-vsprintf.c create mode 100644 lib/unistdio/u8-asnprintf.c create mode 100644 lib/unistdio/u8-asprintf.c create mode 100644 lib/unistdio/u8-printf-parse.c create mode 100644 lib/unistdio/u8-snprintf.c create mode 100644 lib/unistdio/u8-sprintf.c create mode 100644 lib/unistdio/u8-u8-asnprintf.c create mode 100644 lib/unistdio/u8-u8-asprintf.c create mode 100644 lib/unistdio/u8-u8-snprintf.c create mode 100644 lib/unistdio/u8-u8-sprintf.c create mode 100644 lib/unistdio/u8-u8-vasnprintf.c create mode 100644 lib/unistdio/u8-u8-vasprintf.c create mode 100644 lib/unistdio/u8-u8-vsnprintf.c create mode 100644 lib/unistdio/u8-u8-vsprintf.c create mode 100644 lib/unistdio/u8-vasnprintf.c create mode 100644 lib/unistdio/u8-vasprintf.c create mode 100644 lib/unistdio/u8-vsnprintf.c create mode 100644 lib/unistdio/u8-vsprintf.c create mode 100644 lib/unistdio/ulc-asnprintf.c create mode 100644 lib/unistdio/ulc-asprintf.c create mode 100644 lib/unistdio/ulc-fprintf.c create mode 100644 lib/unistdio/ulc-printf-parse.c create mode 100644 lib/unistdio/ulc-snprintf.c create mode 100644 lib/unistdio/ulc-sprintf.c create mode 100644 lib/unistdio/ulc-vasnprintf.c create mode 100644 lib/unistdio/ulc-vasprintf.c create mode 100644 lib/unistdio/ulc-vfprintf.c create mode 100644 lib/unistdio/ulc-vsnprintf.c create mode 100644 lib/unistdio/ulc-vsprintf.c (limited to 'lib/unistdio') diff --git a/lib/unistdio/u-asnprintf.h b/lib/unistdio/u-asnprintf.h new file mode 100644 index 00000000..8fd08d7f --- /dev/null +++ b/lib/unistdio/u-asnprintf.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-asprintf.h b/lib/unistdio/u-asprintf.h new file mode 100644 index 00000000..ba82faba --- /dev/null +++ b/lib/unistdio/u-asprintf.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-printf-args.c b/lib/unistdio/u-printf-args.c new file mode 100644 index 00000000..22fbc088 --- /dev/null +++ b/lib/unistdio/u-printf-args.c @@ -0,0 +1,22 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio/u-printf-args.h" + +#include "printf-args.c" diff --git a/lib/unistdio/u-printf-args.h b/lib/unistdio/u-printf-args.h new file mode 100644 index 00000000..7b2255a2 --- /dev/null +++ b/lib/unistdio/u-printf-args.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#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 */ diff --git a/lib/unistdio/u-printf-parse.h b/lib/unistdio/u-printf-parse.h new file mode 100644 index 00000000..11a953f9 --- /dev/null +++ b/lib/unistdio/u-printf-parse.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#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 */ diff --git a/lib/unistdio/u-snprintf.h b/lib/unistdio/u-snprintf.h new file mode 100644 index 00000000..1665bc23 --- /dev/null +++ b/lib/unistdio/u-snprintf.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-sprintf.h b/lib/unistdio/u-sprintf.h new file mode 100644 index 00000000..8a1b5544 --- /dev/null +++ b/lib/unistdio/u-sprintf.h @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-vasprintf.h b/lib/unistdio/u-vasprintf.h new file mode 100644 index 00000000..965bfbf5 --- /dev/null +++ b/lib/unistdio/u-vasprintf.h @@ -0,0 +1,35 @@ +/* Formatted output to strings. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-vsnprintf.h b/lib/unistdio/u-vsnprintf.h new file mode 100644 index 00000000..481a22f0 --- /dev/null +++ b/lib/unistdio/u-vsnprintf.h @@ -0,0 +1,52 @@ +/* Formatted output to strings. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +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; +} diff --git a/lib/unistdio/u-vsprintf.h b/lib/unistdio/u-vsprintf.h new file mode 100644 index 00000000..36ebd9fa --- /dev/null +++ b/lib/unistdio/u-vsprintf.h @@ -0,0 +1,58 @@ +/* Formatted output to strings. + Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#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; +} diff --git a/lib/unistdio/u16-asnprintf.c b/lib/unistdio/u16-asnprintf.c new file mode 100644 index 00000000..bbe4bacb --- /dev/null +++ b/lib/unistdio/u16-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u16_asnprintf +#define VASNPRINTF u16_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u16-asprintf.c b/lib/unistdio/u16-asprintf.c new file mode 100644 index 00000000..79f3969c --- /dev/null +++ b/lib/unistdio/u16-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u16_asprintf +#define VASPRINTF u16_vasprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u16-printf-parse.c b/lib/unistdio/u16-printf-parse.c new file mode 100644 index 00000000..3a8acd32 --- /dev/null +++ b/lib/unistdio/u16-printf-parse.c @@ -0,0 +1,26 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* 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" diff --git a/lib/unistdio/u16-snprintf.c b/lib/unistdio/u16-snprintf.c new file mode 100644 index 00000000..afed8a7e --- /dev/null +++ b/lib/unistdio/u16-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u16_snprintf +#define VSNPRINTF u16_vsnprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u16-sprintf.c b/lib/unistdio/u16-sprintf.c new file mode 100644 index 00000000..48603652 --- /dev/null +++ b/lib/unistdio/u16-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u16_sprintf +#define VSPRINTF u16_vsprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u16-u16-asnprintf.c b/lib/unistdio/u16-u16-asnprintf.c new file mode 100644 index 00000000..64c257c2 --- /dev/null +++ b/lib/unistdio/u16-u16-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u16_u16_asnprintf +#define VASNPRINTF u16_u16_vasnprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u16-u16-asprintf.c b/lib/unistdio/u16-u16-asprintf.c new file mode 100644 index 00000000..38469c6e --- /dev/null +++ b/lib/unistdio/u16-u16-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u16_u16_asprintf +#define VASPRINTF u16_u16_vasprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u16-u16-snprintf.c b/lib/unistdio/u16-u16-snprintf.c new file mode 100644 index 00000000..7229add1 --- /dev/null +++ b/lib/unistdio/u16-u16-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u16_u16_snprintf +#define VSNPRINTF u16_u16_vsnprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u16-u16-sprintf.c b/lib/unistdio/u16-u16-sprintf.c new file mode 100644 index 00000000..1c517c36 --- /dev/null +++ b/lib/unistdio/u16-u16-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u16_u16_sprintf +#define VSPRINTF u16_u16_vsprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u16-u16-vasnprintf.c b/lib/unistdio/u16-u16-vasnprintf.c new file mode 100644 index 00000000..e33851e2 --- /dev/null +++ b/lib/unistdio/u16-u16-vasnprintf.c @@ -0,0 +1,49 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u16-u16-vasprintf.c b/lib/unistdio/u16-u16-vasprintf.c new file mode 100644 index 00000000..3d8fc508 --- /dev/null +++ b/lib/unistdio/u16-u16-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u16_u16_vasprintf +#define VASNPRINTF u16_u16_vasnprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u16-u16-vsnprintf.c b/lib/unistdio/u16-u16-vsnprintf.c new file mode 100644 index 00000000..6bbf8251 --- /dev/null +++ b/lib/unistdio/u16-u16-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u16-u16-vsprintf.c b/lib/unistdio/u16-u16-vsprintf.c new file mode 100644 index 00000000..1a7e93c2 --- /dev/null +++ b/lib/unistdio/u16-u16-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u16_u16_vsprintf +#define VASNPRINTF u16_u16_vasnprintf +#define FCHAR_T uint16_t +#define DCHAR_T uint16_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/u16-vasnprintf.c b/lib/unistdio/u16-vasnprintf.c new file mode 100644 index 00000000..3ce19d42 --- /dev/null +++ b/lib/unistdio/u16-vasnprintf.c @@ -0,0 +1,50 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u16-vasprintf.c b/lib/unistdio/u16-vasprintf.c new file mode 100644 index 00000000..b63dd183 --- /dev/null +++ b/lib/unistdio/u16-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u16_vasprintf +#define VASNPRINTF u16_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u16-vsnprintf.c b/lib/unistdio/u16-vsnprintf.c new file mode 100644 index 00000000..b06ca094 --- /dev/null +++ b/lib/unistdio/u16-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u16-vsprintf.c b/lib/unistdio/u16-vsprintf.c new file mode 100644 index 00000000..4811bc15 --- /dev/null +++ b/lib/unistdio/u16-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u16_vsprintf +#define VASNPRINTF u16_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint16_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/u32-asnprintf.c b/lib/unistdio/u32-asnprintf.c new file mode 100644 index 00000000..dad1ae49 --- /dev/null +++ b/lib/unistdio/u32-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u32_asnprintf +#define VASNPRINTF u32_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u32-asprintf.c b/lib/unistdio/u32-asprintf.c new file mode 100644 index 00000000..11e23f01 --- /dev/null +++ b/lib/unistdio/u32-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u32_asprintf +#define VASPRINTF u32_vasprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u32-printf-parse.c b/lib/unistdio/u32-printf-parse.c new file mode 100644 index 00000000..a5772566 --- /dev/null +++ b/lib/unistdio/u32-printf-parse.c @@ -0,0 +1,26 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* 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" diff --git a/lib/unistdio/u32-snprintf.c b/lib/unistdio/u32-snprintf.c new file mode 100644 index 00000000..7d670171 --- /dev/null +++ b/lib/unistdio/u32-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u32_snprintf +#define VSNPRINTF u32_vsnprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u32-sprintf.c b/lib/unistdio/u32-sprintf.c new file mode 100644 index 00000000..6f930d09 --- /dev/null +++ b/lib/unistdio/u32-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u32_sprintf +#define VSPRINTF u32_vsprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u32-u32-asnprintf.c b/lib/unistdio/u32-u32-asnprintf.c new file mode 100644 index 00000000..b3a02745 --- /dev/null +++ b/lib/unistdio/u32-u32-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u32_u32_asnprintf +#define VASNPRINTF u32_u32_vasnprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u32-u32-asprintf.c b/lib/unistdio/u32-u32-asprintf.c new file mode 100644 index 00000000..91a96fc4 --- /dev/null +++ b/lib/unistdio/u32-u32-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u32_u32_asprintf +#define VASPRINTF u32_u32_vasprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u32-u32-snprintf.c b/lib/unistdio/u32-u32-snprintf.c new file mode 100644 index 00000000..cf88529c --- /dev/null +++ b/lib/unistdio/u32-u32-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u32_u32_snprintf +#define VSNPRINTF u32_u32_vsnprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u32-u32-sprintf.c b/lib/unistdio/u32-u32-sprintf.c new file mode 100644 index 00000000..ccf6d028 --- /dev/null +++ b/lib/unistdio/u32-u32-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u32_u32_sprintf +#define VSPRINTF u32_u32_vsprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u32-u32-vasnprintf.c b/lib/unistdio/u32-u32-vasnprintf.c new file mode 100644 index 00000000..b272af33 --- /dev/null +++ b/lib/unistdio/u32-u32-vasnprintf.c @@ -0,0 +1,49 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u32-u32-vasprintf.c b/lib/unistdio/u32-u32-vasprintf.c new file mode 100644 index 00000000..bacc7c1b --- /dev/null +++ b/lib/unistdio/u32-u32-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u32_u32_vasprintf +#define VASNPRINTF u32_u32_vasnprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u32-u32-vsnprintf.c b/lib/unistdio/u32-u32-vsnprintf.c new file mode 100644 index 00000000..7f436236 --- /dev/null +++ b/lib/unistdio/u32-u32-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u32-u32-vsprintf.c b/lib/unistdio/u32-u32-vsprintf.c new file mode 100644 index 00000000..46d299ac --- /dev/null +++ b/lib/unistdio/u32-u32-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u32_u32_vsprintf +#define VASNPRINTF u32_u32_vasnprintf +#define FCHAR_T uint32_t +#define DCHAR_T uint32_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/u32-vasnprintf.c b/lib/unistdio/u32-vasnprintf.c new file mode 100644 index 00000000..6aac6235 --- /dev/null +++ b/lib/unistdio/u32-vasnprintf.c @@ -0,0 +1,50 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u32-vasprintf.c b/lib/unistdio/u32-vasprintf.c new file mode 100644 index 00000000..e6883e31 --- /dev/null +++ b/lib/unistdio/u32-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u32_vasprintf +#define VASNPRINTF u32_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u32-vsnprintf.c b/lib/unistdio/u32-vsnprintf.c new file mode 100644 index 00000000..a55e1c76 --- /dev/null +++ b/lib/unistdio/u32-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u32-vsprintf.c b/lib/unistdio/u32-vsprintf.c new file mode 100644 index 00000000..a850e45f --- /dev/null +++ b/lib/unistdio/u32-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u32_vsprintf +#define VASNPRINTF u32_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint32_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/u8-asnprintf.c b/lib/unistdio/u8-asnprintf.c new file mode 100644 index 00000000..b8e7a276 --- /dev/null +++ b/lib/unistdio/u8-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u8_asnprintf +#define VASNPRINTF u8_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u8-asprintf.c b/lib/unistdio/u8-asprintf.c new file mode 100644 index 00000000..22b01705 --- /dev/null +++ b/lib/unistdio/u8-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u8_asprintf +#define VASPRINTF u8_vasprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u8-printf-parse.c b/lib/unistdio/u8-printf-parse.c new file mode 100644 index 00000000..a3555481 --- /dev/null +++ b/lib/unistdio/u8-printf-parse.c @@ -0,0 +1,26 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* 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" diff --git a/lib/unistdio/u8-snprintf.c b/lib/unistdio/u8-snprintf.c new file mode 100644 index 00000000..87290541 --- /dev/null +++ b/lib/unistdio/u8-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u8_snprintf +#define VSNPRINTF u8_vsnprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u8-sprintf.c b/lib/unistdio/u8-sprintf.c new file mode 100644 index 00000000..330feaee --- /dev/null +++ b/lib/unistdio/u8-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u8_sprintf +#define VSPRINTF u8_vsprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u8-u8-asnprintf.c b/lib/unistdio/u8-u8-asnprintf.c new file mode 100644 index 00000000..9379c72a --- /dev/null +++ b/lib/unistdio/u8-u8-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF u8_u8_asnprintf +#define VASNPRINTF u8_u8_vasnprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-asnprintf.h" diff --git a/lib/unistdio/u8-u8-asprintf.c b/lib/unistdio/u8-u8-asprintf.c new file mode 100644 index 00000000..59745278 --- /dev/null +++ b/lib/unistdio/u8-u8-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF u8_u8_asprintf +#define VASPRINTF u8_u8_vasprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-asprintf.h" diff --git a/lib/unistdio/u8-u8-snprintf.c b/lib/unistdio/u8-u8-snprintf.c new file mode 100644 index 00000000..26dfac0e --- /dev/null +++ b/lib/unistdio/u8-u8-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF u8_u8_snprintf +#define VSNPRINTF u8_u8_vsnprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-snprintf.h" diff --git a/lib/unistdio/u8-u8-sprintf.c b/lib/unistdio/u8-u8-sprintf.c new file mode 100644 index 00000000..53b3c96b --- /dev/null +++ b/lib/unistdio/u8-u8-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF u8_u8_sprintf +#define VSPRINTF u8_u8_vsprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-sprintf.h" diff --git a/lib/unistdio/u8-u8-vasnprintf.c b/lib/unistdio/u8-u8-vasnprintf.c new file mode 100644 index 00000000..7535d4ca --- /dev/null +++ b/lib/unistdio/u8-u8-vasnprintf.c @@ -0,0 +1,49 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u8-u8-vasprintf.c b/lib/unistdio/u8-u8-vasprintf.c new file mode 100644 index 00000000..bb28dc5f --- /dev/null +++ b/lib/unistdio/u8-u8-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u8_u8_vasprintf +#define VASNPRINTF u8_u8_vasnprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u8-u8-vsnprintf.c b/lib/unistdio/u8-u8-vsnprintf.c new file mode 100644 index 00000000..f9e99223 --- /dev/null +++ b/lib/unistdio/u8-u8-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u8-u8-vsprintf.c b/lib/unistdio/u8-u8-vsprintf.c new file mode 100644 index 00000000..9e66018a --- /dev/null +++ b/lib/unistdio/u8-u8-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u8_u8_vsprintf +#define VASNPRINTF u8_u8_vasnprintf +#define FCHAR_T uint8_t +#define DCHAR_T uint8_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/u8-vasnprintf.c b/lib/unistdio/u8-vasnprintf.c new file mode 100644 index 00000000..0067e6ce --- /dev/null +++ b/lib/unistdio/u8-vasnprintf.c @@ -0,0 +1,50 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/u8-vasprintf.c b/lib/unistdio/u8-vasprintf.c new file mode 100644 index 00000000..304d4965 --- /dev/null +++ b/lib/unistdio/u8-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF u8_vasprintf +#define VASNPRINTF u8_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-vasprintf.h" diff --git a/lib/unistdio/u8-vsnprintf.c b/lib/unistdio/u8-vsnprintf.c new file mode 100644 index 00000000..87388e29 --- /dev/null +++ b/lib/unistdio/u8-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#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" diff --git a/lib/unistdio/u8-vsprintf.c b/lib/unistdio/u8-vsprintf.c new file mode 100644 index 00000000..aa0b52d2 --- /dev/null +++ b/lib/unistdio/u8-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF u8_vsprintf +#define VASNPRINTF u8_vasnprintf +#define FCHAR_T char +#define DCHAR_T uint8_t +#include "u-vsprintf.h" diff --git a/lib/unistdio/ulc-asnprintf.c b/lib/unistdio/ulc-asnprintf.c new file mode 100644 index 00000000..31d3f220 --- /dev/null +++ b/lib/unistdio/ulc-asnprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASNPRINTF ulc_asnprintf +#define VASNPRINTF ulc_vasnprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-asnprintf.h" diff --git a/lib/unistdio/ulc-asprintf.c b/lib/unistdio/ulc-asprintf.c new file mode 100644 index 00000000..4f760e1d --- /dev/null +++ b/lib/unistdio/ulc-asprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define ASPRINTF ulc_asprintf +#define VASPRINTF ulc_vasprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-asprintf.h" diff --git a/lib/unistdio/ulc-fprintf.c b/lib/unistdio/ulc-fprintf.c new file mode 100644 index 00000000..ac8ab6fe --- /dev/null +++ b/lib/unistdio/ulc-fprintf.c @@ -0,0 +1,74 @@ +/* Formatted output to a stream. + Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#include "fseterr.h" + +/* 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; +} diff --git a/lib/unistdio/ulc-printf-parse.c b/lib/unistdio/ulc-printf-parse.c new file mode 100644 index 00000000..81af3690 --- /dev/null +++ b/lib/unistdio/ulc-printf-parse.c @@ -0,0 +1,27 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* 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" diff --git a/lib/unistdio/ulc-snprintf.c b/lib/unistdio/ulc-snprintf.c new file mode 100644 index 00000000..f774ac04 --- /dev/null +++ b/lib/unistdio/ulc-snprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SNPRINTF ulc_snprintf +#define VSNPRINTF ulc_vsnprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-snprintf.h" diff --git a/lib/unistdio/ulc-sprintf.c b/lib/unistdio/ulc-sprintf.c new file mode 100644 index 00000000..466ffb40 --- /dev/null +++ b/lib/unistdio/ulc-sprintf.c @@ -0,0 +1,28 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include + +#define SPRINTF ulc_sprintf +#define VSPRINTF ulc_vsprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-sprintf.h" diff --git a/lib/unistdio/ulc-vasnprintf.c b/lib/unistdio/ulc-vasnprintf.c new file mode 100644 index 00000000..e89b7fff --- /dev/null +++ b/lib/unistdio/ulc-vasnprintf.c @@ -0,0 +1,46 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* Tell glibc's to provide a prototype for snprintf(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include + +/* 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" diff --git a/lib/unistdio/ulc-vasprintf.c b/lib/unistdio/ulc-vasprintf.c new file mode 100644 index 00000000..8773ab46 --- /dev/null +++ b/lib/unistdio/ulc-vasprintf.c @@ -0,0 +1,30 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include + +#define VASPRINTF ulc_vasprintf +#define VASNPRINTF ulc_vasnprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-vasprintf.h" diff --git a/lib/unistdio/ulc-vfprintf.c b/lib/unistdio/ulc-vfprintf.c new file mode 100644 index 00000000..586fe13a --- /dev/null +++ b/lib/unistdio/ulc-vfprintf.c @@ -0,0 +1,71 @@ +/* Formatted output to a stream. + Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#include "fseterr.h" + +/* 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; +} diff --git a/lib/unistdio/ulc-vsnprintf.c b/lib/unistdio/ulc-vsnprintf.c new file mode 100644 index 00000000..c1665359 --- /dev/null +++ b/lib/unistdio/ulc-vsnprintf.c @@ -0,0 +1,33 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSNPRINTF ulc_vsnprintf +#define VASNPRINTF ulc_vasnprintf +#define FCHAR_T char +#define DCHAR_T char +#define DCHAR_CPY memcpy +#include "u-vsnprintf.h" diff --git a/lib/unistdio/ulc-vsprintf.c b/lib/unistdio/ulc-vsprintf.c new file mode 100644 index 00000000..0cccc05d --- /dev/null +++ b/lib/unistdio/ulc-vsprintf.c @@ -0,0 +1,32 @@ +/* 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 Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include "unistdio.h" + +#include +#include +#include +#include +#include + +#define VSPRINTF ulc_vsprintf +#define VASNPRINTF ulc_vasnprintf +#define FCHAR_T char +#define DCHAR_T char +#include "u-vsprintf.h" -- cgit v1.2.3