[net.sources] GNUPLOT 1.1: part 4 of 6

williams@vu-vlsi.UUCP (01/28/87)

GNUPLOT 1.1: part 4 of 6

-------------------------------CUT HERE----------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	docs
# This archive created: Wed Jan 28 12:04:27 1987
export PATH; PATH=/bin:$PATH
if test ! -d 'docs'
then
	echo shar: creating directory "'docs'"
	mkdir 'docs'
fi
echo shar: entering directory "'docs'"
cd 'docs'
echo shar: extracting "'intro'" '(457 characters)'
if test -f 'intro'
then
	echo shar: will not over-write existing file "'intro'"
else
cat << \SHAR_EOF > 'intro'
.B
.ce
INTRODUCTION
.R
GNUPLOT is a command-driven interactive function plotting program.
It is case sensitive (commands and function names written in lowercase
are not the same as those written in CAPS).  All command names may be
abbreviated, as long as the abbreviation is not ambiguous.  Any number
of commands may appear on line, separated by semicolons (;).
.sp
The following sections provide brief descriptions of each of the program
commands.
.sp 2 
SHAR_EOF
if test 457 -ne "`wc -c < 'intro'`"
then
	echo shar: error transmitting "'intro'" '(should have been 457 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'vmshelp.csh'" '(500 characters)'
if test -f 'vmshelp.csh'
then
	echo shar: will not over-write existing file "'vmshelp.csh'"
else
cat << \SHAR_EOF > 'vmshelp.csh'
#! /bin/csh
#
# vmshelp.csh /usr/help/gnuplot/* > gnuplot.hlp
# will convert the Unix help tree to VMS format,
# then use $ LIB/HELP GNUPLOT GNUPLOT under VMS to create the VMS .HLB

if (! $?level) then
	setenv level 0
endif
@ leveltmp = ($level + 1)
setenv level $leveltmp

foreach i ($*)
	if (-f $i) then
# plain file
		echo -n "$level "
		basename $i .HLP
		sed 's/^/ /' $i
	else if (-d $i) then
# directory
		echo -n "$level "
		basename $i
		sed 's/^/ /' $i/.HLP
# recurse!
		$0 $i/*
	endif
end
SHAR_EOF
if test 500 -ne "`wc -c < 'vmshelp.csh'`"
then
	echo shar: error transmitting "'vmshelp.csh'" '(should have been 500 characters)'
fi
chmod +x 'vmshelp.csh'
fi # end of overwriting check
echo shar: extracting "'term-driver.doc'" '(2024 characters)'
if test -f 'term-driver.doc'
then
	echo shar: will not over-write existing file "'term-driver.doc'"
else
cat << \SHAR_EOF > 'term-driver.doc'
Here's a brief description of what each term.c procedure does:

_init()  Called once, when the device is first selected.  This procedure
should set up things that only need to be set once, like handshaking and
character sets etc...

_graphics()  Called just before a plot is going to be displayed.  This
procedure should set the device into graphics mode.  Devices which can't
be used as terminals (like plotters) will probably be in graphics mode always
and therefore won't need this.

_text()  Called after a plot is displayed.  This procedure should set the
device back into text mode if it is also a terminal, so that commands can
be seen as they're typed.  Again, this will probably do nothing if the
device can't be used as a terminal.

_linetype(lt)  Called to set the line type before text is displayed or line(s)
plotted.  This procedure should select a pen color or line style if the
device has these capabilities.  lt is an integer from -2 to 8.  An lt of
-2 is used for the border of the plot.  An lt of -1 is used for the X and Y
axes.  lt 0 through 8 are used for plots 0 through 8.

_move(x,y)  Called at the start of a line.  The cursor should move to the
(x,y) position without drawing.

_vector(x,y)  Called when a line is to be drawn.  This should display a line
from the last (x,y) position given by _move() or _vector() to this new (x,y)
position.

_ulput_text(row,str)  Called to display text in the upper-left corner of
the screen/page.  row is an integer from 0 through 8.  The row starts
at the upper-left with 0 and proceed down.  str is the string to be displayed.

_lrput_text(row,str)  Called to display text in the lower-right corner of
the screen/page.  This is the same as ulput_text(), except that the string
should be displayed right-justified in the lower right corner of the screen.
The row starts at the lower-right with 0 and proceeds up.

_reset()  Called when Gnuplot is exited.  This procedure should reset the
device, possibly flushing a buffer somewhere or generating a form feed.
SHAR_EOF
if test 2024 -ne "`wc -c < 'term-driver.doc'`"
then
	echo shar: error transmitting "'term-driver.doc'" '(should have been 2024 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'hlp2ms.c'" '(2140 characters)'
if test -f 'hlp2ms.c'
then
	echo shar: will not over-write existing file "'hlp2ms.c'"
else
cat << \SHAR_EOF > 'hlp2ms.c'
/*
 * hlp2ms.c  -- program to convert VMS .HLP format to *roff -ms document
 * Thomas Williams 
 *
 * usage:  hlp2ms < file.hlp > file.ms
 *
 *   where file.hlp is a VMS .HLP file, and file.ms will be a [nt]roff
 *     document suitable for printing with nroff -ms or troff -ms
 *
 * typical usage for GNUPLOT:
 *
 *   vmshelp.csh /usr/help/gnuplot/* | hlp2ms | troff -ms
 */

