diff -uN original/gnuplot.35/command.c patch/gnuplot.35/command.c --- original/gnuplot.35/command.c Thu Sep 16 04:59:44 1993 +++ patch/gnuplot.35/command.c Thu Sep 15 18:11:54 1994 @@ -27,6 +27,9 @@ * * Gnuplot 3.0 additions: Gershon Elber and many others. * + * Nonlinear Least squares fit: + * Carsten Grammes + * * Changes: * * Feb 5, 1992 Jack Veenstra (veenstra@cs.rochester.edu) Added support to @@ -57,6 +60,8 @@ * info-gnuplot-request@dartmouth.edu * The mailing list for bug reports is * bug-gnuplot@dartmouth.edu + * Send bug reports regarding the fit to + * cagr@rz.uni-sb.de * The list of those interested in beta-test versions is * info-gnuplot-beta@dartmouth.edu */ @@ -70,7 +75,7 @@ void sleep(); /* defined later */ #endif -#ifdef OS2 +#if defined(OS2) || defined(MTOS) #include extern jmp_buf env; /* from plot.c */ #endif @@ -108,8 +113,8 @@ #endif /* MSDOS */ -#ifdef ATARI -#ifdef __PUREC__ +#if defined(ATARI) || defined(MTOS) +#if defined(__PUREC__) && !defined(__MINT__) #include #include #include @@ -126,6 +131,7 @@ #include "plot.h" #include "setshow.h" +#include "fit.h" #ifndef _Windows #include "help.h" #else @@ -172,7 +178,7 @@ * instead of */ -#ifndef ATARI +#if !defined(ATARI) && !defined(MTOS) #ifdef _Windows #include #include @@ -190,7 +196,7 @@ #endif /* !AMIGA_SC_6_1 */ #endif #else -#ifdef __PUREC__ +#if defined(__PUREC__) && !defined(__MINT__) /* * a substitute for PureC's buggy sscanf. * this uses the normal sscanf and fixes the following bugs: @@ -389,6 +395,10 @@ /* If last plot was a 3d one. */ TBOOLEAN is_3d_plot = FALSE; +#define min(a,b) ((a)>(b) ? (b) : (a)) +#define Inc_c_token if (++c_token >= num_tokens) \ + int_error ("Syntax error", c_token); + com_line() { if (read_line(PROMPT)) @@ -477,6 +487,9 @@ #endif #ifdef OS2 if( strcmp(term_tbl[term].name, "pm" )!=0 || stime >=0 ) +#endif +#ifdef MTOS + if( strcmp(term_tbl[term].name, "mtos" )!=0 || stime >=0 ) #endif (void) fprintf(stderr, "%s", buf); text = 1; @@ -499,11 +512,25 @@ text = 1; (void) fgets(buf, MAX_LINE_LEN, stdin); } - } + } +#else +#ifdef MTOS + if( strcmp(term_tbl[term].name, "mtos" )==0 && stime < 0 ) { + int rc; + + if ((rc = MTOS_pause(buf)) == 0) + longjmp(env,TRUE); + else if (rc == 2) { + (void) fprintf(stderr, "%s", buf); + text = 1; + (void) fgets(buf, MAX_LINE_LEN, stdin); + } + } #else (void) fgets(buf, MAX_LINE_LEN, stdin); - /* Hold until CR hit. */ -#endif /*OS2*/ + /* Hold until CR hit. */ +#endif /* MTOS */ +#endif /*OS2*/ #endif #ifdef __ZTC__ if (stime > 0) @@ -516,7 +543,8 @@ (void) fprintf(stderr, "\n"); c_token++; screen_ok = FALSE; - } else if (almost_equals(c_token, "pr$int")) { + } + else if (almost_equals(c_token, "pr$int")) { struct value a; c_token++; @@ -525,7 +553,78 @@ disp_value(stderr, &a); (void) putc('\n', stderr); screen_ok = FALSE; - } else if (almost_equals(c_token, "p$lot")) { + } else if (almost_equals(c_token,"fit")) { + register int tmp_token = c_token++, + len, + xcol=1, + ycol=2, + dycol=0; /* default: no weights */ + char fitfunction[80], + datafile[80], + paramsfile[256], + tmps[80]; + + /* + * Syntax: fit f(x) "datafile" > "paramsfile" + * or: fit f(x) "datafile" > via p1, p2,... + */ + while ( !isstring(++tmp_token) && tmp_token expected", c_token); + copy_str (tmps, c_token); + xcol = atoi(tmps); + Inc_c_token + copy_str (tmps, c_token); + if ( strcmp (tmps,":") ) + int_error ("xcol:ycol<:yerr> expected", c_token); + Inc_c_token + copy_str (tmps, c_token); + if ( !isnumber (c_token) ) + int_error ("xcol:ycol<:yerr> expected", c_token); + ycol = atoi(tmps); + Inc_c_token + copy_str (tmps, c_token); + if ( !strcmp (tmps,":") ) { + Inc_c_token + copy_str (tmps, c_token); + if ( !isnumber (c_token) ) + int_error ("xcol:ycol<:yerr> expected", c_token); + dycol = atoi (tmps); + Inc_c_token + } + } + if ( !strnicmp(&input_line[token[c_token].start_index], "via ", 4) ) + strcpy (paramsfile, &input_line[token[c_token].start_index]); + else { + if ( !isstring(c_token) ) + int_error ("Parameter file expected", c_token); + quote_str (paramsfile, c_token); + if ( c_token < num_tokens-1 ) + int_error ("extra input causes syntax error", ++c_token); + } + do_fit (fitfunction, datafile, xcol, ycol, dycol, paramsfile); + } + else if (almost_equals(c_token,"up$date")) { + char tmps[80]; + if ( !isstring(++c_token) ) + int_error ("Parameter filename expected", c_token); + quote_str (tmps, c_token++); + update (tmps); + } + else if (almost_equals(c_token, "p$lot")) { plot_token = c_token++; #ifdef _Windows SetCursor(LoadCursor((HINSTANCE)NULL, IDC_WAIT)); @@ -621,15 +720,15 @@ int_error("expecting directory name", c_token); else { quotel_str(sv_file, c_token); -#if defined(MSDOS) || defined(_Windows) || defined(ATARI) || defined(DOS386) +#if defined(MSDOS) || defined(_Windows) || defined(ATARI) || defined(MTOS) || defined(DOS386) if (!((strlen(sv_file)==2) && isalpha(sv_file[0]) && (sv_file[1]==':'))) #endif if (chdir(sv_file)) { int_error("Can't change to this directory", c_token); } -#if defined(MSDOS) || defined(_Windows) || defined(ATARI) || defined(DOS386) +#if defined(MSDOS) || defined(_Windows) || defined(ATARI) || defined(MTOS) || defined(DOS386) if (isalpha(sv_file[0]) && (sv_file[1]==':')) { -#ifdef ATARI +#if defined(ATARI) || defined (MTOS) (void)Dsetdrv(toupper(sv_file[0])-'A'); #endif @@ -1597,7 +1696,7 @@ this_plot->iso_crvs = NULL; } if (!more_data_fp && is_binary_file(data_fp)) { /* MOD--RKC */ -#if defined(MSDOS)||defined(ATARI)||defined(OS2)||defined(_Windows)||defined(DOS386) +#if defined(MSDOS)||defined(ATARI)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386) /* file must be opened with binary flag. the old cr/lf problem again */ #ifdef PIPES if( pipe_open ) { @@ -3852,7 +3951,7 @@ getparms(input_line + 1, parms); if (fexecv(parms[0], parms) < 0) #else -#if defined(ATARI)&&defined(__GNUC__) +#if (defined(ATARI)&&defined(__GNUC__)) || (defined(MTOS)&&defined(__GNUC__)) /* use preloaded shell, if available */ short (*shell_p) (char *command); void *ssp; diff -uN original/gnuplot.35/contour.c patch/gnuplot.35/contour.c --- original/gnuplot.35/contour.c Thu Sep 16 04:59:44 1993 +++ patch/gnuplot.35/contour.c Thu Sep 15 18:11:56 1994 @@ -83,7 +83,7 @@ #define abs(x) ((x) > 0 ? (x) : (-(x))) #define sqr(x) ((x) * (x)) -#ifndef AMIGA_AC_5 +#if !defined(AMIGA_AC_5) && !defined(MTOS) && !defined(ATARI) extern double sqrt(); #endif /* not AMIGA_AC_5 */ typedef double tri_diag[3]; /* Used to allocate the tri-diag matrix. */ diff -uN original/gnuplot.35/corplot.c patch/gnuplot.35/corplot.c --- original/gnuplot.35/corplot.c Tue May 25 17:30:02 1993 +++ patch/gnuplot.35/corplot.c Thu Sep 15 18:11:56 1994 @@ -53,7 +53,7 @@ #include #include #include -#if defined(ATARI) && defined(__PUREC__) +#if (defined(ATARI) && defined(__PUREC__)) ) || (defined(MTOS)&&defined(__PUREC__)) #include #endif Common subdirectories: original/gnuplot.35/demo and patch/gnuplot.35/demo Common subdirectories: original/gnuplot.35/docs and patch/gnuplot.35/docs diff -uN original/gnuplot.35/fit.c patch/gnuplot.35/fit.c --- original/gnuplot.35/fit.c +++ patch/gnuplot.35/fit.c Thu Sep 15 18:12:56 1994 @@ -0,0 +1,1291 @@ +#ifndef lint +static char *RCSid = "$Id: fit.c 1.3 1993/08/03 07:14:17 cg Exp cg $"; +#endif + +/* + * Nonlinear least squares fit according to the + * Marquardt-Levenberg-algorithm + * + * added as Patch to Gnuplot (v3.2 and higher) + * by Carsten Grammes + * Experimental Physics, University of Saarbruecken, Germany + * + * Internet address: cagr@rz.uni-sb.de + * + * Copyright of this module: Carsten Grammes, 1993 + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * This software is provided "as is" without express or implied warranty. + * + * 930726: Recoding of the Unix-like raw console I/O routines by: + * Michele Marziani (marziani@ferrara.infn.it) + */ + + +#define FIT_MAIN + +#include +#include + +#include +#include +#include +#include +#include + +#if defined(MSDOS) || defined(DOS386) /* non-blocking IO stuff */ +#include +#include +#include +#else +#if defined(AMIGA_SC_6_1) +#include +#include +#include +#include +#include +#include +#include +#else +#if defined(ATARI) || defined(MTOS) +#include +#else +#include +#include +#endif +#endif +#endif + +#include +#define STANDARD stderr /* compatible with gnuplot philosophy */ + +#include "plot.h" +#include "type.h" /* own types */ +#include "matrix.h" +#include "fit.h" + +enum marq_res { OK, ERROR, BETTER, WORSE }; +typedef enum marq_res marq_res_t; + + +#define INFINITY 1e30 +#define NEARLY_ZERO 1e-30 +#define DELTA 0.001 +#define MAX_DATA 2048 +#define MAX_PARAMS 32 +#define MAX_LAMBDA 1e20 +#define MAX_VALUES_PER_LINE 32 +#define MAX_VARLEN 32 +#define START_LAMBDA 0.01 +#if defined(MSDOS) || defined(OS2) || defined(DOS386) +#define PLUSMINUS "\xF1" /* plusminus sign */ +#else +#define PLUSMINUS "+/-" +#endif + +static double epsilon = 1e-5; /* convergence criteria */ + +static char fitfunction[80]; +static char fit_script[127]; +static char logfile[128] = "fit.log"; +static char *fit_index_def = "FIT_INDEX"; +static char *FIXED = "# FIXED"; +static char *GNUFITLOG = "FIT_LOG"; +static char *FITLIMIT = "FIT_LIMIT"; +static char *FITSCRIPT = "FIT_SCRIPT"; +static char *DEFAULT_CMD = "replot"; /* if no fitscript spec. */ +static char *TEMPNAME = "gfttemp.$$$"; + + +static FILE *log_f = NULL; + +static word num_data, + num_params, + skip; +static double *fit_x, + *fit_y, + *err_data, + *a; + +static struct udft_entry func; + +typedef char fixstr[MAX_VARLEN+1]; +static fixstr *par_name; + +extern jmp_buf env; /* from plot.c */ +extern char input_line[]; /* command.c */ + +#if !defined(MSDOS) && !defined(DOS386) && !defined(AMIGA_SC_6_1) +static char buff = 0; /* Unix, Linux, OS/2: buffer for getch(), kbhit() */ +#ifndef OS2 +#define getchx getch /* Unix or Linux */ +#endif +#endif + +/***************************************************************** + internal Prototypes +*****************************************************************/ + +static marq_res_t marquardt (double a[], double **alpha, double *chisq, + double *lambda, double *varianz); +static boolean analyze (double a[], double **alpha, double beta[], + double *chisq, double *varianz); +static void calculate (double *yfunc, double **dyda, double a[]); +static void call_gnuplot (double *par, double *data); +static void show_fit (int i, double chisq, double last_chisq, double *a, + double lambda, FILE *device); +static boolean regress (double a[]); +static int scan_num_entries (char *s, double vlist[]); +static boolean is_variable (char *s); +static void copy_max (char *d, char *s, int n); +static double getdvar (char *varname); +static void splitpath (char *s, char *p, char *f); +static void subst (char *s, char from, char to); +static void dbl_fprintf (FILE *f1, FILE *f2, char *s, ...); +static boolean fit_interrupt (); +static boolean is_empty (char *s); + + +extern struct value *Gcomplex(struct value *v, double re, double im); +extern struct value *Ginteger(struct value *a, int i); +extern double real(struct value *val); +extern void evaluate_at(struct at_type *at_ptr, struct value *val_ptr); +extern int do_line (); + +#if !defined(MSDOS) && !defined(DOS386) && !defined(AMIGA_SC_6_1) +/* non-blocking IO stuff */ +static int kbhit(); +static int getch(); +#endif + +/***************************************************************** + in case of fatal errors +*****************************************************************/ +void error_ex (char *s, ...) +{ + va_list p; + char tmp[128], + *sp; + + strcpy (tmp, " "); /* start after GNUPLOT> */ + va_start (p, s); + vsprintf (tmp+9, s, p); + va_end (p); + sp = strchr (tmp, '\0'); + while ( *--sp == '\n' ) + ; + strcpy (sp+1, "\n\n"); /* terminate with exactly 2 newlines */ + fprintf (STANDARD, tmp); + if ( log_f ) { + fprintf (log_f, "BREAK: %s", tmp); + fclose (log_f); + log_f = NULL; + } + if ( func.at ) { + free (func.at); /* release perm. action table */ + func.at = (struct at_type *) NULL; + } + +/* restore raw or cooked */ +#if defined(AMIGA_SC_6_1) + (void) rawcon (0); /* Since we're returning to the command level, */ + /* we might as well assume non-raw mode. */ +#endif + + longjmp(env, TRUE); /* bail out to command line */ +} + + + +/***************************************************************** + fprintf to 2 streams at a time +*****************************************************************/ +static void dbl_fprintf (FILE *f1, FILE *f2, char *s, ...) +{ + va_list p; + + va_start (p, s); + vfprintf (f1, s, p); + va_start (p, s); + vfprintf (f2, s, p); + va_end (p); +} + + +/***************************************************************** + Marquardt's nonlinear least squares fit +*****************************************************************/ +static marq_res_t marquardt (double a[], double **alpha, double *chisq, + double *lambda, double *varianz) +{ + int j; + static double *da, /* delta-step of the parameter */ + *temp_a, /* temptative new params set */ + **one_da, + *beta, + *tmp_beta, + **tmp_alpha, + **covar, + old_chisq; + + /* Initialization when lambda < 0 */ + + if ( *lambda < 0 ) { /* Get first chi-square check */ + one_da = matr (num_params, 1); + temp_a = vec (num_params); + beta = vec (num_params); + tmp_beta = vec (num_params); + da = vec (num_params); + covar = matr (num_params, num_params); + tmp_alpha = matr (num_params, num_params); + + *lambda = -*lambda; /* make lambda positive */ + return analyze (a, alpha, beta, chisq, varianz) ? OK : ERROR; + } + old_chisq = *chisq; + + for ( j=0 ; j 1e-20 ) + *lambda /= 10; + old_chisq = *chisq; + for ( j=0 ; jufbfh; + if (IsInteractive (StdinHandle) && + WaitForChar (StdinHandle, 0) == DOSTRUE) { + fread (&c, 1, 1, stdin); +#else /* !AMIGA_SC_6_1 */ + if ( kbhit () ) { + do { getchx (); } while ( kbhit() ); +#endif /* !AMIGA_SC_6_1 */ + show_fit (i, chisq, last_chisq, a, lambda, STANDARD); + if ( !fit_interrupt () ) /* handle keys */ + break; + } + if ( res == BETTER ) { + i++; + last_chisq = chisq; + } + if ( (res = marquardt (a, alpha, &chisq, &lambda, &varianz)) == BETTER ) + show_fit (i, chisq, last_chisq, a, lambda, STANDARD); + } + while ( res != ERROR && lambda < MAX_LAMBDA && + (res == WORSE || (last_chisq-chisq)/chisq > epsilon) ); + + dbl_fprintf (STANDARD, log_f, "\nAfter %d iterations the fit converged.\n", i); + dbl_fprintf (STANDARD, log_f, "final sum of squares residuals : %g\n", chisq); + dbl_fprintf (STANDARD, log_f, "rel. change during last iteration : %g\n\n", (chisq-last_chisq)/chisq); + + if ( res == ERROR ) + error_ex ("FIT: error occured during fit"); + + /* compute errors in the parameters */ + + for ( i=0 ; i= n ) + d[n-1] = '\0'; +} + + +/***************************************************************** + Slow but portable implementation of strnicmp +*****************************************************************/ +/* + * please don't add further machine-specific macros, use -DSTRNICMP + * as compiler switch if necessary + */ + +#ifdef STRNICMP +int strnicmp (char *s1, char *s2, int n) +{ + static char ss1[256], ss2[256]; + register char *p; + + copy_max (ss1, s1, sizeof(ss1)); + copy_max (ss2, s2, sizeof(ss2)); + p = ss1-1; + while ( *++p ) + toupper ( *p ); + p = ss2-1; + while ( *++p ) + toupper ( *p ); + return strncmp (ss1, ss2, n); +} +#endif + + +/***************************************************************** + first time settings +*****************************************************************/ +void init_fit () +{ + struct value val; + + /* index used for multi-branch functions */ + fit_index = fit_index_def; + val.type = INTGR; + val.v.int_val = 0; + setvar (fit_index, val); + func.at = (struct at_type *) NULL; /* need to parse 1 time */ +} + + +/***************************************************************** + Set a GNUPLOT user-defined variable +******************************************************************/ +extern struct udvt_entry *first_udv; + +void setvar (char *varname, struct value data) +{ + register struct udvt_entry *udv_ptr = first_udv, + *last = first_udv; + + /* check if it's already in the table... */ + + while (udv_ptr) { + last = udv_ptr; + if ( !strcmp (varname, udv_ptr->udv_name)) + break; + udv_ptr = udv_ptr->next_udv; + } + + if ( !udv_ptr ) { /* generate new entry */ + last->next_udv = udv_ptr = (struct udvt_entry *) + alloc ((unsigned int)sizeof(struct udvt_entry), "setvar"); + udv_ptr->next_udv = NULL; + } + copy_max (udv_ptr->udv_name, varname, sizeof(udv_ptr->udv_name)); + udv_ptr->udv_value = data; + udv_ptr->udv_undef = FALSE; +} + + + +/***************************************************************** + Read INTGR Variable value, return 0 if undefined or wrong type +*****************************************************************/ +int getivar (char *varname) +{ + register struct udvt_entry *udv_ptr = first_udv; + + while (udv_ptr) { + if ( !strcmp (varname, udv_ptr->udv_name)) + return udv_ptr->udv_value.type == INTGR + ? udv_ptr->udv_value.v.int_val /* valid */ + : 0; /* wrong type */ + udv_ptr = udv_ptr->next_udv; + } + return 0; /* not in table */ +} + + +/***************************************************************** + Read DOUBLE Variable value, return 0 if undefined or wrong type +*****************************************************************/ +static double getdvar (char *varname) +{ + register struct udvt_entry *udv_ptr = first_udv; + + while (udv_ptr) { + if ( !strcmp (varname, udv_ptr->udv_name)) + return udv_ptr->udv_value.type == CMPLX + ? udv_ptr->udv_value.v.cmplx_val.real /* valid */ + : 0; /* wrong type */ + udv_ptr = udv_ptr->next_udv; + } + return 0; /* not in table */ +} + + +/***************************************************************** + Split Identifier into path and filename +*****************************************************************/ +static void splitpath (char *s, char *p, char *f) +{ + register char *tmp; + tmp = s + strlen(s) - 1; + while ( *tmp != '\\' && *tmp != '/' && *tmp != ':' && tmp-s >= 0 ) + tmp--; + strcpy (f, tmp+1); + strncpy (p, s, tmp-s+1); + p[tmp-s+1] = '\0'; +} + + +/***************************************************************** + Character substitution +*****************************************************************/ +static void subst (char *s, char from, char to) +{ + while ( *s ) { + if ( *s == from ) + *s = to; + s++; + } +} + + +/***************************************************************** + write the actual parameters to start parameter file +*****************************************************************/ +void update (char *pfile) +{ + char fnam[256], + path[256], + tmpnam[256], + sstr[256], + pname[64], + tail[127], + *s = sstr, +#if !defined(AMIGA_SC_6_1) + *tmpn, +#endif + *tmp, + c; + FILE *of, + *nf; + double pval; + + /* split into path and filename */ + +#if defined(MSDOS) || defined(DOS386) + /* don't get problems during system() call */ + subst (pfile, '/', '\\'); +#endif + splitpath (pfile, path, fnam); + if ( !(of = fopen (pfile, "r")) ) + error_ex ("parameter file %s could not be read", pfile); +#if defined(AMIGA_SC_6_1) + sprintf (tmpnam, "%sgf%08lx", path, FindTask (NULL)); +#else /* !AMIGA_SC_6_1 */ + /* Under MSDOS rename will not work properly if TMP points to another + * drive/dir. In this case use 'path' directory for tempfile + */ +#if defined (MSDOS) || defined (OS2) + sprintf (tmpnam, "%s%s", path, TEMPNAME); +#else +#if defined(ATARI) || defined(MTOS) + tmpn = mktemp("GFTXXXXX"); + if ( tmpn == NULL ) + error_ex ("no more unique names possible during updating"); + sprintf (tmpnam, "%s%s", path, tmpn); +#else + tmpn = tempnam (path, "gnuft"); + if ( tmpn == NULL ) + error_ex ("no more unique names possible during updating"); + strcpy (tmpnam, tmpn); + free (tmpn); +#endif /*ATARI */ +#endif /* MSDOS */ +#endif /* !AMIGA_SC_6_1 */ + if ( !(nf = fopen (tmpnam, "w")) ) + error_ex ("could not open temporary file"); + while ( TRUE ) { + if ( !fgets (s = sstr, sizeof(sstr), of) ) /* EOF found */ + break; + if ( is_empty(s) ) { + fprintf (nf, s); /* preserve comments */ + continue; + } + if ( tmp = strchr (s, '#') ) { + copy_max (tail, tmp, sizeof(tail)); + *tmp = '\0'; + } + else + strcpy (tail, "\n"); + tmp = get_next_word (&s, &c); + if ( !is_variable (tmp) || strlen(tmp) > MAX_VARLEN ) { + fclose (of); + error_ex ("syntax error in parameter file %s", fnam); + } + copy_max (pname, tmp, sizeof(pname)); + /* next must be '=' */ + if ( c != '=' ) { + tmp = strchr (s, '='); + if ( tmp == NULL ) { + fclose (of); + error_ex ("syntax error in parameter file %s", fnam); + } + s = tmp+1; + } + tmp = get_next_word (&s, &c); + if ( !sscanf (tmp, "%lg", &pval) ) { + fclose (of); + error_ex ("syntax error in parameter file %s", fnam); + } + if ( (tmp = get_next_word (&s, &c)) != NULL ) { + fclose (of); + error_ex ("syntax error in parameter file %s", fnam); + } + + /* now modify */ + + if ( (pval = getdvar (pname)) == 0 ) + pval = (double) getivar (pname); + + sprintf (sstr, "%g", pval); + if ( !strchr (sstr, '.') && !strchr (sstr, 'e') ) + strcat (sstr, ".0"); /* assure CMPLX-type */ + fprintf (nf, "%-15.15s = %-15.15s %s", pname, sstr, tail); + } + if ( fclose (of) || fclose (nf) ) + error_ex ("I/O error during update"); + + if ( unlink (pfile) ) /* implies write permission !!!! */ + error_ex ("parameter file %s could not be deleted", pfile); + +#if defined(MSDOS) || defined(OS2) + sprintf (sstr, "ren %s %s", tmpnam, fnam); + if ( system (sstr) ) +#else /* implies write permission !!!! */ + if ( rename (tmpnam, pfile) ) +#endif + error_ex ("unable to rename %s to %s", tmpnam, pfile); +} + + + +/***************************************************************** + Interface to the classic gnuplot-software +*****************************************************************/ +void do_fit (char *fitfunc, char *datafile, int xcol, int ycol, int dycol, + char *paramsfile) +{ + FILE *f; + int i, num, num_rawdata; + static char sstr[1024]; + char c, + *s = sstr, + *tmp; + double vlist[MAX_VALUES_PER_LINE], + tmpd; + time_t timer; + + +/* Amiga: force terminal to raw mode to handle user interrupts */ +#if defined(AMIGA_SC_6_1) + (void) rawcon (1); +#endif + + strcpy (fitfunction, fitfunc); + if ( !(f = fopen (datafile, "r")) ) + error_ex ("datafile %s could not be read", datafile); + + tmpd = getdvar (FITLIMIT); /* get epsilon if given explicitly */ + if ( tmpd < 1.0 && tmpd > 0.0 ) + epsilon = tmpd; + + *fit_script = '\0'; /* FIT_SKIP 1 means each 2nd value */ + if ( tmp = getenv (FITSCRIPT) ) + strcpy (fit_script, tmp); + skip = 1 + (word) getivar (FIT_SKIP); + + tmp = getenv (GNUFITLOG); /* open logfile */ + if ( tmp != NULL ) { + char *tmp2 = &tmp[strlen(tmp)-1]; + if ( *tmp2 == '/' || *tmp2 == '\\' ) + sprintf (logfile, "%s%s", tmp, logfile); + else + strcpy (logfile, tmp); + } + if ( !(log_f = fopen (logfile, "a")) ) + error_ex ("could not open log-file %s", logfile); + fprintf (log_f, "\n\n*******************************************************************************\n"); + time (&timer); + fprintf (log_f, "%s\n\n", ctime (&timer)); + fprintf (log_f, "FIT: data from %s\n x = column #%d\n y = column #%d\n", + datafile, xcol, ycol); + + fit_x = vec (MAX_DATA); /* start with max. value */ + fit_y = vec (MAX_DATA); + + /* first read in experimental data */ + + err_data = vec (MAX_DATA); + num_rawdata = num_data = 0; + while ( TRUE ) { + if ( ! fgets (s = sstr, sizeof(sstr), f) ) + break; /* EOF found */ + if ( is_empty(s) ) + continue; + if ( num_data==MAX_DATA ) { + fclose (f); + error_ex ("max. # of datapoints %d exceeded", MAX_DATA); + } + /* expecting n value entries (x, y (, yerror) ) */ + num = scan_num_entries (s, vlist); + if ( xcol>num || ycol>num || dycol>num ) { + fclose (f); + error_ex ("columns in %s do not match specification", datafile); + } + if ( ++num_rawdata % skip ) /* ignore this one */ + continue; + fit_x[num_data] = vlist[xcol]; + fit_y[num_data] = vlist[ycol]; + err_data[num_data++] = dycol ? vlist[dycol] : 1; + } + fclose (f); + /* now resize fields */ + redim_vec (&fit_x, num_data); + redim_vec (&fit_y, num_data); + redim_vec (&err_data, num_data); + + fprintf (log_f, " #datapoints = %d", num_rawdata); + if ( skip > 1 ) + fprintf (log_f, " use each %d. value\n", skip); + else + fprintf (log_f, "\n"); + if ( dycol ) + fprintf (log_f, " y-error = column #%d\n\n", dycol); + else + fprintf (log_f, " y-errors assumed equally distributed\n\n"); + fprintf (log_f, "function used for fitting: %s\n", fitfunction); + + /* read in parameters */ + + a = vec (MAX_PARAMS); + if ((par_name = (fixstr *) malloc ((MAX_PARAMS+1)*sizeof(fixstr))) == NULL) + error_ex ("Memory running low during fit"); + num_params = 0; + + if ( !strnicmp (paramsfile, "via ", 4) ) { /* no values given */ + char *tmp2; + + fprintf (log_f, "use actual parameter values\n\n"); + paramsfile += 4; + do { + tmp = strchr (paramsfile, ','); + if ( tmp != NULL ) + *tmp = '\0'; + tmp2 = get_next_word (¶msfile, &c); + if ( tmp2 == NULL ) + error_ex ("no parameter specified"); + copy_max (par_name[num_params], tmp2, sizeof(fixstr)); + a[num_params] = getdvar (par_name[num_params]); + num_params++; + paramsfile = tmp+1; + } + while ( tmp ); + } + else { + boolean fixed; + double tmp_par; + + /* get parameters and values out of file and ignore fixed ones */ + + fprintf (log_f, "take parameters from file: %s\n\n", paramsfile); + if ( !(f = fopen (paramsfile, "r")) ) + error_ex ("could not read parameter-file %s", paramsfile); + while ( TRUE ) { + if ( !fgets (s = sstr, sizeof(sstr), f) ) /* EOF found */ + break; + if ( tmp = strstr (s, FIXED) ) { /* ignore fixed params */ + *tmp = '\0'; + fprintf (log_f, "FIXED: %s\n", s); + fixed = TRUE; + } + else + fixed = FALSE; + if ( tmp = strchr (s, '#') ) + *tmp = '\0'; + if ( is_empty(s) ) + continue; + tmp = get_next_word (&s, &c); + if ( !is_variable (tmp) || strlen(tmp) > MAX_VARLEN ) { + fclose (f); + error_ex ("syntax error in parameter file %s", paramsfile); + } + copy_max (par_name[num_params], tmp, sizeof(fixstr)); + /* next must be '=' */ + if ( c != '=' ) { + tmp = strchr (s, '='); + if ( tmp == NULL ) { + fclose (f); + error_ex ("syntax error in parameter file %s", paramsfile); + } + s = tmp+1; + } + tmp = get_next_word (&s, &c); + if ( !sscanf (tmp, "%lg", &tmp_par) ) { + fclose (f); + error_ex ("syntax error in parameter file %s", paramsfile); + } + + /* make fixed params visible to GNUPLOT */ + if ( fixed ) { + struct value v; + Gcomplex (&v, tmp_par, 0.0); + setvar (par_name[num_params], v); /* use parname as temp */ + } + else + a[num_params++] = tmp_par; + + if ( (tmp = get_next_word (&s, &c)) != NULL ) { + fclose (f); + error_ex ("syntax error in parameter file %s", paramsfile); + } + } + fclose (f); + } + redim_vec (&a, num_params); + par_name = (fixstr *) realloc (par_name, (num_params+1)*sizeof(fixstr)); + + /* avoid parameters being equal to zero */ + for ( i=0 ; i 0); +} + +int getch() +{ + char c; + struct termio tmo, tmn; + + if (buff) { + c = buff; + buff = 0; + return (c & 127); + } + + ioctl(fileno(stdin),TCGETA,&tmo); + tmn = tmo; + tmn.c_iflag = tmn.c_lflag = 0; + tmn.c_cc[VMIN] = 1; /* minimum number of characters to be read */ + tmn.c_cc[VTIME] = 0; /* time-out in tenths of a second */ + ioctl(fileno(stdin),TCSETA,&tmn); + + while (read(fileno(stdin),&c,1) != 1) + ; /* do nothing, just wait */ + ioctl(fileno(stdin),TCSETA,&tmo); + return (c & 127); +} +#endif + +#if defined(ATARI) || defined(MTOS) +int kbhit() +{ + int r; + fd_set rfds; + struct timeval time_wait; + + if (buff) return 1; + + time_wait.tv_sec = 0L; + time_wait.tv_usec = 200L; + + rfds = 1L << fileno(stdin); + r = select(fileno(stdin),&rfds,NULL,NULL,&time_wait); + if (r > 0) read(fileno(stdin),&buff,1); + return (r > 0); +} + +int getch() +{ + char c; + + if (buff) { + c = buff; + buff = 0; + } + else + read(fileno(stdin),&c,1); + + return (c & 127); +} +#endif diff -uN original/gnuplot.35/fit.h patch/gnuplot.35/fit.h --- original/gnuplot.35/fit.h +++ patch/gnuplot.35/fit.h Thu Sep 15 18:12:56 1994 @@ -0,0 +1,59 @@ +/* $Id: fit.h 1.1 1993/08/01 04:21:29 cg Exp cg $ */ + +/* + * Header file: public functions in fit.c + * + * + * Copyright of this module: Carsten Grammes, 1993 + * Experimental Physics, University of Saarbruecken, Germany + * + * Internet address: cagr@rz.uni-sb.de + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * This software is provided "as is" without express or implied warranty. + */ + + +#ifndef FIT_H /* avoid multiple inclusions */ +#define FIT_H + +#ifdef EXT +#undef EXT +#endif + +#ifdef FIT_MAIN +#define EXT +#else +#define EXT extern +#endif + +#include "type.h" +#include "plot.h" + +#define FIT_SKIP "FIT_SKIP" + +EXT char *fit_index; + + +/******* public functions ******/ + +EXT void error_ex (char *s, ...); +EXT char *get_next_word (char **s, char *subst); + +#ifdef STRNICMP +EXT int strnicmp (char *s1, char *s2, int n); +#endif + +EXT void init_fit (); +EXT void setvar (char *varname, struct value data); +EXT int getivar (char *varname); +EXT void update (char *pfile); +EXT void do_fit (char *fitfunc, char *datafile, int xcol, int ycol, + int dycol, char *paramsfile); + +#endif diff -uN original/gnuplot.35/help.c patch/gnuplot.35/help.c --- original/gnuplot.35/help.c Thu Sep 16 04:59:46 1993 +++ patch/gnuplot.35/help.c Thu Sep 15 18:12:14 1994 @@ -52,7 +52,7 @@ */ #include -#if defined (ATARI) +#if defined(ATARI) || defined(MTOS) #include "plot.h" #else @@ -68,7 +68,7 @@ #endif #include -extern int errno; +/*extern int errno;*/ extern int instring(); diff -uN original/gnuplot.35/internal.c patch/gnuplot.35/internal.c --- original/gnuplot.35/internal.c Thu Sep 16 04:59:48 1993 +++ patch/gnuplot.35/internal.c Thu Sep 15 18:12:16 1994 @@ -67,7 +67,7 @@ #ifdef apollo int matherr(struct exception *x) /* apollo */ #else /* apollo */ -#if defined(AMIGA_SC_6_1)||defined(ATARI)&&defined(__GNUC__)||defined(__hpux__)||defined(PLOSS) ||defined(SOLARIS) +#if defined(AMIGA_SC_6_1)||defined(ATARI)&&defined(__GNUC__)||defined(MTOS)&&defined(__GNUC__)||defined(__hpux__)||defined(PLOSS) ||defined(SOLARIS) int matherr(x) struct exception *x; #else /* Most everyone else (not apollo). */ diff -uN original/gnuplot.35/makefile.mto patch/gnuplot.35/makefile.mto --- original/gnuplot.35/makefile.mto +++ patch/gnuplot.35/makefile.mto Sat Nov 5 15:41:56 1994 @@ -0,0 +1,188 @@ +# +# GNUPLOT makefile for GCC-ST 1.x and 2.x +# in a cross development environment (unix) or a native TOS environment +# (see configuration section) +# +# Modified from the BorlandC makefile by Alexander Lehmann +# Modified by Dirk Stadler for outboard terminal support +# +# produces executable which pipes data to the GCLIENT.PRG + +# -------------------- begin of configuration section ----------------------- + +# CC is name of compiler producing TOS executables +# HOSTCC is the name of the native compiler +# SL is the path separator (/ for unix or UNIXMODE, \ for standard TOS) + +# settings for crosscompiling: +CC = gcc +#HOSTCC = gcc +HOSTCC = cc +SL=/ + +# settings for native compiling: +#CC = gcc +#HOSTCC = $(CC) +#SL=\ + +# -O means optimisation in general +# o-f-p avoids link-unlink instructions +# s-r optimisation of loops and elimination of iterations variables +# c-r improve register movement +# if you have GCC 2.x (and time), you can choose the -O2 option + +# first line for GCC 1.x, second and third for GCC 2.x + +#OPTFLAGS = -O -fomit-frame-pointer -fstrength-reduce -fcombine-regs +#OPTFLAGS = -O -fomit-frame-pointer -fstrength-reduce +OPTFLAGS = -O2 -fomit-frame-pointer +TTFLAGS = -m68020 -m68881 + +# -c means don't link +# -DREADLINE to use the history/line editing capability. If you want this +# capability add -DREADLINE to CFLAGS + +# NOTE: since readline is the only place where AES events are processed, the +# new (window) version will no longer work without -DREADLINE + +CFLAGS = -c $(OPTFLAGS) -DMTOS -DREADLINE -DPIPES +LDFLAGS = -lpml + +CFLAGS30 = -c $(OPTFLAGS) $(TTFLAGS) -DMTOS -DREADLINE -DPIPES +LDFLAGS30 = $(TTFLAGS) -lgnu020 + +TERMFLAGS = + +# where to place gnuplot.gih helpfile +HELPFILE=gnuplot.gih + +# gnuplot.doc as Tex-File +TEXFILE=gnuplot.tex + +# -------------------- end of configuration section ------------------------- + +OBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o gnubin.o\ + help.o internal.o misc.o parse.o plot.o readline.o scanner.o\ + setshow.o specfun.o standard.o term.o util.o version.o binary.o\ + fit.o matrix.o + +OBJS30 = bitmap.o0 command.o0 contour.o0 eval.o0 graphics.o0 graph3d.o0 gnubin.o0\ + help.o0 internal.o0 misc.o0 parse.o0 plot.o0 readline.o0 scanner.o0\ + setshow.o0 specfun.o0 standard.o0 term.o0 util.o0 version.o0 binary.o0\ + fit.o0 matrix.o0 + +# path prefix for the term subdirectory +TERM = term$(SL) + +TERMS = $(TERM)mtos.trm $(TERM)dumb.trm $(TERM)eepic.trm $(TERM)epson.trm \ + $(TERM)hpgl.trm $(TERM)hpljii.trm $(TERM)hppj.trm $(TERM)latex.trm \ + $(TERM)pbm.trm $(TERM)post.trm $(TERM)texdraw.trm + +all: gnuplot.tos gnuplt30.tos $(HELPFILE) $(TEXFILE) demo$(SL)bf_test.tos + +gnuplot.tos: $(OBJS) + $(CC) -o $@ $(OBJS) $(LDFLAGS) + fixstk 120k $@ + xstrip $@ + +gnuplt30.tos: $(OBJS30) + $(CC) -o $@ $(OBJS30) $(LDFLAGS30) + fixstk 120k $@ + xstrip $@ + +# to run bivariat demo ca. 100k stack is needed, all others work with ca. 32k + +# default rules + +%.o: %.c + $(CC) -o $@ $(CFLAGS) $< + +%.o0: %.c + $(CC) -o $@ $(CFLAGS30) $< + +# dependencies + +# for GNUPLOT.TOS + +bitmap.o: bitmap.c bitmap.h plot.h +binary.o: binary.c plot.h +command.o: command.c plot.h setshow.h help.h + $(CC) -o $@ $(CFLAGS) -DHELPFILE=\"$(HELPFILE)\" $< +contour.o: contour.c plot.h +eval.o: eval.c plot.h +graphics.o: graphics.c plot.h setshow.h +graph3d.o: graph3d.c plot.h setshow.h +gnubin.o: gnubin.c plot.h setshow.h +fit.o: fit.c fit.h matrix.h plot.h +matrix.o: matrix.c matrix.h fit.h +help.o: help.c help.h +internal.o: internal.c plot.h +misc.o: misc.c plot.h setshow.h help.h +parse.o: parse.c plot.h +plot.o: plot.c plot.h setshow.h +readline.o: readline.c +scanner.o: scanner.c plot.h +setshow.o: setshow.c plot.h setshow.h +specfun.o: plot.h specfun.c +standard.o: standard.c plot.h +term.o: term.c term.h plot.h setshow.c bitmap.h $(TERMS) + $(CC) -o $@ $(CFLAGS) $(TERMFLAGS) -Iterm term.c +util.o: util.c plot.h +version.o: version.c + +# for GNUPLT30.TOS + +bitmap.o0: bitmap.c bitmap.h plot.h +binary.o0: binary.c plot.h +command.o0: command.c plot.h setshow.h help.h + $(CC) -o $@ $(CFLAGS30) -DHELPFILE=\"$(HELPFILE)\" $< +contour.o0: contour.c plot.h +eval.o0: eval.c plot.h +graphics.o0: graphics.c plot.h setshow.h +graph3d.o0: graph3d.c plot.h setshow.h +gnubin.o0: gnubin.c plot.h setshow.h +fit.o0: fit.c fit.h matrix.h plot.h +matrix.o0: matrix.c matrix.h fit.h +help.o0: help.c help.h +internal.o0: internal.c plot.h +misc.o0: misc.c plot.h setshow.h help.h +parse.o0: parse.c plot.h +plot.o0: plot.c plot.h setshow.h +readline.o0: readline.c +scanner.o0: scanner.c plot.h +setshow.o0: setshow.c plot.h setshow.h +specfun.o0: plot.h specfun.c +standard.o0: standard.c plot.h +term.o0: term.c term.h plot.h setshow.c bitmap.h $(TERMS) + $(CC) -o $@ $(CFLAGS30) $(TERMFLAGS) -Iterm term.c +util.o0: util.c plot.h +version.o0: version.c + + +$(HELPFILE): doc2gih.ttp docs$(SL)gnuplot.doc + doc2gih.ttp docs$(SL)gnuplot.doc $@ + +$(TEXFILE): doc2tex.ttp docs$(SL)gnuplot.doc + doc2tex.ttp docs$(SL)gnuplot.doc $@ + +doc2gih.ttp: docs$(SL)doc2gih.c + $(CC) -Idocs -o $@ $< + +doc2tex.ttp: docs$(SL)doc2tex.c + $(CC) -Idocs -o $@ $< + +demo$(SL)bf_test.tos: bf_test.o binary.o + $(CC) -o $@ bf_test.o binary.o -lpml + +clean: # remove temporary files, but leave executable intact + rm -f $(OBJS) $(OBJS30) bf_test.o doc2gih + +realclean: clean # remove all files generated by make + rm -f gnuplot.prg gnuplot.gih demo$(SL)binary1 demo$(SL)binary2 + rm -f demo$(SL)binary3 demo$(SL)bf_test.tos + +# empty rules for file extensions (some makes might need this) +%.trm: + +%.doc: + diff -uN original/gnuplot.35/makefile.os2 patch/gnuplot.35/makefile.os2 --- original/gnuplot.35/makefile.os2 Thu Sep 16 04:59:48 1993 +++ patch/gnuplot.35/makefile.os2 @@ -1,104 +0,0 @@ -# -# $Id: makefile.os2%v 3.50 1993/07/09 05:35:24 woo Exp $ -# -# Make file for use with emx 0.8e (gcc2.2.2) and nmake -# for compiling for OS/2 2.0 -# usage: nmake OR dmake -r -B -# (file has blanks instead of real tabs, doesn't use dmake.ini) -# - -# where to place gnuplot.gih helpfile -HELPFILE = gnuplot.gih - -CFLAGS = -c -O2 -DOS2 -DGETCWD -DREADLINE -DPIPES - -# see other terminal defines in term.h -TERMFLAGS = - - -OBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o \ - help.o internal.o misc.o parse.o plot.o readline.o specfun.o \ - scanner.o setshow.o standard.o term.o util.o version.o \ - binary.o gnubin.o - -CSOURCE5 = term\aed.trm term\cgi.trm term/dumb.trm term/dxf.trm term\dxy.trm \ - term\eepic.trm term\epson.trm term\fig.trm term\hp26.trm \ - term\hp2648.trm term\hpgl.trm term\hpljii.trm -CSOURCE6 = term\impcodes.h term\imagen.trm term\object.h \ - term\iris4d.trm term\kyo.trm term\latex.trm term/pbm.trm term\pm.trm -CSOURCE7 = term\post.trm term\qms.trm term\regis.trm term\sun.trm \ - term\t410x.trm term\tek.trm term\unixpc.trm term\unixplot.trm \ - term\v384.trm term\x11.trm -CSOURCE8 = contour.c - -# default rules -.c.o: - gcc $(CFLAGS) -o $*.o $*.c - -gnuplot.exe: $(OBJS) - gcc -o gnuplot.exe $(OBJS) -los2 - - -bitmap.o: bitmap.c bitmap.h plot.h - -binary.o: binary.c plot.h - -gnubin.o: gnubin.c plot.h - -command.o: command.c plot.h setshow.h help.h - -contour.o: contour.c plot.h - -eval.o: eval.c plot.h - -graphics.o: graphics.c plot.h setshow.h - -graph3d.o: graph3d.c plot.h setshow.h - -help.o: help.c plot.h help.h - -internal.o: internal.c plot.h - -misc.o: misc.c plot.h setshow.h - -parse.o: parse.c plot.h - -plot.o: plot.c plot.h setshow.h - -readline.o: readline.c - -scanner.o: scanner.c plot.h - -setshow.o: setshow.c plot.h setshow.h - -specfun.o: specfun.c plot.h - -standard.o: standard.c plot.h - -term.o: term.c term.h plot.h setshow.h bitmap.h $(CSOURCE5) $(CSOURCE6) $(CSOURCE7) - gcc $(CFLAGS) $(TERMFLAGS) -Iterm -o term.o term.c - -util.o: util.c plot.h - -version.o: version.c - -all: gnuplot.exe $(HELPFILE) - -# convert gnuplot.doc to gnuplot.gih -doc2gih.exe: docs\doc2gih.c - gcc -o doc2gih.exe docs/doc2gih.c - -$(HELPFILE): doc2gih.exe docs\gnuplot.doc - doc2gih docs\gnuplot.doc $(HELPFILE) - -clean: - del *.o - -# realclean target - remove all files created by the makefile - -realclean: clean - del gnuplot.exe - del doc2gih.exe - del gnuplot.gih - - diff -uN original/gnuplot.35/matrix.c patch/gnuplot.35/matrix.c --- original/gnuplot.35/matrix.c +++ patch/gnuplot.35/matrix.c Thu Sep 15 18:12:56 1994 @@ -0,0 +1,354 @@ +#ifndef lint +static char *RCSid = "$Id: matrix.c 1.1 1993/08/01 04:21:37 cg Exp cg $"; +#endif + +/* + * Matrix algebra, part of + * + * Nonlinear least squares fit according to the + * Marquardt-Levenberg-algorithm + * + * added as Patch to Gnuplot (v3.2 and higher) + * by Carsten Grammes + * Experimental Physics, University of Saarbruecken, Germany + * + * Internet address: cagr@rz.uni-sb.de + * + * Copyright of this module: Carsten Grammes, 1993 + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * This software is provided "as is" without express or implied warranty. + */ + + +#define MATRIX_MAIN + +#include +#include +#include + +#include "type.h" +#include "fit.h" +#include "matrix.h" + + +/*****************************************************************/ + +#define Swap(a,b) {double temp=(a); (a)=(b); (b)=temp;} +#define WINZIG 1e-30 + + +/***************************************************************** + internal prototypes +*****************************************************************/ +static void lu_decomp (double **a, int n, int *indx, double *d); +static void lu_backsubst (double **a, int n, int *indx, double b[]); + + +/***************************************************************** + first straightforward vector and matrix allocation functions +*****************************************************************/ +double *vec (int n) +{ + /* allocates a double vector with n elements */ + double *dp; + if( n < 1 ) + return (double *) NULL; + if ( (dp = (double *) malloc ( n * sizeof(double) )) == NULL ) + error_ex ("Memory running low during fit"); + else + return dp; +} + + +int *ivec (int n) +{ + /* allocates a int vector with n elements */ + int *ip; + if( n < 1 ) + return (int *) NULL; + if ( (ip = (int *) malloc ( n * sizeof(int) )) == NULL ) + error_ex ("Memory running low during fit"); + else + return ip; +} + +double **matr (int rows, int cols) +{ + /* allocates a double matrix */ + + register int i; + register double **m; + + if ( rows < 1 || cols < 1 ) + return NULL; + /* allocate pointers to rows */ + if ( (m = (double **) malloc ( rows * sizeof(double *) )) == NULL ) + error_ex ("Memory running low during fit"); + /* allocate rows and set pointers to them */ + for ( i=0 ; i 1 ) + error_ex ("Singular matrix"); + } + else { + if ( (tmp = fabs(*ac)) >= large ) { + large = tmp; + ir = j; + ic = k; + } + } + } + ++(pivot_ix[ic]); + + if ( ic != ir ) { + ac = b[ir]; + cp = b[ic]; + for ( l=0 ; l=0 ; l-- ) + if ( r_ix[l] != c_ix[l] ) + for ( ar=a, k=0 ; k large ) + large = temp; + if ( large == 0.0 ) + error_ex ("Singular matrix in LU-DECOMP"); + *dp++ = 1/large; + } + ar = a; + for ( j=0 ; j= large ) { + large = dummy; + imax = i; + } + } + if ( j != imax ) { + ac = a[imax]; + dp = *ar; + for ( k=0 ; k= 0) { + ac = &(*ar)[memi]; + bp = &b[memi]; + for ( j=memi ; j<=i-1 ; j++ ) + sum -= *ac++ * *bp++; + } + else + if ( sum ) + memi = i; + b[i] = sum; + } + ar--; + for ( i=n-1 ; i>=0 ; i-- ) { + ac = &(*ar)[i+1]; + bp = &b[i+1]; + bip = &b[i]; + for ( j=i+1 ; j #include -#ifndef __PUREC__ +#if !defined(__PUREC__) || (defined(__PUREC__) && defined(__MINT__)) #ifndef VMS #ifdef AMIGA_AC_5 #include @@ -52,7 +52,7 @@ #include "help.h" #endif -#if !defined(__TURBOC__) && !defined (_IBMR2) && !defined (ATARI) && !defined (AMIGA_SC_6_1) && !defined(OSF1) +#if !defined(__TURBOC__) && !defined (_IBMR2) && !defined (ATARI) && !defined (MTOS) && !defined (AMIGA_SC_6_1) && !defined(OSF1) extern char *malloc(); extern char *realloc(); #endif Only in patch/gnuplot.35: object Common subdirectories: original/gnuplot.35/os2 and patch/gnuplot.35/os2 diff -uN original/gnuplot.35/parse.c patch/gnuplot.35/parse.c --- original/gnuplot.35/parse.c Thu Sep 16 04:59:50 1993 +++ patch/gnuplot.35/parse.c Thu Sep 15 18:12:32 1994 @@ -103,8 +103,12 @@ #else #ifdef OS2 (void) signal(an_int, SIG_ACK); +#else +#if (defined(ATARI) && defined(__GNUC__)) || (defined(MTOS) && defined(__GNUC__)) + (void)signal(SIGFPE, (__Sigfunc)fpe); #else (void)signal(SIGFPE, fpe); +#endif #endif #endif #endif @@ -165,9 +169,13 @@ (void)signal(SIGFPE, (void *)fpe); #else #if DJGPP - (void)signal(SIGFPE, (SignalHandler)fpe); + (void)signal(SIGFPE, (SignalHandler)fpe); +#else +#if (defined(ATARI) && defined(__GNUC__)) || (defined(MTOS) && defined(__GNUC__)) + (void)signal(SIGFPE, (__Sigfunc)fpe); #else (void)signal(SIGFPE, fpe); /* catch core dumps on FPEs */ +#endif #endif #endif #endif diff -uN original/gnuplot.35/plot.c patch/gnuplot.35/plot.c --- original/gnuplot.35/plot.c Thu Sep 16 04:59:50 1993 +++ patch/gnuplot.35/plot.c Sat Nov 5 15:22:06 1994 @@ -1,493 +1,524 @@ -#ifndef lint -static char *RCSid = "$Id: plot.c%v 3.50.1.8 1993/07/27 05:37:15 woo Exp $"; -#endif - - -/* GNUPLOT - plot.c */ -/* - * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley - * - * Permission to use, copy, and distribute this software and its - * documentation for any purpose with or without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - * - * Permission to modify the software is granted, but not the right to - * distribute the modified code. Modifications are to be distributed - * as patches to released version. - * - * This software is provided "as is" without express or implied warranty. - * - * - * AUTHORS - * - * Original Software: - * Thomas Williams, Colin Kelley. - * - * Gnuplot 2.0 additions: - * Russell Lang, Dave Kotz, John Campbell. - * - * Gnuplot 3.0 additions: - * Gershon Elber and many others. - * - * There is a mailing list for gnuplot users. Note, however, that the - * newsgroup - * comp.graphics.gnuplot - * is identical to the mailing list (they - * both carry the same set of messages). We prefer that you read the - * messages through that newsgroup, to subscribing to the mailing list. - * (If you can read that newsgroup, and are already on the mailing list, - * please send a message info-gnuplot-request@dartmouth.edu, asking to be - * removed from the mailing list.) - * - * The address for mailing to list members is - * info-gnuplot@dartmouth.edu - * and for mailing administrative requests is - * info-gnuplot-request@dartmouth.edu - * The mailing list for bug reports is - * bug-gnuplot@dartmouth.edu - * The list of those interested in beta-test versions is - * info-gnuplot-beta@dartmouth.edu - */ - -#include -#include -#include -#ifdef XPG3_LOCALE -#include -#endif -#include "plot.h" -#include "setshow.h" -#if defined(MSDOS) || defined(DOS386) -#include -#endif -#ifdef vms -#include -#include -extern int vms_vkid; -extern smg$create_virtual_keyboard(); -unsigned int status[2] = {1, 0}; -#endif -#ifdef AMIGA_SC_6_1 -#include -#endif - -#ifdef _Windows -#include -#ifndef SIGINT -#define SIGINT 2 /* for MSC */ -#endif -#else -# ifdef __TURBOC__ -# include -# endif -#endif - -#ifndef AMIGA_SC_6_1 -extern char *getenv(),*strcat(),*strcpy(),*strncpy(); -#endif /* !AMIGA_SC_6_1 */ - -extern char input_line[]; -extern int c_token; -extern FILE *outfile; -extern int term; - -TBOOLEAN interactive = TRUE; /* FALSE if stdin not a terminal */ -TBOOLEAN noinputfiles = TRUE; /* FALSE if there are script files */ -char *infile_name = NULL; /* name of command file; NULL if terminal */ - -#ifndef STDOUT -#define STDOUT 1 -#endif - -#ifdef _Windows -jmp_buf far env; -#else -jmp_buf env; -#endif - -struct value *Ginteger(),*Gcomplex(); - - -extern f_push(),f_pushc(),f_pushd1(),f_pushd2(),f_pushd(),f_call(),f_calln(), - f_lnot(),f_bnot(),f_uminus(),f_lor(),f_land(),f_bor(),f_xor(), - f_band(),f_eq(),f_ne(),f_gt(),f_lt(), - f_ge(),f_le(),f_plus(),f_minus(),f_mult(),f_div(),f_mod(),f_power(), - f_factorial(),f_bool(),f_jump(),f_jumpz(),f_jumpnz(),f_jtern(); - -extern f_real(),f_imag(),f_arg(),f_conjg(),f_sin(),f_cos(),f_tan(),f_asin(), - f_acos(),f_atan(),f_sinh(),f_cosh(),f_tanh(),f_int(),f_abs(),f_sgn(), - f_sqrt(),f_exp(),f_log10(),f_log(),f_besj0(),f_besj1(),f_besy0(),f_besy1(), - f_erf(), f_erfc(), f_gamma(), f_lgamma(), f_ibeta(), f_igamma(), f_rand(), - f_floor(),f_ceil(), - f_normal(), f_inverse_erf(), f_inverse_normal(); /* XXX - JG */ - - -struct ft_entry GPFAR ft[] = { /* built-in function table */ - -/* internal functions: */ - {"push", f_push}, {"pushc", f_pushc}, - {"pushd1", f_pushd1}, {"pushd2", f_pushd2}, {"pushd", f_pushd}, - {"call", f_call}, {"calln", f_calln}, {"lnot", f_lnot}, - {"bnot", f_bnot}, {"uminus", f_uminus}, {"lor", f_lor}, - {"land", f_land}, {"bor", f_bor}, {"xor", f_xor}, - {"band", f_band}, {"eq", f_eq}, {"ne", f_ne}, - {"gt", f_gt}, {"lt", f_lt}, {"ge", f_ge}, - {"le", f_le}, {"plus", f_plus}, {"minus", f_minus}, - {"mult", f_mult}, {"div", f_div}, {"mod", f_mod}, - {"power", f_power}, {"factorial", f_factorial}, - {"bool", f_bool}, {"jump", f_jump}, {"jumpz", f_jumpz}, - {"jumpnz",f_jumpnz},{"jtern", f_jtern}, - -/* standard functions: */ - {"real", f_real}, {"imag", f_imag}, {"arg", f_arg}, - {"conjg", f_conjg}, {"sin", f_sin}, {"cos", f_cos}, - {"tan", f_tan}, {"asin", f_asin}, {"acos", f_acos}, - {"atan", f_atan}, {"sinh", f_sinh}, {"cosh", f_cosh}, - {"tanh", f_tanh}, {"int", f_int}, {"abs", f_abs}, - {"sgn", f_sgn}, {"sqrt", f_sqrt}, {"exp", f_exp}, - {"log10", f_log10}, {"log", f_log}, {"besj0", f_besj0}, - {"besj1", f_besj1}, {"besy0", f_besy0}, {"besy1", f_besy1}, - {"erf", f_erf}, {"erfc", f_erfc}, {"gamma", f_gamma}, {"lgamma", f_lgamma}, - {"ibeta", f_ibeta}, {"igamma", f_igamma}, {"rand", f_rand}, - {"floor", f_floor}, {"ceil", f_ceil}, - - {"norm", f_normal}, /* XXX-JG */ - {"inverf", f_inverse_erf}, /* XXX-JG */ - {"invnorm", f_inverse_normal}, /* XXX-JG */ - - {NULL, NULL} -}; - -static struct udvt_entry udv_pi = {NULL, "pi",FALSE}; - /* first in linked list */ -struct udvt_entry *first_udv = &udv_pi; -struct udft_entry *first_udf = NULL; - - - -#ifdef vms - -#define HOME "sys$login:" - -#else /* vms */ -#if defined(MSDOS) || defined(AMIGA_AC_5) || defined(AMIGA_SC_6_1) || defined(ATARI) || defined(OS2) || defined(_Windows) || defined(DOS386) - -#define HOME "GNUPLOT" - -#else /* MSDOS || AMIGA || ATARI || OS2 || _Windows || defined(DOS386)*/ - -#define HOME "HOME" - -#endif /* MSDOS || AMIGA || ATARI || OS2 || _Windows || defined(DOS386)*/ -#endif /* vms */ - -#if defined(unix) || defined(AMIGA_AC_5) || defined(AMIGA_SC_6_1) -#define PLOTRC ".gnuplot" -#else /* AMIGA || unix */ -#define PLOTRC "gnuplot.ini" -#endif /* AMIGA || unix */ - -#if defined (__TURBOC__) || defined (__PUREC__) -void tc_interrupt() -#else -#ifdef __ZTC__ -void ztc_interrupt() -#else -#if defined( _CRAY ) || defined( sgi ) || defined( __alpha ) -void inter(an_int) -int an_int; -#else -#if defined( NEXT ) || defined( OS2 ) || defined( VMS ) -void inter(int an_int) -#else -#ifdef sgi -void inter(int sig, int code, struct sigcontext *sc) -#else -#if defined(SOLARIS) -void inter() -#else -inter() -#endif -#endif -#endif -#endif -#endif -#endif -{ -#if defined (MSDOS) || defined(_Windows) || (defined (ATARI) && defined(__PUREC__)) || defined(DOS386) -#if defined (__TURBOC__) || defined (__PUREC__) -#ifndef DOSX286 - (void) signal(SIGINT, tc_interrupt); -#endif -#else -#ifdef __ZTC__ - (void) signal(SIGINT, ztc_interrupt); -#else -#ifdef __EMX__ - (void) signal(SIGINT, (void *)inter); -#else -#ifdef DJGPP - (void) signal(SIGINT, (SignalHandler)inter); -#else -#if defined __MSC__ - (void) signal(SIGINT, inter); -#endif /* __MSC__ */ - -#endif /* DJGPP */ -#endif /* __EMX__ */ -#endif /* ZTC */ -#endif /* __TURBOC__ */ - -#else /* MSDOS */ -#ifdef OS2 - (void) signal(an_int, SIG_ACK); -#else - (void) signal(SIGINT, inter); -#endif /* OS2 */ -#endif /* MSDOS */ -#ifndef DOSX286 - (void) signal(SIGFPE, SIG_DFL); /* turn off FPE trapping */ -#endif - if (term && term_init) - (*term_tbl[term].text)(); /* hopefully reset text mode */ - (void) fflush(outfile); - (void) putc('\n',stderr); - longjmp(env, TRUE); /* return to prompt */ -} - - -#ifdef _Windows -gnu_main(argc, argv) -#else -main(argc, argv) -#endif - int argc; - char **argv; -{ -#ifdef XPG3_LOCALE - (void) setlocale(LC_CTYPE, ""); -#endif -/* Register the Borland Graphics Interface drivers. If they have been */ -/* included by the linker. */ - -#ifndef DOSX286 -#ifndef _Windows -#if defined (__TURBOC__) && defined (MSDOS) -registerfarbgidriver(EGAVGA_driver_far); -registerfarbgidriver(CGA_driver_far); -registerfarbgidriver(Herc_driver_far); -registerfarbgidriver(ATT_driver_far); -# endif -#endif -#endif -#ifdef X11 - { int n = X11_args(argc, argv); argv += n; argc -= n; } -#endif - -#ifdef apollo - apollo_pfm_catch(); -#endif - - setbuf(stderr,(char *)NULL); -#ifdef UNIX - setlinebuf(stdout); -#endif - outfile = stdout; - (void) Gcomplex(&udv_pi.udv_value, Pi, 0.0); - - interactive = FALSE; - init_terminal(); /* can set term type if it likes */ - -#ifdef AMIGA_SC_6_1 - if (IsInteractive(Input()) == DOSTRUE) interactive = TRUE; - else interactive = FALSE; -#else -#if defined(__MSC__) && defined(_Windows) - interactive = TRUE; -#else - interactive = isatty(fileno(stdin)); -#endif -#endif - if (argc > 1) - interactive = noinputfiles = FALSE; - else - noinputfiles = TRUE; - - if (interactive) - show_version(); -#ifdef vms /* initialise screen management routines for command recall */ - if (status[1] = smg$create_virtual_keyboard(&vms_vkid) != SS$_NORMAL) - done(status[1]); -#endif - - if (!setjmp(env)) { - /* first time */ - interrupt_setup(); - load_rcfile(); - - if (interactive && term != 0) /* not unknown */ - fprintf(stderr, "\nTerminal type set to '%s'\n", - term_tbl[term].name); - } else { - /* come back here from int_error() */ - load_file_error(); /* if we were in load_file(), cleanup */ -#ifdef _Windows - SetCursor(LoadCursor((HINSTANCE)NULL, IDC_ARROW)); -#endif -#ifdef vms - /* after catching interrupt */ - /* VAX stuffs up stdout on SIGINT while writing to stdout, - so reopen stdout. */ - if (outfile == stdout) { - if ( (stdout = freopen("SYS$OUTPUT","w",stdout)) == NULL) { - /* couldn't reopen it so try opening it instead */ - if ( (stdout = fopen("SYS$OUTPUT","w")) == NULL) { - /* don't use int_error here - causes infinite loop! */ - fprintf(stderr,"Error opening SYS$OUTPUT as stdout\n"); - } - } - outfile = stdout; - } -#endif /* VMS */ - if (!interactive && !noinputfiles) { - if (term && term_init) - (*term_tbl[term].reset)(); -#ifdef vms - vms_reset(); -#endif - return(IO_ERROR); /* exit on non-interactive error */ - } - } - - if (argc > 1) { - /* load filenames given as arguments */ - while (--argc > 0) { - ++argv; - c_token = NO_CARET; /* in case of file not found */ - load_file(fopen(*argv,"r"), *argv); - } - } else { - /* take commands from stdin */ - while(!com_line()); - } - - if (term && term_init) - (*term_tbl[term].reset)(); -#ifdef vms - vms_reset(); -#endif - return(IO_SUCCESS); -} - -#if defined(ATARI) && defined(__PUREC__) -#include -int purec_matherr(struct exception *e) -{ char *c; - switch (e->type) { - case DOMAIN: c = "domain error"; break; - case SING : c = "argument singularity"; break; - case OVERFLOW: c = "overflow range"; break; - case UNDERFLOW: c = "underflow range"; break; - default: c = "(unknown error"; break; - } - fprintf(stderr, "math exception : %s\n", c); - fprintf(stderr, " name : %s\n", e->name); - fprintf(stderr, " arg 1: %e\n", e->arg1); - fprintf(stderr, " arg 2: %e\n", e->arg2); - fprintf(stderr, " ret : %e\n", e->retval); - return 1; -} -#endif - -/* Set up to catch interrupts */ -interrupt_setup() -{ -#if defined (MSDOS) || defined(_Windows) || (defined (ATARI) && defined(__PUREC__)) || defined(DOS386) -#ifdef __PUREC__ - setmatherr(purec_matherr); -#endif -#if defined (__TURBOC__) || defined (__PUREC__) -#if !defined(DOSX286) && !defined(BROKEN_SIGINT) - (void) signal(SIGINT, tc_interrupt); /* go there on interrupt char */ -#endif -#else -#ifdef __ZTC__ - (void) signal(SIGINT, ztc_interrupt); -#else -#ifdef __EMX__ - (void) signal(SIGINT, (void *)inter); /* go there on interrupt char */ -#else -#ifdef DJGPP - (void) signal(SIGINT, (SignalHandler)inter); /* go there on interrupt char */ -#else - (void) signal(SIGINT, inter); -#endif -#endif -#endif -#endif -#else /* MSDOS */ - (void) signal(SIGINT, inter); /* go there on interrupt char */ -#endif /* MSDOS */ -} - - -/* Look for a gnuplot start-up file */ -load_rcfile() -{ - register FILE *plotrc; - char home[80]; - char rcfile[sizeof(PLOTRC)+80]; - - /* Look for a gnuplot init file in . or home directory */ -#ifdef vms - (void) strcpy(home,HOME); -#else /* vms */ - char *tmp_home=getenv(HOME); - char *p; /* points to last char in home path, or to \0, if none */ - char c='\0';/* character that should be added, or \0, if none */ - - - if(tmp_home) { - strcpy(home,tmp_home); - if( strlen(home) ) p = &home[strlen(home)-1]; - else p = home; -#if defined(MSDOS) || defined(ATARI) || defined( OS2 ) || defined(_Windows) || defined(DOS386) - if( *p!='\\' && *p!='\0' ) c='\\'; -#else -#if defined(AMIGA_AC_5) - if( *p!='/' && *p!=':' && *p!='\0' ) c='/'; -#else /* that leaves unix */ - c='/'; -#endif -#endif - if(c) { - if(*p) p++; - *p++=c; - *p='\0'; - } - } -#endif /* vms */ - -#ifdef NOCWDRC - /* inhibit check of init file in current directory for security reasons */ - { -#else - (void) strcpy(rcfile, PLOTRC); - plotrc = fopen(rcfile,"r"); - if (plotrc == (FILE *)NULL) { -#endif -#ifndef vms - if( tmp_home ) { -#endif - (void) sprintf(rcfile, "%s%s", home, PLOTRC); - plotrc = fopen(rcfile,"r"); -#ifndef vms - } else - plotrc=NULL; -#endif - } - if (plotrc) - load_file(plotrc, rcfile); -} +#ifndef lint +static char *RCSid = "$Id: plot.c%v 3.50.1.8 1993/07/27 05:37:15 woo Exp $"; +#endif + + +/* GNUPLOT - plot.c */ +/* + * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * Permission to modify the software is granted, but not the right to + * distribute the modified code. Modifications are to be distributed + * as patches to released version. + * + * This software is provided "as is" without express or implied warranty. + * + * + * AUTHORS + * + * Original Software: + * Thomas Williams, Colin Kelley. + * + * Gnuplot 2.0 additions: + * Russell Lang, Dave Kotz, John Campbell. + * + * Gnuplot 3.0 additions: + * Gershon Elber and many others. + * + * There is a mailing list for gnuplot users. Note, however, that the + * newsgroup + * comp.graphics.gnuplot + * is identical to the mailing list (they + * both carry the same set of messages). We prefer that you read the + * messages through that newsgroup, to subscribing to the mailing list. + * (If you can read that newsgroup, and are already on the mailing list, + * please send a message info-gnuplot-request@dartmouth.edu, asking to be + * removed from the mailing list.) + * + * The address for mailing to list members is + * info-gnuplot@dartmouth.edu + * and for mailing administrative requests is + * info-gnuplot-request@dartmouth.edu + * The mailing list for bug reports is + * bug-gnuplot@dartmouth.edu + * The list of those interested in beta-test versions is + * info-gnuplot-beta@dartmouth.edu + */ + +#include +#include +#include +#ifdef XPG3_LOCALE +#include +#endif +#include "plot.h" +#include "fit.h" +#include "setshow.h" +#if defined(MSDOS) || defined(DOS386) +#include +#endif +#ifdef vms +#include +#include +extern int vms_vkid; +extern smg$create_virtual_keyboard(); +unsigned int status[2] = {1, 0}; +#endif +#ifdef AMIGA_SC_6_1 +#include +#endif + +#ifdef MTOS +#include +#endif + +#ifdef _Windows +#include +#ifndef SIGINT +#define SIGINT 2 /* for MSC */ +#endif +#else +# ifdef __TURBOC__ +# include +# endif +#endif + +#ifndef AMIGA_SC_6_1 +extern char *getenv(),*strcat(),*strcpy(),*strncpy(); +#endif /* !AMIGA_SC_6_1 */ + +extern char input_line[]; +extern int c_token; +extern FILE *outfile; +extern int term; + +TBOOLEAN interactive = TRUE; /* FALSE if stdin not a terminal */ +TBOOLEAN noinputfiles = TRUE; /* FALSE if there are script files */ +char *infile_name = NULL; /* name of command file; NULL if terminal */ + +#ifndef STDOUT +#define STDOUT 1 +#endif + +#ifdef _Windows +jmp_buf far env; +#else +jmp_buf env; +#endif + +struct value *Ginteger(),*Gcomplex(); + + +extern f_push(),f_pushc(),f_pushd1(),f_pushd2(),f_pushd(),f_call(),f_calln(), + f_lnot(),f_bnot(),f_uminus(),f_lor(),f_land(),f_bor(),f_xor(), + f_band(),f_eq(),f_ne(),f_gt(),f_lt(), + f_ge(),f_le(),f_plus(),f_minus(),f_mult(),f_div(),f_mod(),f_power(), + f_factorial(),f_bool(),f_jump(),f_jumpz(),f_jumpnz(),f_jtern(); + +extern f_real(),f_imag(),f_arg(),f_conjg(),f_sin(),f_cos(),f_tan(),f_asin(), + f_acos(),f_atan(),f_sinh(),f_cosh(),f_tanh(),f_int(),f_abs(),f_sgn(), + f_sqrt(),f_exp(),f_log10(),f_log(),f_besj0(),f_besj1(),f_besy0(),f_besy1(), + f_erf(), f_erfc(), f_gamma(), f_lgamma(), f_ibeta(), f_igamma(), f_rand(), + f_floor(),f_ceil(), + f_normal(), f_inverse_erf(), f_inverse_normal(); /* XXX - JG */ + + +struct ft_entry GPFAR ft[] = { /* built-in function table */ + +/* internal functions: */ + {"push", f_push}, {"pushc", f_pushc}, + {"pushd1", f_pushd1}, {"pushd2", f_pushd2}, {"pushd", f_pushd}, + {"call", f_call}, {"calln", f_calln}, {"lnot", f_lnot}, + {"bnot", f_bnot}, {"uminus", f_uminus}, {"lor", f_lor}, + {"land", f_land}, {"bor", f_bor}, {"xor", f_xor}, + {"band", f_band}, {"eq", f_eq}, {"ne", f_ne}, + {"gt", f_gt}, {"lt", f_lt}, {"ge", f_ge}, + {"le", f_le}, {"plus", f_plus}, {"minus", f_minus}, + {"mult", f_mult}, {"div", f_div}, {"mod", f_mod}, + {"power", f_power}, {"factorial", f_factorial}, + {"bool", f_bool}, {"jump", f_jump}, {"jumpz", f_jumpz}, + {"jumpnz",f_jumpnz},{"jtern", f_jtern}, + +/* standard functions: */ + {"real", f_real}, {"imag", f_imag}, {"arg", f_arg}, + {"conjg", f_conjg}, {"sin", f_sin}, {"cos", f_cos}, + {"tan", f_tan}, {"asin", f_asin}, {"acos", f_acos}, + {"atan", f_atan}, {"sinh", f_sinh}, {"cosh", f_cosh}, + {"tanh", f_tanh}, {"int", f_int}, {"abs", f_abs}, + {"sgn", f_sgn}, {"sqrt", f_sqrt}, {"exp", f_exp}, + {"log10", f_log10}, {"log", f_log}, {"besj0", f_besj0}, + {"besj1", f_besj1}, {"besy0", f_besy0}, {"besy1", f_besy1}, + {"erf", f_erf}, {"erfc", f_erfc}, {"gamma", f_gamma}, {"lgamma", f_lgamma}, + {"ibeta", f_ibeta}, {"igamma", f_igamma}, {"rand", f_rand}, + {"floor", f_floor}, {"ceil", f_ceil}, + + {"norm", f_normal}, /* XXX-JG */ + {"inverf", f_inverse_erf}, /* XXX-JG */ + {"invnorm", f_inverse_normal}, /* XXX-JG */ + + {NULL, NULL} +}; + +static struct udvt_entry udv_pi = {NULL, "pi",FALSE}; + /* first in linked list */ +struct udvt_entry *first_udv = &udv_pi; +struct udft_entry *first_udf = NULL; + + + +#ifdef vms + +#define HOME "sys$login:" + +#else /* vms */ +#if defined(MSDOS) || defined(AMIGA_AC_5) || defined(AMIGA_SC_6_1) || defined(ATARI) || defined(MTOS) || defined(OS2) || defined(_Windows) || defined(DOS386) + +#define HOME "GNUPLOT" + +#else /* MSDOS || AMIGA || ATARI || MTOS || OS2 || _Windows || defined(DOS386)*/ + +#define HOME "HOME" + +#endif /* MSDOS || AMIGA || ATARI || MTOS || OS2 || _Windows || defined(DOS386)*/ +#endif /* vms */ + +#if defined(unix) || defined(AMIGA_AC_5) || defined(AMIGA_SC_6_1) +#define PLOTRC ".gnuplot" +#else /* AMIGA || unix */ +#define PLOTRC "gnuplot.ini" +#endif /* AMIGA || unix */ + +#if defined (__TURBOC__) || defined (__PUREC__) +void tc_interrupt() +#else +#ifdef __ZTC__ +void ztc_interrupt() +#else +#if defined( _CRAY ) || defined( sgi ) || defined( __alpha ) +void inter(an_int) +int an_int; +#else +#if defined( NEXT ) || defined( OS2 ) || defined( VMS ) +void inter(int an_int) +#else +#ifdef sgi +void inter(int sig, int code, struct sigcontext *sc) +#else +#if defined(SOLARIS) +void inter() +#else +inter() +#endif +#endif +#endif +#endif +#endif +#endif +{ +#if defined (MSDOS) || defined(_Windows) || (defined (ATARI) && defined(__PUREC__)) || (defined (MTOS) && defined(__PUREC__)) || defined(DOS386) +#if defined (__TURBOC__) || defined (__PUREC__) +#ifndef DOSX286 + (void) signal(SIGINT, tc_interrupt); +#endif +#else +#ifdef __ZTC__ + (void) signal(SIGINT, ztc_interrupt); +#else +#ifdef __EMX__ + (void) signal(SIGINT, (void *)inter); +#else +#ifdef DJGPP + (void) signal(SIGINT, (SignalHandler)inter); +#else +#if defined __MSC__ + (void) signal(SIGINT, inter); +#endif /* __MSC__ */ + +#endif /* DJGPP */ +#endif /* __EMX__ */ +#endif /* ZTC */ +#endif /* __TURBOC__ */ + +#else /* MSDOS */ +#ifdef OS2 + (void) signal(an_int, SIG_ACK); +#else +#if defined(ATARI) || defined(MTOS) + (void) signal(SIGINT, (__Sigfunc)inter); +#else + (void) signal(SIGINT, inter); +#endif /* ATARI */ +#endif /* OS2 */ +#endif /* MSDOS */ +#ifndef DOSX286 + (void) signal(SIGFPE, SIG_DFL); /* turn off FPE trapping */ +#endif + if (term && term_init) + (*term_tbl[term].text)(); /* hopefully reset text mode */ + (void) fflush(outfile); + (void) putc('\n',stderr); + longjmp(env, TRUE); /* return to prompt */ +} + + +#ifdef _Windows +gnu_main(argc, argv) +#else +main(argc, argv) +#endif + int argc; + char **argv; +{ +#ifdef XPG3_LOCALE + (void) setlocale(LC_CTYPE, ""); +#endif +/* Register the Borland Graphics Interface drivers. If they have been */ +/* included by the linker. */ + +#ifndef DOSX286 +#ifndef _Windows +#if defined (__TURBOC__) && defined (MSDOS) +registerfarbgidriver(EGAVGA_driver_far); +registerfarbgidriver(CGA_driver_far); +registerfarbgidriver(Herc_driver_far); +registerfarbgidriver(ATT_driver_far); +# endif +#endif +#endif +#ifdef X11 + { int n = X11_args(argc, argv); argv += n; argc -= n; } +#endif + +#ifdef apollo + apollo_pfm_catch(); +#endif + +#ifdef MTOS + Pdomain(1); +#endif + + setbuf(stderr,(char *)NULL); +#ifdef UNIX + setlinebuf(stdout); +#endif + outfile = stdout; + (void) Gcomplex(&udv_pi.udv_value, Pi, 0.0); + + interactive = FALSE; + init_terminal(); /* can set term type if it likes */ + +#ifdef AMIGA_SC_6_1 + if (IsInteractive(Input()) == DOSTRUE) interactive = TRUE; + else interactive = FALSE; +#else +#if defined(__MSC__) && defined(_Windows) + interactive = TRUE; +#else + interactive = isatty(fileno(stdin)); +#endif +#endif + if (argc > 1) + interactive = noinputfiles = FALSE; + else + noinputfiles = TRUE; + + if (interactive) + show_version(); +#ifdef vms /* initialise screen management routines for command recall */ + if (status[1] = smg$create_virtual_keyboard(&vms_vkid) != SS$_NORMAL) + done(status[1]); +#endif + + if (!setjmp(env)) { + /* first time */ + interrupt_setup(); + load_rcfile(); + init_fit (); /* Initialization of fitting module */ + + if (interactive && term != 0) /* not unknown */ + fprintf(stderr, "\nTerminal type set to '%s'\n", + term_tbl[term].name); + } else { + /* come back here from int_error() */ +#ifdef AMIGA_SC_6_1 + (void) rawcon(0); +#endif + load_file_error(); /* if we were in load_file(), cleanup */ +#ifdef _Windows + SetCursor(LoadCursor((HINSTANCE)NULL, IDC_ARROW)); +#endif +#ifdef vms + /* after catching interrupt */ + /* VAX stuffs up stdout on SIGINT while writing to stdout, + so reopen stdout. */ + if (outfile == stdout) { + if ( (stdout = freopen("SYS$OUTPUT","w",stdout)) == NULL) { + /* couldn't reopen it so try opening it instead */ + if ( (stdout = fopen("SYS$OUTPUT","w")) == NULL) { + /* don't use int_error here - causes infinite loop! */ + fprintf(stderr,"Error opening SYS$OUTPUT as stdout\n"); + } + } + outfile = stdout; + } +#endif /* VMS */ + if (!interactive && !noinputfiles) { + if (term && term_init) + (*term_tbl[term].reset)(); +#ifdef vms + vms_reset(); +#endif + +#ifdef MTOS + MTOS_quit(); +#endif + + return(IO_ERROR); /* exit on non-interactive error */ + } + } + + if (argc > 1) { + /* load filenames given as arguments */ + while (--argc > 0) { + ++argv; + c_token = NO_CARET; /* in case of file not found */ + load_file(fopen(*argv,"r"), *argv); + } + } else { + /* take commands from stdin */ + while(!com_line()); + } + + if (term && term_init) + (*term_tbl[term].reset)(); +#ifdef vms + vms_reset(); +#endif + +#ifdef MTOS + MTOS_quit(); +#endif + + return(IO_SUCCESS); +} + +#if defined(ATARI) && defined(__PUREC__) || (defined(MTOS) && defined(__PUREC__)) +#include +int purec_matherr(struct exception *e) +{ char *c; + switch (e->type) { + case DOMAIN: c = "domain error"; break; + case SING : c = "argument singularity"; break; + case OVERFLOW: c = "overflow range"; break; + case UNDERFLOW: c = "underflow range"; break; + default: c = "(unknown error"; break; + } + fprintf(stderr, "math exception : %s\n", c); + fprintf(stderr, " name : %s\n", e->name); + fprintf(stderr, " arg 1: %e\n", e->arg1); + fprintf(stderr, " arg 2: %e\n", e->arg2); + fprintf(stderr, " ret : %e\n", e->retval); + return 1; +} +#endif + +/* Set up to catch interrupts */ +interrupt_setup() +{ +#if defined (MSDOS) || defined(_Windows) || (defined (ATARI) && defined(__PUREC__)) || (defined(MTOS) && defined(__PUREC__)) || defined(DOS386) +#ifdef __PUREC__ + setmatherr(purec_matherr); +#endif +#if defined (__TURBOC__) || defined (__PUREC__) +#if !defined(DOSX286) && !defined(BROKEN_SIGINT) + (void) signal(SIGINT, tc_interrupt); /* go there on interrupt char */ +#endif +#else +#ifdef __ZTC__ + (void) signal(SIGINT, ztc_interrupt); +#else +#ifdef __EMX__ + (void) signal(SIGINT, (void *)inter); /* go there on interrupt char */ +#else +#ifdef DJGPP + (void) signal(SIGINT, (SignalHandler)inter); /* go there on interrupt char */ +#else + (void) signal(SIGINT, inter); +#endif +#endif +#endif +#endif +#else /* MSDOS */ +#if defined(ATARI) || defined(MTOS) + (void) signal(SIGINT,(__Sigfunc)inter); +#else + (void) signal(SIGINT, inter); /* go there on interrupt char */ +#endif /* ATARI */ +#endif /* MSDOS */ +} + + +/* Look for a gnuplot start-up file */ +load_rcfile() +{ + register FILE *plotrc; + char home[80]; + char rcfile[sizeof(PLOTRC)+80]; + + /* Look for a gnuplot init file in . or home directory */ +#ifdef vms + (void) strcpy(home,HOME); +#else /* vms */ + char *tmp_home=getenv(HOME); + char *p; /* points to last char in home path, or to \0, if none */ + char c='\0';/* character that should be added, or \0, if none */ + + + if(tmp_home) { + strcpy(home,tmp_home); + if( strlen(home) ) p = &home[strlen(home)-1]; + else p = home; +#if defined(MSDOS) || defined(ATARI) || defined(MTOS) || defined( OS2 ) || defined(_Windows) || defined(DOS386) + if( *p!='\\' && *p!='\0' ) c='\\'; +#else +#if defined(AMIGA_AC_5) + if( *p!='/' && *p!=':' && *p!='\0' ) c='/'; +#else /* that leaves unix */ + c='/'; +#endif +#endif + if(c) { + if(*p) p++; + *p++=c; + *p='\0'; + } + } +#endif /* vms */ + +#ifdef NOCWDRC + /* inhibit check of init file in current directory for security reasons */ + { +#else + (void) strcpy(rcfile, PLOTRC); + plotrc = fopen(rcfile,"r"); + if (plotrc == (FILE *)NULL) { +#endif +#ifndef vms + if( tmp_home ) { +#endif + (void) sprintf(rcfile, "%s%s", home, PLOTRC); + plotrc = fopen(rcfile,"r"); +#ifndef vms + } else + plotrc=NULL; +#endif + } + if (plotrc) + load_file(plotrc, rcfile); +} diff -uN original/gnuplot.35/plot.h patch/gnuplot.35/plot.h --- original/gnuplot.35/plot.h Thu Sep 16 04:59:52 1993 +++ patch/gnuplot.35/plot.h Thu Sep 15 18:12:32 1994 @@ -51,6 +51,10 @@ * info-gnuplot-beta@dartmouth.edu */ +#ifndef PLOT_H /* avoid multiple includes */ +#define PLOT_H + + #define PROGRAM "G N U P L O T" #define PROMPT "gnuplot> " #if defined(AMIGA_SC_6_1) || defined(AMIGA_AC_5) @@ -58,12 +62,16 @@ #else /* AMIGA */ #ifdef ATARI #define SHELL "gulam.prg" -#else /* ATARI */ +#else /* ATARI */ +#ifdef MTOS +#define SHELL "mintshel.ttp" +#else /* MTOS */ #ifdef OS2 #define SHELL "c:\\cmd.exe" #else /*OS2 */ #define SHELL "/bin/sh" /* used if SHELL env variable not set */ -#endif /*OS2 */ +#endif /*OS2 */ +#endif /* MTOS */ #endif /* ATARI */ #endif /* AMIGA */ @@ -174,6 +182,10 @@ #ifdef ATARI #define OS "TOS " #endif + +#ifdef MTOS +#define OS "MULTITOS " +#endif #ifndef OS #define OS "" @@ -205,7 +217,7 @@ #define VERYLARGE 1e37 */ -#ifdef ATARI +#if defined(ATARI) || defined(MTOS) #include /* Prototyping used !! 'size_t' */ #include #include @@ -216,6 +228,9 @@ #include #define VERYLARGE (FLT_MAX/2 -1) #else /* not MSDOS || _Windows */ +#if defined(LINUX) +#define VERYLARGE 1e38 +#else #if defined( vms ) || defined( _CRAY ) || defined( NEXT ) || defined(__osf__) || defined( OS2 ) || defined(__EMX__) || defined( DOS386) || defined(KSR) #include #if defined ( NEXT ) /* bug in NeXT OS 2.0 */ @@ -256,6 +271,7 @@ /* default */ #endif /* !AMIGA_SC_6_1 */ #endif /* !AMIGA_AC_5 */ +#endif /* !LINUX */ #endif /* !VMS !CRAY !NEXT */ #endif /* !MSDOS || !_Windows */ #endif /* !ATARI */ @@ -303,7 +319,7 @@ #ifdef vms # define memcpy(dest,src,len) lib$movc3(&len,src,dest) #else -# if defined(MEMCPY) || defined(MSDOS) || defined (ATARI) || defined( OS2 ) || defined(_Windows) || defined(DOS386) +# if defined(MEMCPY) || defined(MSDOS) || defined (ATARI) || defined(MTOS) || defined( OS2 ) || defined(_Windows) || defined(DOS386) /* use memcpy directly */ # else # ifdef NOCOPY @@ -361,7 +377,7 @@ LEFT, CENTRE, RIGHT }; -#if !(defined(ATARI)&&defined(__GNUC__)&&defined(_MATH_H)) /* FF's math.h has the type already */ +#if !(defined(ATARI)&&defined(__GNUC__)&&defined(_MATH_H)) && !(defined(MTOS)&&defined(__GNUC__)&&defined(_MATH_H)) /* FF's math.h has the type already */ struct cmplx { double real, imag; }; @@ -437,11 +453,7 @@ UNDEFINED /* not defined at all */ }; -#if defined(MSDOS) || defined(_Windows) -typedef float coordval; /* memory is tight on PCs! */ -#else typedef double coordval; -#endif struct coordinate { enum coord_type type; /* see above */ @@ -605,3 +617,5 @@ #ifdef _Windows #include "win/wtext.h" #endif + +#endif /* PLOT_H */ diff -uN original/gnuplot.35/readline.c patch/gnuplot.35/readline.c --- original/gnuplot.35/readline.c Thu Sep 16 04:59:52 1993 +++ patch/gnuplot.35/readline.c Thu Sep 15 18:12:34 1994 @@ -49,7 +49,7 @@ */ #ifdef READLINE -#ifdef ATARI +#if defined(ATARI) || defined(MTOS) #include "plot.h" #endif #ifdef _WINDOWS @@ -85,7 +85,7 @@ #include #include -#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386) +#if !defined(MSDOS) && !defined(ATARI) && !defined(MTOS) && !defined(_Windows) && !defined(DOS386) /* * Set up structures using the proper include file @@ -151,7 +151,7 @@ #define special_getc() ansi_getc() static char ansi_getc(); -#else /* !MSDOS && !ATARI && !_Windows */ +#else /* !MSDOS && !ATARI && !MTOS && !_Windows */ #ifdef _Windows #include @@ -176,9 +176,9 @@ static char msdos_getch(); #endif /* MSDOS */ -#ifdef ATARI +#if defined(ATARI) || defined(MTOS) #include -#ifdef __PUREC__ +#if defined (__PUREC__) && !defined(__MINT__) #include #else #include @@ -187,9 +187,9 @@ static char tos_getch(); #endif -#endif /* !MSDOS && !ATARI && !_Windows */ +#endif /* !MSDOS && !ATARI && !MTOS && !_Windows */ -#if !defined(ATARI) +#if !defined(ATARI) && !defined(MTOS) /* is it or ? just declare what we need */ extern int strlen(); extern char *strcpy(); @@ -322,7 +322,7 @@ } #endif /*OS2*/ if((isprint(cur_char) -#if defined(ATARI) || defined(_Windows) || defined(MSDOS) || defined(DOS386) +#if defined(ATARI) || defined(MTOS) || defined(_Windows) || defined(MSDOS) || defined(DOS386) /* this should be used for all 8bit ASCII machines, I guess */ || ((unsigned char)cur_char > 0x7f) #endif @@ -709,7 +709,7 @@ #endif /* MSDOS */ -#ifdef ATARI +#if defined(ATARI) || defined(MTOS) /* Convert Arrow keystrokes to Control characters: TOS version */ @@ -762,8 +762,9 @@ init = 0; } } - - (void)Cursconf(1, 0); /* cursor on */ +#ifdef ATARI + (void)Cursconf(1, 0); /* cursor on */ +#endif rawkey = Cnecin(); c = (char)rawkey; scan_code= ((int)(rawkey>>16)) & 0xff; /* get the scancode */ @@ -812,13 +813,13 @@ return c; } -#endif /* ATARI */ +#endif /* ATARI || MTOS */ /* set termio so we can do our own input processing */ static void set_termio() { -#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386) +#if !defined(MSDOS) && !defined(ATARI) && !defined(MTOS) && !defined(_Windows) && !defined(DOS386) /* set termio so we can do our own input processing */ /* and save the old terminal modes so we can reset them later */ if(term_set == 0) { @@ -922,13 +923,13 @@ #endif /* SGTTY */ term_set = 1; } -#endif /* !MSDOS && !ATARI && !defined(_Windows) */ +#endif /* !MSDOS && !ATARI && !MTOS !defined(_Windows) */ } static void reset_termio() { -#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386) +#if !defined(MSDOS) && !defined(ATARI) && !defined(MTOS) && !defined(_Windows) && !defined(DOS386) /* reset saved terminal modes */ if(term_set == 1) { #ifdef SGTTY @@ -951,6 +952,6 @@ #endif /* SGTTY */ term_set = 0; } -#endif /* !MSDOS && !ATARI && !_Windows */ +#endif /* !MSDOS && !ATARI && !MTOS && !_Windows */ } #endif /* READLINE */ diff -uN original/gnuplot.35/scanner.c patch/gnuplot.35/scanner.c --- original/gnuplot.35/scanner.c Thu Sep 16 04:59:52 1993 +++ patch/gnuplot.35/scanner.c Thu Sep 15 18:12:34 1994 @@ -151,7 +151,7 @@ } else if (expression[current] == LBRACE) { token[t_num].is_token = FALSE; token[t_num].l_val.type = CMPLX; -#ifdef __PUREC__ +#if defined(__PUREC__) && !defined(__MINT__) { char l[80]; if ((sscanf(&expression[++current],"%lf,%lf%[ }]s", &token[t_num].l_val.v.cmplx_val.real, @@ -275,7 +275,7 @@ return(count); } -#if defined(unix) || defined(vms) || defined(PIPES) || (defined(ATARI) && defined(__PUREC__)) +#if defined(unix) || defined(vms) || defined(PIPES) || (defined(ATARI) && defined(__PUREC__)) || (defined(MTOS) && defined(__PUREC__)) substitute(str,max) /* substitute output from ` ` */ char *str; @@ -287,7 +287,7 @@ #ifdef AMIGA_AC_5 int fd; #else -#if defined(ATARI) && defined(__PUREC__) +#if (defined(ATARI) && defined(__PUREC__) && !defined(__MINT__)) || (defined(MTOS) && defined(__PUREC__) && !defined(__MINT__)) char *atari_tmpfile; char *atari_pgm[MAX_LINE_LEN+100]; #else @@ -323,7 +323,7 @@ if ((f = fopen(MAILBOX,"r")) == NULL) os_error("mailbox open failed",NO_CARET); #else /* vms */ -#if defined(ATARI) && defined(__PUREC__) +#if (defined(ATARI) && defined(__PUREC__) && !defined(__MINT__)) || (defined(MTOS) && defined(__PUREC__) && !defined(__MINT__)) if (system(NULL) == 0) os_error("no command shell"); if ((strlen(atari_tmpfile) + strlen(pgm) + 5) > MAX_LINE_LEN+100) @@ -351,7 +351,7 @@ #ifdef AMIGA_AC_5 (void) close(fd); #else -#if defined(ATARI) && defined(__PUREC__) +#if (defined(ATARI) && defined(__PUREC__) && !defined(__MINT__)) || (defined(MTOS) && defined(__PUREC__) && !defined(__MINT__)) (void) fclose(f); (void) unlink(atari_tmpfile); #else @@ -364,7 +364,7 @@ #ifdef AMIGA_AC_5 (void) close(fd); #else -#if defined(ATARI) && defined(__PUREC__) +#if (defined(ATARI) && defined(__PUREC__) && !defined(__MINT__)) || (defined(MTOS) && defined(__PUREC__) && !defined(__MINT__)) (void) fclose(f); (void) unlink(atari_tmpfile); #else diff -uN original/gnuplot.35/setshow.c patch/gnuplot.35/setshow.c --- original/gnuplot.35/setshow.c Thu Sep 16 04:59:52 1993 +++ patch/gnuplot.35/setshow.c Thu Sep 15 18:12:34 1994 @@ -194,7 +194,7 @@ #ifdef _Windows #include #else -#if !defined(ATARI) && !defined (AMIGA_SC_6_1) +#if !defined(ATARI) && !defined(MTOS) && !defined (AMIGA_SC_6_1) extern char *strcpy(),*strcat(); extern int strlen(); #endif @@ -3015,8 +3015,11 @@ fprintf(stderr,"\n\t%s\n\t%sversion %s\n", PROGRAM, OS, version); fprintf(stderr,"\tpatchlevel %s\n",patchlevel); - fprintf(stderr, "\tlast modified %s\n", date); + fprintf(stderr, "\tlast modified %s\n", date); + fprintf(stderr, "\n\t*** GNUFIT 1.2 22 Nov 93 ***\n"); + fprintf(stderr, "\t*** Nonlinear least squares fit added by C. Grammes ***\n"); + fprintf(stderr, "\t*** Send bugs regarding fit to cagr@rz.uni-sb.de ***\n"); fprintf(stderr,"\n\t%s %s, %s\n", copyright,authors[x],authors[1-x]); - fprintf(stderr, "\n\tSend comments and requests for help to %s", help_email); + fprintf(stderr, "\n\tSend bugs and comments to %s\n", bug_email); fprintf(stderr, "\n\tSend bugs, suggestions and mods to %s\n", bug_email); } diff -uN original/gnuplot.35/standard.c patch/gnuplot.35/standard.c --- original/gnuplot.35/standard.c Thu Sep 16 04:59:54 1993 +++ patch/gnuplot.35/standard.c Thu Sep 15 18:12:36 1994 @@ -66,7 +66,7 @@ * These bessel functions are accurate to about 1e-13 */ -#if defined (ATARI) && defined(__PUREC__) +#if (defined (ATARI) && defined(__PUREC__)) || (defined(MTOS) && defined(__PUREC__)) /* Sorry. But PUREC bugs here. * These bessel functions are NOT accurate to about 1e-13 */ Common subdirectories: original/gnuplot.35/term and patch/gnuplot.35/term diff -uN original/gnuplot.35/term.c patch/gnuplot.35/term.c --- original/gnuplot.35/term.c Thu Sep 16 04:59:54 1993 +++ patch/gnuplot.35/term.c Thu Sep 15 18:12:54 1994 @@ -68,6 +68,8 @@ #else #include #endif +#else +#include /* use ANSI comp. (m)alloc and free */ #endif #if defined(__TURBOC__) && defined(MSDOS) @@ -109,7 +111,7 @@ #if defined(_Windows) || ( defined(__TURBOC__) && defined(MSDOS) ) # include #else -#ifdef ATARI +#if defined(ATARI) || defined(MTOS) #include #include #else @@ -125,7 +127,7 @@ #endif #endif -#ifndef AMIGA_AC_5 +#if !defined(AMIGA_AC_5) && !defined(MTOS) && !defined(ATARI) extern double sqrt(); #endif @@ -141,7 +143,7 @@ #endif -#if defined(MSDOS)||defined(ATARI)||defined(OS2)||defined(_Windows)||defined(DOS386) +#if defined(MSDOS)||defined(ATARI)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386) void reopen_binary(); #define REOPEN_BINARY #endif @@ -339,6 +341,10 @@ #include "term/atari.trm" #endif +#ifdef MTOS /* ATARI-Multitos */ +#include "term/mtos.trm" +#endif + /* all TEK types (TEK,BITGRAPH,KERMIT,VTTEK,SELANAR) are ifdef'd in tek.trm, but most require various TEK routines. Hence TEK must be defined for @@ -605,6 +611,10 @@ #include "term/amiga.trm" #endif /* AMIGASCREEN */ +#ifdef LINUX +#include "term/linux.trm" +#endif /* LINUX */ + /* Dummy functions for unavailable features */ /* change angle of text. 0 is horizontal left to right. @@ -684,6 +694,15 @@ null_justify_text, ATARI_point, do_arrow} #endif +#ifdef MTOS + ,{"mtos", "Multitos Atari ST/TT", + MTOS_XMAX, MTOS_YMAX, MTOS_VCHAR, MTOS_HCHAR, + MTOS_VTIC, MTOS_HTIC, MTOS_options, MTOS_init, MTOS_reset, + MTOS_text, null_scale, MTOS_graphics, MTOS_move, MTOS_vector, + MTOS_linetype, MTOS_put_text, MTOS_text_angle, + MTOS_justify_text, MTOS_point, do_arrow} +#endif + #ifdef DUMB ,{"dumb", "printer or glass dumb terminal", DUMB_XMAX, DUMB_YMAX, 1, 1, @@ -1529,6 +1548,15 @@ Xlib_linetype, Xlib_put_text, null_text_angle, Xlib_justify_text, line_and_point, do_arrow} #endif + +#ifdef LINUX + ,{"linux", "PC with VGA adaptor running Linux", + LINUX_XMAX, LINUX_YMAX, LINUX_VCHAR, LINUX_HCHAR, + LINUX_VTIC, LINUX_HTIC, options_null, LINUX_init, LINUX_reset, + LINUX_text, null_scale, LINUX_graphics, LINUX_move, LINUX_vector, + LINUX_linetype, LINUX_put_text, LINUX_text_angle, + null_justify_text, do_point, do_arrow} +#endif }; #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry)) @@ -1708,6 +1736,10 @@ term_name = "atari"; #endif +#ifdef MTOS + term_name = "mtos"; +#endif + #ifdef UNIXPC if (iswind() == 0) { term_name = "unixpc"; @@ -1740,6 +1772,11 @@ /* EMX compiler has getcwd that can return drive */ if( PM_path[0]=='\0' ) _getcwd2( PM_path, 256 ) ; #endif /*OS2 */ + +/* we prefer X11 as default compatible to gnuplot */ +#if defined (LINUX) && !defined (X11) + term_name = "linux"; +#endif /* LINUX */ } /* We have a name, try to set term type */ @@ -2016,7 +2053,7 @@ } -#if defined(MSDOS)||defined(ATARI)||defined(OS2)||defined(_Windows)||defined(DOS386) +#if defined(MSDOS)||defined(ATARI)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386) /* output for some terminal types must be binary to stop non Unix computers changing \n to \r\n. If the output is not STDOUT, the following code reopens outfile diff -uN original/gnuplot.35/term.h patch/gnuplot.35/term.h --- original/gnuplot.35/term.h Thu Sep 16 04:59:54 1993 +++ patch/gnuplot.35/term.h Thu Sep 15 18:12:54 1994 @@ -1,164 +1,164 @@ - -/* - * $Id: term.h%v 3.50 1993/07/09 05:35:24 woo Exp $ - * - */ - -/* GNUPLOT - term.h */ -/* - * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley - * - * Permission to use, copy, and distribute this software and its - * documentation for any purpose with or without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - * - * Permission to modify the software is granted, but not the right to - * distribute the modified code. Modifications are to be distributed - * as patches to released version. - * - * This software is provided "as is" without express or implied warranty. - * - * - * AUTHORS - * - * Original Software: - * Thomas Williams, Colin Kelley. - * - * Gnuplot 2.0 additions: - * Russell Lang, Dave Kotz, John Campbell. - * - * Gnuplot 3.0 additions: - * Gershon Elber and many others. - * - * There is a mailing list for gnuplot users. Note, however, that the - * newsgroup - * comp.graphics.gnuplot - * is identical to the mailing list (they - * both carry the same set of messages). We prefer that you read the - * messages through that newsgroup, to subscribing to the mailing list. - * (If you can read that newsgroup, and are already on the mailing list, - * please send a message info-gnuplot-request@dartmouth.edu, asking to be - * removed from the mailing list.) - * - * The address for mailing to list members is - * info-gnuplot@dartmouth.edu - * and for mailing administrative requests is - * info-gnuplot-request@dartmouth.edu - * The mailing list for bug reports is - * bug-gnuplot@dartmouth.edu - * The list of those interested in beta-test versions is - * info-gnuplot-beta@dartmouth.edu - */ - -/* - * term.h: terminal support definitions - * Edit this file depending on the set of terminals you wish to support. - * Comment out the terminal types that you don't want or don't have, and - * uncomment those that you want included. Be aware that some terminal - * types (eg, SUN, UNIXPLOT) will require changes in the makefile - * LIBS definition. - */ - -/* These terminals are not relevant for MSDOS, OS2, MS-Windows, ATARI or Amiga */ -#if !defined(MSDOS) && !defined(OS2) && !defined(_Windows) && !defined(ATARI) && !defined(AMIGA_SC_6_1) && !defined(AMIGA_AC_5) - -#define AED /* AED 512 and AED 767 */ -#define BITGRAPH /* BBN BitGraph */ -#define COREL /* CorelDRAW! eps format */ -/* #define CGI /* SCO CGI */ -/* #define IRIS4D /* IRIS4D series computer */ -#define KERMIT /* MS-DOS Kermit Tektronix 4010 emulator */ -/* #define FIG /* Fig graphics language */ -/* #define NEXT /* NeXT workstation console */ -/* #define SUN /* Sun Microsystems Workstation */ -#define REGIS /* ReGis graphics (vt125, vt220, vt240, Gigis...) */ -/* #define RGIP /* WARNING: requires POSIX: Redwood Graphics Interface Protocol UNIPLEX */ -#define SELANAR /* Selanar */ -#define T410X /* Tektronix 4106, 4107, 4109 and 420x terminals */ -#define TEK /* Tektronix 4010, and probably others */ -/* #define UNIXPC /* unixpc (ATT 3b1 or ATT 7300) */ -/* #define UNIXPLOT /* unixplot */ -#define VTTEK /* VT-like tek40xx emulators */ -/* #define X11 /* X11R4 window system */ - -#define DXY800A /* Roland DXY800A plotter */ -#define EXCL /* QMS/EXCL laserprinter (Talaris 1590 and others) */ - -#define HP2648 /* HP2648, HP2647 */ -#define HP26 /* HP2623A and maybe others */ -/* #define DEBUG /* debugging terminal */ -#define HP75 /* HP7580, and probably other HPs */ -#define IMAGEN /* Imagen laser printers (300dpi) (requires -Iterm also) */ - -#define PRESCRIBE /* Kyocera Laser printer */ -#define QMS /* QMS/QUIC laserprinter (Talaris 1200 and others) */ - -#define TANDY60 /* Tandy DMP-130 series 60-dot per inch graphics */ -#define V384 /* Vectrix 384 and tandy color printer */ - -#define TGIF /* TGIF X-Windows draw tool */ - -#endif /* !MSDOS && !OS2 && !_Windows && !_ATARI && !AMIGA */ - -/* These terminals can be used on any system */ -#define AIFM /* Adobe Illustrator Format */ -#define DUMB - - -#define DXF /* DXF format for use with AutoCad (Release 10.x) */ - -#define EEPIC /* EEPIC-extended LaTeX driver, for EEPIC users */ -#define EMTEX /* LATEX picture environment with EMTEX specials */ -#define EPS180 /* Epson-style 180-dot per inch (24 pin) printers */ -#define EPS60 /* Epson-style 60-dot per inch printers */ -#define EPSONP /* Epson LX-800, Star NL-10, NX-1000 and lots of others */ -/* #define FIG /* Fig graphics language */ -#define GPIC /* gpic for groff */ -/* #define GRASS /* GRASS (geographic info system) monitor */ -#define HP500C /* HP DeskJet 500 Color */ -#define HPGL /* HP7475, HP7220 plotters, and (hopefully) lots of others */ -#define HPLJII /* HP LaserJet II */ -#define HPPJ /* HP PaintJet */ -#define LATEX /* LATEX picture environment */ -#define MF /* METAFONT driver */ -#define MIF /* Frame Maker MIF 3.00 format driver */ -#define NEC /* NEC CP6 pinwriter and LQ-800 printer */ -#define OKIDATA /* OKIDATA 320/321 standard 60-dpi printers */ -#define PBM /* PBMPLUS portable bitmap */ -#define PCL /* orignal HP LaserJet III */ -#define POSTSCRIPT /* PostScript */ -#define PSLATEX /* LaTeX picture environment with PostScript \specials */ -#define PSTRICKS /* LaTeX picture environment with PSTricks macros */ -#define STARC /* Star Color Printer */ -#define TEXDRAW /* TeXDraw drawing package for LaTeX */ -#define TPIC /* TPIC specials for TeX */ - -/* These are for Amiga only */ -#if defined(AMIGA_SC_6_1) || defined(AMIGA_AC_5) -#define AMIGASCREEN /* Amiga custom screen */ -#undef AIFM -#undef DXF -#undef FIG -#undef MIF -#endif - -/* These are for MSDOS only */ -#ifdef MSDOS -#ifdef __TURBOC__ -#define ATT6300 /* AT&T 6300 graphics */ -#else -#define ATT6300 /* AT&T 6300 graphics */ -#define CORONA /* Corona graphics 325 */ -#define HERCULES /* IBM PC/Clone with Hercules graphics board */ -#endif /* __TURBOC__ */ -#endif /* MSDOS */ - -#ifdef OS2 -#define OS2PM -#endif /*OS2 */ - -#ifdef GISBASE -#define GRASS -#endif + +/* + * $Id: term.h%v 3.50 1993/07/09 05:35:24 woo Exp $ + * + */ + +/* GNUPLOT - term.h */ +/* + * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * Permission to modify the software is granted, but not the right to + * distribute the modified code. Modifications are to be distributed + * as patches to released version. + * + * This software is provided "as is" without express or implied warranty. + * + * + * AUTHORS + * + * Original Software: + * Thomas Williams, Colin Kelley. + * + * Gnuplot 2.0 additions: + * Russell Lang, Dave Kotz, John Campbell. + * + * Gnuplot 3.0 additions: + * Gershon Elber and many others. + * + * There is a mailing list for gnuplot users. Note, however, that the + * newsgroup + * comp.graphics.gnuplot + * is identical to the mailing list (they + * both carry the same set of messages). We prefer that you read the + * messages through that newsgroup, to subscribing to the mailing list. + * (If you can read that newsgroup, and are already on the mailing list, + * please send a message info-gnuplot-request@dartmouth.edu, asking to be + * removed from the mailing list.) + * + * The address for mailing to list members is + * info-gnuplot@dartmouth.edu + * and for mailing administrative requests is + * info-gnuplot-request@dartmouth.edu + * The mailing list for bug reports is + * bug-gnuplot@dartmouth.edu + * The list of those interested in beta-test versions is + * info-gnuplot-beta@dartmouth.edu + */ + +/* + * term.h: terminal support definitions + * Edit this file depending on the set of terminals you wish to support. + * Comment out the terminal types that you don't want or don't have, and + * uncomment those that you want included. Be aware that some terminal + * types (eg, SUN, UNIXPLOT) will require changes in the makefile + * LIBS definition. + */ + +/* These terminals are not relevant for MSDOS, OS2, MS-Windows, ATARI or Amiga */ +#if !defined(MSDOS) && !defined(OS2) && !defined(_Windows) && !defined(ATARI) && !defined(MTOS) && !defined(AMIGA_SC_6_1) && !defined(AMIGA_AC_5) + +#define AED /* AED 512 and AED 767 */ +#define BITGRAPH /* BBN BitGraph */ +#define COREL /* CorelDRAW! eps format */ +/* #define CGI /* SCO CGI */ +/* #define IRIS4D /* IRIS4D series computer */ +#define KERMIT /* MS-DOS Kermit Tektronix 4010 emulator */ +/* #define FIG /* Fig graphics language */ +/* #define NEXT /* NeXT workstation console */ +/* #define SUN /* Sun Microsystems Workstation */ +#define REGIS /* ReGis graphics (vt125, vt220, vt240, Gigis...) */ +/* #define RGIP /* WARNING: requires POSIX: Redwood Graphics Interface Protocol UNIPLEX */ +#define SELANAR /* Selanar */ +#define T410X /* Tektronix 4106, 4107, 4109 and 420x terminals */ +#define TEK /* Tektronix 4010, and probably others */ +/* #define UNIXPC /* unixpc (ATT 3b1 or ATT 7300) */ +/* #define UNIXPLOT /* unixplot */ +#define VTTEK /* VT-like tek40xx emulators */ +/* #define X11 /* X11R4 window system */ + +#define DXY800A /* Roland DXY800A plotter */ +#define EXCL /* QMS/EXCL laserprinter (Talaris 1590 and others) */ + +#define HP2648 /* HP2648, HP2647 */ +#define HP26 /* HP2623A and maybe others */ +/* #define DEBUG /* debugging terminal */ +#define HP75 /* HP7580, and probably other HPs */ +#define IMAGEN /* Imagen laser printers (300dpi) (requires -Iterm also) */ + +#define PRESCRIBE /* Kyocera Laser printer */ +#define QMS /* QMS/QUIC laserprinter (Talaris 1200 and others) */ + +#define TANDY60 /* Tandy DMP-130 series 60-dot per inch graphics */ +#define V384 /* Vectrix 384 and tandy color printer */ + +#define TGIF /* TGIF X-Windows draw tool */ + +#endif /* !MSDOS && !OS2 && !_Windows && !_ATARI && !_MTOS && !AMIGA */ + +/* These terminals can be used on any system */ +#define AIFM /* Adobe Illustrator Format */ +#define DUMB + + +#define DXF /* DXF format for use with AutoCad (Release 10.x) */ + +#define EEPIC /* EEPIC-extended LaTeX driver, for EEPIC users */ +#define EMTEX /* LATEX picture environment with EMTEX specials */ +#define EPS180 /* Epson-style 180-dot per inch (24 pin) printers */ +#define EPS60 /* Epson-style 60-dot per inch printers */ +#define EPSONP /* Epson LX-800, Star NL-10, NX-1000 and lots of others */ +/* #define FIG /* Fig graphics language */ +#define GPIC /* gpic for groff */ +/* #define GRASS /* GRASS (geographic info system) monitor */ +#define HP500C /* HP DeskJet 500 Color */ +#define HPGL /* HP7475, HP7220 plotters, and (hopefully) lots of others */ +#define HPLJII /* HP LaserJet II */ +#define HPPJ /* HP PaintJet */ +#define LATEX /* LATEX picture environment */ +#define MF /* METAFONT driver */ +#define MIF /* Frame Maker MIF 3.00 format driver */ +#define NEC /* NEC CP6 pinwriter and LQ-800 printer */ +#define OKIDATA /* OKIDATA 320/321 standard 60-dpi printers */ +#define PBM /* PBMPLUS portable bitmap */ +#define PCL /* orignal HP LaserJet III */ +#define POSTSCRIPT /* PostScript */ +#define PSLATEX /* LaTeX picture environment with PostScript \specials */ +#define PSTRICKS /* LaTeX picture environment with PSTricks macros */ +#define STARC /* Star Color Printer */ +#define TEXDRAW /* TeXDraw drawing package for LaTeX */ +#define TPIC /* TPIC specials for TeX */ + +/* These are for Amiga only */ +#if defined(AMIGA_SC_6_1) || defined(AMIGA_AC_5) +#define AMIGASCREEN /* Amiga custom screen */ +#undef AIFM +#undef DXF +#undef FIG +#undef MIF +#endif + +/* These are for MSDOS only */ +#ifdef MSDOS +#ifdef __TURBOC__ +#define ATT6300 /* AT&T 6300 graphics */ +#else +#define ATT6300 /* AT&T 6300 graphics */ +#define CORONA /* Corona graphics 325 */ +#define HERCULES /* IBM PC/Clone with Hercules graphics board */ +#endif /* __TURBOC__ */ +#endif /* MSDOS */ + +#ifdef OS2 +#define OS2PM +#endif /*OS2 */ + +#ifdef GISBASE +#define GRASS +#endif diff -uN original/gnuplot.35/type.h patch/gnuplot.35/type.h --- original/gnuplot.35/type.h +++ patch/gnuplot.35/type.h Thu Sep 15 18:12:56 1994 @@ -0,0 +1,33 @@ +/* $Id: type.h 1.1 1993/08/01 04:22:07 cg Exp cg $ */ + +/* + * Header file: commonly used types + * + * + * Copyright of this module: Carsten Grammes, 1993 + * Experimental Physics, University of Saarbruecken, Germany + * + * Internet address: ph12hucg@rz.uni-sb.de + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. + * + * This software is provided "as is" without express or implied warranty. + */ + + +#ifndef TYPE_H +#define TYPE_H + +#if !defined (FALSE) || !defined (TRUE) +#define FALSE 0 +#define TRUE 1 +#endif + +typedef signed char boolean; +typedef unsigned short word; + +#endif diff -uN original/gnuplot.35/util.c patch/gnuplot.35/util.c --- original/gnuplot.35/util.c Thu Sep 16 04:59:54 1993 +++ patch/gnuplot.35/util.c Thu Sep 15 18:12:54 1994 @@ -44,6 +44,7 @@ send some other output to screen. If FALSE, the command line will be echoed to the screen before the ^ error message. */ +#ifndef LINUX #ifndef vms #if !defined(__ZTC__) && !defined(__PUREC__) #if !defined(__MSC__) @@ -53,6 +54,7 @@ extern char *sys_errlist[]; #endif #endif /* vms */ +#endif /* LINUX */ extern char input_line[]; extern struct lexical_unit token[]; @@ -71,7 +73,7 @@ extern char *strchr(); #endif -#ifndef AMIGA_AC_5 +#if !defined(AMIGA_AC_5) && !defined(MTOS) && !defined(ATARI) extern double sqrt(), atan2(); #endif Common subdirectories: original/gnuplot.35/win and patch/gnuplot.35/win