[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
detect printf failures
From: |
Eric Blake |
Subject: |
detect printf failures |
Date: |
Mon, 22 Oct 2007 16:37:47 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
As recently discovered on the gnulib list, relying on the gnulib closein module
to detect all *printf failures is flawed, since printf can fail for reasons
that don't trigger the setting of ferror() in some libc implementations. So
I'm applying this to the branch, and a similar patch to the head, to make sure
no printf error is ever ignored. (The closin module still detects all fputc
failures, and xprintf factors out the *printf check into a wrapper function;
with the result that we can still use the easier coding style of blindly
outputting without checking results at every call site). This patch even
touches the *printf uses that can only be triggered when compiling with -
DDEBUG, in order to make grepping the source for '\bf\?printf' easier.
From: Eric Blake <address@hidden>
Date: Mon, 22 Oct 2007 10:27:51 -0600
Subject: [PATCH] Never let printf failures go undetected.
* m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
xprintf'.
* src/m4.h: Include xprintf.h.
* src/format.c (format): Warn on format failures.
* src/builtin.c (ntoa): Export.
(m4_errprint): Adjust all *printf callers.
* src/debug.c (debug_message_prefix, trace_format): Likewise.
* src/freeze.c (produce_frozen_state): Likewise.
* src/input.c [DEBUG_INPUT]: Likewise.
* src/m4.c (usage): Likewise.
* src/m4.h (DEBUG_PRINT1, DEBUG_PRINT3, DEBUG_MESSAGE)
(DEBUG_MESSAGE1, DEBUG_MESSAGE2): Likewise.
* src/output.c (m4_tmpname, shipout_text, freeze_diversione):
Likewise.
* src/path.c [DEBUG_INCL]: Likewise.
* src/stackovf.c (process_sigsegv) [DEBUG_STKOVF]: Likewise.
* src/symtab.c [DEBUG_SYM]: Likewise.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 21 +++++++++++++++++++++
m4/gnulib-cache.m4 | 4 ++--
src/builtin.c | 4 ++--
src/debug.c | 10 ++++------
src/format.c | 10 +++++++---
src/freeze.c | 20 ++++++++++----------
src/input.c | 26 +++++++++++++-------------
src/m4.c | 8 ++++----
src/m4.h | 16 +++++++++-------
src/output.c | 26 ++++++++++++++++----------
src/path.c | 8 ++++----
src/stackovf.c | 5 +++--
src/symtab.c | 28 ++++++++++++++--------------
13 files changed, 109 insertions(+), 77 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2e4a12b..33278ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-10-22 Eric Blake <address@hidden>
+
+ Never let printf failures go undetected.
+ * m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
+ xprintf'.
+ * src/m4.h: Include xprintf.h.
+ * src/format.c (format): Warn on format failures.
+ * src/builtin.c (ntoa): Export.
+ (m4_errprint): Adjust all *printf callers.
+ * src/debug.c (debug_message_prefix, trace_format): Likewise.
+ * src/freeze.c (produce_frozen_state): Likewise.
+ * src/input.c [DEBUG_INPUT]: Likewise.
+ * src/m4.c (usage): Likewise.
+ * src/m4.h (DEBUG_PRINT1, DEBUG_PRINT3, DEBUG_MESSAGE)
+ (DEBUG_MESSAGE1, DEBUG_MESSAGE2): Likewise.
+ * src/output.c (m4_tmpname, shipout_text, freeze_diversione):
+ Likewise.
+ * src/path.c [DEBUG_INCL]: Likewise.
+ * src/stackovf.c (process_sigsegv) [DEBUG_STKOVF]: Likewise.
+ * src/symtab.c [DEBUG_SYM]: Likewise.
+
2007-10-17 Eric Blake <address@hidden>
Fix 'm4 -F file -t undefined'.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index a4de73d..8e2002a 100644
--- a/m4/gnulib-cache.m4
+++ b/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=libm4 --source-
base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --with-tests --no-libtool --
macro-prefix=M4 assert avltree-oset binary-io clean-temp cloexec close-stream
closein config-h error fdl fflush fopen-safer free fseeko gendocs getopt
gnupload gpl-3.0 mkstemp obstack regex stdbool stdint stdlib-safer strtol
unlocked-io vasprintf-posix verror version-etc version-etc-fsf xalloc xvasprintf
+# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-
base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --with-tests --no-libtool --
macro-prefix=M4 assert avltree-oset binary-io clean-temp cloexec close-stream
closein config-h error fdl fflush fopen-safer free fseeko gendocs getopt
gnupload gpl-3.0 mkstemp obstack regex stdbool stdint stdlib-safer strtol
unlocked-io vasprintf-posix verror version-etc version-etc-fsf xalloc xprintf
xvasprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([local])
-gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream
closein config-h error fdl fflush fopen-safer free fseeko gendocs getopt
gnupload gpl-3.0 mkstemp obstack regex stdbool stdint stdlib-safer strtol
unlocked-io vasprintf-posix verror version-etc version-etc-fsf xalloc
xvasprintf])
+gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream
closein config-h error fdl fflush fopen-safer free fseeko gendocs getopt
gnupload gpl-3.0 mkstemp obstack regex stdbool stdint stdlib-safer strtol
unlocked-io vasprintf-posix verror version-etc version-etc-fsf xalloc xprintf
xvasprintf])
gl_AVOID([])
gl_SOURCE_BASE([lib])
gl_M4_BASE([m4])
diff --git a/src/builtin.c b/src/builtin.c
index 75859bd..5983ac2 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -553,7 +553,7 @@ numeric_arg (token_data *macro, const char *arg, int
*valuep)
/* Digits for number to ascii conversions. */
static char const digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-static const char *
+const char *
ntoa (int32_t value, int radix)
{
bool negative;
@@ -1541,7 +1541,7 @@ m4_errprint (struct obstack *obs, int argc, token_data
**argv)
dump_args (obs, argc, argv, " ", false);
obstack_1grow (obs, '\0');
debug_flush_files ();
- fprintf (stderr, "%s", (char *) obstack_finish (obs));
+ xfprintf (stderr, "%s", (char *) obstack_finish (obs));
fflush (stderr);
}
diff --git a/src/debug.c b/src/debug.c
index 2c4860f..c94a746 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -231,13 +231,13 @@ debug_set_output (const char *name)
void
debug_message_prefix (void)
{
- fprintf (debug, "m4debug:");
+ xfprintf (debug, "m4debug:");
if (current_line)
{
if (debug_level & DEBUG_TRACE_FILE)
- fprintf (debug, "%s:", current_file);
+ xfprintf (debug, "%s:", current_file);
if (debug_level & DEBUG_TRACE_LINE)
- fprintf (debug, "%d:", current_line);
+ xfprintf (debug, "%d:", current_line);
}
putc (' ', debug);
}
@@ -261,7 +261,6 @@ trace_format (const char *fmt, ...)
char ch;
int d;
- char nbuf[32];
const char *s;
int slen;
int maxlen;
@@ -297,8 +296,7 @@ trace_format (const char *fmt, ...)
case 'd':
d = va_arg (args, int);
- sprintf (nbuf, "%d", d);
- s = nbuf;
+ s = ntoa (d, 10);
break;
default:
diff --git a/src/format.c b/src/format.c
index afb3876..0cc283a 100644
--- a/src/format.c
+++ b/src/format.c
@@ -301,10 +301,14 @@ format (struct obstack *obs, int argc, token_data **argv)
abort();
}
- /* NULL was returned on failure, such as invalid format string. For
- now, just silently ignore that bad specifier. */
+ /* NULL was returned on failure, such as invalid format string.
+ Issue a warning, then proceed. */
if (str == NULL)
- continue;
+ {
+ M4ERROR ((warning_status, 0,
+ "Warning: unable to format output for `%s'", f));
+ continue;
+ }
obstack_grow (obs, str, strlen (str));
free (str);
diff --git a/src/freeze.c b/src/freeze.c
index 89a4c35..18280f7 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -64,15 +64,15 @@ produce_frozen_state (const char *name)
/* Write a recognizable header. */
- fprintf (file, "# This is a frozen state file generated by %s\n",
+ xfprintf (file, "# This is a frozen state file generated by %s\n",
PACKAGE_STRING);
- fprintf (file, "V1\n");
+ xfprintf (file, "V1\n");
/* Dump quote delimiters. */
if (strcmp (lquote.string, DEF_LQUOTE) || strcmp (rquote.string, DEF_RQUOTE))
{
- fprintf (file, "Q%d,%d\n", (int) lquote.length, (int) rquote.length);
+ xfprintf (file, "Q%d,%d\n", (int) lquote.length, (int) rquote.length);
fputs (lquote.string, file);
fputs (rquote.string, file);
fputc ('\n', file);
@@ -82,7 +82,7 @@ produce_frozen_state (const char *name)
if (strcmp (bcomm.string, DEF_BCOMM) || strcmp (ecomm.string, DEF_ECOMM))
{
- fprintf (file, "C%d,%d\n", (int) bcomm.length, (int) ecomm.length);
+ xfprintf (file, "C%d,%d\n", (int) bcomm.length, (int) ecomm.length);
fputs (bcomm.string, file);
fputs (ecomm.string, file);
fputc ('\n', file);
@@ -103,9 +103,9 @@ produce_frozen_state (const char *name)
switch (SYMBOL_TYPE (sym))
{
case TOKEN_TEXT:
- fprintf (file, "T%d,%d\n",
- (int) strlen (SYMBOL_NAME (sym)),
- (int) strlen (SYMBOL_TEXT (sym)));
+ xfprintf (file, "T%d,%d\n",
+ (int) strlen (SYMBOL_NAME (sym)),
+ (int) strlen (SYMBOL_TEXT (sym)));
fputs (SYMBOL_NAME (sym), file);
fputs (SYMBOL_TEXT (sym), file);
fputc ('\n', file);
@@ -119,9 +119,9 @@ produce_frozen_state (const char *name)
INTERNAL ERROR: builtin not found in builtin table!"));
abort ();
}
- fprintf (file, "F%d,%d\n",
- (int) strlen (SYMBOL_NAME (sym)),
- (int) strlen (bp->name));
+ xfprintf (file, "F%d,%d\n",
+ (int) strlen (SYMBOL_NAME (sym)),
+ (int) strlen (bp->name));
fputs (SYMBOL_NAME (sym), file);
fputs (bp->name, file);
fputc ('\n', file);
diff --git a/src/input.c b/src/input.c
index 2da8876..7f6f87b 100644
--- a/src/input.c
+++ b/src/input.c
@@ -845,7 +845,7 @@ next_token (token_data *td, int *line)
if (ch == CHAR_EOF)
{
#ifdef DEBUG_INPUT
- fprintf (stderr, "next_token -> EOF\n");
+ xfprintf (stderr, "next_token -> EOF\n");
#endif
next_char ();
return TOKEN_EOF;
@@ -855,8 +855,8 @@ next_token (token_data *td, int *line)
init_macro_token (td);
next_char ();
#ifdef DEBUG_INPUT
- fprintf (stderr, "next_token -> MACDEF (%s)\n",
- find_builtin_by_addr (TOKEN_DATA_FUNC (td))->name);
+ xfprintf (stderr, "next_token -> MACDEF (%s)\n",
+ find_builtin_by_addr (TOKEN_DATA_FUNC (td))->name);
#endif
return TOKEN_MACDEF;
}
@@ -988,8 +988,8 @@ next_token (token_data *td, int *line)
TOKEN_DATA_ORIG_TEXT (td) = orig_text;
#endif
#ifdef DEBUG_INPUT
- fprintf (stderr, "next_token -> %s (%s)\n",
- token_type_string (type), TOKEN_DATA_TEXT (td));
+ xfprintf (stderr, "next_token -> %s (%s)\n",
+ token_type_string (type), TOKEN_DATA_TEXT (td));
#endif
return type;
}
@@ -1045,7 +1045,7 @@ peek_token (void)
}
#ifdef DEBUG_INPUT
- fprintf (stderr, "peek_token -> %s\n", token_type_string (result));
+ xfprintf (stderr, "peek_token -> %s\n", token_type_string (result));
#endif /* DEBUG_INPUT */
return result;
}
@@ -1082,33 +1082,33 @@ token_type_string (token_type t)
static void
print_token (const char *s, token_type t, token_data *td)
{
- fprintf (stderr, "%s: ", s);
+ xfprintf (stderr, "%s: ", s);
switch (t)
{ /* TOKSW */
case TOKEN_OPEN:
case TOKEN_COMMA:
case TOKEN_CLOSE:
case TOKEN_SIMPLE:
- fprintf (stderr, "char:");
+ xfprintf (stderr, "char:");
break;
case TOKEN_WORD:
- fprintf (stderr, "word:");
+ xfprintf (stderr, "word:");
break;
case TOKEN_STRING:
- fprintf (stderr, "string:");
+ xfprintf (stderr, "string:");
break;
case TOKEN_MACDEF:
- fprintf (stderr, "macro: %p\n", TOKEN_DATA_FUNC (td));
+ xfprintf (stderr, "macro: %p\n", TOKEN_DATA_FUNC (td));
break;
case TOKEN_EOF:
- fprintf (stderr, "eof\n");
+ xfprintf (stderr, "eof\n");
break;
}
- fprintf (stderr, "\t\"%s\"\n", TOKEN_DATA_TEXT (td));
+ xfprintf (stderr, "\t\"%s\"\n", TOKEN_DATA_TEXT (td));
}
static void M4_GNUC_UNUSED
diff --git a/src/m4.c b/src/m4.c
index daa15a8..f22788e 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -137,10 +137,10 @@ static void
usage (int status)
{
if (status != EXIT_SUCCESS)
- fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
+ xfprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
{
- printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
+ xprintf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
fputs ("\
Process macros in FILEs. If no FILE or if FILE is `-', standard input\n\
is read.\n\
@@ -154,7 +154,7 @@ Operation modes:\n\
--help display this help and exit\n\
--version output version information and exit\n\
", stdout);
- printf ("\
+ xprintf ("\
-E, --fatal-warnings once: warnings become errors, twice: stop\n\
execution at first error\n\
-i, --interactive unbuffer output, ignore interrupts\n\
@@ -223,7 +223,7 @@ of directories included after any specified by `-I'.\n\
Exit status is 0 for success, 1 for failure, 63 for frozen file version\n\
mismatch, or whatever value was passed to the m4exit macro.\n\
", stdout);
- printf ("\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT);
+ xprintf ("\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT);
}
exit (status);
}
diff --git a/src/m4.h b/src/m4.h
index 38f9d09..a0b54f6 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -45,6 +45,7 @@
#include "unistd--.h"
#include "verror.h"
#include "xalloc.h"
+#include "xprintf.h"
#include "xvasprintf.h"
/* Canonicalize UNIX recognition macros. */
@@ -128,14 +129,14 @@ extern const char *program_name;
void m4_error (int, int, const char *, ...) M4_GNUC_PRINTF(3, 4);
void m4_error_at_line (int, int, const char *, int,
- const char *, ...) M4_GNUC_PRINTF(5, 6);
+ const char *, ...) M4_GNUC_PRINTF(5, 6);
#define M4ERROR(Arglist) (m4_error Arglist)
#define M4ERROR_AT_LINE(Arglist) (m4_error_at_line Arglist)
#ifdef USE_STACKOVF
void setup_stackovf_trap (char *const *, char *const *,
- void (*handler) (void));
+ void (*handler) (void));
#endif
/* File: debug.c --- debugging and tracing function. */
@@ -174,7 +175,7 @@ extern FILE *debug;
do \
{ \
if (debug != NULL) \
- fprintf (debug, Fmt, Arg1); \
+ xfprintf (debug, Fmt, Arg1); \
} \
while (0)
@@ -182,7 +183,7 @@ extern FILE *debug;
do \
{ \
if (debug != NULL) \
- fprintf (debug, Fmt, Arg1, Arg2, Arg3); \
+ xfprintf (debug, Fmt, Arg1, Arg2, Arg3); \
} \
while (0)
@@ -192,7 +193,7 @@ extern FILE *debug;
if (debug != NULL) \
{ \
debug_message_prefix (); \
- fprintf (debug, Fmt); \
+ xfprintf (debug, Fmt); \
putc ('\n', debug); \
} \
} \
@@ -204,7 +205,7 @@ extern FILE *debug;
if (debug != NULL) \
{ \
debug_message_prefix (); \
- fprintf (debug, Fmt, Arg1); \
+ xfprintf (debug, Fmt, Arg1); \
putc ('\n', debug); \
} \
} \
@@ -216,7 +217,7 @@ extern FILE *debug;
if (debug != NULL) \
{ \
debug_message_prefix (); \
- fprintf (debug, Fmt, Arg1, Arg2); \
+ xfprintf (debug, Fmt, Arg1, Arg2); \
putc ('\n', debug); \
} \
} \
@@ -422,6 +423,7 @@ void undivert_all (void);
void expand_user_macro (struct obstack *, symbol *, int, token_data **);
void m4_placeholder (struct obstack *, int, token_data **);
void init_pattern_buffer (struct re_pattern_buffer *, struct re_registers *);
+const char *ntoa (int32_t, int);
const builtin *find_builtin_by_addr (builtin_func *);
const builtin *find_builtin_by_name (const char *);
diff --git a/src/output.c b/src/output.c
index b36cd81..f88fc4b 100644
--- a/src/output.c
+++ b/src/output.c
@@ -197,7 +197,9 @@ m4_tmpname (int divnum)
free (tail);
tail = strrchr (buffer, '-') + 1;
}
- sprintf (tail, "%d", divnum);
+ if (sprintf (tail, "%d", divnum) < 0)
+ M4ERROR ((EXIT_FAILURE, errno,
+ "cannot create temporary file for diversion"));
return buffer;
}
@@ -468,7 +470,6 @@ void
shipout_text (struct obstack *obs, const char *text, int length, int line)
{
static bool start_of_output_line = true;
- char linebuf[20];
const char *cursor;
/* If output goes to an obstack, merely add TEXT to it. */
@@ -519,7 +520,7 @@ shipout_text (struct obstack *obs, const char *text, int
length, int line)
start_of_output_line = false;
output_current_line++;
#ifdef DEBUG_OUTPUT
- fprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
+ xfprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
line, current_line, output_current_line);
#endif
@@ -529,8 +530,13 @@ shipout_text (struct obstack *obs, const char *text, int
length, int line)
if (output_current_line != line)
{
- sprintf (linebuf, "#line %d", line);
- for (cursor = linebuf; *cursor; cursor++)
+ OUTPUT_CHARACTER ('#');
+ OUTPUT_CHARACTER ('l');
+ OUTPUT_CHARACTER ('i');
+ OUTPUT_CHARACTER ('n');
+ OUTPUT_CHARACTER ('e');
+ OUTPUT_CHARACTER (' ');
+ for (cursor = ntoa (line, 10); *cursor; cursor++)
OUTPUT_CHARACTER (*cursor);
if (output_current_line < 1 && current_file[0] != '\0')
{
@@ -553,7 +559,7 @@ shipout_text (struct obstack *obs, const char *text, int
length, int line)
start_of_output_line = false;
output_current_line++;
#ifdef DEBUG_OUTPUT
- fprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
+ xfprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
line, current_line, output_current_line);
#endif
}
@@ -807,7 +813,7 @@ freeze_diversions (FILE *file)
if (diversion->size || diversion->used)
{
if (diversion->size)
- fprintf (file, "D%d,%d\n", diversion->divnum, diversion->used);
+ xfprintf (file, "D%d,%d\n", diversion->divnum, diversion->used);
else
{
struct stat file_stat;
@@ -817,8 +823,8 @@ freeze_diversions (FILE *file)
if (file_stat.st_size < 0
|| file_stat.st_size != (unsigned long int) file_stat.st_size)
M4ERROR ((EXIT_FAILURE, 0, "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 (diversion);
@@ -832,5 +838,5 @@ freeze_diversions (FILE *file)
/* 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/src/path.c b/src/path.c
index cc08109..27ac4cc 100644
--- a/src/path.c
+++ b/src/path.c
@@ -101,7 +101,7 @@ add_include_directory (const char *dir)
dir_list_end = incl;
#ifdef DEBUG_INCL
- fprintf (stderr, "add_include_directory (%s);\n", dir);
+ xfprintf (stderr, "add_include_directory (%s);\n", dir);
#endif
}
@@ -154,7 +154,7 @@ m4_path_search (const char *file, char **result)
strcpy (name + incl->len + 1, file);
#ifdef DEBUG_INCL
- fprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name);
+ xfprintf (stderr, "m4_path_search (%s) -- trying %s\n", file, name);
#endif
fp = fopen (name, "r");
@@ -185,9 +185,9 @@ include_dump (void)
{
includes *incl;
- fprintf (stderr, "include_dump:\n");
+ xfprintf (stderr, "include_dump:\n");
for (incl = dir_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/src/stackovf.c b/src/stackovf.c
index 775ba30..3877cd9 100644
--- a/src/stackovf.c
+++ b/src/stackovf.c
@@ -154,8 +154,9 @@ process_sigsegv (int signo, const char *p)
{
char buf[140];
- sprintf (buf, "process_sigsegv: p=%#lx stackend=%#lx diff=%ld bot=%#lx\n",
- (long) p, (long) stackend, (long) diff, (long) stackbot);
+ snprintf (buf, sizeof buf,
+ "process_sigsegv: p=%#lx stackend=%#lx diff=%ld bot=%#lx\n",
+ (long) p, (long) stackend, (long) diff, (long) stackbot);
write (2, buf, strlen (buf));
}
#endif
diff --git a/src/symtab.c b/src/symtab.c
index 684dc56..872cfaa 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -56,10 +56,10 @@ show_profile (void)
int i;
for (i = 0; i < 5; i++)
{
- fprintf(stderr, "m4: lookup mode %d called %d times, %d compares, "
- "%d misses, %lld bytes\n",
- i, profiles[i].entry, profiles[i].comparisons,
- profiles[i].misses, profiles[i].bytes);
+ xfprintf(stderr, "m4: lookup mode %d called %d times, %d compares, "
+ "%d misses, %lld bytes\n",
+ i, profiles[i].entry, profiles[i].comparisons,
+ profiles[i].misses, profiles[i].bytes);
}
}
@@ -371,7 +371,7 @@ symtab_debug (void)
s = lookup_symbol (text, SYMBOL_LOOKUP);
if (s == NULL)
- printf ("Name `%s' is unknown\n", text);
+ xprintf ("Name `%s' is unknown\n", text);
if (delete)
(void) lookup_symbol (text, SYMBOL_DELETE);
@@ -387,17 +387,17 @@ symtab_print_list (int i)
symbol *sym;
size_t h;
- printf ("Symbol dump #%d:\n", i);
+ xprintf ("Symbol dump #%d:\n", i);
for (h = 0; h < hash_table_size; h++)
for (sym = symtab[h]; sym != NULL; sym = sym->next)
- printf ("\tname %s, bucket %lu, addr %p, next %p, "
- "flags%s%s%s, pending %d\n",
- SYMBOL_NAME (sym),
- (unsigned long int) h, sym, SYMBOL_NEXT (sym),
- SYMBOL_TRACED (sym) ? " traced" : "",
- SYMBOL_SHADOWED (sym) ? " shadowed" : "",
- SYMBOL_DELETED (sym) ? " deleted" : "",
- SYMBOL_PENDING_EXPANSIONS (sym));
+ xprintf ("\tname %s, bucket %lu, addr %p, next %p, "
+ "flags%s%s%s, pending %d\n",
+ SYMBOL_NAME (sym),
+ (unsigned long int) h, sym, SYMBOL_NEXT (sym),
+ SYMBOL_TRACED (sym) ? " traced" : "",
+ SYMBOL_SHADOWED (sym) ? " shadowed" : "",
+ SYMBOL_DELETED (sym) ? " deleted" : "",
+ SYMBOL_PENDING_EXPANSIONS (sym));
}
#endif /* DEBUG_SYM */
--
1.5.3.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- detect printf failures,
Eric Blake <=