Never let printf failures go undetected.

* ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
xprintf'.
* m4/system_.h: Include xprintf.h.
* m4/debug.c (m4_debug_message_prefix, m4_debug_message): Wrap all
use of printf, xprintf.
* m4/input.c [DEBUG_INPUT]: Likewise.
* m4/module.c [DEBUG_MODULES]: Likewise.
* m4/output.c (m4_shipout_text, m4_shipout_int)
(m4_freeze_diversions): Likewise.
* m4/path.c [DEBUG_INCL]: Likewise.
* m4/symtab.c [DEBUG_SYM]: Likewise.
* m4/syntax.c [DEBUG_SYNTAX]: Likewise.
* modules/modtest.c (export_test): Likewise.
* src/freeze.c (produce_resyntax_dump, produce_syntax_dump)
(produce_module_dump, dump_symbol_CB, produce_frozen_state):
Likewise.
* src/main.c (usage): Likewise.
* po/POTFILES.in: Adjust to new file.
* po/Makevars (XGETTEXT_OPTIONS): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
diff --git a/ChangeLog b/ChangeLog
index 195bde9..0e927bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2007-10-22  Eric Blake  <ebb9@byu.net>
+
+	Never let printf failures go undetected.
+	* ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
+	xprintf'.
+	* m4/system_.h: Include xprintf.h.
+	* m4/debug.c (m4_debug_message_prefix, m4_debug_message): Wrap all
+	use of printf, xprintf.
+	* m4/input.c [DEBUG_INPUT]: Likewise.
+	* m4/module.c [DEBUG_MODULES]: Likewise.
+	* m4/output.c (m4_shipout_text, m4_shipout_int)
+	(m4_freeze_diversions): Likewise.
+	* m4/path.c [DEBUG_INCL]: Likewise.
+	* m4/symtab.c [DEBUG_SYM]: Likewise.
+	* m4/syntax.c [DEBUG_SYNTAX]: Likewise.
+	* modules/modtest.c (export_test): Likewise.
+	* src/freeze.c (produce_resyntax_dump, produce_syntax_dump)
+	(produce_module_dump, dump_symbol_CB, produce_frozen_state):
+	Likewise.
+	* src/main.c (usage): Likewise.
+	* po/POTFILES.in: Adjust to new file.
+	* po/Makevars (XGETTEXT_OPTIONS): Likewise.
+
 2007-10-18  Eric Blake  <ebb9@byu.net>
 
 	Fix 'm4 -F file -t undefined'.
diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4
index 5ca87d6..a0517eb 100644
--- a/ltdl/m4/gnulib-cache.m4
+++ b/ltdl/m4/gnulib-cache.m4
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --with-tests --libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error exit fdl fflush filenamecat fopen-safer fprintf-posix free fseeko gendocs gettext gnupload gpl-3.0 mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xvasprintf
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu --source-base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --with-tests --libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error exit fdl fflush filenamecat fopen-safer fprintf-posix free fseeko gendocs gettext gnupload gpl-3.0 mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xprintf xstrndup xvasprintf
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
-gl_MODULES([assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error exit fdl fflush filenamecat fopen-safer fprintf-posix free fseeko gendocs gettext gnupload gpl-3.0 mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xstrndup xvasprintf])
+gl_MODULES([assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h configmake dirname error exit fdl fflush filenamecat fopen-safer fprintf-posix free fseeko gendocs gettext gnupload gpl-3.0 mkstemp obstack progname regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die xprintf xstrndup xvasprintf])
 gl_AVOID([])
 gl_SOURCE_BASE([gnu])
 gl_M4_BASE([ltdl/m4])
diff --git a/m4/debug.c b/m4/debug.c
index 47ea114..c90efde 100644
--- a/m4/debug.c
+++ b/m4/debug.c
@@ -209,9 +209,9 @@
   if (m4_get_current_line (context))
     {
       if (m4_is_debug_bit (context, M4_DEBUG_TRACE_FILE))
-	fprintf (debug_file, "%s:", m4_get_current_file (context));
+	xfprintf (debug_file, "%s:", m4_get_current_file (context));
       if (m4_is_debug_bit (context, M4_DEBUG_TRACE_LINE))
-	fprintf (debug_file, "%d:", m4_get_current_line (context));
+	xfprintf (debug_file, "%d:", m4_get_current_line (context));
     }
   putc (' ', debug_file);
 }
@@ -233,7 +233,7 @@
 
       m4_debug_message_prefix (context);
       va_start (args, format);
