Use alloca.h instead of liballoca.h.

This commit is contained in:
Bruno Haible 2003-01-14 13:28:57 +00:00
parent 239fa8447b
commit 745e61578f
30 changed files with 228 additions and 63 deletions

View File

@ -1,3 +1,7 @@
2003-01-12 Bruno Haible <bruno@clisp.org>
* configure.in: Invoke gl_FUNC_ALLOCA instead of AC_FUNC_ALLOCA.
2003-01-12 Bruno Haible <bruno@clisp.org>
* Makefile.am: Make use of += for variables.

View File

@ -73,7 +73,7 @@ gt_TYPE_SSIZE_T
AC_TYPE_PID_T
dnl Checks for library functions.
AC_FUNC_ALLOCA
gl_FUNC_ALLOCA
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([getcwd mblen memcpy posix_spawn putc_unlocked raise select \
strerror strtoul uname utime utimes])

View File

@ -1,3 +1,13 @@
2003-01-12 Bruno Haible <bruno@clisp.org>
* alloca_.h: New file, from gnulib.
* liballoca.h: Remove file.
* Makefile.am: Add snippet from gnulib module alloca.
(LIBADD_SOURCE): Remove liballoca.h.
* javacomp.c: Include alloca.h instead of liballoca.h.
* javaexec.c: Likewise.
* setenv.c: Likewise.
2003-01-12 Bruno Haible <bruno@clisp.org>
* Makefile.am: Make use of += for variables.

View File

@ -71,7 +71,7 @@ libgettextlib_la_SOURCES = \
# Sources that are compiled only on platforms that lack the functions.
LIBADD_SOURCE = \
liballoca.h alloca.c \
alloca.c \
getline.h getline.c \
memset.c \
mkdtemp.h mkdtemp.c \
@ -138,6 +138,18 @@ MOSTLYCLEANFILES += stdbool.h
# <<< gnulib module stdbool.
# >>> gnulib module alloca.
EXTRA_DIST += alloca_.h
# The following is needed in order to create an <alloca.h> when the system
# doesn't have one that works with the given compiler.
all-local $(libgettextlib_la_OBJECTS): @ALLOCA_H@
alloca.h: alloca_.h
cp $(srcdir)/alloca_.h alloca.h
MOSTLYCLEANFILES += alloca.h
# <<< gnulib module alloca.
# >>> gnulib module localcharset.
libgettextlib_la_SOURCES += localcharset.c
EXTRA_DIST += config.charset ref-add.sin ref-del.sin

View File

@ -1,5 +1,5 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2002 Free Software Foundation, Inc.
Copyright (C) 1995, 1999, 2001-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
@ -20,8 +20,19 @@
declarations. Thanks to AIX. Therefore we include it right after
"config.h", not later. */
#ifndef _LIBALLOCA_H
#define _LIBALLOCA_H
#ifndef _ALLOCA_H
#define _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.
*/
#ifdef __GNUC__
# ifndef alloca
@ -42,11 +53,11 @@
# ifdef __cplusplus
extern "C" void *alloca (unsigned int);
# else /* not __cplusplus */
void *alloca ();
extern void *alloca ();
# endif /* not __cplusplus */
# else /* not __hpux */
# ifndef alloca
char *alloca ();
extern char *alloca ();
# endif
# endif /* __hpux */
# endif
@ -54,4 +65,4 @@ char *alloca ();
# endif
#endif
#endif /* _LIBALLOCA_H */
#endif /* _ALLOCA_H */

View File

