diff -u -r -N gnuplot-3.7.1.orig/Makefile.in gnuplot-3.7.1-MKDAT-011112/Makefile.in
--- gnuplot-3.7.1.orig/Makefile.in	Wed Oct 27 13:15:10 1999
+++ gnuplot-3.7.1-MKDAT-011112/Makefile.in	Mon Nov 12 00:56:02 2001
@@ -201,7 +201,7 @@
 # List of object files except version.$(O)
 COREOBJS = alloc.$(O) binary.$(O) bitmap.$(O) command.$(O) contour.$(O)\
 	datafile.$(O) eval.$(O) fit.$(O) graphics.$(O) graph3d.$(O) help.$(O)\
-	hidden3d.$(O) internal.$(O) interpol.$(O) matrix.$(O) misc.$(O)\
+	hidden3d.$(O) internal.$(O) interpol.$(O) matrix.$(O) misc.$(O) mkdat.$(O)\
 	parse.$(O) plot.$(O) plot2d.$(O) plot3d.$(O) readline.$(O)\
 	scanner.$(O) set.$(O) show.$(O) specfun.$(O) standard.$(O) stdfn.$(O)\
 	term.$(O) time.$(O) util.$(O) util3d.$(O)
@@ -212,7 +212,7 @@
 
 CSOURCE = alloc.c binary.c bitmap.c command.c contour.c datafile.c eval.c \
 	  fit.c graphics.c graph3d.c help.c hidden3d.c internal.c interpol.c \
-	  matrix.c misc.c parse.c plot.c plot2d.c plot3d.c readline.c \
+	  matrix.c misc.c mkdat.c parse.c plot.c plot2d.c plot3d.c readline.c \
 	  scanner.c set.c show.c specfun.c standard.c stdfn.c term.c time.c \
 	  util.c util3d.c version.c
 
@@ -354,8 +354,8 @@
 	$(srcdir)/mkinstalldirs $(bindir)
 	$(srcdir)/mkinstalldirs $(datadir)
 	$(srcdir)/mkinstalldirs $(mandir)/man1
-	$(INSTALL_PROGRAM) gnuplot $(bindir)/gnuplot
-	test ! -f gnuplot_x11 || $(INSTALL_PROGRAM) gnuplot_x11 $(bindir)/gnuplot_x11
+	$(INSTALL_PROGRAM) gnuplot $(bindir)/gnuplot_mkdat
+	test ! -f gnuplot_x11 || $(INSTALL_PROGRAM) gnuplot_x11 $(bindir)/gnuplot_mkdat_x11
 	-$(INSTALL_DATA) $(srcdir)/docs/gnuplot.1 $(mandir)/man1/gnuplot.1
 	-cd docs && $(MAKE) $(MFLAGS) install
 	@LINUXSUID@
@@ -367,7 +367,7 @@
 lasergnu_noinstall:
 
 uninstall:
-	rm -f $(bindir)/gnuplot $(bindir)/gnuplot_x11
+	rm -f $(bindir)/gnuplot_mkdat $(bindir)/gnuplot_mkdat_x11
 	rm -f $(mandir)/man1/gnuplot.1 $(mandir)/man1/lasergnu.1
 	cd docs && $(MAKE) $(MFLAGS)
 
diff -u -r -N gnuplot-3.7.1.orig/fit.c gnuplot-3.7.1-MKDAT-011112/fit.c
--- gnuplot-3.7.1.orig/fit.c	Fri Oct  1 20:22:14 1999
+++ gnuplot-3.7.1-MKDAT-011112/fit.c	Mon Nov 12 00:53:00 2001
@@ -24,7 +24,7 @@
  *
  *      930726:     Recoding of the Unix-like raw console I/O routines by:
  *                  Michele Marziani (marziani@ferrara.infn.it)
- * drd: start unitialised variables at 1 rather than NEARLY_ZERO
+ * drd: start uninitialised variables at 1 rather than NEARLY_ZERO
  *  (fit is more likely to converge if started from 1 than 1e-30 ?)
  *
  * HBB (Broeker@physik.rwth-aachen.de) : fit didn't calculate the errors
@@ -163,6 +163,8 @@
 static double startup_lambda = 0, lambda_down_factor = LAMBDA_DOWN_FACTOR,
  lambda_up_factor = LAMBDA_UP_FACTOR;
 
+static int steps=0;
+
 /*****************************************************************
 			 internal Prototypes
 *****************************************************************/
@@ -328,6 +330,7 @@
 }
 
 
+
 /*****************************************************************
     Marquardt's nonlinear least squares fit
 *****************************************************************/
@@ -420,6 +423,8 @@
 	return ERROR;
     }
 
