summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gettext-runtime/lib/ChangeLog8
-rw-r--r--gettext-runtime/lib/Makefile.am1
-rw-r--r--gettext-runtime/lib/Makefile.msvc5
-rw-r--r--gettext-runtime/lib/Makefile.vms5
-rw-r--r--gettext-runtime/src/ChangeLog8
-rw-r--r--gettext-runtime/src/gettext.c4
-rw-r--r--gettext-runtime/src/ngettext.c4
-rw-r--r--gettext-tools/ChangeLog4
-rw-r--r--gettext-tools/lib/ChangeLog10
-rw-r--r--gettext-tools/lib/Makefile.am1
-rw-r--r--gettext-tools/lib/Makefile.msvc4
-rw-r--r--gettext-tools/lib/Makefile.vms4
-rw-r--r--gettext-tools/lib/closeout.c97
-rw-r--r--gettext-tools/lib/closeout.h31
-rw-r--r--gettext-tools/src/ChangeLog39
-rw-r--r--gettext-tools/src/hostname.c4
-rw-r--r--gettext-tools/src/msgattrib.c4
-rw-r--r--gettext-tools/src/msgcat.c4
-rw-r--r--gettext-tools/src/msgcmp.c4
-rw-r--r--gettext-tools/src/msgcomm.c4
-rw-r--r--gettext-tools/src/msgconv.c4
-rw-r--r--gettext-tools/src/msgen.c4
-rw-r--r--gettext-tools/src/msgexec.c4
-rw-r--r--gettext-tools/src/msgfilter.c4
-rw-r--r--gettext-tools/src/msgfmt.c4
-rw-r--r--gettext-tools/src/msggrep.c4
-rw-r--r--gettext-tools/src/msginit.c4
-rw-r--r--gettext-tools/src/msgmerge.c4
-rw-r--r--gettext-tools/src/msgunfmt.c4
-rw-r--r--gettext-tools/src/msguniq.c4
-rw-r--r--gettext-tools/src/urlget.c4
-rw-r--r--gettext-tools/src/write-po.c4
-rw-r--r--gettext-tools/src/xgettext.c4
-rw-r--r--gettext-tools/tests/ChangeLog8
-rw-r--r--gettext-tools/tests/tstgettext.c4
-rw-r--r--gettext-tools/tests/tstngettext.c4
-rw-r--r--gettext-tools/windows/gettextlib.def1
37 files changed, 311 insertions, 3 deletions
diff --git a/gettext-runtime/lib/ChangeLog b/gettext-runtime/lib/ChangeLog
index ef75ef9..2432f58 100644
--- a/gettext-runtime/lib/ChangeLog
+++ b/gettext-runtime/lib/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ * Makefile.am (libgrt_a_SOURCES): Add closeout.h, closeout.c.
+ * Makefile.msvc (OBJECTS): Add closeout.obj.
+ (closeout.obj): New rule.
+ * Makefile.vms (OBJECTS): Add closeout.obj.
+ (closeout.obj): New rule.
+
2003-07-01 Bruno Haible <bruno@clisp.org>
* readlink.c: New file, trivial link to ../../gettext-tools/lib.
diff --git a/gettext-runtime/lib/Makefile.am b/gettext-runtime/lib/Makefile.am
index 0a584e2..8078a35 100644
--- a/gettext-runtime/lib/Makefile.am
+++ b/gettext-runtime/lib/Makefile.am
@@ -27,6 +27,7 @@ noinst_LIBRARIES = libgrt.a
libgrt_a_SOURCES = \
../../gettext-tools/lib/basename.h ../../gettext-tools/lib/basename.c \
+ ../../gettext-tools/lib/closeout.h ../../gettext-tools/lib/closeout.c \
../../gettext-tools/lib/error.h ../../gettext-tools/lib/error.c \
../../gettext-tools/lib/exit.h \
../../gettext-tools/lib/getopt.h ../../gettext-tools/lib/getopt.c ../../gettext-tools/lib/getopt1.c \
diff --git a/gettext-runtime/lib/Makefile.msvc b/gettext-runtime/lib/Makefile.msvc
index 421e41f..01dcb3b 100644
--- a/gettext-runtime/lib/Makefile.msvc
+++ b/gettext-runtime/lib/Makefile.msvc
@@ -52,13 +52,16 @@ RM = -del
SHELL = /bin/sh
-OBJECTS = basename.obj error.obj getopt.obj getopt1.obj progname.obj progreloc.obj relocatable.obj xmalloc.obj xstrdup.obj
+OBJECTS = basename.obj closeout.obj error.obj getopt.obj getopt1.obj progname.obj progreloc.obj relocatable.obj xmalloc.obj xstrdup.obj
all : grt.lib
basename.obj : ..\..\gettext-tools\lib\basename.c
$(CC) $(INCLUDES) $(CFLAGS) -c ..\..\gettext-tools\lib\basename.c
+closeout.obj : ..\..\gettext-tools\lib\closeout.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c ..\..\gettext-tools\lib\closeout.c
+
error.obj : ..\..\gettext-tools\lib\error.c
$(CC) $(INCLUDES) $(CFLAGS) -c ..\..\gettext-tools\lib\error.c
diff --git a/gettext-runtime/lib/Makefile.vms b/gettext-runtime/lib/Makefile.vms
index 26b3ec8..af9d560 100644
--- a/gettext-runtime/lib/Makefile.vms
+++ b/gettext-runtime/lib/Makefile.vms
@@ -27,7 +27,7 @@ RM = delete
#### End of system configuration section. ####
-OBJECTS = basename.obj,error.obj,getopt.obj,getopt1.obj,progname.obj,progreloc.obj,relocatable.obj,xmalloc.obj,xstrdup.obj
+OBJECTS = basename.obj,closeout.obj,error.obj,getopt.obj,getopt1.obj,progname.obj,progreloc.obj,relocatable.obj,xmalloc.obj,xstrdup.obj
all : grt.olb
write sys$output "Nothing else to be done for 'all'."
@@ -35,6 +35,9 @@ all : grt.olb
basename.obj : [-.-.gettext-tools.lib]basename.c
$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) [-.-.gettext-tools.lib]basename.c
+closeout.obj : [-.-.gettext-tools.lib]closeout.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) [-.-.gettext-tools.lib]closeout.c
+
error.obj : [-.-.gettext-tools.lib]error.c
$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) [-.-.gettext-tools.lib]error.c
diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog
index 0ebba3a..aa834ed 100644
--- a/gettext-runtime/src/ChangeLog
+++ b/gettext-runtime/src/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ Fix behaviour of "<program> --help > /dev/full".
+ * gettext.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * ngettext.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+
2003-06-08 Bruno Haible <bruno@clisp.org>
* Makefile.vms (LDADD): Take options from .opt files.
diff --git a/gettext-runtime/src/gettext.c b/gettext-runtime/src/gettext.c
index b39daa5..7a6fa51 100644
--- a/gettext-runtime/src/gettext.c
+++ b/gettext-runtime/src/gettext.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <locale.h>
+#include "closeout.h"
#include "error.h"
#include "progname.h"
#include "relocatable.h"
@@ -89,6 +90,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Parse command line options. */
while ((optchar = getopt_long (argc, argv, "+d:eEhnsV", long_options, NULL))
!= EOF)
diff --git a/gettext-runtime/src/ngettext.c b/gettext-runtime/src/ngettext.c
index 654a347..8e6b03f 100644
--- a/gettext-runtime/src/ngettext.c
+++ b/gettext-runtime/src/ngettext.c
@@ -26,6 +26,7 @@
#include <locale.h>
#include <errno.h>
+#include "closeout.h"
#include "error.h"
#include "progname.h"
#include "relocatable.h"
@@ -86,6 +87,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Parse command line options. */
while ((optchar = getopt_long (argc, argv, "+d:eEhV", long_options, NULL))
!= EOF)
diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog
index 4069bef..c1aac57 100644
--- a/gettext-tools/ChangeLog
+++ b/gettext-tools/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ * windows/gettextlib.def: Export close_stdout.
+
2003-09-09 Bruno Haible <bruno@clisp.org>
* configure.ac: Don't test for putc_unlocked.
diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog
index 88f575d..5948692 100644
--- a/gettext-tools/lib/ChangeLog
+++ b/gettext-tools/lib/ChangeLog
@@ -1,3 +1,13 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ * closeout.h: New file, from gnulib with modifications.
+ * closeout.c: New file, from gnulib with modifications.
+ * Makefile.am (libgettextlib_la_SOURCES): Add closeout.h, closeout.c.
+ * Makefile.msvc (OBJECTS): Add closeout.obj.
+ (closeout.obj): New rule.
+ * Makefile.vms (OBJECTS): Add closeout.obj.
+ (closeout.obj): New rule.
+
2003-09-12 Paul Eggert <eggert@twinsun.com>
* progreloc.c (get_full_program_name): Define via prototype.
diff --git a/gettext-tools/lib/Makefile.am b/gettext-tools/lib/Makefile.am
index de81701..3e437bb 100644
--- a/gettext-tools/lib/Makefile.am
+++ b/gettext-tools/lib/Makefile.am
@@ -37,6 +37,7 @@ libgettextlib_la_SOURCES = \
binary-io.h \
c-ctype.h c-ctype.c \
classpath.h classpath.c \
+ closeout.h closeout.c \
copy-file.h copy-file.c \
error.h error.c \
error-progname.h error-progname.c \
diff --git a/gettext-tools/lib/Makefile.msvc b/gettext-tools/lib/Makefile.msvc
index fc363b3..f90705c 100644
--- a/gettext-tools/lib/Makefile.msvc
+++ b/gettext-tools/lib/Makefile.msvc
@@ -85,6 +85,7 @@ OBJECTS = \
basename.obj \
c-ctype.obj \
classpath.obj \
+ closeout.obj \
copy-file.obj \
error.obj \
error-progname.obj \
@@ -146,6 +147,9 @@ c-ctype.obj : c-ctype.c
classpath.obj : classpath.c
$(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c classpath.c
+closeout.obj : closeout.c
+ $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c closeout.c
+
copy-file.obj : copy-file.c
$(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c copy-file.c
diff --git a/gettext-tools/lib/Makefile.vms b/gettext-tools/lib/Makefile.vms
index 8415eed..bd70f25 100644
--- a/gettext-tools/lib/Makefile.vms
+++ b/gettext-tools/lib/Makefile.vms
@@ -43,6 +43,7 @@ OBJECTS = \
basename.obj, \
c-ctype.obj, \
classpath.obj, \
+ closeout.obj, \
copy-file.obj, \
error.obj, \
error-progname.obj, \
@@ -107,6 +108,9 @@ c-ctype.obj : c-ctype.c
classpath.obj : classpath.c
$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) classpath.c
+closeout.obj : closeout.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) closeout.c
+
copy-file.obj : copy-file.c
$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) copy-file.c
diff --git a/gettext-tools/lib/closeout.c b/gettext-tools/lib/closeout.c
new file mode 100644
index 0000000..ab15966
--- /dev/null
+++ b/gettext-tools/lib/closeout.c
@@ -0,0 +1,97 @@
+/* closeout.c - close standard output
+ Copyright (C) 1998-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
+ 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. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "closeout.h"
+
+#include <stdio.h>
+#include <errno.h>
+
+#if 0
+#include "unlocked-io.h"
+#include "__fpending.h"
+#endif
+#include "error.h"
+#include "exit.h"
+#include "gettext.h"
+
+#define _(msgid) gettext (msgid)
+
+/* Close standard output, exiting with status STATUS on failure.
+ If a program writes *anything* to stdout, that program should `fflush'
+ stdout and make sure that it succeeds before exiting. 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.
+
+ FIXME: note the fflush suggested above is implicit in the fclose
+ we actually do below. Consider doing only the fflush and/or using
+ setvbuf to inhibit buffering.
+
+ 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. */
+
+static void
+close_stdout_status (int status)
+{
+ int e = ferror (stdout) ? 0 : -1;
+
+ /* If the stream's error bit is clear, use fflush without fclose.
+ This avoids a useless close(1) system call in the frequent case
+ that no error occurred. */
+ if (e)
+ {
+ if (fflush (stdout) != 0)
+ e = errno;
+ else
+ return;
+ }
+
+ if (fclose (stdout) != 0)
+ e = errno;
+
+ if (0 <= e)
+ error (status, e, "%s", _("write error"));
+}
+
+/* Close standard output, exiting with status EXIT_FAILURE on failure. */
+void
+close_stdout (void)
+{
+ close_stdout_status (EXIT_FAILURE);
+}
+
+/* Note: When exit (...) calls the atexit-registered
+ close_stdout (), which calls
+ error (status, ...), which calls
+ exit (status),
+ we have undefined behaviour according to ISO C 99 section 7.20.4.3.(2).
+ But in practice there is no problem: The second exit call is executed
+ at a moment when the atexit handlers are no longer active. */
diff --git a/gettext-tools/lib/closeout.h b/gettext-tools/lib/closeout.h
new file mode 100644
index 0000000..7f1e478
--- /dev/null
+++ b/gettext-tools/lib/closeout.h
@@ -0,0 +1,31 @@
+/* close standard output
+ Copyright (C) 1998-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
+ 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. */
+
+#ifndef CLOSEOUT_H
+#define CLOSEOUT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void close_stdout (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 190e7ed..4028f77 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,42 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ Fix behaviour of "<program> --help > /dev/full".
+ * hostname.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgattrib.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgcat.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgcmp.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgcomm.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgconv.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgen.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgexec.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgfilter.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgfmt.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msggrep.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msginit.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgmerge.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msgunfmt.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * msguniq.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * urlget.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * xgettext.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * write-po.c (msgdomain_list_print): Don't fclose (stdout) here.
+
2003-09-11 Bruno Haible <bruno@clisp.org>
* po-lex.c (mbfile_getc): Handle unexpected return value of
diff --git a/gettext-tools/src/hostname.c b/gettext-tools/src/hostname.c
index 7099d9f..67e6072 100644
--- a/gettext-tools/src/hostname.c
+++ b/gettext-tools/src/hostname.c
@@ -77,6 +77,7 @@
/* Include this after <sys/socket.h>, to avoid a syntax error on BeOS. */
#include <stdbool.h>
+#include "closeout.h"
#include "error.h"
#include "error-progname.h"
#include "progname.h"
@@ -133,6 +134,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgattrib.c b/gettext-tools/src/msgattrib.c
index 2856323..7e33689 100644
--- a/gettext-tools/src/msgattrib.c
+++ b/gettext-tools/src/msgattrib.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -145,6 +146,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgcat.c b/gettext-tools/src/msgcat.c
index 592c820..1211aa2 100644
--- a/gettext-tools/src/msgcat.c
+++ b/gettext-tools/src/msgcat.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "str-list.h"
#include "file-list.h"
@@ -117,6 +118,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgcmp.c b/gettext-tools/src/msgcmp.c
index 3f211b6..0ec8309 100644
--- a/gettext-tools/src/msgcmp.c
+++ b/gettext-tools/src/msgcmp.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -89,6 +90,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
do_help = false;
do_version = false;
while ((optchar = getopt_long (argc, argv, "D:hmPV", long_options, NULL))
diff --git a/gettext-tools/src/msgcomm.c b/gettext-tools/src/msgcomm.c
index 206ba1c..5f18297 100644
--- a/gettext-tools/src/msgcomm.c
+++ b/gettext-tools/src/msgcomm.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "closeout.h"
#include "dir-list.h"
#include "str-list.h"
#include "file-list.h"
@@ -119,6 +120,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
more_than = -1;
less_than = -1;
diff --git a/gettext-tools/src/msgconv.c b/gettext-tools/src/msgconv.c
index 7ff480a..448bbff 100644
--- a/gettext-tools/src/msgconv.c
+++ b/gettext-tools/src/msgconv.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -109,6 +110,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgen.c b/gettext-tools/src/msgen.c
index fdb06ca..f90a37c 100644
--- a/gettext-tools/src/msgen.c
+++ b/gettext-tools/src/msgen.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -102,6 +103,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c
index 42188ff..01f1066 100644
--- a/gettext-tools/src/msgexec.c
+++ b/gettext-tools/src/msgexec.c
@@ -33,6 +33,7 @@
# include <unistd.h>
#endif
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "xerror.h"
@@ -115,6 +116,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c
index 0cc85b1..3f2749c 100644
--- a/gettext-tools/src/msgfilter.c
+++ b/gettext-tools/src/msgfilter.c
@@ -46,6 +46,7 @@
# include <sys/select.h>
#endif
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -156,6 +157,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c
index 551b535..3d72280 100644
--- a/gettext-tools/src/msgfmt.c
+++ b/gettext-tools/src/msgfmt.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -215,6 +216,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
while ((opt = getopt_long (argc, argv, "a:cCd:D:fhjl:o:Pr:vV", long_options,
NULL))
!= EOF)
diff --git a/gettext-tools/src/msggrep.c b/gettext-tools/src/msggrep.c
index c7a10f7..10a55fa 100644
--- a/gettext-tools/src/msggrep.c
+++ b/gettext-tools/src/msggrep.c
@@ -38,6 +38,7 @@
#include <fnmatch.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -152,6 +153,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c
index 0592713..d888ba5 100644
--- a/gettext-tools/src/msginit.c
+++ b/gettext-tools/src/msginit.c
@@ -69,6 +69,7 @@
# define HAVE_DIR 0
#endif
+#include "closeout.h"
#include "error.h"
#include "error-progname.h"
#include "progname.h"
@@ -173,6 +174,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c
index a2e3591..0ff0262 100644
--- a/gettext-tools/src/msgmerge.c
+++ b/gettext-tools/src/msgmerge.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "error.h"
#include "error-progname.h"
@@ -159,6 +160,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/msgunfmt.c b/gettext-tools/src/msgunfmt.c
index 6e6b54b..e6ce824 100644
--- a/gettext-tools/src/msgunfmt.c
+++ b/gettext-tools/src/msgunfmt.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "error.h"
#include "error-progname.h"
#include "progname.h"
@@ -115,6 +116,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
while ((optchar = getopt_long (argc, argv, "d:eEhijl:o:pr:svVw:",
long_options, NULL))
!= EOF)
diff --git a/gettext-tools/src/msguniq.c b/gettext-tools/src/msguniq.c
index b3fe4f3..c12e870 100644
--- a/gettext-tools/src/msguniq.c
+++ b/gettext-tools/src/msguniq.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <locale.h>
+#include "closeout.h"
#include "dir-list.h"
#include "str-list.h"
#include "error.h"
@@ -112,6 +113,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/urlget.c b/gettext-tools/src/urlget.c
index ea95bc6..3adb5a2 100644
--- a/gettext-tools/src/urlget.c
+++ b/gettext-tools/src/urlget.c
@@ -33,6 +33,7 @@
# include <unistd.h>
#endif
+#include "closeout.h"
#include "error.h"
#include "error-progname.h"
#include "progname.h"
@@ -101,6 +102,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set default values for variables. */
do_help = false;
do_version = false;
diff --git a/gettext-tools/src/write-po.c b/gettext-tools/src/write-po.c
index 9120f21..985179e 100644
--- a/gettext-tools/src/write-po.c
+++ b/gettext-tools/src/write-po.c
@@ -1094,7 +1094,9 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
if (fflush (fp) || ferror (fp))
error (EXIT_FAILURE, errno, _("error while writing \"%s\" file"),
filename);
- fclose (fp);
+
+ if (fp != stdout)
+ fclose (fp);
}
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index 63e51c9..0cd07ab 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -32,6 +32,7 @@
#include <limits.h>
#include "xgettext.h"
+#include "closeout.h"
#include "dir-list.h"
#include "file-list.h"
#include "str-list.h"
@@ -249,6 +250,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Set initial value of variables. */
default_domain = MESSAGE_DOMAIN_DEFAULT;
xgettext_global_source_encoding = po_charset_ascii;
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index 7273943..1f0acbe 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-13 Bruno Haible <bruno@clisp.org>
+
+ Fix behaviour of "<program> --help > /dev/full".
+ * tstgettext.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+ * tstngettext.c: Include closeout.h.
+ (main): Register close_stdout for execution at program exit.
+
2003-09-11 Bruno Haible <bruno@clisp.org>
* msgfmt-14: New file.
diff --git a/gettext-tools/tests/tstgettext.c b/gettext-tools/tests/tstgettext.c
index e8b1632..3b2d9d2 100644
--- a/gettext-tools/tests/tstgettext.c
+++ b/gettext-tools/tests/tstgettext.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <locale.h>
+#include "closeout.h"
#include "error.h"
#include "progname.h"
#include "relocatable.h"
@@ -96,6 +97,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Parse command line options. */
while ((optchar = getopt_long (argc, argv, "+d:eEhnsV", long_options, NULL))
!= EOF)
diff --git a/gettext-tools/tests/tstngettext.c b/gettext-tools/tests/tstngettext.c
index bea4cab..0060ae0 100644
--- a/gettext-tools/tests/tstngettext.c
+++ b/gettext-tools/tests/tstngettext.c
@@ -26,6 +26,7 @@
#include <locale.h>
#include <errno.h>
+#include "closeout.h"
#include "error.h"
#include "progname.h"
#include "relocatable.h"
@@ -85,6 +86,9 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
+ /* Ensure that write errors on stdout are detected. */
+ atexit (close_stdout);
+
/* Parse command line options. */
while ((optchar = getopt_long (argc, argv, "+d:hV", long_options, NULL))
!= EOF)
diff --git a/gettext-tools/windows/gettextlib.def b/gettext-tools/windows/gettextlib.def
index 55f3d45..96c6653 100644
--- a/gettext-tools/windows/gettextlib.def
+++ b/gettext-tools/windows/gettextlib.def
@@ -26,6 +26,7 @@ c_isupper
c_isxdigit
c_tolower
c_toupper
+close_stdout
compile_java_class
concatenated_pathname
copy_file_preserving