-      vfprintf (m4_get_debug_file (context), format, args);
+      xvfprintf (m4_get_debug_file (context), format, args);
       va_end (args);
       putc ('\n', m4_get_debug_file (context));
     }
diff --git a/m4/input.c b/m4/input.c
index 03b9ce0..e5e7c92 100644
--- a/m4/input.c
+++ b/m4/input.c
@@ -1019,7 +1019,7 @@
     if (ch == CHAR_EOF)			/* EOF */
       {
 #ifdef DEBUG_INPUT
-	fprintf (stderr, "next_token -> EOF\n");
+	xfprintf (stderr, "next_token -> EOF\n");
 #endif
 	next_char (context, true);
 	return M4_TOKEN_EOF;
@@ -1173,12 +1173,12 @@
 
 	if (m4_has_syntax (M4SYNTAX, ch,
 			   (M4_SYNTAX_OTHER | M4_SYNTAX_NUM | M4_SYNTAX_DOLLAR
-                            | M4_SYNTAX_LBRACE | M4_SYNTAX_RBRACE)))
+			    | M4_SYNTAX_LBRACE | M4_SYNTAX_RBRACE)))
 	  {
 	    consume_syntax (context, &token_stack,
 			    (M4_SYNTAX_OTHER | M4_SYNTAX_NUM
-                             | M4_SYNTAX_DOLLAR | M4_SYNTAX_LBRACE
-                             | M4_SYNTAX_RBRACE));
+			     | M4_SYNTAX_DOLLAR | M4_SYNTAX_LBRACE
+			     | M4_SYNTAX_RBRACE));
 	    type = M4_TOKEN_STRING;
 	  }
 	else if (m4_has_syntax (M4SYNTAX, ch, M4_SYNTAX_SPACE))
@@ -1199,7 +1199,7 @@
 
 	if (m4_has_syntax (M4SYNTAX, ch,
 			   (M4_SYNTAX_OTHER | M4_SYNTAX_NUM | M4_SYNTAX_DOLLAR
-                            | M4_SYNTAX_LBRACE | M4_SYNTAX_RBRACE)))
+			    | M4_SYNTAX_LBRACE | M4_SYNTAX_RBRACE)))
 	  type = M4_TOKEN_STRING;
 	else if (m4_has_syntax (M4SYNTAX, ch, M4_SYNTAX_SPACE))
 	  type = M4_TOKEN_SPACE;
