plt - Software for 2D Plots 2.5

File: <base>/old/plt-2.0-2.1.patch (12,680 bytes)
diff -Naur plt-2.0/Makefile plt-2.1/Makefile
--- plt-2.0/Makefile	Fri Oct 18 00:03:52 2002
+++ plt-2.1/Makefile	Thu Nov  7 14:03:45 2002
@@ -1,10 +1,10 @@
 # file: Makefile	G. Moody		4 April 2001
-#			Last revised:	      18 October 2002	plt 2.0
+#			Last revised:	      7 November 2002	plt 2.1
 # Top-level `make' description file for `plt'.  See `INSTALL'.
 
 # Version and release numbers.
-PLTVER=2.0
-PLTREL=3
+PLTVER=2.1
+PLTREL=1
 
 # `make all' (or just `make') compiles the targets but does not install them.
 # You must have write permission in the `src' directory, but nothing more is
diff -Naur plt-2.0/src/axis.c plt-2.1/src/axis.c
--- plt-2.0/src/axis.c	Wed May  9 07:06:54 2001
+++ plt-2.1/src/axis.c	Mon Oct 21 01:27:02 2002
@@ -1,11 +1,12 @@
 /* file: axis.c		Paul Albrecht		September 1984
-			Last revised:		12 April 2001
+			Last revised:	       21 October 2002
 Axis and grid functions for plt
 
 Copyright (C) Paul Albrecht 1988
 
 Recent changes (by George Moody, george@mit.edu):
   12 April 2001: "-g ygrid -s x" now works; general cleanup
+  21 October 2002: moved formerly global variables here from plt.h
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -39,6 +40,13 @@
 #define	XGRID		040
 #define	YGRID		0100
 
+typedef	struct {
+    AxisPtr a;
+    double tick;
+    double scl;
+    char *lbl;
+} *TickPtr;
+
 static int gtype = OUT_TICK;
 
 /* Prototypes of functions defined in this module */
@@ -160,6 +168,9 @@
     }
 }
 
+static TickPtr ticks;
+static Uint maxTicks, nTicks;
+
 void TickDef(AxisPtr a, double tick, char *lbl, double scl, Boolean override)
 {
     TickPtr t;
@@ -173,17 +184,17 @@
 	delta = (tmp < 1e-3) ? 1e-3 : tmp/1e3;
     }
 
