diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-02-09 01:27:25 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-02-09 01:27:25 +0000 |
commit | 328f35a635ee7b14c4d6f2dbddacba138e62219b (patch) | |
tree | 5f0effaeb304116c7826d814dfa001d501a3b10a /gnu/usr.bin/texinfo/lib | |
parent | c2daa957909e4243f84a2232ff4a481b6c44a393 (diff) |
TexInfo 4.0. New manpages, can create html.
A bit more grumpy about bad texinfo, though.
Diffstat (limited to 'gnu/usr.bin/texinfo/lib')
-rw-r--r-- | gnu/usr.bin/texinfo/lib/getopt.c | 82 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/getopt.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/getopt1.c | 9 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/strcasecmp.c | 49 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/strncasecmp.c | 48 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/substring.c | 37 | ||||
-rw-r--r-- | gnu/usr.bin/texinfo/lib/xexit.c | 86 |
7 files changed, 271 insertions, 42 deletions
diff --git a/gnu/usr.bin/texinfo/lib/getopt.c b/gnu/usr.bin/texinfo/lib/getopt.c index fc87ce67d69..03effcbdb3e 100644 --- a/gnu/usr.bin/texinfo/lib/getopt.c +++ b/gnu/usr.bin/texinfo/lib/getopt.c @@ -1,13 +1,13 @@ /* 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 roland@gnu.ai.mit.edu + "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 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@prep.ai.mit.edu. + 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 @@ -27,19 +27,19 @@ /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. Ditto for AIX 3.2 and <stdlib.h>. */ #ifndef _NO_PROTO -#define _NO_PROTO +# define _NO_PROTO #endif #ifdef HAVE_CONFIG_H -#include <config.h> +# include <config.h> #endif -#if !defined (__STDC__) || !__STDC__ +#if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ -#ifndef const -#define const -#endif +# ifndef const +# define const +# endif #endif #include <stdio.h> @@ -53,11 +53,11 @@ it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 -#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include <gnu-versions.h> +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif #endif #ifndef ELIDE_CODE @@ -68,26 +68,26 @@ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ -#include <stdlib.h> -#include <unistd.h> +# include <stdlib.h> +# include <unistd.h> #endif /* GNU C library. */ #ifdef VMS -#include <unixlib.h> -#if HAVE_STRING_H - 0 -#include <string.h> -#endif +# include <unixlib.h> +# if HAVE_STRING_H - 0 +# include <string.h> +# endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ -#ifdef HAVE_LIBINTL_H -# include <libintl.h> -# define _(msgid) gettext (msgid) -#else -# define _(msgid) (msgid) -#endif +# ifdef HAVE_LIBINTL_H +# include <libintl.h> +# define _(msgid) gettext (msgid) +# else +# define _(msgid) (msgid) +# endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' @@ -197,14 +197,22 @@ static char *posixly_correct; because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ -#include <string.h> -#define my_index strchr +# include <string.h> +# define my_index strchr #else +# if HAVE_STRING_H +# include <string.h> +# else +# include <strings.h> +# endif + /* Avoid depending on library functions or files whose names are inconsistent. */ -char *getenv (); +#ifndef getenv +extern char *getenv (); +#endif static char * my_index (str, chr) @@ -225,11 +233,11 @@ my_index (str, chr) #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ -#if !defined (__STDC__) || !__STDC__ +# if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); -#endif /* not __STDC__ */ +# endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ @@ -292,7 +300,7 @@ text_set_element (__libc_subinit, store_args_and_env); `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ -#if defined (__STDC__) && __STDC__ +#if defined __STDC__ && __STDC__ static void exchange (char **); #endif @@ -378,7 +386,7 @@ exchange (argv) /* Initialize the internal data when the first call is made. */ -#if defined (__STDC__) && __STDC__ +#if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * @@ -527,11 +535,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) #else -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') diff --git a/gnu/usr.bin/texinfo/lib/getopt.h b/gnu/usr.bin/texinfo/lib/getopt.h index c4adc30bbba..fb30719a860 100644 --- a/gnu/usr.bin/texinfo/lib/getopt.h +++ b/gnu/usr.bin/texinfo/lib/getopt.h @@ -2,7 +2,7 @@ Copyright (C) 1989,90,91,92,93,94,96,97 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@prep.ai.mit.edu. + 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 diff --git a/gnu/usr.bin/texinfo/lib/getopt1.c b/gnu/usr.bin/texinfo/lib/getopt1.c index af8e6819657..ff257374c33 100644 --- a/gnu/usr.bin/texinfo/lib/getopt1.c +++ b/gnu/usr.bin/texinfo/lib/getopt1.c @@ -1,8 +1,9 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. + 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@prep.ai.mit.edu. + 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 @@ -25,7 +26,7 @@ #include "getopt.h" -#if !defined (__STDC__) || !__STDC__ +#if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const @@ -44,7 +45,7 @@ it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 -#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include <gnu-versions.h> #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE diff --git a/gnu/usr.bin/texinfo/lib/strcasecmp.c b/gnu/usr.bin/texinfo/lib/strcasecmp.c new file mode 100644 index 00000000000..366bcf2e9c2 --- /dev/null +++ b/gnu/usr.bin/texinfo/lib/strcasecmp.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991, 1992 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 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 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. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <string.h> +#include <ctype.h> + +/* Compare S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexiographically less than, + equal to or greater than S2. */ +int +strcasecmp (s1, s2) + const char *s1; + const char *s2; +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = tolower (*p1++); + c2 = tolower (*p2++); + if (c1 == '\0') + break; + } + while (c1 == c2); + + return c1 - c2; +} diff --git a/gnu/usr.bin/texinfo/lib/strncasecmp.c b/gnu/usr.bin/texinfo/lib/strncasecmp.c new file mode 100644 index 00000000000..2476fad55ee --- /dev/null +++ b/gnu/usr.bin/texinfo/lib/strncasecmp.c @@ -0,0 +1,48 @@ +/* strncase.c -- compare at most N characters of two strings without + taking care for the case +Copyright (C) 1992 Free Software Foundation. + +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 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. */ + +#include <string.h> +#include <ctype.h> + +/* Compare no more than N characters of S1 and S2, + ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less + than, equal to or greater than S2. */ +int +strncasecmp (s1, s2, n) + const char *s1; + const char *s2; + size_t n; +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2 || n == 0) + return 0; + + do + { + c1 = tolower (*p1++); + c2 = tolower (*p2++); + if (c1 == '\0' || c1 != c2) + return c1 - c2; + } while (--n > 0); + + return c1 - c2; +} diff --git a/gnu/usr.bin/texinfo/lib/substring.c b/gnu/usr.bin/texinfo/lib/substring.c new file mode 100644 index 00000000000..64772334de5 --- /dev/null +++ b/gnu/usr.bin/texinfo/lib/substring.c @@ -0,0 +1,37 @@ +/* substring.c -- extract substring. + $Id: substring.c,v 1.1.1.1 2000/02/09 01:24:23 espie Exp $ + + Copyright (C) 1999 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 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 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. */ + +#include "system.h" + +char * +substring (start, end) + char *start; + char *end; +{ + char *result = xmalloc (end - start + 1); + char *scan_result = result; + char *scan = start; + + while (scan < end) + *scan_result++ = *scan++; + + *scan_result = 0; + return result; +} + diff --git a/gnu/usr.bin/texinfo/lib/xexit.c b/gnu/usr.bin/texinfo/lib/xexit.c new file mode 100644 index 00000000000..a9376f57cfa --- /dev/null +++ b/gnu/usr.bin/texinfo/lib/xexit.c @@ -0,0 +1,86 @@ +/* xexit.c -- exit with attention to return values and closing stdout. + $Id: xexit.c,v 1.1.1.1 2000/02/09 01:24:24 espie Exp $ + + Copyright (C) 1999 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 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 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. */ + +#include "system.h" + +/* SunOS 4.1.1 gets STDC_HEADERS defined, but it doesn't provide + EXIT_FAILURE. So far no system has defined one of EXIT_FAILURE and + EXIT_SUCCESS without the other. */ +#ifdef EXIT_SUCCESS + /* The following test is to work around the gross typo in + systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE + is defined to 0, not 1. */ +# if !EXIT_FAILURE +# undef EXIT_FAILURE +# define EXIT_FAILURE 1 +# endif +#else /* not EXIT_SUCCESS */ +# ifdef VMS /* these values suppress some messages; from gnuplot */ +# define EXIT_SUCCESS 1 +# define EXIT_FAILURE 0x10000002 +# else /* not VMS */ +# define EXIT_SUCCESS 0 +# define EXIT_FAILURE 1 +# endif /* not VMS */ +#endif /* not EXIT_SUCCESS */ + + +/* Flush stdout first, exit if failure. Otherwise, if EXIT_STATUS is + zero, exit successfully, else unsuccessfully. */ + +void +xexit (exit_status) + int exit_status; +{ + if (ferror (stdout)) + { + fprintf (stderr, "ferror on stdout"); + exit_status = 1; + } + else if (fflush (stdout) != 0) + { + fprintf (stderr, "fflush error on stdout"); + exit_status = 1; + } + + exit_status = exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + + exit (exit_status); +} + + +/* Why do we care about stdout you may ask? Here's why, from Jim + Meyering in the lib/closeout.c file. */ + +/* If a program writes *anything* to stdout, that program should close + stdout and make sure that the close succeeds. Otherwise, suppose that + you go to the extreme of checking the return status of every function + that does an explicit write to stdout. The last printf can succeed in + writing to the internal stream buffer, and yet the fclose(stdout) could + still fail (due e.g., to a disk full error) when it tries to write + out that buffered data. Thus, you would be left with an incomplete + output file and the offending program would exit successfully. + + Besides, it's wasteful to check the return value from every call + that writes to stdout -- just let the internal stream state record + the failure. That's what the ferror test is checking below. + + It's important to detect such failures and exit nonzero because many + tools (most notably `make' and other build-management systems) depend + on being able to detect failure in other tools via their exit status. */ |