@@ -1249,43 +1249,43 @@
 int
 m4_print_token (const char *s, m4__token_type type, m4_symbol_value *token)
 {
-  fprintf (stderr, "%s: ", s ? s : "m4input");
+  xfprintf (stderr, "%s: ", s ? s : "m4input");
   switch (type)
     {				/* TOKSW */
     case M4_TOKEN_EOF:
-      fprintf (stderr, "eof\n");
+      xfprintf (stderr, "eof\n");
       break;
     case M4_TOKEN_NONE:
-      fprintf (stderr, "none\n");
+      xfprintf (stderr, "none\n");
       break;
     case M4_TOKEN_STRING:
-      fprintf (stderr, "string\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "string\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_SPACE:
-      fprintf (stderr, "space\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "space\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_WORD:
-      fprintf (stderr, "word\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "word\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_OPEN:
-      fprintf (stderr, "open\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "open\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_COMMA:
-      fprintf (stderr, "comma\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "comma\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_CLOSE:
-      fprintf (stderr, "close\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "close\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_SIMPLE:
-      fprintf (stderr, "simple\t\"%s\"\n", m4_get_symbol_value_text (token));
+      xfprintf (stderr, "simple\t\"%s\"\n", m4_get_symbol_value_text (token));
       break;
     case M4_TOKEN_MACDEF:
       {
 	const m4_builtin *bp;
 	bp = m4_builtin_find_by_func (NULL, m4_get_symbol_value_func (token));
 	assert (bp);
-	fprintf (stderr, "builtin\t<%s>{%s}\n", bp->name,
-		 m4_get_module_name (VALUE_MODULE (token)));
+	xfprintf (stderr, "builtin\t<%s>{%s}\n", bp->name,
+		  m4_get_module_name (VALUE_MODULE (token)));
       }
       break;
     }
diff --git a/m4/macro.c b/m4/macro.c
index ab68bb8..3628a49 100644
--- a/m4/macro.c
+++ b/m4/macro.c
@@ -46,7 +46,7 @@
 				  m4_symbol_value **, m4_input_block *, bool);
 
 static void    trace_format	 (m4 *, const char *, ...)
-  M4_GNUC_PRINTF(2, 3);
+  M4_GNUC_PRINTF (2, 3);
 static void    trace_header	 (m4 *, size_t);
 static void    trace_flush	 (m4 *);
 
diff --git a/m4/module.c b/m4/module.c
index 4c68c0a..458808e 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -405,8 +405,8 @@
 #ifdef DEBUG_MODULES
       if (info->ref_count > 1)
 	{
-	  fprintf (stderr, "module %s: now has %d libtool references.",
-		   name, info->ref_count);
+	  xfprintf (stderr, "module %s: now has %d libtool references.",
+		    name, info->ref_count);
 	}
 #endif /* DEBUG_MODULES */
 
@@ -545,8 +545,8 @@
 #ifdef DEBUG_MODULES
   if (info->ref_count > 1)
     {
-      fprintf (stderr, "module %s: now has %d libtool references.",
-	       name, info->ref_count - 1);
+      xfprintf (stderr, "module %s: now has %d libtool references.",
+		name, info->ref_count - 1);
     }
 #endif /* DEBUG_MODULES */
 
diff --git a/m4/output.c b/m4/output.c
index 751aba7..1f8d1b0 100644
--- a/m4/output.c
+++ b/m4/output.c
@@ -24,8 +24,9 @@
 
 #include "binary-io.h"
 #include "clean-temp.h"
-#include "gl_avltree_oset.h"
 #include "exitfail.h"
+#include "gl_avltree_oset.h"
+#include "intprops.h"
 #include "xvasprintf.h"
 
 /* Define this to see runtime debug output.  Implied by DEBUG.  */
@@ -465,7 +466,7 @@
 		 const char *text, size_t length, int line)
 {
   static bool start_of_output_line = true;
-  char linebuf[20];
+  char linebuf[6 + INT_BUFSIZE_BOUND (unsigned long int)]; /* "#line nnnn" */
   const char *cursor;
 
   /* If output goes to an obstack, merely add TEXT to it.  */
@@ -517,9 +518,9 @@
 	  m4_set_output_line (context, m4_get_output_line (context) + 1);
 
 #ifdef DEBUG_OUTPUT
-	  fprintf (stderr, "DEBUG: line %d, cur %lu, cur out %lu\n", line,
-		   (unsigned long int) m4_get_current_line (context),
-		   (unsigned long int) m4_get_output_line (context));
+	  xfprintf (stderr, "DEBUG: line %d, cur %lu, cur out %lu\n", line,
+		    (unsigned long int) m4_get_current_line (context),
+		    (unsigned long int) m4_get_output_line (context));
 #endif
 
 	  /* Output a `#line NUM' synchronization directive if needed.
@@ -558,9 +559,9 @@
 	      m4_set_output_line (context, m4_get_output_line (context) + 1);
 
 #ifdef DEBUG_OUTPUT
-	      fprintf (stderr, "DEBUG: line %d, cur %lu, cur out %lu\n", line,
-		       (unsigned long int) m4_get_current_line (context),
-		       (unsigned long int) m4_get_output_line (context));
+	      xfprintf (stderr, "DEBUG: line %d, cur %lu, cur out %lu\n", line,
+			(unsigned long int) m4_get_current_line (context),
+			(unsigned long int) m4_get_output_line (context));
 #endif
 	    }
 	  OUTPUT_CHARACTER (*text);
@@ -576,7 +577,7 @@
 void
 m4_shipout_int (m4_obstack *obs, int val)
 {
-  char buf[128];
+  char buf[INT_BUFSIZE_BOUND (int)];
 
   sprintf(buf, "%d", val);
   obstack_grow (obs, buf, strlen (buf));
@@ -845,8 +846,8 @@
 	  if (diversion->size)
 	    {
 	      assert (diversion->used == (int) diversion->used);
-	      fprintf (file, "D%d,%d\n", diversion->divnum,
-		       (int) diversion->used);
+	      xfprintf (file, "D%d,%d\n", diversion->divnum,
+			(int) diversion->used);
 	    }
 	  else
 	    {
@@ -863,8 +864,8 @@
 		  || file_stat.st_size != (unsigned long int) file_stat.st_size)
 		m4_error (context, EXIT_FAILURE, errno,
 			  _("diversion too large"));
-	      fprintf (file, "D%d,%lu\n", diversion->divnum,
-		       (unsigned long int) file_stat.st_size);
+	      xfprintf (file, "D%d,%lu\n", diversion->divnum,
+			(unsigned long int) file_stat.st_size);
 	    }
 
 	  insert_diversion_helper (context, diversion);
@@ -878,5 +879,5 @@
   /* Save the active diversion number, if not already.  */
 
   if (saved_number != last_inserted)
-    fprintf (file, "D%d,0\n\n", saved_number);
+    xfprintf (file, "D%d,0\n\n", saved_number);
 }
diff --git a/m4/path.c b/m4/path.c
index 16aa3c7..b0b45d7 100644
--- a/m4/path.c
+++ b/m4/path.c
@@ -119,8 +119,8 @@
   search_path_add (m4__get_search_path (context), dir, prepend);
 
 #ifdef DEBUG_INCL
-  fprintf (stderr, "add_include_directory (%s) %s;\n", dir,
-	   prepend ? "prepend" : "append");
+  xfprintf (stderr, "add_include_directory (%s) %s;\n", dir,
+	    prepend ? "prepend" : "append");
 #endif
 }
 
@@ -172,7 +172,7 @@
       name = file_name_concat (incl->dir, file, NULL);
 
 #ifdef DEBUG_INCL
-      fprintf (stderr, "path_search (%s) -- trying %s\n", file, name);
+      xfprintf (stderr, "path_search (%s) -- trying %s\n", file, name);
 #endif
 
       fp = fopen (name, "r");
@@ -221,7 +221,7 @@
   fputs ("include_dump:\n", stderr);
   for (incl = m4__get_search_path (context)->list;
        incl != NULL; incl = incl->next)
-    fprintf (stderr, "\t%s\n", incl->dir);
+    xfprintf (stderr, "\t%s\n", incl->dir);
 }
 
 #endif /* DEBUG_INCL */
diff --git a/m4/symtab.c b/m4/symtab.c
index 1228a29..97f247b 100644
--- a/m4/symtab.c
+++ b/m4/symtab.c
@@ -718,8 +718,8 @@
   m4_module *      module	= value ? SYMBOL_MODULE (symbol) : NULL;
   const char *     module_name	= module ? m4_get_module_name (module) : "NONE";
 
-  fprintf (stderr, "%10s: (%d%s) %s=", module_name, flags,
-	   m4_get_symbol_traced (symbol) ? "!" : "", name);
+  xfprintf (stderr, "%10s: (%d%s) %s=", module_name, flags,
+	    m4_get_symbol_traced (symbol) ? "!" : "", name);
 
   if (!value)
     fputs ("<!UNDEFINED!>", stderr);
@@ -730,7 +730,7 @@
       m4_obstack obs;
       obstack_init (&obs);
       m4_symbol_value_print (value, &obs, false, NULL, NULL, 0, true);
-      fprintf (stderr, "%s", (char *) obstack_finish (&obs));
+      xfprintf (stderr, "%s", (char *) obstack_finish (&obs));
       obstack_free (&obs, NULL);
     }
   fputc ('\n', stderr);
diff --git a/m4/syntax.c b/m4/syntax.c
index 3ac655d..9f2e122 100644
--- a/m4/syntax.c
+++ b/m4/syntax.c
@@ -220,9 +220,9 @@
     syntax->table[ch] = (syntax->table[ch] & M4_SYNTAX_MASKS) | code;
 
 #ifdef DEBUG_SYNTAX
-  fprintf(stderr, "Set syntax %o %c = %04X\n",
-	  ch, isprint(ch) ? ch : '-',
-	  syntax->table[ch]);
+  xfprintf(stderr, "Set syntax %o %c = %04X\n",
+	   ch, isprint(ch) ? ch : '-',
+	   syntax->table[ch]);
 #endif
 
   return syntax->table[ch];
@@ -235,9 +235,9 @@
   syntax->table[ch] &= ~code;
 
 #ifdef DEBUG_SYNTAX
-  fprintf(stderr, "Unset syntax %o %c = %04X\n",
-	  ch, isprint(ch) ? ch : '-',
-	  syntax->table[ch]);
+  xfprintf(stderr, "Unset syntax %o %c = %04X\n",
+	   ch, isprint(ch) ? ch : '-',
+	   syntax->table[ch]);
 #endif
 
   return syntax->table[ch];
diff --git a/m4/system_.h b/m4/system_.h
index 88ba28a..e014d75 100644
--- a/m4/system_.h
+++ b/m4/system_.h
@@ -46,6 +46,7 @@
 @INCLUDE_STDBOOL_H@
 
 #include <gnu/xalloc.h>
+#include <gnu/xprintf.h>
 #include <gnu/xstrndup.h>
 
 /* glibc's obstack left out the ability to suspend and resume growth
@@ -137,18 +138,18 @@
 /* Take advantage of GNU C compiler source level optimization hints,
    using portable macros.  */
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
-# define M4_GNUC_ATTRIBUTE(args)	__attribute__(args)
+# define M4_GNUC_ATTRIBUTE(args)	__attribute__ (args)
 #else
 # define M4_GNUC_ATTRIBUTE(args)
 #endif  /* __GNUC__ */
 
 #define M4_GNUC_PRINTF(fmt, arg)				\
-  M4_GNUC_ATTRIBUTE((__format__ (__printf__, fmt, arg)))
+  M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg)))
 #define M4_GNUC_SCANF(fmt, arg)					\