+    steps++;
+
     if (tmp_chisq < *chisq) {	/* Success, accept new solution */
 	if (*lambda > MIN_LAMBDA) {
 	    (void) putc('/', stderr);
@@ -533,6 +538,30 @@
     free(tmp_pars);
 }
 
+#define MEASURE_TIME
+
+#include <sys/time.h>
+#include <unistd.h>
+
+#ifndef DST_NONE
+    #define DST_NONE        0       /* not on dst */
+#endif
+
+static double fit_time=0.0;
+static struct timezone fit_tz={0,DST_NONE};
+static struct timeval fit_time1, fit_time2;
+
+#ifdef MEASURE_TIME
+static double eval_time=0.0;
+#endif
+
+void fit_time_init() {
+
+    gettimeofday(&fit_time1, &fit_tz);
+    fit_time=0.0;
+    eval_time=0.0;
+    steps=0;
+}
 
 /*****************************************************************
     call internal gnuplot functions
@@ -544,23 +573,48 @@
     int i;
     struct value v;
 
+#ifdef MEASURE_TIME
+    struct timezone tz={0,DST_NONE};
+    struct timeval time1, time2;
+#endif
+
+#ifdef MEASURE_TIME
+    gettimeofday(&time1, &tz);
+#endif
+
     /* set parameters first */
     for (i = 0; i < num_params; i++) {
 	(void) Gcomplex(&v, par[i], 0.0);
 	setvar(par_name[i], v);
     }
 
+    (void) Gcomplex(&v, fit_z[0], 0.0);
+
     for (i = 0; i < num_data; i++) {
 	/* calculate fit-function value */
 	(void) Gcomplex(&func.dummy_values[0], fit_x[i], 0.0);
 	(void) Gcomplex(&func.dummy_values[1], fit_y[i], 0.0);
 	evaluate_at(func.at, &v);
+
+#if 1
+	if (undefined)
+	  Eex("Undefined value during function evaluation");
+#else
 	if (undefined)
-	    Eex("Undefined value during function evaluation");
+	  fprintf(stderr,"Undefined value during function evaluation:\ni=%d, fit_x[i]=%.15g, fit_y[i]=%.15g, data[i]=%.15g\n", i, fit_x[i], fit_y[i], real(&v));
+#endif
+
 	data[i] = real(&v);
     }
-}
 
+#ifdef MEASURE_TIME
+    gettimeofday(&time2, &tz);
+    eval_time+=((time2.tv_sec-time1.tv_sec)+(time2.tv_usec-time1.tv_usec)/1000000.0);
+    /*
+    fprintf(stderr, "Elapsed time of function evaluation in this step: %.15g sec.\n", ((time2.tv_sec-time1.tv_sec)+(time2.tv_usec-time1.tv_usec)/1000000.0));
+    */
+#endif
+}
 
 /*****************************************************************
     handle user interrupts during fit
@@ -604,6 +658,18 @@
     return TRUE;
 }
 
+show_fit_time() {
+    gettimeofday(&fit_time2, &fit_tz);
+    fit_time=((fit_time2.tv_sec-fit_time1.tv_sec)+(fit_time2.tv_usec-fit_time1.tv_usec)/1000000.0);
+
+    fprintf(stderr, "\n\n");
+    fprintf(stderr, "Number of steps: %d.\n", steps);
+    fprintf(stderr, "Total elapsed time of the fitting: %.5g sec.\n", fit_time);
+    fprintf(stderr, "Average time of a step: %.5g sec.\n", fit_time/steps);
+#ifdef MEASURE_TIME
+    fprintf(stderr, "Elapsed time of function evaluations: %.5g sec (%.5g %%).\n", eval_time, 100.0*eval_time/fit_time);
+#endif
+}
 
 /*****************************************************************
     frame routine for the marquardt-fit
@@ -718,6 +784,9 @@
 	Dblf("======================= \n\n");
 	for (i = 0; i < num_params; i++)
 	    Dblf3("%-15.15s = %-15g\n", par_name[i], a[i]);
+
+	show_fit_time();
+
     } else if (chisq < NEARLY_ZERO) {
 	int i;
 
@@ -726,6 +795,9 @@
 	Dblf("======================= \n\n");
 	for (i = 0; i < num_params; i++)
 	    Dblf3("%-15.15s = %-15g\n", par_name[i], a[i]);
+
+	show_fit_time();
+
     } else {
 	Dblf2("degrees of freedom (ndf) : %d\n",  num_data - num_params);
 	Dblf2("rms of residuals      (stdfit) = sqrt(WSSR/ndf)      : %g\n", sqrt(chisq / (num_data - num_params)));
@@ -774,6 +846,8 @@
 		  par_name[i], a[i], PLUSMINUS, dpar[i], temp);
 	}
 
+	show_fit_time();
+
 	Dblf("\n\ncorrelation matrix of the fit parameters:\n\n");
 	Dblf("               ");
 
@@ -815,6 +889,7 @@
 }
 
 
+
 /*****************************************************************
     display actual state of the fit
 *****************************************************************/