#include <stdio.h>
#include <ctype.h>

#define MAX_NAME_LEN	256
#define MAX_LINE_LEN	256
#define LINE_SKIP		3


main()
{
	init(stdout);
	convert(stdin,stdout);
	finish(stdout);
	exit(0);
}


init(b)
FILE *b;
{
			/* in nroff, increase line length by 8 and don't adjust lines */
	(void) fputs(".if n \\{.nr LL +8m\n.na \\}\n",b);
    (void) fputs(".nr PO +0.3i\n",b);
	(void) fputs(".so titlepage\n",b);
	(void) fputs(".pn 1\n",b);
    (void) fputs(".ds CH GNUPLOT\n",b);
	(void) fputs(".ds RH Page %\n",b);
	(void) fputs(".bp\n",b);
    (void) fputs(".nr PS 12\n",b);
    (void) fputs(".nr VS 13\n",b);
	(void) fputs(".ta 1.5i 3.0i 4.5i 6.0i 7.5i\n",b);
	(void) fputs("\\&\n.sp 3\n.PP\n",b);
	(void) fputs(".so intro\n",b);
}


convert(a,b)
FILE *a,*b;
{
static char string[MAX_LINE_LEN],line[MAX_LINE_LEN];
int old = 1;
int sh_i, i;

	while (fgets(line,MAX_LINE_LEN,a)) {

		if (isdigit(line[0])) {
			(void) sscanf(line,"%d %[^\n]s",&sh_i,string);

			(void) fprintf(b,".sp %d\n",(sh_i == 1) ? LINE_SKIP : LINE_SKIP-1);

			if (sh_i > old) {
				do
					(void) fputs(".RS\n.IP\n",b);
				while (++old < sh_i);
			}
			else if (sh_i < old) {
				do
					(void) fputs(".RE\n.br\n",b);
				while (--old > sh_i);
			}

			(void) fprintf(b,".NH %d\n%s\n.sp 1\n.LP\n",sh_i,string);
			old = sh_i;

			(void) fputs(".XS\n",b);
			(void) fputs(string,b);
			(void) fputs("\n.XE\n",b);

		} else {
			switch (line[1]) {
				case ' ' : fputs(".br\n",b); fputs(line+1,b); fputs(".br\n",b);
 						   break;
				case '\'': fputs("\\&",b);
				default  : (void) fputs(line+1,b); 
			}
		}

	}
}


finish(b)		/* spit out table of contents */
FILE *b;
{
	(void) fputs(".pn 1\n",b);
	(void) fputs(".ds RH %\n",b);
	(void) fputs(".af % i\n",b);
	(void) fputs(".bp\n.PX\n",b);
}
SHAR_EOF
if test 2140 -ne "`wc -c < 'hlp2ms.c'`"
then
	echo shar: error transmitting "'hlp2ms.c'" '(should have been 2140 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'titlepage'" '(216 characters)'
if test -f 'titlepage'
then
	echo shar: will not over-write existing file "'titlepage'"
else
cat << \SHAR_EOF > 'titlepage'
.nr HM 3.2i
.TL
GNUPLOT
.br
An Interactive Plotting Program
.sp
.AU
Thomas Williams & Colin Kelley
.AI
Department of Electrical Engineering 
Villanova University
Villanova, PA  19085
\*(DY
.AB no
.AE
.LP
.nr HM 1.2i
SHAR_EOF
if test 216 -ne "`wc -c < 'titlepage'`"
then
	echo shar: error transmitting "'titlepage'" '(should have been 216 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'Makefile'" '(761 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
# Makefile for GNUPLOT documentation
#
# troff a copy of gnuplot -ms if you've got a laser printer
# otherwise, just print gnuplot.nroff on a line printer
#
HELPDIR = /usr/help/gnuplot
HELPFILES = $(HELPDIR)/*.HLP\
            $(HELPDIR)/expressions/*.HLP\
            $(HELPDIR)/expressions/functions/*.HLP\
            $(HELPDIR)/expressions/operators/*.HLP\
            $(HELPDIR)/plot/*.HLP\
            $(HELPDIR)/set-show/*.HLP

gnuplot.nroff: titlepage intro gnuplot.ms
	nroff -ms -Tlpr < gnuplot.ms > gnuplot.nroff

gnuplot.ms: hlp2ms gnuplot.hlp
	./hlp2ms < gnuplot.hlp > gnuplot.ms

gnuplot.hlp: $(HELPFILES)
	./vmshelp.csh $(HELPDIR)/* > gnuplot.hlp

hlp2ms: hlp2ms.c
	cc -o hlp2ms hlp2ms.c

clean:
	rm -f gnuplot.nroff gnuplot.ms gnuplot.hlp hlp2ms
SHAR_EOF
if test 761 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 761 characters)'
fi
fi # end of overwriting check
echo shar: done with directory "'docs'"
cd ..
#	End of shell archive
exit 0