-  M4_GNUC_ATTRIBUTE((__format__ (__scanf__, fmt, arg)))
-#define M4_GNUC_NORETURN	M4_GNUC_ATTRIBUTE((__noreturn__))
-#define M4_GNUC_CONST		M4_GNUC_ATTRIBUTE((__const__))
-#define M4_GNUC_UNUSED		M4_GNUC_ATTRIBUTE((__unused__))
+  M4_GNUC_ATTRIBUTE ((__format__ (__scanf__, fmt, arg)))
+#define M4_GNUC_NORETURN	M4_GNUC_ATTRIBUTE ((__noreturn__))
+#define M4_GNUC_CONST		M4_GNUC_ATTRIBUTE ((__const__))
+#define M4_GNUC_UNUSED		M4_GNUC_ATTRIBUTE ((__unused__))
 
 
 
@@ -164,12 +165,12 @@
    be expanded before being quoted.   */
 #ifndef STR
 # define _STR(arg)	#arg
-# define STR(arg)	_STR(arg)
+# define STR(arg)	_STR (arg)
 #endif
 
 #ifndef CONC
 # define _CONC(a, b)	a##b
-# define CONC(a, b)	_CONC(a, b)
+# define CONC(a, b)	_CONC (a, b)
 #endif
 
 END_C_DECLS