@@ -827,6 +902,9 @@
 FILE *device;
 {
     int k;
+    struct value *v;
+    struct udvt_entry *udv = first_udv;
+    int fit_replot=0;
 
     fprintf(device, "\n\n\
 Iteration %d\n\
@@ -838,6 +916,26 @@
 	    (i > 0 ? "resultant" : "initial set of free"));
     for (k = 0; k < num_params; k++)
 	fprintf(device, "%-15.15s = %g\n", par_name[k], a[k]);
+
+    while (udv) {
+      if ( !strcmp(udv->udv_name, "fit_replot") ) {
+	v=&(udv->udv_value);
+	switch (v->type) {
+	case INTGR:
+	  fit_replot=(int) v->v.int_val;
+	  break;
+	case CMPLX:
+	  fit_replot=(int) v->v.cmplx_val.real;
+	  break;
+	default:
+	  int_error("unknown type in show_fit", NO_CARET);
+	}
+      }
+      udv = udv->next_udv;
+    }
+
+    if (fit_replot && replot_line[0] != NUL)
+      replotrequest();
 }
 
 
@@ -1202,6 +1300,8 @@
     time_t timer;
     int token1, token2, token3;
     char *tmp;
+
+    fit_time_init();
 
     /* first look for a restricted x fit range... */
 
diff -u -r -N gnuplot-3.7.1.orig/gplt_x11.c gnuplot-3.7.1-MKDAT-011112/gplt_x11.c
--- gnuplot-3.7.1.orig/gplt_x11.c	Fri Oct 15 18:04:50 1999
+++ gnuplot-3.7.1-MKDAT-011112/gplt_x11.c	Mon Nov 12 00:43:28 2001
@@ -1135,6 +1135,10 @@
     return NULL;
 }
 
+#ifndef SIGUNUSED
+#define SIGUNUSED       31
+#endif
+
 void
 process_event(event)
 XEvent *event;
@@ -1173,7 +1177,18 @@
 	    plot_struct *plot = find_plot(event->xkey.window);
 	    if (plot)
 		delete_plot(plot);
+	} else if (event->xkey.keycode == XKeysymToKeycode(dpy,XStringToKeysym("u"))) {
+/*
+	    fprintf(stderr, "Sending the UNUSED signal to parent.\n");
+*/
+	    kill(getppid(),SIGUNUSED);
+	} else if (event->xkey.keycode == XKeysymToKeycode(dpy,XStringToKeysym("d"))) {
+/*
+	    fprintf(stderr, "Sending the USR2 signal to parent.\n");
+*/
+	    kill(getppid(),SIGUSR2);
 	}
+
 	break;
     case ClientMessage:
 	if (event->xclient.message_type == WM_PROTOCOLS &&
diff -u -r -N gnuplot-3.7.1.orig/mkdat.c gnuplot-3.7.1-MKDAT-011112/mkdat.c
--- gnuplot-3.7.1.orig/mkdat.c	Thu Jan  1 01:00:00 1970
+++ gnuplot-3.7.1-MKDAT-011112/mkdat.c	Mon Nov 12 15:34:23 2001
@@ -0,0 +1,67 @@
+/* Copyright (C) Gábor Ribárik, 2000-2001. All rights reserved. Before using,
+   copying or modifying this program or any of its components, please read
+   first the file MKDAT_COPYRIGHT.
+*/
+
+#include <stdio.h>
+#include <signal.h>
+
+#include "plot.h"
+
+void
+usr1_handler(int signum)
+{
+  struct udvt_entry *udv = first_udv;
+  double p0;
+  char file[256];
+  FILE *fd;
+
+/*
+  fprintf(stderr, "usr1_handler started.\n");
+*/
+  while (udv) {
+    if ( !strcmp(udv->udv_name, "p0") ) {
+      p0=((udv->udv_value).v.cmplx_val.real)*1.05;
+      (udv->udv_value).v.cmplx_val.real=p0;
+    }
+    udv = udv->next_udv;
+  }
+
+  sprintf(file, "tmp/%d.p0.dat", (int) getppid());
+  if ((fd=fopen(file, "w")) != NULL) {
+    fprintf(fd, "BEGIN {p0=%.15g}\n", p0);
+    fclose(fd);
+  }
+
+  if (replot_line[0] != NUL)
+    replotrequest();
+}
+
+void
+usr2_handler(int signum)
+{
+  struct udvt_entry *udv = first_udv;
+  double p0;
+  char file[256];
+  FILE *fd;
+
+/*
+  fprintf(stderr, "usr2_handler started.\n");
+*/
+  while (udv) {
+    if ( !strcmp(udv->udv_name, "p0") ) {
+      p0=((udv->udv_value).v.cmplx_val.real)/1.05;
+      (udv->udv_value).v.cmplx_val.real=p0;
+    }
+    udv = udv->next_udv;
+  }
+
+  sprintf(file, "tmp/%d.p0.dat", (int) getppid());
+  if ((fd=fopen(file, "w")) != NULL) {
+    fprintf(fd, "BEGIN {p0=%.15g}\n", p0);
+    fclose(fd);
+  }
+
+  if (replot_line[0] != NUL)
+    replotrequest();
+}
diff -u -r -N gnuplot-3.7.1.orig/plot.c gnuplot-3.7.1-MKDAT-011112/plot.c
--- gnuplot-3.7.1.orig/plot.c	Thu Sep 23 15:26:36 1999
+++ gnuplot-3.7.1-MKDAT-011112/plot.c	Mon Nov 12 01:12:44 2001
@@ -313,6 +313,13 @@
     longjmp(command_line_env, TRUE);
 }
 