-    for (n = 0; n < nticks; n++) {
+    for (n = 0; n < nTicks; n++) {
 	t = &ticks[n];
 	tmp = fabs(tick - t->tick);
 	if (a->name == (t->a)->name && tmp < delta)
 	    break;
     }
 
-    if (n == nticks) {
-	if (nticks == maxticks)
-	    ticks = (TickPtr)azmem(ticks,&maxticks,12,sizeof(*ticks));
-	t = &ticks[nticks++];
+    if (n == nTicks) {
+	if (nTicks == maxTicks)
+	    ticks = (TickPtr)azmem(ticks, &maxTicks, 12, sizeof(*ticks));
+	t = &ticks[nTicks++];
     }
     else {
 	if (!override)
@@ -375,7 +386,7 @@
     min = (*oa->this)(oa->min);
     max = (*oa->this)(oa->max);
 
-    for (n = 0; n < nticks; n++) {
+    for (n = 0; n < nTicks; n++) {
 	t = &ticks[n];
 	if ((t->a)->name == a->name &&
 	    (t->lbl == 0 || *t->lbl != 0 || (gtype & SUB_GRID))) {
@@ -400,7 +411,7 @@
     ticksize = fudge * ((a->name == 'x') ? xinch : yinch)/5.0;
     toff = a->lo;
 
-    for (n = 0, t = ticks; n < nticks; n++, t++) {
+    for (n = 0, t = ticks; n < nTicks; n++, t++) {
 	if ((t->a)->name == a->name) {
 	    lbl = !(t->lbl && t->lbl[0] == 0);
 	    ticklen = (lbl ? (3*ticksize+1)/2 : ticksize) * t->scl;
diff -Naur plt-2.0/src/lw.c plt-2.1/src/lw.c
--- plt-2.0/src/lw.c	Thu May 10 12:06:59 2001
+++ plt-2.1/src/lw.c	Thu Nov  7 13:59:46 2002
@@ -1,5 +1,5 @@
 /* file: lw.c		Paul Albrecht		July 1987
- 			Last revised:		10 May 2001
+ 			Last revised:	      7 November 2002
 PostScript driver for plt
 
 Copyright (C) Paul Albrecht 1988
@@ -9,6 +9,7 @@
   30 March 2001: added LN, CN, RN, label concatenation
   11 April 2001: general cleanup
   10 May 2001: replaced old elabel() with implementation from xw.c
+  7 November 2002: corrected axis title placement when using log axes
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -197,9 +198,19 @@
     }
 }
 
+static Ptype xax_off, yax_off, xax_roff, yax_roff;
+
 void alabel(char *what, char *lbl, Ptype x, Ptype y)
 {
     sendstring(lbl);
+    if (strcmp(what, "YT") == 0)
+	x -= yax_off;
+    else if (strcmp(what, "YTR") == 0)
+	x += yax_roff;
+    else if (strcmp(what, "XT") == 0)
+	y -= xax_off;
+    else if (strcmp(what, "XTR") == 0)
+	y += xax_roff;
     printf(" %ld %ld %s\n", (long)x, (long)y, what);
 }
 
@@ -208,7 +219,7 @@
 
 void elabel(char *what, char *base, char *exponent, Ptype x, Ptype y)
 {
-    static Ptype xax_off, yax_off, xax_roff, yax_roff, xsize, ysize;
+    static Ptype xsize, ysize;
     Ptype off;
     char *font_name = StringSave(fontcode);
     double base_ps = prev_ps, exp_ps = prev_ps*0.8;
diff -Naur plt-2.0/src/main.c plt-2.1/src/main.c
--- plt-2.0/src/main.c	Wed May  9 07:06:00 2001
+++ plt-2.1/src/main.c	Mon Oct 21 00:36:46 2002
@@ -1,5 +1,5 @@
 /* file: main.c		Paul Albrecht		September 1984
-			Last revised:		24 April 2001
+			Last revised:	       21 October 2002
 plt: a set of programs for making 2D plots
 
 Copyright (C) Paul Albrecht 1988
@@ -9,6 +9,7 @@
 Recent changes (by George Moody, george@mit.edu):
   11 April 2001: general cleanup
   12 April 2001: removed vestigial TicInit()
+  21 October 2002: more cleanup
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -63,9 +64,9 @@
 
   if (pterm == NULL) pterm = getenv("PTERM");
   if (pterm == NULL) pterm = "";
-  if (npso) PTERMSpecificOpts();
+  PTERMSpecificOpts();
   arg0.c = pterm;
-  special(SETPTERM, arg0, arg1);	/* must follow pterm_specific_opts() */
+  special(SETPTERM, arg0, arg1);	/* must follow PTERMSpecificOpts() */
 
   DataInit(argv);
 
@@ -121,8 +122,8 @@
   }
 
   if (omode & LABELS)
-    for (n = 0; n < nlbls; n++)
-      TextDraw(&lbls[n]);
+    for (n = 0; n < Figure.nLbls; n++)
+      TextDraw(&Figure.lbls[n]);
 
   if (Plot.excluded)
     err(NO, "*** Excluded %ld points ***", Plot.excluded);
diff -Naur plt-2.0/src/option.c plt-2.1/src/option.c
--- plt-2.0/src/option.c	Wed May  9 08:54:43 2001
+++ plt-2.1/src/option.c	Mon Oct 21 01:28:54 2002
@@ -1,5 +1,5 @@
 /* file: option.c	Paul Albrecht		September 1987
-			Last revised:		  9 May 2001
+			Last revised:	       21 October 2002 
 Option-processing for plt
 
 Copyright (C) Paul Albrecht 1988
@@ -9,6 +9,7 @@
   3 May 2001: MAXLABELFILES now defined in plt.h
   7 May 2001: merged former optn.c, optn2.c, optn3.c
   9 May 2001: added version number, pointer to sources to optnHelp output
+  21 October 2002: moved formerly global variables here from plt.h
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -64,6 +65,8 @@
 static int in_parse(char **s, short maxflds, char *obj, short maxchrs);
 static int in_obj(char *obj, short maxchrs, Const mode);
 
+static Uint npso;
+
 void PTERMSpecificOpts(void)
 {
     int n;
@@ -109,6 +112,7 @@
 static void SetPTERMSpecificOpt(char *specificPterm, char *options)
 {
     PSOPtr pso;
+    static Uint maxpsos;
 
     if (npso == maxpsos)
 	psos = (PSOPtr)azmem(psos,&maxpsos,10,sizeof(*psos));
@@ -468,9 +472,10 @@
     short n, nc, nlines, status;
     char text[MAXLINE];
 
-    if (nlbls == maxlbls)
-	lbls = (LblPtr)azmem(lbls,&maxlbls,5,sizeof(*lbls));
-    l = &lbls[nlbls++];
+    if (Figure.nLbls == Figure.maxLbls)
+	Figure.lbls = (LblPtr)azmem(Figure.lbls, &Figure.maxLbls, 5,
+				    sizeof(*Figure.lbls));
+    l = &Figure.lbls[Figure.nLbls++];
     if (strcmp(o->name,"l") == 0 || strcmp(o->name,"L") == 0) {
 	l->xpos = d0;
 	l->ypos = d1;
diff -Naur plt-2.0/src/plt.h plt-2.1/src/plt.h
--- plt-2.0/src/plt.h	Wed May  9 08:50:19 2001
+++ plt-2.1/src/plt.h	Mon Oct 21 01:25:42 2002
@@ -1,5 +1,5 @@
 /* file: plt.h		Paul Albrecht		August 1984
-			Last revised:		7 May 2001
+			Last revised:	      21 October 2002
 Constants, macros, data types, global variables, and function prototypes
 
 Copyright (C) Paul Albrecht 1988
@@ -11,6 +11,7 @@
   7 May 2001: removed prototypes for functions in option.c that are now
 		 local in scope (static)
   9 May 2001: added PLT_VERSION, set initially to 1.99
+  21 October 2002: (2.1) moved many formerly global variables to *.c files
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -35,7 +36,7 @@
 #include <math.h>
 
 #ifndef PLT_VERSION
-#define PLT_VERSION	"1.99"
+#define PLT_VERSION	"2.1"
 #endif
 
 /* Constants */
@@ -264,13 +265,6 @@
 } AxisInfo, *AxisPtr;
 
 typedef	struct {
-    AxisPtr a;
-    double tick;
-    double scl;
-    char *lbl;
-} TickInfo, *TickPtr;
-
-typedef	struct {
     short c0;
     short c1;
     short c2;
@@ -283,17 +277,6 @@
     char *name;
 } PltInfo, *PltPtr;
 
-typedef	struct {
-    char *name;		/* name of this font group 			*/
-    char *font;		/* name of the font 				*/
-    double ps;		/* point size of the font group			*/
-    double lw;		/* line width for the font group		*/
-    double gray;	/* gray scale:  0=black, 1=white		*/
-    char *lm;		/* line mode associated with the group		*/
-    char *color;	/* color of the font				*/
-    char *gelem;	/* where on the graph this fgroup is used	*/
-} FgInfo, *FgPtr;
-
 /*	Label justification is coded as two character string.  In general, 
 	the first character (C, R or L) specifies the justification in the
 	axis of the text, while the second specifies the justification
@@ -357,19 +340,17 @@
 COMMON struct {
     float *pts;
     double *row;
-    Uint nPts;
-    Uint maxPts;
-    Uint nCols;
-    Uint maxCols;
+    Uint maxPts, nPts;
+    Uint maxCols, nCols;
 } Data;
 
 COMMON struct {
     FigPtr figs;
-    Uint nFigs;
-    Uint maxFigs;
+    Uint maxFigs, nFigs;
+    LblPtr lbls;
+    Uint maxLbls, nLbls;
     LegPtr legs;
-    Uint nLegs;
-    Uint maxLegs;
+    Uint maxLegs, nLegs;
     double xlPos;
     double ylPos;
     double xlDel;
@@ -380,8 +361,7 @@
 
 COMMON struct {
     PltPtr plts;
-    Uint nPlts;
-    Uint maxPlts;
+    Uint maxPlts, nPlts;
     double xFrom;
     double xIncr;
     Boolean xDrive;
@@ -433,12 +413,8 @@
     xwmaxs,
     ywmins,
     ywmaxs;
-COMMON FgPtr
-    fgrps;
 COMMON LblInfo
     title;
-COMMON LblPtr
-    lbls;
 COMMON PSOPtr
     psos;
 COMMON PStrInfo
@@ -457,17 +433,6 @@
     ywmax;
 COMMON short
     omode SVAL(ERASE|TITLES|LABELS|PLOTS|FIGURES);
-COMMON TickPtr
-    ticks;
-COMMON Uint
-    nticks,
-    maxticks,
-    nlbls,
-    maxlbls,
-    nfgrps,
-    maxfgrps,
-    npso,
-    maxpsos;
 
 /* Function prototypes */
 
diff -Naur plt-2.0/src/text.c plt-2.1/src/text.c
--- plt-2.0/src/text.c	Wed May  9 07:04:28 2001
+++ plt-2.1/src/text.c	Mon Oct 21 01:20:18 2002
@@ -1,5 +1,5 @@
 /* file: text.c		Paul Albrecht		September 1987
-			Last revised:		11 April 2001
+			Last revised:	       21 October 2002
 Text-handling functions for plt
 
 Copyright (C) Paul Albrecht 1988
@@ -7,6 +7,7 @@
 Recent changes (by George Moody, george@mit.edu):
   30 March 2001: added label concatenation
   11 April 2001: fixed nasty buffer overrun in MakeGraphTitle, general cleanup
+  21 October 2002: moved formerly global variables here from plt.h
 _______________________________________________________________________________
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -30,6 +31,19 @@
 #include <time.h>
 #include "plt.h"
 
+
+/* Font group object definition. */
+typedef	struct {
+    char *name;		/* name of this font group 			*/
+    char *font;		/* name of the font 				*/
+    double ps;		/* point size of the font group			*/
+    double lw;		/* line width for the font group		*/
+    double gray;	/* gray scale:  0=black, 1=white		*/
+    char *lm;		/* line mode associated with the font group	*/
+    char *color;	/* color of the font				*/
+    char *gelem;	/* where on the graph this font group is used	*/
+} *FgPtr;
+
 /* Prototypes of functions defined in this module. */
 void TextInit(int psdel);
 void MakeGraphTitle(char **argv);
@@ -395,6 +409,9 @@
   }
 }
 
+static FgPtr fgrps;
+static Uint nfgrps;
+
 static FgPtr FontGroupFind(char *fgName, Boolean mustFind)
 {
   FgPtr fg;
@@ -413,6 +430,7 @@
 static FgPtr FontGroupInit(char *fgName)
 {
   FgPtr fg;
+  static Uint maxfgrps;
 
   if (nfgrps == maxfgrps)		
     fgrps = (FgPtr)azmem(fgrps, &maxfgrps, 6, sizeof(*fgrps));