diff --git a/modules/modtest.c b/modules/modtest.c
index e1143da..022a2ef 100644
--- a/modules/modtest.c
+++ b/modules/modtest.c
@@ -113,6 +113,6 @@
 export_test (const char *foo)
 {
   if (foo)
-    fprintf (stderr, "%s\n", foo);
+    xfprintf (stderr, "%s\n", foo);
   return (bool) (foo != 0);
 }
diff --git a/po/Makevars b/po/Makevars
index 793453a..d952fe8 100644
--- a/po/Makevars
+++ b/po/Makevars
@@ -35,6 +35,8 @@
   --flag=verror:3:c-format --flag=verror_at_line:5:c-format \
   --flag=asprintf:2:c-format --flag=vasprintf:2:c-format \
   --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format \
+  --flag=xprintf:1:c-format --flag=xvprintf:1:c-format \
+  --flag=xfprintf:2:c-format --flag=xvfprintf:2:c-format \
   --flag=m4_error:4:c-format --flag=m4_error_at_line:6:c-format \
   --flag=m4_debug_message:3:c-format
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c949e30..94415f9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,6 +7,7 @@
 gnu/regcomp.c
 gnu/verror.c
 gnu/xalloc-die.c
+gnu/xprintf.c
 m4/builtin.c
 m4/debug.c
 m4/input.c
diff --git a/src/freeze.c b/src/freeze.c
index 9eca014..fa40ce7 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -96,7 +96,7 @@
 
       /* No need to use produce_mem_dump, since we know all resyntax
 	 names are already ASCII-encoded.  */
-      fprintf (file, "R%zu\n%s\n", strlen (resyntax), resyntax);
+      xfprintf (file, "R%zu\n%s\n", strlen (resyntax), resyntax);
     }
 }
 
@@ -121,7 +121,7 @@
 
   if (count || (code & M4_SYNTAX_MASKS))
     {
-      fprintf (file, "S%c%d\n", ch, count);
+      xfprintf (file, "S%c%d\n", ch, count);
       produce_mem_dump (file, buf, count);
       fputc ('\n', file);
     }