+#ifndef SIGUNUSED
+#define SIGUNUSED       31
+#endif
+
+void usr1_handler(int);
+void usr2_handler(int);
+
 #if defined(_Windows) || defined(_Macintosh)
 int gnu_main(argc, argv)
 #else
@@ -321,6 +328,10 @@
 int argc;
 char **argv;
 {
+
+signal(SIGUNUSED, usr1_handler);
+signal(SIGUSR2, usr2_handler);
+
 #ifdef LINUXVGA
     LINUX_setup();
 #endif
diff -u -r -N gnuplot-3.7.1.orig/plot2d.c gnuplot-3.7.1-MKDAT-011112/plot2d.c
--- gnuplot-3.7.1.orig/plot2d.c	Mon Oct 11 14:18:56 1999
+++ gnuplot-3.7.1-MKDAT-011112/plot2d.c	Sun May 13 15:09:57 2001
@@ -718,12 +718,15 @@
 int plot_num;
 {
     int i, curve;
+    char s[1024];
+
+    sprintf(s, "%s %s %%c\n", xformat, yformat);
 
     for (curve = 0; curve < plot_num;
 	 curve++, this_plot = this_plot->next_cp) {
 	fprintf(gpoutfile, "#Curve %d, %d points\n#x y type\n", curve, this_plot->p_count);
 	for (i = 0; i < this_plot->p_count; i++) {
-	    fprintf(gpoutfile, "%g %g %c\n",
+	    fprintf(gpoutfile, s,
 		    this_plot->points[i].x,
 		    this_plot->points[i].y,
 		    this_plot->points[i].type == INRANGE ? 'i'
diff -u -r -N gnuplot-3.7.1.orig/term/x11.trm gnuplot-3.7.1-MKDAT-011112/term/x11.trm
--- gnuplot-3.7.1.orig/term/x11.trm	Wed Aug 25 18:16:40 1999
+++ gnuplot-3.7.1-MKDAT-011112/term/x11.trm	Mon Nov 12 00:56:25 2001
@@ -137,7 +137,7 @@
 # ifdef OS2
 static char X11_command[] = "gnuplot_x11.exe";
 # else
-static char X11_command[] = "gnuplot_x11";
+static char X11_command[] = "gnuplot_mkdat_x11";
 # endif /* !OS/2 */
 
 /*   X11_args - scan gnuplot command line for standard X Toolkit options
diff -u -r -N gnuplot-3.7.1.orig/version.c gnuplot-3.7.1-MKDAT-011112/version.c
--- gnuplot-3.7.1.orig/version.c	Fri Oct 22 20:29:53 1999
+++ gnuplot-3.7.1-MKDAT-011112/version.c	Mon Nov 12 15:37:01 2001
@@ -38,7 +38,7 @@
 
 char version[] = "3.7";
 char patchlevel[] = "1";
-char date[] = "Fri Oct 22 18:00:00 BST 1999";
+char date[] = "Fri Oct 22 18:00:00 BST 1999\n\n\tModified by Gábor Ribárik to work with MKDAT-011112.\n\tModifications Copyright (C) Gábor Ribárik, 2000-2001.\n\tAll rights reserved. Before using, copying or modifying\n\tthis modified program or any of its components, please read\n\tfirst the file MKDAT_COPYRIGHT.";
 char gnuplot_copyright[] = "Copyright(C) 1986 - 1993, 1998, 1999";
 
 char faq_location[] = FAQ_LOCATION;

