comparison src/toplev.cc @ 4051:b79da8779a0e

[project @ 2002-08-17 19:38:32 by jwe]
author jwe
date Sat, 17 Aug 2002 19:38:33 +0000
parents 41e7fa40ff4c
children babc519f245b
comparison
equal deleted inserted replaced
4050:6481f41a79f3 4051:b79da8779a0e
28 #include <cstdlib> 28 #include <cstdlib>
29 #include <cstring> 29 #include <cstring>
30 30
31 #include <fstream> 31 #include <fstream>
32 #include <iostream> 32 #include <iostream>
33 #include <strstream>
34 #include <string> 33 #include <string>
35 34
36 #ifdef HAVE_UNISTD_H 35 #ifdef HAVE_UNISTD_H
37 #ifdef HAVE_SYS_TYPES_H 36 #ifdef HAVE_SYS_TYPES_H
38 #include <sys/types.h> 37 #include <sys/types.h>
47 46
48 #include "cmd-edit.h" 47 #include "cmd-edit.h"
49 #include "file-ops.h" 48 #include "file-ops.h"
50 #include "lo-error.h" 49 #include "lo-error.h"
51 #include "lo-mappers.h" 50 #include "lo-mappers.h"
51 #include "lo-sstream.h"
52 #include "oct-env.h" 52 #include "oct-env.h"
53 #include "str-vec.h" 53 #include "str-vec.h"
54 54
55 #include <defaults.h> 55 #include <defaults.h>
56 #include "defun.h" 56 #include "defun.h"
339 { 339 {
340 unwind_protect::add (cleanup_iprocstream, cmd); 340 unwind_protect::add (cleanup_iprocstream, cmd);
341 341
342 if (*cmd) 342 if (*cmd)
343 { 343 {
344 std::ostrstream output_buf; 344 OSSTREAM output_buf;
345 345
346 // XXX FIXME XXX -- sometimes, the subprocess hasn't written 346 // XXX FIXME XXX -- sometimes, the subprocess hasn't written
347 // anything before we try to read from the procstream. The 347 // anything before we try to read from the procstream. The
348 // kluge below (simply waiting and trying again) is ugly, 348 // kluge below (simply waiting and trying again) is ugly,
349 // but it seems to work, at least most of the time. It 349 // but it seems to work, at least most of the time. It
371 if (WIFEXITED (cmd_status)) 371 if (WIFEXITED (cmd_status))
372 cmd_status = WEXITSTATUS (cmd_status); 372 cmd_status = WEXITSTATUS (cmd_status);
373 else 373 else
374 cmd_status = 127; 374 cmd_status = 127;
375 375
376 output_buf << std::ends; 376 output_buf << OSSTREAM_ENDS;
377
378 char *msg = output_buf.str ();
379 377
380 retval(1) = (double) cmd_status; 378 retval(1) = (double) cmd_status;
381 retval(0) = msg; 379 retval(0) = OSSTREAM_STR (output_buf);
382 380
383 delete [] msg; 381 OSSTREAM_FREEZE (output_buf);
384 } 382 }
385 383
386 unwind_protect::run (); 384 unwind_protect::run ();
387 } 385 }
388 else 386 else