Mercurial > hg > octave-avbm
changeset 597:205b8c2ef749
[project @ 1994-08-09 19:31:39 by jwe]
author | jwe |
---|---|
date | Tue, 09 Aug 1994 19:34:10 +0000 |
parents | 07e689d6e7e5 |
children | 80a8a79ea6e4 |
files | src/data.cc src/pt-plot.cc |
diffstat | 2 files changed, 78 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -243,7 +243,10 @@ if (nr < 0 || nc < 0) { if (user_pref.treat_neg_dim_as_zero) - nr = nc = 0; + { + nr = (nr < 0) ? 0 : nr; + nc = (nc < 0) ? 0 : nc; + } else error ("%s: can't create a matrix with negative dimensions", warnfor);
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -33,9 +33,10 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include <string.h> #include <iostream.h> +#include <strstream.h> #include <fstream.h> -#include <strstream.h> #include "SLStack.h" #include "procstream.h" @@ -71,6 +72,76 @@ // Pipe to gnuplot. static oprocstream plot_stream; +static void +open_plot_stream (void) +{ + static int initialized = 0; + + if (! plot_stream.is_open ()) + { + plot_line_count = 0; + + char *plot_prog = user_pref.gnuplot_binary; + if (plot_prog) + { + plot_stream.open (plot_prog); + if (! plot_stream.is_open ()) + { + warning ("plot: unable to open pipe to `%s'", + plot_prog); + + if (strcmp (plot_prog, "gnuplot") != 0) + { + warning ("having trouble finding plotting program."); + warning ("trying again with `gnuplot'"); + goto last_chance; + } + } + } + else + { + last_chance: + + plot_stream.open ("gnuplot"); + + if (! plot_stream.is_open ()) + error ("plot: unable to open pipe to `%s'", plot_prog); + } + } + + if (! initialized) + { + initialized = 1; + plot_stream << "set data style lines\n"; + } +} + +static int +send_to_plot_stream (const char *cmd) +{ +// From sighandlers.cc: + extern int pipe_handler_error_count; + + if (! plot_stream.is_open ()) + { + open_plot_stream (); + + if (error_state) + return -1; + } + + if (plot_line_count == 0 && strncmp (cmd, "replot", 6) == 0) + error ("replot: no previous plot"); + else + { + plot_stream << cmd; + plot_stream.flush (); + pipe_handler_error_count = 0; + } + + return 0; +} + // Plotting, eh? tree_plot_command::tree_plot_command (void) : tree_command () @@ -109,6 +180,8 @@ if (error_state) return; + open_plot_stream (); + ostrstream plot_buf; switch (ndim) @@ -771,62 +844,6 @@ } } -int -send_to_plot_stream (const char *cmd) -{ -// From sighandlers.cc: - extern int pipe_handler_error_count; - - static int initialized = 0; - - if (! plot_stream.is_open ()) - { - plot_line_count = 0; - - char *plot_prog = user_pref.gnuplot_binary; - if (plot_prog) - { - plot_stream.open (plot_prog); - if (! plot_stream.is_open ()) - { - warning ("plot: unable to open pipe to `%s'", - plot_prog); - - if (strcmp (plot_prog, "gnuplot") != 0) - { - warning ("having trouble finding plotting program."); - warning ("trying again with `gnuplot'"); - goto last_chance; - } - } - } - else - { - last_chance: - - plot_stream.open ("gnuplot"); - - if (! plot_stream.is_open ()) - { - error ("plot: unable to open pipe to `%s'", plot_prog); - return -1; - } - } - } - - if (! initialized) - { - initialized = 1; - plot_stream << "set data style lines\n"; - } - - plot_stream << cmd; - plot_stream.flush (); - pipe_handler_error_count = 0; - - return 0; -} - void close_plot_stream (void) {