@@ -140,7 +140,7 @@
   if (module)
     produce_module_dump (file, module);
 
-  fprintf (file, "M%zu\n", len);
+  xfprintf (file, "M%zu\n", len);
   produce_mem_dump (file, name, len);
   fputc ('\n', file);
 }
@@ -169,9 +169,9 @@
     {
       const char *text = m4_get_symbol_text (symbol);
       size_t text_len = strlen (text);
-      fprintf (file, "T%zu,%zu", symbol_len, text_len);
+      xfprintf (file, "T%zu,%zu", symbol_len, text_len);
       if (module)
-	fprintf (file, ",%zu", module_len);
+	xfprintf (file, ",%zu", module_len);
       fputc ('\n', file);
 
       produce_mem_dump (file, symbol_name, symbol_len);
@@ -188,9 +188,9 @@
 	assert (!"INTERNAL ERROR: builtin not found in builtin table!");
       bp_len = strlen (bp->name);
 
-      fprintf (file, "F%zu,%zu", symbol_len, bp_len);
+      xfprintf (file, "F%zu,%zu", symbol_len, bp_len);
       if (module)
-	fprintf (file, ",%zu", module_len);
+	xfprintf (file, ",%zu", module_len);
       fputc ('\n', file);
 
       produce_mem_dump (file, symbol_name, symbol_len);
@@ -222,8 +222,8 @@
 
   /* Write a recognizable header.  */
 
-  fprintf (file, "# This is a frozen state file generated by GNU %s %s\n",
-	   PACKAGE, VERSION);
+  xfprintf (file, "# This is a frozen state file generated by GNU %s %s\n",
+	    PACKAGE, VERSION);
   fputs ("V2\n", file);
 
   /* Dump quote delimiters.  */
@@ -231,7 +231,7 @@
   if (strcmp (m4_get_syntax_lquote (M4SYNTAX), DEF_LQUOTE)
       || strcmp (m4_get_syntax_rquote (M4SYNTAX), DEF_RQUOTE))
     {
-      fprintf (file, "Q%zu,%zu\n", M4SYNTAX->lquote.length,
+      xfprintf (file, "Q%zu,%zu\n", M4SYNTAX->lquote.length,
 	       M4SYNTAX->rquote.length);
       produce_mem_dump (file, M4SYNTAX->lquote.string,
 			M4SYNTAX->lquote.length);
@@ -245,8 +245,8 @@
   if (strcmp (m4_get_syntax_bcomm (M4SYNTAX), DEF_BCOMM)
       || strcmp (m4_get_syntax_ecomm (M4SYNTAX), DEF_ECOMM))
     {
-      fprintf (file, "C%zu,%zu\n", M4SYNTAX->bcomm.length,
-	       M4SYNTAX->ecomm.length);
+      xfprintf (file, "C%zu,%zu\n", M4SYNTAX->bcomm.length,
+		M4SYNTAX->ecomm.length);
       produce_mem_dump (file, M4SYNTAX->bcomm.string, M4SYNTAX->bcomm.length);
       produce_mem_dump (file, M4SYNTAX->ecomm.string, M4SYNTAX->ecomm.length);
       fputc ('\n', file);
diff --git a/src/main.c b/src/main.c
index 80be58d..3fed2e5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,11 +66,11 @@
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
-    fprintf (stderr, _("Try `%s --help' for more information.\n"),
-	     m4_get_program_name ());
+    xfprintf (stderr, _("Try `%s --help' for more information.\n"),
+	      m4_get_program_name ());
   else
     {
-      printf (_("Usage: %s [OPTION]... [FILE]...\n"), m4_get_program_name ());
+      xprintf (_("Usage: %s [OPTION]... [FILE]...\n"), m4_get_program_name ());
       fputs (_("\
 Process macros in FILEs.\n\
 If no FILE or if FILE is `-', standard input is read.  If no FILE, and both\n\
@@ -104,7 +104,7 @@
   GREP, POSIX_AWK, POSIX_EGREP, MINIMAL, MINIMAL_BASIC, SED.\n\
 "), stdout);
       puts ("");
-      printf (_("\
+      xprintf (_("\
 Dynamic loading features:\n\
   -M, --module-directory=DIR   add DIR to module search path before\n\
                                `%s'\n\
@@ -189,7 +189,7 @@
 	 saying "Report translation bugs to <...>\n" with the address
 	 for translation bugs (typically your translation team's web
 	 or email address).  */
-      printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
+      xprintf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
     }
   exit (status);
 }