summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/lib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/texinfo/lib')
-rw-r--r--contrib/texinfo/lib/README2
-rw-r--r--contrib/texinfo/lib/gettext.h17
-rw-r--r--contrib/texinfo/lib/substring.c10
-rw-r--r--contrib/texinfo/lib/system.h93
-rw-r--r--contrib/texinfo/lib/xalloc.h103
-rw-r--r--contrib/texinfo/lib/xexit.c7
-rw-r--r--contrib/texinfo/lib/xmalloc.c41
-rw-r--r--contrib/texinfo/lib/xstrdup.c13
8 files changed, 139 insertions, 147 deletions
diff --git a/contrib/texinfo/lib/README b/contrib/texinfo/lib/README
index 288bc5d..643f9c1 100644
--- a/contrib/texinfo/lib/README
+++ b/contrib/texinfo/lib/README
@@ -1,4 +1,4 @@
-$Id: README,v 1.2 2002/09/11 16:32:09 karl Exp $
+$Id: README,v 1.3 2004/04/11 17:56:46 karl Exp $
texinfo/lib/README
Copyright (C) 2002 Free Software Foundation, Inc.
diff --git a/contrib/texinfo/lib/gettext.h b/contrib/texinfo/lib/gettext.h
index 8b262f4..835732e 100644
--- a/contrib/texinfo/lib/gettext.h
+++ b/contrib/texinfo/lib/gettext.h
@@ -1,20 +1,19 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ 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 Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
diff --git a/contrib/texinfo/lib/substring.c b/contrib/texinfo/lib/substring.c
index 7d5cda7..9e59fce 100644
--- a/contrib/texinfo/lib/substring.c
+++ b/contrib/texinfo/lib/substring.c
@@ -1,7 +1,7 @@
/* substring.c -- extract substring.
- $Id: substring.c,v 1.1 2002/08/25 23:38:38 karl Exp $
+ $Id: substring.c,v 1.2 2004/04/11 17:56:46 karl Exp $
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004 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
@@ -20,13 +20,11 @@
#include "system.h"
char *
-substring (start, end)
- char *start;
- char *end;
+substring (const char *start, const char *end)
{
char *result = xmalloc (end - start + 1);
char *scan_result = result;
- char *scan = start;
+ const char *scan = start;
while (scan < end)
*scan_result++ = *scan++;
diff --git a/contrib/texinfo/lib/system.h b/contrib/texinfo/lib/system.h
index f2bbf22..946eb3c 100644
--- a/contrib/texinfo/lib/system.h
+++ b/contrib/texinfo/lib/system.h
@@ -1,7 +1,7 @@
/* system.h: system-dependent declarations; include this first.
- $Id: system.h,v 1.5 2003/03/22 17:40:39 karl Exp $
+ $Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp $
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -32,15 +32,11 @@
/* MiKTeX defines substring() in a separate DLL, where it has its
own __declspec declaration. We don't want to try to duplicate
this Microsoft-ism here. */
-extern char *substring ();
+extern char *substring (const char *, const char *);
#endif
-/* <unistd.h> should be included before any preprocessor test
- of _POSIX_VERSION. */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
+/* We follow the order of header inclusion from Autoconf's
+ ac_includes_default, more or less. */
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
@@ -61,10 +57,6 @@ extern char *substring ();
#define _(String) gettext (String)
#define N_(String) (String)
-#ifndef HAVE_LC_MESSAGES
-#define LC_MESSAGES (-1)
-#endif
-
#ifdef STDC_HEADERS
#define getopt system_getopt
#include <stdlib.h>
@@ -75,16 +67,34 @@ extern char *getenv ();
/* Don't use bcopy! Use memmove if source and destination may overlap,
memcpy otherwise. */
-#ifdef HAVE_STRING_H
+#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
-#else
+#endif
+
+#if HAVE_STRINGS_H
+/* Always include <strings.h> if we have it. This is because that's
+ what Autoconf's AC_CHECK_DECL does. On IBM AIX 4.2, strncasecmp is
+ only declared in strings.h. */
# include <strings.h>
+#endif
+
+#if !HAVE_STRNCASECMP || !HAVE_STRCASECMP
+# include "strcase.h"
+#endif
+
+#if !HAVE_DECL_MEMCHR
char *memchr ();
#endif
+/* <unistd.h> defines _POSIX_VERSION, but Paul Eggert points out that is
+ only supposed to be used in user code, not other system headers. */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
#include <errno.h>
#ifndef errno
extern int errno;
@@ -191,30 +201,41 @@ extern int strcoll ();
# define HAVE_LONG_FILENAMES(dir) (pathconf (dir, _PC_NAME_MAX) > 12)
# define NULL_DEVICE "/dev/null"
# define DEFAULT_INFOPATH "c:/djgpp/info;/usr/local/info;/usr/info;."
-# else /* !__DJGPP__ */
+ /* DJGPP supports /dev/null, which is okay for Unix aficionados,
+ shell scripts and Makefiles, but interactive DOS die-hards
+ would probably want to have NUL as well. */
+# define ALSO_NULL_DEVICE "NUL"
+# else /* O_BINARY && !__DJGPP__ */
# define HAVE_LONG_FILENAMES(dir) (0)
# define NULL_DEVICE "NUL"
-# endif /* !__DJGPP__ */
+# endif /* O_BINARY && !__DJGPP__ */
# define SET_SCREEN_SIZE_HELPER terminal_prep_terminal()
# define DEFAULT_INFO_PRINT_COMMAND ">PRN"
-# else /* !__MSDOS__ */
+# else /* O_BINARY && !__MSDOS__ */
# define setmode(f,m) _setmode(f,m)
# define HAVE_LONG_FILENAMES(dir) (1)
# define NULL_DEVICE "NUL"
-# endif /* !__MSDOS__ */
-# define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
+# endif /* O_BINARY && !__MSDOS__ */
+# ifdef __CYGWIN__
+# define DEFAULT_TMPDIR "/tmp/"
+# define PATH_SEP ":"
+# else /* O_BINARY && !__CYGWIN__ */
+# define DEFAULT_TMPDIR "c:/"
+# define PATH_SEP ";"
+# endif /* O_BINARY && !__CYGWIN__ */
+ /* Back to any O_BINARY system. */
+# define FILENAME_CMP strcasecmp
+# define FILENAME_CMPN strncasecmp
# define FOPEN_RBIN "rb"
# define FOPEN_WBIN "wb"
-# define IS_SLASH(c) ((c) == '/' || (c) == '\\')
# define HAVE_DRIVE(n) ((n)[0] && (n)[1] == ':')
+# define IS_SLASH(c) ((c) == '/' || (c) == '\\')
# define IS_ABSOLUTE(n) (IS_SLASH((n)[0]) || ((n)[0] && (n)[1] == ':'))
-# define FILENAME_CMP strcasecmp
-# define FILENAME_CMPN strncasecmp
-# define PATH_SEP ";"
-# define STRIP_DOT_EXE 1
-# define DEFAULT_TMPDIR "c:/"
# define PIPE_USE_FORK 0
-#else /* not O_BINARY */
+# define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0)
+# define STRIP_DOT_EXE 1
+
+#else /* not O_BINARY, i.e., Unix */
# define SET_BINARY(f) (void)0
# define FOPEN_RBIN "r"
# define FOPEN_WBIN "w"
@@ -235,12 +256,8 @@ extern int strcoll ();
# define PIPE_USE_FORK 1
#endif /* not O_BINARY */
-/* DJGPP supports /dev/null, which is okay for Unix aficionados,
- shell scripts and Makefiles, but interactive DOS die-hards
- would probably want to have NUL as well. */
-#ifdef __DJGPP__
-# define ALSO_NULL_DEVICE "NUL"
-#else
+/* Everything but DJGPP. */
+#ifndef ALSO_NULL_DEVICE
# define ALSO_NULL_DEVICE ""
#endif
@@ -248,15 +265,17 @@ extern int strcoll ();
#include <pwd.h>
#endif
/* Some systems don't declare this function in pwd.h. */
-struct passwd *getpwnam ();
+struct passwd *getpwnam (const char *name);
/* Our library routines not included in any system library. */
-extern void *xmalloc (), *xrealloc ();
-extern char *xstrdup ();
-extern void xexit ();
+extern void *xmalloc (size_t), *xrealloc (void *, size_t);
+extern char *xstrdup (const char *);
+extern void xexit (int);
/* For convenience. */
#define STREQ(s1,s2) (strcmp (s1, s2) == 0)
+#define STRCASEEQ(s1,s2) (strcasecmp (s1, s2) == 0)
+#define STRNCASEEQ(s1,s2,n) (strncasecmp (s1, s2, n) == 0)
/* We don't need anything fancy. If we did need something fancy, gnulib
has it. */
diff --git a/contrib/texinfo/lib/xalloc.h b/contrib/texinfo/lib/xalloc.h
index 5b623da..d81f2a6 100644
--- a/contrib/texinfo/lib/xalloc.h
+++ b/contrib/texinfo/lib/xalloc.h
@@ -1,5 +1,7 @@
/* xalloc.h -- malloc with out-of-memory checking
- Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2003, 2004 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
@@ -20,14 +22,12 @@
# include <stddef.h>
-# ifndef PARAMS
-# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
+
+# ifdef __cplusplus
+extern "C" {
# endif
+
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
@@ -38,52 +38,53 @@
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# endif
-/* Exit value when the requested amount of memory is not available.
- It is initialized to EXIT_FAILURE, but the caller may set it to
- some other value. */
-extern int xalloc_exit_failure;
-
-/* If this pointer is non-zero, run the specified function upon each
- allocation failure. It is initialized to zero. */
-extern void (*xalloc_fail_func) PARAMS ((void));
-
-/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
- message is output. It is translated via gettext.
- Its value is "memory exhausted". */
-extern char const xalloc_msg_memory_exhausted[];
-
-/* This function is always triggered when memory is exhausted. It is
- in charge of honoring the three previous items. This is the
+/* This function is always triggered when memory is exhausted.
+ It must be defined by the application, either explicitly
+ or by using gnulib's xalloc-die module. This is the
function to call when one wants the program to die because of a
memory allocation failure. */
-extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
-
-void *xmalloc PARAMS ((size_t n));
-void *xcalloc PARAMS ((size_t n, size_t s));
-void *xrealloc PARAMS ((void *p, size_t n));
-char *xstrdup PARAMS ((const char *str));
-
-# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
-# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
-# define XREALLOC(Ptr, Type, N_items) \
- ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
-
-/* Declare and alloc memory for VAR of type TYPE. */
-# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
-
-/* Free VAR only if non NULL. */
-# define XFREE(Var) \
- do { \
- if (Var) \
- free (Var); \
- } while (0)
-
-/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
-# define CCLONE(Src, Num) \
- (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
-
-/* Return a malloc'ed copy of SRC. */
-# define CLONE(Src) CCLONE (Src, 1)
+extern void xalloc_die (void) ATTRIBUTE_NORETURN;
+
+void *xmalloc (size_t s);
+void *xnmalloc (size_t n, size_t s);
+void *xzalloc (size_t s);
+void *xcalloc (size_t n, size_t s);
+void *xrealloc (void *p, size_t s);
+void *xnrealloc (void *p, size_t n, size_t s);
+void *x2realloc (void *p, size_t *pn);
+void *x2nrealloc (void *p, size_t *pn, size_t s);
+void *xclone (void const *p, size_t s);
+char *xstrdup (const char *str);
+
+/* 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))
+
+/* These macros are deprecated; they will go away soon, and are retained
+ temporarily only to ease conversion to the functions described above. */
+# define CCLONE(p, n) xclone (p, (n) * sizeof *(p))
+# define CLONE(p) xclone (p, sizeof *(p))
+# define NEW(type, var) type *var = xmalloc (sizeof (type))
+# define XCALLOC(type, n) xcalloc (n, sizeof (type))
+# define XMALLOC(type, n) xnmalloc (n, sizeof (type))
+# define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type))
+# define XFREE(p) free (p)
+
+
+# ifdef __cplusplus
+}
+# endif
#endif /* !XALLOC_H_ */
diff --git a/contrib/texinfo/lib/xexit.c b/contrib/texinfo/lib/xexit.c
index fa783b3..53eb0fc 100644
--- a/contrib/texinfo/lib/xexit.c
+++ b/contrib/texinfo/lib/xexit.c
@@ -1,7 +1,7 @@
/* xexit.c -- exit with attention to return values and closing stdout.
- $Id: xexit.c,v 1.4 2003/05/19 13:10:59 karl Exp $
+ $Id: xexit.c,v 1.5 2004/04/11 17:56:46 karl Exp $
- Copyright (C) 1999, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2004 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
@@ -47,8 +47,7 @@
unsuccessfully. */
void
-xexit (exit_status)
- int exit_status;
+xexit (int exit_status)
{
if (ferror (stdout))
{
diff --git a/contrib/texinfo/lib/xmalloc.c b/contrib/texinfo/lib/xmalloc.c
index 156989e..b91e4fc 100644
--- a/contrib/texinfo/lib/xmalloc.c
+++ b/contrib/texinfo/lib/xmalloc.c
@@ -1,12 +1,6 @@
-/* xmalloc.c -- safe versions of malloc and realloc */
+/* xmalloc.c -- safe versions of malloc and realloc.
-/* This file is part of GNU Info, a program for reading online documentation
- stored in Info format.
-
- This file has appeared in prior works by the Free Software Foundation;
- thus it carries copyright dates from 1988 through 1993.
-
- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993 Free Software
+ Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -26,24 +20,20 @@
Written by Brian Fox (bfox@ai.mit.edu). */
#if !defined (ALREADY_HAVE_XMALLOC)
-#include <stdio.h>
-#include <sys/types.h>
+#include "system.h"
-extern void *malloc (), *realloc ();
-static void memory_error_and_abort ();
-
-/* **************************************************************** */
-/* */
-/* Memory Allocation and Deallocation. */
-/* */
-/* **************************************************************** */
+static void
+memory_error_and_abort (const char *fname)
+{
+ fprintf (stderr, "%s: Out of virtual memory!\n", fname);
+ abort ();
+}
/* Return a pointer to free()able block of memory large enough
to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */
void *
-xmalloc (bytes)
- int bytes;
+xmalloc (size_t bytes)
{
void *temp = malloc (bytes);
@@ -53,9 +43,7 @@ xmalloc (bytes)
}
void *
-xrealloc (pointer, bytes)
- void *pointer;
- int bytes;
+xrealloc (void *pointer, size_t bytes)
{
void *temp;
@@ -70,11 +58,4 @@ xrealloc (pointer, bytes)
return (temp);
}
-static void
-memory_error_and_abort (fname)
- char *fname;
-{
- fprintf (stderr, "%s: Out of virtual memory!\n", fname);
- abort ();
-}
#endif /* !ALREADY_HAVE_XMALLOC */
diff --git a/contrib/texinfo/lib/xstrdup.c b/contrib/texinfo/lib/xstrdup.c
index cb1efa8..1182c59 100644
--- a/contrib/texinfo/lib/xstrdup.c
+++ b/contrib/texinfo/lib/xstrdup.c
@@ -1,5 +1,5 @@
/* xstrdup.c -- copy a string with out of memory checking
- Copyright (C) 1990, 1996, 1998, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1996, 1998, 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 General Public License as published by
@@ -19,16 +19,11 @@
# include <config.h>
#endif
-#if STDC_HEADERS || HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-
-#include <sys/types.h>
-
+/* Specification. */
#include "xalloc.h"
+#include <string.h>
+
/* Return a newly allocated copy of STRING. */
char *
OpenPOWER on IntegriCloud