-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include vasprintf-posix from gnulib. Not yet in replacement includes
- Loading branch information
1 parent
11f7a6c
commit 081399d
Showing
11 changed files
with
3,989 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Formatted output to strings. | ||
Copyright (C) 1999, 2002, 2006-2007, 2009-2019 Free Software Foundation, | ||
Inc. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3, or (at your option) | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, see <https://www.gnu.org/licenses/>. */ | ||
|
||
#include <config.h> | ||
|
||
/* Specification. */ | ||
#ifdef IN_LIBASPRINTF | ||
# include "vasprintf.h" | ||
#else | ||
# include <stdio.h> | ||
#endif | ||
|
||
#include <stdarg.h> | ||
|
||
int | ||
asprintf (char **resultp, const char *format, ...) | ||
{ | ||
va_list args; | ||
int result; | ||
|
||
va_start (args, format); | ||
result = vasprintf (resultp, format, args); | ||
va_end (args); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# vasprintf-posix.m4 serial 13 | ||
dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. | ||
dnl This file is free software; the Free Software Foundation | ||
dnl gives unlimited permission to copy and/or distribute it, | ||
dnl with or without modifications, as long as this notice is preserved. | ||
|
||
AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], | ||
[ | ||
AC_REQUIRE([gl_PRINTF_SIZES_C99]) | ||
AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) | ||
AC_REQUIRE([gl_PRINTF_INFINITE]) | ||
AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) | ||
AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) | ||
AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) | ||
AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) | ||
AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS]) | ||
AC_REQUIRE([gl_PRINTF_POSITIONS]) | ||
AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) | ||
AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST]) | ||
AC_REQUIRE([gl_PRINTF_FLAG_ZERO]) | ||
AC_REQUIRE([gl_PRINTF_PRECISION]) | ||
AC_REQUIRE([gl_PRINTF_ENOMEM]) | ||
gl_cv_func_vasprintf_posix=no | ||
AC_CHECK_FUNCS([vasprintf]) | ||
case "$gl_cv_func_printf_sizes_c99" in | ||
*yes) | ||
case "$gl_cv_func_printf_long_double" in | ||
*yes) | ||
case "$gl_cv_func_printf_infinite" in | ||
*yes) | ||
case "$gl_cv_func_printf_infinite_long_double" in | ||
*yes) | ||
case "$gl_cv_func_printf_directive_a" in | ||
*yes) | ||
case "$gl_cv_func_printf_directive_f" in | ||
*yes) | ||
case "$gl_cv_func_printf_directive_n" in | ||
*yes) | ||
case "$gl_cv_func_printf_directive_ls" in | ||
*yes) | ||
case "$gl_cv_func_printf_positions" in | ||
*yes) | ||
case "$gl_cv_func_printf_flag_grouping" in | ||
*yes) | ||
case "$gl_cv_func_printf_flag_leftadjust" in | ||
*yes) | ||
case "$gl_cv_func_printf_flag_zero" in | ||
*yes) | ||
case "$gl_cv_func_printf_precision" in | ||
*yes) | ||
case "$gl_cv_func_printf_enomem" in | ||
*yes) | ||
if test $ac_cv_func_vasprintf = yes; then | ||
# vasprintf exists and is | ||
# already POSIX compliant. | ||
gl_cv_func_vasprintf_posix=yes | ||
fi | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
;; | ||
esac | ||
if test $gl_cv_func_vasprintf_posix = no; then | ||
gl_PREREQ_VASNPRINTF_LONG_DOUBLE | ||
gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE | ||
gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE | ||
gl_PREREQ_VASNPRINTF_DIRECTIVE_A | ||
gl_PREREQ_VASNPRINTF_DIRECTIVE_F | ||
gl_PREREQ_VASNPRINTF_DIRECTIVE_LS | ||
gl_PREREQ_VASNPRINTF_FLAG_GROUPING | ||
gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST | ||
gl_PREREQ_VASNPRINTF_FLAG_ZERO | ||
gl_PREREQ_VASNPRINTF_PRECISION | ||
gl_PREREQ_VASNPRINTF_ENOMEM | ||
gl_REPLACE_VASNPRINTF | ||
gl_REPLACE_VASPRINTF | ||
fi | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# vasprintf.m4 serial 6 | ||
dnl Copyright (C) 2002-2003, 2006-2007, 2009-2019 Free Software Foundation, | ||
dnl Inc. | ||
dnl This file is free software; the Free Software Foundation | ||
dnl gives unlimited permission to copy and/or distribute it, | ||
dnl with or without modifications, as long as this notice is preserved. | ||
|
||
AC_DEFUN([gl_FUNC_VASPRINTF], | ||
[ | ||
AC_CHECK_FUNCS([vasprintf]) | ||
if test $ac_cv_func_vasprintf = no; then | ||
gl_REPLACE_VASPRINTF | ||
fi | ||
]) | ||
|
||
AC_DEFUN([gl_REPLACE_VASPRINTF], | ||
[ | ||
AC_LIBOBJ([vasprintf]) | ||
AC_LIBOBJ([asprintf]) | ||
AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | ||
if test $ac_cv_func_vasprintf = yes; then | ||
REPLACE_VASPRINTF=1 | ||
else | ||
HAVE_VASPRINTF=0 | ||
fi | ||
gl_PREREQ_VASPRINTF_H | ||
gl_PREREQ_VASPRINTF | ||
gl_PREREQ_ASPRINTF | ||
]) | ||
|
||
# Prerequisites of the vasprintf portion of lib/stdio.h. | ||
AC_DEFUN([gl_PREREQ_VASPRINTF_H], | ||
[ | ||
dnl Persuade glibc <stdio.h> to declare asprintf() and vasprintf(). | ||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
]) | ||
|
||
# Prerequisites of lib/vasprintf.c. | ||
AC_DEFUN([gl_PREREQ_VASPRINTF], | ||
[ | ||
]) | ||
|
||
# Prerequisites of lib/asprintf.c. | ||
AC_DEFUN([gl_PREREQ_ASPRINTF], | ||
[ | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Formatted output to strings. | ||
Copyright (C) 1999, 2002, 2006-2019 Free Software Foundation, Inc. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3, or (at your option) | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, see <https://www.gnu.org/licenses/>. */ | ||
|
||
#include <config.h> | ||
|
||
/* Specification. */ | ||
#ifdef IN_LIBASPRINTF | ||
# include "vasprintf.h" | ||
#else | ||
# include <stdio.h> | ||
#endif | ||
|
||
#include <errno.h> | ||
#include <limits.h> | ||
#include <stdlib.h> | ||
|
||
#include "vasnprintf.h" | ||
|
||
int | ||
vasprintf (char **resultp, const char *format, va_list args) | ||
{ | ||
size_t length; | ||
char *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 bytes, excluding the trailing NUL. */ | ||
return length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.