comparison src/print.c @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents 2f8bb876ab1d
children de805c49cfc1
comparison
equal deleted inserted replaced
407:ed6218a7d4d3 408:501cfd01ee6d
104 104
105 105
106 106
107 int stdout_needs_newline; 107 int stdout_needs_newline;
108 108
109 #ifdef WINDOWSNT
110 static int no_useful_stderr;
111 #endif
112
109 static void 113 static void
110 std_handle_out_external (FILE *stream, Lisp_Object lstream, 114 std_handle_out_external (FILE *stream, Lisp_Object lstream,
111 const Extbyte *extptr, Extcount extlen, 115 const Extbyte *extptr, Extcount extlen,
112 /* is this really stdout/stderr? 116 /* is this really stdout/stderr?
113 (controls termscript writing) */ 117 (controls termscript writing) */
115 int must_flush) 119 int must_flush)
116 { 120 {
117 if (stream) 121 if (stream)
118 { 122 {
119 #ifdef WINDOWSNT 123 #ifdef WINDOWSNT
124 if (!no_useful_stderr)
125 no_useful_stderr = GetStdHandle (STD_ERROR_HANDLE) == 0 ? 1 : -1;
126
120 /* we typically have no useful stdout/stderr under windows if we're 127 /* we typically have no useful stdout/stderr under windows if we're
121 being invoked graphically. */ 128 being invoked graphically. */
122 if (!noninteractive) 129 if (!noninteractive || no_useful_stderr > 0)
123 msw_output_console_string (extptr, extlen); 130 msw_output_console_string (extptr, extlen);
124 else 131 else
125 #endif 132 #endif
126 { 133 {
127 fwrite (extptr, 1, extlen, stream); 134 fwrite (extptr, 1, extlen, stream);
172 Extbyte *extptr; 179 Extbyte *extptr;
173 Extcount extlen; 180 Extcount extlen;
174 int retval; 181 int retval;
175 182
176 retval = vsprintf ((char *) kludge, fmt, args); 183 retval = vsprintf ((char *) kludge, fmt, args);
177 TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)), 184 if (initialized && !fatal_error_in_progress)
178 ALLOCA, (extptr, extlen), 185 TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)),
179 Qnative); 186 ALLOCA, (extptr, extlen),
187 Qnative);
188 else
189 {
190 extptr = (Extbyte *) kludge;
191 extlen = (Extcount) strlen ((char *) kludge);
192 }
193
180 std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1); 194 std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1);
181 return retval; 195 return retval;
182 } 196 }
183 197
184 /* Output portably to stderr or its equivalent; call GETTEXT on the 198 /* Output portably to stderr or its equivalent; call GETTEXT on the
188 stderr_out (const char *fmt, ...) 202 stderr_out (const char *fmt, ...)
189 { 203 {
190 int retval; 204 int retval;
191 va_list args; 205 va_list args;
192 va_start (args, fmt); 206 va_start (args, fmt);
193 retval = std_handle_out_va (stderr, GETTEXT (fmt), args); 207 retval =
208 std_handle_out_va
209 (stderr, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt,
210 args);
194 va_end (args); 211 va_end (args);
195 return retval; 212 return retval;
196 } 213 }
197 214
198 /* Output portably to stdout or its equivalent; call GETTEXT on the 215 /* Output portably to stdout or its equivalent; call GETTEXT on the
202 stdout_out (const char *fmt, ...) 219 stdout_out (const char *fmt, ...)
203 { 220 {
204 int retval; 221 int retval;
205 va_list args; 222 va_list args;
206 va_start (args, fmt); 223 va_start (args, fmt);
207 retval = std_handle_out_va (stdout, GETTEXT (fmt), args); 224 retval =
225 std_handle_out_va
226 (stdout, initialized && !fatal_error_in_progress ? GETTEXT (fmt) : fmt,
227 args);
208 va_end (args); 228 va_end (args);
209 return retval; 229 return retval;
210 } 230 }
211 231
212 DOESNT_RETURN 232 DOESNT_RETURN