@ -1,5 +1,5 @@
/* Compile a Java program.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "javacomp.h"

View File

@ -1,5 +1,5 @@
/* Execute a Java program.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "javaexec.h"

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
/* Copyright (C) 1992,1995-1999,2000-2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -19,7 +19,7 @@
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
#include <errno.h>
#if !_LIBC

View File

@ -1,3 +1,12 @@
2003-01-12 Bruno Haible <bruno@clisp.org>
* configure.in: Invoke gl_FUNC_ALLOCA instead of AC_FUNC_ALLOCA.
* alloca_.h: New file, from gnulib.
* liballoca.h: Remove file.
* Makefile.am: Add snippet from gnulib module alloca.
(lib_asprintf_EXTRASOURCES): Remove liballoca.h.
* vasnprintf.c: Include alloca.h instead of liballoca.h.
2003-01-12 Bruno Haible <bruno@clisp.org>
* Makefile.am: Make use of += for variables.

View File

@ -42,12 +42,23 @@ lib_asprintf_EXTRASOURCES = \
printf-args.h printf-args.c \
printf-parse.h printf-parse.c \
vasnprintf.h vasnprintf.c asnprintf.c \
vasprintf.h vasprintf.c asprintf.c \
liballoca.h
vasprintf.h vasprintf.c asprintf.c
lib-asprintf.lo: $(lib_asprintf_EXTRASOURCES)
EXTRA_DIST += $(lib_asprintf_EXTRASOURCES)
# >>> gnulib module alloca.
EXTRA_DIST += alloca_.h
# The following is needed in order to create an <alloca.h> when the system
# doesn't have one that works with the given compiler.
all-local $(lib_OBJECTS): @ALLOCA_H@
alloca.h: alloca_.h
cp $(srcdir)/alloca_.h alloca.h
MOSTLYCLEANFILES += alloca.h
# <<< gnulib module alloca.
# Documentation.
docdir = $(prefix)/doc/@PACKAGE@

View File

@ -1,5 +1,5 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2002 Free Software Foundation, Inc.
Copyright (C) 1995, 1999, 2001-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
@ -20,8 +20,19 @@
declarations. Thanks to AIX. Therefore we include it right after
"config.h", not later. */
#ifndef _LIBALLOCA_H
#define _LIBALLOCA_H
#ifndef _ALLOCA_H
#define _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.
*/
#ifdef __GNUC__
# ifndef alloca
@ -42,11 +53,11 @@
# ifdef __cplusplus
extern "C" void *alloca (unsigned int);
# else /* not __cplusplus */
void *alloca ();
extern void *alloca ();
# endif /* not __cplusplus */
# else /* not __hpux */
# ifndef alloca
char *alloca ();
extern char *alloca ();
# endif
# endif /* __hpux */
# endif
@ -54,4 +65,4 @@ char *alloca ();
# endif
#endif
#endif /* _LIBALLOCA_H */
#endif /* _ALLOCA_H */

View File

@ -37,7 +37,7 @@ AC_CHECK_TYPES(ptrdiff_t)
gt_TYPE_INTMAX_T
dnl Checks for library functions.
AC_FUNC_ALLOCA
gl_FUNC_ALLOCA
AC_CHECK_FUNCS([snprintf vasprintf])
dnl Check for tools needed for formatting the documentation.

View File

@ -26,7 +26,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "vasnprintf.h"

View File

@ -1,3 +1,9 @@
2003-01-12 Bruno Haible <bruno@clisp.org>
* onceonly.m4: New file, from gnulib.
* alloca.m4: New file, from gnulib.
* Makefile.am (EXTRA_DIST): Add them.
2003-01-12 Bruno Haible <bruno@clisp.org>
* wint_t.m4: New file.

View File

@ -4,14 +4,53 @@ aclocaldir = @aclocaldir@
aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 lcmessage.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
# Generate this list with
# find . -type f -name '*.m4' -printf '%f\n'|sort |fmt |tr '\012' @ \
# |sed 's/@$/%/;s/@/ \\@/g' |tr @% '\012\012'
# find . -type f -name '*.m4' -printf '%f\n' | sort | tr '\012' @ | sed 's/@$/%/;s/@/ \\@/g' | tr @% '\012\012'
EXTRA_DIST = README \
backupfile.m4 codeset.m4 error.m4 fixautomake.m4 flex.m4 fnmatch.m4 gcj.m4 \
getline.m4 gettext.m4 glibc21.m4 hostname.m4 iconv.m4 intdiv0.m4 intmax.m4 \
inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 javacomp.m4 \
javaexec.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 libtool.m4 \
longdouble.m4 longlong.m4 mbrtowc.m4 mbstate_t.m4 mbswidth.m4 mkdtemp.m4 \
progtest.m4 setenv.m4 setlocale.m4 siginfo.m4 signalblocking.m4 signed.m4 \
ssize_t.m4 stdbool.m4 stdint_h.m4 tmpdir.m4 uintmax_t.m4 ulonglong.m4 \
unionwait.m4 wchar_t.m4 wint_t.m4
alloca.m4 \
backupfile.m4 \
codeset.m4 \
error.m4 \
fixautomake.m4 \
flex.m4 \
fnmatch.m4 \
gcj.m4 \
getline.m4 \
gettext.m4 \
glibc21.m4 \
hostname.m4 \
iconv.m4 \
intdiv0.m4 \
intmax.m4 \
inttypes.m4 \
inttypes_h.m4 \
inttypes-pri.m4 \
isc-posix.m4 \
javacomp.m4 \
javaexec.m4 \
lcmessage.m4 \
lib-ld.m4 \
lib-link.m4 \
lib-prefix.m4 \
libtool.m4 \
longdouble.m4 \
longlong.m4 \
mbrtowc.m4 \
mbstate_t.m4 \
mbswidth.m4 \
mkdtemp.m4 \
onceonly.m4 \
progtest.m4 \
setenv.m4 \
setlocale.m4 \
siginfo.m4 \
signalblocking.m4 \
signed.m4 \
ssize_t.m4 \
stdbool.m4 \
stdint_h.m4 \
tmpdir.m4 \
uintmax_t.m4 \
ulonglong.m4 \
unionwait.m4 \
wchar_t.m4 \
wint_t.m4

