X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Flog.c;h=e3f2f7109ea7f9a709fc0bfbb3029dc2086da3be;hp=b62bf9dd3781cc1e9d2b7a7e59d0471a6ac6b161;hb=2f6aa1d7417df1dfc58597777686fbd77179b9fd;hpb=090f1596ae2eb446c265a62849f59657a9ee9e07 diff --git a/src/log.c b/src/log.c index b62bf9dd..e3f2f710 100644 --- a/src/log.c +++ b/src/log.c @@ -1,6 +1,6 @@ /* Messages logging. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -34,16 +34,27 @@ as that of the covered work. */ #include #include #include -#ifdef HAVE_UNISTD_H -# include -#endif +#include #include #include #include "utils.h" #include "log.h" -/* This file implement support for "logging". Logging means printing +/* 2005-10-25 SMS. + VMS log files are often VFC record format, not stream, so fputs() can + produce multiple records, even when there's no newline terminator in + the buffer. The result is unsightly output with spurious newlines. + Using fprintf() instead of fputs(), along with inhibiting some + fflush() activity below, seems to solve the problem. +*/ +#ifdef __VMS +# define FPUTS( s, f) fprintf( (f), "%s", (s)) +#else /* def __VMS */ +# define FPUTS( s, f) fputs( (s), (f)) +#endif /* def __VMS [else] */ + +/* This file implements support for "logging". Logging means printing output, plus several additional features: - Cataloguing output by importance. You can specify that a log @@ -307,7 +318,7 @@ logputs (enum log_options o, const char *s) return; CHECK_VERBOSE (o); - fputs (s, fp); + FPUTS (s, fp); if (save_context_p) saved_append (s); if (flush_log_p) @@ -397,7 +408,7 @@ log_vprintf_internal (struct logvprintf_state *state, const char *fmt, /* Writing succeeded. */ saved_append (write_ptr); - fputs (write_ptr, fp); + FPUTS (write_ptr, fp); if (state->bigmsg) xfree (state->bigmsg); @@ -416,7 +427,19 @@ logflush (void) { FILE *fp = get_log_fp (); if (fp) - fflush (fp); + { +/* 2005-10-25 SMS. + On VMS, flush only for a terminal. See note at FPUTS macro, above. +*/ +#ifdef __VMS + if (isatty( fileno( fp))) + { + fflush (fp); + } +#else /* def __VMS */ + fflush (fp); +#endif /* def __VMS [else] */ + } needs_flushing = false; } @@ -583,13 +606,13 @@ log_dump_context (void) { struct log_ln *ln = log_lines + num; if (ln->content) - fputs (ln->content, fp); + FPUTS (ln->content, fp); ROT_ADVANCE (num); } while (num != log_line_current); if (trailing_line) if (log_lines[log_line_current].content) - fputs (log_lines[log_line_current].content, fp); + FPUTS (log_lines[log_line_current].content, fp); fflush (fp); }