#include "insdel.h"
#include "lstream.h"
#include "sysfile.h"
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
#include "console-msw.h"
#endif
-#include <limits.h>
#include <float.h>
/* Define if not in float.h */
#ifndef DBL_DIG
int stdout_needs_newline;
+#ifdef WIN32_NATIVE
+static int no_useful_stderr;
+#endif
+
static void
std_handle_out_external (FILE *stream, Lisp_Object lstream,
const Extbyte *extptr, Extcount extlen,
{
if (stream)
{
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
+ if (!no_useful_stderr)
+ no_useful_stderr = GetStdHandle (STD_ERROR_HANDLE) == 0 ? 1 : -1;
+
/* we typically have no useful stdout/stderr under windows if we're
being invoked graphically. */
- if (!noninteractive)
- msw_output_console_string (extptr, extlen);
+ if (!noninteractive || no_useful_stderr > 0)
+ mswindows_output_console_string (extptr, extlen);
else
#endif
{
fwrite (extptr, 1, extlen, stream);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
/* Q122442 says that pipes are "treated as files, not as
devices", and that this is a feature. Before I found that
article, I thought it was a bug. Thanks MS, I feel much
called from fatal_error_signal().
2) (to be really correct) make a new lstream that outputs using
- msw_output_console_string(). */
+ mswindows_output_console_string(). */
static int
std_handle_out_va (FILE *stream, const char *fmt, va_list args)
int retval;
retval = vsprintf ((char *) kludge, fmt, args);
- TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)),
- ALLOCA, (extptr, extlen),
- Qnative);
+ if (initialized && !fatal_error_in_progress)
+ TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)),
+ ALLOCA, (extptr, extlen),
+ Qnative);
+ else
+ {
+ extptr = (Extbyte *) kludge;
+ extlen = (Extcount) strlen ((char *) kludge);
+ }
+
std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1);
return retval;
}
int retval;
va_list args;
va_start (args, fmt);
- retval = std_handle_out_va (stderr, GETTEXT (fmt), args);
+ retval =
+ std_handle_out_va
+ (stderr, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt,
+ args);
va_end (args);
return retval;
}
int retval;
va_list args;
va_start (args, fmt);
- retval = std_handle_out_va (stdout, GETTEXT (fmt), args);
+ retval =
+ std_handle_out_va
+ (stdout, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt,
+ args);
va_end (args);
return retval;
}
}
#endif /* LISP_FLOAT_TYPE */
-/* Print NUMBER to BUFFER. The digits are first written in reverse
- order (the least significant digit first), and are then reversed.
- This is equivalent to sprintf(buffer, "%ld", number), only much
- faster.
+/* Print NUMBER to BUFFER. This is equivalent to sprintf(buffer,
+ "%ld", number), only much faster.
BUFFER should accept 24 bytes. This should suffice for the longest
numbers on 64-bit machines, including the `-' sign and the trailing
Under MS Windows, this writes output to the console window (which is
created, if necessary), unless XEmacs is being run noninteractively
-(i.e. using the `-batch' argument).
+\(i.e. using the `-batch' argument).
If you have opened a termscript file (using `open-termscript'), then
the output also will be logged to this file.