[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5196] Allow makeinfo in C to be built again.
From: |
Patrice Dumas |
Subject: |
[5196] Allow makeinfo in C to be built again. |
Date: |
Sat, 23 Feb 2013 11:41:58 +0000 |
Revision: 5196
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5196
Author: pertusus
Date: 2013-02-23 11:41:56 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
Allow makeinfo in C to be built again.
Modified Paths:
--------------
trunk/makeinfo/Makefile.am
Added Paths:
-----------
trunk/makeinfo/substring.c
trunk/makeinfo/xexit.c
trunk/makeinfo/xsetenv.c
trunk/makeinfo/xsetenv.h
Modified: trunk/makeinfo/Makefile.am
===================================================================
--- trunk/makeinfo/Makefile.am 2013-02-23 09:53:52 UTC (rev 5195)
+++ trunk/makeinfo/Makefile.am 2013-02-23 11:41:56 UTC (rev 5196)
@@ -28,7 +28,8 @@
files.c files.h float.c float.h footnote.c footnote.h \
html.c html.h index.c index.h insertion.c insertion.h lang.c lang.h \
macro.c macro.h makeinfo.c makeinfo.h multi.c multi.h node.c node.h \
- sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h
+ sectioning.c sectioning.h toc.c toc.h xml.c xml.h xref.c xref.h \
+ substring.c xexit.c xsetenv.c xsetenv.h
EXTRA_DIST = README
Added: trunk/makeinfo/substring.c
===================================================================
--- trunk/makeinfo/substring.c (rev 0)
+++ trunk/makeinfo/substring.c 2013-02-23 11:41:56 UTC (rev 5196)
@@ -0,0 +1,34 @@
+/* substring.c -- extract substring.
+ $Id: substring.c,v 1.5 2007/07/01 21:20:31 karl Exp $
+
+ Copyright (C) 1999, 2004, 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 "system.h"
+
+char *
+substring (const char *start, const char *end)
+{
+ char *result = xmalloc (end - start + 1);
+ char *scan_result = result;
+ const char *scan = start;
+
+ while (scan < end)
+ *scan_result++ = *scan++;
+
+ *scan_result = 0;
+ return result;
+}
+
Added: trunk/makeinfo/xexit.c
===================================================================
--- trunk/makeinfo/xexit.c (rev 0)
+++ trunk/makeinfo/xexit.c 2013-02-23 11:41:56 UTC (rev 5196)
@@ -0,0 +1,87 @@
+/* xexit.c -- exit with attention to return values and closing stdout.
+ $Id: xexit.c,v 1.8 2007/07/01 21:20:31 karl Exp $
+
+ Copyright (C) 1999, 2003, 2004, 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 "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 (therefore, xexit should be
+ called to exit every program, not just `return' from main).
+ Otherwise, if EXIT_STATUS is zero, exit successfully, else
+ unsuccessfully. */
+
+void
+xexit (int exit_status)
+{
+ if (ferror (stdout))
+ {
+ fputs (_("ferror on stdout\n"), stderr);
+ exit_status = 1;
+ }
+ else if (fflush (stdout) != 0)
+ {
+ fputs (_("fflush error on stdout\n"), stderr);
+ 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. */
Added: trunk/makeinfo/xsetenv.c
===================================================================
--- trunk/makeinfo/xsetenv.c (rev 0)
+++ trunk/makeinfo/xsetenv.c 2013-02-23 11:41:56 UTC (rev 5196)
@@ -0,0 +1,38 @@
+/* Setting environment variables, with out-of-memory checking.
+ Copyright (C) 2001-2002, 2005-2007, 2009-2013 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 "xsetenv.h"
+
+#include <stdlib.h>
+
+#include "error.h"
+#include "gettext.h"
+
+#define _(str) gettext (str)
+
+
+/* Set NAME to VALUE in the environment.
+ If REPLACE is nonzero, overwrite an existing value.
+ With error checking. */
+void
+xsetenv (const char *name, const char *value, int replace)
+{
+ if (setenv (name, value, replace) < 0)
+ error (EXIT_FAILURE, 0, _("memory exhausted"));
+}
Added: trunk/makeinfo/xsetenv.h
===================================================================
--- trunk/makeinfo/xsetenv.h (rev 0)
+++ trunk/makeinfo/xsetenv.h 2013-02-23 11:41:56 UTC (rev 5196)
@@ -0,0 +1,31 @@
+/* Setting environment variables, with out-of-memory checking.
+ Copyright (C) 2001-2002, 2007, 2009-2013 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/>. */
+
+/* Get unsetenv(). It can be used without error checking. */
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Set NAME to VALUE in the environment.
+ If REPLACE is nonzero, overwrite an existing value.
+ With error checking. */
+extern void xsetenv (const char *name, const char *value, int replace);
+
+#ifdef __cplusplus
+}
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5196] Allow makeinfo in C to be built again.,
Patrice Dumas <=