comparison src/print.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 501cfd01ee6d
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
36 #include "extents.h" 36 #include "extents.h"
37 #include "frame.h" 37 #include "frame.h"
38 #include "insdel.h" 38 #include "insdel.h"
39 #include "lstream.h" 39 #include "lstream.h"
40 #include "sysfile.h" 40 #include "sysfile.h"
41 #ifdef WINDOWSNT 41 #ifdef WIN32_NATIVE
42 #include "console-msw.h" 42 #include "console-msw.h"
43 #endif 43 #endif
44 44
45 #include <limits.h>
46 #include <float.h> 45 #include <float.h>
47 /* Define if not in float.h */ 46 /* Define if not in float.h */
48 #ifndef DBL_DIG 47 #ifndef DBL_DIG
49 #define DBL_DIG 16 48 #define DBL_DIG 16
50 #endif 49 #endif
104 103
105 104
106 105
107 int stdout_needs_newline; 106 int stdout_needs_newline;
108 107
109 #ifdef WINDOWSNT 108 #ifdef WIN32_NATIVE
110 static int no_useful_stderr; 109 static int no_useful_stderr;
111 #endif 110 #endif
112 111
113 static void 112 static void
114 std_handle_out_external (FILE *stream, Lisp_Object lstream, 113 std_handle_out_external (FILE *stream, Lisp_Object lstream,
118 int output_is_std_handle, 117 int output_is_std_handle,
119 int must_flush) 118 int must_flush)
120 { 119 {
121 if (stream) 120 if (stream)
122 { 121 {
123 #ifdef WINDOWSNT 122 #ifdef WIN32_NATIVE
124 if (!no_useful_stderr) 123 if (!no_useful_stderr)
125 no_useful_stderr = GetStdHandle (STD_ERROR_HANDLE) == 0 ? 1 : -1; 124 no_useful_stderr = GetStdHandle (STD_ERROR_HANDLE) == 0 ? 1 : -1;
126 125
127 /* we typically have no useful stdout/stderr under windows if we're 126 /* we typically have no useful stdout/stderr under windows if we're
128 being invoked graphically. */ 127 being invoked graphically. */
129 if (!noninteractive || no_useful_stderr > 0) 128 if (!noninteractive || no_useful_stderr > 0)
130 msw_output_console_string (extptr, extlen); 129 mswindows_output_console_string (extptr, extlen);
131 else 130 else
132 #endif 131 #endif
133 { 132 {
134 fwrite (extptr, 1, extlen, stream); 133 fwrite (extptr, 1, extlen, stream);
135 #ifdef WINDOWSNT 134 #ifdef WIN32_NATIVE
136 /* Q122442 says that pipes are "treated as files, not as 135 /* Q122442 says that pipes are "treated as files, not as
137 devices", and that this is a feature. Before I found that 136 devices", and that this is a feature. Before I found that
138 article, I thought it was a bug. Thanks MS, I feel much 137 article, I thought it was a bug. Thanks MS, I feel much
139 better now. - kkm */ 138 better now. - kkm */
140 must_flush = 1; 139 must_flush = 1;
168 1) pre-allocate all the lstreams and do whatever else was necessary 167 1) pre-allocate all the lstreams and do whatever else was necessary
169 to make sure that no allocation occurs, since these functions may be 168 to make sure that no allocation occurs, since these functions may be
170 called from fatal_error_signal(). 169 called from fatal_error_signal().
171 170
172 2) (to be really correct) make a new lstream that outputs using 171 2) (to be really correct) make a new lstream that outputs using
173 msw_output_console_string(). */ 172 mswindows_output_console_string(). */
174 173
175 static int 174 static int
176 std_handle_out_va (FILE *stream, const char *fmt, va_list args) 175 std_handle_out_va (FILE *stream, const char *fmt, va_list args)
177 { 176 {
178 Bufbyte kludge[8192]; 177 Bufbyte kludge[8192];
932 buf [(buf [0] == '-' ? 1 : 0)] = '0'; 931 buf [(buf [0] == '-' ? 1 : 0)] = '0';
933 } 932 }
934 } 933 }
935 #endif /* LISP_FLOAT_TYPE */ 934 #endif /* LISP_FLOAT_TYPE */
936 935
937 /* Print NUMBER to BUFFER. The digits are first written in reverse 936 /* Print NUMBER to BUFFER. This is equivalent to sprintf(buffer,
938 order (the least significant digit first), and are then reversed. 937 "%ld", number), only much faster.
939 This is equivalent to sprintf(buffer, "%ld", number), only much
940 faster.
941 938
942 BUFFER should accept 24 bytes. This should suffice for the longest 939 BUFFER should accept 24 bytes. This should suffice for the longest
943 numbers on 64-bit machines, including the `-' sign and the trailing 940 numbers on 64-bit machines, including the `-' sign and the trailing
944 \0. */ 941 \0. */
945 void 942 void
1557 to stderr. You can use this function to write directly to the terminal. 1554 to stderr. You can use this function to write directly to the terminal.
1558 This function can be used as the STREAM argument of Fprint() or the like. 1555 This function can be used as the STREAM argument of Fprint() or the like.
1559 1556
1560 Under MS Windows, this writes output to the console window (which is 1557 Under MS Windows, this writes output to the console window (which is
1561 created, if necessary), unless XEmacs is being run noninteractively 1558 created, if necessary), unless XEmacs is being run noninteractively
1562 (i.e. using the `-batch' argument). 1559 \(i.e. using the `-batch' argument).
1563 1560
1564 If you have opened a termscript file (using `open-termscript'), then 1561 If you have opened a termscript file (using `open-termscript'), then
1565 the output also will be logged to this file. 1562 the output also will be logged to this file.
1566 */ 1563 */
1567 (char_or_string, stdout_p, device)) 1564 (char_or_string, stdout_p, device))