diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/iconv/gnulib-local |
Fresh start
Diffstat (limited to 'jni/iconv/gnulib-local')
-rw-r--r-- | jni/iconv/gnulib-local/lib/alloca.in.h | 68 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/lib/error.h.diff | 33 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/lib/progname.h.diff | 19 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/lib/xalloc.h | 158 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/lib/xmalloc.c | 128 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/lib/xstrdup.c | 40 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/m4/alloca.m4 | 35 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/modules/libiconv-misc | 20 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/modules/mbstate | 21 | ||||
-rw-r--r-- | jni/iconv/gnulib-local/modules/xalloc | 23 |
10 files changed, 545 insertions, 0 deletions
diff --git a/jni/iconv/gnulib-local/lib/alloca.in.h b/jni/iconv/gnulib-local/lib/alloca.in.h new file mode 100644 index 0000000..964cb8d --- /dev/null +++ b/jni/iconv/gnulib-local/lib/alloca.in.h @@ -0,0 +1,68 @@ +/* Memory allocation on the stack. + Copyright (C) 1995, 1999, 2001-2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 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 <http://www.gnu.org/licenses/>. */ + +/* When this file is included, it may be preceded only by preprocessor + declarations. Thanks to AIX. Therefore we include it right after + "config.h", not later. */ + +/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H + means there is a real alloca function. */ +#ifndef _GL_ALLOCA_H +#define _GL_ALLOCA_H + +/* alloca(N) returns a pointer (void* or char*) to N bytes of memory + allocated on the stack, and which will last until the function returns. + Use of alloca should be avoided: + - inside arguments of function calls - undefined behaviour, + - in inline functions - the allocation may actually last until the + calling function returns, + - for huge N (say, N >= 65536) - you never know how large (or small) + the stack is, and when the stack cannot fulfill the memory allocation + request, the program just crashes. + */ + +#ifndef alloca +# ifdef __GNUC__ +# define alloca __builtin_alloca +# else +# ifdef _MSC_VER +# include <malloc.h> +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifdef __hpux /* This section must match that of bison generated files. */ +# ifdef __cplusplus +extern "C" void *alloca (unsigned int); +# else /* not __cplusplus */ +extern void *alloca (); +# endif /* not __cplusplus */ +# else /* not __hpux */ +# ifndef alloca +extern char *alloca (); +# endif +# endif /* __hpux */ +# endif +# endif +# endif +# endif +#endif + +#endif /* _GL_ALLOCA_H */ diff --git a/jni/iconv/gnulib-local/lib/error.h.diff b/jni/iconv/gnulib-local/lib/error.h.diff new file mode 100644 index 0000000..069df8d --- /dev/null +++ b/jni/iconv/gnulib-local/lib/error.h.diff @@ -0,0 +1,33 @@ +*** gnulib/lib/error.h 2005-05-14 08:03:58.000000000 +0200 +--- srclib/error.h 2005-05-20 23:06:02.000000000 +0200 +*************** +*** 50,63 **** + /* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +! extern void (*error_print_progname) (void); + + /* This variable is incremented each time `error' is called. */ +! extern unsigned int error_message_count; + + /* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +! extern int error_one_per_line; + + #ifdef __cplusplus + } +--- 50,63 ---- + /* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +! extern DLL_VARIABLE void (*error_print_progname) (void); + + /* This variable is incremented each time `error' is called. */ +! extern DLL_VARIABLE unsigned int error_message_count; + + /* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +! extern DLL_VARIABLE int error_one_per_line; + + #ifdef __cplusplus + } diff --git a/jni/iconv/gnulib-local/lib/progname.h.diff b/jni/iconv/gnulib-local/lib/progname.h.diff new file mode 100644 index 0000000..37dda97 --- /dev/null +++ b/jni/iconv/gnulib-local/lib/progname.h.diff @@ -0,0 +1,19 @@ +*** gnulib/lib/progname.h 2005-05-14 08:03:58.000000000 +0200 +--- srclib/progname.h 2005-05-20 23:06:02.000000000 +0200 +*************** +*** 30,36 **** + + + /* String containing name the program is called with. */ +! extern const char *program_name; + + /* Set program_name, based on argv[0]. */ + extern void set_program_name (const char *argv0); +--- 30,36 ---- + + + /* String containing name the program is called with. */ +! extern DLL_VARIABLE const char *program_name; + + /* Set program_name, based on argv[0]. */ + extern void set_program_name (const char *argv0); diff --git a/jni/iconv/gnulib-local/lib/xalloc.h b/jni/iconv/gnulib-local/lib/xalloc.h new file mode 100644 index 0000000..e0d56fc --- /dev/null +++ b/jni/iconv/gnulib-local/lib/xalloc.h @@ -0,0 +1,158 @@ +/* malloc with out of memory checking. + Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc. + Written by Bruno Haible <haible@clisp.cons.org>, 2001. + + 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 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 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 <http://www.gnu.org/licenses/>. */ + +#ifndef _XALLOC_H +#define _XALLOC_H + +#include <stddef.h> + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Defined in xmalloc.c. */ + +/* Allocate SIZE bytes of memory dynamically, with error checking. */ +extern void *xmalloc (size_t size); + +/* Allocate memory for NMEMB elements of SIZE bytes, with error checking. + SIZE must be > 0. */ +extern void *xnmalloc (size_t nmemb, size_t size); + +/* Allocate SIZE bytes of memory dynamically, with error checking, + and zero it. */ +extern void *xzalloc (size_t size); + +/* Allocate memory for NMEMB elements of SIZE bytes, with error checking, + and zero it. */ +extern void *xcalloc (size_t nmemb, size_t size); + +/* Change the size of an allocated block of memory PTR to SIZE bytes, + with error checking. If PTR is NULL, run xmalloc. */ +extern void *xrealloc (void *ptr, size_t size); +#ifdef __cplusplus +} +template <typename T> + inline T * xrealloc (T * ptr, size_t size) + { + return (T *) xrealloc ((void *) ptr, size); + } +extern "C" { +#endif + +/* This function is always triggered when memory is exhausted. It is + in charge of honoring the three previous items. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die (void) +#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) && !__STRICT_ANSI__ + __attribute__ ((__noreturn__)) +#endif + ; + +/* In the following macros, T must be an elementary or structure/union or + typedef'ed type, or a pointer to such a type. To apply one of the + following macros to a function pointer or array type, you need to typedef + it first and use the typedef name. */ + +/* Allocate an object of type T dynamically, with error checking. */ +/* extern T *XMALLOC (typename T); */ +#define XMALLOC(T) \ + ((T *) xmalloc (sizeof (T))) + +/* Allocate memory for NMEMB elements of type T, with error checking. */ +/* extern T *XNMALLOC (size_t nmemb, typename T); */ +#if HAVE_INLINE +/* xnmalloc performs a division and multiplication by sizeof (T). Arrange to + perform the division at compile-time and the multiplication with a factor + known at compile-time. */ +# define XNMALLOC(N,T) \ + ((T *) (sizeof (T) == 1 \ + ? xmalloc (N) \ + : xnboundedmalloc(N, (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / sizeof (T), sizeof (T)))) +static inline void * +xnboundedmalloc (size_t n, size_t bound, size_t s) +{ + if (n > bound) + xalloc_die (); + return xmalloc (n * s); +} +#else +# define XNMALLOC(N,T) \ + ((T *) (sizeof (T) == 1 ? xmalloc (N) : xnmalloc (N, sizeof (T)))) +#endif + +/* Allocate an object of type T dynamically, with error checking, + and zero it. */ +/* extern T *XZALLOC (typename T); */ +#define XZALLOC(T) \ + ((T *) xzalloc (sizeof (T))) + +/* Allocate memory for NMEMB elements of type T, with error checking, + and zero it. */ +/* extern T *XCALLOC (size_t nmemb, typename T); */ +#define XCALLOC(N,T) \ + ((T *) xcalloc (N, sizeof (T))) + +/* Return a pointer to a new buffer of N bytes. This is like xmalloc, + except it returns char *. */ +#define xcharalloc(N) \ + XNMALLOC (N, char) + + +/* Defined in xstrdup.c. */ + +/* Return a newly allocated copy of the N bytes of memory starting at P. */ +extern void *xmemdup (const void *p, size_t n); +#ifdef __cplusplus +} +template <typename T> + inline T * xmemdup (const T * p, size_t n) + { + return (T *) xmemdup ((const void *) p, n); + } +extern "C" { +#endif + +/* Return a newly allocated copy of STRING. */ +extern char *xstrdup (const char *string); + + +/* Return 1 if an array of N objects, each of size S, cannot exist due + to size arithmetic overflow. S must be positive and N must be + nonnegative. This is a macro, not an inline function, so that it + works correctly even when SIZE_MAX < N. + + By gnulib convention, SIZE_MAX represents overflow in size + calculations, so the conservative dividend to use here is + SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. + However, malloc (SIZE_MAX) fails on all known hosts where + sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for + exactly-SIZE_MAX allocations on such hosts; this avoids a test and + branch when S is known to be 1. */ +# define xalloc_oversized(n, s) \ + ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) + + +#ifdef __cplusplus +} +#endif + + +#endif /* _XALLOC_H */ diff --git a/jni/iconv/gnulib-local/lib/xmalloc.c b/jni/iconv/gnulib-local/lib/xmalloc.c new file mode 100644 index 0000000..d2a1214 --- /dev/null +++ b/jni/iconv/gnulib-local/lib/xmalloc.c @@ -0,0 +1,128 @@ +/* xmalloc.c -- malloc with out of memory checking + Copyright (C) 1990-1996, 2000-2003, 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 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 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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include "xalloc.h" + +#include <stdlib.h> + +#include "error.h" +#include "gettext.h" + +#define _(str) gettext (str) + + +/* Exit value when the requested amount of memory is not available. + The caller may set it to some other value. */ +int xmalloc_exit_failure = EXIT_FAILURE; + +void +xalloc_die () +{ + error (xmalloc_exit_failure, 0, _("memory exhausted")); + /* The `noreturn' cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does terminate, call exit. */ + exit (EXIT_FAILURE); +} + +static void * +fixup_null_alloc (size_t n) +{ + void *p; + + p = NULL; + if (n == 0) + p = malloc ((size_t) 1); + if (p == NULL) + xalloc_die (); + return p; +} + +/* Allocate N bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t n) +{ + void *p; + + p = malloc (n); + if (p == NULL) + p = fixup_null_alloc (n); + return p; +} + +/* Allocate memory for NMEMB elements of SIZE bytes, with error checking. + SIZE must be > 0. */ + +void * +xnmalloc (size_t nmemb, size_t size) +{ + size_t n; + void *p; + + if (xalloc_oversized (nmemb, size)) + xalloc_die (); + n = nmemb * size; + p = malloc (n); + if (p == NULL) + p = fixup_null_alloc (n); + return p; +} + +/* Allocate SIZE bytes of memory dynamically, with error checking, + and zero it. */ + +void * +xzalloc (size_t size) +{ + void *p; + + p = xmalloc (size); + memset (p, 0, size); + return p; +} + +/* Allocate memory for N elements of S bytes, with error checking, + and zero it. */ + +void * +xcalloc (size_t n, size_t s) +{ + void *p; + + p = calloc (n, s); + if (p == NULL) + p = fixup_null_alloc (n); + return p; +} + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. + If P is NULL, run xmalloc. */ + +void * +xrealloc (void *p, size_t n) +{ + if (p == NULL) + return xmalloc (n); + p = realloc (p, n); + if (p == NULL) + p = fixup_null_alloc (n); + return p; +} diff --git a/jni/iconv/gnulib-local/lib/xstrdup.c b/jni/iconv/gnulib-local/lib/xstrdup.c new file mode 100644 index 0000000..9ad1b94 --- /dev/null +++ b/jni/iconv/gnulib-local/lib/xstrdup.c @@ -0,0 +1,40 @@ +/* xstrdup.c -- copy a string with out of memory checking + Copyright (C) 1990, 1996, 2000-2003, 2005-2006 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 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 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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include "xalloc.h" + +#include <string.h> + +/* Return a newly allocated copy of the N bytes of memory starting at P. */ + +void * +xmemdup (const void *p, size_t n) +{ + void *q = xmalloc (n); + memcpy (q, p, n); + return q; +} + +/* Return a newly allocated copy of STRING. */ + +char * +xstrdup (const char *string) +{ + return strcpy (XNMALLOC (strlen (string) + 1, char), string); +} diff --git a/jni/iconv/gnulib-local/m4/alloca.m4 b/jni/iconv/gnulib-local/m4/alloca.m4 new file mode 100644 index 0000000..cd4a679 --- /dev/null +++ b/jni/iconv/gnulib-local/m4/alloca.m4 @@ -0,0 +1,35 @@ +# alloca.m4 serial 3 (gettext-0.16) +dnl Copyright (C) 2002-2003, 2006 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_ALLOCA], +[ + dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. + AC_REQUIRE([AC_PROG_CPP]) + AC_REQUIRE([AC_PROG_EGREP]) + + AC_REQUIRE([AC_FUNC_ALLOCA]) + if test $ac_cv_func_alloca_works = no; then + gl_PREREQ_ALLOCA + fi + + # Define an additional variable used in the Makefile substitution. + + AC_EGREP_CPP([Need own alloca], [ +#if defined __GNUC__ || defined _MSC_VER || !HAVE_ALLOCA_H + Need own alloca +#endif + ], + ALLOCA_H=alloca.h, + ALLOCA_H=) + AC_SUBST([ALLOCA_H]) +]) + +# Prerequisites of lib/alloca.c. +# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. +AC_DEFUN([gl_PREREQ_ALLOCA], [ + AC_CHECK_HEADERS_ONCE(stdlib.h string.h) + : +]) diff --git a/jni/iconv/gnulib-local/modules/libiconv-misc b/jni/iconv/gnulib-local/modules/libiconv-misc new file mode 100644 index 0000000..af89ac5 --- /dev/null +++ b/jni/iconv/gnulib-local/modules/libiconv-misc @@ -0,0 +1,20 @@ +Description: + +Files: + +Depends-on: + +configure.ac: + +Makefile.am: +# Parametrization of the 'relocatable' module. +AM_CPPFLAGS += -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 + +Include: + +License: +GPL + +Maintainer: +Bruno Haible + diff --git a/jni/iconv/gnulib-local/modules/mbstate b/jni/iconv/gnulib-local/modules/mbstate new file mode 100644 index 0000000..24e70e8 --- /dev/null +++ b/jni/iconv/gnulib-local/modules/mbstate @@ -0,0 +1,21 @@ +Description: +mbstate_t type. + +Files: +m4/mbstate_t.m4 + +Depends-on: + +configure.ac: +AC_TYPE_MBSTATE_T + +Makefile.am: + +Include: + +License: +LGPL + +Maintainer: +Bruno Haible + diff --git a/jni/iconv/gnulib-local/modules/xalloc b/jni/iconv/gnulib-local/modules/xalloc new file mode 100644 index 0000000..54fa33c --- /dev/null +++ b/jni/iconv/gnulib-local/modules/xalloc @@ -0,0 +1,23 @@ +Description: +Memory allocation with out-of-memory checking. + +Files: +lib/xalloc.h +lib/xmalloc.c +lib/xstrdup.c + +Depends-on: + +configure.ac: + +Makefile.am: +lib_SOURCES += xalloc.h xmalloc.c xstrdup.c + +Include: +"xalloc.h" + +License: +GPL + +Maintainer: +all |