36
m4/alloca.m4 Normal file
View File

@ -0,0 +1,36 @@
# alloca.m4 serial 2
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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)
])

View File

@ -1,3 +1,19 @@
2003-01-12 Bruno Haible <bruno@clisp.org>
* format-java.c: Include alloca.h instead of liballoca.h.
* msggrep.c: Likewise.
* msginit.c: Likewise.
* msgl-cat.c: Likewise.
* msgl-charset.c: Likewise.
* msgl-iconv.c: Likewise.
* msgmerge.c: Likewise.
* po-charset.c: Likewise.
* read-tcl.c: Likewise.
* write-java.c: Likewise.
* write-mo.c: Likewise.
* write-po.c: Likewise.
* write-tcl.c: Likewise.
2003-01-12 Bruno Haible <bruno@clisp.org>
* Makefile.am: Make use of += for variables.

View File

@ -1,5 +1,5 @@
/* Java format strings.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
#include <stdbool.h>
#include <stdlib.h>

View File

@ -1,5 +1,5 @@
/* Extract some translations of a translation catalog.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
#include <errno.h>
#include <getopt.h>
@ -286,7 +286,7 @@ main (int argc, char **argv)
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"),
"2001-2002");
"2001-2003");
printf (_("Written by %s.\n"), "Bruno Haible");
exit (EXIT_SUCCESS);
}

View File

@ -1,5 +1,5 @@
/* Initializes a new PO file.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
#include <errno.h>
#include <getopt.h>
@ -231,7 +231,7 @@ main (int argc, char **argv)
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"),
"2001-2002");
"2001-2003");
printf (_("Written by %s.\n"), "Bruno Haible");
exit (EXIT_SUCCESS);
}

View File

@ -1,5 +1,5 @@
/* Message list concatenation and duplicate handling.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "msgl-cat.h"

View File

@ -1,5 +1,5 @@
/* Message list charset and locale charset handling.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "msgl-charset.h"

View File

@ -1,5 +1,5 @@
/* Message list charset and locale charset handling.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "msgl-iconv.h"
@ -60,7 +60,7 @@ iconv_string (iconv_t cd, const char *start, const char *end,
size_t length;
char *result;
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
/* Set to the initial state. */
@ -117,7 +117,7 @@ iconv_string (iconv_t cd, const char *start, const char *end,
if (length == 0)
return 0;
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
/* Return to the initial state. */

View File

@ -1,5 +1,5 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
This program is free software; you can redistribute it and/or modify
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
#include <getopt.h>
#include <limits.h>
@ -261,7 +261,7 @@ main (int argc, char **argv)
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"),
"1995-1998, 2000-2002");
"1995-1998, 2000-2003");
printf (_("Written by %s.\n"), "Peter Miller");
exit (EXIT_SUCCESS);
}

View File

@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "po-charset.h"

View File

@ -1,5 +1,5 @@
/* Reading tcl/msgcat .msg files.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002-2003 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software; you can redistribute it and/or modify
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "read-tcl.h"

View File

@ -1,5 +1,5 @@
/* Writing Java ResourceBundles.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
Copyright (C) 2001-2003 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
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "write-java.h"

View File

@ -1,5 +1,5 @@
/* Writing binary .mo files.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
This program is free software; you can redistribute it and/or modify
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "write-mo.h"

View File

@ -20,7 +20,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "write-po.h"

View File

@ -1,5 +1,5 @@
/* Writing tcl/msgcat .msg files.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002-2003 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software; you can redistribute it and/or modify
@ -19,7 +19,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "liballoca.h"
#include <alloca.h>
/* Specification. */
#include "write-tcl.h"