[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnuplot-info-beta
Subject:    Re: [Fwd: replot; etc]
From:       Lars Hecking <lhecking () nmrc ! ucc ! ie>
Date:       1999-06-01 19:29:10
[Download RAW message or body]

crawford richard writes:
> On Sun, 25 Apr 1999 Lars Hecking <lhecking@nmrc.ucc.ie> wrote:
> 
> >  Is this a bug or a "feature"? Any ideas?
> > 
> > ----- Forwarded message from leopoldo cerbaro <cerbaro@keycomm.it> -----
> > [...]
> > I'm trying to add some functionality to a terminal, so I want to pass
> > something like
> > set term post; set out 'z.ps'; replot; set term linux
> > to the core program from the terminal.
> > this doesn't work (the term isn't changed, it remains the postscript one);
> > because the replot copies the last plot command
> > (replot_line in the source); but if you use
> > replot 1/0
> > this work and all the line is treated, restoring the terminal.
> > [...]
> > ----- End forwarded message -----
> 
> It doesn't have anything to do with the terminal:  Try the following:
> 
>   plot x; set xlabel 'x'
>   replot 1/0; set ylabel 'y'
>   replot; set title 't'
>   replot
> 
> I'd vote for "bug".
 
 Please try the following patch.


--- command.c.orig	Mon May 31 19:37:07 1999
+++ command.c	Tue Jun  1 20:21:46 1999
@@ -761,11 +761,21 @@
      * after do_plot has returned, whence we know all is well
      */
     if (END_OF_COMMAND) {
-	/* it must already be long enough, but lets make sure */
-	int len = strlen(replot_line) + 1;
-	while (input_line_len < len)
+	char *rest_args = &input_line[token[c_token].start_index];
+	int replot_len = strlen(replot_line);
+	int rest_len = strlen(rest_args);
+
+	/* move rest of input line to the start
+	 * necessary because of realloc() in extend_input_line() */
+	memmove(input_line,rest_args,rest_len+1);
+	/* reallocs if necessary */
+	while (input_line_len < replot_len+rest_len+1)
 	    extend_input_line();
-	strcpy(input_line, replot_line);
+	/* move old rest args off start of input line to
+	 * make space for replot_line */
+	memmove(input_line+replot_len,input_line,rest_len+1);
+	/* copy previous plot command to start of input line */
+	strncpy(input_line, replot_line, replot_len);
     } else {
 	char *replot_args = NULL;	/* else m_capture will free it */
 	int last_token = num_tokens - 1;


[[[[ unsubscribe from info-gnuplot-beta via majordomo@dartmouth.edu ]]]]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic