Patch 3 to Reldb - Relational database and graphing tools
Gunnar Stefansson
gunnar at hafro.is
Tue Sep 26 22:53:00 AEST 1989
This is patch number 3 to Reldb - the filters for relational database
operations and line plotting.
These patches constitute our additions to the line drawing program,
along with some minor mods to a few of the filters for database
operations. Thanks to Al Gaspar <gaspar at STL-08SIMA.ARMY.MIL> for
pointing out some portability problems. Some of these have now been
corrected and others at least documented along with a way to get around
them. A serious bug in the math program was also corrected.
Remember to apply patches 1 and 2 first.
Cd to the top level directory where you are keeping the Reldb stuff and
pipe this through 'patch -p'.
The scat program along with the plot filters should be a very nice
combination by the time you have installed these three initial patches.
I would very much like to hear about any suggestions, problems, etc, but
I will not be able to answer mail during the first few weeks of October.
Enjoy
-----------------------------------------------------------------------------
Gunnar Stefansson Uucp: {mcvax,enea}!hafro!gunnar
Marine Research Institute Internet: gunnar at hafro.is
P.O. Box 1390,Reykjavik Tel: +354 1 20240 Fax: +354 1 623790
*** patchlevel.h Tue Sep 26 12:01:13 1989
--- patchlevel.h Tue Sep 26 12:13:57 1989
Prereq: 2
***************
*** 1 ****
! #define PATCHLEVEL 2
--- 1 ----
! #define PATCHLEVEL 3
*** scat.src/defs.h Tue Sep 26 11:50:49 1989
--- scat.src/defs.h Sat Aug 19 20:14:30 1989
***************
*** 2,4 ****
! #define MAXPTS 1500 /* max no of data points (lines in file) */
#define MAXCOLS 25 /* max no of data columns */
--- 2,4 ----
! #define MAXPTS 2500 /* max no of data points (lines in file) */
#define MAXCOLS 25 /* max no of data columns */
*** scat.src/plttics.c Tue Sep 26 11:50:49 1989
--- scat.src/plttics.c Mon Sep 25 09:48:58 1989
***************
*** 5,7 ****
! plot_tics(wxmin,wxmax,wymin,wymax,xmin,xmax,xdelta,ymin,ymax,ydelta)
double xmin,xmax; /* min, max of all x-values */
--- 5,9 ----
! plot_ticks(wxmin,wxmax,wymin,wymax,xmin,xmax,xdelta,ymin,ymax,ydelta,
! numxlargeticks,numylargeticks,numxsmallticks,numysmallticks)
! int numxlargeticks,numylargeticks,numxsmallticks,numysmallticks;
double xmin,xmax; /* min, max of all x-values */
***************
*** 14,16 ****
char number[80];
- double numlargeticks;
double x, y;
--- 16,17 ----
***************
*** 23,26 ****
! labelplace("u");
x=xmin; /* x axis */
sprintf(number,xformat,x); /* char version of axis number */
--- 24,44 ----
! /*
! Figure out the number of tic marks on each axis
! */
!
! if(numxsmallticks==0)
! numxsmallticks=5;
! if(numxlargeticks==0)
! numxlargeticks=(int)(((xmax-xmin)/xdelta)/numxsmallticks);
! else
! xdelta=(xmax-xmin)/(numxlargeticks*numxsmallticks);
! if(numysmallticks==0)
! numysmallticks=5;
! if(numylargeticks==0)
! numylargeticks=(int)(((ymax-ymin)/ydelta)/numysmallticks);
! else
! ydelta=(ymax-ymin)/(numylargeticks*numysmallticks);
!
x=xmin; /* x axis */
+ labelplace("u"); /* labels under ticks */
sprintf(number,xformat,x); /* char version of axis number */
***************
*** 35,39 ****
! numlargeticks=(((xmax-xmin)/xdelta)/5);
! for(i=(int)numlargeticks;i--;){ /* large tick loop */
! for(j=5;j--;){ /* small tick loop */
transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
--- 53,56 ----
! for(i=numxlargeticks;i--;){ /* large tick loop */
! for(j=numxsmallticks;j--;){ /* small tick loop */
transf_data(wxmin,wymin,wxmax,wymax,x,ymin,&outx,&outy);
***************
*** 54,57 ****
- labelplace("l");
y=ymin; /* y axis */
sprintf(number,yformat,y); /* string rep of # */
--- 71,74 ----
y=ymin; /* y axis */
+ labelplace("l"); /* Labels left of ticks */
sprintf(number,yformat,y); /* string rep of # */
***************
*** 64,68 ****
label(number);
! numlargeticks=(((ymax-ymin)/ydelta)/5);
! for (i=(int)numlargeticks;i--;){
! for(j=5;j--;){
transf_data(wxmin,wymin,wxmax,wymax,xmin,y,&outx,&outy);
--- 81,85 ----
label(number);
!
! for (i=numylargeticks;i--;){
! for(j=numysmallticks;j--;){
transf_data(wxmin,wymin,wxmax,wymax,xmin,y,&outx,&outy);
*** scat.src/pttxt.c Tue Sep 26 11:50:49 1989
--- scat.src/pttxt.c Tue Apr 11 17:57:21 1989
***************
*** 14,16 ****
int outx, outy;
!
if(debuglevel)fprintf(stderr,"In plot_texts\n");
--- 14,16 ----
int outx, outy;
!
if(debuglevel)fprintf(stderr,"In plot_texts\n");
*** scat.src/readdat.c Tue Sep 26 11:50:50 1989
--- scat.src/readdat.c Mon Sep 25 09:42:26 1989
***************
*** 1,2 ****
--- 1,3 ----
#include <memory.h>
+ #include <stdio.h>
#include <string.h>
***************
*** 45,47 ****
! if (debuglevel) fprintf(stderr,"In read_data\n");
do{
--- 46,48 ----
! if (debuglevel>=2) fprintf(stderr,"In read_data\n");
do{
***************
*** 49,50 ****
--- 50,57 ----
col++;
+ if(col>=MAXCOLS){
+ fprintf(stderr,
+ "Too many columns in data(%d), max is %d",
+ col,MAXCOLS);
+ exit(1);
+ }
while((c=getchar())!='\t'&&c!=' '&&c!='\n'&&c!=EOF)
***************
*** 65,67 ****
! if (debuglevel) {
fprintf(stderr,"drawline after pcol\n");
--- 72,74 ----
! if (debuglevel>=2) {
fprintf(stderr,"drawline after pcol\n");
***************
*** 83,85 ****
}
! if (debuglevel) {
fprintf(stderr,"drawline after lcol\n");
--- 90,92 ----
}
! if (debuglevel>=2) {
fprintf(stderr,"drawline after lcol\n");
***************
*** 100,102 ****
! if (debuglevel) {
fprintf(stderr,"drawline after fix\n");
--- 107,109 ----
! if (debuglevel>=2) {
fprintf(stderr,"drawline after fix\n");
***************
*** 107,109 ****
*numcols=tmpcols-lcol;
! if (debuglevel) fprintf(stderr,"numcols= %d\n",*numcols);
--- 114,116 ----
*numcols=tmpcols-lcol;
! if (debuglevel>=2) fprintf(stderr,"numcols= %d\n",*numcols);
***************
*** 119,120 ****
--- 126,133 ----
+ if(*numpts>=MAXPTS){
+ fprintf(stderr,
+ "Too many lines in data(%d), max is %d",
+ *numpts,MAXPTS);
+ exit(1);
+ }
do {
*** scat.src/scat.c Tue Sep 26 11:50:50 1989
--- scat.src/scat.c Mon Sep 25 22:25:09 1989
***************
*** 15,17 ****
! char *optstr = "Eeicl:P:H:X:Y:F:w:x:y:d:l:L:"; /* list of options */
char *header = ""; /* figure caption */
--- 15,17 ----
! char *optstr = "Eeicl:P:H:X:Y:F:w:x:y:d:l:L:T:t:"; /* list of options */
char *header = ""; /* figure caption */
***************
*** 42,43 ****
--- 42,45 ----
"-F \"x/y format\" Format for numbers on x/y axis ",
+ "-T \"x/y number\" Number of large tick marks on x/y axis ",
+ "-t \"x/y number\" Number of small tick marks on x/y axis ",
"-c Use colors ",
***************
*** 67,68 ****
--- 69,71 ----
* missing */
+
double spaceconst = SPACECONST;
***************
*** 92,93 ****
--- 95,104 ----
+ int numxlargeticks=0;/* number of large ticks on x axis*/
+ int numylargeticks=0;/* number of large ticks on y axis*/
+ int numxsmallticks=0;/* number of small ticks on x axis*/
+ int numysmallticks=0;/* number of small ticks on y axis*/
+
+
+
+
while ((c = getopt(argc, argv, optstr)) != EOF) {
***************
*** 134,135 ****
--- 145,192 ----
break;
+ case 'T':
+ if(debuglevel)
+ fprintf(stderr,"Got arg -T with ->%s<-\n",optarg);
+ c = optarg[0];
+ if (c == 'x' || c == 'X' ) {
+ if(sscanf(++optarg,"%d",&numxlargeticks)!=1)
+ {
+ fprintf(stderr,"Incorrect use of -T option\n");
+ fprintf(stderr,"Sample use: -Tx10\n");
+ fprintf(stderr,"Use scat -h to get list of options\n");
+ exit(1);
+ }
+ if(debuglevel)
+ fprintf(stderr,"Read this as %d for x\n",numxlargeticks);
+ } else {
+ if(sscanf(++optarg,"%d",&numylargeticks)!=1)
+ {
+ fprintf(stderr,"Incorrect use of -T option\n");
+ fprintf(stderr,"Sample use: -Ty10\n");
+ fprintf(stderr,"Use scat -h to get list of options\n");
+ exit(1);
+ }
+ if(debuglevel)
+ fprintf(stderr,"Read this as %d for y\n",numylargeticks);
+ }
+ break;
+ case 't':
+ c = optarg[0];
+ if (c == 'x' || c == 'X') {
+ if(sscanf(++optarg,"%d",&numxsmallticks)!=1)
+ {
+ fprintf(stderr,"Incorrect use of -t option\n");
+ fprintf(stderr,"Sample use: -tx10\n");
+ fprintf(stderr,"Use scat -h to get list of options\n");
+ exit(1);
+ }
+ } else {
+ if(sscanf(++optarg,"%d",&numysmallticks)!=1)
+ {
+ fprintf(stderr,"Incorrect use of -t option\n");
+ fprintf(stderr,"Sample use: -ty10\n");
+ fprintf(stderr,"Use scat -h to get list of options\n");
+ exit(1);
+ }
+ }
+ break;
case 'w':
***************
*** 162,163 ****
--- 219,222 ----
fprintf(stderr, "pcol= %d, lcol=%d\n", pcol, lcol);
+ fprintf(stderr, "xtics= (%d,%d), ytics=(%d,%d)\n",
+ numxlargeticks, numxsmallticks,numylargeticks, numysmallticks);
}
***************
*** 220,221 ****
--- 279,285 ----
}
+
+ /*
+ Open the plotting device and possibly erase
+ */
+
if (debuglevel)
***************
*** 235,236 ****
--- 299,308 ----
+ /*
+ Convert all input data to the new coordinates.
+ Note that there are two transformations,
+ both to get into the (0,0) to (spaceconst,spaceconst) area
+ (which defines the paper or screen), and then another to
+ get into whatever is specified by the -w option.
+ */
+
if (debuglevel)
***************
*** 243,244 ****
--- 315,325 ----
+ /*
+ Now we get to drawing the figure.
+ Lots of ifs and buts here.
+ We need to check whether colors are used.
+ Also whether a label or line should be drawn.
+ If we have a missing value (<tab><tab> in input)
+ then we don't draw a line to the point.
+ */
+
if (debuglevel)
***************
*** 276,278 ****
fprintf(stderr, "Plotting tic-marks\n");
! plot_tics(wxmin, wxmax, wymin, wymax, xmin, xmax, xdelta, ymin, ymax, ydelta);
--- 357,361 ----
fprintf(stderr, "Plotting tic-marks\n");
! plot_ticks(wxmin, wxmax, wymin, wymax, xmin, xmax, xdelta,
! ymin, ymax, ydelta,
! numxlargeticks,numylargeticks,numxsmallticks,numysmallticks);
*** scat.src/trans.c Tue Sep 26 11:50:50 1989
--- scat.src/trans.c Mon Sep 25 09:41:30 1989
***************
*** 15,17 ****
*outy=(int)((wy2-wy1)*(iny-wymin)/(wymax-wymin)+wy1);
! if(debuglevel){
fprintf(stderr,"inx= %lf iny= %lf\n",inx,iny);
--- 15,17 ----
*outy=(int)((wy2-wy1)*(iny-wymin)/(wymax-wymin)+wy1);
! if(debuglevel>=5){
fprintf(stderr,"inx= %lf iny= %lf\n",inx,iny);
*** reldb.src/addup.c Tue Sep 26 11:50:42 1989
--- reldb.src/addup.c Sat Sep 23 12:38:04 1989
***************
*** 31,33 ****
#include <stdio.h>
! #include <strings.h>
--- 31,37 ----
#include <stdio.h>
! #ifdef SYSV
! # include <string.h>
! #else
! # include <strings.h>
! #endif
***************
*** 191,193 ****
} /* addup */
!
output(oldline,sum)
--- 195,197 ----
} /* addup */
!
output(oldline,sum)
*** reldb.src/dbe.add.sh Tue Sep 26 11:50:44 1989
--- reldb.src/dbe.add.sh Tue Sep 5 12:37:17 1989
***************
*** 1,2 ****
! :
#
--- 1,2 ----
! #!/bin/sh
#
***************
*** 15,16 ****
--- 15,37 ----
#
+
+ if [ ! -f "$1" ]
+ then
+ echo "Usage: $0 filename"
+ exit 1
+ fi
+
+ #
+ # Stole the following from Elm - probably from Larry Wall originally
+ #
+ if [ "`echo -n`" = "-n" ]
+ then
+ erase="tput clear"
+ nflag=""
+ cflag="\\c"
+ else
+ erase=clear
+ nflag="-n"
+ cflag=""
+ fi
+
read x < $1
***************
*** 19,21 ****
record=""
! tput clear
for fld in $x
--- 40,42 ----
record=""
! $erase
for fld in $x
***************
*** 22,24 ****
do
! echo "$fld : \c"
read temp
--- 43,45 ----
do
! echo $nflag "$fld : $cflag"
read temp
*** reldb.src/joinle.c Tue Sep 26 11:50:45 1989
--- reldb.src/joinle.c Tue Apr 11 17:56:58 1989
***************
*** 26,28 ****
char *curfile;
!
int minlen=999999;
--- 26,28 ----
char *curfile;
!
int minlen=999999;
*** reldb.src/math.sh Tue Sep 26 11:50:45 1989
--- reldb.src/math.sh Tue Sep 12 14:34:44 1989
***************
*** 35,37 ****
mean=sum[i]/freq[i]
! if(mean=int(mean))
printf("%d\t",sum[i]/freq[i]);
--- 35,37 ----
mean=sum[i]/freq[i]
! if(mean==int(mean))
printf("%d\t",sum[i]/freq[i]);
*** reldb.src/matrix.c Tue Sep 26 11:50:46 1989
--- reldb.src/matrix.c Tue Apr 11 17:57:00 1989
***************
*** 19,21 ****
char *format="\t%f"; /* Output table default format */
!
static float freq[MAXX][MAXY]; /* the frequencies */
--- 19,21 ----
char *format="\t%f"; /* Output table default format */
!
static float freq[MAXX][MAXY]; /* the frequencies */
***************
*** 26,28 ****
int minx,maxx,miny,maxy;/* computed bounds on input data */
!
while(--argc){
--- 26,28 ----
int minx,maxx,miny,maxy;/* computed bounds on input data */
!
while(--argc){
*** reldb.src/plokk.c Tue Sep 26 11:50:47 1989
--- reldb.src/plokk.c Tue Apr 11 17:57:03 1989
***************
*** 18,20 ****
int n; /* first value in a data line */
!
int select[5000]; /* 1=values to select 0=skip*/
--- 18,20 ----
int n; /* first value in a data line */
!
int select[5000]; /* 1=values to select 0=skip*/
*** reldb.src/project.c Tue Sep 26 11:50:47 1989
--- reldb.src/project.c Sat Sep 23 12:45:20 1989
***************
*** 3,5 ****
! Author; johanna at hafro.is (1987?)
*/
--- 3,26 ----
! Original author: johanna at hafro.is (1987?)
! ================================================================
! Note:
!
! This program is in severe need of rehabilitation -- first of all there
! are no comments, so it's quite hard to figure out what's going on, and
! secondly a number of things are hardwired.
!
! A known problem here is with compilation, due to the way matrices are
! defined in:
! char tabv[1000][100];
! int posv[1000];
! On at least one machine, the program runs if you change these
! definitions to:
! char tabv[500][50];
! int posv[500];
! Not that this kind of thing occurs several times in the program.
! If you do clean up the program, please let me know so that I can send
! the mods to other people.
!
! gunnar at hafro.is (September, 1989)
! ================================================================
*/
*** reldb.src/regress.c Tue Sep 26 11:50:40 1989
--- reldb.src/regress.c Tue Apr 11 17:57:06 1989
***************
*** 4,6 ****
Input : A reldb file of the form :
!
xname yname
--- 4,6 ----
Input : A reldb file of the form :
!
xname yname
***************
*** 12,14 ****
Usage : regress < datafile
!
Output : to std. out, all sorts of regression statistics.
--- 12,14 ----
Usage : regress < datafile
!
Output : to std. out, all sorts of regression statistics.
*** reldb.src/subtotal.c Tue Sep 26 11:50:41 1989
--- reldb.src/subtotal.c Sat Sep 23 12:38:58 1989
***************
*** 16,18 ****
Revisions due to incorrect string handling:
! gunnar at hafro.is (April, 1989)
*/
--- 16,18 ----
Revisions due to incorrect string handling:
! gunnar at hafro.is (April, 1989) and again, Sept, 1989.
*/
***************
*** 21,24 ****
#include <sys/wait.h>
- #endif
#include <strings.h>
#define MAXCMD 1000
--- 21,27 ----
#include <sys/wait.h>
#include <strings.h>
+ #else
+ #include <string.h>
+ #endif
+
#define MAXCMD 1000
*** reldb.src/testdb.sh Tue Sep 26 11:50:42 1989
--- reldb.src/testdb.sh Tue Sep 5 12:40:28 1989
***************
*** 19,20 ****
--- 19,21 ----
then
+ echo Making directory `pwd`/testdb
mkdir testdb
***************
*** 26,28 ****
cp $RELDBDIR/* .
! echo "Running 'make' - this willl result in a number of .tmp-files"
make
--- 27,29 ----
cp $RELDBDIR/* .
! echo "Running 'make' - this will result in a number of .tmp-files:"
make
*** testdb/subtotal.res Tue Sep 26 11:50:58 1989
--- testdb/subtotal.res Sun Apr 16 20:17:21 1989
***************
*** 25,27 ****
2 9
!
Input data (subtotal.data):
--- 25,27 ----
2 9
!
Input data (subtotal.data):
--
-----------------------------------------------------------------------------
Gunnar Stefansson Uucp: {mcvax,enea}!hafro!gunnar
Marine Research Institute Internet: gunnar at hafro.is
P.O. Box 1390,Reykjavik Tel: +354 1 20240 Fax: +354 1 623790
More information about the Comp.sources.bugs
mailing list