summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/lib
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-03-25 13:08:32 +0000
committerru <ru@FreeBSD.org>2002-03-25 13:08:32 +0000
commit5500b59c459afe212e4ee8d1c1847e051a9b7653 (patch)
treea83aebd48e0338a00136e68cbd70a1ef081175fc /contrib/texinfo/lib
parent05f7b4b96773cc26ff78d5e68babd66861aa07a8 (diff)
downloadFreeBSD-src-5500b59c459afe212e4ee8d1c1847e051a9b7653.zip
FreeBSD-src-5500b59c459afe212e4ee8d1c1847e051a9b7653.tar.gz
Import of stripped down GNU texinfo 4.1
Diffstat (limited to 'contrib/texinfo/lib')
-rw-r--r--contrib/texinfo/lib/getopt.c51
-rw-r--r--contrib/texinfo/lib/getopt.h84
-rw-r--r--contrib/texinfo/lib/getopt1.c14
-rw-r--r--contrib/texinfo/lib/gettext.h74
-rw-r--r--contrib/texinfo/lib/system.h55
-rw-r--r--contrib/texinfo/lib/xstrdup.c24
6 files changed, 228 insertions, 74 deletions
diff --git a/contrib/texinfo/lib/getopt.c b/contrib/texinfo/lib/getopt.c
index 03effcb..d176d3e 100644
--- a/contrib/texinfo/lib/getopt.c
+++ b/contrib/texinfo/lib/getopt.c
@@ -1,14 +1,10 @@
/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to drepper@gnu.org
- before changing it!
+ NOTE: The canonical source of this file is maintained with the GNU
+ C Library. Bugs can be reported to bug-glibc@gnu.org.
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
Free Software Foundation, Inc.
- NOTE: The canonical source of this file is maintained with the GNU C Library.
- Bugs can be reported to bug-glibc@gnu.org.
-
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
@@ -20,9 +16,8 @@
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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
@@ -32,13 +27,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
-#endif
-
-#if !defined __STDC__ || !__STDC__
+#else
+# if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
-# ifndef const
-# define const
+# ifndef const
+# define const
+# endif
# endif
#endif
@@ -112,7 +107,7 @@
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
-char *optarg = NULL;
+char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@@ -133,7 +128,7 @@ int optind = 1;
causes problems with re-calling getopt as programs generally don't
know that. */
-int __getopt_initialized = 0;
+int __getopt_initialized;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
@@ -698,16 +693,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
+ {
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ _("%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ _("%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0], pfound->name);
+ }
nextchar += strlen (nextchar);
diff --git a/contrib/texinfo/lib/getopt.h b/contrib/texinfo/lib/getopt.h
index fb30719..ac6728f 100644
--- a/contrib/texinfo/lib/getopt.h
+++ b/contrib/texinfo/lib/getopt.h
@@ -1,9 +1,7 @@
/* Declarations for getopt.
- Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
-
+ Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
-
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
@@ -20,7 +18,10 @@
USA. */
#ifndef _GETOPT_H
-#define _GETOPT_H 1
+
+#ifndef __need_getopt
+# define _GETOPT_H 1
+#endif
#ifdef __cplusplus
extern "C" {
@@ -57,6 +58,7 @@ extern int opterr;
extern int optopt;
+#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
@@ -80,11 +82,11 @@ extern int optopt;
struct option
{
-#if defined (__STDC__) && __STDC__
+# if defined __STDC__ && __STDC__
const char *name;
-#else
+# else
char *name;
-#endif
+# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
@@ -94,40 +96,74 @@ struct option
/* Names for the values of the `has_arg' field of `struct option'. */
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
+# define no_argument 0
+# define required_argument 1
+# define optional_argument 2
+#endif /* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+ arguments in ARGV (ARGC of them, minus the program name) for
+ options given in OPTS.
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
+ Return the option character from OPTS just read. Return -1 when
+ there are no more options. For unrecognized options, or options
+ missing arguments, `optopt' is set to the option letter, and '?' is
+ returned.
+
+ The OPTS string is a list of characters which are recognized option
+ letters, optionally followed by colons, specifying that that letter
+ takes an argument, to be placed in `optarg'.
+
+ If a letter in OPTS is followed by two colons, its argument is
+ optional. This behavior is specific to the GNU `getopt'.
+
+ The argument `--' causes premature termination of argument
+ scanning, explicitly telling `getopt' that there are no more
+ options.
+
+ If OPTS begins with `--', then non-option arguments are treated as
+ arguments to the option '\0'. This behavior is specific to the GNU
+ `getopt'. */
+
+#if defined __STDC__ && __STDC__
+# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
+extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
+# else /* not __GNU_LIBRARY__ */
extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
+# endif /* __GNU_LIBRARY__ */
+
+# ifndef __need_getopt
+extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
+ const struct option *__longopts, int *__longind);
+extern int getopt_long_only (int __argc, char *const *__argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
+extern int _getopt_internal (int __argc, char *const *__argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only);
+# endif
#else /* not __STDC__ */
extern int getopt ();
+# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
+# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
+/* Make sure we later can get all the definitions and declarations. */
+#undef __need_getopt
+
#endif /* getopt.h */
diff --git a/contrib/texinfo/lib/getopt1.c b/contrib/texinfo/lib/getopt1.c
index ff25737..9c82565 100644
--- a/contrib/texinfo/lib/getopt1.c
+++ b/contrib/texinfo/lib/getopt1.c
@@ -1,7 +1,6 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
-
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@@ -16,16 +15,12 @@
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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
-#include "getopt.h"
-
+#else
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
@@ -33,6 +28,9 @@
#define const
#endif
#endif
+#endif
+
+#include "getopt.h"
#include <stdio.h>
diff --git a/contrib/texinfo/lib/gettext.h b/contrib/texinfo/lib/gettext.h
new file mode 100644
index 0000000..4ab74d9
--- /dev/null
+++ b/contrib/texinfo/lib/gettext.h
@@ -0,0 +1,74 @@
+/* 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)
+ 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.
+
+ 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. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+#else
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+#if 0
+/* no thanks, not ready to go const --karl, 26feb02 */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+#else /* not 0 */
+# define gettext(Msgid) ((Msgid))
+# define dgettext(Domainname, Msgid) (Msgid)
+# define dcgettext(Domainname, Msgid, Category) (Msgid)
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 ? (Msgid1) : (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((N) == 1 ? (Msgid1) : (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((N) == 1 ? (Msgid1) : (Msgid2))
+# define textdomain(Domainname) (Domainname)
+# define bindtextdomain(Domainname, Dirname) (Dirname)
+# define bind_textdomain_codeset(Domainname, Codeset) (Codeset)
+#endif /* 0 */
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+#endif /* _LIBGETTEXT_H */
diff --git a/contrib/texinfo/lib/system.h b/contrib/texinfo/lib/system.h
index 4ca1837..a816553 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.14 1999/07/17 21:11:34 karl Exp $
+ $Id: system.h,v 1.22 2002/02/26 14:31:18 karl Exp $
- Copyright (C) 1997, 98, 99 Free Software Foundation, Inc.
+ Copyright (C) 1997, 98, 99, 00, 01, 02 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
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <ctype.h>
+/* All systems nowadays probably have these functions, but ... */
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
@@ -42,10 +43,14 @@
#endif
/* For gettext (NLS). */
-#include <libintl.h>
+#include "gettext.h"
#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>
@@ -78,6 +83,16 @@ extern int errno;
extern char *strerror ();
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifndef PATH_MAX
+#ifndef _POSIX_PATH_MAX
+# define _POSIX_PATH_MAX 255
+#endif
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+
#ifndef HAVE_DECL_STRCASECMP
extern int strcasecmp ();
#endif
@@ -123,7 +138,6 @@ extern int strcoll ();
- directories in environment variables (like INFOPATH) are separated
by `;' rather than `:';
- text files can have their lines ended either with \n or with \r\n pairs;
-
These are all parameterized here except the last, which is
handled by the source code as appropriate (mostly, in info/). */
#ifndef O_BINARY
@@ -134,13 +148,35 @@ extern int strcoll ();
# endif
#endif /* O_BINARY */
+/* We'd like to take advantage of _doprnt if it's around, a la error.c,
+ but then we'd have no VA_SPRINTF. */
+#if HAVE_VPRINTF
+# if __STDC__
+# include <stdarg.h>
+# define VA_START(args, lastarg) va_start(args, lastarg)
+# else
+# include <varargs.h>
+# define VA_START(args, lastarg) va_start(args)
+# endif
+# define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap)
+# define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap)
+#else /* not HAVE_VPRINTF */
+# define VA_START(args, lastarg)
+# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
+# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
+# define va_end(args)
+#endif
+
#if O_BINARY
-# include <io.h>
+# ifdef HAVE_IO_H
+# include <io.h>
+# endif
# ifdef __MSDOS__
# include <limits.h>
# ifdef __DJGPP__
# 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__ */
# define HAVE_LONG_FILENAMES(dir) (0)
# define NULL_DEVICE "NUL"
@@ -185,6 +221,15 @@ 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
+# define ALSO_NULL_DEVICE ""
+#endif
+
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
diff --git a/contrib/texinfo/lib/xstrdup.c b/contrib/texinfo/lib/xstrdup.c
index d5bcaf3..38674ca 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 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1996, 1998 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,24 +19,28 @@
# include <config.h>
#endif
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
+#ifndef PARAMS
+# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
+# define PARAMS(Args) Args
+# else
+# define PARAMS(Args) ()
+# endif
+#endif
+
+#if STDC_HEADERS || HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
-#if defined (__STDC__) && __STDC__
-char *xmalloc (size_t);
-char *xstrdup (char *string);
-#else
-char *xmalloc ();
-#endif
+#include <sys/types.h>
+
+char *xmalloc PARAMS ((size_t n));
/* Return a newly allocated copy of STRING. */
char *
-xstrdup (string)
- char *string;
+xstrdup (const char *string)
{
return strcpy (xmalloc (strlen (string) + 1), string);
}
OpenPOWER on IntegriCloud