Overview
Comment:discard some files that are probably not especially useful

git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1377 2bfe0521-f11c-4a00-b80e-6202646ff360

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: bb64a0280f83aca79f04fde800ca9f2d5b8da49496f40c44e6bd4a79df86d526
User & Date: arthurcnorman@users.sourceforge.net on 2011-09-02 18:49:16
Other Links: manifest | tags
Context
2011-09-02
18:52:16
discard some files that are probably not especially useful

git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1378 2bfe0521-f11c-4a00-b80e-6202646ff360 check-in: 8e196c7117 user: arthurcnorman@users.sourceforge.net tags: master, trunk

18:49:16
discard some files that are probably not especially useful

git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1377 2bfe0521-f11c-4a00-b80e-6202646ff360 check-in: bb64a0280f user: arthurcnorman@users.sourceforge.net tags: master, trunk

18:41:44
discard some files that are probably not especially useful

git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1376 2bfe0521-f11c-4a00-b80e-6202646ff360 check-in: 2bf132ecc3 user: arthurcnorman@users.sourceforge.net tags: master, trunk

Changes

Deleted r34.1/plot/Copyright version [b7a479a1d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































Deleted r34.1/plot/EPSView.h version [13610bdc68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * $Id: EPSView.h,v 3.24 1992/02/29 16:29:37 woo Exp woo $
 *
 * $Log: EPSView.h,v $
 * Revision 3.24  1992/02/29  16:29:37  woo
 * gnuplot3.2, beta 4
 *
 */

#import <appkit/View.h>

@interface EPSView:View {}

+ new;

@end

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































Deleted r34.1/plot/EPSView.m version [da8021ccc0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef lint
static char *RCSid = "$Id: EPSView.m,v 3.24 1992/02/29 16:23:41 woo Exp woo $";
#endif

/*
 * $Log: EPSView.m,v $
# Revision 3.24  1992/02/29  16:23:41  woo
# gnuplot3.2, beta 4
#
 * Revision 3.23  1992/02/21  20:18:16  woo
 * gnuplot3.2, beta 3
 *
 */

#import "EPSView.h"

@implementation EPSView

+ new
{
	self = [super new];
	return self;
}

@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted r34.1/plot/EpsViewer.h version [71a6669d47].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * $Id: EpsViewer.h,v 3.24 1992/02/29 16:27:40 woo Exp woo $
 *
 * $Log: EpsViewer.h,v $
 * Revision 3.24  1992/02/29  16:27:40  woo
 * gnuplot3.2, beta 4
 *
 */

#import <appkit/Application.h>
#import <appkit/graphics.h>
#import <dpsclient/dpsclient.h>
#import <appkit/Window.h>

@interface EpsViewer:Application
{
	id theNewWin;
}

- windowCreate:(NXCoord)width Height:(NXCoord)height;
- (NXRect *)nextRectForWidth:(NXCoord)width Height:(NXCoord)height;

@end


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted r34.1/plot/EpsViewer.m version [993a0d8ccc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef lint
static char *RCSid = "$Id: EpsViewer.m,v 3.24 1992/02/29 16:27:40 woo Exp woo $";
#endif

/*
 * $Log: EpsViewer.m,v $
# Revision 3.24  1992/02/29  16:27:40  woo
# gnuplot3.2, beta 4
#
 */

#import "EpsViewer.h"
#import "EPSView.h"
#import <appkit/nextstd.h>
#import <appkit/OpenPanel.h>

@implementation EpsViewer

- windowCreate:(NXCoord) width Height:(NXCoord) height
{
	NXRect rect = {{0.0,0.0},{width,height}};
	
	/* create the new window, in a good place */
	theNewWin = [Window
		newContent:[self nextRectForWidth:width Height:height]
		style:NX_TITLEDSTYLE
		backing:NX_RETAINED
		buttonMask:(NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK)
		defer:NO];
	/* we need to receive windowDidBecomeMain: and windowDidResignMain: */
	[theNewWin setDelegate:self];
	/*
	 * create a new EPSView, make it the contentView of our new window,
	 * and destroy the window's old contentView 
	 */
	[[theNewWin setContentView:[EPSView new]] free];
		/* display the window, and bring it forth */
	[theNewWin display];
	[theNewWin makeKeyAndOrderFront:self];	
/*	[theNewWin orderBack:self];			*/
	/* show the frame */
	return self;
}
 
/***************************************************************************/
/* nextRectForWidth:Height: - return the next good content rectangle       */
/*  from Carl F. Sutter's wonderful ViewGif2 'Controller' method...        */
/***************************************************************************/
/* nextTopLeft - return the next good top left window position		   */
/***************************************************************************/

- (NXRect *)nextRectForWidth:(NXCoord)width Height:(NXCoord)height
{
#define OFFSET 10.0
#define MAX_STEPS 20
#define INITIAL_X 356.0
#define INITIAL_Y 241.0
	NXPoint         nxpTopLeft;
	NXRect          nxrTemp;	/* used to find window height	 */
	NXRect          nxrWinHeight;	/* bounds of enclosing window	 */
	NXSize          nxsScreen;	/* size of screen		 */
	static NXRect   nxrResult;	/* the Answer!			 */
	static int      nCurStep = 0;

	/* find a good top-left coord */
	nxpTopLeft.x = INITIAL_X + nCurStep * OFFSET;
	nxpTopLeft.y = INITIAL_Y + nCurStep * OFFSET;
	if (++nCurStep > MAX_STEPS)
		nCurStep = 0;
	/* find window height using nxrTemp */
	nxrTemp.size.width = width;
	nxrTemp.size.height = height;
	nxrTemp.origin.x = nxrTemp.origin.y = 0;
	[Window getFrameRect:&nxrWinHeight forContentRect:&nxrTemp
	 style:NX_TITLEDSTYLE];
	[NXApp getScreenSize:&nxsScreen];
	/* find the lower-left coord */
	nxrResult.origin.x = nxpTopLeft.x;
	nxrResult.origin.y = nxsScreen.height - nxrWinHeight.size.height - nxpTopLeft.y;
	nxrResult.size.width = width;
	nxrResult.size.height = height;
	return (&nxrResult);
}

@end

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































Deleted r34.1/plot/History version [167578b53b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334

		     GNUPLOT 3.2 RELEASE NOTES

This describes changes to gnuplot since version 3.0.

Highlights: 
-----------
Version 3.1 (also known as version 3.0, patchlevel 1) was a bugfix
release.  In particular, it corrected the y logscale error.
Version 3.2 also fixes a number of bugs but contains two major
changes.  The X11 support, in particular, gnuplot_x11.c was completely
rewritten to rely solely on X11 intrinsics and no widget libraries.
This should hopefully make it more portable.  The other major change
is hidden line removal for explicit 3D surfaces.  

This release was deliberately limited in scope in order to
release a new X11 driver and have some hidden line removal capability
quickly.  Version 3.3 will be a much larger modification.


                            ACKNOWLEDGEMENTS

- New generic gnuplot_x11.c, Ed Kubatis <ejk@ux2.ncsa.uiuc.edu>
- Hidden Line Removal for Explicit Surfaces and IRIX 4.0 fixes,
  Gershon Elber <gershon@gr.utah.edu>
- Table Terminal Driver, Kevin Russo <russo@rudedog.nrl.navy.mil>
- PCL5 driver fixes (HPGL page eject),datafile pipe and README,
  Alex Woo <woo@ames.arc.nasa.gov>
- Pbmplus driver & fix to ylog tics, Put FAR pointers in bitmap.c and bitmap.h
  Russell Lang <rjl@monu1.cc.monash.edu.au>
- NeXT Console Driver, Nick Strobel <strobel@phast.phys.washington.edu>
- Fix GNUTERM environment with disk resident BGI drivers,
  Craig Johnston <johnston@maxwell.ee.washington.edu>
- Fix tables for troff in doc2ms, Michael Schuh <schuh@ames.arc.nasa.gov>
- Fix dump when GNUPLOT$HELP undefined, 
  Wolfgang J. Moeller <moeller@gwdgv1.dnet.gwdg.de>
- Fix AMIGA segment limits, Carsten Steger <stegerc@informatik.tu-muenchen.de>
- Bug fix to latex.trm, Rob Cunningham <rkc@xn.ll.mit.edu>

=========================================================================
		     GNUPLOT 3.0 RELEASE NOTES

This describes changes to gnuplot since version 2.02 (ie, 2.0
patchlevel 2). 

Highlights: 
-----------
Gnuplot now handles surfaces as well. A new command names 'splot' (for
surface plot) has been added for that purpose. A number of new 'set'
options for surfaces have also been added and include: isosamples,
view, contour, cntrparam, mapping and surface.  All tic/label/range
setting for x and y axes were extended for z as well.

The size of data file for both curves and surfaces is now independent
of the samples (and iso_samples) variables. Data structures will
automatically be extended to hold the entire data file.

New features:
-------------
3-d plotting with 'splot', and many auxiliary options.

New 'errorbars' plot style.

New 'using x:y{:z}' format (NOT COMPATIBLE WITH GNUPLOT 2.02).

Data file plotting (for both curves and surfaces) does not require
setting samples (and isosamples for surfaces) any more. Size is
increased on the fly, without affecting the sample rate of functions. 

New makefile scheme for unix, that supports lots of flavors.

Command-line editing and history.

Adjustable display of plot border ('set border').

Set-commands 'x/y/zlabel' can now position the label.

Set-command 'title' can now position the title.

New time display command ('set time').

All PostScript devices were rewritten and merged into one (Color
Postscript is supported). Due to this many of the old postscript
terminal driver names are not supported; only 'postscript' is
recognized. Use 'help set terminal postscript' to find out how to get
your old favorite back, and more.

A 'gnuplot' mode for emacs in the file gnuplot.el.

SGI device was improved.

New option to 'set arrow' called 'nohead'. 

List of all new commands:
-------------------------
splot

List of all new set-show commands:
---------------------------------
border, cntrparam, contour, isosamples, mapping, rrange, surface,
time, view, zlabel, ztics, zrange.

List of changed set-show commands:
----------------------------------
arrow, terminal, title, xlabel, ylabel, zlabel

New terminal drivers:
---------------------
vws, apollo, gpr apollo, dumb, BigFig, Super
VGA, ln03/hplj/hpdj, dxf.

Deletions:
----------
The gnut2p translator (translating gnutex to gnuplot) has been removed
from the standard distribution.  It is available for ftp separately at
cs.duke.edu as dist/sources/gnuplot/gnut2p.tar.Z

Bug fixes include:
------------------
Fix a bug in parametric type hangup.

Add a .sty file to fix indexing problem in manual.

Fix a bug in hpljii.

Fix a bug in FIG arrows.


                            ACKNOWLEDGEMENTS

- New PostScript device by Russell Lang (rjl@monu1.cc.monash.edu.au).
- Several bug fixes, manual proofing, World Map by John Campbell
(campbell@nauvax.ucc.nau.edu).
- Eliminating samples from data files, lasergnu, and errorbars by
David Kotz (David.Kotz@Dartmouth.edu).
- New history and line editing capability for Unix and MSDOS, bivariate
  functions and some bug fixes by Tom Tkacik (tkacik@hobbes.cs.gmr.com).
- New using x:y{:z} format by Dennis Linse (djlinse@phoenix.princeton.edu).
- Some polar enhancements, time display and some bug fixes by
Alex Woo (woo@ra-next.arc.nasa.gov).
- Dumb terminal by Francois Pinard (pinard@iro.umontreal.ca).
- VWS device by Walter Speth (speth@dbnpib5.bitnet).
- BigFig device by (ian@augean.ua.oz.au).
- XDF device by Florian Hiss (fhis1231@w204zrz.zrz.tu-berlin.de).
- HP Desk Jet device, overlay support for BCC and more efficient help
and pc.trm for MSDOS by Maurice Castro and Russell Lang
(rjl@monu1.cc.monash.edu.au). 
- New makefile scheme by Roque Donizete De Oliveira and David Kotz
(oliveria@caen.engin.umich.edu and David.Kotz@Dartmouth.edu).
- The 3d extensions, contouring, Super VGA device, and bringing this new
version up by Gershon Elber (gershon@cs.utah.edu).

Other bug fixes/improvments:
= Tom Bopp (tbopp@uhunix.uhcc.hawaii.edu)
= Kenneth H. Carpenter (khc@eece.ksu.edu)
= Mark Christopher (christo@bnr.ca)
= Henk de Haan (haan@irimcf.tudelft.nl)
= David Gillespie (daveg@csvax.cs.caltech.edu)

Beta testers:
+ John Campbell (campbell@nauvax.ucc.nau.edu)
+ Kenneth H. Carpenter (khc@eece.ksu.edu)
+ Gershon Elber (gershon@cs.utah.edu)
+ Pat Empleo (empleop@afal-edwards.af.mil)
+ David Kotz (dfk@moose.dartmouth.edu)
+ Russell Lang (rjl@monu1.cc.monash.edu.au)
+ Tom Tkacik (tkacik@hobbes.cs.gmr.com)
+ Roque Donizete De Oliveira (oliveria@caen.engin.umich.edu)
+ Walter Speth (Speth@dbnpib5.bitnet)
+ Carsten Steger (stegerc@gshalle2.informatik.tu-muenchen.de)

============================================================================

                     GNUPLOT 2.0 RELEASE NOTES

New terminal drivers: ATT6300, Roland DXY800A, EEPIC, emTeX, EPSON LX-800, 
EPSON 60dpi, Fig, HP2648, HPGL, HP LaserJet, Imagen, Kermit-MS Tektronix 
emulator, LaTeX, MCGA, NEC CP6 pinwriter, POSTSCRIPT, Proprinter, Star color 
printer, Tandy DMP-130, Tektronix 410x, SUN, VGA, X11.

Additions:

Command-line arguments are accepted. They are treated as names of
files containing gnuplot commands. Gnuplot loads them, one by one, and
then exits.

Command 'plot' now has a 'title' option to change the information in
the key.  The 'with' option can now specify line type and point type.

Command 'pause'.

Command 'replot' allows the addition of extra plots. 

Command 'save' now saves all the 'set' options, including the last
plot command.

Command 'set autoscale' now accepts autoscaling on the x axis for data
files. The default is autoscaling on both axes. 

Command 'set noclip' disables clipping of points near the border. 'set
clip' reenables clipping. The default used to be 'clip', and is now
'noclip'. Clipping has also been extended to clip lines that extend
outside the borders: line plots are now clipped at the plot boundary.
Formerly, the line stopped at the last in-range data point.

Numerical labelling at tic marks on x and y axes.  Command 'set
format' allows the format of the tic mark labels to be altered.
Commands 'set xtics' and 'set ytics' allow for alphanumeric labels and
arbitrary tic positions. 

Command 'set grid' adds a grid between the tic marks.

Improved key gives sample point or line types.  Key can be disabled
with the 'set nokey'. Key can be positioned anywhere. 

Command 'set label' allows the placement of arbitrary text labels and
arrows. 

Command 'set polar' for polar plots.

Command 'set offsets' for reducing the plotted area.  Useful for polar
plots.

Command 'set size' scales the displayed size of the plot.

Command 'set tics out' causes the tics to be drawn outwards from the
border.  Useful for impulse plots.

Command 'set title' places a text label above the plot.

Commands 'set xlabel' and 'set ylabel' place text labels on the x and
y axes respectively.  Some terminals will place the y label vertically
upwards on the left of the plot, others place the label horizontally
at the left of the plot.

Improved tics on log scales.

Extended comments: comments are allowed anywhere reasonable in the
input line, and continue to the end of the input line.

Line continuation (with \) is added.

Non-interactive use, through redirection or "load" command, is
improved. Error messages expanded to include file name and line
number, and to reprint command line if not interactive.

New plotting styles 'linespoints' and 'dots'.

Blank lines in data files denote "breaks". In lines and linespoints
plot styles, this breaks the curve being drawn and begins at the next
point, without changing the line or point types.

Completely new interactive help system that is similar to VMS help
system. A printed manual can be obtained in LaTeX, troff, or nroff and
is based on the same information as the interactive help.

PC version now compiles with the large model so that gnuplot will
compile with the above additions!

Bug fixes include:
------------------
Bug involving functions plotted on a logarithmic x axis is fixed. 

Errors inside of loaded files now clean up and close files properly.

Numbers of the form xxxxe+nn are now acceptable (+ sign caused error).

Tics are now place inside the borders (some were outside).

Reverse axes now work properly.

Command 'set output ""' used to crash.  

VMS was closing stdout, so 'set output' code changed to avoid closing
it.  VMS version of gnuplot now performs a SET TERM/NOWRAP itself.

Terminal is now reset before closing output file, changing terminal
type or exiting gnuplot.

Several old bugs have been superseded by new ones.


                            ACKNOWLEDGEMENTS

The Unix PC, polar, pause, and offset additions were by John Campbell.
(CAMPBELL@NAUVAX.bitnet)
The Turbo C additions were by Bill Wilson.
(WILSON@NAUVAX.bitnet)
Some of the labelling improvements and combining of these additions 
were by Russell Lang.
(rjl@monu1.cc.monash.oz.au)
The LaTeX driver, the help system, and some of the labelling
improvements were by David Kotz. 
(David.Kotz@Dartmouth.edu)
And of course, the vast majority of the program is by Colin Kelley
and Thomas Williams.
(info-gnuplot@ames.arc.nasa.gov)

=======================================================================

                      GNUPLOT 1.1 RELEASE NOTES

New terminal drivers: AED 512, BBN BitGraph, HP2623, POSTSCRIPT,
Selanar, Vectrix 384.  The PC version now supports Hercules and ATT
6300 monochrome graphics.  Thanks to those who sent these drivers in.

New commands: 'set dummy' and 'show dummy' to select the dummy
variable name; 'replot' to repeat the last 'plot' command.

The exclamation point (!) is now accepted as postfix factorial
operator.  The gamma() function is also included, if your C library
has gamma().  See GAMMA below.

Logical AND (&&) and OR (||) now short-circuit the way they do in C.
That is, the second && operand is not evaluated if the first is false;
the second || operand is not evaluated if the first is true.  The
ternary operator (?:) also does not evaluate the unused operand.  This
change allows for the definition of recursive functions, e.g. a
synonym for the ! factorial operator:

	fact(x) = (x<=1) ? 1 : x*fact(x-1)

GNUPLOT now has a much better memory allocation scheme, replacing most
fixed-size arrays with malloc()'d linked lists.  There is no longer
any artificial maximum on the number of simultaneous plots, number of
points in those plots, or the number of user-defined functions or
variables.  All these are limited only by the memory available to
malloc().  This is a big improvement for memory-starved machines like
PDP-11s or PCs.

Lines beginning with # (also ! in VMS) are treated as comments.  Only
the $ may now be used for a shell escape in VMS, since ! is a comment.

Several old bugs have been superseded by new ones.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/Intergraph.x11 version [9db54e0c64].

1
2
3
4
5
6
7
8
9
10
#!/bin/sh
mv gnuplot_x11.c gnuplot_x11.c_x
mv corplot.c corplot.c_pc
acc -knr -DSYSV -DUSG -DVFORK -DNOCOPY -DGAMMA=gamma -DGETCWD -DX11 \
-DUNIXPLOT -I/usr/include/X11 -I/usr/include/X11/Xaw *.c \
-lbsd -lplot -lm -o gnuplot.intergraph
mv gnuplot_x11.c_x gnuplot_x11.c
acc -knr -DSYSV -DUSG -DVFORK -DNOCOPY -DGAMMA=gamma -DGETCWD -DX11 \
-DUNIXPLOT -I/usr/include/X11 -I/usr/include/X11/Xaw gnuplot_x11.c \
-lXaw -lXmu -lXt -lXext -lX11 -lbsd -lm -o gnuplot_x11.intergraph
<
<
<
<
<
<
<
<
<
<




















Deleted r34.1/plot/Makefile version [087265c103].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
#
# $Id: makefile.unx,v 3.26 92/03/24 22:36:48 woo Exp Locker: woo $
#
############################################################
#
# GNUPLOT 3.2 Makefile (Unix X11 support) for
#  Apollo/Sun/Dec5000/IBMrs6000/HP9000/SGI/3B1/386IX/Cray
#
# Original version by:
#   oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA)
#   Wed, 3 Jul 91 14:31:37 -0400
#
#>>> Customizing: You must customize part of this makefile for your site.
#>>> Then type 'make' for further instructions.
#>>> Customization instructions look like these lines do (#>>>).
#

TARGET = All # What to make by default

############################################################
#>>> Decide where the binaries and manuals will go. 
# directory where to install executables on 'make install'
DEST=/usr/local/bin
# directory for installing man page on 'make man_install'.
MANDEST=/usr/local/man/manl
# where to install help file gnuplot.gih
HELPDEST=/usr/local/lib/gnuplot.gih
#HELPDEST=docs/gnuplot.gih
# Where to send email about bugs and comments (locally)
EMAIL=bug-gnuplot@ames.arc.nasa.gov

############################################################
#>>> Choose your C compiler and basic compiler flags.
CC     = cc # the C compiler
COPTS  = -O # -O if you trust your compiler's optimizer
LD     =$(CC) $(CFLAGS)	    # default loading command
NPROC  = 2
RCSOLD = 3.25
RCSVER = 3.26
RCSCOM = "gnuplot3.2  release6"

############################################################
#>>> Choose some optional features. 
#>>> At this point there are only two optional features:
# READLINE:
#   If READLINE is defined, then command-line editing is supported.
#   Otherwise, your normal terminal editing is all you get.
#   Some machines will not support this, and they will turn this
#   option off (for example, apollos running SR10.2 or SR10.3 and
#   loaded with BSD4.3 instead of SYS5). Note: problems with 
#   gnuplot prompts have been noted when this feature is selected
#   on IBM RS/6000 AIX, and compile errors are encountered on
#   Sequent Dynix 3 and Convex OS 9.0.
# NOCWDRC:
#   If NOCWDRC is defined, then any .gnuplot in the current directory
#   is not read on startup. This is a security consideration
#   especially for root users ( we recommend you define -DNOCWDRC ).
OPTIONS = -DREADLINE -DNOCWDRC

#>>> Optionally install the lasergnu script.
# Lasergnu is a handy shell script for creating a plot from the
# command line and sending it directly to the printer. It currently
# supports postscript and imagen printers, and probably would need
# tailoring to your site.
# Use lasergnu_install to install lasergnu.
# Use lasergnu_noinstall to not install lasergnu (default).
LASERGNU = lasergnu_install

############################################################
# X11 support
#

#>>> List your X11 libraries
X11LIBS = -lX11

#>>> List where the X11 include directory is found (if other than /usr/include)
X11INCLUDES =

#>>> List additional CFLAGS for X11 compilation
# -DOLD_SELECT if you have an old 4.2 BSD OS (e.g. Sun OS 3.5) and
#   encounter compile error for missing include file <sys/select.h>
X11FLAGS = 

#>>> You shouldn't have to change these, since they are controlled by
#>>> Machine dependent definitions below.
#       Compile option for plot.c and TERMFLAGS, to include X11 support
PLOTXFLAG = -DX11
#       make gnuplot_x11 by default
GNUPLOT_X11 = gnuplot_x11
#       install gnuplot_x11 by default
X11INSTALL = x11_install

############################################################
#>>> Okay, you've changed enough. Now type 'make'.

############################################################
# This is used to pass many of the above definitions to make
# subprocesses. Don't change this.
MY_FLAGS  = CC="$(CC)" 	COPTS="$(COPTS)" DEST="$(DEST)" \
		MANDEST="$(MANDEST)" HELPDEST="$(HELPDEST)" \
		EMAIL="$(EMAIL)" LASERGNU="$(LASERGNU)"

############################################################
# Explanations of CFLAGS definitions.
#  These should not need to be changed by you.
# They are set correctly for each machine below. If your machine
# doesn't fit the one of the patterns, override on the make command
# line or make a new target for it and a new _FLAGS definition. 
#  -DNOVFORK if you're unix and you have don't have vfork()
#  -DMEMSET if you need to use memset() instead of bzero() 
#  -DMEMCPY if your bcopy() is called memcpy()
#  -DNOCOPY if you don't have a memcpy() by any name
#  -DGAMMA=foo if your gamma function is called foo(). Apollos have
#    lgamma(3m). If you don't have gamma(), use -DNOGAMMA.
#    The default is -DGAMMA=gamma.
#  -DGETCWD if your unix uses getcwd() instead of getcd()
#    this is needed by HP-UX and Cray Unicos systems.
#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
#    "every other plot" problem.
#  -DCRIPPLED_SELECT if "select errors" are encountered with X. This
#    option is needed on SVR3 platforms with incomplete support for
#    the BSD select() system call
#  -Dunix is required to explicitly define "unix" for SCO and IBM
#   	   RS/6000 running AIX 3.1 
#  -fswitch if you are compiling on a Sun3 (or even -f68881)
#    (but -fswitch is buggy on some systems, so watch out)

# Defaults in case the user types 'make All' directly
# Should match X11_FLAGS's CFLAGS definition
CFLAGS = $(COPTS) $(OPTIONS)

############################################################
# Terminal (device) support
#
# All devices available to a given machine are compiled in by default.
# This documents the flags available in TERMFLAGS, although TERMFLAGS
# is usually controlled by the machine-dependent definitions below.
# See other terminal defines in term.h.
# Define ULTRIX_KLUDGE if you have the every-other plot problem in Ultrix X11.
#
# -DAPOLLO      Apollo Graphics Primitive Resource (window resize after replot)
# -DGPR         Apollo Graphics Primitive Resource (fixed-size window)
# -DCGI         SCO CGI
# -DIRIS4D      IRIS4D series computer
# -DSUN         Sun Microsystems Workstation
# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
# -DUNIXPLOT    unixplot
# -DX11         X11 Window System (This is $(PLOTXFLAG))
TERMFLAGS = -Iterm -DUNIXPLOT $(PLOTXFLAG) 

############################################################
# Library explanations. 
#  You shouldn't need to adjust this; again, it is handled by the
# machine-dependent definitions below.
#
#  -lplot if you have -DUNIXPLOT in TERMFLAGS
#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
#  -lgl_s if -DIRIS4D in TERMFLAGS
#  -lccgi if -DCGI in TERMFLAGS
LIBS = -lm -lplot

####################################################################
# List of object files except version.o
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 scanner.o \
	   setshow.o standard.o term.o util.o  

NEXTOBJS = EPSView.o EpsViewer.o
############################################################
# Machine-dependent settings.
#
X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

DEC_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) " \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DULTRIX_KLUDGE"

APOLLO_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="-L/usr/lib/X11 -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

HP_FLAGS = \
    	   CFLAGS="+O1 $(OPTIONS) -DMEMSET -DMEMCPY  -DGETCWD" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11R4" \
    	   X11LIBS="-L/usr/lib/X11R4 -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

SUN_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DSUN"

SUN_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DSUN"

SGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
    	   LIBS="-lgl_s -lm" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DIRIS4D"

SGIX11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
    	   LIBS="-lgl_s -lm -lc_s" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="-L/usr/lib/X11 -lX11" \
     	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
     	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11 -DIRIS4D"

CGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix" \
    	   LIBS="-lccgi $(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DCGI"

3B1_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   LD="ld /lib/crt0s.o /lib/shlib.ifile" \
    	   TERMFLAGS="-Iterm -DUNIXPC"

386IX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " \
    	   X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT"
386IX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
    	   X11INSTALL= "$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DX11"
 	
AIX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

NEXT_FLAGS = \
    	   CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT" \
           LIBS="-lNeXT_s -lsys_s -lm" \
    	   X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES=" " X11LIBS=" " PLOTXFLAG=" " \
    	   GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm" OBJS=" $(OBJS) $(NEXTOBJS)"

NEXT_X11_FLAGS = \
    	   CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT" \
           LIBS="-lNeXT_s -lsys_s -lm" \
           X11LIBS="-L/usr/lib/X11 -lX11" \
    	   X11INCLUDES="$(X11INCLUDES)" X11FLAGS="$(X11FLAGS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11" OBJS=" $(OBJS) $(NEXTOBJS)"

CRAY_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
	   LIBS="-lm" X11FLAGS=" " \
	   X11INCLUDES=" " \
	   X11LIBS=" " \
	   PLOTXFLAG=" " GNUPLOT_X11=" " \
	   X11INSTALL=x11_noinstall \
	   TERMFLAGS="-Iterm"

CRAY_X11_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
	   X11INCLUDES="$(X11INCLUDES)" \
	   X11LIBS="$(X11LIBS)" \
	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
	   X11INSTALL=$(X11INSTALL) \
	   TERMFLAGS="-Iterm -DX11"

PTX_X11_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DCRIPPLED_SELECT" \
	   LIBS="-lm -lplot" X11FLAGS="$(X11FLAGS)" \
	   X11INCLUDES="$(X11INCLUDES)" \
	   X11LIBS="-lX11 -lseq -lsocket -linet -lnsl" \
	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
	   X11INSTALL=$(X11INSTALL) \
	   TERMFLAGS="$(TERMFLAGS)"

CONVEX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DHUGE=8.9e307" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

####################################################################
# List of source files
# Used for makeing shar files, lint, and some dependencies.
DIRS = term demo docs docs/latextut

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/amiga.trm 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 \
	term/apollo.trm term/gpr.trm term/ai.trm term/next.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pbm.trm term/pc.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 term/bigfig.trm term/vws.trm gnuplot_x11.c
CSOURCE8 = contour.c
NEXTSRC  = EPSView.m EPSView.h EpsViewer.m EpsViewer.h
# not C code, but still needed

DEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.demo demo/controls.demo \
	demo/electron.demo demo/glass.dat demo/param.demo demo/polar.demo \
	demo/simple.demo demo/surface1.demo demo/surface2.demo demo/using.dat \
	demo/using.demo demo/world.cor demo/world.dat demo/world.demo \
	demo/err.dat demo/poldat.demo demo/polar.dat demo/errorbar.demo \
	demo/antenna.dat demo/all.demo demo/bivariat.demo demo/hidden.demo

ETC = Copyright README README.gnutex README.amiga makefile.unx makefile.vms  \
	linkopt.amg makefile.amg makefile.ami linkopt.vms buildvms.com \
	lasergnu  README.3d README.x11 README.NeXT \
	term/README History gnuplot.el Intergraph.x11 README.Install

#BETA files (not standard distribution files)
BETA = BETA6
# PC-specific files
PC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
	linkopt.msc linkopt.tc linkopt.tco makefile.msc makefile.tc \
	pcgraph.asm 

# Documentation and help files
DOCS1 = docs/Makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entry.sty \
	docs/titlepage.ms docs/titlepage.tex docs/Makefile.ami
DOCS2 = docs/gnuplot.doc
DOCS3 = docs/latextut/Makefile docs/latextut/eg1.plt \
	docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
	docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
	docs/latextut/header.tex docs/latextut/tutorial.tex \
	docs/latextut/linepoint.plt

#########################################################################
# Default target (informational)
info:
	@echo "Please do a 'make <MACHINE>' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo       for Apollo running SR10.3 with Apollo's X11"
	@echo "dec          for Dec3100/5000 running Ultrix 3.1d with MIT's X11"
	@echo "hp           for HP/9000 700 series running HP/UX 8.0 with MIT's X11R4"
	@echo "sun          for Sun sparcstation running SunOS 4.1 with suntools (no X11) "
	@echo "sun_x11      for Sun sparcstation running SunOS 4.1 with suntools and X11 "
	@echo "sgi          for Silicon Graphics IRIS4D machines (no X11) "
	@echo "sgix11       for Silicon Graphics IRIS4D machines (X11) "
	@echo "next         for NeXT Cube and Slab running NeXTOS 2.0+ (no X11)"
	@echo "next_11      for NeXT Cube and Slab running NeXTOS 2.0+ with X11"
	@echo "3b1          for ATT 3b1 machines (no X11) "
	@echo "386ix        for 386 machines running 386/ix (no X11)"
	@echo "386ix_x11    for 386 machines running 386/ix with T.Roell X386"
	@echo "ibmrs6000    for IBM RS/6000 running Aix 3.1 with IBM's X11"
	@echo "x11          for a generic machine (like a sun or dec) with MIT's X11"
	@echo "cray         for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 (no X11)"
	@echo "cray_x11     for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 with X11"
	@echo "ptx_x11      for Sequent Dynix/PTX with MIT X11"
	@echo "convex_x11   for Convex 9.0 with MIT X11"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11"
	@echo "         make apollo"
	@echo "         make apollo       OPTIONS='-DNOCWDRC' "
	@echo "         make apollo       DEST='/usr/um/misc/bin' "
	@echo "         make dec"
	@echo "         make hp"
	@echo "         make next"
	@echo "         make sun          HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make sun          X11INCLUDES='-I/usr/local/include' "
	@echo "         make sun_x11"
	@echo "         make sgi"
	@echo "         make 3b1"
	@echo "         make 386ix"
	@echo "         make ibmrs6000    MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo "         make cray"
	@echo "         make cray_x11"
	@echo 
	@echo "If you just type 'make All' , it will build gnuplot for Unix X11"
	@echo "and the following variables will be used as default:"
	@echo 
	@echo " DEST                     " $(DEST)
	@echo " MANDEST                  " $(MANDEST)
	@echo " HELPDEST                 " $(HELPDEST)
	@echo " EMAIL                    " $(EMAIL)
	@echo " CC                       " $(CC)
	@echo " COPTS                    " $(COPTS)
	@echo " OPTIONS                  " $(OPTIONS)
	@echo " CFLAGS                   " $(CFLAGS)
	@echo " LIBS                     " $(LIBS)
	@echo " X11FLAGS                 " $(X11FLAGS)
	@echo " X11LIBS                  " $(X11LIBS)
	@echo " X11INCLUDES              " $(X11INCLUDES)
	@echo " TERMFLAGS                " $(TERMFLAGS)
	@echo " LASERGNU                 " $(LASERGNU)
	@echo 
	@echo "If you are not familiar with makefiles or just want to know what"
	@echo " 'make <MACHINE>' would  do without actually doing anything, then type"
	@echo " 'make <MACHINE> -n' "
	@echo 

###############################################################
# Targets for each machine

x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11_FLAGS)    $(TARGET)

dec:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_FLAGS)      $(TARGET)

apollo:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_FLAGS)   $(TARGET)

hp:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(HP_FLAGS)       $(TARGET)

next:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_FLAGS)     $(TARGET)

next_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_X11_FLAGS)     $(TARGET)

sun:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_FLAGS)      $(TARGET)

sun_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_X11_FLAGS)  $(TARGET)

sgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGI_FLAGS)      $(TARGET)

sgix11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGIX11_FLAGS)   $(TARGET)

cgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CGI_FLAGS)      $(TARGET)

3b1:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(3B1_FLAGS)      $(TARGET)

386ix:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_FLAGS)    $(TARGET)

386ix_x11: 
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_X11_FLAGS) $(TARGET)

ibmrs6000:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_FLAGS)      $(TARGET)

cray:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_FLAGS)     $(TARGET)
cray_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_X11_FLAGS) $(TARGET)
ptx_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(PTX_X11_FLAGS) $(TARGET)
convex_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CONVEX_X11_FLAGS) $(TARGET)

#############################################################
# Targets that really do something

all:
	@echo "Please just type  'make'  in order to get some information on "
	@echo "how to build gnuplot under Unix and the X Window System."

All:	gnuplot $(GNUPLOT_X11) doc

gnuplot: $(OBJS) version.o
	$(LD) $(OBJS) version.o $(LIBS) -o gnuplot

doc:
	( cd docs; $(MAKE) $(MFLAGS) gnuplot.gih )

gnuplot_x11: gnuplot_x11.c
	$(CC) $(CFLAGS) $(X11FLAGS) $(X11INCLUDES) -o gnuplot_x11 gnuplot_x11.c $(X11LIBS)

################################################################
# Installation instructions

install:
	@echo 
	@echo "Please do a 'make <MACHINE> TARGET=Install' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, dec, hp, sun, sun_x11, sgi, sgix11, cgi,"
	@echo "next, next_x11, 3b1, 386ix, 386ix_x11, ibmrs6000,"
	@echo "x11, cray, cray_x11, ptx_x11, convex_x11"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11          TARGET=Install "
	@echo "         make apollo       TARGET=Install "
	@echo "         make dec          TARGET=Install "
	@echo "         make hp           TARGET=Install "
	@echo "         make sun          TARGET=Install HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make ibmrs6000    TARGET=Install MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo 
################################################################
# Installation targets

Install: All man_install $(X11INSTALL) $(LASERGNU)
	cp gnuplot     $(DEST)
	strip $(DEST)/gnuplot
	( cd docs; $(MAKE) $(MFLAGS) install-unix HELPDEST=$(HELPDEST) )

x11_install: gnuplot_x11
	cp gnuplot_x11 $(DEST)
	strip $(DEST)/gnuplot_x11

x11_noinstall: 
	@echo "X11 not requested, so gnuplot_x11 program not installed"

man_install: docs/gnuplot.1
	cp docs/gnuplot.1 $(MANDEST)

lasergnu_install: lasergnu docs/lasergnu.1
	cp lasergnu $(DEST)
	chmod 755 $(DEST)/lasergnu
	cp docs/lasergnu.1 $(MANDEST)

lasergnu_noinstall:
	@echo 
	@echo "Lasergnu will not be installed by default."
	@echo "If you think you need the lasergnu script to print"
	@echo " files on the imagen or postscript printers, then"
	@echo " type"
	@echo "      'make <MACHINE> TARGET=Install LASERGNU='lasergnu_install' "
	@echo
	@echo "Lasergnu is really not needed since within gnuplot you can"
	@echo " can create files (in impress or postscript language) and"
	@echo " print them through your favorite print command (lpr, lp, prf, ipr)."
	@echo 

################################################################
# Dependencies

plot.o: plot.c
	$(CC) $(CFLAGS) $(PLOTXFLAG) -c plot.c

term.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) -c term.c

version.o:
	$(CC) $(CFLAGS) -DCONTACT=\"$(EMAIL)\" -c version.c

EpsViewer.o : EpsViewer.h EpsViewer.m EPSView.h
	$(CC) -c EpsViewer.m

EPSView.o : EPSView.h EPSView.m
		$(CC) -c EPSView.m  

$(OBJS): plot.h

command.o: command.c
	$(CC) $(CFLAGS) -c command.c -DHELPFILE=\"$(HELPDEST)\"

command.o help.o misc.o: help.h

command.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h

bitmap.o term.o: bitmap.h

################################################################
# Miscellaneous targets

SOURCES=plot.h help.h setshow.h bitmap.h term.h $(CSOURCE1) $(CSOURCE2) \
	$(CSOURCE3) $(CSOURCE4) $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)\
	 $(CSOURCE8) $(NEXTSRC)

DOCS  = $(DOCS1) $(DOCS2) $(DOCS3)

lint:
	lint -hx $(SOURCES)

clean:
	rm -f *.o *~ *.bak term/*~ term/*.bak
	( cd docs; $(MAKE) $(MFLAGS) clean )
	( cd docs/latextut; $(MAKE) $(MFLAGS) clean )

spotless:
	rm -f *.o *~ *.bak term/*~ term/*.bak TAGS gnuplot gnuplot_x11
	( cd docs; $(MAKE) $(MFLAGS) clean )
	( cd docs/latextut; $(MAKE) $(MFLAGS) spotless )

################################################################
# Making shar files for mailing gnuplot

shar: gnuplot.sh00 gnuplot.sh01 gnuplot.sh02 gnuplot.sh03 gnuplot.sh04 \
	gnuplot.sh05 gnuplot.sh06 gnuplot.sh07 gnuplot.sh08 \
	gnuplot.sh09 gnuplot.sh10 gnuplot.sh11 gnuplot.sh12 \
	gnuplot.sh13 gnuplot.sh14 gnuplot.sh15 

gnuplot.sh00:
	echo '#!/bin/sh' > gnuplot.sh00
	echo '# This is a shell file to make directories' >> gnuplot.sh00
	echo mkdir $(DIRS) >> gnuplot.sh00

gnuplot.sh01: $(ETC)
	shar $(ETC) > gnuplot.sh01

gnuplot.sh02: $(DOCS1)
	shar $(DOCS1) > gnuplot.sh02

gnuplot.sh03: $(DOCS2)
	shar $(DOCS2) > gnuplot.sh03

gnuplot.sh04: $(DOCS3)
	shar $(DOCS3) > gnuplot.sh04

gnuplot.sh05: $(CSOURCE1)
	shar $(CSOURCE1) > gnuplot.sh05

gnuplot.sh06: $(CSOURCE2)
	shar $(CSOURCE2) > gnuplot.sh06

gnuplot.sh07: $(CSOURCE3)
	shar $(CSOURCE3) > gnuplot.sh07

gnuplot.sh08: $(CSOURCE4)
	shar $(CSOURCE4) > gnuplot.sh08

gnuplot.sh09: $(CSOURCE5)
	shar $(CSOURCE5) > gnuplot.sh09

gnuplot.sh10: $(CSOURCE6)
	shar $(CSOURCE6) > gnuplot.sh10

gnuplot.sh11: $(CSOURCE7)
	shar $(CSOURCE7) > gnuplot.sh11

gnuplot.sh12: $(PC)
	shar $(PC) > gnuplot.sh12

gnuplot.sh13: $(CSOURCE8)
	shar $(CSOURCE8) > gnuplot.sh13

gnuplot.sh14: $(DEMOS)
	shar $(DEMOS) > gnuplot.sh14

gnuplot.sh15: $(BETA)
	shar $(BETA) > gnuplot.sh15

tar: $(ETC) $(SOURCES) $(PC) $(DEMOS) $(BETA) $(DOCS)
	$(TAR) cvf /tmp/gnuplot.tar $(ETC) $(SOURCES) $(PC)\
		 $(DEMOS) $(BETA) $(DOCS)
rcsdoc:
	rcs -o-$(RCSOLD) -l$(RCSVER) $(DOCS)

rcs:
	rcs -l$(RCSVER) -c$(RCSCOM) $(ETC) $(SOURCES) $(PC)

ci:
	ci -l$(RCSVER) -m$(RCSCOM) $(SOURCES) $(PC) $(ETC)

cidoc:
	ci -l$(RCSVER) -m$(RCSCOM) $(DOCS)

cidemo:
	ci -l$(RCSVER) -m$(RCSCOM) $(DEMOS)

co:
	co -l -r$(RCSVER) $(ETC) $(SOURCES) $(PC)

codoc:
	co -l -r$(RCSVER) $(DOCS)

codemo:
	co -l -r$(RCSVER) $(DEMOS)

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/Makefile.save version [746aec69eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
############################################################
#
# GNUPLOT 3.0 Makefile (Unix X11 Motif/Athena support) for
#  Apollo/Sun/Dec5000/IBMrs6000/HP9000/SGI/3B1/386IX
#
# Original version by:
#   oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA)
#   Wed, 3 Jul 91 14:31:37 -0400
#
#>>> Customizing: You must customize part of this makefile for your site.
#>>> Then type 'make' for further instructions.
#>>> Customization instructions look like these lines do (#>>>).
#

TARGET = All # What to make by default

############################################################
#>>> Decide where the binaries and manuals will go. 
# directory where to install executables on 'make install'
DEST=/usr/local/bin
# directory for installing man page on 'make man_install'.
MANDEST=/usr/man/manl
# where to install help file gnuplot.gih
HELPDEST=~/gnuplot
#HELPDEST=docs/gnuplot.gih
# Where to send email about bugs and comments (locally)
EMAIL=hugo

############################################################
#>>> Choose your C compiler and basic compiler flags.
CC     = cc # the C compiler
COPTS  = -O # -O if you trust your compiler's optimizer
LD     =$(CC) $(CFLAGS)	    # default loading command

############################################################
#>>> Choose some optional features. 
#>>> At this point there are only two optional features:
# READLINE:
#   If READLINE is defined, then command-line editing is supported.
#   Otherwise, your normal terminal editing is all you get.
#   Some machines will not support this, and they will turn this
#   option off (for example, apollos running SR10.2 or SR10.3 and
#   loaded with BSD4.3 instead of SYS5). 
# NOCWDRC:
#   If NOCWDRC is defined, then any .gnuplot in the current directory
#   is not read on startup. This is a security consideration
#   especially for root users ( we recommend you define -DNOCWDRC ).
OPTIONS = -DREADLINE -DNOCWDRC

#>>> Optionally install the lasergnu script.
# Lasergnu is a handy shell script for creating a plot from the
# command line and sending it directly to the printer. It currently
# supports postscript and imagen printers, and probably would need
# tailoring to your site.
# Use lasergnu_install to install lasergnu.
# Use lasergnu_noinstall to not install lasergnu (default).
LASERGNU = lasergnu_noinstall

############################################################
# X11 support
#

#>>> List your X11 libraries#
# standard MIT X11 R4:                      -lXaw -lXmu -lXt -lXext -lX11
# Apollo DomainOS 10.3 (R3/Athena):         -L/usr/lib/X11 -lXaw -lXmu -lXt -lX11
# Apollo DomainOS 10.3 (R3/Motif):          -L/usr/lib/X11 -lXm -lXtm -lX11
# IBM RS/6000 AIX 3.1 (R3/Athena):          -L/usr/lpp/X11/Xamples/lib/Xmu \
#                                           -L/usr/lpp/X11/Xamples/lib/Xaw \
#                                           -lXaw -lXmu -lXt -lXext -lX11
# IBM RS/6000 AIX 3.1 (R3/Motif):           -lXm -lXt -lX11
# HP 9000/375 HP-UX 6.5 and 7.0 (R3/Motif): -lXm -lXt -lX11
# Interactive 386/ix with T.Roell X386 and network support:
#                                           -lXaw -lXm -lXt -lXext -lX11 -linet -lpt
X11LIBS = -lXaw -lXmu -lXt -lXext -lX11

#>>> List your X11 include directories
# standard MIT X11 R4: -I/usr/include/X11   -I/usr/include/X11/Xaw 
# Apollo DomainOS 10.3 (R3/Athena):         -I/usr/include/X11
# Apollo DomainOS 10.3 (R3/Motif):          -I/usr/include/Xm
# IBM RS/6000 AIX 3.1 (R3/Athena):          -I/usr/include/X11 \
#                                           -I/usr/lpp/X11/Xamples/lib/Xaw \
#                                           -I/usr/lpp/X11/Xamples/lib/Xaw/X11
# IBM RS/6000 AIX 3.1 (R3/Motif):           -I/usr/include/Xm
# HP 9000/375 HP-UX 6.5 and 7.0 (R3/Motif): -I/usr/include/Xm
# HP 9000/700 HP-UX 8.0 (R4):               -I/usr/include/X11R4 \
#                                           -I/usr/include/X11R4/X11/Xaw
X11INCLUDES = -I/usr/include/X11 -I/usr/include/X11/Xaw -I/zib/include_sun4/X11 -I/zib/include_sun4/X11/Xaw -I/zib/include_sun4

#>>> You shouldn't have to change these, since they are controlled by
#>>> Machine dependent definitions below.
#       Compile option for plot.c and TERMFLAGS, to include X11 support
PLOTXFLAG = -DX11
#   	   this can add to CFLAGS for X11 compilations. Probably needs no change.
X11FLAGS = 
#       make gnuplot_x11 by default
GNUPLOT_X11 = gnuplot_x11
#       install gnuplot_x11 by default
X11INSTALL = x11_install

############################################################
#>>> Okay, you've changed enough. Now type 'make'.

############################################################
# This is used to pass many of the above definitions to make
# subprocesses. Don't change this.
MY_FLAGS  = CC="$(CC)" 	COPTS="$(COPTS)" DEST="$(DEST)" \
		MANDEST="$(MANDEST)" HELPDEST="$(HELPDEST)" \
		EMAIL="$(EMAIL)" LASERGNU="$(LASERGNU)"

############################################################
# Explanations of CFLAGS definitions.
#  These should not need to be changed by you.
# They are set correctly for each machine below. If your machine
# doesn't fit the one of the patterns, override on the make command
# line or make a new target for it and a new _FLAGS definition. 
#  -DNOVFORK if you're unix and you have don't have vfork()
#  -DMEMSET if you need to use memset() instead of bzero() 
#  -DMEMCPY if your bcopy() is called memcpy()
#  -DNOCOPY if you don't have a memcpy() by any name
#  -DGAMMA=foo if your gamma function is called foo(). Apollos have
#    lgamma(3m). If you don't have gamma(), use -DNOGAMMA.
#    The default is -DGAMMA=gamma.
#  -DGETCWD if your unix uses getcwd() instead of getcd()
#    this is needed by HP-UX and Cray Unicos systems.
#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
#    "every other plot" problem.
#  -Dunix is required to explicitly define "unix" for SCO and IBM
#   	   RS/6000 running AIX 3.1 
#  -fswitch if you are compiling on a Sun3 (or even -f68881)
#    (but -fswitch is buggy on some systems, so watch out)

# Defaults in case the user types 'make All' directly
# Should match X11R4_FLAGS's CFLAGS definition
CFLAGS = $(COPTS) $(OPTIONS)

############################################################
# Terminal (device) support
#
# All devices available to a given machine are compiled in by default.
# This documents the flags available in TERMFLAGS, although TERMFLAGS
# is usually controlled by the machine-dependent definitions below.
# See other terminal defines in term.h.
# Define ULTRIX_KLUDGE if you have the every-other plot problem in Ultrix X11.
#
# -DAPOLLO      Apollo Graphics Primitive Resource (window resize after replot)
# -DGPR         Apollo Graphics Primitive Resource (fixed-size window)
# -DCGI         SCO CGI
# -DIRIS4D      IRIS4D series computer
# -DSUN         Sun Microsystems Workstation
# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
# -DUNIXPLOT    unixplot
# -DX11         X11 Window System (This is $(PLOTXFLAG))
TERMFLAGS = -Iterm -DUNIXPLOT $(PLOTXFLAG)

############################################################
# Library explanations. 
#  You shouldn't need to adjust this; again, it is handled by the
# machine-dependent definitions below.
#
#  -lplot if you have -DUNIXPLOT in TERMFLAGS
#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
#  -lgl_s if -DIRIS4D in TERMFLAGS
#  -lccgi if -DCGI in TERMFLAGS
LIBS = -lm -lplot

############################################################
# Machine-dependent settings.
#
X11R4_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

X11R4_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF -D_NO_PROTO" \
    	   X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

DEC_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) " \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DULTRIX_KLUDGE"

DEC_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF -D_NO_PROTO" \
    	   X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)  -DULTRIX_KLUDGE"

APOLLO_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11" \
    	   X11LIBS="-L/usr/lib/X11 -lXaw -lXmu -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

APOLLO_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF" X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-L/usr/lib/X11 -lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

HP_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DMEMSET -DMEMCPY  -DGETCWD" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11R4 -I/usr/include/X11R4/X11/Xaw \
	   -I/usr/include/X11 -I/usr/include/X11/Xaw -I/zib/include_sun4/X11 \
           -I/zib/include_sun4/X11/Xaw -I/zib/include_sun4" \
    	   X11LIBS="-L/usr/lib/X11R4 -lXaw -lXmu -lXt -lXext -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

SUN_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DSUN"

SUN_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DSUN"

SGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lgl_s -lm" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DIRIS4D"

SGIX11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11 -I/usr/include/X11/Xaw" \
    	   X11LIBS="-L/usr/lib/X11 -lXaw -lXmu -lXt -lXext -lX11" \
     	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
     	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

CGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix" \
    	   LIBS="-lccgi $(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DCGI"

3B1_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   LD="ld /lib/crt0s.o /lib/shlib.ifile" \
    	   TERMFLAGS="-Iterm -DUNIXPC"

386IX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " \
    	   X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT"
386IX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
    	   X11INSTALL= "$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DX11"
 	
AIX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11 -I/usr/lpp/X11/Xamples/lib/Xaw -I/usr/lpp/X11/Xamples/lib/Xaw/X11" \
    	   X11LIBS="-L/usr/lpp/X11/Xamples/lib/Xmu -L/usr/lpp/X11/Xamples/lib/Xaw -lXaw -lXmu -lXt -lXext -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

AIX_M_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="-DMOTIF" X11INCLUDES="-I/usr/include/Xm" \
    	   X11LIBS="-lXm -lXt -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

NEXT_FLAGS = \
    	   CFLAGS="$(COPTS) -DNOCWDRC -DGAMMA=lgamma -DNEXT" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES=" " X11LIBS=" " PLOTXFLAG=" " \
    	   GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm"

####################################################################
# List of object files except version.o
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 scanner.o \
	   setshow.o standard.o term.o util.o  
####################################################################
# List of source files
# Used for makeing shar files, lint, and some dependencies.
DIRS = term demo docs docs/latextut

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/amiga.trm 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 \
	term/apollo.trm term/gpr.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pc.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 term/bigfig.trm term/vws.trm gnuplot_x11.c
CSOURCE8 = contour.c
# not C code, but still needed

DEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.demo demo/controls.demo \
	demo/electron.demo demo/glass.dat demo/param.demo demo/polar.demo \
	demo/simple.demo demo/surface1.demo demo/surface2.demo demo/using.dat \
	demo/using.demo demo/world.cor demo/world.dat demo/world.demo \
	demo/err.dat demo/poldat.demo demo/polar.dat demo/errorbar.demo \
	demo/antenna.dat demo/all.demo demo/bivariat.demo

ETC = Copyright README README.gnutex README.amiga makefile.unx makefile.vms  \
	linkopt.amg makefile.amg makefile.ami linkopt.vms buildvms.com \
	plot.h help.h setshow.h bitmap.h term.h lasergnu \
	term/README History gnuplot.el Intergraph.x11 README.Install

#BETA files (not standard distribution files)
BETA = BETA10
# PC-specific files
PC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
	linkopt.msc linkopt.tc linkopt.tco makefile.msc makefile.tc \
	pcgraph.asm 

# Documentation and help files
DOCS1 = docs/Makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entry.sty \
	docs/titlepage.ms docs/titlepage.tex docs/Makefile.ami
DOCS2 = docs/gnuplot.doc
DOCS3 = docs/latextut/Makefile docs/latextut/eg1.plt \
	docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
	docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
	docs/latextut/header.tex docs/latextut/tutorial.tex \
	docs/latextut/linepoint.plt

#########################################################################
# Default target (informational)
info:
	@echo "Please do a 'make <MACHINE>' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, apollo_motif       for Apollo running SR10.3 with Apollo's X11R3"
	@echo "dec, dec_motif             for Dec3100/5000 running Ultrix 3.1d with MIT's X11R4"
	@echo "hp                         for HP/9000 700 series running HP/UX 8.0 with MIT's X11R4"
	@echo "sun                        for Sun sparcstation running SunOS 4.1 with suntools (no X11R4) "
	@echo "sun_x11                    for Sun sparcstation running SunOS 4.1 with suntools and X11R4 "
	@echo "sgi                        for Silicon Graphics IRIS4D machines (no X11R4) "
	@echo "sgix11                     for Silicon Graphics IRIS4D machines (X11R4) "
	@echo "next                       for NeXT Cube and Slab running NeXTOS 2.0+ (no X11R4) "
	@echo "3b1                        for ATT 3b1 machines (no X11R4) "
	@echo "386ix                      for 386 machines running 386/ix (no X11)"
	@echo "386ix_x11                  for 386 machines running 386/ix with T.Roell X386"
	@echo "ibmrs6000, ibmrs6000_motif for IBM RS/6000 running Aix 3.1 with IBM's X11R3"
	@echo "x11r4, x11r4_motif         for a generic machine (like a sun or dec) with MIT's X11R4"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11r4"
	@echo "         make x11r4_motif"
	@echo "         make apollo"
	@echo "         make apollo       OPTIONS='-DNOCWDRC' "
	@echo "         make apollo_motif DEST='/usr/um/misc/bin' "
	@echo "         make dec"
	@echo "         make hp"
	@echo "         make next"
	@echo "         make sun          HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make sun          X11INCLUDES='-I/usr/local/include -I/usr/local/include/X11 -I/usr/local/include/X11/Xaw' "
	@echo "         make sun_x11"
	@echo "         make sgi"
	@echo "         make 3b1"
	@echo "         make 386ix"
	@echo "         make ibmrs6000    MANDEST='/usr/usr/misc/man/man1' COPTS='-O' "
	@echo 
	@echo "If you just type 'make All' , it will build gnuplot for Unix X11R4/Athena"
	@echo "and the following variables will be used as default:"
	@echo 
	@echo " DEST                     " $(DEST)
	@echo " MANDEST                  " $(MANDEST)
	@echo " HELPDEST                 " $(HELPDEST)
	@echo " EMAIL                    " $(EMAIL)
	@echo " CC                       " $(CC)
	@echo " COPTS                    " $(COPTS)
	@echo " OPTIONS                  " $(OPTIONS)
	@echo " CFLAGS                   " $(CFLAGS)
	@echo " LIBS                     " $(LIBS)
	@echo " X11FLAGS                 " $(X11FLAGS)
	@echo " X11LIBS                  " $(X11LIBS)
	@echo " X11INCLUDES              " $(X11INCLUDES)
	@echo " TERMFLAGS                " $(TERMFLAGS)
	@echo " LASERGNU                 " $(LASERGNU)
	@echo 
	@echo "If you are not familiar with makefiles or just want to know what"
	@echo " 'make <MACHINE>' would  do without actually doing anything, then type"
	@echo " 'make <MACHINE> -n' "
	@echo 

###############################################################
# Targets for each machine

x11r4:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11R4_FLAGS)    $(TARGET)

x11r4_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11R4_M_FLAGS)  $(TARGET)

dec:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_FLAGS)      $(TARGET)

dec_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_M_FLAGS)    $(TARGET)

apollo:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_FLAGS)   $(TARGET)

apollo_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_M_FLAGS) $(TARGET)

hp:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(HP_FLAGS)       $(TARGET)

next:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_FLAGS)     $(TARGET)

sun:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_FLAGS)      $(TARGET)

sun_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_X11_FLAGS)  $(TARGET)

sgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGI_FLAGS)      $(TARGET)

sgix11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGIX11_FLAGS)   $(TARGET)

cgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CGI_FLAGS)      $(TARGET)

3b1:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(3B1_FLAGS)      $(TARGET)

386ix:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_FLAGS)    $(TARGET)

386ix_x11: 
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_X11_FLAGS) $(TARGET)

ibmrs6000:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_FLAGS)      $(TARGET)

ibmrs6000_motif:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_M_FLAGS)    $(TARGET)

#############################################################
# Targets that really do something

all:
	@echo "Please just type  'make'  in order to get some information on "
	@echo "how to build gnuplot under Unix and the X Window System."

All:	gnuplot $(GNUPLOT_X11) doc

gnuplot: $(OBJS) version.o
	$(LD) $(OBJS) version.o $(LIBS) -o gnuplot

doc:
	( cd docs; make $(MFLAGS) gnuplot.gih )

gnuplot_x11: gnuplot_x11.c
	$(CC) $(CFLAGS) $(X11FLAGS) $(X11INCLUDES) -o gnuplot_x11 gnuplot_x11.c $(X11LIBS)

################################################################
# Installation instructions

install:
	@echo 
	@echo "Please do a 'make <MACHINE> TARGET=Install' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, apollo_motif, dec, dec_motif, hp, sun, sun_x11, sgi, sgix11"
	@echo "next, 3b1, 386ix, ibmrs6000, ibmrs6000_motif, x11r4, x11r4_motif"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11r4        TARGET=Install "
	@echo "         make apollo       TARGET=Install "
	@echo "         make apollo_motif TARGET=Install DEST='/usr/um/misc/bin' "
	@echo "         make dec          TARGET=Install "
	@echo "         make hp           TARGET=Install "
	@echo "         make sun          TARGET=Install HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make ibmrs6000    TARGET=Install MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo 
################################################################
# Installation targets

Install: All man_install $(X11INSTALL) $(LASERGNU)
	cp gnuplot     $(DEST)
	strip $(DEST)/gnuplot
	(cd docs; make $(MFLAGS) install-unix HELPDEST=$(HELPDEST))

x11_install: gnuplot_x11
	cp gnuplot_x11 $(DEST)
	strip $(DEST)/gnuplot_x11

x11_noinstall: 
	@echo "X11 not requested, so gnuplot_x11 program not installed"

man_install: docs/gnuplot.1
	cp docs/gnuplot.1 $(MANDEST)

lasergnu_install: lasergnu docs/lasergnu.1
	cp lasergnu $(DEST)
	chmod 755 $(DEST)/lasergnu
	cp docs/lasergnu.1 $(MANDEST)

lasergnu_noinstall:
	@echo 
	@echo "Lasergnu will not be installed by default."
	@echo "If you think you need the lasergnu script to print"
	@echo " files on the imagen or postscript printers, then"
	@echo " type"
	@echo "      'make <MACHINE> TARGET=Install LASERGNU='lasergnu_install' "
	@echo
	@echo "Lasergnu is really not needed since within gnuplot you can"
	@echo " can create files (in impress or postscript language) and"
	@echo " print them through your favorite print command (lpr, lp, prf, ipr)."
	@echo 

################################################################
# Dependencies

plot.o: plot.c
	$(CC) $(CFLAGS) $(PLOTXFLAG) -c plot.c

term.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) -c term.c

version.o:
	$(CC) $(CFLAGS) -DCONTACT=\"$(EMAIL)\" -c version.c

$(OBJS): plot.h

command.o:
	$(CC) $(CFLAGS) -c command.c -DHELPFILE=\"$(HELPDEST)\"

command.o help.o misc.o: help.h

command.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h

bitmap.o term.o: bitmap.h

################################################################
# Miscellaneous targets

SOURCES=plot.h help.h setshow.h bitmap.h term.h $(CSOURCE1) $(CSOURCE2) \
	$(CSOURCE3) $(CSOURCE4) $(CSOURCE5) $(CSOURCE6) $(CSOURCE7) $(CSOURCE8)

lint:
	lint -hx $(SOURCES)

clean:
	rm -f *.o *~ *.bak term/*~ term/*.bak
	(cd docs; make $(MFLAGS) clean)
	(cd docs/latextut; make $(MFLAGS) clean)

spotless:
	rm -f *.o *~ *.bak term/*~ term/*.bak TAGS gnuplot gnuplot_x11
	(cd docs; make $(MFLAGS) clean)
	(cd docs/latextut; make $(MFLAGS) spotless)

################################################################
# Making shar files for mailing gnuplot

shar: gnuplot.sh00 gnuplot.sh01 gnuplot.sh02 gnuplot.sh03 gnuplot.sh04 \
	gnuplot.sh05 gnuplot.sh06 gnuplot.sh07 gnuplot.sh08 \
	gnuplot.sh09 gnuplot.sh10 gnuplot.sh11 gnuplot.sh12 \
	gnuplot.sh13 gnuplot.sh14 gnuplot.sh15 

gnuplot.sh00:
	echo '#!/bin/sh' > gnuplot.sh00
	echo '# This is a shell file to make directories' >> gnuplot.sh00
	echo mkdir $(DIRS) >> gnuplot.sh00

gnuplot.sh01: $(ETC)
	shar $(ETC) > gnuplot.sh01

gnuplot.sh02: $(DOCS1)
	shar $(DOCS1) > gnuplot.sh02

gnuplot.sh03: $(DOCS2)
	shar $(DOCS2) > gnuplot.sh03

gnuplot.sh04: $(DOCS3)
	shar $(DOCS3) > gnuplot.sh04

gnuplot.sh05: $(CSOURCE1)
	shar $(CSOURCE1) > gnuplot.sh05

gnuplot.sh06: $(CSOURCE2)
	shar $(CSOURCE2) > gnuplot.sh06

gnuplot.sh07: $(CSOURCE3)
	shar $(CSOURCE3) > gnuplot.sh07

gnuplot.sh08: $(CSOURCE4)
	shar $(CSOURCE4) > gnuplot.sh08

gnuplot.sh09: $(CSOURCE5)
	shar $(CSOURCE5) > gnuplot.sh09

gnuplot.sh10: $(CSOURCE6)
	shar $(CSOURCE6) > gnuplot.sh10

gnuplot.sh11: $(CSOURCE7)
	shar $(CSOURCE7) > gnuplot.sh11

gnuplot.sh12: $(PC)
	shar $(PC) > gnuplot.sh12

gnuplot.sh13: $(CSOURCE8)
	shar $(CSOURCE8) > gnuplot.sh13

gnuplot.sh14: $(DEMOS)
	shar $(DEMOS) > gnuplot.sh14

gnuplot.sh15: $(BETA)
	shar $(BETA) > gnuplot.sh15

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/README version [01b1f1dfc8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

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 a line, separated by semicolons (;).
Strings are indicated with quotes.  They may be either single or double
quotation marks, e.g.,

         load "filename"
         cd 'dir'

Any command-line arguments are assumed to be names of files containing
GNUPLOT commands, with the exception of standard X11 arguments, which
are processed first. Each file is loaded with the `load` command, in the
order specified. GNUPLOT exits after the last file is processed.  When
no load files are named, gnuplot enters into an interactive mode.

Commands may extend over several input lines, by ending each
line but the last with a backslash (\). The backslash must be the LAST
character on each line. The effect is as if the backslash and newline
were not there. That is, no white space is implied, nor is a comment
terminated. Therefore, commenting out a continued line comments out
the entire command (see `comment`).

For help on any topic, type `help` followed by the name of the topic.

The new GNUPLOT user should begin by reading about the `plot`
command (type `help plot`).  The manual for gnuplot can be printed
either with TeX, troff or nroff.  Look at the docs/Makefile for
the appropriate option.

                   Where to get updates to GNUPLOT

Congratulations on getting this version of GNUPLOT! Unfortunately, it
may not be the most recent version ("you never know where this version
has been!"). You can be sure that it IS the most recent version by
checking one of the official distribution sites, guaranteed to be kept
up to date (of course, if you got this file from one of those sites,
you don't need to check!).

To hear automatically about future releases (and other GNUPLOT news),
join the mailing list; see below.

At the time of this writing, the following are the official
distribution sites and transfer instructions. Note that
prep.ai.mit.edu is NOT an official site, and may not be up to date.
Also, comp.sources.misc is usually a month or so behind us.

Date: Sun Mar 1 20:45:52 EDT 1992
Version: 3.2

In general, GNUPLOT 3.2 is available as the file gnuplot3.2.tar.Z.
There are patches which bring GNUPLOT 3.0 up to 3.1 and patches
which bring GNUPLOT 3.1 up to GNUPLOT 3.2.  The latter are in
the file gnuplot3.2.shar.Z.
There are no patches that bring GNUPLOT 2.02 up to 3.0, so you must
obtain the whole new release. 
Please obtain gnuplot from the site
nearest you.

USENET users:

    GNUPLOT 3.2 was posted to comp.sources.misc.


NORTH AMERICA:

     Anonymous ftp to dartmouth.edu (129.170.16.4)
     Fetch
        pub/gnuplot/gnuplot3.2.tar.Z
     in binary mode.

     Users without ftp capability can obtain it through a mail ftp
     server. Send a mail message saying 'help' to
     BITFTP@pucc.princeton.edu for instructions. For a uuencoded
     copy of the gnuplot sources (compressed tar file), send this
     message to BITFTP@pucc.princeton.edu:
         FTP DARTMOUTH.EDU UUENCODE
         USER ANONYMOUS
         CD pub/gnuplot
         BINARY
         GET gnuplot3.2.tar.Z
         QUIT


AUSTRALIA:

     Anonymous ftp to monu1.cc.monash.edu.au (130.194.1.101).
     Fetch pub/gnuplot3.2.tar.Z in binary mode.


EUROPE:

     Anonymous ftp to irisa.irisa.fr (131.254.2.3).
     Fetch pub/gnuplot3.2.tar.Z in binary mode.

----

     DISCLAIMER - This product is not related in any way to
     Pixar or any other commercial venture.

----
  CONTACTS:
     Please send any questions or comments to
        info-gnuplot@ames.arc.nasa.gov.
     To join the above mailing list (or get yourself off), mail to
        info-gnuplot-request@ames.arc.nasa.gov.
     Send bug reports and problems to
        bug-gnuplot@ames.arc.nasa.gov.

                                        -Thomas Williams-

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































Deleted r34.1/plot/README.3d version [80cb4179cb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

		   A tutorial on explicit/parametric
				   and
		    everything you did not dare to ask
				  about
			   curves and surfaces
				    in
				  gnuplot

Several types of curves and surface are supported in gnuplot. Of those
not every operation is supported for every curve or surface type and it
can be therefore useful to understand the different types, their advantages
and limitations.

Curves in gnuplot are almost always planar (with one exception which we
will deal with in the end) and are assumed to be in the XY plane.
Therefore only X and Y coordinates are needed for plotting curves.
The simplest curve is the `explicit function`. This curve is in fact a
function and for each given x, there is one and only one y value associated
with it. A gnuplot example for such type is `plot sin(x)` or
`plot "datafile" using 1". Note the later is using only a single column from
the data file which is assumed to be the y values.

Alternatively one can define a `parametric curve` form. In this case
x and y are both functions of a third free parameter t, while independent
of each other. A circle can be expressed parametrically as x = cos(t),
y = sin(t) and be plotted using gnuplot as
'set parametric; plot cos(t),sin(t)'.
This form is not a function since there can be unlimited number of y values
associated with same x. Furthermore the explicit form is a special case of
the parametric representation by letting x equal to t. The curve y = sin(x)
can be written in parametric form as y = sin(t), x = t.

We are used to think of the plane in cartesian coordinate system.
In practice, some coordinate systems may be easier to use then others
under some circumstances. The polar form uses a different basis
to span the XY plane. In this representation the cartesian x coordinate
is equal to r cos(t) and the cartesian y coordinate is equal to r sin(t).
To draw a unit circle using the polar coordinate system in gnuplot use the
following simple command: 'set polar; plot 1'. To better understand this
explicit form lets backup a little.
When we plot a regular explicit function like `y = sin(x)` we march in equal
steps in x, evaluate the provided function and plot a piecewise linear curve
between the sampled points approximating the real function. In the polar
explicit form we do exactly the same thing, but we march along the angular
direction - we turn around the origin, computing the length of the radius
at that angle. Since for the unit circle, this radius is a constant 1,
`plot 1` in polar form plots a circle (if t domain is from 0 or 2Pi).
Note the polar form is explicit in that for each angle there is only a
single radius.

Surprisingly (or maybe not so surprising) surfaces share the same
representations. Since surfaces are two dimensional entities, they
require two free parameters (like t for curves).

A surface explicit function uses x and y as the free parameters. For
each such pair it provides a single z value. An example for this form
can be `splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)` for a three dimensional
sinc function or `splot 'datafile' using 1`. As for curves, the single column
used from the data file defines the function value or z in this case.
The order of the x and y function values is very strict in this form and
simply defines a rectangular grid in the XY plane. Fortunately this
strict form allows us to apply a very simplistic hidden line algorithm
called "the floating horizon". This hidden line algorithm exploits the
rectangular XY domain of the surface and therefore may be used for this
type of surfaces only. Since in gnuplot this is the only form of hidden
lines removing algorithm provided, only explicit surfaces may have their
hidden lines removed.

Parametric surfaces are the exact extension for explicit surfaces as in
the curves case. the x, y, and z are defined in terms of two new free
variables and are totally independent of each other as x(u, v), y(u, v),
and z(u, v). Again the explicit surface is a special case of the parametric
representation where x = u, and y = v. Examples for plotting parametric
surfaces in gnuplot can be `splot cos(u)*cos(v),cos(u)*sin(v),sin(u)` which
defines a sphere, or `splot "datafile" using 1:2:3`. Since these are
parametric surfaces, gnuplot must be informed to handle them by issuing
`set parametric`.

The curve polar form takes the obvious extensions in the surface world.
The first possible extension is spherical coordinate system, while the
second is the cylinderical one. These modes currently work for data files
only and both requires two parameters, teta and phi for mapping onto the
unit sphere, and teta and z form mapping on a unit radius cylinder as follow:

	Spherical coord.			Cylin. coord.
	----------------			-------------
	x = cos( theta ) * cos( phi )		x = cos( theta )
	y = sin( theta ) * cos( phi )		y = sin( theta )
	z = sin( phi )				z = z

This subject brings us back to non planar curves. When surfaces are displayed
under gnuplot, isocurves are actually getting plotted. An isocurve is a
curve on the surface in which one of the two free parameters of the
surface is fixed. For example the u isolines of a surface are drawn by
setting u to be fixed and varying v along the entire v domain. The v isolines
are similarly drawn by fixing v. When data files are specified they are
classified internally into two types. A surface is tagged to have grid
topology if all its specified isolines are of the same length. A data mesh
of five isolines, seven points each is an example. In such a case the
surface cross isolines are drawn as well. Seven isolines with five points
each will be automatically created and drawn for grid type data. If
however, isolines of different length are found in the data, it is
tagged as nongrid surface and in fact is nothing more than a collection
of three dimensional curves. only the provided data is plotted in that
case (see world.demo for a such an example).

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































Deleted r34.1/plot/README.3p2 version [3f29ce5493].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
This is the official release of GNUPLOT.3.2.  It is available in either
a patch or tar archive.  Sites for the retrieval are listed in the
README.   Below are the modifications and contributors to this release.
The patch file 3_1to3_2.patch needs to be applied with the p1 flag

>cd gnuplot
>patch -p1 < 3_1to3_2.patch

Thanks  ---  Alex Woo

* Subject: New generic gnuplot_x11.c 
  Name: Ed Kubatis
  Email: ejk@ux2.ncsa.uiuc.edu

* Subject: Hidden Line Removal for Explicit Surfaces and IRIX 4.0 fixes.
  Name: Gershon Elber
  Email: gershon@gr.utah.edu

* Subject: Table Terminal Driver.
  Name: Kevin Russo
  Email: russo@rudedog.nrl.navy.mil

* Subject: PCL5 driver fixes (HPGL page eject),datafile pipe and README.
  Name: Alex Woo
  Email: woo@ames.arc.nasa.gov

* Subject: Pbmplus driver and fix to y log tics.
  Name: Russell Lang 
  Email: rjl@monu1.cc.monash.edu.au  

* Subject: NeXT Console Driver.
  Name: Nick Strobel 
  Email: strobel@phast.phys.washington.edu

* Subject: Fix GNUTERM environment with disk resident BGI drivers
  Name: Craig Johnston
  Email: johnston@maxwell.ee.washington.edu

* Subject: Fix tables for troff in doc2ms
  Name: Michael Schuh
  Email: schuh@ames.arc.nasa.gov

* Subject: Fix dump when GNUPLOT$HELP undefined
  Name: Wolfgang J. Moeller
  Email: moeller@gwdgv1.dnet.gwdg.de 
  
* Subject: Fix AMIGA segment limits
  Name: Carsten Steger
  Email: stegerc@informatik.tu-muenchen.de
  
* Subject: Put FAR pointers in bitmap.c and bitmap.h
  Name: Russell Lang 
  Email: rjl@monu1.cc.monash.edu.au  
  
* Subject: Bug fix to latex.trm 
  Name: Rob Cunningham
  Email: rkc@xn.ll.mit.edu
----------------------------------------------------------------------------

                   GNUPLOT 3.1 Patch

This package provides the upgrade of gnuplot 3.0 to patch level 1.
Below are the contributers to this upgrade and the modifications made.

Thank you all

Gershon

----------------------------------------------------------------------------

* Subject: Y log / postscript eps fix
  Name: Russell Lang
  Email: rjl@monu1.cc.monash.edu.au

* Subject: HP26 driver to lift text.
  Name: Bruce Lueckenhoff
  Email: luechen@cis.udel.edu

* Subject: CRAY prt, UIUC coordinates.
  Name: Daniel Lewart
  Email: d-lewart@uiuc.edu

* Subject: AI device
  Name:	Ray Ghanbari
  Email: ray@mtl.mit.edu

* Subject: HP_MOTIF on a Snake, X11 for Next
  Name: Alex Woo
  Email: woo@ra-next.arc.nasa.gov

* Subject: Mod. to LaTeX for multiple curves/plots, complex atan function fix.
  Name: Ray Toy???
  Email: toy@soho.crd.ge.com

* Subject: Fix the "splot 'file.dat'" with only z values.
  Name: Gershon Elber
  Email: gershon@gr.utah.edu

* Subject: Underscore prefixed names.
  Name: Tom Tkacik
  Email: tkacik@hobbes.cs.gmr.com

* Subject: Amiga port
  Name: Carsten Steger 
  Email: stegerc@informatik.tu-muenchen.de
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































Deleted r34.1/plot/README.Install version [d2eac95aca].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
The GNUPLOT source code and executables may be copied and/or modified
freely as long as the copyright messages are left intact.

See the History file for changes to GNUPLOT.

Compilation instructions are near the end of this file.

GNUPLOT has been tested on Sun3's and Sun4's (SunOS 4.0.3 and 4.1.1),
a VAX 6410 (VMS 5.2), Commodore Amiga's (KS/WB 1.3 and 2.0, Lattice C
and Aztec C beta 5.2a), IBM PC XT's and AT's (MS-DOS 3.3/5.0 BC++ 2.0/TC++
1.0), IRIS 4D/70G and 4D/25G with MIPS C, NeXT with gnu C 1.34,
DECStation 5000/200PXG (ULTRIX V4.1),
AT&T 3B1 (version 3.51m with cc and gcc 1.39),
and Apollo's (DomainOS SR10.3 BSD4.3 with C compiler 68K Rev 6.7(316)).
The code is written with portability in mind.
GNUPLOT has not been tested on Pyramid 90x and IBM PC Microsoft C.

Send your comments, suggestions, or modifications to 
  info-gnuplot@ames.arc.nasa.gov
This is a mailing list; to join it send a note to 
  info-gnuplot-request@ames.arc.nasa.gov
Send bug reports to
  bug-gnuplot@ames.arc.nasa.gov

                       PREPROCESSOR #DEFINES

These #defines should be checked before compilation (see the makefiles):
define      file            note
------      ----            --------
NOVFORK     Makefile        define if you don't have the vfork() system call
GAMMA       Makefile        define if you've got gamma(3)
MEMCPY      Makefile        define if your bcopy() is called memcpy()
MEMSET      Makefile        define if you have memset() but not bzero()
NOCOPY      Makefile        define if you've don't have a memcpy() by any name
bcopy()     plot.h          define if you've got a memcpy() by some OTHER name
                              (see example in plot.h)
PC          Makefile        define if compiling on a PClone
MSDOS       Makefile        define if compiling under MSDOS;
                              automatically defined by Microsoft C 5.10
HELPFILE    Makefile        name including path of gnuplot.gih file.
VERYLARGE   plot.h          define to be largest coordinate number.
SHELL       plot.h          default shell to spawn if SHELL environment
                              variable not found at run-time
NOCWDRC     Makefile        define to inhibit check of ./.gnuplot
READLINE    Makefile        define if you want command-line editing

Valid TERMFLAGS defines.  These defines are used to include the
various plotting terminals, printers, and protocols that a given version
of gnuplot can access:

define 	    file            note
------      ----            --------
TERMFLAGS   Makefile        the set of terminals you want, from below
            or term.h

   AED         AED 512 and AED 767
   AIFM        Adobe Illustrator Format
   AMIGASCREEN Amiga custom screen
   APOLLO      Apollo Graphics Primitive Resource (resizable window)
   ATT6300     PC with AT&T 6300 graphics
   BITGRAPH    BBN BitGraph
   CGI         SCO CGI
   CORONA      PC with Corona graphics 325
   DXY800A     Roland DXY800A plotter
   DUMB	       Printer or glass dumb terminal
   DXF	       AutoCad (Release 10.x) dxf file format
   EEPIC       EEPIC-extended LaTeX driver, for EEPIC users
   EGALIB      PC with EGA/VGA graphics.
   EMTEX       LATEX picture environment with emTeX specials
   EPS60       Epson-style 60-dot per inch printers
   EPSONP      Epson LX-800, Star NL-10, NX-1000 and lots of others
   FIG         Fig graphics language (requires object.h from TransFig)
   GPR         Apollo Graphics Primitive Resource (fixed-size window)
   HERCULES    IBM PC/Clone with Hercules graphics board
   HP2648      HP2648, HP2647
   HP26        HP2623A and maybe others
   HP75        HP7580, and probably other HPs
   HPGL        HP7475 and (hopefully) lots of others
   HPLJII      HP Laserjet II
   HPLJIII     HP Laserjet III (HPGL/2)
   IMAGEN      Imagen laser printers (300dpi) (requires -Iterm also)
   IRIS4D      IRIS4D series computer
   KERMIT      MS-Kermit Tektronix 4010 emulator
   LATEX       LATEX picture environment
   LN03P       DEC LN03P laser printer
   NEC         NEC CP6 pinwriter printer
   PBM         PBMPLUS pbm, pgm, ppm formats
   POSTSCRIPT  Postscript
   PRESCRIBE   Kyocera Laser printer
   QMS         QMS/QUIC laserprinter (Talaris 1200 and others)
   REGIS       ReGis graphics (vt125, vt220, vt240, Gigis...)
   SELANAR     Selanar
   STARC       Star Color Printer
   SUN         Sun Microsystems Workstation
   T410X       Tektronix 4106, 4107, 4109 and 420x terminals
   TANDY60     Tandy DMP-130 series 60-dot per inch graphics
   TEK         Tektronix 4010, and probably others
   UNIXPC      unixpc (ATT 3b1 or ATT 7300)
   UNIXPLOT    unixplot
   V384        Vectrix 384 and tandy color printer
   VTTEK       VT like Tektronix 4010 emulator
   X11         X11R4 window system


These #defines are defined automatically by various compilers, some
gnuplot routines check these defines to implement features found in the
various environments:

define 	      note
------        --------
AMIGA_AC_5    defined for Manx Aztec C 5.2a on the Amiga
AMIGA_LC_5_1  defined for Lattice C 5.01 on the Amiga
apollo        defined by Apollo's C compilers.
_CRAY         defined by CRAY's C compiler.
__TURBOC__    defined automatically by Turbo C 2.0, C++ 1.0, Borland C++ 2.0
unix          defined by most unix C compilers.  
vms           (and VMS) defined by VAX-11 C under VMS.
__ZTC__       Zortech C compiler under MSDOS.


                             TO COMPILE

under UNIX:  
To compile do:
  Copy makefile.unx to Makefile
      cp makefile.unx Makefile
  Look through the Makefile to see if you need to make any changes.
  See especially the HELPDEST and TERMFLAGS variables.  Edit if needed.
  Alternatively, all these variables may be set as command line arguments to
  'make'. For example:

	make <MACHINE> HELPDEST='/usr/um/misc/lib/gnuplot.gih' \
		DEST='/usr/um/misc/bin' READLINE=

  Edit term.h, to include/exclude terminals
  Type
      make
  For further instructions.
  If that works, try
      make install
  For further instructions.

under VMS:  
  To compile:
     copy makefile.vms makefile.
     make
  Or if you don't have a suitable make:
     @buildvms
  To tell gnuplot where to find the help library:
      $ define gnuplot$help disk:[directory]gnuplot.hlb
  Alternatively (and preferably) put the help in the main system help library.

under AmigaDOS:
Using Aztec C 5.2a
      make -f makefile.ami
Using Lattice C 5.1
      lmk -f makefile.amg

under MSDOS:
Using Microsoft C 5.10.
      copy makefile.msc makefile
      make makefile

Using Borland C++ 2.0, Turbo C++ 1.0
      copy makefile.tc makefile
  Edit makefile to change TC, BIN, BGI, BGIOBJ. You may also want to turn
      on overlays (See manual for more on overlays).
  Edit linkopt.tc (linkopt.tco if overlays on) to change location of
      libraries.
      make

Using Turbo C 2.0.
  As per Borland C++ 2.0. Edit linkopt.tc to change location of libraries.


The file gnuplot.gih is needed for help on the PC.
If the file gnuplot.gih is not in the default directory, then use:
    set GNUHELP={full path name of gnuplot.gih}


                         ENVIRONMENT VARIABLES

See 'help environment'.

If the environment variable GNUTERM is found, it is used as the terminal
type. Otherwise, in some cases the variable TERM will be used, or the
hardware may be automatically detected. 

The PC version looks for the environment variable GNUPLOT to contain
the name of the directory from which to load the initialization file
GNUPLOT.INI.  See the help on 'start_up' for more information.

HOME is examined as a directory where a .gnuplot startup file might be
found. See help on "start-up".

If defined, the environment variable GNUHELP is used for the name
of the .gih help file, otherwise HELPFILE (defined in makefile or 
plot.c) is used.

The VMS version looks for the logical name GNUPLOT$HELP to locate 
the help library.

The CGI drivers need the CGIPATH environment variable to set the path
to the CGI agents, and the CGIDISP and/or CGIPRNT environment
variables to set the output devices.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































Deleted r34.1/plot/README.NeXT version [f11c2b42b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
	This directory contains version 2 of the additional files
you'll need to get gnuplot3.0 to display it's postscript directly to a
window instead of going through the klunky process of writing the
postscript to a file and launching Previewer to view the file.  Note
that all input is still done at the shell level! Fancier NeXTStep
interfaces will be a future project.

	This version is faster and leaner than the old method.  It
also does not eat up swap space like the older version (this was
particularly noticeable when doing animation-like plots).  To do this
I used DPS function calls instead of creating a NXImage and
compositing the stream of commands. I based my code on the program
called "epsview" in the hackkit tar file on the archive servers.

	The next_dps.trm (next terminal) is basically the post.trm
(postscript terminal) with the fprintf replaced by DPSPrintf and
outfile by the DPSContext d.  You'll also see that I also used some
code (with modifications) from David S. Joerg's MovieApp.  Using the
DPS functions enabled me to slim down the EpsViewer.[hm] and
EPSView.[hm] files.

	No claim is made to code elegance or to it being a good example of
objective-c coding.  This is my first (well, second, sort of) objective-c 
program. It seems to work for me. Any constructive criticism would be 
appreciated.  I can be reached at strobel@phast.phys.washington.edu

cheers!

nick strobel

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































Deleted r34.1/plot/README.amiga version [a9a743cf4c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
SOME NOTES ON GNUPLOT ON THE AMIGA ...



Environment Variables:

   GNUFONT   You can say "setenv GNUFONT <Fontname>/<Pointsize>" to get the font
             of your liking on the screen, e.g. "setenv GNUFONT sapphire/14".
             Otherwise gnuplot will select the default-font you chose with
             "Preferences".

   GNUHELP   Allows you to define a pathname for the GNUPlot help file.  For
             example, "setenv GNUHELP TEX:gnuplot.gih"

   GNUPLOT   Your current directory is searched for the file ".gnuplot".
             If you say "setenv GNUPLOT <Path>" (without the filename!)
             GNUPlot will look for it there.

   GNUTERM   You can define a default driver with "setenv GNUTERM <driver>".
             A good choice is "setenv GNUTERM amiga" :^)

   SHELL     If you don't like "NewShell" as your shell, you can say
             "setenv SHELL <Shell>".


Stack Size:

   Set your stack to at least 20000 and you'll be fine (I hope).
   If you're using the integral feature, a stack size of at least 70000
   is necessary (at least it is for "bivariat.demo" to execute).



--------------------------   LATTICE C VERSION   ------------------------------


Default paths/directories:

   Gnuplot looks for the file "gnuplot.gih" in your "S:"-directory unless you
   specify the full pathname including the filename via "setenv GNUHELP".


Bugs/deficiencies:

   The SAS/C 5.1 library routine [fs]scanf will not correctly handle
   format-strings like "%[^\n]s". Maybe this will be fixed by SAS in future
   versions.

   When using "%g" as format-string, SAS/C 5.1 [fs]printf will incorrectly
   output "0" as "0.". This looks rather ugly as a axis-label.


SAS/C 5.1 bugs:

   SAS/C 5.1 [fs]scanf will count parameters overread with the "%*s" format-
   string as properly matched. I included a fix for this by counting the
   "%*"-sequences in the given format-string. Therfore the "*" must immediately
   follow the "%" (I don't know if it's legal to put something in-between
   these two characters anyway...).

   If you start a shell via the gnuplot "shell"-command you won't be able to
   close your CLI/Shell again. This is probably due to an error in the
   SAS/C "system"-call.

   "isatty(fileno(stdin))" did not work correctly. A fix is included.

   SAS/C does not seem to handle float-parameters in function-calls and
   -declarations correctly. (This cost me at least 2 hours to figure out >:-( ).
   See the latex- and eepic-drivers for details.




---------------------------   AZTEC C VERSION   -------------------------------


Default paths/directories:

   GNUPlot looks for the "gnuplot.gih" file in "GNUPLOT:docs/gnuplot.gih" if
   GNUHELP is not defined.   This is defined in the makefile (makefile.ami).


Terminal Drivers:

   The Aztec C version can now use the "amiga.trm" driver written by
   Carsten Steger.  Under KS/WB 2.0, a custom screen will be used with a size
   specified by the Prefs/Overscan program.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































Deleted r34.1/plot/README.gnutex version [aea1db01d8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
A note to former Gnutex users, from David Kotz (David.Kotz@Dartmouth.edu).
--------------------------------------------------------------------------

May 30, 1991

GNUTeX was merged with GNUPLOT beginning with GNUPLOT 2.0.  Many
aspects of gnutex 1.6 made it into GNUPLOT 2.0. Unfortunately for
those of us who have a lot of gnutex input files around, not
everything from gnutex is supported by GNUPLOT. To help gnutex users
with the process of adapting to GNUPLOT (and I recommend it), I have
included a section in the LaTeX/GNUPLOT tutorial (in ./docs/latextut/)
about the differences, and written a translator program.  Please read
the LaTeX/GNUPLOT tutorial. 

The translator was available as part of the GNUPLOT 2.0 release, but
has been removed from the standard distribution of GNUPLOT.  The
translator is now available for anonymous ftp from cs.duke.edu as
dist/sources/gnuplot/gnut2p.tar.Z. It has not changed since GNUPLOT
2.01 (ie, GNUPLOT 2.0 patchlevel 1).

Users of gnutex that did not use the LaTeX driver will probably have
little difficulty adapting. 

Please send all comments, complaints, and suggestions on this subject
to David.Kotz@Dartmouth.edu.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted r34.1/plot/README.patch1 version [0c67fef9a4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
This package provides the upgrade of gnuplot 3.0 to patch level 1.
Below are the contributers to this upgrade and the modifications made.

Thank you all

Gershon

----------------------------------------------------------------------------

* Subject: Y log / postscript eps fix
  Name: Russell Lang
  Email: rjl@monu1.cc.monash.edu.au

* Subject: HP26 driver to lift text.
  Name: Bruce Lueckenhoff
  Email: luechen@cis.udel.edu

* Subject: CRAY prt, UIUC coordinates.
  Name: Daniel Lewart
  Email: d-lewart@uiuc.edu

* Subject: AI device
  Name:	Ray Ghanbari
  Email: ray@mtl.mit.edu

* Subject: HP_MOTIF on a Snake, X11 for Next
  Name: Alex Woo
  Email: woo@ra-next.arc.nasa.gov

* Subject: Mod. to LaTeX for multiple curves/plots, complex atan function fix.
  Name: Ray Toy???
  Email: toy@soho.crd.ge.com

* Subject: Fix the "splot 'file.dat'" with only z values.
  Name: Gershon Elber
  Email: gershon@gr.utah.edu

* Subject: Underscore prefixed names.
  Name: Tom Tkacik
  Email: tkacik@hobbes.cs.gmr.com

* Subject: Amiga port
  Name: Carsten Steger 
  Email: stegerc@informatik.tu-muenchen.de
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































Deleted r34.1/plot/README.x11 version [2bea23893f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

Notes on the new X11 features are attached. 

Ed
----------------------------------
Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
Computing & Communications Services Office - University of Illinois, Urbana

===============================================================================
Gnuplot_x11 for 3.2
-------------------

New features
------------
   o CRIPPLED_SELECT build option for SVR3 platforms with incomplete
     or faulty implementations of BSD select().

   o Xlib only

     X11 support no longer requires Athena or Motif libraries and
     include files. This makes life easier for people on platforms
     with Open Look only. It also simplifies X11 tailoring on all
     platforms. Oh yes, and the gnuplot_x11 executable is smaller
     (~43K instead of ~500K on RS/6000.)

     makefile.unx has been edited to remove references to Athena &
     Motif. Also, with the exception of the HP definition (where it
     appeared to be intentionally specific to R4) all references to 
     X11R4 have also been removed since this version should work without 
     changes on R3, R4, or R5.

   o Grayscale handling

     * grayscale displays get monochrome rendering by default

     * '-gray' option & resource forces grayscale rendering on grayscale
       or color displays.

     * '-mono' option forces monochrome rendering on color displays.

     * special grayscale resources (separate from color)

   o Miscellaneous

     * By default, the window is no longer momentarily cleared when
       a new plot is displayed. The new plot "silently" replaces the
       previous one.  I found this useful when running some of the demos, 
       such as contours.demo, where a plot "adds" a feature to
       the one before (gnuplot "movies" anyone?;-).

       However, a "-clear" command line-option and "gnuplot*clear: on"
       restores the momentary clear that was there previously.

     * Added ptx_x11 and convex_x11 machine options to makefile.unx.

     * There is an X11FLAGS option (-DOLD_SELECT) for old 4.2 BSD systems
       (such as SunOS 3.5) which don't have the FD_XXX macros that
       go with select().


A few words about CRIPPLED_SELECT
---------------------------------
I closely reviewed four different ways people had devised for dealing with 
the "select error" problem encountered on some SVR3 platforms. I had one 
such platform (Sequent Dynix/PTX) available for testing. Unfortunately 3 of 
the four ways that had been submitted did not work for PTX (which has 
problems with non-blocking I/O and Unix domain sockets as well as select). 
The fourth way worked there but it used SV STREAMS and I had no way to 
verify that it would also work on all the other platforms that encountered 
the problem.

What was done instead was to use a temporary file instead of a pipe for
gnuplot->gnuplot_x11 communication when CRIPPLED_SELECT is used. This is 
like a sledgehammer - crude but (hopefully) robust. It should work on any 
platform with open(), read(), write(), close(), unlink(), getpid(), and 
getppid().

Response time is not bad with CRIPPLED_SELECT. Timings on an RS/6000 
for all.demo (hitting RETURN as soon as a plot appears) indicate that 
CRIPPLED_SELECT only adds an average of .5 seconds to response time, 
about what one would expect given the 1 second timer used. And curiously, 
CRIPPLED_SELECT used 30% less CPU than the default mode.

Testing
-------
The new gnuplot_x11 was tested here on the following platforms:

   o IBM RS/6000 AIX 3.1.6 (IBM X11R3)
   o IBM RS/6000 AIX 3.1.6 (MIT X11R4)
   o Apollo 400s DomainOS 10.3 (Apollo X11R3)
   o Sun SPARC SunOS 4.1.1-GFX-Rev2 (X11R?)
   o Vax BSD 4.3 Reno (X11R5)
   o Vax Ultrix-32 V3.0 Rev 64 (MIT X11R4)
   o Sun 3/50 SunOS 3.5 (MIT X11R4)
   o Sun 3/60 SunOS 4.1 (MIT X11R4)
   o NeXT (X11 R?)
   o Convex C2 9.0 OS (MIT X11R5)
   o Sequent Dynix 3.1 (MIT X11R5)
   o Sequent Dynix/PTX (MIT X11R5)
   o Cray 2 - Unicos 5+?
   o Cray Y-MP - Unicos 5+?

And with the following servers:

   o NCD 19 monochrome (NCD X11R3)
   o Visual X-15 monochrome (Visual X11R4)
   o Sun 3/50 monochrome (MIT X11R4)
   o IBM XStation 120 grayscale (IBM X11R4)
   o Visual Turbo X-19 grayscale (Visual X11R4)
   o IBM XStation 120 color (IBM X11R4)
   o Sun 3/60 color (MIT X11R4)
   o IBM XStation 130 1.3 (IBM X11R4)

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































Deleted r34.1/plot/bitmap.c version [540c74f256].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
#ifndef lint
static char *RCSid = "$Id: bitmap.c,v 3.26 92/03/24 22:34:39 woo Exp Locker: woo $";
#endif


/* GNUPLOT - bitmap.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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:
 *     Jyrki Yli-Nokari <jty@intrin.UUCP>
 *     Ronald J. Hartranft <rjh2@ns.cc.lehigh.edu>
 *     Russell Lang <rjl@monu1.cc.monash.edu.au>
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

/*
** General raster plotting routines.
** Raster routines written and copyrighted 1987 by
** Jyrki Yli-Nokari (jty@intrin.UUCP)
** Intrinsic, Ltd.
**
** You may use this code for anything you like as long as
** you are not selling it and the credit is given and
** this message retained.
**
*/

/* Bitmap plotting routines derived from above raster plotting routines
 * Russell Lang, 1990
 */

#include <stdio.h>
#include "plot.h"
#include "bitmap.h"

bitmap *b_p = (bitmap *)NULL;	/* global pointer to bitmap */
unsigned int b_currx, b_curry;	/* the current coordinates */
unsigned int b_xsize, b_ysize;	/* the size of the bitmap */
unsigned int b_planes;			/* number of color planes */
unsigned int b_psize;			/* size of each plane */
unsigned int b_rastermode;		/* raster mode rotates -90deg */
unsigned int b_linemask = 0xffff;	/* 16 bit mask for dotted lines */
unsigned int b_value = 1;		/* colour of lines */
unsigned int b_hchar;			/* width of characters */
unsigned int b_hbits;			/* actual bits in char horizontally */
unsigned int b_vchar;			/* height of characters */
unsigned int b_vbits;			/* actual bits in char vertically */
unsigned int b_angle;			/* rotation of text */
char_box b_font[FNT_CHARS];		/* the current font */
unsigned int b_pattern[] = {0xffff, 0x1111,
	0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
int b_maskcount = 0;
unsigned int b_lastx, b_lasty;	/* last pixel set - used by b_line */

#define IN(i,size)  ((unsigned)i < (unsigned)size)

/* 5x9 font, bottom row first, left pixel in lsb */
char_row FAR fnt5x9[FNT_CHARS][FNT5X9_VBITS] = {
  /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000},
  /*!*/  {000000,000000,0x0004,000000,0x0004,0x0004,0x0004,0x0004,0x0004},
  /*"*/  {000000,000000,000000,000000,000000,000000,0x000a,0x000a,0x000a},
  /*#*/  {000000,000000,0x000a,0x000a,0x001f,0x000a,0x001f,0x000a,0x000a},
  /*$*/  {000000,000000,0x0004,0x000f,0x0014,0x000e,0x0005,0x001e,0x0004},
  /*%*/  {000000,000000,0x0018,0x0019,0x0002,0x0004,0x0008,0x0013,0x0003},
  /*&*/  {000000,000000,0x0016,0x0009,0x0015,0x0002,0x0005,0x0005,0x0002},
  /*'*/  {000000,000000,000000,000000,000000,0x0002,0x0004,0x0006,0x0006},
  /*(*/  {000000,000000,0x0008,0x0004,0x0002,0x0002,0x0002,0x0004,0x0008},
  /*)*/  {000000,000000,0x0002,0x0004,0x0008,0x0008,0x0008,0x0004,0x0002},
  /***/  {000000,000000,0x0004,0x0015,0x000e,0x001f,0x000e,0x0015,0x0004},
  /*+*/  {000000,000000,000000,0x0004,0x0004,0x001f,0x0004,0x0004,000000},
  /*,*/  {000000,0x0002,0x0004,0x0006,0x0006,000000,000000,000000,000000},
  /*-*/  {000000,000000,000000,000000,000000,0x001f,000000,000000,000000},
  /*.*/  {000000,000000,0x0006,0x0006,000000,000000,000000,000000,000000},
  /*-/-*/{000000,000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,000000},
  /*0*/  {000000,000000,0x000e,0x0011,0x0013,0x0015,0x0019,0x0011,0x000e},
  /*1*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0006,0x0004},
  /*2*/  {000000,000000,0x001f,0x0001,0x0001,0x000e,0x0010,0x0011,0x000e},
  /*3*/  {000000,000000,0x000e,0x0011,0x0010,0x000c,0x0010,0x0011,0x000e},
  /*4*/  {000000,000000,0x0008,0x0008,0x001f,0x0009,0x000a,0x000c,0x0008},
  /*5*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x000f,0x0001,0x001f},
  /*6*/  {000000,000000,0x000e,0x0011,0x0011,0x000f,0x0001,0x0002,0x000c},
  /*7*/  {000000,000000,0x0001,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  /*8*/  {000000,000000,0x000e,0x0011,0x0011,0x000e,0x0011,0x0011,0x000e},
  /*9*/  {000000,000000,0x0006,0x0008,0x0010,0x001e,0x0011,0x0011,0x000e},
  /*:*/  {000000,000000,000000,0x0006,0x0006,000000,0x0006,0x0006,000000},
  /*;*/  {000000,0x0001,0x0002,0x0006,0x0006,000000,0x0006,0x0006,000000},
  /*<*/  {000000,000000,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,0x0008},
  /*=*/  {000000,000000,000000,000000,0x001f,000000,0x001f,000000,000000},
  /*>*/  {000000,000000,0x0002,0x0004,0x0008,0x0010,0x0008,0x0004,0x0002},
  /*?*/  {000000,000000,0x0004,000000,0x0004,0x0008,0x0010,0x0011,0x000e},
  /*@*/  {000000,000000,0x000e,0x0015,0x0015,0x0016,0x0010,0x0011,0x000e},
  /*A*/  {000000,000000,0x0011,0x0011,0x001f,0x0011,0x0011,0x000a,0x0004},
  /*B*/  {000000,000000,0x000f,0x0012,0x0012,0x000e,0x0012,0x0012,0x000f},
  /*C*/  {000000,000000,0x000e,0x0011,0x0001,0x0001,0x0001,0x0011,0x000e},
  /*D*/  {000000,000000,0x000f,0x0012,0x0012,0x0012,0x0012,0x0012,0x000f},
  /*E*/  {000000,000000,0x001f,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  /*F*/  {000000,000000,0x0001,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
  /*G*/  {000000,000000,0x001e,0x0011,0x0011,0x0019,0x0001,0x0001,0x001e},
  /*H*/  {000000,000000,0x0011,0x0011,0x0011,0x001f,0x0011,0x0011,0x0011},
  /*I*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x000e},
  /*J*/  {000000,000000,0x000e,0x0011,0x0010,0x0010,0x0010,0x0010,0x0010},
  /*K*/  {000000,000000,0x0011,0x0009,0x0005,0x0003,0x0005,0x0009,0x0011},
  /*L*/  {000000,000000,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  /*M*/  {000000,000000,0x0011,0x0011,0x0011,0x0015,0x0015,0x001b,0x0011},
  /*N*/  {000000,000000,0x0011,0x0011,0x0011,0x0019,0x0015,0x0013,0x0011},
  /*O*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x000e},
  /*P*/  {000000,000000,0x0001,0x0001,0x0001,0x000f,0x0011,0x0011,0x000f},
  /*Q*/  {000000,0x0018,0x000e,0x0015,0x0011,0x0011,0x0011,0x0011,0x000e},
  /*R*/  {000000,000000,0x0011,0x0009,0x0005,0x000f,0x0011,0x0011,0x000f},
  /*S*/  {000000,000000,0x000e,0x0011,0x0010,0x000e,0x0001,0x0011,0x000e},
  /*T*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x001f},
  /*U*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011},
  /*V*/  {000000,000000,0x0004,0x0004,0x000a,0x000a,0x0011,0x0011,0x0011},
  /*W*/  {000000,000000,0x0011,0x001b,0x0015,0x0011,0x0011,0x0011,0x0011},
  /*X*/  {000000,000000,0x0011,0x0011,0x000a,0x0004,0x000a,0x0011,0x0011},
  /*Y*/  {000000,000000,0x0004,0x0004,0x0004,0x0004,0x000a,0x0011,0x0011},
  /*Z*/  {000000,000000,0x001f,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
  /*[*/  {000000,000000,0x000e,0x0002,0x0002,0x0002,0x0002,0x0002,0x000e},
  /*\*/  {000000,000000,000000,0x0010,0x0008,0x0004,0x0002,0x0001,000000},
  /*]*/  {000000,000000,0x000e,0x0008,0x0008,0x0008,0x0008,0x0008,0x000e},
  /*^*/  {000000,000000,000000,000000,000000,000000,0x0011,0x000a,0x0004},
  /*_*/  {000000,000000,0x001f,000000,000000,000000,000000,000000,000000},
  /*`*/  {000000,000000,000000,000000,000000,0x0008,0x0004,0x000c,0x000c},
  /*a*/  {000000,000000,0x001e,0x0011,0x001e,0x0010,0x000e,000000,000000},
  /*b*/  {000000,000000,0x000d,0x0013,0x0011,0x0013,0x000d,0x0001,0x0001},
  /*c*/  {000000,000000,0x000e,0x0011,0x0001,0x0011,0x000e,000000,000000},
  /*d*/  {000000,000000,0x0016,0x0019,0x0011,0x0019,0x0016,0x0010,0x0010},
  /*e*/  {000000,000000,0x000e,0x0001,0x001f,0x0011,0x000e,000000,000000},
  /*f*/  {000000,000000,0x0004,0x0004,0x0004,0x000e,0x0004,0x0014,0x0008},
  /*g*/  {0x000e,0x0011,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  /*h*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,0x0001,0x0001},
  /*i*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0006,000000,0x0004},
  /*j*/  {0x0006,0x0009,0x0008,0x0008,0x0008,0x0008,0x000c,000000,0x0008},
  /*k*/  {000000,000000,0x0009,0x0005,0x0003,0x0005,0x0009,0x0001,0x0001},
  /*l*/  {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x0006},
  /*m*/  {000000,000000,0x0015,0x0015,0x0015,0x0015,0x000b,000000,000000},
  /*n*/  {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,000000,000000},
  /*o*/  {000000,000000,0x000e,0x0011,0x0011,0x0011,0x000e,000000,000000},
  /*p*/  {0x0001,0x0001,0x000d,0x0013,0x0011,0x0013,0x000d,000000,000000},
  /*q*/  {0x0010,0x0010,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
  /*r*/  {000000,000000,0x0001,0x0001,0x0001,0x0013,0x000d,000000,000000},
  /*s*/  {000000,000000,0x000f,0x0010,0x000e,0x0001,0x001e,000000,000000},
  /*t*/  {000000,000000,0x0008,0x0014,0x0004,0x0004,0x001f,0x0004,0x0004},
  /*u*/  {000000,000000,0x0016,0x0019,0x0011,0x0011,0x0011,000000,000000},
  /*v*/  {000000,000000,0x0004,0x000a,0x0011,0x0011,0x0011,000000,000000},
  /*w*/  {000000,000000,0x000a,0x0015,0x0015,0x0011,0x0011,000000,000000},
  /*x*/  {000000,000000,0x0011,0x000a,0x0004,0x000a,0x0011,000000,000000},
  /*y*/  {0x000e,0x0010,0x001e,0x0011,0x0011,0x0011,0x0011,000000,000000},
  /*z*/  {000000,000000,0x001f,0x0002,0x0004,0x0008,0x001f,000000,000000},
  /*{*/  {000000,000000,0x0008,0x0004,0x0004,0x0002,0x0004,0x0004,0x0008},
  /*|*/  {000000,000000,0x0004,0x0004,0x0004,000000,0x0004,0x0004,0x0004},
  /*}*/  {000000,000000,0x0002,0x0004,0x0004,0x0008,0x0004,0x0004,0x0002},
  /*~*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0015,0x0002},
  /*DEL*/{000000,000000,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f},
};

/* 9x17 font, bottom row first, left pixel in lsb */
char_row FAR fnt9x17[FNT_CHARS][FNT9X17_VBITS] = {
  /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000},
  /*!*/  {000000,000000,000000,000000,0x0010,000000,000000,000000,0x0010,
          0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010},
  /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x0044},
  /*#*/  {000000,000000,000000,000000,0x0044,0x0044,0x0044,0x0044,0x01ff,
          0x0044,0x0044,0x0044,0x01ff,0x0044,0x0044,0x0044,0x0044},
  /*$*/  {000000,000000,000000,000000,0x0010,0x0010,0x007e,0x0091,0x0110,
          0x0090,0x007c,0x0012,0x0011,0x0112,0x00fc,0x0010,0x0010},
  /*%*/  {000000,000000,000000,000000,0x0080,0x0141,0x0081,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0102,0x0105,0x0002},
  /*&*/  {000000,000000,000000,000000,0x011c,0x00a2,0x0041,0x00c1,0x0141,
          0x0022,0x001c,0x0014,0x0022,0x0022,0x001c,000000,000000},
  /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010},
  /*(*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0008,
          0x0004,0x0004,0x0004,0x0008,0x0008,0x0010,0x0020,0x0040},
  /*)*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0020,
          0x0040,0x0040,0x0040,0x0020,0x0020,0x0010,0x0008,0x0004},
  /***/  {000000,000000,000000,000000,0x0010,0x0010,0x0111,0x0092,0x0054,
          0x0038,0x01ff,0x0038,0x0054,0x0092,0x0111,0x0010,0x0010},
  /*+*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0010,0x0010,
          0x0010,0x01ff,0x0010,0x0010,0x0010,0x0010,000000,000000},
  /*,*/  {000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,000000,
          000000,000000,000000,000000,000000,000000,000000,000000},
  /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,0x01ff,000000,000000,000000,000000,000000,000000},
  /*.*/  {000000,000000,000000,000000,0x0010,0x0038,0x0010,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000},
  /*-/-*/{000000,000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,000000,000000},
  /*0*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0103,0x0105,
          0x0109,0x0111,0x0121,0x0141,0x0181,0x0101,0x0082,0x007c},
  /*1*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0010,0x0010,0x0010,0x001c,0x0018,0x0010},
  /*2*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
          0x0002,0x007c,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  /*3*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
          0x0080,0x0078,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  /*4*/  {000000,000000,000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x01ff,0x0041,0x0042,0x0044,0x0048,0x0050,0x0060,0x0040},
  /*5*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
          0x0100,0x0080,0x007f,0x0001,0x0001,0x0001,0x0001,0x01ff},
  /*6*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
          0x0081,0x007f,0x0001,0x0001,0x0001,0x0002,0x0084,0x0078},
  /*7*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0100,0x01ff},
  /*8*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
          0x0082,0x007c,0x0082,0x0101,0x0101,0x0101,0x0082,0x007c},
  /*9*/  {000000,000000,000000,000000,0x001c,0x0022,0x0040,0x0080,0x0100,
          0x0100,0x01fc,0x0102,0x0101,0x0101,0x0101,0x0082,0x007c},
  /*:*/  {000000,000000,000000,000000,000000,000000,0x0010,0x0038,0x0010,
          000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  /*;*/  {000000,000000,000000,0x0004,0x0008,0x0010,0x0030,0x0038,0x0010,
          000000,000000,000000,0x0010,0x0038,0x0010,000000,000000},
  /*<*/  {000000,000000,000000,000000,0x0040,0x0020,0x0010,0x0008,0x0004,
          0x0002,0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040},
  /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x01ff,
          000000,000000,000000,0x01ff,000000,000000,000000,000000},
  /*>*/  {000000,000000,000000,000000,0x0004,0x0008,0x0010,0x0020,0x0040,
          0x0080,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004},
  /*?*/  {000000,000000,000000,0x0010,0x0038,0x0010,000000,0x0010,0x0010,
          0x0020,0x0040,0x0080,0x0100,0x0100,0x0101,0x0082,0x007c},
  /*@*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x01f9,0x0145,
          0x0145,0x0145,0x0179,0x0101,0x0101,0x0101,0x0082,0x007c},
  /*A*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x01ff,
          0x0101,0x0082,0x0082,0x0044,0x0044,0x0028,0x0028,0x0010},
  /*B*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
          0x0084,0x007c,0x0084,0x0104,0x0104,0x0104,0x0084,0x007f},
  /*C*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0101,0x0082,0x007c},
  /*D*/  {000000,000000,000000,000000,0x007f,0x0084,0x0104,0x0104,0x0104,
          0x0104,0x0104,0x0104,0x0104,0x0104,0x0104,0x0084,0x007f},
  /*E*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  /*F*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x01ff},
  /*G*/  {000000,000000,000000,000000,0x00fc,0x0102,0x0101,0x0101,0x0101,
          0x0101,0x01c1,0x0001,0x0001,0x0001,0x0001,0x0102,0x00fc},
  /*H*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
          0x0101,0x01ff,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  /*I*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x007c},
  /*J*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
          0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x0180},
  /*K*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
          0x0009,0x0005,0x000b,0x0011,0x0021,0x0041,0x0081,0x0101},
  /*L*/  {000000,000000,000000,000000,0x01ff,0x0101,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  /*M*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
          0x0101,0x0111,0x0111,0x0129,0x0145,0x0145,0x0183,0x0101},
  /*N*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0181,0x0141,
          0x0141,0x0121,0x0111,0x0109,0x0105,0x0105,0x0103,0x0101},
  /*O*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  /*P*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  /*Q*/  {000000,000000,0x0180,0x0040,0x007c,0x0092,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0082,0x007c},
  /*R*/  {000000,000000,000000,000000,0x0101,0x0081,0x0041,0x0021,0x0011,
          0x0009,0x007f,0x0081,0x0101,0x0101,0x0101,0x0081,0x007f},
  /*S*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0100,0x0100,
          0x0080,0x007c,0x0002,0x0001,0x0001,0x0101,0x0082,0x007c},
  /*T*/  {000000,000000,000000,000000,0x0038,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0111,0x01ff},
  /*U*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  /*V*/  {000000,000000,000000,000000,0x0010,0x0010,0x0028,0x0028,0x0044,
          0x0044,0x0082,0x0082,0x0101,0x0101,0x0101,0x0101,0x0101},
  /*W*/  {000000,000000,000000,000000,0x0101,0x0183,0x0145,0x0145,0x0129,
          0x0111,0x0111,0x0101,0x0101,0x0101,0x0101,0x0101,0x0101},
  /*X*/  {000000,000000,000000,000000,0x0101,0x0101,0x0082,0x0082,0x0044,
          0x0028,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  /*Y*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0028,0x0044,0x0082,0x0082,0x0101,0x0101},
  /*Z*/  {000000,000000,000000,000000,0x01ff,0x0001,0x0002,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0080,0x0100,0x01ff},
  /*[*/  {000000,000000,000000,000000,0x007c,0x0004,0x0004,0x0004,0x0004,
          0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x007c},
  /*\*/  {000000,000000,000000,000000,000000,000000,0x0100,0x0080,0x0040,
          0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,000000,000000},
  /*]*/  {000000,000000,000000,000000,0x007c,0x0040,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x007c},
  /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010},
  /*_*/  {000000,000000,000000,000000,0x01ff,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000},
  /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,0x0020,0x0010,0x0008,0x000c,0x001c,0x0008},
  /*a*/  {000000,000000,000000,000000,0x03fc,0x0102,0x0101,0x0102,0x01fc,
          0x0100,0x0100,0x0080,0x007c,000000,000000,000000,000000},
  /*b*/  {000000,000000,000000,000000,0x007d,0x0083,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0083,0x007d,0x0001,0x0001,0x0001,0x0001},
  /*c*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0001,0x0001,
          0x0001,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  /*d*/  {000000,000000,000000,000000,0x017c,0x0182,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0182,0x017c,0x0100,0x0100,0x0100,0x0100},
  /*e*/  {000000,000000,000000,000000,0x007c,0x0002,0x0001,0x0001,0x01ff,
          0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  /*f*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x007c,0x0010,0x0010,0x0010,0x0110,0x00a0,0x0040},
  /*g*/  {0x007c,0x0082,0x0101,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  /*h*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
          0x0103,0x0103,0x0085,0x0079,0x0001,0x0001,0x0001,0x0001},
  /*i*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0018,000000,000000,0x0018,0x0018,000000},
  /*j*/  {0x003c,0x0042,0x0081,0x0080,0x0080,0x0080,0x0080,0x0080,0x0080,
          0x0080,0x0080,0x00c0,000000,000000,0x00c0,0x00c0,000000},
  /*k*/  {000000,000000,000000,000000,0x0082,0x0042,0x0022,0x0012,0x000a,
          0x0016,0x0022,0x0042,0x0002,0x0002,0x0002,0x0002,0x0002},
  /*l*/  {000000,000000,000000,000000,0x007c,0x0010,0x0010,0x0010,0x0010,
          0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x001c},
  /*m*/  {000000,000000,000000,000000,0x0111,0x0111,0x0111,0x0111,0x0111,
          0x0111,0x0111,0x00ab,0x0045,000000,000000,000000,000000},
  /*n*/  {000000,000000,000000,000000,0x0101,0x0101,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  /*o*/  {000000,000000,000000,000000,0x007c,0x0082,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0082,0x007c,000000,000000,000000,000000},
  /*p*/  {0x0001,0x0001,0x0001,0x0001,0x007d,0x0003,0x0081,0x0101,0x0101,
          0x0101,0x0101,0x0083,0x007d,000000,000000,000000,000000},
  /*q*/  {0x0100,0x0100,0x0100,0x0100,0x017c,0x0182,0x0101,0x0101,0x0101,
          0x0101,0x0101,0x0182,0x017c,000000,000000,000000,000000},
  /*r*/  {000000,000000,000000,000000,0x0001,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x0103,0x0085,0x0079,000000,000000,000000,000000},
  /*s*/  {000000,000000,000000,000000,0x007e,0x0081,0x0100,0x0080,0x007c,
          0x0002,0x0001,0x0102,0x00fc,000000,000000,000000,000000},
  /*t*/  {000000,000000,000000,000000,0x0040,0x00a0,0x0110,0x0010,0x0010,
          0x0010,0x0010,0x0010,0x00fe,0x0010,0x0010,0x0010,0x0010},
  /*u*/  {000000,000000,000000,000000,0x013c,0x0142,0x0181,0x0101,0x0101,
          0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  /*v*/  {000000,000000,000000,000000,0x0010,0x0028,0x0044,0x0082,0x0101,
          0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  /*w*/  {000000,000000,000000,000000,0x0044,0x00aa,0x0111,0x0111,0x0101,
          0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  /*x*/  {000000,000000,000000,000000,0x0101,0x0082,0x0044,0x0028,0x0010,
          0x0028,0x0044,0x0082,0x0101,000000,000000,000000,000000},
  /*y*/  {0x007c,0x0082,0x0101,0x0100,0x0100,0x01fc,0x0102,0x0101,0x0101,
          0x0101,0x0101,0x0101,0x0101,000000,000000,000000,000000},
  /*z*/  {000000,000000,000000,000000,0x01ff,0x0002,0x0004,0x0008,0x0010,
          0x0020,0x0040,0x0080,0x01ff,000000,000000,000000,000000},
  /*{*/  {000000,000000,000000,000000,0x00c0,0x0020,0x0010,0x0010,0x0010,
          0x0008,0x0004,0x0008,0x0010,0x0010,0x0010,0x0020,0x00c0},
  /*|*/  {000000,000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010,
          000000,000000,000000,0x0010,0x0010,0x0010,0x0010,0x0010},
  /*}*/  {000000,000000,000000,000000,0x0006,0x0008,0x0010,0x0010,0x0010,
          0x0020,0x0040,0x0020,0x0010,0x0010,0x0010,0x0008,0x0006},
  /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,0x0040,0x00a0,0x0111,0x000a,0x0004},
  /*DEL*/{000000,000000,000000,000000,0x0155,000000,0x0155,000000,0x0155,
          000000,0x0155,000000,0x0155,000000,0x0155,000000,0x0155},
};

/* 13x25 font, bottom row first, left pixel in lsb */
char_row FAR fnt13x25[FNT_CHARS][FNT13X25_VBITS] = {
  /* */  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000},
  /*!*/  {000000,000000,000000,000000,000000,0x00e0,0x00e0,0x00e0,000000,
          000000,000000,0x0040,0x0040,0x0040,0x0040,0x0040,0x00e0,0x00e0,
          0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x00e0,0x0040},
  /*"*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000,000000,
          0x0208,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  /*#*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0208,0x0208,
          0x0208,0x0208,0x0208,0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,
          0x1fff,0x0208,0x0208,0x0208,0x0208,0x0208,0x0208},
  /*$*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
          0x03f8,0x0444,0x0842,0x0840,0x0840,0x0440,0x03f8,0x0044,0x0042,
          0x0042,0x0842,0x0444,0x03f8,0x0040,0x0040,0x0040},
  /*%*/  {000000,000000,000000,000000,000000,000000,0x0c00,0x1200,0x1201,
          0x0c01,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
          0x0200,0x0400,0x0800,0x1006,0x1009,0x0009,0x0006},
  /*&*/  {000000,000000,000000,000000,000000,000000,0x1078,0x1084,0x0902,
          0x0601,0x0601,0x0901,0x1081,0x0042,0x0024,0x0018,0x0018,0x0024,
          0x0042,0x0042,0x0042,0x0042,0x0024,0x0018,000000},
  /*'*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,0x0001,0x0002,0x0004,0x0008,
          0x0010,0x0030,0x0078,0x0078,0x0078,0x0030,000000},
  /*(*/  {000000,000000,000000,000000,000000,000000,0x0080,0x0040,0x0020,
          0x0020,0x0010,0x0008,0x0008,0x0004,0x0004,0x0004,0x0004,0x0004,
          0x0008,0x0008,0x0010,0x0020,0x0020,0x0040,0x0080},
  /*)*/  {000000,000000,000000,000000,000000,000000,0x0020,0x0040,0x0080,
          0x0080,0x0100,0x0200,0x0200,0x0400,0x0400,0x0400,0x0400,0x0400,
          0x0200,0x0200,0x0100,0x0080,0x0080,0x0040,0x0020},
  /***/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
          0x1041,0x0842,0x0444,0x0248,0x0150,0x00e0,0x1fff,0x00e0,0x0150,
          0x0248,0x0444,0x0842,0x1041,0x0040,0x0040,0x0040},
  /*+*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x1fff,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,000000,000000,000000},
  /*,*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
          0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000},
  /*-*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
          000000,000000,000000,000000,000000,000000,000000},
  /*.*/  {000000,000000,000000,000000,000000,000000,000000,0x0038,0x007c,
          0x007c,0x007c,0x0038,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000},
  /*-/-*/{000000,000000,000000,000000,000000,000000,000000,000000,0x0001,
          0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
          0x0200,0x0400,0x0800,0x1000,0x1000,000000,000000},
  /*0*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1003,0x1005,0x1009,0x1011,0x1021,0x1041,0x1081,0x1101,
          0x1201,0x1401,0x1801,0x1001,0x0802,0x0404,0x03f8},
  /*1*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0048,0x0070,0x0060,0x0040},
  /*2*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0002,0x03fc,0x0400,0x0800,0x1000,
          0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  /*3*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03e0,0x0400,0x0800,
          0x1000,0x1000,0x1000,0x1001,0x0802,0x0404,0x03f8},
  /*4*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0200,0x0200,
          0x0200,0x0200,0x0200,0x0200,0x1fff,0x0201,0x0201,0x0202,0x0204,
          0x0208,0x0210,0x0220,0x0240,0x0280,0x0300,0x0200},
  /*5*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x0800,0x0400,0x03ff,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  /*6*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff,0x0001,0x0001,
          0x0001,0x0001,0x0002,0x0004,0x0808,0x0410,0x03e0},
  /*7*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
          0x0002,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
          0x0200,0x0400,0x0800,0x0800,0x1000,0x1000,0x1fff},
  /*8*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*9*/  {000000,000000,000000,000000,000000,000000,0x00f8,0x0104,0x0202,
          0x0400,0x0800,0x1000,0x1000,0x1000,0x1000,0x1ff8,0x1004,0x1002,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*:*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x0030,
          0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
          0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  /*;*/  {000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0030,0x0078,
          0x0078,0x0078,0x0030,000000,000000,000000,000000,000000,000000,
          0x0030,0x0078,0x0078,0x0030,000000,000000,000000},
  /*<*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0100,0x0080,
          0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200},
  /*=*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,0x1fff,000000,000000,000000,000000,000000,
          0x1fff,000000,000000,000000,000000,000000,000000},
  /*>*/  {000000,000000,000000,000000,000000,000000,0x0008,0x0010,0x0020,
          0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,0x1000,0x0800,0x0400,
          0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008},
  /*?*/  {000000,000000,000000,000000,000000,0x0040,0x00e0,0x0040,000000,
          000000,000000,0x0040,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
          0x1000,0x1000,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*@*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0002,
          0x0001,0x0001,0x0ee1,0x1111,0x1111,0x1111,0x1111,0x1111,0x12e1,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*A*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,0x1001,0x1001,0x0802,
          0x0802,0x0404,0x0208,0x0110,0x00a0,0x00a0,0x0040},
  /*B*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
          0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03f8,0x0408,0x0808,
          0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  /*C*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  /*D*/  {000000,000000,000000,000000,000000,000000,0x03ff,0x0408,0x0808,
          0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,0x1008,
          0x1008,0x1008,0x1008,0x1008,0x0808,0x0408,0x03ff},
  /*E*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  /*F*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x007f,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1fff},
  /*G*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x1004,0x1002,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1f01,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0002,0x1004,0x0ff8},
  /*H*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1fff,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  /*I*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8},
  /*J*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
          0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1e00},
  /*K*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
          0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x000f,0x0009,0x0011,
          0x0021,0x0041,0x0081,0x0101,0x0201,0x0401,0x0801},
  /*L*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x1001,0x1001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  /*M*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1041,0x1041,0x10a1,
          0x10a1,0x1111,0x1209,0x1209,0x1405,0x1803,0x1001},
  /*N*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1801,0x1401,0x1201,0x1201,0x1101,0x1081,0x1041,0x1041,
          0x1021,0x1011,0x1009,0x1009,0x1005,0x1003,0x1001},
  /*O*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*P*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03ff,0x0401,0x0801,
          0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  /*Q*/  {000000,000000,000000,000000,0x0c00,0x0200,0x03f8,0x0494,0x0862,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,0x03f8},
  /*R*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0801,0x0401,
          0x0201,0x0101,0x0081,0x0041,0x0021,0x0011,0x03ff,0x0401,0x0801,
          0x1001,0x1001,0x1001,0x1001,0x0801,0x0401,0x03ff},
  /*S*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1000,0x1000,0x1000,0x0800,0x0400,0x03f8,0x0004,0x0002,
          0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,0x03f8},
  /*T*/  {000000,000000,000000,000000,000000,000000,0x00e0,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x1041,0x1fff},
  /*U*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  /*V*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x00a0,
          0x00a0,0x0110,0x0110,0x0208,0x0208,0x0404,0x0404,0x0802,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  /*W*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1803,
          0x1405,0x1405,0x1209,0x1209,0x1111,0x1111,0x10a1,0x1041,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001},
  /*X*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x0802,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,
          0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001},
  /*Y*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x00a0,0x0110,0x0208,
          0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001},
  /*Z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0001,0x0001,
          0x0002,0x0004,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,
          0x0200,0x0400,0x0400,0x0800,0x1000,0x1000,0x1fff},
  /*[*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0008,0x0008,
          0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,
          0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x03f8},
  /*\*/  {000000,000000,000000,000000,000000,000000,000000,000000,0x1000,
          0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,
          0x0008,0x0004,0x0002,0x0001,0x0001,000000,000000},
  /*]*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0200,0x0200,
          0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
          0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,0x03f8},
  /*^*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000,000000,
          0x1001,0x0802,0x0404,0x0208,0x0110,0x00a0,0x0040},
  /*_*/  {000000,000000,000000,000000,000000,000000,0x1fff,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000},
  /*`*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,0x0400,0x0200,0x0100,0x0080,
          0x0040,0x0060,0x00f0,0x00f0,0x00f0,0x0060,000000},
  /*a*/  {000000,000000,000000,000000,000000,000000,0x17f8,0x0804,0x0802,
          0x0802,0x0802,0x0804,0x0ff8,0x0800,0x0800,0x0800,0x0800,0x0404,
          0x03f8,000000,000000,000000,000000,000000,000000},
  /*b*/  {000000,000000,000000,000000,000000,000000,0x03f9,0x0405,0x0803,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
          0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  /*c*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0802,0x0404,
          0x03f8,000000,000000,000000,000000,000000,000000},
  /*d*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
          0x13f8,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000},
  /*e*/  {000000,000000,000000,000000,000000,000000,0x0ff8,0x0004,0x0002,
          0x0001,0x0001,0x0001,0x1fff,0x1001,0x1001,0x1001,0x0802,0x0404,
          0x03f8,000000,000000,000000,000000,000000,000000},
  /*f*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x03f8,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x1040,0x0880,0x0500,0x0200},
  /*g*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x13f8,0x1404,0x1802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
          0x13f8,000000,000000,000000,000000,000000,000000},
  /*h*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
          0x03f9,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
  /*i*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070,
          000000,000000,000000,0x00e0,0x00e0,0x00e0,000000},
  /*j*/  {0x00f0,0x0108,0x0204,0x0402,0x0400,0x0400,0x0400,0x0400,0x0400,
          0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0700,
          000000,000000,000000,0x0700,0x0700,0x0700,000000},
  /*k*/  {000000,000000,000000,000000,000000,000000,0x0804,0x0404,0x0204,
          0x0104,0x0084,0x0044,0x0024,0x0014,0x002c,0x0044,0x0084,0x0104,
          0x0204,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004},
  /*l*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0070},
  /*m*/  {000000,000000,000000,000000,000000,000000,0x1041,0x1041,0x1041,
          0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x1041,0x08a3,0x0515,
          0x0209,000000,000000,000000,000000,000000,000000},
  /*n*/  {000000,000000,000000,000000,000000,000000,0x1001,0x1001,0x1001,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
          0x03f9,000000,000000,000000,000000,000000,000000},
  /*o*/  {000000,000000,000000,000000,000000,000000,0x03f8,0x0404,0x0802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0802,0x0404,
          0x03f8,000000,000000,000000,000000,000000,000000},
  /*p*/  {0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x03f9,0x0405,0x0803,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x0803,0x0405,
          0x03f9,000000,000000,000000,000000,000000,000000},
  /*q*/  {0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x13f8,0x1404,0x1802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1802,0x1404,
          0x13f8,000000,000000,000000,000000,000000,000000},
  /*r*/  {000000,000000,000000,000000,000000,000000,0x0001,0x0001,0x0001,
          0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x1001,0x0803,0x0405,
          0x03f9,000000,000000,000000,000000,000000,000000},
  /*s*/  {000000,000000,000000,000000,000000,000000,0x03fc,0x0402,0x0800,
          0x0800,0x0800,0x0400,0x03f8,0x0004,0x0002,0x0002,0x0002,0x0804,
          0x07f8,000000,000000,000000,000000,000000,000000},
  /*t*/  {000000,000000,000000,000000,000000,000000,0x0200,0x0500,0x0880,
          0x1040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
          0x07fc,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  /*u*/  {000000,000000,000000,000000,000000,000000,0x13f8,0x1404,0x1802,
          0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,000000,000000,000000,000000,000000,000000},
  /*v*/  {000000,000000,000000,000000,000000,000000,0x0040,0x00a0,0x0110,
          0x0208,0x0404,0x0802,0x0802,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,000000,000000,000000,000000,000000,000000},
  /*w*/  {000000,000000,000000,000000,000000,000000,0x0208,0x0514,0x08a2,
          0x08a2,0x1041,0x1041,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,000000,000000,000000,000000,000000,000000},
  /*x*/  {000000,000000,000000,000000,000000,000000,0x1001,0x0802,0x0404,
          0x0208,0x0110,0x00a0,0x0040,0x00a0,0x0110,0x0208,0x0404,0x0802,
          0x1001,000000,000000,000000,000000,000000,000000},
  /*y*/  {0x03f8,0x0404,0x0802,0x1001,0x1000,0x1000,0x1000,0x1000,0x1ff8,
          0x1004,0x1002,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
          0x1001,000000,000000,000000,000000,000000,000000},
  /*z*/  {000000,000000,000000,000000,000000,000000,0x1fff,0x0002,0x0004,
          0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,
          0x1fff,000000,000000,000000,000000,000000,000000},
  /*{*/  {000000,000000,000000,000000,000000,000000,0x0600,0x0100,0x0080,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x0020,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0600},
  /*|*/  {000000,000000,000000,000000,000000,000000,0x0040,0x0040,0x0040,
          0x0040,0x0040,0x0040,0x0040,000000,000000,000000,000000,000000,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040},
  /*}*/  {000000,000000,000000,000000,000000,000000,0x000c,0x0010,0x0020,
          0x0040,0x0040,0x0040,0x0040,0x0040,0x0080,0x0100,0x0080,0x0040,
          0x0040,0x0040,0x0040,0x0040,0x0020,0x0010,0x000c},
  /*~*/  {000000,000000,000000,000000,000000,000000,000000,000000,000000,
          000000,000000,000000,000000,000000,000000,000000,000000,000000,
          0x0600,0x0900,0x1080,0x1041,0x0021,0x0012,0x000c},
  /*DEL*/{000000,000000,000000,000000,000000,000000,0x1249,000000,000000,
          0x1249,000000,000000,0x1249,000000,000000,0x1249,000000,000000,
          0x1249,000000,000000,0x1249,000000,000000,0x1249},
};

/*
** The plotting area is defined as a huge bitmap.
** The bitmap is stored in a dynamically allocated pixel array b_p
**
** The bitmap is allocated (and initialized to zero) with
** b_makebitmap(xsize, ysize, planes)
** and freed with b_freebitmap()
** xsize and ysize will be rounded up to a multiple of 8.
**
** Valid (int) coordinates range from zero to (xsize-1,ysize-1)
**
** Plotting is done via b_move(x, y) and b_vector(x, y) functions,
** where the point (x,y) is the target to go from the current point
** To set the color use b_setvalue(value) where value is the value 
** (0 or 1 or a color number) to be stored in every pixel.
** To get dotted line styles, use b_setlinetype(linetype).
**
** Internally all plotting goes through b_setpixel(x, y, value).
*/


/*
** set pixel (x, y, value) to value value (this can be 1/0 or a color number).
*/
void
b_setpixel(x, y, value)
unsigned int x, y, value;
{
  register unsigned int row;
  register unsigned char mask;
  int i;
  if (b_rastermode) {
	/* interchange so that new (x,y) is old (y,b_ysize-1-x) */
	row = x;  /* temp storage */
	x = y;
	y = b_ysize-1-row;
  }
  if (IN(x, b_xsize) && IN(y, b_ysize))
  {
    row = y/8;
    mask = 1<<(y%8);

	for (i=0; i<b_planes; i++) {
		if (value&1)
			*((*b_p)[row]+x) |= mask;
		else
			*((*b_p)[row]+x) &= ~mask;
		row += b_psize;
		value >>= 1;
	}
  }
#ifdef BITMAPDEBUG
  else
  {
    if (b_rastermode)
      fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n", 
		b_ysize-1-y, x, value);
    else
      fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n",
		x, y, value);
  }
#endif
}

/*
** get pixel (x,y) value----unused
*/
/****************************
unsigned int
b_getpixel(x, y)
unsigned int x, y;
{
  register unsigned int row;
  register unsigned char mask;
  register unsigned char value;
  int i;

  if (b_rastermode) {
	row = x;
	x = y;
	y = b_ysize-1-row;
  }
  if (IN(x, b_xsize) && IN(y, b_ysize))
  {
    row = y/8 + (b_planes-1)*b_psize;
    mask = 1<<(y%8);

	for (i=0; i<b_planes; i++) {
		if ( *((*b_p)[row]+x) & mask )
			value |= 1;
		row -= b_psize;
		value <<= 1;
	}
    return(value);
  }
  else
  {
#ifdef BITMAPDEBUG
    if (b_rastermode)
      fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n",
		b_ysize-1-y, x);
    else
      fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n", x, y);
#endif
    return(0);
  }
}
********************************/

/*
** allocate the bitmap
*/
void
b_makebitmap(x, y, planes)
unsigned int x, y, planes;
{
  register unsigned j;
  unsigned rows;

  x = 8 * (unsigned int)(x/8.0+0.9);	/* round up to multiple of 8 */
  y = 8 * (unsigned int)(y/8.0+0.9);	/* round up to multiple of 8 */
  b_psize = y/8;					/* size of each plane */
  rows = b_psize * planes;			/* total number of rows of 8 pixels high */
  b_xsize = x; b_ysize = y;
  b_currx = b_curry = 0;
  b_planes = planes;
  b_value = 1;
  b_angle = 0;
  b_rastermode = 0;
  /* allocate row pointers */
  b_p = (bitmap *)alloc( rows * sizeof(pixels *), "bitmap row buffer");
  bzero(b_p, rows * sizeof(pixels *));
  for (j = 0; j < rows; j++) {
    /* allocate bitmap buffers */
    (*b_p)[j] = (pixels *)alloc(x * sizeof(pixels),(char *)NULL);
    if ((*b_p)[j] == (pixels *)NULL) {
		b_freebitmap();  /* free what we have already allocated */
		int_error("out of memory for bitmap buffer", NO_CARET);
	}
    bzero((*b_p)[j], x * sizeof(pixels));
  }
}
  
/*
** free the allocated bitmap
*/
void
b_freebitmap()
{
  int j;
  unsigned rows;

  rows = b_psize * b_planes;   /* total number of rows of 8 pixels high */
  for (j = 0; j < rows; j++)
  {
    (void) free((char *)(*b_p)[j]);
  }
  (void) free((char *)b_p);
  b_p = (bitmap *)(NULL);
}

/*
** set pixel at (x,y) with color b_value and dotted mask b_linemask.
*/
void
b_setmaskpixel(x,y,value)
unsigned int x,y,value;
{
	/* dotted line generator */
	if ((b_linemask>>b_maskcount)&(unsigned int)(1)) {
		b_setpixel(x,y,value);
	}
	b_maskcount= (b_maskcount+1) % 16;
	b_lastx= x;  /* last pixel set with mask */
	b_lasty= y;
}

/*
** draw a line from (x1,y1) to (x2,y2)
** with color b_value and dotted mask b_linemask.
*/
void
b_line(x1,y1,x2,y2)
unsigned int x1,y1,x2,y2;
{
int runcount;
int dx,dy;
int xinc,yinc;
unsigned int xplot,yplot;

	runcount=0;
	dx = abs((int)(x1)-(int)(x2));
	if (x2>x1)  xinc=  1;
	if (x2==x1) xinc=  0;
	if (x2<x1)  xinc= -1;
	dy = abs((int)(y1)-(int)(y2));
	if (y2>y1)  yinc=  1;
	if (y2==y1) yinc=  0;
	if (y2<y1)  yinc= -1;
	xplot=x1;
	yplot=y1;
	if (dx>dy) {
		/* iterate x */
		if ( (b_linemask==0xffff) ||
			((xplot!=b_lastx) && (yplot!=b_lasty)) )
			b_setmaskpixel(xplot,yplot,b_value);
		while (xplot!=x2) {
			xplot+=xinc;
			runcount+=dy;
			if (runcount>=(dx-runcount)) {
				yplot+=yinc;
				runcount-=dx;
			}
			b_setmaskpixel(xplot,yplot,b_value);
		}
	} else {
		/* iterate y */
		if ( (b_linemask==0xffff) ||
			((xplot!=b_lastx) && (yplot!=b_lasty)) )
			b_setmaskpixel(xplot,yplot,b_value);
		while (yplot!=y2) {
			yplot+=yinc;
			runcount+=dx;
			if (runcount>=(dy-runcount)) {
				xplot+=xinc;
				runcount-=dy;
			}
			b_setmaskpixel(xplot,yplot,b_value);
		}
	}
}

/*
** set character size
*/
void
b_charsize(size)
unsigned int size;
{
	int j;
	switch(size) {
		case FNT5X9:
			b_hchar = FNT5X9_HCHAR;
			b_hbits = FNT5X9_HBITS;
			b_vchar = FNT5X9_VCHAR;
			b_vbits = FNT5X9_VBITS;
			for (j = 0; j < FNT_CHARS; j++ )
				b_font[j] = &fnt5x9[j][0];
			break;
		case FNT9X17:
			b_hchar = FNT9X17_HCHAR;
			b_hbits = FNT9X17_HBITS;
			b_vchar = FNT9X17_VCHAR;
			b_vbits = FNT9X17_VBITS;
			for (j = 0; j < FNT_CHARS; j++ )
				b_font[j] = &fnt9x17[j][0];
			break;
		case FNT13X25:
			b_hchar = FNT13X25_HCHAR;
			b_hbits = FNT13X25_HBITS;
			b_vchar = FNT13X25_VCHAR;
			b_vbits = FNT13X25_VBITS;
			for (j = 0; j < FNT_CHARS; j++ )
				b_font[j] = &fnt13x25[j][0];
			break;
		default:
			int_error("Unknown character size",NO_CARET);
	}
}


/*
** put characater c at (x,y) rotated by angle with color b_value.
*/
void
b_putc(x,y,c,angle)
unsigned int x,y;
char c;
unsigned int angle;
{
	unsigned int i, j, k;
	char_row fc;

	j = c - ' ';
	for ( i = 0; i < b_vbits; i++ ) {
		fc = *( b_font[j] + i );
		if ( c == '_' ) {	/* treat underline specially */
			if ( fc  ) {	/* this this the underline row ? *?
				/* draw the under line for the full h_char width */
				for ( k = ( b_hbits - b_hchar )/2;
					k < ( b_hbits + b_hchar )/2; k++ ) {
					switch(angle) {
						case 0 : b_setpixel(x+k+1,y+i,b_value);
							break;
						case 1 : b_setpixel(x-i,y+k+1,b_value);
							break;
					}
				}
			}
		}
		else {
			/* draw character */
			for ( k = 0; k < b_hbits; k++ ) {
				if ( ( fc >> k ) & 1 ) {
					switch(angle) {
						case 0 : b_setpixel(x+k+1,y+i,b_value);
							break;
						case 1 : b_setpixel(x-i,y+k+1,b_value);
							break;
					}
				}
			}
		}
	}
}


/*
** set b_linemask to b_pattern[linetype]
*/
int
b_setlinetype(linetype)
int linetype;
{
	if (linetype>=7)
		linetype %= 7;
	b_linemask = b_pattern[linetype+2];
	b_maskcount=0;
}

/*
** set b_value to value
*/
void
b_setvalue(value)
unsigned int value;
{
	b_value = value;
}

/*
** move to (x,y)
*/
int
b_move(x, y)
unsigned int x, y;
{
  b_currx = x;
  b_curry = y;
}

/*
** draw to (x,y) with color b_value
*/
int
b_vector(x, y)
unsigned int x, y;
{
  b_line(b_currx, b_curry, x, y);
  b_currx = x;
  b_curry = y;
}


/*
** put text str at (x,y) with color b_value and rotation b_angle
*/
int
b_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	if (b_angle == 1)
		x += b_vchar/2;
	else
		y -= b_vchar/2;
   switch (b_angle) {
      case 0:
	 for (; *str; ++str, x += b_hchar)
	    b_putc (x, y, *str, b_angle);
					break;
      case 1:
	 for (; *str; ++str, y += b_hchar)
	    b_putc (x, y, *str, b_angle);
					break;
	}
}


int
b_text_angle(ang)
int ang;
{
	b_angle=(unsigned int)ang;
	return TRUE;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/bitmap.h version [e8177ee6a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * $Id: bitmap.h,v 3.26 92/03/24 22:34:16 woo Exp Locker: woo $
 */

/* bitmap.h */

#ifdef __TURBOC__
#define FAR far
#else
#define FAR
#endif

/* allow up to 16 bit width for character array */
typedef unsigned int char_row;
typedef char_row * FAR char_box;

#define FNT_CHARS   96      /* Number of characters in the font set */

#define FNT5X9 0
#define FNT5X9_VCHAR 11 /* vertical spacing between characters */
#define FNT5X9_VBITS 9 /* actual number of rows of bits per char */
#define FNT5X9_HCHAR 7 /* horizontal spacing between characters */
#define FNT5X9_HBITS 5 /* actual number of bits per row per char */
extern char_row FAR fnt5x9[FNT_CHARS][FNT5X9_VBITS];

#define FNT9X17 1
#define FNT9X17_VCHAR 21 /* vertical spacing between characters */
#define FNT9X17_VBITS 17 /* actual number of rows of bits per char */
#define FNT9X17_HCHAR 13 /* horizontal spacing between characters */
#define FNT9X17_HBITS 9 /* actual number of bits per row per char */
extern char_row FAR fnt9x17[FNT_CHARS][FNT9X17_VBITS];

#define FNT13X25 2
#define FNT13X25_VCHAR 31 /* vertical spacing between characters */
#define FNT13X25_VBITS 25 /* actual number of rows of bits per char */
#define FNT13X25_HCHAR 19 /* horizontal spacing between characters */
#define FNT13X25_HBITS 13 /* actual number of bits per row per char */
extern char_row FAR fnt13x25[FNT_CHARS][FNT13X25_VBITS];


typedef unsigned char pixels;  /* the type of one set of 8 pixels in bitmap */
typedef pixels *bitmap[];  /* the bitmap */

extern bitmap *b_p;						/* global pointer to bitmap */
extern unsigned int b_currx, b_curry;	/* the current coordinates */
extern unsigned int b_xsize, b_ysize;	/* the size of the bitmap */
extern unsigned int b_planes;			/* number of color planes */
extern unsigned int b_psize;			/* size of each plane */
extern unsigned int b_rastermode;		/* raster mode rotates -90deg */
extern unsigned int b_linemask;			/* 16 bit mask for dotted lines */
extern unsigned int b_value;			/* colour of lines */
extern unsigned int b_hchar;			/* width of characters */
extern unsigned int b_hbits;			/* actual bits in char horizontally */
extern unsigned int b_vchar;			/* height of characters */
extern unsigned int b_vbits;			/* actual bits in char vertically */
extern unsigned int b_angle;			/* rotation of text */
extern char_box b_font[FNT_CHARS];		/* the current font */
extern unsigned int b_pattern[];
extern int b_maskcount;
extern unsigned int b_lastx, b_lasty;	/* last pixel set - used by b_line */


extern void b_makebitmap();
extern void b_freebitmap();
extern void b_setpixel();
extern unsigned int b_getpixel();
extern void b_line();
extern void b_setmaskpixel();
extern void b_putc();
extern void b_charsize();
extern void b_setvalue();

extern int b_setlinetype();
extern int b_move();
extern int b_vector();
extern int b_put_text();
extern int b_text_angle();

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































Deleted r34.1/plot/buildvms.com version [a3ff70c597].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ ! buildvms.com  (Command file to compile/link gnuplot and doc2hlp)
$ CFLAGS = "/NOOP/define=(NOGAMMA,MEMSET)"
$ !TERMFLAGS = "/define=()"
$ TERMFLAGS = ""
$ set verify
$ cc 'CFLAGS' bitmap.c
$ cc 'CFLAGS' command.c
$ cc 'CFLAGS' contour.c
$ cc 'CFLAGS' eval.c
$ cc 'CFLAGS' graphics.c
$ cc 'CFLAGS' graph3d.c
$ cc 'CFLAGS' internal.c
$ cc 'CFLAGS' misc.c
$ cc 'CFLAGS' parse.c
$ cc 'CFLAGS' plot.c
$ cc 'CFLAGS' scanner.c
$ cc 'CFLAGS' setshow.c
$ cc 'CFLAGS' standard.c
$ cc 'CFLAGS' 'TERMFLAGS' term.c
$ cc 'CFLAGS' util.c
$ cc 'CFLAGS' version.c
$ link /exe=gnuplot -
   bitmap.obj,command.obj,contour.obj,eval.obj,graphics.obj,graph3d.obj, -
   internal.obj,misc.obj,parse.obj,plot.obj,scanner.obj,setshow.obj, -
   standard.obj,term.obj,util.obj,version.obj ,linkopt.vms/opt
$ cc [.docs]doc2hlp.c
$ link doc2hlp,linkopt.vms/opt
$ @[.docs]doc2hlp.com
$ library/create/help gnuplot.hlb gnuplot.hlp
$ set noverify
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































Deleted r34.1/plot/command.c version [54411f3cdb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
#ifndef lint
static char *RCSid = "$Id: command.c,v 3.26 92/03/24 22:34:17 woo Exp Locker: woo $";
#endif

/* GNUPLOT - command.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <math.h>

#ifdef AMIGA_AC_5
#include <time.h>
void sleep();		/* defined later */
#endif

#ifdef MSDOS
#include <process.h>

#ifdef __ZTC__
#define P_WAIT 0
#include <time.h>	/* usleep() */
#else

#ifdef __TURBOC__
#include <dos.h>	/* sleep() */
#include <conio.h>
extern unsigned _stklen = 16394;	/* increase stack size */

#else	/* must be MSC */
#include <time.h>	/* kludge to provide sleep() */
void sleep();		/* defined later */
#endif /* TURBOC */
#endif /* ZTC */

#endif /* MSDOS */

#ifdef AMIGA_LC_5_1
#include <proto/dos.h>
void sleep();
#endif	/* AMIGA_LC_5_1 */

#include "plot.h"
#include "setshow.h"
#include "help.h"

#ifndef STDOUT
#define STDOUT 1
#endif

#ifndef HELPFILE
#ifdef AMIGA_LC_5_1
#define HELPFILE "S:gnuplot.gih"
#else
#define HELPFILE "docs/gnuplot.gih" /* changed by makefile */
#endif /* AMIGA_LC_5_1 */
#endif /* HELPFILE */

#define inrange(z,min,max) ((min<max) ? ((z>=min)&&(z<=max)) : ((z>=max)&&(z<=min)) )

/*
 * instead of <strings.h>
 */

extern char *gets(),*getenv();
extern char *strcpy(),*strncpy(),*strcat();
extern int strlen(), strcmp();

/*
 * Only reference to contours library.
 */
extern struct gnuplot_contours *contour();

#if defined(unix) && !defined(hpux)
#ifdef GETCWD
extern char *getcwd();	/* some Unix's use getcwd */
#else
extern char *getwd();	/* most Unix's use getwd */
#endif
#else
extern char *getcwd();	/* Turbo C, MSC and VMS use getcwd */
#endif

#ifdef vms
int vms_vkid; /* Virtual keyboard id */
#endif

#ifdef unix
extern FILE *popen();
static BOOLEAN pipe_open=FALSE;
#endif

extern int chdir();

extern double magnitude(),angle(),real(),imag();
extern struct value *const_express(), *pop(), *complex();
extern struct at_type *temp_at(), *perm_at();
extern struct udft_entry *add_udf();
extern struct udvt_entry *add_udv();
extern void squash_spaces();
extern void lower_case();

/* local functions */
static enum coord_type adjustlog();

extern BOOLEAN interactive;	/* from plot.c */

/* input data, parsing variables */
struct lexical_unit token[MAX_TOKENS];
char input_line[MAX_LINE_LEN+1] = "";
int num_tokens, c_token;
int inline_num = 0;			/* input line number */

char c_dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1];	/* current dummy vars */

/* the curves/surfaces of the plot */
struct curve_points *first_plot = NULL;
struct surface_points *first_3dplot = NULL;
static struct udft_entry plot_func;
struct udft_entry *dummy_func;

/* support for replot command */
char replot_line[MAX_LINE_LEN+1] = "";
static int plot_token;					/* start of 'plot' command */

/* If last plot was a 3d one. */
BOOLEAN is_3d_plot = FALSE;

com_line()
{
	read_line(PROMPT);

	/* So we can flag any new output: if false at time of error, */
	/* we reprint the command line before printing caret. */
	/* TRUE for interactive terminals, since the command line is typed. */
	/* FALSE for non-terminal stdin, so command line is printed anyway. */
	/* (DFK 11/89) */
	screen_ok = interactive; 

	do_line();
}


do_line()	  /* also used in load_file */
{
	if (is_system(input_line[0])) {
		do_system();
		(void) fputs("!\n",stderr);
		return;
	}
	num_tokens = scanner(input_line);
	c_token = 0;
	while(c_token < num_tokens) {
		command();
		if (c_token < num_tokens)	/* something after command */
			if (equals(c_token,";"))
				c_token++;
			else
					int_error("';' expected",c_token);
	}
}



command()
{
    int i;
    char sv_file[MAX_LINE_LEN+1];
    /* string holding name of save or load file */

	for (i = 0; i < MAX_NUM_VAR; i++)
	    c_dummy_var[i][0] = '\0';		/* no dummy variables */

	if (is_definition(c_token))
		define();
	else if (almost_equals(c_token,"h$elp") || equals(c_token,"?")) {
	    c_token++;
	    do_help();
	}
	else if (almost_equals(c_token,"test")) {
	    c_token++;
		test_term();
	}
	else if (almost_equals(c_token,"pa$use")) {
		struct value a;
		int stime, text=0;
		char buf[MAX_LINE_LEN+1];

		c_token++;
		stime = (int )real(const_express(&a));
		if (!(END_OF_COMMAND)) {
			if (!isstring(c_token))
				int_error("expecting string",c_token);
			else {
				quotel_str(buf,c_token);
				(void) fprintf (stderr, "%s",buf);
				text = 1;
			}
		}
		if (stime < 0) (void) fgets (buf,MAX_LINE_LEN,stdin);  
						/* Hold until CR hit. */
#ifdef __ZTC__
		if (stime > 0) usleep((unsigned long) stime);
#else
		if (stime > 0) sleep((unsigned int) stime);
#endif
		if (text != 0 && stime >= 0) (void) fprintf (stderr,"\n");
		c_token++;
		screen_ok = FALSE;
	}
	else if (almost_equals(c_token,"pr$int")) {
		struct value a;

		c_token++;
		(void) const_express(&a);
		(void) putc('\t',stderr);
		disp_value(stderr,&a);
		(void) putc('\n',stderr);
		screen_ok = FALSE;
	}
	else if (almost_equals(c_token,"p$lot")) {
		plot_token = c_token++;
		plotrequest();
	}
	else if (almost_equals(c_token,"sp$lot")) {
		plot_token = c_token++;
		plot3drequest();
	}
	else if (almost_equals(c_token,"rep$lot")) {
		if (replot_line[0] == '\0') 
			int_error("no previous plot",c_token);
		c_token++;
		replotrequest();
	}
	else if (almost_equals(c_token,"se$t"))
		set_command();
	else if (almost_equals(c_token,"sh$ow"))
		show_command();
	else if (almost_equals(c_token,"cl$ear")) {
		if (!term_init) {
			(*term_tbl[term].init)();
			term_init = TRUE;
		}
		(*term_tbl[term].graphics)();
		(*term_tbl[term].text)();
		(void) fflush(outfile);
		screen_ok = FALSE;
		c_token++;
	}
	else if (almost_equals(c_token,"she$ll")) {
		do_shell();
		screen_ok = FALSE;
		c_token++;
	}
	else if (almost_equals(c_token,"sa$ve")) {
		if (almost_equals(++c_token,"f$unctions")) {
			if (!isstring(++c_token))
				int_error("expecting filename",c_token);
			else {
				quote_str(sv_file,c_token);
				save_functions(fopen(sv_file,"w"));
			}
		}
		else if (almost_equals(c_token,"v$ariables")) {
			if (!isstring(++c_token))
				int_error("expecting filename",c_token);
			else {
				quote_str(sv_file,c_token);
				save_variables(fopen(sv_file,"w"));
			}
		}
		else if (almost_equals(c_token,"s$et")) {
			if (!isstring(++c_token))
				int_error("expecting filename",c_token);
			else {
				quote_str(sv_file,c_token);
				save_set(fopen(sv_file,"w"));
			}
		}
		else if (isstring(c_token)) {
			quote_str(sv_file,c_token);
			save_all(fopen(sv_file,"w"));
		}
		else {
			int_error(
		"filename or keyword 'functions', 'variables', or 'set' expected",
					c_token);
		}
		c_token++;
	}
	else if (almost_equals(c_token,"l$oad")) {
		if (!isstring(++c_token))
			int_error("expecting filename",c_token);
		else {
			quote_str(sv_file,c_token);
			load_file(fopen(sv_file,"r"), sv_file);	
		/* input_line[] and token[] now destroyed! */
			c_token = num_tokens = 0;
		}
	}
	else if (almost_equals(c_token,"cd")) {
		if (!isstring(++c_token))
			int_error("expecting directory name",c_token);
		else {
			quotel_str(sv_file,c_token);
			if (chdir(sv_file)) {
			  int_error("Can't change to this directory",c_token);
			}
		c_token++;
		}
	}
	else if (almost_equals(c_token,"pwd")) {
#if defined(unix) && !defined(hpux)
#ifdef GETCWD
	  (void) getcwd(sv_file,MAX_ID_LEN); /* some Unix's use getcwd */
#else
	  (void) getwd(sv_file); /* most Unix's use getwd */
#endif
#else
/* Turbo C and VMS have getcwd() */
	  (void) getcwd(sv_file,MAX_ID_LEN);
#endif
	  fprintf(stderr,"%s\n", sv_file);
	  c_token++;
	}
	else if (almost_equals(c_token,"ex$it") ||
			almost_equals(c_token,"q$uit")) {
		done(IO_SUCCESS);
	}
	else if (!equals(c_token,";")) {		/* null statement */
		int_error("invalid command",c_token);
	}
}

replotrequest()
{
char str[MAX_LINE_LEN+1];
		if(equals(c_token,"["))
			int_error("cannot set range with replot",c_token);
		if (!END_OF_COMMAND) {
			capture(str,c_token,num_tokens-1);
			if ( (strlen(str) + strlen(replot_line)) <= MAX_LINE_LEN-1) {
				(void) strcat(replot_line,",");
				(void) strcat(replot_line,str); 
			} else {
				int_error("plot line too long with replot arguments",c_token);
			}
		}
		(void) strcpy(input_line,replot_line);
		screen_ok = FALSE;
		num_tokens = scanner(input_line);
		c_token = 1;					/* skip the 'plot' part */
		is_3d_plot ? plot3drequest() : plotrequest();
}


plotrequest()
/*
   In the parametric case we can say 
      plot [a= -4:4] [-2:2] [-1:1] sin(a),a**2
   while in the non-parametric case we would say only
      plot [b= -2:2] [-1:1] sin(b)
*/
{
    BOOLEAN changed;
    int dummy_token = -1;

    is_3d_plot = FALSE;

    if (parametric && strcmp(dummy_var[0], "u") == 0)
	strcpy (dummy_var[0], "t");

    autoscale_lt = autoscale_t;
    autoscale_lx = autoscale_x;
    autoscale_ly = autoscale_y;

	if (!term)					/* unknown */
		int_error("use 'set term' to set terminal type first",c_token);

	if (equals(c_token,"[")) {
		c_token++;
		if (isletter(c_token)) {
		    if (equals(c_token+1,"=")) {
			   dummy_token = c_token;
			   c_token += 2;
		    } else {
			   /* oops; probably an expression with a variable. */
			   /* Parse it as an xmin expression. */
			   /* used to be: int_error("'=' expected",c_token); */
		    }
		}
		changed = parametric ? load_range(&tmin,&tmax):load_range(&xmin,&xmax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed) {
			if (parametric)
				autoscale_lt = FALSE;
			else
				autoscale_lx = FALSE;
		}
	}

	if (parametric && equals(c_token,"[")) { /* set optional x ranges */
		c_token++;
		changed = load_range(&xmin,&xmax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed)
		  autoscale_lx = FALSE;
	}

	if (equals(c_token,"[")) { /* set optional y ranges */
		c_token++;
		changed = load_range(&ymin,&ymax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed)
		  autoscale_ly = FALSE;
	}

     /* use the default dummy variable unless changed */
	if (dummy_token >= 0)
	  copy_str(c_dummy_var[0],dummy_token);
	else
	  (void) strcpy(c_dummy_var[0],dummy_var[0]);

	eval_plots();
}

plot3drequest()
/*
   in the parametric case we would say
      splot [u= -Pi:Pi] [v= 0:2*Pi] [-1:1] [-1:1] [-1:1] sin(v)*cos(u),sin(v)*cos(u),sin(u)
   in the non-parametric case we would say only
      splot [x= -2:2] [y= -5:5] sin(x)*cos(y)

*/
{
    BOOLEAN changed;
    int dummy_token0 = -1,
	dummy_token1 = -1;

    is_3d_plot = TRUE;

    if (parametric && strcmp(dummy_var[0], "t") == 0) {
    	strcpy (dummy_var[0], "u");
    	strcpy (dummy_var[1], "v");
    }

    autoscale_lx = autoscale_x;
    autoscale_ly = autoscale_y;
    autoscale_lz = autoscale_z;

	if (!term)					/* unknown */
		int_error("use 'set term' to set terminal type first",c_token);

	if (equals(c_token,"[")) {
		c_token++;
		if (isletter(c_token)) {
		    if (equals(c_token+1,"=")) {
			   dummy_token0 = c_token;
			   c_token += 2;
		    } else {
			   /* oops; probably an expression with a variable. */
			   /* Parse it as an xmin expression. */
			   /* used to be: int_error("'=' expected",c_token); */
		    }
		}
		changed = parametric ? load_range(&umin,&umax):load_range(&xmin,&xmax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed && !parametric) {
			autoscale_lx = FALSE;
		}
	}

	if (equals(c_token,"[")) {
		c_token++;
		if (isletter(c_token)) {
		    if (equals(c_token+1,"=")) {
			   dummy_token1 = c_token;
			   c_token += 2;
		    } else {
			   /* oops; probably an expression with a variable. */
			   /* Parse it as an xmin expression. */
			   /* used to be: int_error("'=' expected",c_token); */
		    }
		}
		changed = parametric ? load_range(&vmin,&vmax):load_range(&ymin,&ymax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed && !parametric) {
			autoscale_ly = FALSE;
		}
	}

	if (equals(c_token,"[")) { /* set optional x ranges */
		c_token++;
		changed = load_range(&xmin,&xmax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed)
		  autoscale_lx = FALSE;
	}

	if (equals(c_token,"[")) { /* set optional y ranges */
		c_token++;
		changed = load_range(&ymin,&ymax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed)
		  autoscale_ly = FALSE;
	}

	if (equals(c_token,"[")) { /* set optional z ranges */
		c_token++;
		changed = load_range(&zmin,&zmax);
		if (!equals(c_token,"]"))
			int_error("']' expected",c_token);
		c_token++;
		if (changed)
		  autoscale_lz = FALSE;
	}

     /* use the default dummy variable unless changed */
	if (dummy_token0 >= 0)
	  copy_str(c_dummy_var[0],dummy_token0);
	else
	  (void) strcpy(c_dummy_var[0],dummy_var[0]);

	if (dummy_token1 >= 0)
	  copy_str(c_dummy_var[1],dummy_token1);
	else
	  (void) strcpy(c_dummy_var[1],dummy_var[1]);

	eval_3dplots();
}


define()
{
register int start_token;  /* the 1st token in the function definition */
register struct udvt_entry *udv;
register struct udft_entry *udf;

	if (equals(c_token+1,"(")) {
		/* function ! */
		start_token = c_token;
		copy_str(c_dummy_var[0], c_token + 2);
		if(equals(c_token+3,",")) {
			copy_str(c_dummy_var[1], c_token + 4);
			c_token += 2;  /* skip the  , dummy2 */
		}
		c_token += 5; /* skip (, dummy, ) and = */
		if (END_OF_COMMAND)
			int_error("function definition expected",c_token);
		udf = dummy_func = add_udf(start_token);
		if (udf->at)				/* already a dynamic a.t. there */
			free((char *)udf->at);	/* so free it first */
		if ((udf->at = perm_at()) == (struct at_type *)NULL)
			int_error("not enough memory for function",start_token);
		m_capture(&(udf->definition),start_token,c_token-1);
	}
	else {
		/* variable ! */
		start_token = c_token;
		c_token +=2;
		udv = add_udv(start_token);
		(void) const_express(&(udv->udv_value));
		udv->udv_undef = FALSE;
	}
}


get_data(this_plot)
struct curve_points *this_plot;
{
register int i, l_num, datum;
register FILE *fp;
float x, y;
float ylow, yhigh;			/* for error bars */
float temp;
BOOLEAN yfirst;
char format[MAX_LINE_LEN+1], data_file[MAX_LINE_LEN+1], line[MAX_LINE_LEN+1];
char *float_format = "%f", *float_skip = "%*f";
int xcol = 1, ycol = 2, yemin = 3, yemax = 4;
struct value colvalue;
#ifdef AMIGA_LC_5_1
int num_perc_ast;
char *start_search;
#endif /* AMIGA_LC_5_1 */

	quote_str(data_file, c_token);
	this_plot->plot_type = DATA;
	if( parametric)
		int_error("Parametric data files not yet implemented",NO_CARET);
#ifdef unix
	if ( *data_file == '<' ) {
	  	if ((fp = popen(data_file+1,"r")) == (FILE *)NULL)
	    	os_error("cannot create pipe; output not changed",c_token);
		else
		    pipe_open = TRUE;
	} else
#endif
	if ((fp = fopen(data_file, "r")) == (FILE *)NULL)
		os_error("can't open data file", c_token);

	format[0] = '\0';
	yfirst = FALSE;
	c_token++;	/* skip data file name */
	if (almost_equals(c_token,"u$sing")) {
		c_token++;  	/* skip "using" */
		if (!END_OF_COMMAND && !isstring(c_token)) {
			struct value a;
			ycol = (int)magnitude(const_express(&a));
			xcol = ycol;
			if (equals(c_token,":")) {
				c_token++;      /* skip ":" */
				ycol = (int)magnitude(const_express(&a));
				if (equals(c_token,":")) {
					c_token++;      /* skip ":" */
					yemin = (int)magnitude(const_express(&a));
					if (equals(c_token,":")) {
						c_token++;      /* skip ":" */
						yemax = (int)magnitude(const_express(&a));
					}
					else
					        yemax = -1;
				}
				else {
				        yemin = -1;
				        yemax = -1;
				}
			}
			else {
			        yemin = -1;
			        yemax = -1;
			}
			if (xcol > ycol) yfirst = TRUE;
		}
		if (!END_OF_COMMAND && isstring(c_token)) {
			quotel_str(format, c_token);
			c_token++;	/* skip format */
		}
	}
	if (strlen(format) == 0) {
		for(i = 1; i <= ((xcol > ycol) ? xcol : ycol); i++)
			if ((i == xcol) || (i == ycol))
				(void) strcat(format,float_format);
			else
				(void) strcat(format,float_skip);

		if (yemin > 0) {
			/* We have error bars - handle them. */
			yemin -= (xcol > ycol) ? xcol : ycol;
			yemax -= (xcol > ycol) ? xcol : ycol;
			if (yemin > yemax && yemax > 0) {
				i = yemin;
				yemin = yemax;
				yemax = i;
			}

			if (yemin == yemax)
				int_error("Two error bar columns are the same",
					  NO_CARET);

			if (yemin <= 0)
				int_error("Error bar columns must follow data columns",
					  NO_CARET);

			for (i = 1; i < yemin; i++)
				(void) strcat(format,float_skip);
			(void) strcat(format,float_format);

			if (yemax > 0) {
				for (i = 1; i < yemax - yemin; i++)
					(void) strcat(format,float_skip);
				(void) strcat(format,float_format);
			}
		}
	}

	l_num = 0;
     datum = 0;
	i = 0;
#ifdef AMIGA_LC_5_1
	num_perc_ast = 0;
	start_search = format;
	while (*start_search != '\0') {
		if (start_search[0] == '%')
			if (start_search[1] == '*') num_perc_ast++;
		start_search++;
	}
#endif /* AMIGA_LC_5_1 */
	while ( fgets(line, MAX_LINE_LEN, fp) != (char *)NULL ) {
		l_num++;
		if (is_comment(line[0]))
			continue;		/* ignore comments */
		if (i >= this_plot->p_max) {
		    /* overflow about to occur. Extend size of points[]
			* array. We either double the size, or add 1000 points,
			* whichever is a smaller increment. Note i=p_max.
			*/
		    cp_extend(this_plot, i + (i < 1000 ? i : 1000));
		}
		if (!line[1]) { /* is it blank line ? */
			/* break in data, make next point undefined */
			this_plot->points[i].type = UNDEFINED;
			i++;
			continue;
		}

#ifdef AMIGA_LC_5_1
		switch (sscanf(line, format, &x, &y, &ylow, &yhigh) -
			 num_perc_ast) {
#else /* AMIGA_LC_5_1 */
		switch (sscanf(line, format, &x, &y, &ylow, &yhigh)) {
#endif /* AMIGA_LC_5_1 */
		    case 1: {		/* only one number on the line */
			   y = x;		/* assign that number to y */
			   x = datum;	/* and make the index into x */
			   /* no break; !!! */
		    }
		    case 2: {
			   if (yfirst) { /* exchange x and y */
				  temp = y;
				  y = x;
				  x = temp;
			   }
			   datum++;

			   /* ylow and yhigh are same as y */
			   store2d_point(this_plot, i++, x, y, y, y);
			   break;
		    }
		    case 3: {		/* x, y, ydelta */
			   if (yfirst) { /* exchange x and y */
				  temp = y;
				  y = x;
				  x = temp;
			   }
			   datum++;

			   /* ydelta is in the ylow variable */
			   store2d_point(this_plot, i++, x, y, y-ylow, y+ylow);
			   break;
		    }
		    case 4: {		/* x, y, ylow, yhigh */
			   if (yfirst) { /* exchange x and y */
				  temp = y;
				  y = x;
				  x = temp;
			   }
			   datum++;

			   store2d_point(this_plot, i++, x, y, ylow, yhigh);
			   break;
		    }
		    default: {
			   (void) sprintf(line, "bad data on line %d", l_num);
			   int_error(line,c_token);
		    }
		}
	}
	this_plot->p_count = i;
	cp_extend(this_plot, i);	/* shrink to fit */

#ifdef unix
	if ( pipe_open ) {
		(void) pclose(fp);
		pipe_open = FALSE;
	} else
#endif
	(void) fclose(fp);
}

/* called by get_data for each point */
store2d_point(this_plot, i, x, y, ylow, yhigh)
struct curve_points *this_plot;
int i;					/* point number */
#ifdef AMIGA_LC_5_1
double x, y;
double ylow, yhigh;
#else
float x, y;
float ylow, yhigh;
#endif
{
    struct coordinate *cp = &(this_plot->points[i]);

    /* the easy part: */
    cp->type = INRANGE;
    cp->x = x;
    cp->y = y;
    cp->ylow = ylow;
    cp->yhigh = yhigh;
    
    /* Adjust for log scale. */
    if (log_x)
	 cp->type = adjustlog(cp->type, &(cp->x));
    if (log_y) {
	   cp->type = adjustlog(cp->type, &(cp->y));
	   /* Note ylow,yhigh can't affect cp->type. */
	   (void)     adjustlog(cp->type, &(cp->ylow));
	   (void)     adjustlog(cp->type, &(cp->yhigh));
    }

    /* Now adjust the xrange, or declare the point out of range */
    /* The yrange is handled later, once we know whether to 
	* include ylow, yhigh in the calculation. See adjust_yrange()
	*/
    if (cp->type == INRANGE)
	 if (autoscale_lx || inrange(x,xmin,xmax)) {
		if (autoscale_lx) {
		    if (x < xmin) xmin = x;
		    if (x > xmax) xmax = x;
		}
	 } else {
		cp->type = OUTRANGE;
	 }
}

/* Adjust for log scale:
 * take the log of the second parameter, in place, if possible. 
 * If not possible, return new type for point; if possible, then 
 * return old type for point.
 */
static enum coord_type
adjustlog(type, val)
	enum coord_type type;
	coordval *val;
{
    if (*val < 0.0) {
	   return(UNDEFINED);
    } else if (*val == 0.0) {
	   *val = -VERYLARGE;
	   return(OUTRANGE);
    } else {
	   *val = log10(*val);
	   return(type);
    }
}


/* now adjust the yrange, or declare the point out of range */
/* this does all points in a curve */
adjust_yrange(curve)
	struct curve_points *curve;
{
    BOOLEAN ebars = (curve->plot_style == ERRORBARS);
    int npoints = curve->p_count; /* number of points */
    coordval y, ylow, yhigh;	/* one point value */
    struct coordinate *cp;	/* one coordinate */
    int i;				/* index into points */

    for (i = 0; i < npoints; i++) {
	   cp = &(curve->points[i]);
	   if (cp->type == INRANGE) {
		  y = log_y ? pow(10.0,cp->y) : cp->y;
		  if ((autoscale_ly ||
		       inrange(y, ymin, ymax) ||
		       polar)) {
			 if (autoscale_ly) {
				if (y < ymin) ymin = y;
				if (y > ymax) ymax = y;
				if (ebars) {
				    ylow =  log_y ? pow(10.0,cp->ylow)  : cp->ylow;
				    yhigh = log_y ? pow(10.0,cp->yhigh) : cp->yhigh;
				    if (ylow < ymin) ymin = ylow;
				    if (ylow > ymax) ymax = ylow;
				    if (yhigh < ymin) ymin = yhigh;
				    if (yhigh > ymax) ymax = yhigh;
				}
			 }
		  } else {
			 cp->type = OUTRANGE;
		  }
	   }
    }
}


get_3ddata(this_plot)
struct surface_points *this_plot;
{
register int i, j, l_num, xdatum, ydatum;
register FILE *fp;
float x, y, z;
BOOLEAN only_z = FALSE;
char format[MAX_LINE_LEN+1], data_file[MAX_LINE_LEN+1], line[MAX_LINE_LEN+1];
char *float_format = "%f", *float_skip = "%*f";
int xcol = 1, ycol = 2, zcol = 3, pt_in_iso_crv = 0, maxcol;
enum XYZ_order_type {XYZ, YXZ, ZXY, XZY, ZYX, YZX, XY, YX} xyz_order;
struct iso_curve *this_iso;
#ifdef AMIGA_LC_5_1
int num_perc_ast;
char *start_search;
#endif /* AMIGA_LC_5_1 */
	    
	quote_str(data_file, c_token);
	this_plot->plot_type = DATA3D;
	this_plot->has_grid_topology = TRUE;
#ifdef unix
	if ( *data_file == '<' ) {
		if ((fp = popen(data_file+1,"r")) == (FILE *)NULL)
		    os_error("cannot create pipe; output not changed",c_token);
	  	else
		    pipe_open = TRUE;
	} else
#endif
	if ((fp = fopen(data_file, "r")) == (FILE *)NULL)
		os_error("can't open data file", c_token);

	format[0] = '\0';
	c_token++;	/* skip data file name */
	if (almost_equals(c_token,"u$sing")) {
		c_token++;  	/* skip "using" */
		if (!END_OF_COMMAND && !isstring(c_token)) {
			struct value a;
			zcol = (int)magnitude(const_express(&a));
			only_z = TRUE;
			if (equals(c_token,":")) {
				c_token++;	/* skip ":" */
				only_z = FALSE;
				ycol = zcol;
				zcol = (int)magnitude(const_express(&a));
				if (equals(c_token,":")) {
					c_token++;	/* skip ":" */
					xcol = ycol;
					ycol = zcol;
					zcol = (int)magnitude(const_express(&a));
				}
				else {
					if (mapping3d == MAP3D_CARTESIAN)
						int_error("Must specify 1 or 3 columns",c_token);
					xcol = ycol;
					ycol = zcol;
				}
			}
			if (!only_z)
				if ( (xcol == ycol) || (ycol == zcol) || (xcol == zcol))
					int_error("Columns must be distinct",c_token);
		}
		if (!END_OF_COMMAND && isstring(c_token)) {
			quotel_str(format, c_token);
			c_token++;	/* skip format */
		}
	}
	else {
	    if ( only_z = !parametric )
		zcol = 1;
	}

	switch (mapping3d) {
	    case MAP3D_CARTESIAN:
		maxcol = (xcol > ycol) ? xcol : ycol;
		maxcol = (maxcol > zcol) ? maxcol : zcol;
		if (!only_z) {	/* Determine ordering of input columns */
 			if (zcol == maxcol) {
 				if (xcol < ycol)
 					xyz_order = XYZ;  /* scanf(x,y,z) */
 				else
 					xyz_order = YXZ;  /* scanf(y,x,z) */
 			}
 			else if (ycol == maxcol) {
 				if (xcol < zcol)
 					xyz_order = XZY;  /* scanf(x,z,y) */
 				else
 					xyz_order = ZXY;  /* scanf(z,x,y) */
 			}
 			else {
 				if (ycol < zcol)
 					xyz_order = YZX;  /* scanf(y,z,x) */
 				else
 					xyz_order = ZYX;  /* scanf(z,y,x) */
 			}
		}
		if (strlen(format) == 0) {
			if (only_z) {
				for(i = 1; i <= zcol; i++)
					if (i == zcol)
						(void) strcat(format,float_format);
					else
						(void) strcat(format,float_skip);
			}
			else {
				for(i = 1; i <= maxcol; i++)
					if ((i == xcol) || (i == ycol) || (i == zcol))
						(void) strcat(format,float_format);
					else
						(void) strcat(format,float_skip);
			}
		}
	        break;
	    case MAP3D_SPHERICAL:
	    case MAP3D_CYLINDRICAL:
		if (only_z)
			int_error("Two columns for spherical/cylindrical coords.",c_token);
		maxcol = (xcol > ycol) ? xcol : ycol;
		xyz_order = (xcol < ycol) ? XY : YX;
		for(i = 1; i <= maxcol; i++)
			if ((i == xcol) || (i == ycol))
				(void) strcat(format,float_format);
			else
				(void) strcat(format,float_skip);
	}
#ifdef AMIGA_LC_5_1
	num_perc_ast = 0;
	start_search = format;
	while (*start_search != '\0') {
		if (start_search[0] == '%')
			if (start_search[1] == '*') num_perc_ast++;
		start_search++;
	}
#endif /* AMIGA_LC_5_1 */

	l_num = 0;
	xdatum = 0;
	ydatum = 0;
	this_plot->num_iso_read = 0;
	this_plot->has_grid_topology = TRUE;
	if ( this_plot->iso_crvs != NULL ) {
	    struct iso_curve *icrv, *icrvs = this_plot->iso_crvs;

	    while ( icrvs ) {
		icrv = icrvs;
		icrvs = icrvs->next;
		iso_free( icrv );
	    }
	    this_plot->iso_crvs = NULL;
	}
	this_iso = iso_alloc( samples );

	while ( fgets(line, MAX_LINE_LEN, fp) != (char *)NULL ) {
		l_num++;
		if (is_comment(line[0]))
			continue;		/* ignore comments */
		if (!line[1]) {			/* is it blank line ? */
		        if (pt_in_iso_crv == 0) {
			        if (xdatum == 0)
					continue;
			        pt_in_iso_crv = xdatum;
			}

			if (xdatum > 0) {
				this_iso->p_count = xdatum;
				this_iso->next = this_plot->iso_crvs;
				this_plot->iso_crvs = this_iso;
				this_plot->num_iso_read++;

				if (xdatum != pt_in_iso_crv)
					this_plot->has_grid_topology = FALSE;

				this_iso = iso_alloc(pt_in_iso_crv);
				xdatum = 0;
				ydatum++;
			}
			continue;
		}

		if (xdatum >= this_iso->p_max)
		{
		    /* overflow about to occur. Extend size of points[]
			* array. We either double the size, or add 1000 points,
			* whichever is a smaller increment. Note i=p_max.
			*/
		    iso_extend(this_iso,
			       xdatum + (xdatum < 1000 ? xdatum : 1000));
		}

#ifdef AMIGA_LC_5_1
		switch (sscanf(line, format, &x, &y, &z) - num_perc_ast) {
#else
		switch (sscanf(line, format, &x, &y, &z)) {
#endif
		    case 3: 		/* All parameter are specified. */
			   if (!only_z) {
				switch (xyz_order) {
				   case XYZ:	/* scanf(x,y,z) */
					this_iso->points[xdatum].x = x;
					this_iso->points[xdatum].y = y;
					this_iso->points[xdatum].z = z;
					break;
				   case XZY:	/* scanf(x,z,y) */
					this_iso->points[xdatum].x = x;
					this_iso->points[xdatum].y = z;
					this_iso->points[xdatum].z = y;
					break;
				   case YXZ: 	/* scanf(y,x,z) */
					this_iso->points[xdatum].x = y;
					this_iso->points[xdatum].y = x;
					this_iso->points[xdatum].z = z;
					break;
				   case ZXY:	/* scanf(z,x,y) */
					this_iso->points[xdatum].x = y;
					this_iso->points[xdatum].y = z;
					this_iso->points[xdatum].z = x;
					break;
				   case YZX:	/* scanf(y,z,x) */
					this_iso->points[xdatum].x = z;
					this_iso->points[xdatum].y = x;
					this_iso->points[xdatum].z = y;
					break;
				   case ZYX:	/* scanf(z,y,x) */
					this_iso->points[xdatum].x = z;
					this_iso->points[xdatum].y = y;
					this_iso->points[xdatum].z = x;
					break;
				}
				if (xyz_order != XYZ) {
					x = this_iso->points[xdatum].x;
					y = this_iso->points[xdatum].y;
					z = this_iso->points[xdatum].z;
				}
				if (!parametric)
					int_error("Must be in parametric mode.",
						  NO_CARET);
			   	break;
			   }
		    case 1: 		/* only one number on the line */
			   if (!only_z)
				int_error("3 columns expected, only 1 found", c_token);
			   /* assign that number to z */
			   this_iso->points[xdatum].z = x;
			   z = x;
			   this_iso->points[xdatum].x = xdatum;
			   x = this_iso->points[xdatum].x;
			   this_iso->points[xdatum].y = ydatum;
			   y = this_iso->points[xdatum].y;
			   if (parametric)
				int_error("Must be in non parametric mode.",
					  NO_CARET);
			   break;
		    case 2:
			   switch (xyz_order) {
			       case YX:
				   z = x;	/* Use z as temp */
				   x = y;
				   y = z;
				   break;
			       default:
				   break;
			   }
			   switch (mapping3d) {
			       case MAP3D_CARTESIAN:
			           int_error("2 columns found, 3 expected",
					     c_token);
				   break;
			       case MAP3D_SPHERICAL:
				   if (angles_format == ANGLES_DEGREES) {
				       x *= DEG2RAD; /* Convert to radians. */
				       y *= DEG2RAD;
				   }
				   this_iso->points[xdatum].x = cos(x) * cos(y);
				   this_iso->points[xdatum].y = sin(x) * cos(y);
				   this_iso->points[xdatum].z = sin(y);
				   break;
			       case MAP3D_CYLINDRICAL:
				   if (angles_format == ANGLES_DEGREES)
				       x *= DEG2RAD; /* Convert to radians. */
				   this_iso->points[xdatum].x = cos(x);
				   this_iso->points[xdatum].y = sin(x);
				   this_iso->points[xdatum].z = y;
				   break;
			   }
			   x = this_iso->points[xdatum].x;
			   y = this_iso->points[xdatum].y;
			   z = this_iso->points[xdatum].z;
			   break;
		    default:
			   (void) sprintf(line, "bad data on line %d", l_num);
			   int_error(line,c_token);
		}

		if (log_x) {
		    if (x < 0.0)
			int_error("X value must be above 0 for log scale!",
				  NO_CARET);
		    else
			this_iso->points[xdatum].x =
			    log10(this_iso->points[xdatum].x);
		}
		if (log_y) {
		    if (y < 0.0)
			int_error("Y value must be above 0 for log scale!",
				  NO_CARET);
		    else
			this_iso->points[xdatum].y =
			    log10(this_iso->points[xdatum].y);
		}
		if (log_z) {
		    if (z < 0.0)
			int_error("Z value must be above 0 for log scale!",
				  NO_CARET);
		    else
			this_iso->points[xdatum].z =
			    log10(this_iso->points[xdatum].z);
		}

		if (autoscale_lx) {
			if (x < xmin) xmin = x;
			if (x > xmax) xmax = x;
		}
		if (autoscale_ly) {
			if (y < ymin) ymin = y;
			if (y > ymax) ymax = y;
		}
		if (autoscale_lz) {
			if (z < zmin) zmin = z;
			if (z > zmax) zmax = z;
		}

		xdatum++;
	}

	if (xdatum > 0) {
		this_plot->num_iso_read++; /* Update last iso. */
		this_iso->p_count = xdatum;

		this_iso->next = this_plot->iso_crvs; 
		this_plot->iso_crvs = this_iso;

		if (xdatum != pt_in_iso_crv)
			this_plot->has_grid_topology = FALSE;

	}
	else {
		iso_free(this_iso);/* Free last allocation. */
	}

#ifdef unix
	if ( pipe_open ) {
		(void) pclose(fp);
		pipe_open = FALSE;
	} else
#endif
	(void) fclose(fp);
      if (this_plot->num_iso_read <= 1)
          this_plot->has_grid_topology = FALSE;
	if (this_plot->has_grid_topology) {
	        struct iso_curve *new_icrvs = NULL;
		int num_new_iso = this_plot->iso_crvs->p_count,
		    len_new_iso = this_plot->num_iso_read;

		/* Now we need to set the other direction (pseudo) isolines. */
	        for (i = 0; i < num_new_iso; i++) {
		    struct iso_curve *new_icrv = iso_alloc(len_new_iso);

		    new_icrv->p_count = len_new_iso;

		    for (j = 0, this_iso = this_plot->iso_crvs;
		         this_iso != NULL;
			 j++, this_iso = this_iso->next) {
			new_icrv->points[j].x = this_iso->points[i].x;
		     	new_icrv->points[j].y = this_iso->points[i].y;
		     	new_icrv->points[j].z = this_iso->points[i].z;
		    }

		    new_icrv->next = new_icrvs;
		    new_icrvs = new_icrv;
		}

		/* Append the new iso curves after the read ones. */
		for (this_iso = this_plot->iso_crvs;
		     this_iso->next != NULL;
		     this_iso = this_iso->next);
		this_iso->next = new_icrvs;
	}
}

/* print_points:
 * a debugging routine to print out the points of a curve,
 * and the curve structure. If curve<0, then we print the 
 * list of curves.
 */
static char *plot_type_names[4] = {
    "Function", "Data", "3D Function", "3d data"
};
static char *plot_style_names[6] = {
    "Lines", "Points", "Impulses", "LinesPoints", "Dots", "Errorbars"
};

print_points(curve)
	int curve;			/* which curve to print */
{
    register struct curve_points *this_plot;
    int i;

    if (curve < 0) {
	   for (this_plot = first_plot, i=0; 
		   this_plot != NULL; 
		   i++, this_plot = this_plot->next_cp) {
		  printf("Curve %d:\n", i);
		  if ((int)this_plot->plot_type >= 0 && (int)(this_plot->plot_type) < 4)
		    printf("Plot type %d: %s\n", (int)(this_plot->plot_type),
				 plot_type_names[(int)(this_plot->plot_type)]);
		  else
		    printf("Plot type %d: BAD\n", (int)(this_plot->plot_type));
		  if ((int)this_plot->plot_style >= 0 && (int)(this_plot->plot_style) < 6)
		    printf("Plot style %d: %s\n", (int)(this_plot->plot_style),
				 plot_style_names[(int)(this_plot->plot_style)]);
		  else
		    printf("Plot style %d: BAD\n", (int)(this_plot->plot_style));
		  printf("Plot title: '%s'\n", this_plot->title);
		  printf("Line type %d\n", this_plot->line_type);
		  printf("Point type %d\n", this_plot->point_type);
		  printf("max points %d\n", this_plot->p_max);
		  printf("current points %d\n", this_plot->p_count);
		  printf("\n");
	   }
    } else {
	   for (this_plot = first_plot, i = 0; 
		   i < curve && this_plot != NULL; 
		   i++, this_plot = this_plot->next_cp)
		;
	   if (this_plot == NULL)
		printf("Curve %d does not exist; list has %d curves\n", curve, i);
	   else {
		  printf ("Curve %d, %d points\n", curve, this_plot->p_count);
		  for (i = 0; i < this_plot->p_count; i++) {
			 printf("%c x=%g y=%g z=%g ylow=%g yhigh=%g\n", 
				   this_plot->points[i].type == INRANGE ? 'i'
				   : this_plot->points[i].type == OUTRANGE ? 'o'
				   : 'u',
				   this_plot->points[i].x,
				   this_plot->points[i].y,
				   this_plot->points[i].z,
				   this_plot->points[i].ylow,
				   this_plot->points[i].yhigh);
		  }
		  printf("\n");
	   }
    }    
}

print_table()
{
    register struct curve_points *this_plot;
    int i, curve;

   for (this_plot = first_plot, curve = 0; this_plot != NULL;
       curve++, this_plot = this_plot->next_cp)
   {
	  fprintf(outfile,"Curve %d, %d points\n", curve, this_plot->p_count);
	  for (i = 0; i < this_plot->p_count; i++) {
		 fprintf(outfile,"%c x=%g y=%g\n",
			   this_plot->points[i].type == INRANGE ? 'i'
			   : this_plot->points[i].type == OUTRANGE ? 'o'
			   : 'u',
			   this_plot->points[i].x,
			   this_plot->points[i].y);
	  }
	  fprintf(outfile,"\n");
   }
   fflush(outfile);
}

print_3dtable()
{
    register struct surface_points *this_3dplot;
    int i, curve;
    struct gnuplot_contours *contours;      /* Not NULL If have contours. */
    struct iso_curve *isocrv;

    for (this_3dplot = first_3dplot, curve = 0; this_3dplot != NULL;
       curve++, this_3dplot = this_3dplot->next_sp)
    {
	  isocrv = this_3dplot->iso_crvs;
	  fprintf(outfile,"Curve %d, %d points\n", curve, isocrv->p_count);
	  for (i = 0; i < isocrv->p_count; i++) {
		 fprintf(outfile,"%c x=%g y=%g z=%g\n",
			   isocrv->points[i].type == INRANGE ? 'i'
			   : isocrv->points[i].type == OUTRANGE ? 'o'
			   : 'u',
			   isocrv->points[i].x,
			   isocrv->points[i].y,
			   isocrv->points[i].z);
	  }
	  fprintf(outfile,"\n");
   }
   fflush(outfile);
}

/* This parses the plot command after any range specifications. 
 * To support autoscaling on the x axis, we want any data files to 
 * define the x range, then to plot any functions using that range. 
 * We thus parse the input twice, once to pick up the data files, 
 * and again to pick up the functions. Definitions are processed 
 * twice, but that won't hurt.
 */
eval_plots()
{
register int i;
register struct curve_points *this_plot, **tp_ptr;
register int start_token, end_token;
register int begin_token;
double x_min, x_max, y_min, y_max;
register double x, xdiff, temp;
static struct value a;
BOOLEAN ltmp, some_data_files = FALSE;
int plot_num, line_num, point_num, xparam=0;
char *xtitle;
void parametric_fixup();

	if (autoscale_ly) {
		ymin = VERYLARGE;
		ymax = -VERYLARGE;
	} else if (log_y && (ymin <= 0.0 || ymax <= 0.0))
			int_error("y range must be above 0 for log scale!",
				NO_CARET);

	tp_ptr = &(first_plot);
	plot_num = 0;
	line_num = 0; 	/* default line type */
	point_num = 0;	/* default point type */

	xtitle = NULL;

	begin_token = c_token;

/*** First Pass: Read through data files ***/
/* This pass serves to set the xrange and to parse the command, as well 
 * as filling in every thing except the function data. That is done after
 * the xrange is defined.
 */
	while (TRUE) {
		if (END_OF_COMMAND)
			int_error("function to plot expected",c_token);

		start_token = c_token;

		if (is_definition(c_token)) {
			define();
		} else {
			plot_num++;

			if (isstring(c_token)) {			/* data file to plot */
				if (parametric && xparam) 
					int_error("previous parametric function not fully specified",
																	c_token);

				if (!some_data_files && autoscale_lx) {
				    xmin = VERYLARGE;
				    xmax = -VERYLARGE;
				}
				some_data_files = TRUE;

				if (*tp_ptr)
				  this_plot = *tp_ptr;
				else {		/* no memory malloc()'d there yet */
				    this_plot = cp_alloc(MIN_CRV_POINTS);
				    *tp_ptr = this_plot;
				}
				this_plot->plot_type = DATA;
				this_plot->plot_style = data_style;
				end_token = c_token;
				get_data(this_plot); /* this also parses the using option */
			} 
			else {							/* function to plot */
				if (parametric)			/* working on x parametric function */
					xparam = 1 - xparam;
				if (*tp_ptr) {
				    this_plot = *tp_ptr;
				    cp_extend(this_plot, samples+1);
				} else {		/* no memory malloc()'d there yet */
				    this_plot = cp_alloc(samples+1);
				    *tp_ptr = this_plot;
				}
				this_plot->plot_type = FUNC;
				this_plot->plot_style = func_style;
				dummy_func = &plot_func;
				plot_func.at = temp_at();
				/* ignore it for now */
				end_token = c_token-1;
			}

			if (almost_equals(c_token,"t$itle")) {
				if (parametric) {
					if (xparam) 
						int_error(
		"\"title\" allowed only after parametric function fully specified",
																	c_token);
					else if (xtitle != NULL)
						xtitle[0] = '\0';  /* Remove default title .*/
				}
				c_token++;
				if ( isstring( c_token ) ) {
					m_quote_capture(&(this_plot->title),c_token,c_token);
				}
				else {
					int_error("expecting \"title\" for plot",c_token);
				}
				c_token++;
			}
  			else {
  				m_capture(&(this_plot->title),start_token,end_token);
 				if (xparam) xtitle = this_plot->title;
  			}
  
  			this_plot->line_type = line_num;
			this_plot->point_type = point_num;

			if (almost_equals(c_token,"w$ith")) {
				if (parametric && xparam) 
					int_error("\"with\" allowed only after parametric function fully specified",
									c_token);
			    this_plot->plot_style = get_style();
			}

			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				this_plot->line_type = (int)real(const_express(&t))-1;
			}
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				this_plot->point_type = (int)real(const_express(&t))-1;
			}
			if ( (this_plot->plot_style == POINTS) ||
				 (this_plot->plot_style == LINESPOINTS) ||
				 (this_plot->plot_style == ERRORBARS) )
					if (!xparam) point_num++;
			if (!xparam) line_num++;

			if (this_plot->plot_type == DATA) 
			  /* now that we know the plot style, adjust the yrange */
			  adjust_yrange(this_plot);

			tp_ptr = &(this_plot->next_cp);
		}

		if (equals(c_token,",")) 
			c_token++;
		else  
			break;
	}

	if (parametric && xparam) 
		int_error("parametric function not fully specified", NO_CARET);

	if (parametric) {
	/* Swap t and x ranges for duration of these eval_plot computations. */
		ltmp = autoscale_lx; autoscale_lx = autoscale_lt; autoscale_lt = ltmp;
		temp = xmin; xmin = tmin; tmin = temp;
		temp = xmax; xmax = tmax; tmax = temp;
	}

/*** Second Pass: Evaluate the functions ***/
/* Everything is defined now, except the function data. We expect
 * no syntax errors, etc, since the above parsed it all. This makes 
 * the code below simpler. If autoscale_ly, the yrange may still change.
 */
     if (fabs(xmax-xmin) < zero)
	  if (autoscale_lx) {
		 fprintf(stderr, "Warning: empty %c range [%g:%g], ", 
			parametric ? 't' : 'x', xmin,xmax);
		 if (fabs(xmin) < zero) {
			/* completely arbitary */
			xmin = -1.;
			xmax = 1.;
		 } else {
			/* expand range by 10% in either direction */
			xmin = xmin * 0.9;
			xmax = xmax * 1.1;
		 }
		 fprintf(stderr, "adjusting to [%g:%g]\n", xmin,xmax);
	  } else {
		 int_error("x range is less than `zero`", c_token);
	  }

	/* give error if xrange badly set from missing datafile error */
	if (xmin == VERYLARGE || xmax == -VERYLARGE) {
		int_error("x range is invalid", c_token);
	}

    if (log_x) {
	   if (xmin <= 0.0 || xmax <= 0.0)
		int_error("x range must be greater than 0 for log scale!",NO_CARET);
	   x_min = log10(xmin);
	   x_max = log10(xmax);
    } else {
	   x_min = xmin;
	   x_max = xmax;
    }

    xdiff = (x_max - x_min) / (samples - 1);

    tp_ptr = &(first_plot);
    plot_num = 0;
    this_plot = first_plot;
    c_token = begin_token;	/* start over */

    /* Read through functions */
	while (TRUE) {
		if (is_definition(c_token)) {
			define();
		} else {
			plot_num++;
			if (isstring(c_token)) {			/* data file to plot */
			    /* ignore this now */
				c_token++;
				if (almost_equals(c_token,"u$sing")) {
					c_token++;  	/* skip "using" */
						if (!isstring(c_token)) {
						struct value a;
						(void)magnitude(const_express(&a)); /* skip xcol */
						if (equals(c_token,":")) {
							c_token++;      /* skip ":" */
							(void)magnitude(const_express(&a)); /* skip ycol */
						}
						if (equals(c_token,":")) {
							c_token++;      /* skip ":" */
							(void)magnitude(const_express(&a)); /* skip yemin */
						}
						if (equals(c_token,":")) {
							c_token++;      /* skip ":" */
							(void)magnitude(const_express(&a)); /* skip yemax */
						}
					}
					if (isstring(c_token))
						c_token++;      /* skip format string */
				}
			}
			else {					/* function to plot */
				if (parametric)			/* working on x parametric function */
					xparam = 1 - xparam;
				dummy_func = &plot_func;
				plot_func.at = temp_at(); /* reparse function */

				for (i = 0; i < samples; i++) {
				    x = x_min + i*xdiff;
				    /* if (log_x) PEM fix logscale x axis */
				    /* x = pow(10.0,x); 26-Sep-89 */
				    (void) complex(&plot_func.dummy_values[0],
							    log_x ? pow(10.0,x) : x,
							    0.0);

				    evaluate_at(plot_func.at,&a);

				    if (undefined || (fabs(imag(&a)) > zero)) {
					   this_plot->points[i].type = UNDEFINED;
					   continue;
				    }

				    temp = real(&a);

				    if (log_y && temp < 0.0) {
					   this_plot->points[i].type = UNDEFINED;
					   continue;
				    }

				    this_plot->points[i].x = x;
				    if (log_y) {
					   if (temp == 0.0) {
						  this_plot->points[i].type = OUTRANGE;
						  this_plot->points[i].y = -VERYLARGE;
						  continue;
					   } else {
						  this_plot->points[i].y = log10(temp);
					   }
				    } else
					 this_plot->points[i].y = temp;

				    if (autoscale_ly || polar
					   || inrange(temp, ymin, ymax)) {
					   this_plot->points[i].type = INRANGE;
					/* When xparam is 1 we are not really computing y's! */
						if (!xparam && autoscale_ly) {
					   	if (temp < ymin) ymin = temp;
					   	if (temp > ymax) ymax = temp;
						}
				    } else
					 this_plot->points[i].type = OUTRANGE;
				}
				this_plot->p_count = i; /* samples */
			 }

			/* title was handled above */
			if (almost_equals(c_token,"t$itle")) {
				c_token++;
				c_token++;
			}

			/* style was handled above */
			if (almost_equals(c_token,"w$ith")) {
			    c_token++;
			    c_token++;
			}

			/* line and point types were handled above */
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				(void)real(const_express(&t));
			}
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				(void)real(const_express(&t));
			}

 			tp_ptr = &(this_plot->next_cp); /* used below */
			this_plot = this_plot->next_cp;
		 }
		
		if (equals(c_token,",")) 
		  c_token++;
		else  
		  break;
	 }

    /* throw out all curve_points at end of list, that we don't need  */
    cp_free(*tp_ptr);
    *tp_ptr = NULL;

    if (fabs(ymax - ymin) < zero)
	 /* if autoscale, widen range */
	 if (autoscale_ly) {
		fprintf(stderr, "Warning: empty y range [%g:%g], ", ymin, ymax);
		if (fabs(ymin) < zero) {
		    ymin = -1.;
		    ymax = 1.;
		} else {
		    /* expand range by 10% in either direction */
		    ymin = ymin * 0.9;
		    ymax = ymax * 1.1;
		}
		fprintf(stderr, "adjusting to [%g:%g]\n", ymin, ymax);
	 } else {
		int_error("y range is less than `zero`", c_token);
	 }

/* Now we finally know the real ymin and ymax */
	if (log_y) {
		y_min = log10(ymin);
		y_max = log10(ymax);
	} else {
		y_min = ymin;
		y_max = ymax;
	}
	capture(replot_line,plot_token,c_token);

	if (parametric) {
	/* Now put t and x ranges back before we actually plot anything. */
		ltmp = autoscale_lx; autoscale_lx = autoscale_lt; autoscale_lt = ltmp;
		temp = xmin; xmin = tmin; tmin = temp;
		temp = xmax; xmax = tmax; tmax = temp;
		if (some_data_files && autoscale_lx) {
		/* 
			Stop any further autoscaling in this case (may be a mistake, have
  			to consider what is really wanted some day in the future--jdc). 
		*/
		    autoscale_lx = 0;
		}
	/* Now actually fix the plot pairs to be single plots. */
		parametric_fixup (first_plot, &plot_num, &x_min, &x_max);
	}

	if (strcmp(term_tbl[term].name,"table") == 0)
		print_table();
	else
		do_plot(first_plot,plot_num,x_min,x_max,y_min,y_max);
	cp_free(first_plot);
	first_plot = NULL;
}

/* This parses the splot command after any range specifications. 
 * To support autoscaling on the x/z axis, we want any data files to 
 * define the x/y range, then to plot any functions using that range. 
 * We thus parse the input twice, once to pick up the data files, 
 * and again to pick up the functions. Definitions are processed 
 * twice, but that won't hurt.
 */
eval_3dplots()
{
register int i,j,k;
register struct surface_points *this_plot, **tp_3d_ptr;
register int start_token, end_token;
register int begin_token;
double x_min, x_max, y_min, y_max, z_min, z_max;
register double x, xdiff, xisodiff, y, ydiff, yisodiff, temp;
static struct value a;
BOOLEAN ltmp, some_data_files = FALSE;
int plot_num, line_num, point_num,
    crnt_param = 0; /* 0=x, 1=y, 2=z */
char *xtitle;
char *ytitle;
void parametric_3dfixup();

	if (autoscale_lz) {
		zmin = VERYLARGE;
		zmax = -VERYLARGE;
	} else if (log_z && (zmin <= 0.0 || zmax <= 0.0))
			int_error("z range must be above 0 for log scale!",
				NO_CARET);

	tp_3d_ptr = &(first_3dplot);
	plot_num = 0;
	line_num = 0; 	/* default line type */
	point_num = 0;	/* default point type */

	xtitle = NULL;
	ytitle = NULL;

	begin_token = c_token;

/*** First Pass: Read through data files ***/
/* This pass serves to set the x/yranges and to parse the command, as well 
 * as filling in every thing except the function data. That is done after
 * the x/yrange is defined.
 */
	while (TRUE) {
		if (END_OF_COMMAND)
			int_error("function to plt3d expected",c_token);

		start_token = c_token;

		if (is_definition(c_token)) {
			define();
		} else {
			plot_num++;

			if (isstring(c_token)) {			/* data file to plot */
				if (parametric && crnt_param != 0)
					int_error("previous parametric function not fully specified",
																	c_token);

				if (!some_data_files) {
					if (autoscale_lx) {
						xmin = VERYLARGE;
						xmax = -VERYLARGE;
					}
					if (autoscale_ly) {
						ymin = VERYLARGE;
						ymax = -VERYLARGE;
					}
				}

				some_data_files = TRUE;

				if (*tp_3d_ptr)
				    this_plot = *tp_3d_ptr;
				else {	/* no memory malloc()'d there yet */
				    /* Allocate samples * iso_samples twice for */
				    /* Each of the isoparametric direction. */
				    this_plot = sp_alloc(0,0);
				    *tp_3d_ptr = this_plot;
				}

				this_plot->plot_type = DATA3D;
				this_plot->plot_style = data_style;
				end_token = c_token;
				get_3ddata(this_plot); /* this also parses the using option */
			} 
			else {						/* function to plot */
				if (parametric) /* Rotate between x/y/z axes */
					crnt_param = (crnt_param+1) % 3;
				if (*tp_3d_ptr) {
				    this_plot = *tp_3d_ptr;
				    sp_replace(this_plot,samples,2*iso_samples);
				}
				else {	/* no memory malloc()'d there yet */
				    /* Allocate samples * iso_samples twice for */
				    /* Each of the isoparametric direction. */
				    this_plot = sp_alloc(samples,2*iso_samples);
				    *tp_3d_ptr = this_plot;
				}

				this_plot->plot_type = FUNC3D;
				this_plot->has_grid_topology = TRUE;
				this_plot->plot_style = func_style;
				dummy_func = &plot_func;
				plot_func.at = temp_at();
				/* ignore it for now */
				end_token = c_token-1;
			}

			if (almost_equals(c_token,"t$itle")) {
				if (parametric) {
				        if (crnt_param)
						int_error(
		"\"title\" allowed only after parametric function fully specified",
																	c_token);
					else {
						/* Remove default title */
						if (xtitle != NULL)
							xtitle[0] = '\0';
						if (ytitle != NULL)
							ytitle[0] = '\0';
					}
			        }
				c_token++;
				if ( isstring( c_token ) ) {
					m_quote_capture(&(this_plot->title),c_token,c_token);
				}
				else {
					int_error("expecting \"title\" for plot",c_token);
				}
				c_token++;
			}
  			else {
  				m_capture(&(this_plot->title),start_token,end_token);
				if (crnt_param == 1) xtitle = this_plot->title;
				if (crnt_param == 2) ytitle = this_plot->title;
  			}
  
  			this_plot->line_type = line_num;
			this_plot->point_type = point_num;

			if (almost_equals(c_token,"w$ith")) {
			    this_plot->plot_style = get_style();
			}

			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				this_plot->line_type = (int)real(const_express(&t))-1;
			}
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				this_plot->point_type = (int)real(const_express(&t))-1;
			}
			if ( (this_plot->plot_style == POINTS) ||
				 (this_plot->plot_style == LINESPOINTS) ||
				 (this_plot->plot_style == ERRORBARS) )
					if (crnt_param == 0)
						point_num +=
						    1 + (draw_contour != 0)
						      + (hidden3d != 0);
			if (crnt_param == 0)
			    line_num += 1 + (draw_contour != 0)
			                  + (hidden3d != 0);

			tp_3d_ptr = &(this_plot->next_sp);
		}

		if (equals(c_token,",")) 
			c_token++;
		else  
			break;
	}

	if (parametric && crnt_param != 0)
		int_error("parametric function not fully specified", NO_CARET);

	if (parametric) {
	/* Swap u/v and x/y ranges for duration of these eval_plot computations. */
		ltmp = autoscale_lx; autoscale_lx = autoscale_lu; autoscale_lu = ltmp;
		ltmp = autoscale_ly; autoscale_ly = autoscale_lv; autoscale_lv = ltmp;
		temp = xmin; xmin = umin; umin = temp;
		temp = xmax; xmax = umax; umax = temp;
		temp = ymin; ymin = vmin; vmin = temp;
		temp = ymax; ymax = vmax; vmax = temp;
	}
/*** Second Pass: Evaluate the functions ***/
/* Everything is defined now, except the function data. We expect
 * no syntax errors, etc, since the above parsed it all. This makes 
 * the code below simpler. If autoscale_ly, the yrange may still change.
 */
     if (xmin == xmax)
	  if (autoscale_lx) {
		 fprintf(stderr, "Warning: empty x range [%g:%g], ", 
			 xmin,xmax);
		 if (xmin == 0.0) {
			/* completely arbitary */
			xmin = -1.;
			xmax = 1.;
		 } else {
			/* expand range by 10% in either direction */
			xmin = xmin * 0.9;
			xmax = xmax * 1.1;
		 }
		 fprintf(stderr, "adjusting to [%g:%g]\n", xmin,xmax);
	  } else {
		 int_error("x range is empty", c_token);
	  }

     if (ymin == ymax)
	  if (autoscale_ly) {
		 fprintf(stderr, "Warning: empty y range [%g:%g], ", 
			ymin,ymax);
		 if (ymin == 0.0) {
			/* completely arbitary */
			ymin = -1.;
			ymax = 1.;
		 } else {
			/* expand range by 10% in either direction */
			ymin = ymin * 0.9;
			ymax = ymax * 1.1;
		 }
		 fprintf(stderr, "adjusting to [%g:%g]\n", ymin,ymax);
	  } else {
		 int_error("y range is empty", c_token);
	  }

    /* give error if xrange badly set from missing datafile error */
    if (xmin == VERYLARGE || xmax == -VERYLARGE) {
	int_error("x range is invalid", c_token);
    }

    if (log_x) {
	   if (xmin <= 0.0 || xmax <= 0.0)
		int_error("x range must be greater than 0 for log scale!",NO_CARET);
	   x_min = log10(xmin);
	   x_max = log10(xmax);
    } else {
	   x_min = xmin;
	   x_max = xmax;
    }

    if (log_y) {
	   if (ymin <= 0.0 || ymax <= 0.0)
		int_error("y range must be greater than 0 for log scale!",NO_CARET);
	   y_min = log10(ymin);
	   y_max = log10(ymax);
    } else {
	   y_min = ymin;
	   y_max = ymax;
    }

    if (samples < 2 || iso_samples < 2)
	int_error("samples or iso_samples < 2. Must be at least 2.\n");

    xdiff = (x_max - x_min) / (samples - 1);
    ydiff = (y_max - y_min) / (samples - 1);
    xisodiff = (x_max - x_min) / (iso_samples - 1);
    yisodiff = (y_max - y_min) / (iso_samples - 1);

    plot_num = 0;
    this_plot = first_3dplot;
    c_token = begin_token;	/* start over */

    /* Read through functions */
	while (TRUE) {
		if (is_definition(c_token)) {
			define();
		} else {
			plot_num++;
			if (isstring(c_token)) {			/* data file to plot */
			    /* ignore this now */
				c_token++;
				if (almost_equals(c_token,"u$sing")) {
					c_token++;  	/* skip "using" */
                    			if (!isstring(c_token)) {
						struct value a;
						(void)magnitude(const_express(&a));	/* skip xcol */
						if (equals(c_token,":")) {
							c_token++;	/* skip ":" */
							(void)magnitude(const_express(&a));	/* skip ycol */
							if (equals(c_token,":")) {
								c_token++;	/* skip ":" */
								(void)magnitude(const_express(&a));	/* skip zcol */
							}
						}
					}
                    			if (isstring(c_token))
						c_token++;	/* skip format string */
				}
			}
			else {					/* function to plot */
				struct iso_curve *this_iso = this_plot->iso_crvs;
				struct coordinate *points = this_iso->points;
				
				if (parametric)
					crnt_param = (crnt_param+1) % 3;
				dummy_func = &plot_func;
				plot_func.at = temp_at(); /* reparse function */

				for (j = 0; j < iso_samples; j++) {
				    y = y_min + j*yisodiff;
				    /* if (log_y) PEM fix logscale y axis */
				    /* y = pow(10.0,y); 26-Sep-89 */
				    (void) complex(&plot_func.dummy_values[1],
							    log_y ? pow(10.0,y) : y,
							    0.0);

				    for (i = 0; i < samples; i++) {
				        x = x_min + i*xdiff;
				        /* if (log_x) PEM fix logscale x axis */
				        /* x = pow(10.0,x); 26-Sep-89 */
				        (void) complex(&plot_func.dummy_values[0],
							    log_x ? pow(10.0,x) : x,
							    0.0);

				        points[i].x = x;
				        points[i].y = y;

				        evaluate_at(plot_func.at,&a);

				        if (undefined || (fabs(imag(&a)) > zero)) {
					   points[i].type = UNDEFINED;
					   continue;
				        }

				        temp = real(&a);

				        if (log_z && temp < 0.0) {
					   points[i].type = UNDEFINED;
					   continue;
				        }

				        if (log_z) {
					   if (temp == 0.0) {
						  points[i].type = OUTRANGE;
						  points[i].z = -VERYLARGE;
						  continue;
					   } else {
						  points[i].z = log10(temp);
					   }
				        } else
					   points[i].z = temp;

				        if (autoscale_lz
					   || inrange(temp, zmin, zmax)) {
					   points[i].type = INRANGE;
					   if (autoscale_lz) {
					      if (temp < zmin) zmin = temp;
					      if (temp > zmax) zmax = temp;
					   }
				        } else
					   points[i].type = OUTRANGE;
				    }
				    this_iso->p_count = samples;
				    this_iso = this_iso->next;
				    points = this_iso->points;
				}

				for (i = 0; i < iso_samples; i++) {
				    x = x_min + i*xisodiff;
				    /* if (log_x) PEM fix logscale x axis */
				    /* x = pow(10.0,x); 26-Sep-89 */
				    (void) complex(&plot_func.dummy_values[0],
							    log_x ? pow(10.0,x) : x,
							    0.0);

				    for (j = 0; j < samples; j++) {
				        y = y_min + j*ydiff;
				        /* if (log_y) PEM fix logscale y axis */
				        /* y = pow(10.0,y); 26-Sep-89 */
				        (void) complex(&plot_func.dummy_values[1],
							    log_y ? pow(10.0,y) : y,
							    0.0);

				        points[j].x = x;
				        points[j].y = y;

				        evaluate_at(plot_func.at,&a);

				        if (undefined || (fabs(imag(&a)) > zero)) {
					   points[j].type = UNDEFINED;
					   continue;
				        }

				        temp = real(&a);

				        if (log_z && temp < 0.0) {
					   points[j].type = UNDEFINED;
					   continue;
				        }

				        if (log_z) {
					   if (temp == 0.0) {
						  points[j].type = OUTRANGE;
						  points[j].z = -VERYLARGE;
						  continue;
					   } else {
						  points[j].z = log10(temp);
					   }
				        } else
					   points[j].z = temp;

				        if (autoscale_lz
					   || inrange(temp, zmin, zmax)) {
					   points[j].type = INRANGE;
					   if (autoscale_lz) {
					      if (temp < zmin) zmin = temp;
					      if (temp > zmax) zmax = temp;
					   }
				        } else
					   points[j].type = OUTRANGE;
				    }
    				    this_iso->p_count = samples;
				    this_iso = this_iso->next;
				    points = this_iso ? this_iso->points : NULL;
				}
			 }

			/* title was handled above */
			if (almost_equals(c_token,"t$itle")) {
				c_token++;
				c_token++;
			}

			/* style was handled above */
			if (almost_equals(c_token,"w$ith")) {
			    c_token++;
			    c_token++;
			}

			/* line and point types were handled above */
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				(void)real(const_express(&t));
			}
			if ( !equals(c_token,",") && !END_OF_COMMAND ) {
				struct value t;
				(void)real(const_express(&t));
			}

			this_plot = this_plot->next_sp;
		 }

		if (equals(c_token,","))
		  c_token++;
		else
		  break;
	 }

    if (fabs(zmax - zmin) < zero)
	 /* if autoscale, widen range */
	 if (autoscale_lz) {
		fprintf(stderr, "Warning: empty z range [%g:%g], ", zmin, zmax);
		if (fabs(zmin) < zero ) {
		    zmin = -1.;
		    zmax = 1.;
		} else {
		    /* expand range by 10% in either direction */
		    zmin = zmin * 0.9;
		    zmax = zmax * 1.1;
		}
		fprintf(stderr, "adjusting to [%g:%g]\n", zmin, zmax);
	 } else {
		int_error("z range is less than `zero`", c_token);
	 }

/* Now we finally know the real zmin and zmax */
	if (log_z) {
		if (zmin <= 0.0 || zmax <= 0.0)
			int_error("z range must be greater than 0 for log scale!",NO_CARET);
		z_min = log10(zmin);
		z_max = log10(zmax);
	} else {
		z_min = zmin;
		z_max = zmax;
	}
	capture(replot_line,plot_token,c_token);

	if (parametric) {
	/* Now put u/v and x/y ranges back before we actually plot anything. */
		ltmp = autoscale_lx; autoscale_lx = autoscale_lu; autoscale_lu = ltmp;
		ltmp = autoscale_ly; autoscale_ly = autoscale_lv; autoscale_lv = ltmp;
		temp = xmin; xmin = umin; umin = temp;
		temp = xmax; xmax = umax; umax = temp;
		temp = ymin; ymin = vmin; vmin = temp;
		temp = ymax; ymax = vmax; vmax = temp;

	/* Now actually fix the plot triplets to be single plots. */
		parametric_3dfixup(first_3dplot, &plot_num,
				   &x_min, &x_max, &y_min, &y_max,
				   &z_min, &z_max);
		if (log_x) {
			if (x_min <= 0.0 || x_max <= 0.0)
				int_error("x range must be greater than 0 for log scale!",NO_CARET);
			x_min = log10(x_min);
			x_max = log10(x_max);
		}

		if (log_y) {
			if (y_min <= 0.0 || y_max <= 0.0)
				int_error("y range must be greater than 0 for log scale!",NO_CARET);
			y_min = log10(y_min);
			y_max = log10(y_max);
		}

		if (log_z) {
			if (z_min <= 0.0 || z_max <= 0.0)
				int_error("z range must be greater than 0 for log scale!",NO_CARET);
			z_min = log10(z_min);
			z_max = log10(z_max);
		}
	}


	/* Creates contours if contours are to be plotted as well. */
	if (draw_contour) {
		for (this_plot=first_3dplot, i=0;
		     i < plot_num;
		     this_plot=this_plot->next_sp, i++) {
			if (this_plot->contours) {
				struct gnuplot_contours *cntr, *cntrs = this_plot->contours;

				while (cntrs) {
					cntr = cntrs;
					cntrs = cntrs->next;
					free(cntr->coords);
					free(cntr);
				}
			}
			/* Make sure this one can be contoured. */
			if (!this_plot->has_grid_topology) {
			    this_plot->contours = NULL;
			    int_error("Can not contour non grid data!",NO_CARET);
			}
			if (this_plot->plot_type == DATA3D)
			    this_plot->contours = contour(
					       this_plot->num_iso_read,
					       this_plot->iso_crvs,
					       contour_levels, contour_pts,
					       contour_kind, contour_order);
			else
			    this_plot->contours = contour(iso_samples,
					       this_plot->iso_crvs,
					       contour_levels, contour_pts,
					       contour_kind, contour_order);
		}
	}

	if (strcmp(term_tbl[term].name,"table") == 0)
	   print_3dtable();
	else
	   do_3dplot(first_3dplot,plot_num,x_min,x_max,y_min,y_max,z_min,z_max);
	sp_free(first_3dplot);
	first_3dplot = NULL;
}

done(status)
int status;
{
	if (term && term_init)
		(*term_tbl[term].reset)();
#ifdef vms
	vms_reset();
#endif
	exit(status);
}

void parametric_fixup (start_plot, plot_num, x_min, x_max)
struct curve_points *start_plot;
int *plot_num;
double *x_min, *x_max;
/*
	The hardest part of this routine is collapsing the FUNC plot types
   in the list (which are gauranteed to occur in (x,y) pairs while 
	preserving the non-FUNC type plots intact.  This means we have to
	work our way through various lists.  Examples (hand checked):
		start_plot:F1->F2->NULL ==> F2->NULL
		start_plot:F1->F2->F3->F4->F5->F6->NULL ==> F2->F4->F6->NULL
		start_plot:F1->F2->D1->D2->F3->F4->D3->NULL ==> F2->D1->D2->F4->D3->NULL
	
	Of course, the more interesting work is to move the y values of
	the x function to become the x values of the y function (checking
	the mins and maxs as we go along).
*/
{
	struct curve_points *xp, *new_list, *yp = start_plot, *tmp, 
			*free_list, *free_head=NULL;
	int i, tlen, curve; 
	char *new_title;
	double lxmin, lxmax, temp;

	if (autoscale_lx) {
		lxmin = VERYLARGE;
		lxmax = -VERYLARGE;
	} else {
		lxmin = xmin;
		lxmax = xmax;
	}

/* 
	Ok, go through all the plots and move FUNC types together.  Note: this
	originally was written to look for a NULL next pointer, but gnuplot 
	wants to be sticky in grabbing memory and the right number of items
	in the plot list is controlled by the plot_num variable.

	Since gnuplot wants to do this sticky business, a free_list of 
	curve_points is kept and then tagged onto the end of the plot list as
	this seems more in the spirit of the original memory behavior than
	simply freeing the memory.  I'm personally not convinced this sort
	of concern is worth it since the time spent computing points seems
	to dominate any garbage collecting that might be saved here...
*/
	new_list = xp = start_plot; 
	yp = xp->next_cp;
   curve = 0;
	for (; curve < *plot_num; xp = xp->next_cp,yp = yp->next_cp,curve++) {
		if (xp->plot_type != FUNC) {
			continue;
		}
	/* Here's a FUNC parametric function defined as two parts. */
		--(*plot_num);
	/* 
		Go through all the points assigning the y's from xp to be the
		x's for yp.  Check max's and min's as you go.
	*/
		for (i = 0; i < yp->p_count; ++i) {
		/* 
			Throw away excess xp points, mark excess yp points as OUTRANGE.
		*/
			if (i > xp->p_count) {
				yp->points[i].type = OUTRANGE;
				continue;
			}
		/* 
			Just as we had to do when we computed y values--now check that
			x's (computed parametrically) are in the permitted ranges as well.
		*/
			temp = xp->points[i].y;   /* New x value for yp function. */
			yp->points[i].x = temp;
		/* Handle undefined values differently from normal ranges. */
			if (xp->points[i].type == UNDEFINED)
				yp->points[i].type = xp->points[i].type;  
			if (autoscale_lx || polar
					   || inrange(temp, lxmin, lxmax)) {
			   if (autoscale_lx && temp < lxmin) lxmin = temp;
				if (autoscale_lx && temp > lxmax) lxmax = temp;
			} else
			yp->points[i].type = OUTRANGE;  /* Due to x value. */
		}
   /* Ok, fix up the title to include both the xp and yp plots. */
		if (xp->title && xp->title[0] != '\0') {
			tlen = strlen (yp->title) + strlen (xp->title) + 3;
      	new_title = alloc ((unsigned int) tlen, "string");
			strcpy (new_title, xp->title);  
			strcat (new_title, ", ");       /* + 2 */
			strcat (new_title, yp->title);  /* + 1 = + 3 */
			free (yp->title);
			yp->title = new_title;
		}
	/* Eliminate the first curve (xparam) and just use the second. */
		if (xp == start_plot) {
		/* Simply nip off the first element of the list. */
			new_list = first_plot = yp;
			xp = xp->next_cp;
			if (yp->next_cp != NULL)
				yp = yp->next_cp;
		/* Add start_plot to the free_list. */
			if (free_head == NULL) {
				free_list = free_head = start_plot;
				free_head->next_cp = NULL;
			} else {
				free_list->next_cp = start_plot;
				start_plot->next_cp = NULL;
				free_list = start_plot;
			}
		}
		else {
		/* Here, remove the xp node and replace it with the yp node. */
			tmp = xp;
		/* Pass over any data files that might have been in place. */
			while (new_list->next_cp && new_list->next_cp != xp) 
				new_list = new_list->next_cp;
			new_list->next_cp = yp;
			new_list = new_list->next_cp;
			xp = xp->next_cp;
			if (yp->next_cp != NULL)
				yp = yp->next_cp;
		/* Add tmp to the free_list. */
			tmp->next_cp = NULL;
			if (free_head == NULL) {
				free_list = free_head = tmp;
			} else {
				free_list->next_cp = tmp;
				free_list = tmp;
			}
		}
	}
/* Ok, stick the free list at the end of the curve_points plot list. */
	while (new_list->next_cp != NULL)
		new_list = new_list->next_cp;
	new_list->next_cp = free_head;

/* Report the overall graph mins and maxs. */
	*x_min = lxmin;
	*x_max = lxmax;
}

void parametric_3dfixup(start_plot, plot_num, x_min, x_max, y_min, y_max,
							    z_min, z_max)
struct surface_points *start_plot;
int *plot_num;
double *x_min, *x_max, *y_min, *y_max, *z_min, *z_max;
/*
	The hardest part of this routine is collapsing the FUNC plot types
   in the list (which are gauranteed to occur in (x,y,z) triplets while 
	preserving the non-FUNC type plots intact.  This means we have to
	work our way through various lists.  Examples (hand checked):
		start_plot:F1->F2->F3->NULL ==> F3->NULL
		start_plot:F1->F2->F3->F4->F5->F6->NULL ==> F3->F6->NULL
		start_plot:F1->F2->F3->D1->D2->F4->F5->F6->D3->NULL ==>
						F3->D1->D2->F6->D3->NULL
*/
{
	struct surface_points *xp, *yp, *zp, *new_list, *tmp, 
			*free_list, *free_head=NULL;
	struct iso_curve *icrvs, *xicrvs, *yicrvs, *zicrvs;
	int i, tlen, surface;
	char *new_title;
	double lxmin, lxmax, lymin, lymax, lzmin, lzmax, temp;

	if (autoscale_lx) {
		lxmin = VERYLARGE;
		lxmax = -VERYLARGE;
	} else {
		lxmin = xmin;
		lxmax = xmax;
	}

	if (autoscale_ly) {
		lymin = VERYLARGE;
		lymax = -VERYLARGE;
	} else {
		lymin = ymin;
		lymax = ymax;
	}

	if (autoscale_lz) {
		lzmin = VERYLARGE;
		lzmax = -VERYLARGE;
	} else {
		lzmin = zmin;
		lzmax = zmax;
	}

/* 
	Ok, go through all the plots and move FUNC3D types together.  Note:
	this originally was written to look for a NULL next pointer, but
	gnuplot wants to be sticky in grabbing memory and the right number
	of items in the plot list is controlled by the plot_num variable.

	Since gnuplot wants to do this sticky business, a free_list of 
	surface_points is kept and then tagged onto the end of the plot list as
	this seems more in the spirit of the original memory behavior than
	simply freeing the memory.  I'm personally not convinced this sort
	of concern is worth it since the time spent computing points seems
	to dominate any garbage collecting that might be saved here...
*/
	new_list = xp = start_plot; 
	for (surface = 0; surface < *plot_num; surface++) {
		if (xp->plot_type != FUNC3D) {
			icrvs = xp->iso_crvs;

			while ( icrvs ) {
				struct coordinate *points = icrvs->points;

				for (i = 0; i < icrvs->p_count; ++i) {
					if (lxmin > points[i].x)
						lxmin = points[i].x;
					if (lxmax < points[i].x)
						lxmax = points[i].x;
					if (lymin > points[i].y)
						lymin = points[i].y;
					if (lymax < points[i].y)
						lymax = points[i].y;
					if (lzmin > points[i].z)
						lzmin = points[i].z;
					if (lzmax < points[i].z)
						lzmax = points[i].z;
				}

				icrvs = icrvs->next;
			}
			xp = xp->next_sp;
			continue;
		}

		yp = xp->next_sp;
		zp = yp->next_sp;

	/* Here's a FUNC3D parametric function defined as three parts. */
		(*plot_num) -= 2;
	/* 
		Go through all the points and assign the x's and y's from xp
		and yp to zp.  Check max's and min's as you go.
	*/
		xicrvs = xp->iso_crvs;
		yicrvs = yp->iso_crvs;
		zicrvs = zp->iso_crvs;
		while ( zicrvs ) {
			struct coordinate *xpoints = xicrvs->points,
				     *ypoints = yicrvs->points,
				     *zpoints = zicrvs->points;
			for (i = 0; i < zicrvs->p_count; ++i) {
				zpoints[i].x = xpoints[i].z;
				zpoints[i].y = ypoints[i].z;

				if (lxmin > zpoints[i].x) lxmin = zpoints[i].x;
				if (lxmax < zpoints[i].x) lxmax = zpoints[i].x;
				if (lymin > zpoints[i].y) lymin = zpoints[i].y;
				if (lymax < zpoints[i].y) lymax = zpoints[i].y;
				if (lzmin > zpoints[i].z) lzmin = zpoints[i].z;
				if (lzmax < zpoints[i].z) lzmax = zpoints[i].z;
			}
			xicrvs = xicrvs->next;
			yicrvs = yicrvs->next;
			zicrvs = zicrvs->next;
		}

	/* Ok, fix up the title to include xp and yp plots. */
		if ((xp->title && xp->title[0] != '\0') ||
		    (yp->title && yp->title[0] != '\0')) {
			tlen = (xp->title ? strlen(xp->title) : 0) +
			       (yp->title ? strlen(yp->title) : 0) +
			       (zp->title ? strlen(zp->title) : 0) + 5;
			new_title = alloc ((unsigned int) tlen, "string");
			new_title[0] = 0;
			if (xp->title) {
				strcat(new_title, xp->title);
				strcat(new_title, ", ");       /* + 2 */
			}
			if (yp->title) {
				strcat(new_title, yp->title);
				strcat(new_title, ", ");       /* + 2 */
			}
			if (zp->title) {
				strcat(new_title, zp->title);
			}
			free (zp->title);
			zp->title = new_title;
		}

	/* Eliminate the first two surfaces (xp and yp) and just use the third. */
		if (xp == start_plot) {
		/* Simply nip off the first two elements of the list. */
			new_list = first_3dplot = zp;
			xp = zp->next_sp;
		/* Add xp and yp to the free_list. */
			if (free_head == NULL) {
				free_head = start_plot;
			} else {
				free_list->next_sp = start_plot;
			}
			free_list = start_plot->next_sp;
			free_list->next_sp = NULL;
		}
		else {
		/* Here, remove the xp,yp nodes and replace them with the zp node. */
			tmp = xp;
		/* Pass over any data files that might have been in place. */
			while (new_list->next_sp && new_list->next_sp != xp)
				new_list = new_list->next_sp;
			new_list->next_sp = zp;
			new_list = zp;
			xp = zp->next_sp;
		/* Add tmp to the free_list. */
			if (free_head == NULL) {
				free_head = tmp;
			} else {
				free_list->next_sp = tmp;
			}
			free_list = tmp->next_sp;
			free_list->next_sp = NULL;
		}
	}
/* Ok, stick the free list at the end of the surface_points plot list. */
	while (new_list->next_sp != NULL)
		new_list = new_list->next_sp;
	new_list->next_sp = free_head;
      if (lxmax - lxmin < zero) {
          if (fabs(lxmax) < zero) {
              lxmin = -1.0;
              lxmax = 1.0;
          }
          else {
              lxmin *= 0.9;
              lxmax *= 1.1;
          }
      }
      if (lymax - lymin < zero) {
          if (fabs(lymax) < zero) {
              lymin = -1.0;
              lymax = 1.0;
          }
          else {
              lymin *= 0.9;
              lymax *= 1.1;
          }
      }
      if (lzmax - lzmin < zero) {
          if (fabs(lzmax) < zero) {
              lzmin = -1.0;
              lzmax = 1.0;
          }
          else {
              lzmin *= 0.9;
              lzmax *= 1.1;
          }
      }

/* Report the overall graph mins and maxs. */
	if (autoscale_lx) {
		*x_min = (log_x ? pow(10.0, lxmin) : lxmin);
		*x_max = (log_x ? pow(10.0, lxmax) : lxmax);
	}
	else {
		*x_min = xmin;
		*x_max = xmax;
	}
	if (autoscale_ly) {
		*y_min = (log_y ? pow(10.0, lymin) : lymin);
		*y_max = (log_y ? pow(10.0, lymax) : lymax);
	}
	else {
		*y_min = ymin;
		*y_max = ymax;
	}
	if (autoscale_lz) {
		*z_min = (log_z ? pow(10.0, lzmin) : lzmin);
		*z_max = (log_z ? pow(10.0, lzmax) : lzmax);
	}
	else {
		*z_min = zmin;
		*z_max = zmax;
	}
}

#ifdef AMIGA_LC_5_1
void sleep(delay)
unsigned int delay;
{
  Delay(50 * delay);
}
#endif

#ifdef AMIGA_AC_5
void sleep(delay)
unsigned int delay;
{
unsigned long time_is_up;
	time_is_up = time(NULL) + (unsigned long) delay; 
	while (time(NULL)<time_is_up)
		/* wait */ ;
}
#endif

#ifdef MSDOS
#ifndef __TURBOC__	/* Turbo C already has sleep() */
#ifndef __ZTC__ 	/* ZTC already has usleep() */
/* kludge to provide sleep() for msc 5.1 */
void sleep(delay)
unsigned int delay;
{
unsigned long time_is_up;
	time_is_up = time(NULL) + (unsigned long) delay; 
	while (time(NULL)<time_is_up)
		/* wait */ ;
}
#endif /* not ZTC */
#endif /* not TURBOC */
#endif /* MSDOS */


/* Support for input, shell, and help for various systems */

#ifdef vms

#include <descrip.h>
#include <rmsdef.h>
#include <errno.h>
#include <smgdef.h>
#include <smgmsg.h>

extern lib$get_input(), lib$put_output();
extern smg$read_composed_line();

int vms_len;

unsigned int status[2] = {1, 0};

static char help[MAX_LINE_LEN+1] = "gnuplot";

$DESCRIPTOR(prompt_desc,PROMPT);
$DESCRIPTOR(line_desc,input_line);

$DESCRIPTOR(help_desc,help);
$DESCRIPTOR(helpfile_desc,"GNUPLOT$HELP");


read_line(prompt)
char *prompt;
{
    int more, start=0;
    char expand_prompt[40];

    prompt_desc.dsc$w_length = strlen (prompt);
    prompt_desc.dsc$a_pointer = prompt;
    (void) strcpy (expand_prompt, "_");
    (void) strncat (expand_prompt, prompt, 38);
    do {
        line_desc.dsc$w_length = MAX_LINE_LEN - start;
        line_desc.dsc$a_pointer = &input_line[start];
        switch(status[1] = smg$read_composed_line(&vms_vkid,0,&line_desc, &prompt_desc, &vms_len)){
		  case SMG$_EOF:
		  done(IO_SUCCESS);	/* ^Z isn't really an error */
		  break;
		  case RMS$_TNS:	/* didn't press return in time *
						   /
						   vms_len--; /* skip the last character */
		  break;			/* and parse anyway */
		  case RMS$_BES:	/* Bad Escape Sequence */
		  case RMS$_PES:	/* Partial Escape Sequence */
		  sys$putmsg(status);
		  vms_len = 0;		/* ignore the line */
		  break;
		  case SS$_NORMAL:
		  break;			/* everything's fine */
		  default:
		  done(status[1]);	/* give the error message */
        }
        start += vms_len;
        input_line[start] = '\0';
	   inline_num++;
        if (input_line[start-1] == '\\') {
		  /* Allow for a continuation line. */
		  prompt_desc.dsc$w_length = strlen (expand_prompt);
		  prompt_desc.dsc$a_pointer = expand_prompt;
		  more = 1;
		  --start;
        }
        else {
		  line_desc.dsc$w_length = strlen(input_line);
		  line_desc.dsc$a_pointer = input_line;
		  more = 0;
        }
    } while (more);
}


do_help()
{
	help_desc.dsc$w_length = strlen(help);
	if ((vaxc$errno = lbr$output_help(lib$put_output,0,&help_desc,
		&helpfile_desc,0,lib$get_input)) != SS$_NORMAL)
			os_error("can't open GNUPLOT$HELP",NO_CARET);
}


do_shell()
{
	if ((vaxc$errno = lib$spawn()) != SS$_NORMAL) {
		os_error("spawn error",NO_CARET);
	}
}


do_system()
{
	input_line[0] = ' ';	/* an embarrassment, but... */

	if ((vaxc$errno = lib$spawn(&line_desc)) != SS$_NORMAL)
		os_error("spawn error",NO_CARET);

	(void) putc('\n',stderr);
}

#else /* vms */

/* do_help: (not VMS, although it would work)
 * Give help to the user. 
 * It parses the command line into helpbuf and supplies help for that 
 * string. Then, if there are subtopics available for that key,
 * it prompts the user with this string. If more input is
 * given, do_help is called recursively, with the argument the index of 
 * null character in the string. Thus a more specific help can be 
 * supplied. This can be done repeatedly. 
 * If null input is given, the function returns, effecting a
 * backward climb up the tree.
 * David Kotz (David.Kotz@Dartmouth.edu) 10/89
 */
do_help()
{
    static char *helpbuf = NULL;
    static char *prompt = NULL;
    int base;				/* index of first char AFTER help string */
    int len;				/* length of current help string */
    BOOLEAN more_help;
    BOOLEAN only;			/* TRUE if only printing subtopics */
    int subtopics;			/* 0 if no subtopics for this topic */
    int start;				/* starting token of help string */
	char *help_ptr;			/* name of help file */

	if ( (help_ptr = getenv("GNUHELP")) == (char *)NULL )
		/* if can't find environment variable then just use HELPFILE */
		help_ptr = HELPFILE;

    /* Since MSDOS DGROUP segment is being overflowed we can not allow such  */
    /* huge static variables (1k each). Instead we dynamically allocate them */
    /* on the first call to this function...				     */
    if (helpbuf == NULL) {
	helpbuf = alloc(MAX_LINE_LEN, "help buffer");
	prompt = alloc(MAX_LINE_LEN, "help prompt");
	helpbuf[0] = prompt[0] = 0;
    }

    len = base = strlen(helpbuf);

    /* find the end of the help command */
    for (start = c_token; !(END_OF_COMMAND); c_token++)
	 ;
    /* copy new help input into helpbuf */
    if (len > 0)
	 helpbuf[len++] = ' ';	/* add a space */
    capture(helpbuf+len, start, c_token-1);
    squash_spaces(helpbuf+base); /* only bother with new stuff */
    lower_case(helpbuf+base); /* only bother with new stuff */
    len = strlen(helpbuf);

    /* now, a lone ? will print subtopics only */
    if (strcmp(helpbuf + (base ? base+1 : 0), "?") == 0) {
	   /* subtopics only */
	   subtopics = 1;
	   only = TRUE;
	   helpbuf[base] = '\0';	/* cut off question mark */
    } else {
	   /* normal help request */
	   subtopics = 0;
	   only = FALSE;
    }

    switch (help(helpbuf, help_ptr, &subtopics)) {
	   case H_FOUND: {
		  /* already printed the help info */
		  /* subtopics now is true if there were any subtopics */
		  screen_ok = FALSE;
    
		  do {
			 if (subtopics && !only) {
				/* prompt for subtopic with current help string */
				if (len > 0)
				  (void) sprintf(prompt, "Subtopic of %s: ", helpbuf);
				else
				  (void) strcpy(prompt, "Help topic: ");
				read_line(prompt);
				num_tokens = scanner(input_line);
				c_token = 0;
				more_help = !(END_OF_COMMAND);
				if (more_help)
				  /* base for next level is all of current helpbuf */
				  do_help();
			 } else 
			   more_help = FALSE;
		  } while(more_help);
    
		  break;
	   }
	   case H_NOTFOUND: {
		  printf("Sorry, no help for '%s'\n", helpbuf);
		  break;
	   }
	   case H_ERROR: {
		  perror(help_ptr);
		  break;
	   }
	   default: {		/* defensive programming */
		  int_error("Impossible case in switch\n", NO_CARET);
		  /* NOTREACHED */
	   }
    }
    
    helpbuf[base] = '\0';	/* cut it off where we started */
}

#ifdef AMIGA_AC_5
char strg0[256];
#endif

do_system()
{
#ifdef AMIGA_AC_5
   char *parms[80];
   void getparms();

   getparms(input_line+1,parms);
   if(fexecv(parms[0],parms) < 0)
#else
   if (system(input_line + 1))
#endif /* AMIGA_AC_5 */
      os_error("system() failed",NO_CARET);
}

#ifdef AMIGA_AC_5

/******************************************************************************/
/*                                                                            */
/*  Parses the command string (for fexecv use) and  converts the first token  */
/*     to lower case                                                          */
/*                                                                            */
/******************************************************************************/

void getparms(command,parms)
   char *command;
   char **parms;
   {
   register int i = 0;                         /* A bunch of indices          */
   register int j = 0;
   register int k = 0;

   while(*(command+j) != '\0')                 /* Loop on string characters   */
      {
      parms[k++] = strg0+i;
      while(*(command+j) == ' ') ++j;
      while(*(command+j) != ' ' && *(command+j) != '\0')
         {
         if(*(command+j) == '"')               /* Get quoted string           */
            for(*(strg0+(i++)) = *(command+(j++));
                *(command+j)  != '"';
                *(strg0+(i++)) = *(command+(j++)));
         *(strg0+(i++)) = *(command+(j++));
         }
      *(strg0+(i++)) = '\0';                   /* NUL terminate every token   */
      }
   parms[k] = '\0';

   for(k=strlen(strg0)-1; k>=0; --k)           /* Convert to lower case       */
      *(strg0+k)>='A' && *(strg0+k)<='Z'? *(strg0+k)|=32: *(strg0+k);
   }

#endif /* AMIGA_AC_5 */

#ifdef READLINE
char *
rlgets(s, n, prompt)
char *s;
int n;
char *prompt;
{
      char *readline();
      static char *line = (char *)NULL;

      /* If we already have a line, first free it */
      if(line != (char *)NULL) 
              free(line);

      line = readline((interactive)?prompt:"");

      /* If it's not an EOF */
      if(line) {
	  if (*line)
              add_history(line);
	  strncpy(s, line, n);
	  return s;
      }

      return line;
}
#endif /* READLINE */

#ifdef MSDOS

#ifdef __TURBOC__
/* cgets implemented using dos functions */
/* Maurice Castro 22/5/91 */
char *doscgets(s)
char *s;
{
   long datseg;

   /* protect and preserve segments - call dos to do the dirty work */
   datseg = _DS;

   _DX = FP_OFF(s);
   _DS = FP_SEG(s);
   _AH = 0x0A;
   geninterrupt(33);
   _DS = datseg;

   /* check for a carriage return and then clobber it with a null */
   if (s[s[1]+2] == '\r') 
      s[s[1]+2] = 0;

   /* return the input string */
   return(&(s[2]));
   }
#endif /* __TURBOC__ */


read_line(prompt)
	char *prompt;
{
    register int i;
    int start = 0, ilen = 0;
    BOOLEAN more;
    int last;
    char *p, *crnt_prompt = prompt;
    
#ifndef __ZTC__
	if (interactive) { /* if interactive use console IO so CED will work */
#ifndef READLINE
		cputs(prompt);
#endif /* READLINE */
		do {
		   ilen = MAX_LINE_LEN-start-1;
		   input_line[start] = ilen > 126 ? 126 : ilen;
#ifdef READLINE
		   input_line[start+2] = 0;
		   (void) rlgets(&(input_line[start+2]), ilen, crnt_prompt );
		   if (p = strchr(&(input_line[start+2]), '\r')) *p = 0;
		   if (p = strchr(&(input_line[start+2]), '\n')) *p = 0;
		   input_line[start+1] = strlen(&(input_line[start+2]));
#else /* READLINE */
#ifdef __TURBOC__
		   (void) doscgets(&(input_line[start]));
#else /* __TURBOC__ */
		   (void) cgets(&(input_line[start]));
#endif /* __TURBOC__ */
		   (void) putc('\n',stderr);
#endif /* READLINE */
		   if (input_line[start+2] == 26) {
			  /* end-of-file */
			  (void) putc('\n',stderr);
			  input_line[start] = '\0';
			  inline_num++;
			  if (start > 0)	/* don't quit yet - process what we have */
				more = FALSE;
			  else {
				 (void) putc('\n',stderr);
				 done(IO_SUCCESS);
				 /* NOTREACHED */
			  }
		   } else {
			  /* normal line input */
			  register i = start;
			  while ( (input_line[i] = input_line[i+2]) != (char)NULL )
				i++;		/* yuck!  move everything down two characters */

			  inline_num++;
			  last = strlen(input_line) - 1;
			  if (last + 1 >= MAX_LINE_LEN)
				int_error("Input line too long",NO_CARET);
					 
			  if (input_line[last] == '\\') { /* line continuation */
				 start = last;
				 more = TRUE;
			  } else
				more = FALSE;
		   }
#ifndef READLINE
		   if (more)
			cputs("> ");
#else
		   crnt_prompt = "> ";
#endif /* READLINE */
		} while(more);
	}
	else { /* not interactive */
#endif /* not ZTC */
		if (interactive)
		 fputs(prompt,stderr);
		do {
		   /* grab some input */
		   if ( fgets(&(input_line[start]), MAX_LINE_LEN - start, stdin) 
					== (char *)NULL ) {
			  /* end-of-file */
			  if (interactive)
				(void) putc('\n',stderr);
			  input_line[start] = '\0';
			  inline_num++;
			  if (start > 0)	/* don't quit yet - process what we have */
				more = FALSE;
			  else
				done(IO_SUCCESS); /* no return */
		   } else {
			  /* normal line input */
			  last = strlen(input_line) - 1;
			  if (input_line[last] == '\n') { /* remove any newline */
				 input_line[last] = '\0';
				 /* Watch out that we don't backup beyond 0 (1-1-1) */
				 if (last > 0) --last;
				 inline_num++;
			  } else if (last+1 >= MAX_LINE_LEN)
				int_error("Input line too long",NO_CARET);
					 
			  if (input_line[last] == '\\') { /* line continuation */
				 start = last;
				 more = TRUE;
			  } else
				more = FALSE;
		   }
			if (more && interactive)
			fputs("> ", stderr);
		} while(more);
#ifndef __ZTC__
	}
#endif
}


do_shell()
{
register char *comspec;
	if ((comspec = getenv("COMSPEC")) == (char *)NULL)
		comspec = "\command.com";
	if (spawnl(P_WAIT,comspec,NULL) == -1)
		os_error("unable to spawn shell",NO_CARET);
}

#else /* MSDOS */
		/* plain old Unix */

read_line(prompt)
	char *prompt;
{
    int start = 0;
    BOOLEAN more = FALSE;
    int last = 0;

#ifndef READLINE
    if (interactive)
	 fputs(prompt,stderr);
#endif /* READLINE */
    do {
	   /* grab some input */
#ifdef READLINE
	 if (((interactive)
		 ?rlgets(&(input_line[start]), MAX_LINE_LEN - start,
				((more)?"> ":prompt))
		 :fgets(&(input_line[start]), MAX_LINE_LEN - start, stdin))
                              == (char *)NULL ) {
#else
	   if ( fgets(&(input_line[start]), MAX_LINE_LEN - start, stdin) 
				== (char *)NULL ) {
#endif /* READLINE */
		  /* end-of-file */
		  if (interactive)
		    (void) putc('\n',stderr);
		  input_line[start] = '\0';
		  inline_num++;
		  if (start > 0)	/* don't quit yet - process what we have */
		    more = FALSE;
		  else
		    done(IO_SUCCESS); /* no return */
	   } else {
		  /* normal line input */
		  last = strlen(input_line) - 1;
		  if (input_line[last] == '\n') { /* remove any newline */
			 input_line[last] = '\0';
                /* Watch out that we don't backup beyond 0 (1-1-1) */
			 if (last > 0) --last;
			 inline_num++;
		  } else if (last+1 >= MAX_LINE_LEN)
		    int_error("Input line too long",NO_CARET);
				 
		  if (input_line[last] == '\\') { /* line continuation */
			 start = last;
			 more = TRUE;
		  } else
		    more = FALSE;
	   }
#ifndef READLINE
        if (more && interactive)
		fputs("> ", stderr);
#endif
    } while(more);
}

#ifdef VFORK

do_shell()
{
register char *shell;
register int p;
static int execstat;
	if (!(shell = getenv("SHELL")))
		shell = SHELL;
#ifdef AMIGA_AC_5
	execstat = fexecl(shell,shell,NULL);
#else
	if ((p = vfork()) == 0) {
		execstat = execl(shell,shell,NULL);
		_exit(1);
	} else if (p == -1)
		os_error("vfork failed",c_token);
	else
		while (wait(NULL) != p)
#endif
			;
	if (execstat == -1)
		os_error("shell exec failed",c_token);
	(void) putc('\n',stderr);
}
#else /* VFORK */

#ifdef AMIGA_LC_5_1
do_shell()
{
register char *shell;
	if (!(shell = getenv("SHELL")))
		shell = SHELL;

	if (system(shell))
		os_error("system() failed",NO_CARET);

	(void) putc('\n',stderr);
}
#else /* AMIGA_LC_5_1 */

#define EXEC "exec "
do_shell()
{
static char exec[100] = EXEC;
register char *shell;
	if (!(shell = getenv("SHELL")))
		shell = SHELL;

	if (system(strncpy(&exec[sizeof(EXEC)-1],shell,
		sizeof(exec)-sizeof(EXEC)-1)))
		os_error("system() failed",NO_CARET);

	(void) putc('\n',stderr);
}
#endif /* AMIGA_LC_5_1 */
#endif /* VFORK */
#endif /* MSDOS */
#endif /* vms */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/contour.c version [702d747f5e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
#ifndef lint
static char *RCSid = "$Id: contour.c,v 3.26 92/03/24 22:35:54 woo Exp Locker: woo $";
#endif

/* GNUPLOT - contour.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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:
 *       Gershon Elber
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include "plot.h"

#define DEFAULT_NUM_OF_ZLEVELS  10  /* Some dflt values (setable via flags). */
#define DEFAULT_NUM_APPROX_PTS  5
#define DEFAULT_BSPLINE_ORDER  3
#define MAX_NUM_OF_ZLEVELS      100 /* Some max. values (setable via flags). */
#define MAX_NUM_APPROX_PTS      100
#define MAX_BSPLINE_ORDER      10

#define INTERP_NOTHING   0            /* Kind of interpolations on contours. */
#define INTERP_CUBIC     1                           /* Cubic spline interp. */
#define APPROX_BSPLINE   2                         /* Bspline interpolation. */

#define ACTIVE   1                    /* Status of edges at certain Z level. */
#define INACTIVE 2

#define OPEN_CONTOUR     1                                 /* Contour kinds. */
#define CLOSED_CONTOUR   2

#define EPSILON  1e-5              /* Used to decide if two float are equal. */
#define INFINITY 1e10

#ifndef TRUE
#define TRUE     -1
#define FALSE    0
#endif

#define DEFAULT_NUM_CONTOURS	10
#define MAX_POINTS_PER_CNTR 	100
#define SHIFT_Z_EPSILON		0.000301060 /* Dec. change of poly bndry hit.*/

#define abs(x)  ((x) > 0 ? (x) : (-(x)))
#define sqr(x)  ((x) * (x))

#ifndef AMIGA_AC_5
extern double sqrt();
#endif /* not AMIGA_AC_5 */
typedef double tri_diag[3];         /* Used to allocate the tri-diag matrix. */
typedef double table_entry[4];	       /* Cubic spline interpolation 4 coef. */

struct vrtx_struct {
    double X, Y, Z;                       /* The coordinates of this vertex. */
    struct vrtx_struct *next;                             /* To chain lists. */
};

struct edge_struct {
    struct poly_struct *poly[2];   /* Each edge belongs to up to 2 polygons. */
    struct vrtx_struct *vertex[2]; /* The two extreme points of this vertex. */
    struct edge_struct *next;                             /* To chain lists. */
    int status, /* Status flag to mark edges in scanning at certain Z level. */
	boundary;                   /* True if this edge is on the boundary. */
};

struct poly_struct {
    struct edge_struct *edge[3];           /* As we do triangolation here... */
    struct poly_struct *next;                             /* To chain lists. */
};

struct cntr_struct {	       /* Contours are saved using this struct list. */
    double X, Y;                          /* The coordinates of this vertex. */
    struct cntr_struct *next;                             /* To chain lists. */
};

static int test_boundary;    /* If TRUE look for contours on boundary first. */
static struct gnuplot_contours *contour_list = NULL;
static double crnt_cntr[MAX_POINTS_PER_CNTR * 2];
static int crnt_cntr_pt_index = 0;
static double contour_level = 0.0;
static table_entry *hermit_table = NULL;    /* Hold hermite table constants. */
static int num_of_z_levels = DEFAULT_NUM_OF_ZLEVELS;  /* # Z contour levels. */
static int num_approx_pts = DEFAULT_NUM_APPROX_PTS;/* # pts per approx/inter.*/
static int bspline_order = DEFAULT_BSPLINE_ORDER;   /* Bspline order to use. */
static int interp_kind = INTERP_NOTHING;  /* Linear, Cubic interp., Bspline. */

static void gen_contours();
static int update_all_edges();
static struct cntr_struct *gen_one_contour();
static struct cntr_struct *trace_contour();
static struct cntr_struct *update_cntr_pt();
static int fuzzy_equal();
static void gen_triangle();
static struct vrtx_struct *gen_vertices();
static struct edge_struct *gen_edges_middle();
static struct edge_struct *gen_edges();
static struct poly_struct *gen_polys();
static void free_contour();
static void put_contour();
static put_contour_nothing();
static put_contour_cubic();
static put_contour_bspline();
static calc_tangent();
static int count_contour();
static complete_spline_interp();
static calc_hermit_table();
static hermit_interp();
static prepare_spline_interp();
static int solve_tri_diag();
static gen_bspline_approx();
static double fetch_knot();
static eval_bspline();

/*
 * Entry routine to this whole set of contouring module.
 */
struct gnuplot_contours *contour(num_isolines, iso_lines,
				 ZLevels, approx_pts, kind, order1)
int num_isolines;
struct iso_curve *iso_lines;
int ZLevels, approx_pts, kind, order1;
{
    int i;
    struct poly_struct *p_polys, *p_poly;
    struct edge_struct *p_edges, *p_edge;
    struct vrtx_struct *p_vrts, *p_vrtx;
    double x_min, y_min, z_min, x_max, y_max, z_max, z, dz, z_scale = 1.0;

    num_of_z_levels = ZLevels;
    num_approx_pts = approx_pts;
    bspline_order = order1 - 1;
    interp_kind = kind;

    contour_list = NULL;

    if (interp_kind == INTERP_CUBIC) calc_hermit_table();

    gen_triangle(num_isolines, iso_lines, &p_polys, &p_edges, &p_vrts,
		&x_min, &y_min, &z_min, &x_max, &y_max, &z_max);
    dz = (z_max - z_min) / (num_of_z_levels+1);
    /* Step from z_min+dz upto z_max-dz in num_of_z_levels times. */
    z = z_min + dz;
    crnt_cntr_pt_index = 0;

    for (i=0; i<num_of_z_levels; i++, z += dz) {
	contour_level = z;
	gen_contours(p_edges, z + dz * SHIFT_Z_EPSILON, x_min, x_max,
							y_min, y_max);
    }

    /* Free all contouring related temporary data. */
    while (p_polys) {
	p_poly = p_polys -> next;
	free (p_polys);
	p_polys = p_poly;
    }
    while (p_edges) {
	p_edge = p_edges -> next;
	free (p_edges);
	p_edges = p_edge;
    }
    while (p_vrts) {
	p_vrtx = p_vrts -> next;
	free (p_vrts);
	p_vrts = p_vrtx;
    }

    if (interp_kind == INTERP_CUBIC) free(hermit_table);

    return contour_list;
}

/*
 * Adds another point to the currently build contour.
 */
add_cntr_point(x, y)
double x, y;
{
    int index;

    if (crnt_cntr_pt_index >= MAX_POINTS_PER_CNTR-1) {
	index = crnt_cntr_pt_index - 1;
	end_crnt_cntr();
	crnt_cntr[0] = crnt_cntr[index * 2];
	crnt_cntr[1] = crnt_cntr[index * 2 + 1];
	crnt_cntr_pt_index = 1; /* Keep the last point as first of this one. */
    }
    crnt_cntr[crnt_cntr_pt_index * 2] = x;
    crnt_cntr[crnt_cntr_pt_index * 2 + 1] = y;
    crnt_cntr_pt_index++;
}

/*
 * Done with current contour - create gnuplot data structure for it.
 */
end_crnt_cntr()
{
    int i;
    struct gnuplot_contours *cntr = (struct gnuplot_contours *)
					alloc(sizeof(struct gnuplot_contours),
					      "gnuplot_contour");

    cntr->coords = (struct coordinate *) alloc(sizeof(struct coordinate) *
							  crnt_cntr_pt_index,
					       "contour coords");
    for (i=0; i<crnt_cntr_pt_index; i++) {
	cntr->coords[i].x = crnt_cntr[i * 2];
	cntr->coords[i].y = crnt_cntr[i * 2 + 1];
	cntr->coords[i].z = contour_level;
    }
    cntr->num_pts = crnt_cntr_pt_index;

    cntr->next = contour_list;
    contour_list = cntr;

    crnt_cntr_pt_index = 0;
}

/*
 * Generates all contours by tracing the intersecting triangles.
 */
static void gen_contours(p_edges, z_level, x_min, x_max, y_min, y_max)
struct edge_struct *p_edges;
double z_level, x_min, x_max, y_min, y_max;
{
    int num_active,                        /* Number of edges marked ACTIVE. */
	contour_kind;                /* One of OPEN_CONTOUR, CLOSED_CONTOUR. */
    struct cntr_struct *p_cntr;

    num_active = update_all_edges(p_edges, z_level);           /* Do pass 1. */

    test_boundary = TRUE;        /* Start to look for contour on boundaries. */

    while (num_active > 0) {                                   /* Do Pass 2. */
        /* Generate One contour (and update MumActive as needed): */
	p_cntr = gen_one_contour(p_edges, z_level, &contour_kind, &num_active);
	put_contour(p_cntr, z_level, x_min, x_max, y_min, y_max,
			      contour_kind); /* Emit it in requested format. */
    }
}

/*
 * Does pass 1, or marks the edges which are active (crosses this z_level)
 * as ACTIVE, and the others as INACTIVE:
 * Returns number of active edges (marked ACTIVE).
 */
static int update_all_edges(p_edges, z_level)
struct edge_struct *p_edges;
double z_level;
{
    int count = 0;

    while (p_edges) {
	if (((p_edges -> vertex[0] -> Z >= z_level) &&
	     (p_edges -> vertex[1] -> Z <= z_level)) ||
	    ((p_edges -> vertex[1] -> Z >= z_level) &&
	     (p_edges -> vertex[0] -> Z <= z_level))) {
	    p_edges -> status = ACTIVE;
	    count++;
	}
	else p_edges -> status = INACTIVE;
	p_edges = p_edges -> next;
    }

    return count;
}

/*
 * Does pass 2, or find one complete contour out of the triangolation data base:
 * Returns a pointer to the contour (as linked list), contour_kind is set to
 * one of OPEN_CONTOUR, CLOSED_CONTOUR, and num_active is updated.
 */
static struct cntr_struct *gen_one_contour(p_edges, z_level, contour_kind,
								num_active)
struct edge_struct *p_edges;
double z_level;
int *contour_kind, *num_active;
{
    struct edge_struct *pe_temp;

    if (test_boundary) {    /* Look for something to start with on boundary: */
	pe_temp = p_edges;
	while (pe_temp) {
	    if ((pe_temp -> status == ACTIVE) && (pe_temp -> boundary)) break;
	    pe_temp = pe_temp -> next;
	}
	if (!pe_temp) test_boundary = FALSE;/* No more contours on boundary. */
	else {
	    *contour_kind = OPEN_CONTOUR;
	    return trace_contour(pe_temp, z_level, num_active, *contour_kind);
	}
    }

    if (!test_boundary) {        /* Look for something to start with inside: */
	pe_temp = p_edges;
	while (pe_temp) {
	    if ((pe_temp -> status == ACTIVE) && (!(pe_temp -> boundary)))
		break;
	    pe_temp = pe_temp -> next;
	}
	if (!pe_temp) {
	    *num_active = 0;
	    return NULL;
	}
	else {
	    *contour_kind = CLOSED_CONTOUR;
	    return trace_contour(pe_temp, z_level, num_active, *contour_kind);
	}
    }
    return NULL;		     /* We should never be here, but lint... */
}

/*
 * Search the data base along a contour starts at the edge pe_start until
 * a boundary edge is detected or until we close the loop back to pe_start.
 * Returns a linked list of all the points on the contour
 * Also decreases num_active by the number of points on contour.
 */
static struct cntr_struct *trace_contour(pe_start, z_level, num_active,
								contour_kind)
struct edge_struct *pe_start;
double z_level;
int *num_active, contour_kind;
{
    int i, in_middle;       /* If TRUE the z_level is in the middle of edge. */
    struct cntr_struct *p_cntr, *pc_tail;
    struct edge_struct *p_edge = pe_start, *p_next_edge;
    struct poly_struct *p_poly, *PLastpoly = NULL;

    /* Generate the header of the contour - the point on pe_start. */
    if (contour_kind == OPEN_CONTOUR) pe_start -> status = INACTIVE;
    (*num_active)--;
    p_cntr = pc_tail = update_cntr_pt(pe_start, z_level, &in_middle);
    if (!in_middle) {
	return NULL;
    }

    do {
	/* Find polygon to continue (Not where we came from - PLastpoly): */
	if (p_edge -> poly[0] == PLastpoly) p_poly = p_edge -> poly[1];
	else p_poly = p_edge -> poly[0];
	p_next_edge = NULL;		  /* In case of error, remains NULL. */
	for (i=0; i<3; i++)              /* Test the 3 edges of the polygon: */
	    if (p_poly -> edge[i] != p_edge)
	        if (p_poly -> edge[i] -> status == ACTIVE)
		    p_next_edge = p_poly -> edge[i];
	if (!p_next_edge) {
	    pc_tail -> next = NULL;
	    free_contour(p_cntr);
	    return NULL;
	}
	p_edge = p_next_edge;
	PLastpoly = p_poly;
	p_edge -> status = INACTIVE;
	(*num_active)--;
	pc_tail -> next = update_cntr_pt(p_edge, z_level, &in_middle);
	if (!in_middle) {
	    pc_tail -> next = NULL;
	    free_contour(p_cntr);
	    return NULL;
	}
        pc_tail = pc_tail -> next;
    }
    while ((pe_start != p_edge) && (!p_edge -> boundary));
    pc_tail -> next = NULL;

    return p_cntr;
}

/*
 * Allocates one contour location and update it to to correct position
 * according to z_level and edge p_edge. if z_level is found to be at
 * one of the extreme points nothing is allocated (NULL is returned)
 * and in_middle is set to FALSE.
 */
static struct cntr_struct *update_cntr_pt(p_edge, z_level, in_middle)
struct edge_struct *p_edge;
double z_level;
int *in_middle;
{
    double t;
    struct cntr_struct *p_cntr;

    t = (z_level - p_edge -> vertex[0] -> Z) /
	(p_edge -> vertex[1] -> Z - p_edge -> vertex[0] -> Z);

    if (fuzzy_equal(t, 1.0) || fuzzy_equal(t, 0.0)) {
        *in_middle = FALSE;
        return NULL;
    }
    else {
	*in_middle = TRUE;
	p_cntr = (struct cntr_struct *) alloc(sizeof(struct cntr_struct),
							"contour cntr_struct");
	p_cntr -> X = p_edge -> vertex[1] -> X * t +
		     p_edge -> vertex[0] -> X * (1-t);
	p_cntr -> Y = p_edge -> vertex[1] -> Y * t +
		     p_edge -> vertex[0] -> Y * (1-t);
	return p_cntr;
    }
}

/*
 * Simple routine to decide if two real values are equal by simply
 * calculating the relative/absolute error between them (< EPSILON).
 */
static int fuzzy_equal(x, y)
double x, y;
{
    if (abs(x) > EPSILON)			/* Calculate relative error: */
        return (abs((x - y) / x) < EPSILON);
    else					/* Calculate absolute error: */
	return (abs(x - y) < EPSILON);
}

/*
 * Generate the triangles.
 * Returns the lists (vrtxs edges & polys) via pointers to their heads.
 */
static void gen_triangle(num_isolines, iso_lines, p_polys, p_edges,
	p_vrts, x_min, y_min, z_min, x_max, y_max, z_max)
int num_isolines;
struct iso_curve *iso_lines;
struct poly_struct **p_polys;
struct edge_struct **p_edges;
struct vrtx_struct **p_vrts;
double *x_min, *y_min, *z_min, *x_max, *y_max, *z_max;
{
    int i, grid_x_max = iso_lines->p_count;
    struct vrtx_struct *p_vrtx1, *p_vrtx2, *pv_temp;
    struct edge_struct *p_edge1, *p_edge2, *pe_tail1, *pe_tail2, *pe_temp,
		      *p_edge_middle, *pe_m_tail;
    struct poly_struct *p_poly, *pp_tail;

    *p_polys = NULL;
    *p_edges = NULL;
    *p_vrts = NULL;
    *z_min = INFINITY;
    *y_min = INFINITY;
    *x_min = INFINITY;
    *z_max = -INFINITY;
    *y_max = -INFINITY;
    *x_max = -INFINITY;

    /* Read 1st row. */
    p_vrtx1 = gen_vertices(grid_x_max, iso_lines->points,
			   x_min, y_min, z_min, x_max, y_max, z_max);
    *p_vrts = p_vrtx1;
    /* Gen. its edges.*/
    pe_temp = p_edge1 = gen_edges(grid_x_max, p_vrtx1, &pe_tail1);
    for (i = 1; i < grid_x_max; i++) {/* Mark one side of edges as boundary. */
	pe_temp -> poly[1] = NULL;
	pe_temp = pe_temp -> next;
    }
    for (i = 1; i < num_isolines; i++) { /* Read next column and gen. polys. */
	iso_lines = iso_lines->next;
    	/* Get row into list. */
        p_vrtx2 = gen_vertices(grid_x_max, iso_lines->points,
			       x_min, y_min, z_min, x_max, y_max, z_max);
    	/* Generate its edges. */
        p_edge2 = gen_edges(grid_x_max, p_vrtx2, &pe_tail2);
	/* Generate edges from one vertex list to the other one: */
	p_edge_middle = gen_edges_middle(grid_x_max, p_vrtx1, p_vrtx2,
								 &pe_m_tail);

	/* Now we can generate the polygons themselves (triangles). */
	p_poly = gen_polys(grid_x_max, p_edge1, p_edge_middle, p_edge2,
								 &pp_tail);
        pe_tail1 -> next = (*p_edges);      /* Chain new edges to main list. */
        pe_m_tail -> next = p_edge1;
	*p_edges = p_edge_middle;
	pe_tail1 = pe_tail2;
	p_edge1 = p_edge2;

	pv_temp = p_vrtx2;
	while (pv_temp -> next) pv_temp = pv_temp -> next;
	pv_temp -> next = *p_vrts;
	*p_vrts = p_vrtx1 = p_vrtx2;

        pp_tail -> next = (*p_polys);       /* Chain new polys to main list. */
	*p_polys = p_poly;
    }

    pe_temp = p_edge1;
    for (i = 1; i < grid_x_max; i++) {/* Mark one side of edges as boundary. */
	pe_temp -> poly[0] = NULL;
	pe_temp = pe_temp -> next;
    }

    pe_tail1 -> next = (*p_edges);    /* Chain last edges list to main list. */
    *p_edges = p_edge1;

    /* Update the boundary flag, saved in each edge, and update indexes: */
    pe_temp = (*p_edges);
    i = 1;

    while (pe_temp) {
	pe_temp -> boundary = (!(pe_temp -> poly[0])) ||
			      (!(pe_temp -> poly[1]));
	pe_temp = pe_temp -> next;
    }
}

/*
 * Handles grid_x_max 3D points (One row) and generate linked list for them.
 */
static struct vrtx_struct *gen_vertices(grid_x_max, points,
				      x_min, y_min, z_min, x_max, y_max, z_max)
int grid_x_max;
struct coordinate *points;
double *x_min, *y_min, *z_min, *x_max, *y_max, *z_max;
{
    int i;
    struct vrtx_struct *p_vrtx, *pv_tail, *pv_temp;

    for (i=0; i<grid_x_max; i++) {/* Get a point and generate the structure. */
        pv_temp = (struct vrtx_struct *) alloc(sizeof(struct vrtx_struct),
						"contour vertex");
	pv_temp -> X = points[i].x;
	pv_temp -> Y = points[i].y;
	pv_temp -> Z = points[i].z;

	if (pv_temp -> X > *x_max) *x_max = pv_temp -> X; /* Update min/max. */
	if (pv_temp -> Y > *y_max) *y_max = pv_temp -> Y;
	if (pv_temp -> Z > *z_max) *z_max = pv_temp -> Z;
	if (pv_temp -> X < *x_min) *x_min = pv_temp -> X;
	if (pv_temp -> Y < *y_min) *y_min = pv_temp -> Y;
	if (pv_temp -> Z < *z_min) *z_min = pv_temp -> Z;

	if (i == 0)                              /* First vertex in row: */
	    p_vrtx = pv_tail = pv_temp;
	else {
	    pv_tail -> next = pv_temp;   /* Stick new record as last one. */
	    pv_tail = pv_tail -> next;    /* And continue to last record. */
	}
    }
    pv_tail -> next = NULL;

    return p_vrtx;
}

/*
 * Combines N vertices in pair to form N-1 edges.
 * Returns pointer to the edge list (pe_tail will point on last edge in list).
 */
static struct edge_struct *gen_edges(grid_x_max, p_vrtx, pe_tail)
int grid_x_max;
struct vrtx_struct *p_vrtx;
struct edge_struct **pe_tail;
{
    int i;
    struct edge_struct *p_edge, *pe_temp;

    for (i=0; i<grid_x_max-1; i++) {         /* Generate grid_x_max-1 edges: */
	pe_temp = (struct edge_struct *) alloc(sizeof(struct edge_struct),
						"contour edge");
	pe_temp -> vertex[0] = p_vrtx;              /* First vertex of edge. */
	p_vrtx = p_vrtx -> next;                     /* Skip to next vertex. */
	pe_temp -> vertex[1] = p_vrtx;             /* Second vertex of edge. */
        if (i == 0)                                    /* First edge in row: */
	    p_edge = (*pe_tail) = pe_temp;
	else {
	    (*pe_tail) -> next = pe_temp;   /* Stick new record as last one. */
	    *pe_tail = (*pe_tail) -> next;   /* And continue to last record. */
 	}
    }
    (*pe_tail) -> next = NULL;

    return p_edge;
}

/*
 * Combines 2 lists of N vertices each into edge list:
 * The dots (.) are the vertices list, and the              .  .  .  .
 *  edges generated are alternations of vertical edges      |\ |\ |\ |
 *  (|) and diagonal ones (\).                              | \| \| \|
 *  A pointer to edge list (alternate | , \) is returned    .  .  .  .
 * Note this list will have (2*grid_x_max-1) edges (pe_tail points on last
 * record).
 */
static struct edge_struct *gen_edges_middle(grid_x_max, p_vrtx1, p_vrtx2,
								pe_tail)
int grid_x_max;
struct vrtx_struct *p_vrtx1, *p_vrtx2;
struct edge_struct **pe_tail;
{
    int i;
    struct edge_struct *p_edge, *pe_temp;

    /* Gen first (|). */
    pe_temp = (struct edge_struct *) alloc(sizeof(struct edge_struct),
							"contour edge");
    pe_temp -> vertex[0] = p_vrtx2;                 /* First vertex of edge. */
    pe_temp -> vertex[1] = p_vrtx1;                /* Second vertex of edge. */
    p_edge = (*pe_tail) = pe_temp;

    /* Advance in vrtx list grid_x_max-1 times, and gen. 2 edges /| for each.*/
    for (i=0; i<grid_x_max-1; i++) {
	/* The / edge. */
	pe_temp = (struct edge_struct *) alloc(sizeof(struct edge_struct),
							"contour edge");
	pe_temp -> vertex[0] = p_vrtx1;             /* First vertex of edge. */
	pe_temp -> vertex[1] = p_vrtx2 -> next;    /* Second vertex of edge. */
        (*pe_tail) -> next = pe_temp;       /* Stick new record as last one. */
	*pe_tail = (*pe_tail) -> next;       /* And continue to last record. */

	/* The | edge. */
	pe_temp = (struct edge_struct *) alloc(sizeof(struct edge_struct),
							"contour edge");
	pe_temp -> vertex[0] = p_vrtx2 -> next;     /* First vertex of edge. */
	pe_temp -> vertex[1] = p_vrtx1 -> next;    /* Second vertex of edge. */
        (*pe_tail) -> next = pe_temp;       /* Stick new record as last one. */
	*pe_tail = (*pe_tail) -> next;       /* And continue to last record. */

        p_vrtx1 = p_vrtx1 -> next;   /* Skip to next vertices in both lists. */
        p_vrtx2 = p_vrtx2 -> next;
    }
    (*pe_tail) -> next = NULL;

    return p_edge;
}

/*
 * Combines 3 lists of edges into triangles:
 * 1. p_edge1: Top horizontal edge list:        -----------------------
 * 2. p_edge_middge: middle edge list:         |\  |\  |\  |\  |\  |\  |
 *                                             |  \|  \|  \|  \|  \|  \|
 * 3. p_edge2: Bottom horizontal edge list:     -----------------------
 * Note that p_edge1/2 lists has grid_x_max-1 edges, while p_edge_middle has
 * (2*grid_x_max-1) edges.
 * The routine simple scans the two list    Upper 1         Lower
 * and generate two triangle upper one        ----         | \
 * and lower one from the lists:             0\   |2      0|   \1
 * (Nums. are edges order in polys)             \ |         ----
 * The routine returns a pointer to a                         2
 * polygon list (pp_tail points on last polygon).          1
 *                                                   -----------
 * In addition, the edge lists are updated -        | \   0     |
 * each edge has two pointers on the two            |   \       |
 * (one active if boundary) polygons which         0|1   0\1   0|1
 * uses it. These two pointer to polygons           |       \   |
 * are named: poly[0], poly[1]. The diagram         |    1    \ |
 * on the right show how they are used for the       -----------
 * upper and lower polygons.                             0
 */
static struct poly_struct *gen_polys(grid_x_max, p_edge1, p_edge_middle,
							p_edge2, pp_tail)
int grid_x_max;
struct edge_struct *p_edge1, *p_edge_middle, *p_edge2;
struct poly_struct **pp_tail;
{
    int i;
    struct poly_struct *p_poly, *pp_temp;

    p_edge_middle -> poly[0] = NULL;			    /* Its boundary! */

    /* Advance in vrtx list grid_x_max-1 times, and gen. 2 polys for each. */
    for (i=0; i<grid_x_max-1; i++) {
	/* The Upper. */
	pp_temp = (struct poly_struct *) alloc(sizeof(struct poly_struct),
							"contour poly");
	/* Now update polys about its edges, and edges about the polygon. */
	pp_temp -> edge[0] = p_edge_middle -> next;
	p_edge_middle -> next -> poly[1] = pp_temp;
	pp_temp -> edge[1] = p_edge1;
	p_edge1 -> poly[0] = pp_temp;
	pp_temp -> edge[2] = p_edge_middle -> next -> next;
	p_edge_middle -> next -> next -> poly[0] = pp_temp;
	if (i == 0)				   /* Its first one in list: */
	    p_poly = (*pp_tail) = pp_temp;
	else {
	    (*pp_tail) -> next = pp_temp;
	    *pp_tail = (*pp_tail) -> next;
	}

	/* The Lower. */
	pp_temp = (struct poly_struct *) alloc(sizeof(struct poly_struct),
							"contour poly");
	/* Now update polys about its edges, and edges about the polygon. */
	pp_temp -> edge[0] = p_edge_middle;
	p_edge_middle -> poly[1] = pp_temp;
	pp_temp -> edge[1] = p_edge_middle -> next;
	p_edge_middle -> next -> poly[0] = pp_temp;
	pp_temp -> edge[2] = p_edge2;
	p_edge2 -> poly[1] = pp_temp;
	(*pp_tail) -> next = pp_temp;
	*pp_tail = (*pp_tail) -> next;

        p_edge1 = p_edge1 -> next;
        p_edge2 = p_edge2 -> next;
        p_edge_middle = p_edge_middle -> next -> next;
    }
    p_edge_middle -> poly[1] = NULL;			    /* Its boundary! */
    (*pp_tail) -> next = NULL;

    return p_poly;
}

/*
 * Calls the (hopefully) desired interpolation/approximation routine.
 */
static void put_contour(p_cntr, z_level, x_min, x_max, y_min, y_max, contr_kind)
struct cntr_struct *p_cntr;
double z_level, x_min, x_max, y_min, y_max;
int contr_kind;
{
    if (!p_cntr) return;            /* Nothing to do if it is empty contour. */

    switch (interp_kind) {
	case INTERP_NOTHING:              /* No interpolation/approximation. */
	    put_contour_nothing(p_cntr);
	    break;
	case INTERP_CUBIC:                    /* Cubic spline interpolation. */
	    put_contour_cubic(p_cntr, z_level, x_min, x_max, y_min, y_max,
								contr_kind);
	    break;
	case APPROX_BSPLINE:                       /* Bspline approximation. */
	    put_contour_bspline(p_cntr, z_level, x_min, x_max, y_min, y_max,
    								contr_kind);
	    break;
    }

    free_contour(p_cntr);
}

/*
 * Simply puts contour coordinates in order with no interpolation or
 * approximation.
 */
static put_contour_nothing(p_cntr)
struct cntr_struct *p_cntr;
{
    while (p_cntr) {
	add_cntr_point(p_cntr -> X, p_cntr -> Y);
	p_cntr = p_cntr -> next;
    }
    end_crnt_cntr();
}

/*
 * Find Complete Cubic Spline Interpolation.
 */
static put_contour_cubic(p_cntr, z_level, x_min, x_max, y_min, y_max,
								 contr_kind)
struct cntr_struct *p_cntr;
double z_level, x_min, x_max, y_min, y_max;
int contr_kind;
{
    int num_pts, i;
    double tx1, ty1, tx2, ty2;                    /* Tangents at end points. */
    struct cntr_struct *pc_temp;

    num_pts = count_contour(p_cntr);         /* Number of points in contour. */

    if (num_pts > 2) {  /* Take into account 3 points in tangent estimation. */
	calc_tangent(3, p_cntr -> X, p_cntr -> next -> X,
			p_cntr -> next -> next -> X,
			p_cntr -> Y, p_cntr -> next -> Y,
			p_cntr -> next -> next -> Y, &tx1, &ty1);
	pc_temp = p_cntr;
	for (i=3; i<num_pts; i++) pc_temp = pc_temp -> next;/* Go to the end.*/
	calc_tangent(3, pc_temp -> next -> next -> X,
 			pc_temp -> next -> X, pc_temp -> X,
			pc_temp -> next -> next -> Y,
			pc_temp -> next -> Y, pc_temp -> Y, &tx2, &ty2);
        tx2 = (-tx2);   /* Inverse the vector as we need opposite direction. */
        ty2 = (-ty2);
    }
    /* If following (num_pts > 1) is TRUE then exactly 2 points in contour.  */
    else if (num_pts > 1) {/* Take into account 2 points in tangent estimat. */
	calc_tangent(2, p_cntr -> X, p_cntr -> next -> X, 0.0,
			p_cntr -> Y, p_cntr -> next -> Y, 0.0, &tx1, &ty1);
	calc_tangent(2, p_cntr -> next -> X, p_cntr -> X, 0.0,
			p_cntr -> next -> Y, p_cntr -> Y, 0.0, &tx2, &ty2);
        tx2 = (-tx2);   /* Inverse the vector as we need opposite direction. */
        ty2 = (-ty2);
    }
    else return;			/* Only one point (???) - ignore it. */

    switch (contr_kind) {
	case OPEN_CONTOUR:
	    break;
	case CLOSED_CONTOUR:
	    tx1 = tx2 = (tx1 + tx2) / 2.0;	     /* Make tangents equal. */
	    ty1 = ty2 = (ty1 + ty2) / 2.0;
	    break;
    }
    complete_spline_interp(p_cntr, num_pts, 0.0, 1.0, tx1, ty1, tx2, ty2);
    end_crnt_cntr();
}

/*
 * Find Bspline approximation for this data set.
 * Uses global variable num_approx_pts to determine number of samples per
 * interval, where the knot vector intervals are assumed to be uniform, and
 * Global variable bspline_order for the order of Bspline to use.
 */
static put_contour_bspline(p_cntr, z_level, x_min, x_max, y_min, y_max,
								contr_kind)
struct cntr_struct *p_cntr;
double z_level, x_min, x_max,  y_min, y_max;
int contr_kind;
{
    int num_pts, i, order = bspline_order;
    struct cntr_struct *pc_temp;

    num_pts = count_contour(p_cntr);         /* Number of points in contour. */
    if (num_pts < 2) return;     /* Cannt do nothing if empty or one points! */
    /* Order must be less than number of points in curve - fix it if needed. */
    if (order > num_pts - 1) order = num_pts - 1;

    gen_bspline_approx(p_cntr, num_pts, order, contr_kind);
    end_crnt_cntr();
}

/*
 * Estimate the tangents according to the n last points where n might be
 * 2 or 3 (if 2 onlt x1, x2).
 */
static calc_tangent(n, x1, x2, x3, y1, y2, y3, tx, ty)
int n;
double x1, x2, x3, y1, y2, y3, *tx, *ty;
{
    double v1[2], v2[2], v1_magnitude, v2_magnitude;

    switch (n) {
	case 2:
	    *tx = (x2 - x1) * 0.3;
	    *ty = (y2 - y1) * 0.3;
	    break;
	case 3:
	    v1[0] = x2 - x1;   v1[1] = y2 - y1;
	    v2[0] = x3 - x2;   v2[1] = y3 - y2;
	    v1_magnitude = sqrt(sqr(v1[0]) + sqr(v1[1]));
	    v2_magnitude = sqrt(sqr(v2[0]) + sqr(v2[1]));
	    *tx = (v1[0] / v1_magnitude) - (v2[0] / v2_magnitude) * 0.1;
	    *tx *= v1_magnitude * 0.1;  /* Make tangent less than magnitude. */
	    *ty = (v1[1] / v1_magnitude) - (v2[1] / v2_magnitude) * 0.1;
	    *ty *= v1_magnitude * 0.1;  /* Make tangent less than magnitude. */
	    break;
	default:				       /* Should not happen! */
	    (*ty) = 0.1;
	    *tx = 0.1;
	    break;
    }
}

/*
 * Free all elements in the contour list.
 */
static void free_contour(p_cntr)
struct cntr_struct *p_cntr;
{
    struct cntr_struct *pc_temp;

    while (p_cntr) {
	pc_temp = p_cntr;
	p_cntr = p_cntr -> next;
	free((char *) pc_temp);
    }
}

/*
 * Counts number of points in contour.
 */
static int count_contour(p_cntr)
struct cntr_struct *p_cntr;
{
    int count = 0;

    while (p_cntr) {
	count++;
	p_cntr = p_cntr -> next;
    }
    return count;
}

/*
 * Interpolate given point list (defined via p_cntr) using Complete
 * Spline interpolation.
 */
static complete_spline_interp(p_cntr, n, t_min, t_max, tx1, ty1, tx2, ty2)
struct cntr_struct *p_cntr;
int n;
double t_min, t_max, tx1, ty1, tx2, ty2;
{
    double dt, *tangents_x, *tangents_y;
    int i;

    tangents_x = (double *) alloc((unsigned) (sizeof(double) * n),
						"contour c_s_intr");
    tangents_y = (double *) alloc((unsigned) (sizeof(double) * n),
						"contour c_s_intr");

    if (n > 1) prepare_spline_interp(tangents_x, tangents_y, p_cntr, n,
					t_min, t_max, tx1, ty1, tx2, ty2);
    else {
	free((char *) tangents_x);
	free((char *) tangents_y);
	return;
    }

    dt = (t_max-t_min)/(n-1);

    add_cntr_point(p_cntr -> X, p_cntr -> Y);	       /* First point. */

    for (i=0; i<n-1; i++) {
        hermit_interp(p_cntr -> X, p_cntr -> Y,
                     tangents_x[i], tangents_y[i],
		     p_cntr -> next -> X, p_cntr -> next -> Y,
                     tangents_x[i+1], tangents_y[i+1], dt);

        p_cntr = p_cntr -> next;
    }

    free((char *) tangents_x);
    free((char *) tangents_y);
}

/*
 * Routine to calculate intermidiate value of the Hermit Blending function:
 * This routine should be called only ONCE at the beginning of the program.
 */
static calc_hermit_table()
{
    int i;
    double t, dt;

    hermit_table = (table_entry *) alloc ((unsigned) (sizeof(table_entry) *
						(num_approx_pts + 1)),
						"contour hermit table");
    t = 0;
    dt = 1.0/num_approx_pts;
    for (i=0; i<=num_approx_pts; i++) {
        hermit_table[i][0] = (t-1)*(t-1)*(2*t+1);		     /* h00. */
        hermit_table[i][1] = t*t*(-2*t+3);			     /* h10. */
        hermit_table[i][2] = t*(t-1)*(t-1);			     /* h01. */
        hermit_table[i][3] = t*t*(t-1);				     /* h11. */
        t = t + dt;
    }
}

/*
 * Routine to generate an hermit interpolation between two points given as
 * two InterpStruct structures. Assume hermit_table is already calculated.
 * Currently the points generated are printed to stdout as two reals (X, Y).
 */
static hermit_interp(x1, y1, tx1, ty1, x2, y2, tx2, ty2, dt)
double x1, y1, tx1, ty1, x2, y2, tx2, ty2, dt;
{
    int i;
    double x, y, vec_size, tang_size;

    tx1 *= dt;  ty1 *= dt; /* Normalize the tangents according to param. t.  */
    tx2 *= dt;  ty2 *= dt;

    /* Normalize the tangents so that their magnitude will be 1/3 of the     */
    /* segment length. This tumb rule guaranteed no cusps or loops!          */
    /* Note that this normalization keeps continuity to be G1 (but not C1).  */
    vec_size = sqrt(sqr(x1 - x2) + sqr(y2 - y1));
    tang_size = sqrt(sqr(tx1) + sqr(ty1));                  /* Normalize T1. */
    if (tang_size * 3 > vec_size) {
	tx1 *= vec_size / (tang_size * 3);
	ty1 *= vec_size / (tang_size * 3);
    }
    tang_size = sqrt(sqr(tx2) + sqr(ty2));                  /* Normalize T2. */
    if (tang_size * 3 > vec_size) {
	tx2 *= vec_size / (tang_size * 3);
	ty2 *= vec_size / (tang_size * 3);
    }

    for (i=1; i<=num_approx_pts; i++) {      /* Note we start from 1 - first */
        x = hermit_table[i][0] * x1 +       /* point is not printed as it is */
            hermit_table[i][1] * x2 +   /* redundent (last on last section). */
            hermit_table[i][2] * tx1 +
            hermit_table[i][3] * tx2;
        y = hermit_table[i][0] * y1 +
            hermit_table[i][1] * y2 +
            hermit_table[i][2] * ty1 +
            hermit_table[i][3] * ty2;
	add_cntr_point(x, y);
    }
}

/*
 * Routine to Set up the 3*N mat for solve_tri_diag routine used in the
 * Complete Spline Interpolation. Returns TRUE of calc O.K.
 * Gets the points list in p_cntr (Of length n) and with tangent vectors tx1,
 * ty1 at starting point and tx2, ty2 and end point.
 */
static prepare_spline_interp(tangents_x, tangents_y, p_cntr, n, t_min, t_max,
			   tx1, ty1, tx2, ty2)
double tangents_x[], tangents_y[];
struct cntr_struct *p_cntr;
int n;
double t_min, t_max, tx1, ty1, tx2, ty2;
{
    int i;
    double *r, t, dt;
    tri_diag *m;		   /* The tri-diagonal matrix is saved here. */
    struct cntr_struct *p;

    m = (tri_diag *) alloc((unsigned) (sizeof(tri_diag) * n),
						"contour tri_diag");
    r = (double *) alloc((unsigned) (sizeof(double) * n),
						"contour tri_diag2");
    n--;

    p = p_cntr;
    m[0][0] = 0.0;    m[0][1] = 1.0;    m[0][2] = 0.0;
    m[n][0] = 0.0;    m[n][1] = 1.0;    m[n][2] = 0.0;
    r[0] = tx1;					       /* Set start tangent. */
    r[n] = tx2;						 /* Set end tangent. */
    t = t_min;
    dt = (t_max-t_min)/n;
    for (i=1; i<n; i++) {
       t = t + dt;
       m[i][0] = dt;
       m[i][2] = dt;
       m[i][1] = 2 * (m[i][0] + m[i][2]);
       r[i] = m[i][0] * ((p -> next -> X) - (p -> X)) / m[i][2]
            + m[i][2] * ((p -> next -> next -> X) - 
                         (p -> next -> X)) / m[i][0];
       r[i] *= 3.0;
       p = p -> next;
    }

    if (!solve_tri_diag(m, r, tangents_x, n+1)) { /* Find the X(t) tangents. */
    	free((char *) m);
    	free((char *) r);
	int_error("Cannt interpolate X using complete splines", NO_CARET);
    }

    p = p_cntr;
    m[0][0] = 0.0;    m[0][1] = 1.0;    m[0][2] = 0.0;
    m[n][0] = 0.0;    m[n][1] = 1.0;    m[n][2] = 0.0;
    r[0] = ty1;					       /* Set start tangent. */
    r[n] = ty2;						 /* Set end tangent. */
    t = t_min;
    dt = (t_max-t_min)/n;
    for (i=1; i<n; i++) {
       t = t + dt;
       m[i][0] = dt;
       m[i][2] = dt;
       m[i][1] = 2 * (m[i][0] + m[i][2]);
       r[i] = m[i][0] * ((p -> next -> Y) - (p -> Y)) / m[i][2]
            + m[i][2] * ((p -> next -> next -> Y) -
                         (p -> next -> Y)) / m[i][0];
       r[i] *= 3.0;
       p = p -> next;
    }

    if (!solve_tri_diag(m, r, tangents_y, n+1)) { /* Find the Y(t) tangents. */
    	free((char *) m);
    	free((char *) r);
	int_error("Cannt interpolate Y using complete splines", NO_CARET);
    }
    free((char *) m);
    free((char *) r);
}

/*
 * Solve tri diagonal linear system equation. The tri diagonal matrix is
 * defined via matrix M, right side is r, and solution X i.e. M * X = R.
 * Size of system given in n. Return TRUE if solution exist.
 */
static int solve_tri_diag(m, r, x, n)
tri_diag m[];
double r[], x[];
int n;
{
    int i;
    double t;

    for (i=1; i<n; i++) {   /* Eliminate element m[i][i-1] (lower diagonal). */
	if (m[i-1][1] == 0) return FALSE;
	t = m[i][0] / m[i-1][1];        /* Find ratio between the two lines. */
	m[i][0] = m[i][0] - m[i-1][1] * t;
	m[i][1] = m[i][1] - m[i-1][2] * t;
	r[i] = r[i] - r[i-1] * t;
    }
    /* Now do back subtitution - update the solution vector X: */
    if (m[n-1][1] == 0) return FALSE;
    x[n-1] = r[n-1] / m[n-1][1];		       /* Find last element. */
    for (i=n-2; i>=0; i--) {
	if (m[i][1] == 0) return FALSE;
	x[i] = (r[i] - x[i+1] * m[i][2]) / m[i][1];
    }
    return TRUE;
}

/*
 * Generate a Bspline curve defined by all the points given in linked list p:
 * Algorithm: using deBoor algorithm
 * Note: if Curvekind is OPEN_CONTOUR than Open end knot vector is assumed,
 *       else (CLOSED_CONTOUR) Float end knot vector is assumed.
 * It is assumed that num_of_points is at list 2, and order of Bspline is less
 * than num_of_points!
 */
static gen_bspline_approx(p_cntr, num_of_points, order, contour_kind)
struct cntr_struct *p_cntr;
int num_of_points, order, contour_kind;
{
    int i, knot_index = 0, pts_count = 1;
    double dt, t, next_t, t_min, t_max, x, y;
    struct cntr_struct *pc_temp = p_cntr, *pc_tail;

    /* If the contour is Closed one we must update few things:               */
    /* 1. Make the list temporary circular, so we can close the contour.     */
    /* 2. Update num_of_points - increase it by "order-1" so contour will be */
    /*    closed. This will evaluate order more sections to close it!        */
    if (contour_kind == CLOSED_CONTOUR) {
	pc_tail = p_cntr;
	while (pc_tail -> next) pc_tail = pc_tail -> next;/* Find last point.*/
	pc_tail -> next = p_cntr;   /* Close contour list - make it circular.*/
	num_of_points += order;
    }

    /* Find first (t_min) and last (t_max) t value to eval: */
    t = t_min = fetch_knot(contour_kind, num_of_points, order, order);
    t_max = fetch_knot(contour_kind, num_of_points, order, num_of_points);
    next_t = t_min + 1.0;
    knot_index = order;
    dt = 1.0/num_approx_pts;            /* Number of points per one section. */


    while (t<t_max) {
	if (t > next_t) {
	    pc_temp = pc_temp -> next;     /* Next order ctrl. pt. to blend. */
            knot_index++;
	    next_t += 1.0;
	}
        eval_bspline(t, pc_temp, num_of_points, order, knot_index,
    					contour_kind, &x, &y);   /* Next pt. */
	add_cntr_point(x, y);
	pts_count++;
	/* As we might have some real number round off problems we must      */
	/* test if we dont produce too many points here...                   */
	if (pts_count + 1 == num_approx_pts * (num_of_points - order) + 1)
    		break;
        t += dt;
    }

    eval_bspline(t_max - EPSILON, pc_temp, num_of_points, order, knot_index,
		contour_kind, &x, &y);
    /* If from round off errors we need more than one last point: */
    for (i=pts_count; i<num_approx_pts * (num_of_points - order) + 1; i++)
	add_cntr_point(x, y);			    /* Complete the contour. */

    if (contour_kind == CLOSED_CONTOUR)     /* Update list - un-circular it. */
	pc_tail -> next = NULL;
}

/*
 * The recursive routine to evaluate the B-spline value at point t using
 * knot vector PKList, and the control points Pdtemp. Returns x, y after the
 * division by the weight w. Note that Pdtemp points on the first control
 * point to blend with. The B-spline is of order order.
 */
static eval_bspline(t, p_cntr, num_of_points, order, j, contour_kind, x, y)
double t;
struct cntr_struct *p_cntr;
int num_of_points, order, j, contour_kind;
double *x, *y;
{
    int i, p;
    double ti, tikp, *dx, *dy;      /* Copy p_cntr into it to make it faster. */

    dx = (double *) alloc((unsigned) (sizeof(double) * (order + j)),
						"contour b_spline");
    dy = (double *) alloc((unsigned) (sizeof(double) * (order + j)),
						"contour b_spline");
    /* Set the dx/dy - [0] iteration step, control points (p==0 iterat.): */
    for (i=j-order; i<=j; i++) {
        dx[i] = p_cntr -> X;
        dy[i] = p_cntr -> Y;
        p_cntr = p_cntr -> next;
    }

    for (p=1; p<=order; p++) {        /* Iteration (b-spline level) counter. */
	for (i=j; i>=j-order+p; i--) {           /* Control points indexing. */
            ti = fetch_knot(contour_kind, num_of_points, order, i);
            tikp = fetch_knot(contour_kind, num_of_points, order, i+order+1-p);
	    if (ti == tikp) {   /* Should not be a problems but how knows... */
	    }
	    else {
		dx[i] = dx[i] * (t - ti)/(tikp-ti) +         /* Calculate x. */
			dx[i-1] * (tikp-t)/(tikp-ti);
		dy[i] = dy[i] * (t - ti)/(tikp-ti) +         /* Calculate y. */
			dy[i-1] * (tikp-t)/(tikp-ti);
	    }
	}
    }
    *x = dx[j]; *y = dy[j];
    free((char *) dx);
    free((char *) dy);
}

/*
 * Routine to get the i knot from uniform knot vector. The knot vector
 * might be float (Knot(i) = i) or open (where the first and last "order"
 * knots are equal). contour_kind determines knot kind - OPEN_CONTOUR means
 * open knot vector, and CLOSED_CONTOUR selects float knot vector.
 * Note the knot vector is not exist and this routine simulates it existance
 * Also note the indexes for the knot vector starts from 0.
 */
static double fetch_knot(contour_kind, num_of_points, order, i)
int contour_kind, num_of_points, order, i;
{
    switch (contour_kind) {
	case OPEN_CONTOUR:
	    if (i <= order) return 0.0;
	    else if (i <= num_of_points) return (double) (i - order);
		 else return (double) (num_of_points - order);
	case CLOSED_CONTOUR:
	    return (double) i;
	default: /* Should never happen */
	    return 1.0;
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/corgraph.asm version [b9f68e538e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
TITLE	Corona graphics module
;	Colin Kelley
;	January 1987

include header.mac

if1
include lineproc.mac
endif


_text	segment

public	_GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask

corpixel proc near
	ror word ptr linemask,1
	jc cont
	ret
cont:	push bp
	mov bp,sp
	push ax
	push bx
	push cx
	mov es,ScSeg
	shl bx,1			; y
	mov bx,word ptr LookUp[bx] ; bx has y mem address
	mov cl,al			; x
	and cl,7
	shr ax,1
	shr ax,1
	shr ax,1			; ax /= 8
	add bx,ax
	mov al,1
	shl al,cl			; al contains bit mask
	or byte ptr es:[bx],al
	pop cx
	pop bx
	pop ax
	pop bp
	ret

lineproc _Cor_line, corpixel

beginproc _GrInit
	push bp
	mov bp,sp
	push di
	mov ax, [bp+X]			; screen number (0 - 7)
	mov cl,11
	shl ax,cl			; multiply by 2048 to get segment
	mov ScSeg,ax			; save segment for later
	push ax
	mov es, ax
	xor ax,ax
	mov di,ax
	mov cx, 4000h
	cld
	rep stosw
	pop cx
	call near ptr GrAddr
	mov ax,es
	pop di
	pop bp
	ret
_GrInit	endp

beginproc _GrReset
	mov cx, 0
	call near ptr GrAddr
	ret
_GrReset endp

GrAddr	proc near
	mov dx,3b4h			; address of 6845
	mov al,0ch			; register 12
	out dx,al
	inc dx
	mov al,ch			; Graphics Segment High
	out dx,al
	dec dx
	mov al,0dh			; register 13
	out dx,al
	mov al,cl			; Graphics Segment Low
	inc dx
	out dx,al
	ret
GrAddr	endp

beginproc _GrOnly
	mov dx,3b8h
	mov al,0a0h
	out dx,al
	ret
_GrOnly	endp

beginproc _TxOnly
	mov dx,3b8h
	mov al,28h
	out dx,al
	ret
_TxOnly	endp

beginproc _GrandTx
	mov dx,3b8h
	mov al,0a8h
	out dx,al
	ret
_GrandTx endp

beginproc _Cor_mask
	push bp
	mov bp,sp
	mov ax,[bp+x]			; mask
	mov linemask,ax
	pop bp
	ret
_Cor_mask endp

corpixel endp

_text	ends
 

_data	segment
linemask dw -1
ScSeg	dw 0
_data	ends

const	segment

K	equ 1024

mem_mac	MACRO x
	dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
	dw 18*K+x,20*K+x,22*K+x,24*K+x
	ENDM
LookUp	equ $
	mem_mac 0
	mem_mac 80
	mem_mac (80*2)
	mem_mac (80*3)
	mem_mac (80*4)
	mem_mac (80*5)
	mem_mac (80*6)
	mem_mac (80*7)
	mem_mac (80*8)
	mem_mac (80*9)
	mem_mac (80*10)
	mem_mac (80*11)
	mem_mac (80*12)
	mem_mac (80*13)
	mem_mac (80*14)
	mem_mac (80*15)
	mem_mac (80*16)
	mem_mac (80*17)
	mem_mac (80*18)
	mem_mac (80*19)
	mem_mac (80*20)
	mem_mac (80*21)
	mem_mac (80*22)
	mem_mac (80*23)
	mem_mac (80*24)

const	ends

	end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































Deleted r34.1/plot/corplot.c version [bae53e1a29].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef lint
static char *RCSid = "$Id: corplot.c,v 3.26 92/03/24 22:36:10 woo Exp Locker: woo $";
#endif

/* GNUPLOT - corplot.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */
#include <stdio.h>
#include <process.h>
#include <dos.h>

#define BOUNDARY 32768
#define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
#define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))

char *malloc(),*realloc();

char prog[] = "gnuplot";
char corscreen[] = "CORSCREEN=0";

main()
{
register unsigned int segm,start;
char *m;
	if (!(m = malloc(BOUNDARY))) {
		printf("malloc() failed\n");
		exit(1);
	}
	segm = segment(m);
	start = round(segm,BOUNDARY/16);

	if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
		printf("can't realloc() memory\n");
		exit(2);
	}

	if ((segm = start >> 11) >= 8) {
		printf("not enough room in first 256K\n");
		exit(3);
	}

	corscreen[sizeof(corscreen)-2] = '0' + segm;
	if (putenv(corscreen))
		perror("putenv");

	if (spawnlp(P_WAIT,prog,prog,NULL))
		perror("spawnlp");
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































Deleted r34.1/plot/demo/1.dat version [8fc8e61db4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# $Id: 1.dat,v 3.26 92/03/24 22:32:15 woo Exp Locker: woo $
#
-20.000000 -3.041676
-19.000000 -3.036427
-18.000000 -3.030596
-17.000000 -3.024081
-16.000000 -3.016755
-15.000000 -3.008456
-14.000000 -2.998978
-13.000000 -2.988049
-12.000000 -2.975310
-11.000000 -2.960273
-10.000000 -2.942255
-9.000000 -2.920278
-8.000000 -2.892883
-7.000000 -2.857799
-6.000000 -2.811295
-5.000000 -2.746802
-4.000000 -2.651635
-3.000000 -2.498092
-2.000000 -2.214297
-1.000000 -1.570796
0.000000 0.000000
1.000000 1.570796
2.000000 2.214297
3.000000 2.498092
4.000000 2.651635
5.000000 2.746802
6.000000 2.811295
7.000000 2.857799
8.000000 2.892883
9.000000 2.920278
10.000000 2.942255
11.000000 2.960273
12.000000 2.975310
13.000000 2.988049
14.000000 2.998978
15.000000 3.008456
16.000000 3.016755
17.000000 3.024081
18.000000 3.030596
19.000000 3.036427
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































Deleted r34.1/plot/demo/2.dat version [038f4ade56].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# $Id: 2.dat,v 3.26 92/03/24 22:32:16 woo Exp Locker: woo $
#
-20.000000 -6.083352
-19.000000 -6.072853
-18.000000 -6.061191
-17.000000 -6.048162
-16.000000 -6.033510
-15.000000 -6.016913
-14.000000 -5.997955
-13.000000 -5.976098
-12.000000 -5.950620
-11.000000 -5.920546
-10.000000 -5.884511
-9.000000 -5.840556
-8.000000 -5.785765
-7.000000 -5.715597
-6.000000 -5.622591
-5.000000 -5.493603
-4.000000 -5.303271
-3.000000 -4.996183
-2.000000 -4.428595
-1.000000 -3.141593
0.000000 0.000000
1.000000 3.141593
2.000000 4.428595
3.000000 4.996183
4.000000 5.303271
5.000000 5.493603
6.000000 5.622591
7.000000 5.715597
8.000000 5.785765
9.000000 5.840556
10.000000 5.884511
11.000000 5.920546
12.000000 5.950620
13.000000 5.976098
14.000000 5.997955
15.000000 6.016913
16.000000 6.033510
17.000000 6.048162
18.000000 6.061191
19.000000 6.072853
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































Deleted r34.1/plot/demo/3.dat version [a1b7dbeae5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# $Id: 3.dat,v 3.26 92/03/24 22:32:17 woo Exp Locker: woo $
#
-20.000000 -9.125028
-19.000000 -9.109280
-18.000000 -9.091787
-17.000000 -9.072243
-16.000000 -9.050265
-15.000000 -9.025369
-14.000000 -8.996933
-13.000000 -8.964147
-12.000000 -8.925931
-11.000000 -8.880819
-10.000000 -8.826766
-9.000000 -8.760835
-8.000000 -8.678648
-7.000000 -8.573396
-6.000000 -8.433886
-5.000000 -8.240405
-4.000000 -7.954906
-3.000000 -7.494275
-2.000000 -6.642892
-1.000000 -4.712389
0.000000 0.000000
1.000000 4.712389
2.000000 6.642892
3.000000 7.494275
4.000000 7.954906
5.000000 8.240405
6.000000 8.433886
7.000000 8.573396
8.000000 8.678648
9.000000 8.760835
10.000000 8.826766
11.000000 8.880819
12.000000 8.925931
13.000000 8.964147
14.000000 8.996933
15.000000 9.025369
16.000000 9.050265
17.000000 9.072243
18.000000 9.091787
19.000000 9.109280
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































Deleted r34.1/plot/demo/all.demo version [6d4a85755b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# $Id: all.demo,v 3.26 92/03/24 22:32:37 woo Exp Locker: woo $
#
#
# Executes ALL demos in this directory, in functionality order.
#

pause 0 "******************** file simple.demo ********************"
load "simple.demo"

pause 0 "******************** file controls.demo ********************"
load "controls.demo"

pause 0 "******************** file electron.demo ********************"
load "electron.demo"

pause 0 "******************** file using.demo ********************"
load "using.demo"

pause 0 "******************** file errorbar.demo ********************"
load "errorbar.demo"

pause 0 "******************** file param.demo ********************"
load "param.demo"

pause 0 "******************** file polar.demo ********************"
load "polar.demo"

pause 0 "******************** file poldat.demo ********************"
load "poldat.demo"

pause 0 "******************** file surface1.demo ********************"
load "surface1.demo"

pause 0 "******************** file surface2.demo ********************"
load "surface2.demo"

pause 0 "******************** file contours.demo ********************"
load "contours.demo"

pause 0 "******************** file hidden.demo ********************"
load "hidden.demo"

pause 0 "******************** file world.demo ********************"
load "world.demo"

pause 0 "******************** file bivariat.demo ********************"
load "bivariat.demo"
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































Deleted r34.1/plot/demo/antenna.dat version [b457580671].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#
# $Id: antenna.dat,v 3.26 92/03/24 22:32:36 woo Exp Locker: woo $
#
   0.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
   2.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
   4.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
   6.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
   8.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
  10.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
  12.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
  14.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
  16.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
  18.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
  20.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
  22.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
  24.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
  26.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
  28.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
  30.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
  32.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
  34.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
  36.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
  38.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
  40.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
  42.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
  44.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
  46.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
  48.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
  50.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
  52.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
  54.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
  56.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
  58.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
  60.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
  62.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
  64.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
  66.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
  68.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
  70.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
  72.000 -41.802E+00 -37.180E+00 -39.114E+00 -24.830E+00
  74.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
  76.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
  78.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
  80.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
  82.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
  84.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
  86.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
  88.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
  90.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
  92.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
  94.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
  96.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
  98.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 100.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 102.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 104.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 106.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 108.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 110.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 112.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 114.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 116.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 118.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 120.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 122.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 124.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 126.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 128.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 130.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 132.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 134.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 136.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 138.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 140.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 142.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 144.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 146.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 148.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 150.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 152.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 154.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 156.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 158.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 160.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 162.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 164.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 166.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 168.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 170.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 172.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 174.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 176.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 178.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 180.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
 182.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 184.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 186.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 188.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 190.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 192.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 194.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 196.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 198.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 200.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 202.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 204.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 206.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 208.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 210.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 212.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 214.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 216.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 218.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 220.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 222.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 224.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 226.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 228.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 230.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 232.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 234.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 236.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 238.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 240.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 242.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 244.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 246.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 248.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 250.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 252.000 -41.802E+00 -37.180E+00 -39.114E+00 -24.830E+00
 254.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 256.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 258.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 260.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 262.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 264.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 266.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 268.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 270.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
 272.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 274.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 276.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 278.000  13.099E-02  42.554E-01 -25.105E+00  59.101E-01
 280.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 282.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 284.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 286.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 288.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 290.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 292.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 294.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 296.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 298.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 300.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 302.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 304.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 306.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 308.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 310.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 312.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 314.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 316.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 318.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 320.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 322.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 324.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 326.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 328.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 330.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 332.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 334.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 336.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 338.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 340.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 342.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 344.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 346.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 348.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 350.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 352.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 354.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 356.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 358.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 360.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
   2.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
   4.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
   6.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
   8.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
  10.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
  12.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
  14.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
  16.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
  18.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
  20.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
  22.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
  24.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
  26.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
  28.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
  30.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
  32.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
  34.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
  36.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
  38.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
  40.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
  42.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
  44.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
  46.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
  48.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
  50.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
  52.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
  54.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
  56.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
  58.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
  60.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
  62.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
  64.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
  66.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
  68.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
  70.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
  72.000 -41.802E+00 -37.180E+00 -39.114E+00 -24.830E+00
  74.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
  76.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
  78.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
  80.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
  82.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
  84.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
  86.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
  88.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
  90.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
  92.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
  94.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
  96.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
  98.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 100.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 102.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 104.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 106.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 108.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 110.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 112.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 114.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 116.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 118.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 120.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 122.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 124.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 126.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 128.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 130.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 132.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 134.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 136.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 138.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 140.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 142.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 144.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 146.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 148.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 150.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 152.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 154.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 156.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 158.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 160.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 162.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 164.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 166.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 168.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 170.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 172.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 174.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 176.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 178.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 180.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
 182.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 184.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 186.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 188.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 190.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 192.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 194.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 196.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 198.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 200.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 202.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 204.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 206.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 208.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 210.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 212.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 214.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 216.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 218.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 220.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 222.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 224.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 226.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 228.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 230.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 232.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 234.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 236.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 238.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 240.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 242.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 244.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 246.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 248.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 250.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 252.000 -41.802E+00 -37.180E+00 -39.114E+00 -24.830E+00
 254.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 256.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 258.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 260.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 262.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 264.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 266.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 268.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 270.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
 272.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 274.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 276.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 278.000  13.099E-02  42.554E-01 -25.105E+00  59.101E-01
 280.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 282.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 284.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 286.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 288.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 290.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 292.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 294.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 296.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 298.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 300.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 302.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 304.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 306.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 308.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 310.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 312.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 314.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 316.000 -39.287E+00 -23.397E+00 -38.646E+00 -60.943E-01
 318.000 -38.418E+00 -14.735E+00 -29.897E+00 -76.375E-01
 320.000 -36.549E+00 -12.197E+00 -27.142E+00 -11.075E+00
 322.000 -35.220E+00 -12.594E+00 -27.052E+00 -15.787E+00
 324.000 -35.691E+00 -16.286E+00 -29.566E+00 -13.578E+00
 326.000 -37.632E+00 -21.690E+00 -37.458E+00 -96.424E-01
 328.000 -33.989E+00 -13.340E+00 -38.930E+00 -75.039E-01
 330.000 -28.216E+00 -83.757E-01 -29.576E+00 -64.985E-01
 332.000 -24.356E+00 -58.580E-01 -26.299E+00 -60.712E-01
 334.000 -22.103E+00 -48.803E-01 -25.429E+00 -59.416E-01
 336.000 -21.258E+00 -52.193E-01 -26.432E+00 -62.183E-01
 338.000 -22.060E+00 -71.064E-01 -29.743E+00 -74.312E-01
 340.000 -25.979E+00 -11.868E+00 -38.677E+00 -10.860E+00
 342.000 -41.802E+00 -37.181E+00 -39.114E+00 -24.830E+00
 344.000 -20.405E+00 -10.185E+00 -30.112E+00 -11.564E+00
 346.000 -12.849E+00 -36.543E-01 -26.702E+00 -36.253E-01
 348.000 -76.407E-01  15.917E-02 -25.211E+00  82.257E-02
 350.000 -34.589E-01  26.769E-01 -24.794E+00  38.084E-01
 352.000  13.100E-02  42.554E-01 -25.105E+00  59.101E-01
 354.000  33.053E-01  48.742E-01 -26.062E+00  73.795E-01
 356.000  60.696E-01  40.782E-01 -28.040E+00  83.501E-01
 358.000  81.667E-01  13.355E-02 -32.735E+00  89.007E-01
 360.000  90.007E-01 -35.926E+00 -71.297E+00  90.783E-01
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/demo/bivariat.demo version [9e5917546b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#
# $Id: bivariat.demo,v 3.26 92/03/24 22:32:38 woo Exp Locker: woo $
#
#
# This demo is very slow and requires unusually large stack size.
# Do not attempt to run this demo under MSDOS.
#

# the function integral_f(x) approximates the integral of f(x) from 0 to x.
# integral2_f(x,y) approximates the integral from x to y.
# define f(x) to be any single variable function
#
# the integral is calculated as the sum of f(x_n)*delta 
#   do this x/delta times (from x down to 0)
#
f(x) = exp(-x**2)
delta = 0.025
#
# integral_f(x) takes one variable, the upper limit.  0 is the lower limit.
# calculate the integral of function f(t) from 0 to x
integral_f(x) = (x>0)?integral1a(x):-integral1b(x)
integral1a(x) = (x<=0)?0:(integral1a(x-delta)+delta*f(x))
integral1b(x) = (x>=0)?0:(integral1b(x+delta)+delta*f(x))
#
# integral2_f(x,y) takes two variables; x is the lower limit, and y the upper.
# claculate the integral of function f(t) from x to y
integral2_f(x,y) = (x<y)?integral2(x,y):-integral2(y,x)
integral2(x,y) = (x>y)?0:(integral2(x+delta,y)+delta*f(x))

set title "approximate the integral of functions"
set samples 50

plot [-5:5] f(x) title "f(x)=exp(-x**2)", 2/sqrt(pi)*integral_f(x) title "erf(x)=2/sqrt(pi)*integral_f(x)"

pause -1 "Hit return to continue"

f(x)=sin(x)

plot [-5:5] f(x) title "f(x)=sin(x)", integral_f(x)

pause -1 "Hit return to continue"

set title "approximate the integral of functions (upper and lower limits)"

f(x)=(x-2)**2-20

plot [-10:10] f(x) title "f(x)=(x-2)**2-20", integral2_f(-5,x)

pause -1 "Hit return to continue"

f(x)=sin(x-1)-.75*sin(2*x-1)+(x**2)/8-5

plot  [-10:10] f(x) title "f(x)=sin(x-1)-0.75*sin(2*x-1)+(x**2)/8-5", integral2_f(x,1)

pause -1 "Hit return to continue"

#
# This definition computes the ackermann. Do not attempt to compute its
# values for non integral values. In addition, do not attempt to compute
# its beyond m = 3, unless you want to wait really long time.

ack(m,n) = (m == 0) ? n + 1 : (n == 0) ? ack(m-1,1) : ack(m-1,ack(m,n-1))

set xrange [0:3]
set yrange [0:3]

set isosamples 4
set samples 4

set title "Plot of the ackermann function"

splot ack(x, y)

pause -1 "Hit return to continue"

set xrange [-5:5]
set yrange [-10:10]
set isosamples 10
set samples 100
set key 4,-3
set title "Min(x,y) and Max(x,y)"

#
min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

plot sin(x), x**2, x**3, max(sin(x), min(x**2, x**3))+0.5

pause -1 "Hit return to continue"

#
# gcd(x,y) finds the greatest common divisor of x and y,
#          using Euclid's algorithm
# as this is defined only for integers, first round to the nearest integer
gcd(x,y) = gcd1(rnd(max(x,y)),rnd(min(x,y)))
gcd1(x,y) = (y == 0) ? x : gcd1(y, x - x/y * y)
rnd(x) = int(x+0.5)

set samples 59
set xrange [1:59]
set auto
set key

set title "Greatest Common Divisor (for integers only)"

plot gcd(x, 60)
pause -1 "Hit return to continue"

set xrange [-10:10]
set yrange [-10:10]
set auto
set isosamples 10
set samples 100
set title ""

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































Deleted r34.1/plot/demo/contours.demo version [fba94e5bd9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#
# $Id: contours.demo,v 3.26 92/03/24 22:32:18 woo Exp Locker: woo $
#
set samples 20
set isosamples 21
set xlabel "X axis" -5,-2
set ylabel "Y axis" 4,-1
set zlabel "Z axis"
set title "3D gnu plot demo - contour plot"
set contour
splot x*y
pause -1 "Hit return to continue (1)"
set cntrparam levels 20
set title "3D gnu plot demo - contour plot (more contours)"
replot
pause -1 "Hit return to continue (2)"
set cntrparam levels 40
set title "3D gnu plot demo - contour plot (and again more contours)"
replot
pause -1 "Hit return to continue (3)"
set cntrparam levels 10
set title "3D gnu plot demo - contour plot on base grid"
set contour base
splot x**2-y**2
pause -1 "Hit return to continue (4)"
set title "3D gnu plot demo - contour plot on surface"
set contour surface
replot
pause -1 "Hit return to continue (5)"
set title "3D gnu plot demo - contour plot on both"
set contour both
replot
pause -1 "Hit return to continue (6)"
set contour base
set title "3D gnu plot demo - 2 surfaces
splot x**2*y**3, x**3*y**2
pause -1 "Hit return to continue (7)"
set title "3D gnu plot demo - some more interesting contours"
splot x*y / (x**2 + y**2 + 0.1)
pause -1 "Hit return to continue (8)"
splot [x=-3:3] [y=-3:3] sin(x) * cos(y)
pause -1 "Hit return to continue (9)"
set zrange [-0.5:0.5]
replot
pause -1 "Hit return to continue (10)"
set samples 6
set isosamples 6
set cntrparam levels 5
set title "3D gnu plot demo - low resolution (6x6)"
replot
pause -1 "Hit return to continue (11)"
set cntrparam bspline
set title "3D gnu plot demo - low resolution (6x6) using bspline approx."
replot
pause -1 "Hit return to continue (12)"
set cntrparam order 8
set title "3D gnu plot demo - low resolution (6x6) raise bspline order."
replot
pause -1 "Hit return to continue (13)"
set cntrparam linear
set auto
set title "3D gnu plot demo - low resolution (6x6) using linear contours."
splot x*y
pause -1 "Hit return to continue (14)"
set cntrparam order 4
set cntrparam bspline
set title "3D gnu plot demo - low resolution (6x6) using bspline approx."
replot
pause -1 "Hit return to continue (15)"
set samples 25
set isosamples 26
set title "3D gnu plot demo - contour of Sinc function"
splot [-5:5.01] [-5:5.01] sin(sqrt(x**2+y**2)) / sqrt(x**2+y**2)
pause -1 "Hit return to continue (16)"
splot [-12:12.01] [-12:12.01] sin(sqrt(x**2+y**2)) / sqrt(x**2+y**2)
pause -1 "Hit return to continue (17)"
set cntrparam levels 10
set xrange [0:15]
set yrange [0:15]
set auto
set zrange [-0.6:0.6]
set data style lines
set title "3D gnu plot demo - contour of data grid plotting"
set parametric
splot "glass.dat"
pause -1 "Hit return to continue (18)"
set zrange [-1.2:1.2]
set noparametric
splot "glass.dat" using 1
pause -1 "Hit return to continue (19)"
set view 0,0,1
set nosurface
set title "3D gnu plot demo - 2D contour projection of last plot"
replot
pause -1 "Hit return to continue (20)"


#
# Clean up:
#
set surface
set nocontour
set cntrparam levels 5
set cntrparam linear
set samples 100
set isosamples 10
set view 60,30,1,1
set xrange [-10:10]
set yrange [-10:10]
set zrange [-10:10]
set auto
set title "" 0,0
set xlabel "" 0,0
set ylabel "" 0,0
set zlabel "" 0,0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































Deleted r34.1/plot/demo/controls.demo version [df8498ee4d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#
# $Id: controls.demo,v 3.26 92/03/24 22:32:19 woo Exp Locker: woo $
#
#
# warning:  this demo is SLOW on PCs without math coprocessors!
#
# From _Automatic_Control_Systems_, fourth ed., figure 6-14
# transient response of a second-order system to a unit step input function
#
damp(t) = exp(-s*wn*t)/sqrt(1.0-s*s)
per(t) = sin(wn*sqrt(1.0-s**2)*t - atan(-sqrt(1.0-s**2)/s))
c(t) = 1-damp(t)*per(t)
#
#	wn is natural undamped frequency
#	s is damping factor
#
wn = 1.0
set xrange [0:13]
set samples 50
set dummy t
#
# plot c(t) for several different damping factors s
#
plot s=.1,c(t),s=.3,c(t),s=.5,c(t),s=.7,c(t),s=.9,c(t),s=1.0,c(t),s=1.5,c(t),s=2.0,c(t)
pause -1 "Hit return to continue"

# undo what we have done
set xrange [-10:10]
set autoscale xy
set samples 160
set dummy x

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































Deleted r34.1/plot/demo/electron.demo version [766e1bc5de].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#
# $Id: electron.demo,v 3.26 92/03/24 22:32:20 woo Exp Locker: woo $
#
# Electronics demo
#
# Bipolar Transistor (NPN) Mutual Characteristic
Ie(Vbe)=Ies*exp(Vbe/kT_q)
Ic(Vbe)=alpha*Ie(Vbe)+Ico
alpha = 0.99
Ies = 4e-14
Ico = 1e-09
kT_q = 0.025
set dummy Vbe
set grid
set offsets
set nolog
set nopolar
set samples 160
set title "Mutual Characteristic of a Transistor"
set xlabel "Vbe (base emmitter voltage)"
set xrange [0 : 0.75]
set ylabel "Ic (collector current)"
set yrange [0 : 0.005]
set key .2,.0045
set format y "%.4f"
plot Ic(Vbe)
set format "%g"

pause -1 "Hit return to continue"

# Junction Field Effect Transistor (JFET) Mutual Characteristic
# drain current above pinch off
Ida(Vd)=Ido*(1-Vg/Vp)**2
# drain current below pinch off
Idb(Vd)=Ido*(2*Vd*(Vg-Vp)-Vd*Vd)/(Vp*Vp)
# drain current
Id(Vd)= (Vd>Vg-Vp) ? Ida(Vd) : Idb(Vd)
# drain current at zero gate voltage
Ido = 2.5
# pinch off voltage
Vp = -1.25
# gate voltage
Vg = 0
set dummy Vd
set nogrid
set nokey
set offsets 0, 1, 0, 0
set title "JFET Mutual Characteristic"
set xlabel "Drain voltage Vd (V)"
set xrange [0 : 4]
set ylabel "Drain current Id (mA)"
set yrange [0 : 5]
set label "-0.5 Vp" at 4.1,0.625
set label "-0.25 Vp" at 4.1,1.4
set label "0" at 4.1,2.5
set label "Vg = 0.5 Vp" at 4.1,3.9
plot Vg=0.5*Vp,Id(Vd),Vg=0.25*Vp,Id(Vd),Vg=0,Id(Vd),Vg=-0.25*Vp,Id(Vd)
set nolabel

pause -1 "Hit return to continue"

# amplitude frequency response
A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
p1 = 10
p2 = 10000
set dummy jw
set grid
set key
set logscale xy
set offsets 0, 0, 0, 0
set title "Amplitude Frequency Response"
set xlabel "jw (radians)"
set xrange [1.1 : 90000.0]
set ylabel "magnitude of A(jw)"
set autoscale  y
plot abs(A(jw))

pause -1 "Hit return to continue"

# phase frequency response
set nolog y
set logscale x
set title "Phase Frequency Response"
set ylabel "Phase of A(jw) (degrees)"
plot 180/pi*arg(A(jw))

pause -1 "Hit return to continue"

# undo what we've done
set dummy x
set nogrid
set offsets 0,0,0,0
set title ""
set ylabel ""
set xlabel ""
set xrange [-10:10]
set autoscale xy
set key
set format xy "%g"
set nolabel
set nolog
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































Deleted r34.1/plot/demo/err.dat version [1bb5afc797].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#
# $Id: err.dat,v 3.26 92/03/24 22:32:32 woo Exp Locker: woo $
#
0	11.062	9.757	12.667	2.345
2	9.212	8.0908	10.932	1.725
5	8.55	7.6612	9.0388	2.846
10	8.122	7.327	8.617	0.957
15	8.156	7.6101	8.9019	1.577
20	8.122	7.5431	8.8009	3.141
25	7.988	6.3007	9.2753	1.57
27	8.096	6.665	10.555	2.172
29	7.936	6.9395	8.325	0.582
30	7.854	6.4909	9.8171	0.603
35	8.01	7.1556	8.644	1.063
40	8.02	7.0301	9.7099	2.152
45	8.092	6.9164	9.7676	1.44
50	8.072	7.2993	8.4447	1.96
60	8.286	7.7265	8.755	1.0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted r34.1/plot/demo/errorbar.demo version [dc3207f404].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# $Id: errorbar.demo,v 3.26 92/03/24 22:32:35 woo Exp Locker: woo $
#
#
# Requires data file "err.dat" from this directory,
# so change current working directory to this directory before running.
# gnuplot> set term <term-type>
# gnuplot> load 'errorbar.demo'
#

set title "Demonstration of error bars (both ylow and yhigh, default format)"
plot [-3:65] "err.dat" with errorbars

pause -1 "Hit return to continue"

# this should look the same
set title "Demonstration of error bars (both ylow and yhigh)"
plot [-3:65] "err.dat" using 1:2:3:4 with errorbars

pause -1 "Hit return to continue"

set title "Demonstration of error bars (only ydelta)"
plot [-3:65] "err.dat" using 1:2:5 with errorbars

pause -1 "Hit return to continue"

set title "Plot data file twice to get lines and errorbars"
plot [-3:65] [6:14] "err.dat" with lines, "err.dat" using 1:2:4:3 with errorbars

set title ""
set autoscale

pause -1 "Hit return to continue"
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































Deleted r34.1/plot/demo/glass.dat version [a34893693d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#
# $Id: glass.dat,v 3.26 92/03/24 22:32:21 woo Exp Locker: woo $
#
#
# 16x16 grid Glass shape. Created Using DRAWFN3D, Gershon Elber 1990.
#
  0.568000   0.000000  -0.911000
  0.518894   0.231026  -0.911000
  0.380066   0.422106  -0.911000
  0.175522   0.540200  -0.911000
 -0.059372   0.564888  -0.911000
 -0.284000   0.491902  -0.911000
 -0.459522   0.333862  -0.911000
 -0.555588   0.118094  -0.911000
 -0.555588  -0.118094  -0.911000
 -0.459522  -0.333862  -0.911000
 -0.284000  -0.491902  -0.911000
 -0.059372  -0.564888  -0.911000
  0.175522  -0.540200  -0.911000
  0.380066  -0.422106  -0.911000
  0.518894  -0.231027  -0.911000
  0.568000  -0.000000  -0.911000

  0.341741   0.000000  -0.905215
  0.312196   0.138999  -0.905215
  0.228669   0.253963  -0.905215
  0.105604   0.325015  -0.905215
 -0.035722   0.339869  -0.905215
 -0.170870   0.295956  -0.905215
 -0.276474   0.200870  -0.905215
 -0.334273   0.071052  -0.905215
 -0.334273  -0.071052  -0.905215
 -0.276474  -0.200870  -0.905215
 -0.170871  -0.295956  -0.905215
 -0.035722  -0.339869  -0.905215
  0.105604  -0.325015  -0.905215
  0.228669  -0.253963  -0.905215
  0.312196  -0.138999  -0.905215
  0.341741  -0.000000  -0.905215

  0.212153   0.000000  -0.863178
  0.193812   0.086290  -0.863178
  0.141958   0.157661  -0.863178
  0.065559   0.201770  -0.863178
 -0.022176   0.210991  -0.863178
 -0.106077   0.183730  -0.863178
 -0.171636   0.124701  -0.863178
 -0.207517   0.044109  -0.863178
 -0.207517  -0.044109  -0.863178
 -0.171636  -0.124701  -0.863178
 -0.106077  -0.183730  -0.863178
 -0.022176  -0.210991  -0.863178
  0.065559  -0.201770  -0.863178
  0.141958  -0.157661  -0.863178
  0.193812  -0.086291  -0.863178
  0.212153  -0.000000  -0.863178

  0.138097   0.000000  -0.764660
  0.126157   0.056169  -0.764660
  0.092405   0.102626  -0.764660
  0.042674   0.131338  -0.764660
 -0.014435   0.137340  -0.764660
 -0.069048   0.119595  -0.764660
 -0.111722   0.081171  -0.764660
 -0.135079   0.028712  -0.764660
 -0.135079  -0.028712  -0.764660
 -0.111722  -0.081171  -0.764660
 -0.069048  -0.119595  -0.764660
 -0.014435  -0.137340  -0.764660
  0.042674  -0.131338  -0.764660
  0.092405  -0.102626  -0.764660
  0.126157  -0.056169  -0.764660
  0.138097  -0.000000  -0.764660

  0.098588   0.000000  -0.618872
  0.090065   0.040099  -0.618872
  0.065968   0.073265  -0.618872
  0.030465   0.093763  -0.618872
 -0.010305   0.098048  -0.618872
 -0.049294   0.085380  -0.618872
 -0.079760   0.057949  -0.618872
 -0.096434   0.020498  -0.618872
 -0.096434  -0.020498  -0.618872
 -0.079760  -0.057949  -0.618872
 -0.049294  -0.085380  -0.618872
 -0.010305  -0.098048  -0.618872
  0.030465  -0.093763  -0.618872
  0.065968  -0.073265  -0.618872
  0.090065  -0.040099  -0.618872
  0.098588  -0.000000  -0.618872

  0.084164   0.000000  -0.452254
  0.076887   0.034232  -0.452254
  0.056317   0.062546  -0.452254
  0.026008   0.080044  -0.452254
 -0.008798   0.083703  -0.452254
 -0.042082   0.072888  -0.452254
 -0.068090   0.049470  -0.452254
 -0.082325   0.017499  -0.452254
 -0.082325  -0.017499  -0.452254
 -0.068090  -0.049470  -0.452254
 -0.042082  -0.072888  -0.452254
 -0.008798  -0.083703  -0.452254
  0.026008  -0.080045  -0.452254
  0.056317  -0.062546  -0.452254
  0.076887  -0.034233  -0.452254
  0.084164  -0.000000  -0.452254

  0.092386   0.000000  -0.291706
  0.084399   0.037577  -0.291706
  0.061819   0.068656  -0.291706
  0.028549   0.087865  -0.291706
 -0.009657   0.091880  -0.291706
 -0.046193   0.080009  -0.291706
 -0.074742   0.054303  -0.291706
 -0.090368   0.019208  -0.291706
 -0.090368  -0.019208  -0.291706
 -0.074742  -0.054303  -0.291706
 -0.046193  -0.080009  -0.291706
 -0.009657  -0.091880  -0.291706
  0.028549  -0.087865  -0.291706
  0.061819  -0.068656  -0.291706
  0.084399  -0.037577  -0.291706
  0.092386  -0.000000  -0.291706

  0.124988   0.000000  -0.153861
  0.114183   0.050837  -0.153861
  0.083634   0.092885  -0.153861
  0.038624   0.118871  -0.153861
 -0.013065   0.124304  -0.153861
 -0.062494   0.108243  -0.153861
 -0.101118   0.073466  -0.153861
 -0.122257   0.025987  -0.153861
 -0.122257  -0.025987  -0.153861
 -0.101118  -0.073466  -0.153861
 -0.062494  -0.108243  -0.153861
 -0.013065  -0.124304  -0.153861
  0.038624  -0.118871  -0.153861
  0.083634  -0.092885  -0.153861
  0.114183  -0.050837  -0.153861
  0.124988  -0.000000  -0.153861

  0.185015   0.000000  -0.041791
  0.169020   0.075253  -0.041791
  0.123799   0.137493  -0.041791
  0.057173   0.175960  -0.041791
 -0.019339   0.184002  -0.041791
 -0.092508   0.160228  -0.041791
 -0.149681   0.108749  -0.041791
 -0.180972   0.038467  -0.041791
 -0.180972  -0.038467  -0.041791
 -0.149681  -0.108749  -0.041791
 -0.092508  -0.160228  -0.041791
 -0.019339  -0.184002  -0.041791
  0.057173  -0.175960  -0.041791
  0.123799  -0.137493  -0.041791
  0.169020  -0.075253  -0.041791
  0.185015  -0.000000  -0.041791

  0.273264   0.000000   0.053395
  0.249639   0.111146   0.053395
  0.182849   0.203075   0.053395
  0.084443   0.259889   0.053395
 -0.028564   0.271767   0.053395
 -0.136632   0.236653   0.053395
 -0.221075   0.160620   0.053395
 -0.267292   0.056815   0.053395
 -0.267292  -0.056815   0.053395
 -0.221075  -0.160620   0.053395
 -0.136632  -0.236653   0.053395
 -0.028564  -0.271767   0.053395
  0.084443  -0.259889   0.053395
  0.182849  -0.203075   0.053395
  0.249639  -0.111146   0.053395
  0.273264  -0.000000   0.053395

  0.384384   0.000000   0.149114
  0.351152   0.156343   0.149114
  0.257203   0.285653   0.149114
  0.118781   0.365570   0.149114
 -0.040179   0.382278   0.149114
 -0.192192   0.332886   0.149114
 -0.310973   0.225935   0.149114
 -0.375984   0.079918   0.149114
 -0.375984  -0.079918   0.149114
 -0.310973  -0.225935   0.149114
 -0.192192  -0.332886   0.149114
 -0.040179  -0.382278   0.149114
  0.118781  -0.365571   0.149114
  0.257203  -0.285653   0.149114
  0.351152  -0.156343   0.149114
  0.384384  -0.000000   0.149114

  0.504089   0.000000   0.267473
  0.460508   0.205031   0.267473
  0.337301   0.374611   0.267473
  0.155772   0.479417   0.267473
 -0.052692   0.501327   0.267473
 -0.252044   0.436554   0.267473
 -0.407816   0.296296   0.267473
 -0.493073   0.104806   0.267473
 -0.493073  -0.104806   0.267473
 -0.407816  -0.296296   0.267473
 -0.252044  -0.436554   0.267473
 -0.052692  -0.501327   0.267473
  0.155772  -0.479417   0.267473
  0.337301  -0.374611   0.267473
  0.460508  -0.205031   0.267473
  0.504089  -0.000000   0.267473

  0.609609   0.000000   0.430046
  0.556906   0.247950   0.430046
  0.407908   0.453028   0.430046
  0.188380   0.579773   0.430046
 -0.063721   0.606270   0.430046
 -0.304805   0.527937   0.430046
 -0.493184   0.358319   0.430046
 -0.596288   0.126745   0.430046
 -0.596288  -0.126745   0.430046
 -0.493184  -0.358319   0.430046
 -0.304805  -0.527937   0.430046
 -0.063722  -0.606270   0.430046
  0.188380  -0.579773   0.430046
  0.407908  -0.453028   0.430046
  0.556906  -0.247951   0.430046
  0.609609  -0.000000   0.430046

  0.675154   0.000000   0.647779
  0.616784   0.274610   0.647779
  0.451766   0.501737   0.647779
  0.208634   0.642110   0.647779
 -0.070573   0.671455   0.647779
 -0.337577   0.584700   0.647779
 -0.546211   0.396846   0.647779
 -0.660400   0.140372   0.647779
 -0.660400  -0.140372   0.647779
 -0.546211  -0.396845   0.647779
 -0.337577  -0.584700   0.647779
 -0.070573  -0.671455   0.647779
  0.208634  -0.642110   0.647779
  0.451766  -0.501737   0.647779
  0.616784  -0.274610   0.647779
  0.675154  -0.000000   0.647779

  0.681825   0.000000   0.900691
  0.622878   0.277323   0.900691
  0.456230   0.506695   0.900691
  0.210696   0.648454   0.900691
 -0.071270   0.678090   0.900691
 -0.340913   0.590478   0.900691
 -0.551608   0.400767   0.900691
 -0.666926   0.141760   0.900691
 -0.666926  -0.141759   0.900691
 -0.551608  -0.400767   0.900691
 -0.340913  -0.590478   0.900691
 -0.071270  -0.678090   0.900691
  0.210695  -0.648454   0.900691
  0.456230  -0.506695   0.900691
  0.622878  -0.277324   0.900691
  0.681825  -0.000000   0.900691

  0.626000   0.000000   1.101000
  0.571879   0.254617   1.101000
  0.418876   0.465209   1.101000
  0.193445   0.595361   1.101000
 -0.065435   0.622571   1.101000
 -0.313000   0.542132   1.101000
 -0.506445   0.367954   1.101000
 -0.612320   0.130153   1.101000
 -0.612320  -0.130153   1.101000
 -0.506445  -0.367953   1.101000
 -0.313000  -0.542132   1.101000
 -0.065435  -0.622571   1.101000
  0.193444  -0.595361   1.101000
  0.418876  -0.465209   1.101000
  0.571879  -0.254617   1.101000
  0.626000  -0.000000   1.101000

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































Deleted r34.1/plot/demo/hidden.demo version [3b23bef846].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
# $Id$
#
# $Log$
#
set samples 20
set isosamples 20
set hidden3d
set title "Hidden line removal of explicit surfaces"


set xrange [-3:3]
set yrange [-2:2]
splot 1 / (x*x + y*y + 1)
pause -1 "Hit return to continue (1)"

set xrange [-1:1]
set yrange [-1:1]
splot x*y / (x**2 + y**2 + 0.1)
pause -1 "Hit return to continue (2)"

set view 70,45
set nocontour
set xrange [-3:3]
set yrange [-3:3]
splot sin(x*x + y*y) / (x*x + y*y)
pause -1 "Hit return to continue (3)"

set view 60,30
set xrange [-3:3]
set yrange [-3:3]
splot sin(x) * cos(y)
pause -1 "Hit return to continue (4)"

set view 75,230
set contour
replot
pause -1 "Hit return to continue (5)"

set view 80,30,1,1
set data style lines
set autoscale
splot "glass.dat" using 1
pause -1 "Hit return to continue (6)"

set view 50,
set grid
replot
pause -1 "Hit return to continue (7)"

set nocontour
set nogrid
set nohidden3d
set samples 100
set isosamples 10
set view 60,30,1,1
set xrange [-10:10]
set yrange [-10:10]
set zrange [-10:10]
set auto
set title "" 0,0


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted r34.1/plot/demo/param.demo version [0fd8bcbb4e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
# $Id: param.demo,v 3.26 92/03/24 22:32:22 woo Exp Locker: woo $
#
#
# Show some of the new parametric capabilities.
#
set parametric
set dummy t
set autoscale
set samples 160
set title ""
plot t,sin(t)/t title "t,sin(t)/t or sin(x)/x"
pause -1 "Hit return to continue"

plot sin(t)/t,t
pause -1 "Hit return to continue"

plot sin(t),cos(t)
pause -1 "Hit return to continue"

set xrange [-3:3]
set yrange [-3:3]
set title "Parametric Conic Sections"
plot -t,t,cos(t),cos(2*t),2*cos(t),sin(t),-cosh(t),sinh(t)
set title ""
pause -1 "Hit return to continue"

set xrange [-5:5]
set yrange [-5:5]
plot tan(t),t,t,tan(t)
pause -1 "Hit return to continue"

set trange [-3:3]
plot t,log(t),-t,log(t),sin(t),t**2
pause -1 "Hit return to continue"

set autoscale x
set yrange [-1.5:1.5]
set trange [0:10*pi]
plot sin(t)/t,cos(t)/t
pause -1 "Hit return to continue"

# undo what we've done above
set noparametric
set samples 160
set autoscale xy
set title ""
set offset 0,0,0,0
set key
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































Deleted r34.1/plot/demo/polar.dat version [bafb192802].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
# $Id: polar.dat,v 3.26 92/03/24 22:32:34 woo Exp Locker: woo $
#
# Input data ncmain.d4 generated by genpat2.f:Tx antenna pattern
# x,y,z of center point B in coord 3
#     -5.12000     0.00000    -1.50000  
# euler matrix
#      0.00000    -1.00000     0.00000  
#      0.70710     0.00000     0.70710  
#     -0.70710     0.00000     0.70710  
#  theta(deg)    phi(deg)  E-theta(dB)  phase     E-phi(dB)    phase
      0.000      0.000   -200.000      0.000     18.992      0.000 
      2.000      0.000   -200.000      0.000     18.898      0.000 
      4.000      0.000   -200.000      0.000     18.619      0.000 
      6.000      0.000   -200.000      0.000     18.152      0.000 
      8.000      0.000   -200.000      0.000     17.497      0.000 
     10.000      0.000   -200.000      0.000     16.651      0.000 
     12.000      0.000   -200.000      0.000     15.614      0.000 
     14.000      0.000   -200.000      0.000     14.382      0.000 
     16.000      0.000   -200.000      0.000     12.952      0.000 
     18.000      0.000   -200.000      0.000     11.320      0.000 
     20.000      0.000   -200.000      0.000      9.483      0.000 
     22.000      0.000   -200.000      0.000      7.434      0.000 
     24.000      0.000   -200.000      0.000      5.169      0.000 
     26.000      0.000   -200.000      0.000      2.680      0.000 
     28.000      0.000   -200.000      0.000     -0.039      0.000 
     30.000      0.000   -200.000      0.000     -2.998      0.000 
     32.000      0.000   -200.000      0.000     -6.204      0.000 
     34.000      0.000   -200.000      0.000     -9.670      0.000 
     36.000      0.000   -200.000      0.000    -13.407      0.000 
     38.000      0.000   -200.000      0.000    -17.429      0.000 
     40.000      0.000   -200.000      0.000    -21.751      0.000 
     42.000      0.000   -200.000      0.000    -26.391      0.000 
     44.000      0.000   -200.000      0.000    -31.368      0.000 
     46.000      0.000   -200.000      0.000    -36.705      0.000 
     48.000      0.000   -200.000      0.000    -42.429      0.000 
     50.000      0.000   -200.000      0.000    -48.569      0.000 
     52.000      0.000   -200.000      0.000    -55.160      0.000 
     54.000      0.000   -200.000      0.000    -62.243      0.000 
     56.000      0.000   -200.000      0.000    -69.867      0.000 
     58.000      0.000   -200.000      0.000    -78.087      0.000 
     60.000      0.000   -200.000      0.000    -86.971      0.000 
     62.000      0.000   -200.000      0.000    -96.602      0.000 
     64.000      0.000   -200.000      0.000   -107.080      0.000 
     66.000      0.000   -200.000      0.000   -118.530      0.000 
     68.000      0.000   -200.000      0.000   -131.110      0.000 
     70.000      0.000   -200.000      0.000   -145.022      0.000 
     72.000      0.000   -200.000      0.000   -160.534      0.000 
     74.000      0.000   -200.000      0.000   -177.982      0.000 
     76.000      0.000   -200.000      0.000   -195.848      0.000 
     78.000      0.000   -200.000      0.000   -199.967      0.000 
     80.000      0.000   -200.000      0.000   -200.000      0.000 
     82.000      0.000   -200.000      0.000   -200.000      0.000 
     84.000      0.000   -200.000      0.000   -200.000      0.000 
     86.000      0.000   -200.000      0.000   -200.000      0.000 
     88.000      0.000   -200.000      0.000   -200.000      0.000 
     90.000      0.000   -200.000      0.000   -200.000      0.000 
     92.000      0.000   -200.000      0.000   -200.000      0.000 
     94.000      0.000   -200.000      0.000   -200.000      0.000 
     96.000      0.000   -200.000      0.000   -200.000      0.000 
     98.000      0.000   -200.000      0.000   -200.000      0.000 
    100.000      0.000   -200.000      0.000   -200.000      0.000 
    102.000      0.000   -200.000      0.000   -200.000      0.000 
    104.000      0.000   -200.000      0.000   -200.000      0.000 
    106.000      0.000   -200.000      0.000   -200.000      0.000 
    108.000      0.000   -200.000      0.000   -200.000      0.000 
    110.000      0.000   -200.000      0.000   -200.000      0.000 
    112.000      0.000   -200.000      0.000   -200.000      0.000 
    114.000      0.000   -200.000      0.000   -200.000      0.000 
    116.000      0.000   -200.000      0.000   -200.000      0.000 
    118.000      0.000   -200.000      0.000   -200.000      0.000 
    120.000      0.000   -200.000      0.000   -200.000      0.000 
    122.000      0.000   -200.000      0.000   -200.000      0.000 
    124.000      0.000   -200.000      0.000   -200.000      0.000 
    126.000      0.000   -200.000      0.000   -200.000      0.000 
    128.000      0.000   -200.000      0.000   -200.000      0.000 
    130.000      0.000   -200.000      0.000   -200.000      0.000 
    132.000      0.000   -200.000      0.000   -200.000      0.000 
    134.000      0.000   -200.000      0.000   -200.000      0.000 
    136.000      0.000   -200.000      0.000   -200.000      0.000 
    138.000      0.000   -200.000      0.000   -200.000      0.000 
    140.000      0.000   -200.000      0.000   -200.000      0.000 
    142.000      0.000   -200.000      0.000   -200.000      0.000 
    144.000      0.000   -200.000      0.000   -200.000      0.000 
    146.000      0.000   -200.000      0.000   -200.000      0.000 
    148.000      0.000   -200.000      0.000   -200.000      0.000 
    150.000      0.000   -200.000      0.000   -200.000      0.000 
    152.000      0.000   -200.000      0.000   -200.000      0.000 
    154.000      0.000   -200.000      0.000   -200.000      0.000 
    156.000      0.000   -200.000      0.000   -200.000      0.000 
    158.000      0.000   -200.000      0.000   -200.000      0.000 
    160.000      0.000   -200.000      0.000   -200.000      0.000 
    162.000      0.000   -200.000      0.000   -200.000      0.000 
    164.000      0.000   -200.000      0.000   -200.000      0.000 
    166.000      0.000   -200.000      0.000   -200.000      0.000 
    168.000      0.000   -200.000      0.000   -200.000      0.000 
    170.000      0.000   -200.000      0.000   -200.000      0.000 
    172.000      0.000   -200.000      0.000   -200.000      0.000 
    174.000      0.000   -200.000      0.000   -200.000      0.000 
    176.000      0.000   -200.000      0.000   -200.000      0.000 
    178.000      0.000   -200.000      0.000   -200.000      0.000 
    180.000      0.000   -200.000      0.000   -200.000      0.000 
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































Deleted r34.1/plot/demo/polar.demo version [5560d98d11].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# $Id: polar.demo,v 3.26 92/03/24 22:32:23 woo Exp Locker: woo $
#
#
# Show some of the new polar capabilities.
#
set polar
set dummy x
set samples 160
set xrange [0:2*pi]
set title "Three circles (with aspect ratio distortion)"
plot .5,1,1.5
pause -1 "Hit return to continue"
set title ""

plot cos(2*x)
pause -1 "Hit return to continue"

plot 2*sqrt(cos(x)),-2*sqrt(cos(x))
pause -1 "Hit return to continue"

set offset pi/4,pi/4,0,0
plot sin(4*x),cos(4*x)
set offset 0,0,0,0
pause -1 "Hit return to continue"

set yrange [-5:5]
plot x/cos(3*x)
pause -1 "Hit return to continue"
set autoscale

plot 1-sin(x)
pause -1 "Hit return to continue"

set xrange [0:12*pi]
plot 2*x
pause -1 "Hit return to continue"

butterfly(x)=exp(cos(x))-2*cos(4*x)+sin(x/12)**5
set samples 800
pause 0 "This is a big one (many samples), be patient..."
set title "Butterfly"
set nokey
plot butterfly(x)
pause -1 "Hit return to continue"

# undo what we've done above
set nopolar
set samples 160
set autoscale xy
set title ""
set offset 0,0,0,0
set key
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































Deleted r34.1/plot/demo/poldat.demo version [1b601fc75b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# $Id: poldat.demo,v 3.26 92/03/24 22:32:33 woo Exp Locker: woo $
#
set samples 361
set size .757,1.0
set time
set title "Antenna Pattern"
set xlabel "Azimuth"
set ylabel "dBSM"
set data style line
set angles degrees
set polar
set yrange [-220:220]
set rrange [-200:60]
plot "polar.dat" using 1:5,"antenna.dat",-150,-100,-50,0
pause -1 "Hit return to continue"

set samples 100
set size 1.0,1.0
set notime
set title "" 0,0
set xlabel "" 0,0
set ylabel "" 0,0
set data style points
set angles radians
set nopolar
set yrange [-10:10]
set rrange [0:10]
set auto
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































Deleted r34.1/plot/demo/simple.demo version [1293b2d87a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# $Id: simple.demo,v 3.26 92/03/24 22:32:24 woo Exp Locker: woo $
#
#
# Requires data files "[123].dat" from this directory,
# so change current working directory to this directory before running.
# gnuplot> set term <term-type>
# gnuplot> load 'simple.demo'
#
set samples 50
plot [-10:10] sin(x),atan(x),cos(atan(x))
pause -1 "Hit return to continue"

set samples 100 
plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))
pause -1 "Hit return to continue"

set samples 200 
plot [-3:5] asin(x),acos(x)
pause -1 "Hit return to continue"

plot [-30:20] besj0(x)*0.12e1 with impulses, (x**besj0(x))-2.5 with points
pause -1 "Hit return to continue"

set samples 400
plot [-10:10] real(sin(x)**besj0(x))
pause -1 "Hit return to continue"

plot [-5*pi:5*pi] [-5:5] real(tan(x)/atan(x)), 1/x
pause -1 "Hit return to continue"

set autoscale
set samples 800
plot [-30:20] sin(x*20)*atan(x)
pause -1 "Hit return to continue"

plot [-19:19] '1.dat'with impulses ,'2.dat' ,'3.dat' with lines
pause -1 "Hit return to continue"

# undo what we have done above
set samples 160
set xrange [-10:10]
set autoscale xy
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































Deleted r34.1/plot/demo/surface1.demo version [c2b9cafc35].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# $Id: surface1.demo,v 3.26 92/03/24 22:32:25 woo Exp Locker: woo $
#
set samples 21
set isosample 11
set xlabel "X axis" -3,-2
set ylabel "Y axis" 3,-2
set zlabel "Z axis" -5
set title "3D gnu plot demo"
set label 1 "This is the surface boundary" at -20,-5,210
set arrow 1 from -10,-5,220 to -10,0,0 nohead
set arrow 2 from -10,-5,220 to 10,0,0 nohead
set arrow 3 from -10,-5,220 to 0,10,0 nohead
set arrow 4 from -10,-5,220 to 0,-10,0 nohead
splot x*y
pause -1 "Hit return to continue (1)"
set noarrow
set nolabel
set grid
splot x**2+y**2, x**2-y**2
pause -1 "Hit return to continue (2)"
rep x*y
pause -1 "Hit return to continue (3)"
rep (x**3+y**3)/10
pause -1 "Hit return to continue (4)"
set ticslevel 0.0
set title "3D gnu plot demo ( ticslevel = 0.0 )"
rep
pause -1 "Hit return to continue (5)"
set ticslevel 2.0
set title "3D gnu plot demo ( ticslevel = 2.0 )"
rep
pause -1 "Hit return to continue (6)"
set ticslevel 0.5
set title "3D gnu plot demo ( ticslevel = 0.5 )"
rep
pause -1 "Hit return to continue (7)"
set title "3D gnu plot demo"
set nogrid
splot x*y with points
pause -1 "Hit return to continue (8)"
set noxtics
set noytics
set xrange [-1:1]
set yrange [-1:1]
set title "Surfaces with no grid or tics"
splot x*y with lines, x**2*y**3 with dots, x**3*y*2 with points
pause -1 "Hit return to continue (9)"
set xtics ("low" -3, "mid" 0, "high" 3)
set ytics -2,0.5,2
set xrange [-3:3]
set yrange [-3:3]
set log z
set title "Surfaces with z log scale"
splot x**2*y**2 + 2, x**2*y**4 + 2, x**4*y**2 + 2
pause -1 "Hit return to continue (10)"
set nolog z
set xtics
set ytics
set xrange [-1:1]
set yrange [-1:1]
set samples 51
set isosample 21
set dummy u,v
set title "3D gnu plot demo"
splot u*v / (u**2 + v**2 + 0.1)
pause -1 "Hit return to continue (11)"
splot [x=-3:3] [y=-3:3] sin(x) * cos(y)
pause -1 "Hit return to continue (12)"
set zrange [-0.35:0.35]
replot
pause -1 "Hit return to continue (13)"
set title "Sinc function"
set label 1 "This is equal to 1" at -5,-2,0.75 right
set arrow 1 from -5,-2.1,0.75 to 0,0,1
sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)
splot [-5:5.01] [-5:5.01] sinc(u,v)
pause -1 "Hit return to continue (14)"
set view 70,20,1
set zrange [-0.5:1.0]
set ztics -1,0.25,1
set label 1 "This is equal to 1" at -5,-2,1.5 centre
set arrow 1 from -5,-2.1,1.4 to 0,0,1
splot [-12:12.01] [-12:12.01] sinc(u,v)
pause -1 "Hit return to continue (15)"
set noarrow
set ztics
set nolabel
set log
set auto
set title "This has logarithmic scale"
splot [x=1:15] [y=1:15] x**2+y**2
pause -1 "Hit return to continue (16)"
set nolog
set xrange [0:15]
set yrange [0:15]
set auto
set zrange [-0.6:0.6]
set data style lines
set title "Data grid plotting"
set parametric
splot "glass.dat"
pause -1 "Hit return to continue (17)"
splot "glass.dat" using 3:2:1
pause -1 "Hit return to continue (18)"
set zrange [-1.2:1.2]
set noparametric
splot "glass.dat" using 1, "glass.dat" using 2, "glass.dat" using 3
pause -1 "Hit return to continue (19)"

#
# Clean up:
#
set samples 100
set isosamples 10
set view 60,30,1,1
set xrange [-10:10]
set yrange [-10:10]
set zrange [-10:10]
set auto
set title "" 0,0
set xlabel "" 0,0
set ylabel "" 0,0
set zlabel "" 0,0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































Deleted r34.1/plot/demo/surface2.demo version [81d77499dc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# $Id: surface2.demo,v 3.26 92/03/24 22:32:26 woo Exp Locker: woo $
#
set parametric
set samples 50

set title "Parametric Sphere"
set urange [-pi/2:pi/2]
set vrange [0:2*pi]
set zrange [-1:1]
set ztics -1.0,0.25,1.0
set view ,,,2.5
splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
pause -1 "Hit return to continue (1)"

set view ,,,0.8
replot
pause -1 "Hit return to continue (2)"

set view ,,,1.6
replot
pause -1 "Hit return to continue (3)"

set view ,,,1.0

set title "Parametric Torus"
set urange [0:2*pi]
set vrange [0:2*pi]
splot (1-0.2*cos(v))*cos(u),(1-0.2*cos(v))*sin(u),0.2*sin(v)
pause -1 "Hit return to continue (4)"

set title "Parametric Hexagon"
set urange [-1.3:1.3]
set vrange [0:2*pi]
set zrange [-0.6:0.6]
set ztics
splot cos(v)**3*cos(u)**3,sin(v)**3*cos(u)**3,sin(u)**3
pause -1 "Hit return to continue (5)"

set title "Parametric Helix"
set samples 100
set urange [0:10*pi]
set vrange [0:2*pi]
set zrange [-0.6:0.6]
splot (1-0.1*cos(v))*cos(u),(1-0.1*cos(v))*sin(u),0.1*(sin(v)+u/1.7-10)
pause -1 "Hit return to continue (6)"

set title "Parametric Shell"
set samples 40
set view 50,30,1.0
set urange [0:2*pi]
set vrange [0:2*pi]
set zrange [-3:1.5]
splot cos(u)*u*(1+cos(v)/2),sin(v)*u/2,sin(u)*u*(1+cos(v)/2)
pause -1 "Hit return to continue (7)"

#
# Clean up:
#
set noparametric
set dummy x,y
set samples 100
set view 60,30,1,1
set urange [-5:5]
set vrange [-5:5]
set zrange [-10:10]
set auto
set title "" 0,0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































Deleted r34.1/plot/demo/using.dat version [e0efbaed7b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#
# $Id: using.dat,v 3.26 92/03/24 22:32:26 woo Exp Locker: woo $
#
891101 00   1.00  14   8.6  94.0
891101 01   1.04  10  17.5  94.4
891101 02   1.08   9   9.7  97.1
891101 03   1.13   9  10.1  94.3
891101 04   1.17   9   5.7  98.3
891101 05   1.21   8   8.1  99.7
891101 06   1.25   7   3.2  99.6
891101 07   1.29   6   2.5  99.8
891101 08   1.33  20   2.3  99.4
891101 09   1.38  30   3.5  96.1
891101 10   1.42  37   7.7  96.4
891101 11   1.46  36   9.8  97.4
891101 12   1.50  30   8.8  97.4
891101 13   1.54  32   9.1  96.5
891101 14   1.58  37   6.3  97.0
891101 15   1.63  35   6.1  97.3
891101 16   1.67  41   8.6  97.2
891101 17   1.71  28   7.6  97.3
891101 18   1.75  16   4.3  97.6
891101 19   1.79  21   4.2  97.5
891101 20   1.83  20   5.6  96.9
891101 21   1.88  24   6.6  96.2
891101 22   1.92  19   5.8  97.1
891101 23   1.96  16   7.4  97.1
891102 00   2.00  13   7.4  96.4
891102 01   2.04   8   6.6  95.6
891102 02   2.08   6   7.4  94.1
891102 03   2.13   6   6.4  95.9
891102 04   2.17   7   6.4  95.5
891102 05   2.21   6   6.7  95.5
891102 06   2.25   6   6.3  94.6
891102 07   2.29   7   6.5  93.1
891102 08   2.33  15   6.5  92.8
891102 09   2.38  22   7.2  93.2
891102 10   2.42  31   9.1  93.9
891102 11   2.46  37  11.0  95.6
891102 12   2.50  40   9.8  98.7
891102 13   2.54  45   9.5  97.3
891102 14   2.58  46  11.4  98.5
891102 15   2.63  46  11.9  99.1
891102 16   2.67  43  13.0  98.8
891102 17   2.71  28  14.5  99.1
891102 18   2.75  25  13.4  99.1
891102 19   2.79  24   9.9  99.7
891102 20   2.83  25   8.1  99.5
891102 21   2.88  24  10.3  99.4
891102 22   2.92  24  12.0  98.7
891102 23   2.96  23  18.2  98.7
891103 00   3.00  20  16.8  99.0
891103 01   3.04  16  14.8  99.2
891103 02   3.08  17  15.5  98.0
891103 03   3.13  17  14.4  99.4
891103 04   3.17  16  14.4  99.4
891103 05   3.21  14  11.3  99.4
891103 06   3.25  13   8.0  99.7
891103 07   3.29  13   6.1  99.9
891103 08   3.33  18   6.4  99.8
891103 09   3.38  31   6.5  98.9
891103 10   3.42  39   7.5  99.0
891103 11   3.46  37   9.1  98.8
891103 12   3.50  33   9.0  99.2
891103 13   3.54  40  10.4  98.7
891103 14   3.58  45  12.9  98.3
891103 15   3.63  45  13.8  98.5
891103 16   3.67  37  16.1  98.9
891103 17   3.71  29  16.0  99.3  57
891103 18   3.75  21  17.4  97.9  55
891103 19   3.79  14  14.6  97.7
891103 20   3.83  11  14.3  97.8  57
891103 21   3.88  15  14.7  96.2  59
891103 22   3.92  10  12.8  95.1  57
891103 23   3.96   8  10.2  97.6
891104 00   4.00   6   7.3  98.6
891104 01   4.04   4   4.7  99.8
891104 02   4.08   3   3.4  98.0
891104 03   4.13   4   2.9  99.6
891104 04   4.17   4   2.1  99.8
891104 05   4.21   4  11.7  99.9
891104 06   4.25   4   4.5  99.9
891104 07   4.29   4   1.6  88.4
891104 08   4.33   4   1.3  65.2
891104 09   4.38   7   1.4  71.4
891104 10   4.42   9   1.3  70.7
891104 11   4.46  14   8.1  99.5
891104 12   4.50  12   4.2  75.3
891104 13   4.54  18  10.9  95.3
891104 14   4.58  16   7.1  87.6
891104 15   4.63  18   3.3  98.9
891104 16   4.67  15   3.4  99.6
891104 17   4.71   8   2.4  99.9
891104 18   4.75   8   2.2  99.8
891104 19   4.79  11   2.2  99.7
891104 20   4.83  14   2.3  99.7
891104 21   4.88  13   2.5  99.7
891104 22   4.92  10   3.1  99.8
891104 23   4.96  12   4.5  99.7
891105 00   5.00   9   4.8  99.7
891105 01   5.04   8   4.9  99.8
891105 02   5.08   5   5.7  97.5
891105 03   5.13   5   5.2  97.6
891105 04   5.17   4   3.3  85.9
891105 05   5.21   5   1.2  71.4
891105 06   5.25   5   1.1  61.8
891105 07   5.29   5   1.0  71.8
891105 08   5.33   5   1.0  55.7
891105 09   5.38   6   1.0  62.2
891105 10   5.42   7   1.1  61.9
891105 11   5.46   9   1.4  65.6
891105 12   5.50  14   2.8  99.6
891105 13   5.54  16   2.1  94.0
891105 14   5.58  16   2.2  85.1
891105 15   5.63  17   2.5  99.7
891105 16   5.67  19   2.2  90.8
891105 17   5.71  16   1.5  61.3
891105 18   5.75  12   1.6  71.8
891105 19   5.79  16   2.8  98.3
891105 20   5.83  17   3.3  88.8
891105 21   5.88  18   1.3  56.5
891105 22   5.92  20   0.9  38.8
891105 23   5.96  12   1.1  50.8
891106 00   6.00  10   2.2  68.4
891106 01   6.04   8   1.2  54.4
891106 02   6.08   8   1.6  58.4
891106 03   6.13   7   1.1  52.2
891106 04   6.17   6   1.1  56.4
891106 05   6.21   6   1.2  55.7
891106 06   6.25   6   1.0  46.2
891106 07   6.29   7   0.5   7.2
891106 08   6.33  17   0.7  13.8
891106 09   6.38  31   1.1  41.5
891106 10   6.42  37   1.5  52.7
891106 11   6.46  36   3.1  83.7
891106 12   6.50  29   2.0  70.0
891106 13   6.54  28   1.6  71.4
891106 14   6.58  38   3.1  99.1
891106 15   6.63  39   5.6  98.2
891106 16   6.67  43   5.7  98.7  59
891106 17   6.71  27   5.7  99.4
891106 18   6.75  15   4.3  99.8
891106 19   6.79  17   4.1  99.7
891106 20   6.83  20   2.9  99.3
891106 21   6.88  16   3.1  96.3
891106 22   6.92  16   2.8  86.1
891106 23   6.96  16   3.3  96.5
891107 00   7.00  12   3.2  98.2
891107 01   7.04  12   1.6  77.7
891107 02   7.08  10   3.0  98.7
891107 03   7.13   8   1.7  71.1
891107 04   7.17   8   2.8  81.4
891107 05   7.21   8   5.4  92.4
891107 06   7.25   9   5.3  87.7
891107 07   7.29  11   5.6  94.0
891107 08   7.33  15   2.0  74.0
891107 09   7.38  25   2.7  84.3
891107 10   7.42  32   3.0  92.9
891107 11   7.46  41   5.5  97.4
891107 12   7.50  39   6.5  97.5
891107 13   7.54  31   4.4  95.9
891107 14   7.58  35   7.3  98.6
891107 15   7.63  37   8.3  96.3
891107 16   7.67  34   9.2  97.6
891107 17   7.71  20   7.5  99.3
891107 18   7.75  14   7.1  99.5
891107 19   7.79  15   7.1  99.7
891107 20   7.83  16   4.9  99.7
891107 21   7.88  18   4.3  99.7
891107 22   7.92  15   3.1  99.7
891107 23   7.96  11   3.3  99.6
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































Deleted r34.1/plot/demo/using.demo version [0e0943b98c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# $Id: using.demo,v 3.26 92/03/24 22:32:27 woo Exp Locker: woo $
#
#
# Requires data file "using.dat" from this directory,
# so change current working directory to this directory before running.
#
set title "Convex     November 1-7 1989"
set label "(Weekend)" at 5,25 center
plot 'using.dat' using 3:4 title "Logged in" with impulses,\
     'using.dat' using 3:5 t "Load average" with points,\
     'using.dat' using 3:6 t "%CPU used" with lines
set nolabel
pause -1 "Hit return to continue"

set title "Convex     November 1-7 1989    Circadian"
set xrange[-1:24]
plot 'using.dat' using 2:4 title "Logged in" with impulses,\
     'using.dat' using 2:4 title "Logged in" with points
pause -1 "Hit return to continue"

# undo what we have done above
set title
set autoscale x
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































Deleted r34.1/plot/demo/world.cor version [c0ae53b769].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# $Id: world.cor,v 3.26 92/03/24 22:32:28 woo Exp Locker: woo $
#
# Gnuplot world correspondences.  Feel free to check for and update
# your site; especially if it represents a new location or you
# know more precise coordinates for a site.  A (?) indicates
# the site may not be correct.  Currently coordinates are generally
# rounded to the nearest latitude and longitude.  It's fine, however,
# to give as many decimal places with each as you like.

# USA
# Carnegie Mellon University
# Univ. of Calif. at Irvine
# University of Maryland
-110 35        # Northern Arizona University, Flagstaff, Arizona
-111 32        # Univ. of Arizona, Tucson, Arizona
-110 43        # University of Utah, Salt Lake City, Utah
-118 34        # California Institute of Technology (CALTECH), L.A., Calif.
-118 34        # Claremont, California
-118 34        # Univ. of Calif. at Los Angeles (UCLA), California
-120 34.5      # Univ. of Calif. at Santa Barbara, California
-122 37.5      # Stanford, California
-122 38        # Berkeley, California
-122 38        # Richmond, California
-122 47.5      # University of Washington, Washington
-71 42.5       # MIT, Cambridge, Massachusetts
-74.5 40.5     # New Brunswick, New Jersey
-75 41         # Bethlehem, Pennsylvania
-76 42         # Cornell College, Ithica, New York
-78.5 38       # Univ of Virginia, Charlottesville, Virginia
-79 36         # N.C. State University, Chapel Hill, North Carolina
-80 35         # Duke University, Durham, North Carolina
-81 28         # Melbourne, Florida
-83 40         # Ohio State, Columbus, Ohio
-83 42         # Detroit, Michigan
-84 34         # Alpharetta, Georgia
-84 34         # Atlanta, Georgia
-84 42         # Univ. of Michigan, Ann Arbor, Michigan
-86 39         # UCS Indiana (?)
-88 40         # University of Illinois, Urbana-Champaign, Illinois
-88 42         # Arlington Heights, Illinois
-88 42         # Northwestern University, Evanston, Illinois
-92 30         # Lafayette, Louisiana
-93 45         # Eagan, Minnesota
-95 30         # Houston, Texas
-95 39         # Kansas State University
-96 31         # Texas A&M, College Station, Texas
-98 30         # Univ of Texas, Austin, Texas
# Canada
-123 49        # BC Hydro, Vancover, British Columbia  (?)
-63 45         # Dartmouth, Nova Scotia, Canada
-75 45         # Ecole Polytechnique de Montreal, Canada
# United Kingdom
-8 54.5        # Bangor, United Kingdom
-80.5 43.5     # Waterloo, Ontario, Canada
0 52           # Cambridge, U. K.
# Italy
14 46          # Trieste, Italy
# Australia
138.5666 -35.01666      # Flinders University, Adelaide, South Australia
138.6333 -34.8          # South Australian Institute, Adelaide, South AUS
145.1333 -37.9167       # Monash University, Melbourne, Victoria
144.9833 -37.8167       # Melbourne University, Melbourne, Victoria
# Namibia
17 -23         # Windhoek, Namibia
# Sweden
18 60          # Stockholm, Sweden
# France
2 49           # Valbonne, CEDEX, France  (?)
# Finland
24 60          # Espoo, Finland
24 62          # Wassau, Finland (?)
# Belgium
4.5 51         # Brussels, Belgium
# The Netherlands
4.5 52         # Delft, The Netherlands
# Germany
7 51           # University of Cologne, Federal Republic of Germany
7 51.5         # Fraunhofer Institut, Duisburg, Germany
8 48           # Freiburg im Br.  (Federal Republic of Germany)
8 52           # Univesity of Dortmund, Federal Republic of Germany
11.5 48        # Technische Universitaet Muenchen, Munich, Germany
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































Deleted r34.1/plot/demo/world.dat version [927ae14485].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
#
# $Id: world.dat,v 3.26 92/03/24 22:32:29 woo Exp Locker: woo $
#
-140.37  60.25
-132.08  57.20
-131.46  55.98
-133.84  57.12
-136.01  59.12
-137.12  58.28
-139.98  59.73
-146.54  60.36
-149.90  59.50
-149.18  60.81
-153.53  59.32
-156.52  57.11
-162.34  55.06
-157.85  58.12
-162.06  58.36
-164.58  60.06
-165.29  62.57
-161.12  64.49
-168.23  65.49
-162.99  65.97
-161.56  66.55
-166.64  68.25
-159.53  70.38
-154.37  70.96
-148.09  70.26
-142.49  69.83
-141.21  69.56 

-152.62  58.41
-152.60  58.40 

-153.30  57.80
-152.40  57.48
-153.32  57.79 

-166.96  53.96
-167.01  53.95 

-168.36  53.50
-168.19  53.36 

-170.73  52.68
-170.60  52.55 

-174.47  51.94
-174.47  51.92 

-176.58  51.71
-176.64  51.73 

-177.55  51.76
-177.41  51.63 

-178.27  51.75 

177.35  51.80
177.33  51.76 

172.44  53.00
172.55  53.03 

-141.21  60.16
-133.38  58.93
-130.88  54.83
-128.86  53.90
-126.58  52.12
-127.08  50.80
-124.42  49.66
-122.56  48.91 

-92.32  48.24
-88.13  48.92
-83.11  46.27
-81.66  44.76
-82.09  42.29
-77.10  44.00
-69.95  46.92
-65.92  45.32
-66.37  44.25
-61.22  45.43
-64.94  47.34
-64.12  48.52
-70.68  47.02
-67.24  49.33
-59.82  50.48
-56.14  52.46
-59.07  53.58
-58.26  54.21
-60.69  55.33
-61.97  57.41
-64.35  59.49
-67.29  58.15
-69.89  59.91
-71.31  61.45
-78.22  61.97
-77.28  59.53
-77.09  55.88
-79.06  51.68
-82.23  52.70
-86.75  55.72
-92.17  56.86
-95.61  58.82
-92.66  62.02
-90.65  63.24
-95.96  64.12
-89.88  63.98
-89.30  65.22
-86.86  66.12
-84.54  66.88
-82.30  67.76
-83.10  69.68
-86.05  67.98
-88.18  68.20
-91.00  68.82
-91.72  69.69
-93.15  71.09
-96.58  71.05
-93.35  69.52
-94.23  68.25
-95.96  66.73
-98.83  68.27
-102.45  67.69
-108.34  68.43
-105.83  68.05
-108.15  66.60
-111.15  67.63
-114.10  68.23
-120.92  69.44
-124.32  69.26
-128.76  70.50
-131.86  69.19
-131.15  69.79
-135.81  69.13
-140.19  69.37
-141.20  69.58 

-123.40  48.33
-128.00  50.84
-123.50  48.34 

-132.49  52.88
-132.44  52.91 

-132.64  53.02
-131.97  53.71
-132.63  53.02 

-55.36  51.56
-54.66  49.52
-53.65  47.48
-52.98  46.31
-56.12  46.84
-58.47  47.57
-57.61  50.38
-55.39  51.53 

-61.37  49.01
-61.80  49.29
-61.38  49.03 

-63.01  46.71
-64.42  46.61
-63.04  46.68 

-60.14  46.48
-60.14  46.50 

-122.44  48.92
-124.42  47.18
-124.52  42.48
-123.09  38.45
-121.73  36.62
-117.60  33.34
-117.28  32.64 

-97.62  25.82
-95.62  28.84
-90.77  29.03
-87.33  30.22
-82.69  28.15
-80.16  26.66
-80.74  32.31
-76.89  35.43
-76.47  38.21
-75.66  37.67
-71.31  41.76
-69.44  44.17
-67.69  47.03
-73.18  45.14
-79.26  43.28
-82.84  42.59
-83.49  45.32
-86.36  43.65
-87.75  43.42
-86.01  45.96
-87.00  46.59
-91.39  46.79
-90.05  47.96 

-71.97  41.11
-71.97  41.15 

-80.79  27.03
-81.01  26.99 

-113.01  42.09
-113.10  42.01 

-155.74  20.02
-155.73  19.98 

-156.51  20.78
-156.51  20.78 

-157.12  21.21
-157.08  20.95 

-157.87  21.42 

-159.53  22.07 

-117.44  66.46
-119.59  65.24
-123.95  65.03
-123.69  66.44
-119.21  66.22
-117.44  66.44 

-120.71  64.03
-114.91  62.30
-109.07  62.72
-112.62  61.19
-118.68  61.19
-117.01  61.17
-115.97  62.56
-119.46  64.00
-120.59  63.94 

-112.31  58.46
-108.90  59.44
-104.14  58.90
-102.56  56.72
-101.82  58.73
-104.65  58.91
-111.00  58.51
-112.35  58.62 

-98.74  50.09
-99.75  52.24
-99.62  51.47
-98.82  50.39 

-97.02  50.21
-97.50  54.02
-98.69  52.93
-97.19  51.09
-96.98  50.20 

-95.34  49.04
-92.32  50.34
-94.14  49.47
-95.36  48.82 

-80.39  56.16
-79.22  55.94
-80.34  56.08 

-103.56  58.60
-103.60  58.58 

-101.82  58.03
-102.33  58.10
-101.77  58.06 

-101.88  55.79
-97.92  57.15
-101.22  55.85
-101.88  55.74 

-117.29  32.48
-114.75  27.80
-112.53  24.80
-110.55  24.07
-114.23  29.59
-112.58  29.99
-109.57  25.94
-105.61  21.94
-102.09  17.87
-95.75  15.94
-92.21  14.97 

-88.45  17.42
-87.01  21.33
-91.65  18.72
-96.96  20.37
-97.65  25.67 

-92.22  14.71
-86.74  12.06
-83.03   8.65
-79.93   8.74
-77.17   7.94
-81.99   8.97
-83.92  12.70
-86.33  15.80
-88.40  15.92 

-77.61   6.80
-78.70   0.97
-80.75  -4.47
-76.19 -14.57
-70.44 -18.75
-70.68 -26.15
-71.44 -32.03
-73.38 -37.27
-73.06 -42.11
-73.17 -46.09
-73.52 -48.05
-73.67 -51.56
-71.06 -53.88
-69.14 -50.77
-67.51 -46.59
-63.49 -42.80
-62.14 -40.16
-57.12 -36.71
-53.17 -34.15
-51.26 -32.02
-48.16 -25.48
-40.73 -22.32
-38.88 -15.24
-34.60  -7.81
-41.95  -3.42
-48.02  -1.84
-48.44  -1.57
-50.81   0.00
-54.47   5.39
-60.59   8.32
-64.19   9.88
-70.78  10.64
-70.97  11.89
-76.26   8.76
-77.61   6.80 

-69.14 -52.79
-66.16 -55.08
-70.01 -54.88
-70.55 -53.85
-69.31 -52.81 

-59.29 -51.58
-59.35 -51.54 

-58.65 -51.55
-58.55 -51.56 

-84.39  21.44
-73.90  19.73
-79.27  21.18
-83.74  21.80
-84.32  21.42 

-66.96  17.95
-67.05  17.89 

-77.88  17.22
-78.06  16.98 

-74.47  18.08
-69.88  18.99
-71.10  17.76
-74.45  17.86 

-85.28  73.74
-85.79  70.96
-85.13  71.94
-84.74  72.96
-80.61  73.10
-78.45  72.20
-75.44  72.55
-73.89  71.98
-72.56  71.04
-71.49  70.57
-69.78  70.29
-68.12  69.71
-65.91  69.19
-66.92  68.39
-64.08  67.68
-62.50  66.68
-63.07  65.33
-66.11  66.08
-67.48  65.41
-64.05  63.15
-66.58  63.26
-69.04  62.33
-72.22  63.77
-76.88  64.17
-73.25  65.54
-70.09  66.64
-72.05  67.44
-76.32  68.36
-78.34  70.17
-82.12  69.71
-87.64  70.12
-89.68  71.43
-85.28  73.74 

-80.90  76.10
-84.21  76.28
-88.94  76.38
-85.47  77.40
-85.43  77.93
-87.01  78.54
-83.17  78.94
-84.87  79.93
-81.33  79.82
-76.27  80.92
-82.88  80.62
-82.58  81.16
-86.51  81.05
-89.36  81.21
-90.45  81.38
-89.28  81.86
-87.21  82.30
-80.51  82.05
-80.16  82.55
-77.83  82.86
-75.51  83.05
-71.18  82.90
-65.10  82.78
-63.34  81.80
-68.26  81.26
-69.46  80.34
-71.05  79.82
-74.40  79.46
-75.42  79.03
-75.48  78.92
-76.01  78.20
-80.66  77.28
-78.07  76.98
-80.90  76.13 

-92.86  74.13
-92.50  72.70
-94.89  73.16
-92.96  74.14 

-94.80  76.95
-89.68  76.04
-88.52  75.40
-82.36  75.67
-79.39  74.65
-86.15  74.22
-91.70  74.94
-95.60  76.91
-94.87  76.96 

-99.96  73.74
-97.89  72.90
-98.28  71.13
-102.04  72.92
-101.34  73.14
-99.69  73.59 

-107.58  73.25
-104.59  71.02
-101.71  69.56
-104.07  68.62
-106.61  69.12
-114.09  69.05
-113.89  70.12
-115.88  70.32
-116.10  71.32
-117.45  72.48
-113.53  72.44
-109.84  72.24
-106.62  71.71
-107.43  73.04 

-120.96  74.29
-118.37  72.53
-123.06  71.18
-123.40  73.77
-120.93  74.27 

-108.83  76.74
-106.25  75.54
-107.08  74.78
-112.99  74.16
-112.28  74.99
-116.04  75.33
-115.27  76.20
-110.95  75.56
-109.77  76.31
-108.82  76.70 

-115.70  77.46
-118.10  76.30
-121.13  76.37
-116.04  77.28 

-110.01  77.86
-112.36  77.68
-109.96  77.86 

-109.60  78.48
-112.20  78.01
-109.60  78.48 

-97.87  76.61
-99.21  75.31
-100.86  75.60
-99.40  76.26
-97.79  76.60 

-94.72  75.53
-94.66  75.52 

-104.10  79.01
-99.19  77.54
-103.22  78.08
-104.30  78.95 

-93.74  77.52
-93.74  77.52 

-96.88  78.50
-96.91  77.77
-96.94  78.48 

-84.69  65.84
-81.58  63.87
-85.00  62.96
-84.63  65.71 

-81.84  62.75
-82.01  62.63 

-79.88  62.12
-79.88  62.12 

-43.53  59.89
-45.29  60.67
-47.91  60.83
-49.90  62.41
-50.71  64.42
-51.39  64.94
-52.96  66.09
-53.62  67.19
-53.51  67.51
-51.84  68.65
-52.19  70.00
-51.85  71.03
-55.41  71.41
-54.63  72.97
-56.98  74.70
-61.95  76.09
-66.38  75.83
-71.13  77.00
-66.81  77.60
-70.78  77.78
-64.96  79.70
-63.38  81.16
-56.89  82.17
-48.18  82.15
-42.08  82.74
-38.02  83.54
-23.96  82.94
-25.97  81.97
-25.99  80.64
-13.57  80.97
-16.60  80.16
-19.82  78.82
-18.80  77.54
-21.98  76.46
-20.69  75.12
-21.78  74.40
-24.10  73.69
-26.54  73.08
-24.63  72.69
-21.84  71.69
-24.62  71.24
-27.16  70.89
-27.21  70.00
-24.10  69.35
-28.35  68.43
-32.48  68.56
-35.26  66.26
-37.90  65.90
-40.04  65.00
-40.49  64.04
-42.01  63.14
-42.88  61.15
-43.09  60.07
-43.56  59.90 

-16.26  66.41
-15.32  64.29
-20.14  63.47
-21.76  64.21
-21.33  64.97
-23.04  65.62
-21.76  66.26
-18.77  66.12
-16.23  66.35 

  0.56  51.47
 -1.71  54.94
 -3.41  57.52
 -5.42  58.14
 -5.77  55.59
 -3.48  54.82
 -4.68  52.88
 -2.68  51.58
 -3.80  50.08
  1.26  51.14
  0.65  51.41 

 -7.17  54.91
 -9.97  53.47
 -8.52  51.76
 -5.69  54.79
 -7.34  55.25 

 -1.33  60.66
 -1.17  60.38 

 -6.18  58.44
 -6.09  58.36 

 -6.47  57.58
 -6.33  57.54 

 -7.30  57.54 

 -7.46  57.05 

 -6.54  56.94 

 -6.00  55.94 

 -5.09  55.55 

 -4.44  54.38
 -4.30  54.19 

 -8.08  71.02
 -8.21  70.86 

 16.92  79.52
 22.26  78.46
 16.86  76.41
 16.00  77.39
 16.03  77.92
 16.81  79.50 

 14.71  79.40
 16.05  79.12
 14.02  77.80
 13.56  78.46
 12.63  79.26
 14.68  79.40 

 22.01  78.24
 21.86  78.23 

 21.54  77.75
 23.88  77.26
 21.53  77.67
 22.79  77.79 

 23.50  79.97
 28.24  79.54
 20.85  78.94
 19.00  79.34
 21.05  79.88
 23.41  79.96 

 46.98  80.23
 43.13  79.97
 47.18  80.22

 50.43  80.19
 50.55  79.88
 47.77  79.86
 50.45  80.14

 61.79  80.18
 61.79  80.18

 65.08  80.69
 64.27  80.59
 65.13  80.68

 -5.13  35.66
  4.06  36.63
 10.40  37.12
 11.36  33.61
 20.10  30.10
 23.49  32.17
 31.65  30.80
 35.76  23.74
 39.75  14.82
 42.93  11.34
 51.52  11.45
 49.82   6.99
 43.13  -0.62
 39.15  -7.58
 40.37 -13.20
 37.74 -18.17
 35.33 -22.71
 32.84 -28.15
 26.50 -34.39
 19.55 -35.51
 17.50 -30.88
 12.24 -18.75
 13.89 -12.81
 12.05  -5.55
  9.67   0.14
  7.19   3.79
  1.74   5.39
 -4.77   4.59
-12.00   6.75
-15.54  10.98
-16.33  15.50
-16.10  22.29
-12.90  27.12
 -9.52  31.09
 -5.41  35.58

 33.71   0.00
 33.48  -3.42
 33.34  -0.20
 33.71   0.00

 49.30 -12.50
 49.28 -18.79
 43.95 -25.50
 44.37 -20.08
 46.34 -16.31
 47.91 -14.08
 49.30 -12.50

 32.18  30.58
 36.08  35.03
 32.53  36.17
 27.77  36.94
 26.51  39.18
 31.54  40.82
 38.53  40.48
 40.35  43.17
 39.88  46.45
 35.18  44.99
 33.50  44.96
 30.24  45.14
 28.70  41.48
 26.55  39.84
 23.62  39.67
 23.80  37.34
 21.90  36.92
 18.79  42.02
 14.52  44.31
 14.58  42.25
 18.32  39.57
 16.05  39.35
 11.52  42.36
  6.87  43.08
  2.80  41.09
 -1.11  37.14
 -6.24  36.70
 -8.67  39.57
 -6.51  43.13
 -0.84  45.55
 -3.93  48.40
  0.48  49.09
  4.20  51.29
  6.44  52.92
  8.42  55.94
 11.72  55.49
 11.73  53.66
 16.78  54.14
 21.40  56.32
 24.67  57.20
 28.94  59.18
 24.16  59.52
 22.07  62.66
 23.76  65.35
 18.70  62.54
 19.11  59.67
 18.40  58.54
 15.34  55.73
 11.74  58.08
  8.37  57.68
  5.80  59.20
  7.38  60.86
  7.51  61.86
  9.62  62.99
 13.37  65.46
 15.46  67.12
 18.54  68.62
 22.32  69.64
 24.77  70.17
 25.93  69.79
 28.56  70.46
 29.75  69.76
 33.83  69.11
 41.90  66.85
 35.14  66.25
 33.30  66.07
 35.46  64.15
 37.68  64.03
 41.71  64.09
 44.80  65.58
 44.87  68.16
 45.92  66.83
 51.79  67.85
 53.70  67.89
 59.68  68.09
 65.07  69.08
 68.56  69.19
 68.38  70.97
 73.03  71.62
 73.80  68.29
 69.42  66.45
 73.43  66.36
 77.51  68.36
 80.74  66.74
 75.27  68.67
 75.11  71.80
 78.62  70.56
 78.43  71.90
 82.72  71.23
 84.25  70.03
 81.40  72.76
 86.50  74.01
 87.68  74.78
 90.25  75.23

 68.33  76.71
 66.03  75.62
 59.10  74.11
 54.92  73.03
 56.67  74.10
 58.56  75.09
 63.86  75.87
 68.19  76.70

 53.04  72.57
 58.29  70.39
 55.03  70.78
 53.44  72.26
 53.63  72.61

 90.06  21.03
 82.06  15.95
 80.05  11.72
 76.41   8.60
 72.79  17.43
 72.02  20.00
 68.98  21.99
 64.62  24.41
 57.83  24.77
 53.11  26.20
 49.67  29.41
 50.96  25.15
 54.33  23.44
 59.03  22.57
 57.87  18.86
 52.95  15.74
 47.26  12.96
 42.75  14.68
 39.93  19.61
 36.92  25.78
 33.30  28.46
 32.60  30.63

 52.22  46.50
 51.73  44.73
 52.56  41.80
 53.43  40.40
 54.22  37.86
 49.04  38.45
 48.17  42.76
 49.33  45.64
 52.22  46.50

 62.32  46.32
 60.32  43.06
 59.57  45.58
 61.94  46.33

 79.55  46.12
 74.30  44.44
 78.62  45.79
 79.66  46.07

 76.81  41.96
 76.73  41.86

 35.15  35.15
 34.61  34.84
 35.18  35.17

 23.84  35.33
 24.30  34.91
 24.09  35.39

 15.54  37.89
 13.47  37.89
 15.54  37.89

  9.56  40.95
  8.46  39.99
  9.12  40.69

  9.72  42.60
  9.54  42.35

 80.60   8.95
 79.73   5.96
 80.10   8.30

 11.04  57.44
 10.67  57.25

-77.92  24.67
-77.98  24.22

-77.61  23.62
-77.18  23.64

-75.55  24.13
-75.41  24.31

-91.40  -0.17
-91.52  -0.26

-60.25  46.68
-60.71  46.33

-63.89  49.47
-63.45  49.43

142.53 -10.60
145.62 -16.34
149.79 -22.09
153.21 -26.82
150.52 -35.19
145.60 -38.53
140.13 -37.69
137.34 -34.77
135.76 -34.56
131.50 -31.34
121.72 -33.65
115.62 -33.25
114.09 -26.01
114.88 -21.27
122.34 -18.13
125.32 -14.53
128.39 -14.90
132.35 -11.42
136.16 -12.43
138.07 -16.45
142.25 -10.78

144.72 -40.68
148.32 -42.14
145.57 -42.77
146.47 -41.19

172.86 -34.23
176.10 -37.52
177.06 -39.49
174.77 -38.03
172.83 -34.27

172.36 -40.53
172.92 -43.81
168.41 -46.13
170.26 -43.21
173.69 -40.94

150.74 -10.18
143.04  -8.26
138.48  -6.97
131.95  -2.94
130.91  -1.35
134.38  -2.64
141.24  -2.62
148.19  -8.15
150.75 -10.27

117.24   7.01
117.90   0.76
113.89  -3.50
109.44  -0.82
113.13   3.38
117.24   7.01

 95.31   5.75
102.32   1.40
106.03  -2.98
101.46  -2.81
 95.20   5.73

140.91  41.53
140.79  35.75
136.82  34.56
133.56  34.72
132.49  35.41
136.73  37.20
139.82  40.00
140.68  41.43

133.71  34.30
131.41  31.58
129.38  33.10
133.90  34.37

141.89  45.50
144.12  42.92
140.30  41.64
141.53  45.30
141.89  45.53

142.57  54.36
143.64  49.19
141.99  45.88
141.92  50.85
142.60  54.34

121.92  25.48
120.53  24.70
121.70  25.51

110.81  20.07
109.20  19.66
110.81  20.07

106.51  -6.16
114.15  -7.72
108.71  -7.89
106.51  -6.16

164.27 -20.01
164.16 -20.27

178.61 -17.04
178.61 -17.04

179.45 -16.43
179.35 -16.43

-172.55 -13.39
-172.61 -13.78

122.26  18.67
123.05  13.86
120.73  13.80
120.43  16.43
121.72  18.40

125.34   9.79
125.56   6.28
122.38   7.00
125.10   9.38

119.64  11.35
118.81  10.16
119.59  10.86

 90.05  21.74
 94.21  17.79
 97.66  15.36
 98.21   9.17
103.22   1.56
100.26   8.30
100.01  13.52
104.39  10.37
107.32  10.45
107.55  16.34
108.53  21.73
112.69  21.81
118.83  24.93
121.28  30.25
120.73  32.65
121.77  36.90
117.58  38.21
121.62  40.15
125.12  39.08
126.15  35.18
128.33  38.46
129.92  42.04
138.77  47.30
140.72  52.43
137.10  54.07
140.77  58.39
148.57  59.46
153.83  59.10
156.81  61.68
159.90  60.73
163.79  61.73
156.40  57.76
156.42  51.09
161.82  54.88
162.92  57.34
164.48  59.89
170.42  60.17
177.46  62.62
178.20  64.29
179.48  64.88

-179.87  65.14
-177.13  65.63
-173.46  64.74
-171.13  66.38
-176.48  67.78
-178.80  68.42

178.88  69.10
170.20  69.99
167.68  69.63
159.92  70.14
150.77  71.28
146.92  72.21
146.04  72.39
139.60  72.23
135.49  71.51
130.53  70.86
126.10  72.24
128.94  73.02
123.10  73.28
113.34  73.37
110.43  73.71
107.88  73.72
112.99  75.60
106.34  76.40
104.10  77.52
 99.69  76.09
 95.12  75.95
 89.68  75.57

101.96  79.08
101.31  77.86
101.22  79.04

 94.29  79.29
100.02  79.43
 95.31  78.68
 95.44  79.65
 97.26  79.62

 95.46  80.62
 92.39  79.66
 95.07  80.54

 91.39  79.62
 91.33  79.62

138.54  76.05
144.93  75.45
140.30  74.99
137.27  75.44
138.29  75.98

146.08  75.29
147.75  74.73
145.85  75.06

141.44  73.88
141.48  73.84

  0.01 -71.68
  6.57 -70.57
 15.04 -70.44
 25.10 -70.75
 33.37 -69.10
 38.46 -69.77
 42.85 -68.16
 46.59 -67.23
 49.35 -66.96
 52.90 -65.97
 58.46 -67.20
 63.60 -67.58
 70.63 -68.41
 69.24 -70.36
 76.20 -69.44
 88.08 -66.64
 94.98 -66.52
101.53 -66.09
111.31 -65.91
118.64 -66.87
126.24 -66.24
133.09 -66.18
139.85 -66.72
146.86 -67.96
153.65 -68.82
159.94 -69.57
164.10 -70.67
170.19 -71.94
165.68 -74.64
163.82 -77.60
162.10 -78.95
166.72 -82.84
175.58 -83.86

-178.56 -84.37
-147.96 -85.40
-152.96 -81.12
-153.95 -79.50
-151.24 -77.48
-146.74 -76.44
-137.68 -75.16
-131.63 -74.63
-123.05 -74.41
-114.76 -73.97
-111.91 -75.41
-105.05 -74.77
-100.90 -74.21
-101.04 -73.18
-100.28 -73.06
-93.06 -73.33
-85.40 -73.18
-79.82 -73.04
-78.21 -72.52
-71.90 -73.41
-67.51 -71.10
-67.57 -68.92
-66.65 -66.83
-64.30 -65.28
-59.14 -63.74
-59.58 -64.37
-62.50 -65.94
-62.48 -66.66
-65.64 -68.02
-63.85 -69.07
-61.69 -70.87
-60.89 -72.71
-61.07 -74.30
-63.33 -75.88
-76.05 -77.06
-83.04 -77.12
-74.30 -80.83
-56.40 -82.14
-42.46 -81.65
-31.60 -80.17
-34.01 -79.20
-32.48 -77.28
-26.28 -76.18
-17.18 -73.45
-11.20 -72.01
 -8.67 -71.98
 -5.45 -71.45
 -0.82 -71.74
  0.07 -71.68

164.65 -77.89
170.95 -77.37
179.67 -78.25

-178.74 -78.24
-165.76 -78.47
-158.42 -77.73

-58.98 -64.63
-60.99 -68.62
-61.02 -71.70

-62.01 -74.94
-52.00 -77.07
-42.23 -77.80
-36.22 -78.03

-35.03 -77.81
-26.13 -75.54
-19.35 -73.04
-12.16 -71.86
 -6.15 -70.65
 -0.57 -69.14
  4.93 -70.25
 10.91 -69.99
 16.52 -69.87
 25.41 -70.22
 32.13 -69.29
 33.62 -69.58

 70.56 -68.53
 73.91 -69.51

 81.42 -67.87
 84.67 -66.41
 89.07 -66.73

-135.79 -74.67
-124.34 -73.22
-116.65 -74.08
-109.93 -74.64
-105.36 -74.56
-105.83 -74.77

-69.30 -70.06
-71.33 -72.68
-71.42 -71.85
-75.10 -71.46
-71.79 -70.55
-70.34 -69.26
-69.34 -70.13

-49.20 -77.83
-44.59 -78.79
-44.14 -80.13
-59.04 -79.95
-49.28 -77.84
-48.24 -77.81

-58.13 -80.12
-63.25 -80.20
-58.32 -80.12

-163.64 -78.74
-161.20 -79.93
-163.62 -78.74

 66.82  66.82
 66.82  66.82

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/demo/world.demo version [6a2b0a7c34].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# $Id: world.demo,v 3.26 92/03/24 22:32:31 woo Exp Locker: woo $
#
set title "Gnuplot Correspondences"
set nokey
set noborder
set noyzeroaxis
set noxtics
set noytics
#
# plot world map and correspondent locations as a +
plot 'world.dat' with lines 3 4, 'world.cor' with points 1 2
set title ""
set key
set border
set yzeroaxis
set xtics
set ytics
pause -1 "Hit return to continue"
#
# plot a '3D version using spherical coordinate system' of the world.
set angles degrees
set title "3D version using spherical coordinate system"
set view 70,40,,2.0
set mapping spherical
set parametric
set samples 32
set isosamples 9
set urange [-pi/2:pi/2]
set vrange [0:2*pi]
splot 'world.dat' with lines 3 4, 'world.cor' with points 1 2, cos(u)*cos(v),cos(u)*sin(v),sin(u) with lines 5 6
pause -1 "Hit return to continue"
#
# plot a '3D version using cylindrical coordinate system' of the world.
set title "3D version using cylindrical coordinate system"
set view 70,40,,2.0
set mapping cylindrical
set parametric
set samples 32
set isosamples 9
set urange [-pi:pi]
set vrange [-90:90]
splot 'world.dat' with lines 3 4, 'world.cor' with points 1 2, cos(u),sin(u),v with lines 5 6
pause -1 "Hit return to continue"


#
# Clean up:
#
set noparametric
set mapping cartesian
set angles radians
set samples 100
set isosamples 10
set view 60,30,1,1
set xrange [-10:10]
set yrange [-10:10]
set zrange [-10:10]
set auto
set title "" 0,0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































Deleted r34.1/plot/docs/Makefile version [60c2b500a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# $Id: Makefile,v 3.26 1992/03/25 04:53:29 woo Exp woo $
#
# Makefile for GNUPLOT documentation
#
# Note that the top-level file for documentation is gnuplot.doc.
# See README.
#
# To print manual:
#    make gnuplot.dvi             (for latex)
#    (print or view gnuplot.dvi)
# OR
#    make gnuplot.nroff           (for nroff)
#    (print or view gnuplot.nroff)
#   or
#    make "TROFF=itroff" troff    (for troff; use your troff here)
#
# $Id: Makefile,v 3.26 1992/03/25 04:53:29 woo Exp woo $

# usually overridden by ../Makefile
HELPDEST = /usr/local/lib/

# substitute your troff command (and any flags) for this one
TROFF=troff
  
# substitute cp if you do not have the install program
INSTALL=install

# Compiler flags
# -DSYSV if att sys V
# -DMSDOS if MSDOS PS
# -traditional -g -O if gcc (set 'CC = gcc')
# no extra flags for BSD
CFLAGS = -s
CC = cc

# default is what is needed for interactive gnuplot
default: gnuplot.hlp gnuplot.gih

### [tn]roff documentation
troff: gnuplot.ms titlepage.ms
	tbl gnuplot.ms | eqn | $(TROFF) -ms

nroff gnuplot.nroff: gnuplot.ms titlepage.ms
	tbl gnuplot.ms | neqn | nroff -ms | col > gnuplot.nroff

ms gnuplot.ms: doc2ms gnuplot.doc
	./doc2ms < gnuplot.doc > gnuplot.ms

doc2ms: doc2ms.c
	$(CC) $(CFLAGS) -o doc2ms doc2ms.c

### LaTeX documentation
tex gnuplot.tex: doc2tex gnuplot.doc
	./doc2tex < gnuplot.doc > gnuplot.tex

dvi gnuplot.dvi: gnuplot.tex titlepage.tex
	(latex gnuplot.tex ; latex gnuplot.tex)

doc2tex: doc2tex.c
	$(CC) $(CFLAGS) -o doc2tex doc2tex.c

# this is how to make gnuplot.hlp
hlp gnuplot.hlp: doc2hlp gnuplot.doc
	./doc2hlp < gnuplot.doc > gnuplot.hlp

doc2hlp: doc2hlp.c
	$(CC) $(CFLAGS) -o doc2hlp doc2hlp.c

# this is how to make gnuplot.gih
gih gnuplot.gih: doc2gih gnuplot.doc
	./doc2gih < gnuplot.doc > gnuplot.gih

doc2gih: doc2gih.c
	$(CC) $(CFLAGS) -o doc2gih doc2gih.c

# this is how to check the gnuplot.doc file
check: checkdoc gnuplot.doc
	./checkdoc < gnuplot.doc

checkdoc: checkdoc.c
	$(CC) $(CFLAGS) -o checkdoc checkdoc.c

# For Unix and MSDOS only
install-unix: gnuplot.gih
	$(INSTALL) gnuplot.gih $(HELPDEST)

# for VMS only
install-vms: gnuplot.hlp
	$(INSTALL) gnuplot.hlp $(HELPDEST)

# remove all derived files
clean:
	rm -f doc2ms gnuplot.nroff gnuplot.ms
	rm -f doc2tex gnuplot.tex gnuplot.dvi gnuplot.aux gnuplot.log gnuplot.toc
	rm -f doc2hlp gnuplot.hlp
	rm -f doc2gih gnuplot.gih
	rm -f checkdoc *~ *.o core a.out
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































Deleted r34.1/plot/docs/Makefile.ami version [542d886298].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# $Id: Makefile.ami,v 3.26 1992/03/25 04:53:29 woo Exp woo $
#
# Makefile for GNUPLOT documentation (Aztec C v5.xx Version)
#
# Note that the top-level file for documentation is gnuplot.doc.
# See README.
#
# To print manual:
#    make gnuplot.dvi             (for latex)
#    (print or view gnuplot.dvi)
# OR
#    make gnuplot.nroff           (for nroff)
#    (print or view gnuplot.nroff)
#   or
#    make "TROFF=itroff" troff    (for troff; use your troff for itroff here)
#
# $Id: Makefile.ami,v 3.26 1992/03/25 04:53:29 woo Exp woo $

# usually overridden by ../Makefile
HELPDEST = /usr/local/lib/

# substitute your troff command (and any flags) for this one
TROFF=itroff
  
# substitute cp if you do not have the install program
INSTALL=install

# Compiler flags
# -DSYSV if att sys V
# -DMSDOS if MSDOS PS
# -traditional -g -O if gcc (set 'CC = gcc')
# no extra flags for BSD
CFLAGS = 
CC = cc
LN =ln
LFLAGS = -lm -lc

# default is what is needed for interactive gnuplot
default: gnuplot.hlp gnuplot.gih

### [tn]roff documentation
troff: gnuplot.ms titlepage.ms
	tbl gnuplot.ms | eqn | $(TROFF) -ms

# for screen viewing, or printers with backspace/overstrike, remove the -Tlpr
nroff gnuplot.nroff: gnuplot.ms titlepage.ms
	tbl gnuplot.ms | neqn | nroff -ms -Tlpr > gnuplot.nroff

ms gnuplot.ms: doc2ms gnuplot.doc
	doc2ms < gnuplot.doc > gnuplot.ms

doc2ms: doc2ms.c
	$(CC) $(CFLAGS) -o doc2ms.o doc2ms.c
	$(LN) -o doc2ms doc2ms.o $(LFLAGS)

### LaTeX documentation
tex gnuplot.tex: doc2tex gnuplot.doc
	doc2tex < gnuplot.doc > gnuplot.tex

dvi gnuplot.dvi: gnuplot.tex titlepage.tex
	latex gnuplot.tex
	latex gnuplot.tex

doc2tex: doc2tex.c
	$(CC) $(CFLAGS) -o doc2tex.o doc2tex.c
	$(LN) -o doc2tex doc2tex.o $(LFLAGS)

# this is how to make gnuplot.hlp
hlp gnuplot.hlp: doc2hlp gnuplot.doc
	doc2hlp < gnuplot.doc > gnuplot.hlp

doc2hlp: doc2hlp.c
	$(CC) $(CFLAGS) -o doc2hlp.o doc2hlp.c
	$(LN) -o doc2hlp doc2hlp.o $(LFLAGS)

# this is how to make gnuplot.gih
gih gnuplot.gih: doc2gih gnuplot.doc
	doc2gih < gnuplot.doc > gnuplot.gih

doc2gih: doc2gih.c
	$(CC) $(CFLAGS) -o doc2gih.o doc2gih.c
	$(LN) -o doc2gih doc2gih.o $(LFLAGS)

# this is how to check the gnuplot.doc file
check: checkdoc gnuplot.doc
	checkdoc < gnuplot.doc

checkdoc: checkdoc.c
	$(CC) $(CFLAGS) -o checkdoc.o checkdoc.c
	$(LN) -o checkdoc checkdoc.o $(LFLAGS)

# For Unix and MSDOS only
install-unix: gnuplot.gih
	$(INSTALL) gnuplot.gih $(HELPDEST)

# for VMS only
install-vms: gnuplot.hlp
	$(INSTALL) gnuplot.hlp $(HELPDEST)

# remove all derived files
clean:
	rm -f doc2ms gnuplot.nroff gnuplot.ms
	rm -f doc2tex gnuplot.tex gnuplot.dvi gnuplot.aux gnuplot.log gnuplot.toc
	rm -f doc2hlp gnuplot.hlp
	rm -f doc2gih gnuplot.gih
	rm -f checkdoc *~ *.o core a.out
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































Deleted r34.1/plot/docs/README version [c366f3b11b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Notes on the gnuplot help files and documentation.

Gnuplot documentation is available in three ways:

1 - interactively, within gnuplot
2 - as a printed document. 
3 - as a manual page, through the Unix man(1) facility

The first two forms describe the inner workings, and contain
equivalent information, while the third form tells how to run gnuplot.

The two first forms above derive their information from the file
gnuplot.doc, which is the MASTER copy of gnuplot help information. All
other forms, except for gnuplot.1, the man page, are derived from it. 

gnuplot.doc -> gnuplot.hlp 
            -> gnuplot.gih
            -> gnuplot.tex
            -> gnuplot.ms
    	   	  	 	    		
On VMS the interactive help is supplied by the system help facility,
using the gnuplot.hlp file. This is made with ('make hlp').  On Unix,
AmigaDOS, and MSDOS the interactive help is built in to the program,
and uses the gnuplot.gih file ('make gih').

The printed document is available in either latex or troff/nroff (ms)
format, using gnuplot.tex or gnuplot.ms, derived from gnuplot.doc with
either doc2tex or doc2ms. Type 'make dvi' or 'make nroff'. For troff,
type 'make ms' and then troff -ms gnuplot.ms in whatever way you use
troff.

If VMS users prefer the gnuplot interactive help facility to the
system facility, this can be easily changed in command.c.


Description of the gnuplot.doc format:
--------------------------------------

Here is an example of the DOC master help format:

?
1 gnuplot
 GNUPLOT is a command-driven interactive function plotting program.  It
 ...
?exit
2 exit
 'exit', 'quit' and ...
?expressions
2 expressions
 In general, any mathematical expression accepted by C, ...

 Topics:
 functions operators
?expressions functions
?functions
3 functions
 The functions in GNUPLOT are ...

 Topics:
 abs acos arg ...
?expressions functions abs
?functions abs
?abs
4 abs
 This function returns the absolute value of its argument.  The
 returned value is of the same type as the argument. 
?expressions functions acos
?functions acos
?acos
4 acos
 This function returns the arc cosine (inverse cosine) of its
 argument.  'acos' returns its argument in radians. 


Some notes about the format:
----------------------------
Remember that all text must be able to be processed by gnuplot, VMS,
 nroff, troff, and latex, and always do something reasonable. 
The first column is reserved for control characters.
Text does not start in the first column.
Lines that start in column 2 may be typeset by LaTeX.
Lines that have a space in column 2 are to be printed in a verbatim
 environment by LaTeX.
Do NOT use tabs in the help file.
Conversion from this format to vax .hlp file involves removal of
 lines starting with [?@#$%] (see doc2hlp). VMS uses the numbers
 to represent a tree. 
Conversion from this format to gnuplot .gih file involves removal of
 lines starting with [0-9@#$%] (see doc2gih). Gnuplot matches your
 help query against the ? lines to find the help information.
 Multiple ? lines for one text block constitute synonyms. The most
 specific should be first, eg 'expressions functions' before 'functions'.
 Spaces are allowed here, but should be single.
Backquote pairs are converted by the doc2tex program into boldface;
 that is, `some text` is converted to {\bf some text}. Be sure to pair
 the backquotes, or the whole document will be boldface!

Control characters in first column:
?    used by .gih format, for builtin interactive help - keyword
0-9  used by VMS help and by doc2{tex,ms} formatters to define level,keyword
@    used by doc2{tex,ms} to define table start/end
#    used by doc2tex: table entry
%    used by doc2ms: table entry
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































Deleted r34.1/plot/docs/checkdoc.c version [644c0fa163].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef lint
static char *RCSid = "$Id: checkdoc.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
#endif

/*
 * checkdoc -- check a doc file for correctness of first column. 
 *
 * Prints out lines that have an illegal first character.
 * First character must be space, digit, or ?, @, #, %, 
 * or line must be empty.
 *
 * usage: checkdoc < docfile
 * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
 *
 * Original version by David Kotz used the following one line script!
 * sed -e '/^$/d' -e '/^[ 0-9?@#%]/d' gnuplot.doc
 *
 */

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

#define MAX_LINE_LEN	256
#define TRUE 1
#define FALSE 0

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

convert(a,b)
	FILE *a,*b;
{
    static char line[MAX_LINE_LEN];

    while (fgets(line,MAX_LINE_LEN,a)) {
	   process_line(line, b);
    }
}

process_line(line, b)
	char *line;
	FILE *b;
{
    switch(line[0]) {		/* control character */
	   case '?': {			/* interactive help entry */
		  break;			/* ignore */
	   }
	   case '@': {			/* start/end table */
		  break;			/* ignore */
	   }
	   case '#': {			/* latex table entry */
		  break;			/* ignore */
	   }
	   case '%': {			/* troff table entry */
		  break;			/* ignore */
	   }
	   case '\n':			/* empty text line */
	   case ' ': {			/* normal text line */
		  break;
	   }
	   default: {
		  if (isdigit(line[0])) { /* start of section */
		  		/* ignore */
		  } else
			fputs(line,b);    /* output bad line */
		  break;
	   }
    }
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































Deleted r34.1/plot/docs/doc2gih version [705eac0100].

cannot compute difference between binary files

Deleted r34.1/plot/docs/doc2gih.c version [62377ad68c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef lint
static char *RCSid = "$Id: doc2gih.c,v 3.26 92/03/25 04:53:29 woo Exp Locker: woo $";
#endif

/*
 * doc2gih.c  -- program to convert Gnuplot .DOC format to gnuplot
 * interactive help (.GIH) format.
 *
 * This involves stripping all lines with a leading digit or
 * a leading @, #, or %.
 * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
 *
 * usage:  doc2gih < file.doc > file.gih
 *
 * Original version by David Kotz used the following one line script!
 * sed '/^[0-9@#%]/d' file.doc > file.gih
 */

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

#define MAX_LINE_LEN	256
#define TRUE 1
#define FALSE 0

main(argc,argv)
int argc;
char **argv;
{
FILE * infile;
FILE * outfile;
	infile = stdin;
	outfile = stdout;
	if (argc > 3) {
		fprintf(stderr,"Usage: %s infile outfile\n", argv[0]);
		exit(1);
	}
	if (argc >= 2) 
		if ( (infile = fopen(argv[1],"r")) == (FILE *)NULL) {
			fprintf(stderr,"%s: Can't open %s for reading\n",
				argv[0], argv[1]);
			exit(1);
		}
	if (argc == 3)
		if ( (outfile = fopen(argv[2],"w")) == (FILE *)NULL) {
			fprintf(stderr,"%s: Can't open %s for writing\n",
				argv[0], argv[2]);
		}
	
	convert(infile,outfile);
	exit(0);
}


convert(a,b)
	FILE *a,*b;
{
    static char line[MAX_LINE_LEN];

    while (fgets(line,MAX_LINE_LEN,a)) {
	   process_line(line, b);
    }
}

process_line(line, b)
	char *line;
	FILE *b;
{
    static int line_count = 0;

    line_count++;

    switch(line[0]) {		/* control character */
	   case '?': {			/* interactive help entry */
		  (void) fputs(line,b); 
		  break;		
	   }
	   case '@': {			/* start/end table */
		  break;			/* ignore */
	   }
	   case '#': {			/* latex table entry */
		  break;			/* ignore */
	   }
	   case '%': {			/* troff table entry */
		  break;			/* ignore */
	   }
	   case '\n':			/* empty text line */
	   case ' ': {			/* normal text line */
		  (void) fputs(line,b); 
		  break;
	   }
	   default: {
		  if (isdigit(line[0])) { /* start of section */
		  		/* ignore */
		  } else
		    fprintf(stderr, "unknown control code '%c' in column 1, line %d\n",
			    line[0], line_count);
		  break;
	   }
    }
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































Deleted r34.1/plot/docs/doc2hlp version [d4bb435422].

cannot compute difference between binary files

Deleted r34.1/plot/docs/doc2hlp.c version [208895ee16].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef lint
static char *RCSid = "$Id: doc2hlp.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
#endif

/*
 * doc2hlp.c  -- program to convert Gnuplot .DOC format to 
 * VMS help (.HLP) format.
 *
 * This involves stripping all lines with a leading ?,
 * @, #, or %.
 * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
 *
 * usage:  doc2hlp < file.doc > file.hlp
 *
 * Original version by David Kotz used the following one line script!
 * sed '/^[?@#%]/d' file.doc > file.hlp
 */

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

#define MAX_LINE_LEN	256
#define TRUE 1
#define FALSE 0

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


convert(a,b)
	FILE *a,*b;
{
    static char line[MAX_LINE_LEN];

    while (fgets(line,MAX_LINE_LEN,a)) {
	   process_line(line, b);
    }
}

process_line(line, b)
	char *line;
	FILE *b;
{
    static int line_count = 0;

    line_count++;

    switch(line[0]) {		/* control character */
	   case '?': {			/* interactive help entry */
		  break;			/* ignore */
	   }
	   case '@': {			/* start/end table */
		  break;			/* ignore */
	   }
	   case '#': {			/* latex table entry */
		  break;			/* ignore */
	   }
	   case '%': {			/* troff table entry */
		  break;			/* ignore */
	   }
	   case '\n':			/* empty text line */
	   case ' ': {			/* normal text line */
		  (void) fputs(line,b); 
		  break;
	   }
	   default: {
		  if (isdigit(line[0])) { /* start of section */
			(void) fputs(line,b); 
		  } else
		    fprintf(stderr, "unknown control code '%c' in column 1, line %d\n", 
				  line[0], line_count);
		  break;
	   }
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































Deleted r34.1/plot/docs/doc2hlp.com version [4ce9625fe6].

1
2
3
$ def/user sys$input [.docs]gnuplot.doc
$ def/user sys$output []gnuplot.hlp
$ run doc2hlp
<
<
<






Deleted r34.1/plot/docs/doc2ms.c version [eb541958c0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#ifndef lint
static char *RCSid = "$Id: doc2ms.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
#endif

/*
 * doc2ms.c  -- program to convert Gnuplot .DOC format to *roff -ms document
 * From hlp2ms by Thomas Williams 
 *
 * Modified by Russell Lang, 2nd October 1989
 * to make vms help level 1 and 2 create the same ms section level.
 *
 * Modified to become doc2ms by David Kotz (David.Kotz@Dartmouth.edu) 12/89
 * Added table and backquote support.
 *
 * usage:  doc2ms < file.doc > file.ms
 *
 *   where file.doc is a VMS .DOC file, and file.ms will be a [nt]roff
 *     document suitable for printing with nroff -ms or troff -ms
 *
 * typical usage for GNUPLOT:
 *
 *   doc2ms < gnuplot.doc | troff -ms
 */

static char rcsid[] = "$Id: doc2ms.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";

#include <stdio.h>
#include <ctype.h>
#ifdef AMIGA_LC_5_1
#include <string.h>
#endif

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

#define TRUE 1
#define FALSE 0

typedef int boolean;

static boolean intable = FALSE;

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.ms\n",b);
    (void) fputs(".pn 1\n",b);
    (void) fputs(".bp\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);
    /* following line commented out by rjl
	  (void) fputs(".so intro\n",b);
	  */
}


convert(a,b)
	FILE *a,*b;
{
    static char line[MAX_LINE_LEN];

    while (fgets(line,MAX_LINE_LEN,a)) {
	   process_line(line, b);
    }
}

process_line(line, b)
	char *line;
	FILE *b;
{
    switch(line[0]) {		/* control character */
	   case '?': {			/* interactive help entry */
		  break;			/* ignore */
	   }
	   case '@': {			/* start/end table */
		  if (intable) {
			 (void) fputs(".TE\n.KE\n", b);
			 (void) fputs(".EQ\ndelim off\n.EN\n\n",b);
			 intable = FALSE;
		  } else {
			 (void) fputs("\n.EQ\ndelim $$\n.EN\n",b);
			 (void) fputs(".KS\n.TS\ncenter box tab (@) ;\n", b);
			 (void) fputs("c c l .\n", b);
			 intable = TRUE;
		  }
		  /* ignore rest of line */
		  break;
	   }
	   case '#': {			/* latex table entry */
		  break;			/* ignore */
	   }
	   case '%': {			/* troff table entry */
		  if (intable)
		    (void) fputs(line+1, b); /* copy directly */
		  else
		    fprintf(stderr, "error: % line found outside of table\n");
		  break;
	   }
	   case '\n':			/* empty text line */
	   case ' ': {			/* normal text line */
		  if (intable)
		    break;		/* ignore while in table */
		  switch(line[1]) {
			 case ' ': {
				/* verbatim mode */
				fputs(".br\n",b); 
				fputs(line+1,b); 
				fputs(".br\n",b);
				break;
			 }
			 case '\'': {
				fputs("\\&",b);
				putms(line+1,b); 
				break;
			 }
			 default: {
				if (line[0] == '\n')
				  putms(line,b); /* handle totally blank line */
				else
				  putms(line+1,b);
				break;
			 }
			 break;
		  }
		  break;
	   }
	   default: {
		  if (isdigit(line[0])) { /* start of section */
			 if (!intable)	/* ignore while in table */
			   section(line, b);
		  } else
		    fprintf(stderr, "unknown control code '%c' in column 1\n", 
				  line[0]);
		  break;
	   }
    }
}


/* process a line with a digit control char */
/* starts a new [sub]section */

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

  
#ifdef AMIGA_LC_5_1
    (void) sscanf(line,"%d",&sh_i);
    strcpy(string,strchr(line,' ')+1);
    {
      char *p;
      p = strchr(string,'\n');
      if (p != NULL) *p = '\0';
    }
#else
    (void) sscanf(line,"%d %[^\n]s",&sh_i,string);
#endif
    
    (void) fprintf(b,".sp %d\n",(sh_i == 1) ? LINE_SKIP : LINE_SKIP-1);
    
    if (sh_i > old) {
	   do
		if (old!=1)	/* this line added by rjl */
		  (void) fputs(".RS\n.IP\n",b);
	   while (++old < sh_i);
    }
    else if (sh_i < old) {
	   do
			   if (sh_i!=1) /* this line added by rjl */
				(void) fputs(".RE\n.br\n",b);
	   while (--old > sh_i);
    }
    
    /* added by dfk to capitalize section headers */
    if (islower(string[0]))
	 string[0] = toupper(string[0]);
    
    /* next 3 lines added by rjl */
    if (sh_i!=1) 
	 (void) fprintf(b,".NH %d\n%s\n.sp 1\n.LP\n",sh_i-1,string);
    else 
	 (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);
}

putms(s, file)
	char *s;
	FILE *file;
{
    static boolean inquote = FALSE;

    while (*s != '\0') {
	   switch (*s) {
		  case '`': {		/* backquote -> boldface */
			 if (inquote) {
				fputs("\\fR", file);
				inquote = FALSE;
			 } else {
				fputs("\\fB", file);
				inquote = TRUE;
			 }
			 break;
		  }
		  case '\\': {		/* backslash */
			 fputs("\\\\", file);
			 break;
		  }
		  default: {
			 fputc(*s, file);
			 break;
		  }
	   }
	   s++;
    }
}

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);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/doc2tex version [56f0bb4de7].

cannot compute difference between binary files

Deleted r34.1/plot/docs/doc2tex.c version [cad09ead23].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#ifndef lint
static char *RCSid = "$Id: doc2tex.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
#endif

/*
 * doc2tex.c  -- program to convert Gnuplot .DOC format to LaTeX document
 * Also will work for VMS .HLP files. 
 * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
 * Extended by David Kotz to support quotes ("), backquotes, tables.
 *
 * usage:  doc2tex < file.doc > file.tex
 *
 *   where file.doc is a Gnuplot .DOC file, and file.tex will be an
 *     article document suitable for printing with LaTeX.
 *
 * typical usage for GNUPLOT:
 *
 *   doc2tex < gnuplot.doc > gnuplot.tex 
 *   latex gnuplot.tex ; latex gnuplot.tex
 */

static char rcsid[] = "$Id: doc2tex.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";

#include <stdio.h>
#include <ctype.h>
#ifdef AMIGA_LC_5_1
#include <string.h>
#endif

#define MAX_NAME_LEN	256
#define MAX_LINE_LEN	256
#define TRUE 1
#define FALSE 0

typedef int boolean;

boolean intable = FALSE;
boolean verb = FALSE;

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


init(b)
FILE *b;
{
	(void) fputs("\\input{titlepage.tex}\n",b);
}


convert(a,b)
	FILE *a,*b;
{
    static char line[MAX_LINE_LEN];

    while (fgets(line,MAX_LINE_LEN,a)) {
	   process_line(line, b);
    }
}

process_line(line, b)
	char *line;
	FILE *b;
{
    switch(line[0]) {		/* control character */
	   case '?': {			/* interactive help entry */
		  break;			/* ignore */
	   }
	   case '@': {			/* start/end table */
		  if (intable) {
			 (void) fputs("\\hline\n\\end{tabular}\n", b);
			 (void) fputs("\\end{center}\n",b);
			 intable = FALSE;
		  } else {
			 if (verb) {
				(void) fputs("\\end{verbatim}\n",b);
				verb=FALSE;
			 } 
			 (void) fputs("\n\\begin{center}\n", b);
			 (void) fputs("\\begin{tabular}{|ccl|} \\hline\n", b);
			 intable = TRUE;
		  }
		  /* ignore rest of line */
		  break;
	   }
	   case '#': {			/* latex table entry */
		  if (intable)
		    (void) fputs(line+1, b); /* copy directly */
		  else
		    fprintf(stderr, "error: # line found outside of table\n");
		  break;
	   }
	   case '%': {			/* troff table entry */
		  break;			/* ignore */
	   }
	   case '\n':			/* empty text line */
	   case ' ': {			/* normal text line */
		  if (intable)
		    break;		/* ignore while in table */
		  if (line[1] == ' ') {
			 /* verbatim mode */
			 if (!verb) {
				(void) fputs("\\begin{verbatim}\n",b);
				verb=TRUE;
			 }
			 (void) fputs(line+1,b); 
		  } else {
			 if (verb) {
				(void) fputs("\\end{verbatim}\n",b);
				verb=FALSE;
			 } 
			 if (line[0] == '\n')
			   puttex(line,b); /* handle totally blank line */
			 else
			   puttex(line+1,b);
		  }
		  break;
	   }
	   default: {
		  if (isdigit(line[0])) { /* start of section */
			 if (!intable)	/* ignore while in table */
			   section(line, b);
		  } else
		    fprintf(stderr, "unknown control code '%c' in column 1\n", 
				  line[0]);
		  break;
	   }
    }
}

/* process a line with a digit control char */
/* starts a new [sub]section */

section(line, b)
	char *line;
	FILE *b;
{
    static char string[MAX_LINE_LEN];
    int sh_i;

    if (verb) {
	   (void) fputs("\\end{verbatim}\n",b);
	   verb=FALSE;
    } 
#ifdef AMIGA_LC_5_1
    (void) sscanf(line,"%d",&sh_i);
    strcpy(string,strchr(line,' ')+1);
    {
      char *p;
      p = strchr(string,'\n');
      if (p != NULL) *p = '\0';
    }
#else
    (void) sscanf(line,"%d %[^\n]s",&sh_i,string);
#endif
    switch(sh_i)
	 {
		case 1: 
		(void) fprintf(b,"\\section{");
		break;
		case 2: 
		(void) fprintf(b,"\\section{");
		break;
		case 3:
		(void) fprintf(b,"\\subsection{");
		break;
		case 4: 
		(void) fprintf(b,"\\subsubsection{");
		break;
		default:
		case 5: 
		(void) fprintf(b,"\\paragraph{");
		break;
	 }
    if (islower(string[0]))
	 string[0] = toupper(string[0]);
    puttex(string,b);
    (void) fprintf(b,"}\n");
}

/* put text in string str to file while buffering special TeX characters */
puttex(str,file)
FILE *file;
register char *str;
{
register char ch;
static boolean inquote = FALSE;

	 while( (ch = *str++) != '\0') {
		 switch(ch) {
			 case '#':
			 case '$':
			 case '%':
			 case '&':
			 case '_':
			 case '{':
			 case '}':
				 (void) fputc('\\',file);
				 (void) fputc(ch,file);
				 break;
			 case '\\':
				 (void) fputs("$\\backslash$",file);
				 break;
			 case '~':
				 (void) fputs("\\~{\\ }",file);
				 break;
			 case '^':
				 (void) fputs("\\verb+^+",file);
				 break;
			 case '>':
			 case '<':
			 case '|':
				 (void) fputc('$',file);
				 (void) fputc(ch,file);
				 (void) fputc('$',file);
				 break;
			 case '"': 
				 /* peek at next character: if space, end of quote */
				 if (*str == NULL || isspace(*str) || ispunct(*str))
				   (void) fputs("''", file);
				 else
				   (void) fputs("``", file);
				 break;
			 case '`':	/* backquotes mean boldface */
				 if (inquote) {
					fputs("}", file);
					inquote = FALSE;
				 } else {
					fputs("{\\bf ", file);
					inquote = TRUE;
				 }
				 break;
			 default:
				 (void) fputc(ch,file);
				 break;
		 }
	 }
}


finish(b)
FILE *b;
{
	(void) fputs("\\end{document}\n",b);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.1 version [afc143dcd7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
.\" dummy line
.TH GNUPLOT 1 "31 August 1990"
.UC 4
.SH NAME
gnuplot \- an interactive plotting program
.SH SYNOPSIS
.B gnuplot
[ X11 options ] [file ...]
.br
.SH DESCRIPTION
.I Gnuplot 
is a command-driven interactive function plotting program.
.PP
If files are given, 
.I gnuplot 
loads each file with the 
.I load
command, in the order specified.
.I Gnuplot 
exits after the last file is processed.
.PP
Here are some of its features:
.PP
Plots any number of functions, built up of C operators, C library
functions, and some things C doesn't have like **, sgn(), etc.  Also
support for plotting data files, to compare actual
data to theoretical curves.
.PP
User-defined X and Y ranges (optional auto-ranging), smart axes scaling,
smart tic marks.
.PP
Labelling of X and Y axes.
.PP
User-defined constants and functions.
.PP
Support through a generalized graphics driver for
AED 512,
AED 767,
BBN BitGraph,
Commodore Amiga,
Roland DXY800A,
EEPIC,
EmTeX,
Epson 60dpi printers,
Epson LX-800,
Fig, 
HP2623,
HP2648,
HP75xx,
HPGL,
HP LaserJet II,
Imagen,
Iris 4D,
Kermit-MS,
Kyocera laser printer,
LaTeX,
NEC CP6 pinwriter,
PostScript,
QMS QUIC,
ReGis (VT125 and VT2xx),
SCO Xenix CGI,
Selanar,
Star color printer,
Tandy DMP-130 printer,
Tek 401x,
Tek 410x,
Vectrix 384,
VT like tekronix emulator,
Unix PC (ATT 3b1 or ATT 7300),
unixplot,  
and X11.
The PC version compiled by Microsoft C
supports IBM CGA, EGA, VGA, Hercules, ATT 6300,
and Corona 325 graphics.  
The PC version compiled by Turbo C
supports IBM CGA, EGA, MCGA, VGA, Hercules and ATT 6300 graphics.  
Other devices can be added simply, but will require recompiling.
.PP
Shell escapes and command line substitution.
.PP
Load and save capability.
.PP
Output redirection.
.PP
All computations performed in the complex domain.  Just the real part is
plotted by default, but functions like imag() and abs() and arg() are
available to override this.
.SH X11 OPTIONS
.I Gnuplot 
provides two terminal types (\fIx11\fP and \fIX11\fP) for use
with X servers. The \fIX11\fP terminal type provides differing colors as well 
as shapes for the \fIpoints\fP plotting style. The two types are otherwise 
identical.  When used with either of these terminal types, \fIgnuplot\fP
accepts all the standard X Toolkit options and resources such as geometry, font,
and background. See the X(1) man page for a description of
the options. 
.PP
In addition to the X Toolkit options, there are three more
command line options. \fB\-mono\fP forces monochrome rendering on
color displays.
\fB\-gray\fP requests grayscale rendering on grayscale or color displays. 
(Grayscale displays receive monochrome rendering by default.) 
\fB\-clear\fP requests that the window be cleared momentarily before a
new plot is displayed. These options may also be controlled with resources.
For example: \fBgnuplot*gray: on\fP .

For color displays \fIgnuplot\fP honors 
the following resources (shown here with default values):
.sp
.B  "gnuplot*background: white"
.br 
.B  "gnuplot*textColor: black"
.br 
.B  "gnuplot*borderColor: black"
.br 
.B  "gnuplot*axisColor: black"
.br 
.B  "gnuplot*line1Color: red"
.br 
.B  "gnuplot*line2Color: green"
.br 
.B  "gnuplot*line3Color: blue"
.br 
.B  "gnuplot*line4Color: magenta"
.br 
.B  "gnuplot*line5Color: cyan"
.br 
.B  "gnuplot*line6Color: sienna"
.br 
.B  "gnuplot*line7Color: orange"
.br 
.B  "gnuplot*line8Color: coral"
.br 

When \fB\-gray\fP is selected, \fIgnuplot\fP honors 
the following resources for grayscale or color displays (shown here with 
default values). Note that the default background is black.
.sp
.B  "gnuplot*background: black"
.br 
.B  "gnuplot*textGray: white"
.br 
.B  "gnuplot*borderGray: gray50"
.br 
.B  "gnuplot*axisGray: gray50"
.br 
.B  "gnuplot*line1Gray: gray100"
.br 
.B  "gnuplot*line2Gray: gray60"
.br 
.B  "gnuplot*line3Gray: gray80"
.br 
.B  "gnuplot*line4Gray: gray40"
.br 
.B  "gnuplot*line5Gray: gray90"
.br 
.B  "gnuplot*line6Gray: gray50"
.br 
.B  "gnuplot*line7Gray: gray70"
.br 
.B  "gnuplot*line8Gray: gray30"
.br 

.PP
The size or aspect ratio of a plot may be changed by resizing the
.I gnuplot
window.
.SH AUTHORS
Thomas Williams, Pixar Corporation, 
.br
(info-gnuplot@ames.arc.nasa.gov)
.br
and Colin Kelley.
.PP
Additions for labelling by Russell Lang, Monash University, Australia.
.br
(rjl@monu1.cc.monash.edu.au)
.br
Further additions by David Kotz, Dartmouth College, New Hampshire, USA
(formerly of Duke University, North Carolina, USA).  
.br
(David.Kotz@Dartmouth.edu)
.br
X11 support by Ed Kubaitis, University of Illinois, USA.
.SH BUGS
The atan() function does not work correctly for complex arguments.
.br
The bessel functions do not work for complex arguments.
.br
See the 
.I help bugs
command in gnuplot.
.SH SEE ALSO
See the printed manual or the on-line help for details on specific commands.
.br
X(1).
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.aux version [9d74298b7c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
\relax 
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {1}Gnuplot}{1}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {2}Cd}{1}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {3}Clear}{1}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {4}Command-line editing}{1}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {5}Comment}{2}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {6}Environment}{2}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {7}Exit}{3}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {8}Expressions}{3}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {8.1}Functions}{3}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {8.2}Operators}{4}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {8.2.1}Binary}{4}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {8.2.2}Unary}{5}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {9}Help}{5}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {10}Load}{6}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {11}Pause}{6}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {12}Plot}{6}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.1}Data-file}{7}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {12.1.1}Using}{8}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.2}Errorbars}{10}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.3}Parametric}{10}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.4}Ranges}{11}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.5}Style}{12}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {12.6}Title}{13}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {13}Print}{13}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {14}Pwd}{13}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {15}Quit}{14}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {16}Replot}{14}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {17}Save}{14}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {18}Set-show}{14}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.1}Angles}{14}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.2}Arrow}{15}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.3}Autoscale}{15}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.3.1}Parametric mode}{16}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.4}Border}{17}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.5}Clip}{17}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.6}Cntrparam}{17}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.7}Contour}{18}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.8}Data style}{18}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.9}Dummy}{18}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.10}Format}{19}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.11}Function style}{19}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.12}Functions}{19}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.13}Grid}{20}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.14}Hidden3d}{20}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.15}Isosamples}{20}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.16}Key}{20}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.17}Label}{21}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.18}Logscale}{22}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.19}Mapping}{22}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.20}Offsets}{23}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.21}Output}{23}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.22}Parametric}{23}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.23}Polar}{24}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.24}Rrange}{25}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.25}Samples}{25}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.26}Size}{25}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.27}Style}{26}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.28}Surface}{26}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.29}Terminal}{27}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.1}Dumb}{27}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.2}Hpljii}{27}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.3}Iris4d}{27}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.4}Pbm}{28}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.5}Postscript}{28}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.6}Aifm}{29}}
\@writefile{toc}{\string\contentsline\space {subsubsection}{\string\numberline\space {18.29.7}Table}{29}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.30}Tics}{29}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.31}Time}{30}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.32}Title}{30}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.33}Trange}{31}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.34}Urange}{31}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.35}Variables}{31}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.36}View}{31}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.37}Vrange}{32}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.38}Xlabel}{32}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.39}Xrange}{32}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.40}Xtics}{33}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.41}Xzeroaxis}{33}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.42}Ylabel}{33}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.43}Yrange}{34}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.44}Ytics}{34}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.45}Yzeroaxis}{34}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.46}Zero}{35}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.47}Zeroaxis}{35}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.48}Zlabel}{35}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.49}Zrange}{35}}
\@writefile{toc}{\string\contentsline\space {subsection}{\string\numberline\space {18.50}Ztics}{36}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {19}Shell}{36}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {20}Splot}{36}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {21}Start-up}{36}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {22}Substitution}{36}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {23}User-defined}{37}}
\@writefile{toc}{\string\contentsline\space {section}{\string\numberline\space {24}Bugs}{37}}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































Deleted r34.1/plot/docs/gnuplot.doc version [1740eed755].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
1 gnuplot
?
 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 a line, separated by semicolons (;).
 Strings are indicated with quotes.  They may be either single or double
 quotation marks, e.g.,

          load "filename"
          cd 'dir'
 
 Any command-line arguments are assumed to be names of files containing 
 GNUPLOT commands, with the exception of standard X11 arguments, which
 are processed first. Each file is loaded with the `load` command, in the
 order specified. GNUPLOT exits after the last file is processed.  When
 no load files are named, gnuplot enters into an interactive mode.
 
 Commands may extend over several input lines, by ending each 
 line but the last with a backslash (\). The backslash must be the LAST
 character on each line. The effect is as if the backslash and newline
 were not there. That is, no white space is implied, nor is a comment
 terminated. Therefore, commenting out a continued line comments out
 the entire command (see `comment`).
 
 In this documentation, curly braces ({}) denote optional arguments to
 many commands, and a vertical bar (|) separates mutually exclusive
 choices.  GNUPLOT keywords or help topics are indicated by backquotes
 or `boldface` (where available).  Angle brackets (<>) are used to mark
 replaceable tokens.
 
 For help on any topic, type `help` followed by the name of the topic.

 The new GNUPLOT user should begin by reading about the `plot`
 command (type `help plot`).
2 cd
?cd
 The `cd` command changes the working directory.
 
 Syntax:
         cd "<directory-name>"
 
 The directory name must be enclosed in quotes.
 
 Examples:
         cd 'subdir'
         cd ".."
2 clear
?clear
 The `clear` command erases the current screen or output device as
 specified by `set output`. This usually generates a formfeed on
 hardcopy devices. Use `set terminal` to set the device type.
2 command-line editing
?line-editing
?editing
?history
 The Unix and IBM PC versions of GNUPLOT support command-line editing.
 Also, a history mechanism allows previous commands to be edited, and
 re-executed. After the command line has been edited, a newline or
 carriage return will enter the entire line regardless of where the
 cursor is positioned.

 The editing commands are as follows:
 
@start table - first is interactive cleartext form
 `Line editing`:
 
 ^B moves back a single character.
 ^F moves forward a single character.
 ^A moves to the beginning of the line.
 ^E moves to the end of the line.
 ^H and DEL delete the previous character.
 ^D deletes the current character.
 ^K deletes from current position to the end of line.
 ^L,^R redraws line in case it gets trashed.
 ^U deletes the entire line.
 ^W deletes the last word.

 `History`:
 
 ^P moves back through history.
 ^N moves forward through history.
#Character && Function \\ \hline 
#\multicolumn{3}{|c|}{Line Editing}\\
#\verb~^B~ && move back a single character.\\
#\verb~^F~ && move forward a single character.\\
#\verb~^A~ && move to the beginning of the line.\\
#\verb~^E~ && move to the end of the line.\\
#\verb~^H, DEL~ && delete the previous character.\\
#\verb~^D~ && delete the current character.\\
#\verb~^K~ && delete from current position to the end of line.\\
#\verb~^L, ^R~ && redraw line in case it gets trashed.\\
#\verb~^U~ && delete the entire line. \\
#\verb~^W~ && delete from the current word to the end of line. \\ \hline
#\multicolumn{3}{|c|}{History} \\
#\verb~^P~ && move back through history.\\
#\verb~^N~ && move forward through history.\\
%Character@@Function
%_
%@@Line Editing
%^B@@move back a single character.
%^F@@move forward a single character.
%^A@@move to the beginning of the line.
%^E@@move to the end of the line.
%^H, DEL@@delete the previous character.
%^D@@delete the current character.
%^K@@delete from current position to the end of line.
%^L, ^R@@redraw line in case it gets trashed.
%^U@@delete the entire line.
%^W@@delete from the current word to the end of line.
%_
%@@History
%^P@@move back through history.
%^N@@move forward through history.
@end table 

 On the IBM PC the use of a TSR program such as DOSEDIT or CED may be
 desired for line editing. For such a case GNUPLOT may be compiled with
 no line editing capability (default makefile setup). Set READLINE in the
 makefile and add readline.obj to the link file if GNUPLOT line editing
 is to be used for the IBM PC. The following arrow keys may be used
 on the IBM PC version if readline is used:
 
@start table - first is interactive cleartext form
 Left  Arrow     - same as ^B.
 Right Arrow     - same as ^F.
 Ctl Left  Arrow - same as ^A.
 Ctl Right Arrow - same as ^E.
 Up    Arrow     - same as ^P.
 Down  Arrow     - same as ^N.
#Arrow key & Function & \\ \hline 
#Left      & same as \verb~^B~. & \\
#Right     & same as \verb~^F~. & \\
#Ctl Left  & same as \verb~^A~. & \\
#Ctl Right & same as \verb~^E~. & \\
#Up        & same as \verb~^P~. & \\
#Down      & same as \verb~^N~. & \\
%Arrow key@@Function
%_
%Left Arrow@@same as ^B.
%Right Arrow@@same as ^F.
%Ctl Left Arrow@@same as ^A.
%Ctl Right Arrow@@same as ^E.
%Up Arrow@@same as ^P.
%Down Arrow@@same as ^N.
%_
@end table
 (The readline function in gnuplot is not the same as the readline used
 in GNU BASH and GNU EMACS.  It is somewhat compatible however.) 
2 comment
?comments
 Comments are supported as follows: a # may appear in most places in a line
 and GNUPLOT will ignore the rest of the line. It will not have this
 effect inside quotes, inside numbers (including complex numbers), inside
 command substitutions, etc. In short, it works anywhere it makes sense
 to work.
2 environment
?environment
 A number of shell environment variables are understood by GNUPLOT.
 None of these are required, but may be useful.
 
 If GNUTERM is defined, it is used as the name of the terminal type to
 be used. This overrides any terminal type sensed by GNUPLOT on start
 up, but is itself overridden by the .gnuplot (or equivalent) start-up
 file (see `start-up`), and of course by later explicit changes.
 
 On Unix, AmigaDOS, and MS-DOS, GNUHELP may be defined to be the pathname
 of the HELP file (gnuplot.gih).

 On VMS, the symbol GNUPLOT$HELP should be defined as the name of 
 the help library for GNUPLOT.
 
 On Unix, HOME is used as the name of a directory to search for 
 a .gnuplot file if none is found in the current directory.
 On AmigaDOS and MS-DOS, GNUPLOT is used. On VMS, SYS$LOGIN: is used.
 See help start-up.
 
 On Unix, PAGER is used as an output filter for help messages.
 
 On Unix and AmigaDOS, SHELL is used for the `shell` command. On MS-DOS,
 COMSPEC is used for the `shell` command.

 On AmigaDOS, GNUFONT is used for the screen font.  For example:
 "setenv GNUFONT sapphire/14".

 On MS-DOS, if the BGI interface is used, the variable `BGI` is used to point 
 to the full path to the BGI drivers directory. Furthermore SVGA is used to
 name the Super VGA BGI driver in 800x600 res., and its mode of operation
 as 'Name.Mode'.
 For example, if the Super VGA driver is C:\TC\BGI\SVGADRV.BGI and mode 3 is
 used for 800x600 res., then: 'set BGI=C:\TC\BGI' and 'set SVGA=SVGADRV.3'.
2 exit
?exit
?quit
 The commands `exit` and `quit` and the END-OF-FILE character
 will exit GNUPLOT. All these commands will clear the output device
 (as the `clear` command does) before exiting.
2 expressions
?expressions
 In general, any mathematical expression accepted by C, FORTRAN,
 Pascal, or BASIC is valid. The precedence of these operators is
 determined by the specifications of the C programming language.
 White space (spaces and tabs) is ignored inside expressions.
 
 Complex constants may be expressed as the {<real>,<imag>}, where <real>
 and <imag> must be numerical constants. For example, {3,2}
 represents 3 + 2i; {0,1} represents `i` itself. The curly braces 
 are explicitly required here.
3 functions
?expressions functions
?functions
 The functions in GNUPLOT are the same as the corresponding functions
 in the Unix math library, except that all functions accept integer,
 real, and complex arguments, unless otherwise noted. The `sgn`
 function is also supported, as in BASIC.
@start table
#Function & Arguments & Returns \\ \hline
%Function@Arguments@Returns
%_
4 abs
?expressions functions abs
?functions abs
?abs
#abs(x) & any  &  absolute value of {\tt x}, $|x|$; same type \\
#abs(x) & complex &  length of {\tt x}, $\sqrt{{\mbox{real}(x)^{2} +
#\mbox{imag}(x)^{2}}}$ \\
%abs(x)@any@absolute value of x, $|x|$; same type 
%abs(x)@complex@length of x, $sqrt{roman real (x) sup 2 + roman imag (x) sup 2}$ 
 The `abs` function returns the absolute value of its argument. The
 returned value is of the same type as the argument.
 
 For complex arguments, abs(x) is defined as the length of x in the
 complex plane [i.e.,  sqrt(real(x)**2 + imag(x)**2) ].
4 acos
?expressions functions acos
?functions acos
?acos
#acos(x) & any  & $\cos^{-1} x$ (inverse cosine) in radians \\
%acos(x)@any@$cos sup -1 x$ (inverse cosine) in radians 
 The `acos` function returns the arc cosine (inverse cosine) of its
 argument. `acos` returns its argument in radians.
4 arg
?expressions functions arg
?functions arg
?arg
#arg(x) & complex & the phase of $x$ in radians\\
%arg(x)@complex@the phase of $x$ in radians
 The `arg` function returns the phase of a complex number, in radians.
4 asin
?expressions functions asin
?functions asin
?asin
#asin(x) & any  & $\sin^{-1} x$ (inverse sin) in radians \\
%asin(x)@any@$sin sup -1 x$ (inverse sin) in radians 
 The `asin` function returns the arc sin (inverse sin) of its argument.
 `asin` returns its argument in radians.
4 atan
?expressions functions atan
?functions atan
?atan
#atan(x) & any  & $\tan^{-1} x$ (inverse tangent) in radians \\
%atan(x)@any@$tan sup -1 x$ (inverse tangent) in radians 
 The `atan` function returns the arc tangent (inverse tangent) of its
 argument. `atan` returns its argument in radians.
4 besj0
?expressions functions besj0
?functions besj0
?besj0
#besj0(x) & radians &  $j_{0}$ Bessel function of $x$ \\
%besj0(x)@radians@$j sub 0$ Bessel function of $x$ 
 The `besj0` function returns the j0th Bessel function of its argument.
 `besj0` expects its argument to be in radians.
4 besj1
?expressions functions besj1
?functions besj1
?besj1
#besj1(x) & radians & $j_{1}$ Bessel function of $x$ \\
%besj1(x)@radians@$j sub 1$ Bessel function of $x$ 
 The `besj1` function returns the j1st Bessel function of its argument.
 `besj1` expects its argument to be in radians.
4 besy0
?expressions functions besy0
?functions besy0
?besy0
#besy0(x) & radians & $y_{0}$ Bessel function of $x$ \\
%besy0(x)@radians@$y sub 0$ Bessel function of $x$ 
 The `besy0` function returns the y0th Bessel function of its argument.
 `besy0` expects its argument to be in radians.
4 besy1
?expressions functions besy1
?functions besy1
?besy1
#besy1(x) & radians & $y_{1}$ Bessel function of $x$ \\
%besy1(x)@radians@$y sub 1$ Bessel function of $x$ 
 The `besy1` function returns the y1st Bessel function of its argument.
 `besy1` expects its argument to be in radians.
4 ceil
?expressions functions ceil
?functions ceil
?ceil
#ceil(x) & any & $\lceil x \rceil$, smallest integer not less than $x$
#(real part) \\
%ceil(x)@any@$left ceiling x right ceiling$, smallest integer not less than $x$ (real part) 
 The `ceil` function returns the smallest integer that is not less than its
 argument. For complex numbers, `ceil` returns the smallest integer
 not less than the real part of its argument.
4 cos
?expressions functions cos
?functions cos
?cos
#cos(x) & radians & $\cos x$, cosine of $x$ \\
%cos(x)@radians@$cos~x$, cosine of $x$ 
 The `cos` function returns the cosine of its argument. `cos` expects its
 argument to be in radians.
4 cosh
?expressions functions cosh
?functions cosh
?cosh
#cosh(x) & radians & $\cosh x$, hyperbolic cosine of $x$ \\
%cosh(x)@radians@$cosh~x$, hyperbolic cosine of $x$ 
 The `cosh` function returns the hyperbolic cosine of its argument.
 `cosh` expects its argument to be in radians.
4 exp
?expressions functions exp
?functions exp
?exp
#exp(x) & any & $e^{x}$,  exponential function of $x$ \\
%exp(x)@any@$e sup x$, exponential function of $x$ 
 The `exp` function returns the exponential function of its argument
 (`e` raised to the power of its argument).
4 floor
?expressions functions floor
?functions floor
?floor
#floor(x) & any & $\lfloor x \rfloor$,  largest integer not greater
#than $x$ (real part) \\
%floor(x)@any@$left floor x right floor$, largest integer not greater than $x$ (real part) 
 The `floor` function returns the largest integer not greater than its
 argument. For complex numbers, `floor` returns the largest
 integer not greater than the real part of its argument.
4 gamma
?expressions functions gamma
?functions gamma
?gamma
#gamma(x) & any & $\Gamma(\mbox{real}(x))$,  gamma function of real($x$) \\
%gamma(x)@any@$GAMMA ( roman real (x))$, gamma function of real ($x$)
 The `gamma` function returns the gamma function of the real part of
 its argument. For integer n, gamma(n+1) = n! .
 If the argument is a complex value, the imaginary component is ignored.
4 imag
?expressions functions imag
?functions imag
?imag
#imag(x) & complex &  imaginary part of $x$ as a real number \\
%imag(x)@complex@imaginary part of $x$ as a real number 
 The `imag` function returns the imaginary part of its argument as a
 real number.
4 int
?expressions functions int
?functions int
?int
#int(x) & real &  integer part of $x$, truncated toward zero \\
%int(x)@real@integer part of $x,$ truncated toward zero 
 The `int` function returns the integer part of its argument, truncated
 toward zero.
4 log
?expressions functions log
?functions log
?log
#log(x) & any & $\log_{e} x$,  natural logarithm (base $e$) of $x$ \\
%log(x)@any@$ln~x$, natural logarithm (base $e$) of $x$ 
 The `log` function returns the natural logarithm (base `e`) of its
 argument.
4 log10
?expressions functions log10
?functions log10
?log10
#log10(x) & any & $\log_{10} x$,  logarithm (base $10$) of $x$ \\
%log10(x)@any@${log sub 10}~x$, logarithm (base $10$) of $x$ 
 The `log10` function returns the logarithm (base 10) of its argument.
4 real
?expressions functions real
?functions real
?real
#real(x) & any &  real part of $x$ \\
%real(x)@any@real part of $x$ 
 The `real` function returns the real part of its argument.
4 sgn
?expressions functions sgn
?functions sgn
?sgn
#sgn(x) & any & 1 if $x>0$, -1 if $x<0$, 0 if $x=0$. imag($x$) ignored \\
%sgn(x)@any@1 if $x > 0$, -1 if $x < 0$, 0 if $x = 0$. $roman imag (x)$ ignored 
 The `sgn` function returns 1 if its argument is positive, -1 if its
 argument is negative, and 0 if its argument is 0. If the argument
 is a complex value, the imaginary component is ignored.
4 sin
?expressions functions sin
?functions sin
?sin
#sin(x) & radians & $\sin x$, sine of $x$ \\
%sin(x)@radians@$sin~x$, sine of $x$ 
 The `sin` function returns the sine of its argument. `sin` expects its
 argument to be in radians.
4 sinh
?expressions functions sinh
?functions sinh
?sinh
#sinh(x) & radians & $\sinh x$, hyperbolic sine $x$ \\
%sinh(x)@radians@$sinh~x$, hyperbolic sine $x$ 
 The `sinh` function returns the hyperbolic sine of its argument. `sinh`
 expects its argument to be in radians.
4 sqrt
?expressions functions sqrt
?functions sqrt
?sqrt
#sqrt(x) & any & $\sqrt{x}$,  square root of $x$ \\
%sqrt(x)@any@$sqrt x $, square root of $x$ 
 The `sqrt` function returns the square root of its argument.
4 tan
?expressions functions tan
?functions tan
?tan
#tan(x) & radians & $\tan x$,  tangent of $x$ \\
%tan(x)@radians@$tan~x$, tangent of $x$ 
 The `tan` function returns the tangent of its argument. `tan` expects
 its argument to be in radians.
4 tanh
?expressions functions tanh
?functions tanh
?tanh
#tanh(x) & radians & $\tanh x$, hyperbolic tangent of $x$\\
%tanh(x)@radians@$tanh~x$, hyperbolic tangent of $x$
 The `tanh` function returns the hyperbolic tangent of its argument.
 `tanh` expects its argument to be in radians.
@end table
3 operators
?expressions operators
?operators
 The operators in GNUPLOT are the same as the corresponding operators
 in the C programming language, except that all operators accept
 integer, real, and complex arguments, unless otherwise noted.
 The ** operator (exponentiation) is supported, as in FORTRAN.
 
 Parentheses may be used to change order of evaluation.
4 binary
?expressions operators binary
?operators binary
?binary
 The following is a list of all the binary operators and their
 usages:
 
@start table - first is interactive cleartext form
  Symbol      Example      Explanation
   **          a**b          exponentiation
   *           a*b           multiplication
   /           a/b           division
   %           a%b         * modulo
   +           a+b           addition
   -           a-b           subtraction
   ==          a==b          equality
   !=          a!=b          inequality
   &           a&b         * bitwise AND
   ^           a^b         * bitwise exclusive OR
   |           a|b         * bitwise inclusive OR
   &&          a&&b        * logical AND
   ||          a||b        * logical OR
   ?:          a?b:c       * ternary operation
#\multicolumn{3}{|c|}{Binary Operators} \\
#Symbol & Example & Explanation \\ \hline
#\verb~**~ & \verb~a**b~ & exponentiation\\
#\verb~*~ & \verb~a*b~ & multiplication\\
#\verb~/~ & \verb~a/b~ & division\\
#\verb~%~ & \verb~a%b~ & * modulo\\
#\verb~+~ & \verb~a+b~ & addition\\
#\verb~-~ & \verb~a-b~ & subtraction\\
#\verb~==~ & \verb~a==b~ & equality\\
#\verb~!=~ & \verb~a!=b~ & inequality\\
#\verb~&~ & \verb~a&b~ & * bitwise AND\\
#\verb~^~ & \verb~a^b~ & * bitwise exclusive OR\\
#\verb~|~ & \verb~a|b~ & * bitwise inclusive OR\\
#\verb~&&~ & \verb~a&&b~ & * logical AND\\
#\verb~||~ & \verb~a||b~ & * logical OR\\
#\verb~?:~ & \verb~a?b:c~ & * ternary operation\\
%Symbol@Example@Explanation
%_
%**@a**b@exponentiation
%*@a*b@multiplication
%/@a/b@division
%%@a%b@* modulo
%+@a+b@addition
%-@a-b@subtraction
%==@a==b@equality
%!=@a!=b@inequality
%&@a&b@* bitwise AND
%^@a^b@* bitwise exclusive OR
%|@a|b@* bitwise inclusive OR
%&&@a&&b@* logical AND
%||@a||b@* logical OR
%?:@a?b:c@* ternary operation
 
@end table 
 (*) Starred explanations indicate that the operator requires
 integer arguments.
 
 Logical AND (&&) and OR (||) short-circuit the way they do in C.
 That is, the second && operand is not evaluated if the first is
 false; the second || operand is not evaluated if the first is true.
 
 The ternary operator evaluates its first argument (a). If it is
 true (non-zero) the second argument (b) is evaluated and returned,
 otherwise the third argument (c) is evaluated and returned.
4 unary
?expressions operators unary
?operators unary
?unary
 The following is a list of all the unary operators and their
 usages:
 
@start table - first is interactive cleartext form
  Symbol     Example      Explanation
   -           -a          unary minus
   ~           ~a        * one's complement
   !           !a        * logical negation
   !           a!        * factorial
#\multicolumn{3}{|c|}{Unary Operators}\\
#Symbol & Example & Explanation \\ \hline
#\verb@-@ & \verb@-a@ & unary minus \\
#\verb@~@ & \verb@~a@ & * one's complement \\
#\verb@!@ & \verb@!a@ & * logical negation \\
#\verb@!@ & \verb@a!@ & * factorial \\
%-@-a@unary minus
%~@~a@* one's complement
%!@!a@* logical negation
%!@a!@* factorial
 
@end table 
 (*) Starred explanations indicate that the operator requires an
 integer argument.
 
 The factorial operator returns a real number to allow a greater range.
2 help
?help
 The `help` command displays on-line help. To specify information on a
 particular topic use the syntax:
 
         help {<topic>}
 
 If <topic> is not specified, a short message is printed about
 GNUPLOT. After help for the requested topic is given, help for a
 subtopic may be requested by typing its name, extending the help
 request. After that subtopic has been printed, the request may be
 extended again, or simply pressing return goes back one level to the
 previous topic. Eventually, the GNUPLOT command line will return.
2 load
?load
 The `load` command executes each line of the specified input file as
 if it had been typed in interactively. Files created by the `save`
 command can later be `load`ed. Any text file containing valid
 commands can be created and then executed by the `load` command.
 Files being `load`ed may themselves contain `load` commands. See
 `comment` for information about comments in commands.
 
 The `load` command must be the last command on the line.
 
 Syntax:
         load "<input-file>"
 
 The name of the input file must be enclosed in quotes.
 
 Examples:
 
         load 'work.gnu'
         load "func.dat"
 
 The `load` command is performed implicitly on any file names given as
 arguments to GNUPLOT. These are loaded in the order specified, and
 then GNUPLOT exits.
2 pause
?pause
 The `pause` command displays any text associated with the command and
 then waits a specified amount of time or until the carriage return is
 pressed.  `pause` is especially useful in conjunction with `load` files.

 Syntax:
         pause <time> {"<string>"}

 <time> may be any integer constant or expression. Choosing -1 will
 wait until a carriage return is hit, zero (0) won't pause at all, and
 a positive integer will wait the specified number of seconds.
 
 Note: Since `pause` is not part of the plot it may interact with
 different device drivers differently (depending upon how text and
 graphics are mixed).
 
 Examples:
         pause -1    # Wait until a carriage return is hit
         pause 3     # Wait three seconds
         pause -1  "Hit return to continue"
         pause 10  "Isn't this pretty?  It's a cubic-spline."
 
2 plot
?plot
?splot
 `plot` and `splot` are the primary commands of the program. They plot
 functions and data in many, many ways. `plot` is used to plot 2-d
 functions and data, while `splot` plots 3-d surfaces and data.

 Syntax:
 
         plot {ranges}  <function> {title} {style}
                     {, <function> {title} {style}...}
 
         splot {ranges}  <function> {title} {style}
                      {, <function> {title} {style}...}
 
 where <function> is either a mathematical expression, the name of a
 data file enclosed in quotes, or a pair (`plot`) or triple (`splot`)
 of mathematical expressions in the case of parametric functions.
 User-defined functions and variables may also be defined here.
 
 `plot` and `splot` commands can be as simple as
 
         plot sin(x)
 
 and
 
         splot x * y
 
 or as complex as (!)
 
         plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
3 data-file
?plot datafile
?plot data-file
?splot datafile
?splot data-file
?datafile
?data-file
?data
 Discrete data contained in a file can displayed by specifying the
 name of the data file (enclosed in quotes) on the `plot` or `splot`
 command line. Data files should contain one data point per line.
 Lines beginning with # (or ! on VMS) will be treated as comments
 and ignored. For `plot`s, each data point represents an (x,y)
 pair. For `splot`s, each point is an (x,y,z) triple. For `plot`s with
 error bars (see `plot errorbars`), each data point is either
 (x,y,ydelta) or (x,y,ylow,yhigh). In all cases, the numbers on each
 line of a data file must be separated by blank space. This blank
 space divides each line into columns.

 For `plot`s the x value may be omitted, and for `splot`s the x
 and y values may be omitted. In either case the omitted values are
 assigned the current coordinate number. Coordinate numbers start at 0
 and are incremented for each data point read.

 To specify other formats, see `plot datafile using`.
 
 In the `plot` command, blank lines in the data file cause a break in
 the plot. There will be no line drawn between the preceding and
 following points if the plot style is `lines` or `linespoints` (see
 `plot style`). This does not change the plot style, as would plotting
 the data as separate curves.
 
 This example compares the data in the file population.dat to a
 theoretical curve:
 
         pop(x) = 103*exp((1965-x)/10)
         plot [1960:1990] 'population.dat', pop(x)
 
 The file population.dat might contain:
 
         # Gnu population in Antarctica since 1965
         1965   103
         1970   55
         1975   34
         1980   24
         1985   10
 
 When a data file is plotted, `samples` and `iso_samples` are ignored.
 Curves plotted using the `plot` command are automatically extended to
 hold the entire curve. Similarly grid data plotted using the `splot`
 command is automatically extended, using the assumption that isolines
 are separated by blank lines (a line with only a CR/LF in it).
 
 Implicitly, there are two types of 3-d datafiles. If all the isolines
 are of the same length, the data is assumed to be a grid data, i.e.,
 the data has a grid topology. Cross isolines in the other parametric
 direction (the ith cross isoline passes thru the ith point of all the
 provided isolines) will also be drawn for grid data. (Note contouring
 is available for grid data only.) If all the isolines are not of the
 same length, no cross isolines will be drawn and contouring that data
 is impossible.
 
 For splot if 3-d datafile and using format (see `splot datafile using`)
 specify only z (height field), a non parametric mode must be specified.
 If, on the other hand, x, y, and z are all specified, a parametric
 mode should be selected (see `set parametric`) since data is defining a
 parametric surface.

 A simple example of plotting a 3-d data file is
 
         set parametric
         splot 'glass.dat'
 
 or
 
         set noparametric
         splot 'datafile.dat'
 
 where the file datafile.dat might contain:
 
         # The valley of the Gnu.
         10
         10
         10
 
         10
         5
         10
 
         10
         1
         10
 
         10
         0
         10
 
 Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ).
 Rows are separated by blank lines.

 On some computer systems with a popen function (UNIX), the datafile
 can be piped through a shell command by starting the file name
 with a '<'.  For example:

         pop(x) = 103*exp(x/10)
         plot '< awk "{print $1-1965 $2}" population.dat', pop(x)

 would plot the same information as the first population example
 but with years since 1965 as the x axis.
 
 For more information about 3-d plotting, see `splot`.
4 using
?plot datafile using
?plot data-file using
?splot datafile using
?splot data-file using
?using
 The format of data within a file can be selected with the `using` 
 option. An explicit scanf string can be used, or simpler column
 choices can be made.
 
 Syntax:
 
         plot "datafile" { using { <ycol> |
                                   <xcol>:<ycol> |
                                   <xcol>:<ycol>:<ydelta> |
                                   <xcol>:<ycol>:<ylow>:<yhigh> }
                                 {"<scanf string>"} } ...

 and

         splot "datafile" { using { <xcol>:<ycol>:<zcol> | <zcol> }
                                  {"<scanf string>"} } ...
 
 <xcol>, <ycol>, and <zcol> explicitly select the columns to plot from
 a space or tab separated multicolumn data file. If only <ycol> is
 selected for `plot`, <xcol> defaults to 1. If only <zcol> is selected
 for `splot`, then only that column is read from the file. An <xcol> of
 0 forces <ycol> to be plotted versus its coordinate number. <xcol>,
 <ycol>, and <zcol> can be entered as constants or expressions.

 If errorbars (see also `plot errorbars`) are used for `plot`s,
 ydelta (for example, a +/- error) should be provided as the third
 column, or ylow and yhigh as third and fourth columns.  These columns
 must follow the x and y columns.

 Scanf strings override any <xcol>:<ycol>(:<zcol>) choices, except for
 ordering of input, e.g.,
         plot "datafile" using 2:1 "%f%*f%f"
 causes the first column to be y and the third column to be x.

 If the scanf string is omitted, the default is generated based on the
 <xcol>:<ycol>(:<zcol>) choices. If the `using` option is omitted, "%f%f"
 is used for `plot` ("%f%f%f%f" for `errorbar` `plot`s) and "%f%f%f" is
 used for `splot`.
 
 Examples:
 
         plot "MyData" using "%*f%f%*20[^\n]%f" with lines

 Data are read from the file "MyData" using the format
 "%*f%f%*20[^\n]%f". The meaning of this format is: "%*f" ignore the
 first number, "%f" then read in the second and assign to x,
 "%*20[^\n]" then ignore 20 non-newline characters, "%f" then read in
 the y value.

         n=3;
         plot "MyData", "MyData" using n 

 causes GNUPLOT to plot the second and third columns of MyData versus
 the first column. The command 'n=4; replot' would then plot the second
 and fourth columns of MyData versus the first column.
 
         splot "glass.dat" using 1

 causes GNUPLOT to plot the first coordinate of the points of glass.dat
 as the z coordinate while ignoring the other two coordinates.
 
 Note: GNUPLOT first reads a line of the data file into a buffer and 
 then does a 
         sscanf(input_buffer, scanf_string, &x, &y{, &z});
 where 'x', 'y', and 'z' are of type 'float'. Any scanf string that
 specifies two (three for `splot`, three or four for `errorbars`) float
 numbers may be used.
3 errorbars
?plot errorbars
?errorbars
 Error bars are supported for 2-d data file plots by reading one or
 two additional columns specifying ydelta or ylow and yhigh
 respectively. No support exists for x error bars or any error bars
 for `splot`s.

 In the default situation, GNUPLOT expects to see three or four
 numbers on each line of the data file, either (x, y, ydelta) or 
 (x, y, ylow, yhigh). The x coordinate must be specified. The order
 of the numbers must be exactly as given above. Data files in this
 format can easily be plotted with error bars:

         plot "data.dat" with errorbars

 The error bar is a vertical line plotted from (x, ylow) to (x,
 yhigh). If ydelta is specified instead of ylow and yhigh, 
 ylow=y-ydelta and yhigh=y+ydelta are derived. If there
 are only two numbers on the line, yhigh and ylow are both set to
 y. To get lines plotted between the data points, `plot` the
 data file twice, once with errorbars and once with lines.

 If y autoscaling is on, the y range will be adjusted to fit the
 error bars.

 The `using` option may be used to specify how columns of the data file
 are to be assigned to x, y, ydelta, ylow, and yhigh. The x column must
 be provided and both the x and y columns must appear before the
 errorbar columns. If three column numbers are given, they are x, y,
 and ydelta. If four columns are given, they are x, y, ylow, and
 yhigh.

 Examples:
 
         plot "data.dat" using 1:2:3:4 with errorbars
         plot "data.dat" using 3:2:6 with errorbars
         plot "data.dat" using 3:4:8:7 with errorbars
 
 The first example reads, x, y, ylow, and yhigh, from columns 1, 2, 3,
 and 4. This is equivalent to the default.  The second example reads x
 from the third column, y from second and ydelta from the sixth column.
 The third example reads x from the third column, y from the fourth,
 ylow from the eighth, and yhigh from seventh columns.
 
 See also `plot using` and `plot style`.
3 parametric
?plot parametric
?splot parametric
?parametric
 When in parametric mode (`set parametric`) mathematical expressions must
 be given in pairs for `plot` and in triplets for `splot`:
         plot sin(t),t**2
 or
         splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
 
 Data files are plotted as before, except any preceding parametric
 function must be fully specified before a data file is given as a
 plot. In other words, the x parametric function (sin(t) above) and
 the y parametric function (t**2 above) must not be interrupted with
 any modifiers or data functions; doing so will generate a syntax error
 stating that the parametric function is not fully specified.
 
 Ranges take on a different meaning when in parametric mode. The first
 range on the `plot` command is the `trange`, the next is the `xrange`,
 and the last is the `yrange`. For `splot` the order is `urange`,
 `vrange`, `xrange`, `yrange`, and finally `zrange`. The following
 `plot` command shows setting the `trange` to [-pi:pi], the `xrange` to
 [-1.3:1.3] and the `yrange` to [-1:1] for the duration of the plot:
         plot [-pi:pi] [-1.3:1.3] [-1:1] sin(t),t**2
 
 Other modifiers, such as `with` and `title`, may be specified only
 after the parametric function has been completed:
         plot sin(t),t**2 title 'Parametric example' with linespoints
3 ranges
?splot ranges
?plot ranges
?ranges
 The optional range specifies the region of the plot that will be
 displayed.
 
 Ranges may be provided on the `plot` and `splot` command line and
 affect only that plot, or in the `set xrange`, `set yrange`, etc.,
 commands, to change the default ranges for future plots.
 
 Syntax:
         [{<dummy-var> =} {<xmin> : <xmax>}] { [{<ymin> : <ymax>}] }
 
 where <dummy-var> is the independent variable (the defaults are x and
 y, but this may be changed with `set dummy`) and the min and max
 terms can be constant expressions.
 
 Both the min and max terms are optional. The ':' is also optional
 if neither a min nor a max term is specified. This allows '[ ]' to
 be used as a null range specification.
 
 Specifying a range in the `plot` command line turns autoscaling for
 that axis off for that plot. Using one of the `set` range commands
 turns autoscaling off for that axis for future plots, unless changed
 later. (See `set autoscale`).
 
 Examples:
 
 This uses the current ranges:
         plot cos(x)
 
 This sets the x range only:
         plot [-10:30] sin(pi*x)/(pi*x)
 
 This is the same, but uses t as the dummy-variable:
         plot [t = -10 :30]  sin(pi*t)/(pi*t)
 
 This sets both the x and y ranges:
         plot [-pi:pi] [-3:3]  tan(x), 1/x
 
 This sets only the y range, and turns off autoscaling on both axes:
         plot [ ] [-2:sin(5)*-8] sin(x)**besj0(x)
 
 This sets xmax and ymin only:
         plot [:200] [-pi:]  exp(sin(x))
 
 This sets the x, y, and z ranges:
         splot [0:3] [1:4] [-1:1] x*y
3 style
?plot style
?splot style
?style
?plot with
?with
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis (or from the grid base for `splot`) to each point. The
 `dots` style plots a tiny dot at each point; this is useful for
 scatter plots with many points.

 The `errorbars` style is only relevant to 2-d data file plotting. It
 is treated like `points` for `splot`s and function `plot`s. For data
 `plot`s, `errorbars` is like `points`, except that a vertical error 
 bar is also drawn: for each point (x,y), a line is drawn from
 (x,ylow) to (x,yhigh). A tic mark is placed at the ends of the error
 bar. The ylow and yhigh values are read from the data file's columns,
 as specified with the `using` option to plot. See `plot errorbars` for
 more information.
 
 Default styles are chosen with the `set function style` and
 `set data style` commands.
 
 By default, each function and data file will use a different 
 line type and point type, up to the maximum number of available 
 types. All terminal drivers support at least six different point
 types, and re-use them, in order, if more than six are required.
 The LaTeX driver supplies an additional six point types (all variants
 of a circle), and thus will only repeat after twelve curves are
 plotted with points.
 
 If desired, the style and (optionally) the line type and point type
 used for a curve can be specified.

 Syntax:
 
         with <style> {<linetype> {<pointtype>}}
 
 where <style> is either `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`. The <linetype> and <pointtype> are positive
 integer constants or expressions and specify the line type and point
 type to be used for the plot. Line type 1 is the first line type used
 by default, line type 2 is the second line type used by default, etc.
 
 Examples:
 
 This plots sin(x) with impulses:
         plot sin(x) with impulses
 
 This plots x*y with points, x**2 + y**2 default:
         splot x*y w points, x**2 + y**2
 
 This plots tan(x) with the default function style, "data.1" with lines:
         plot [ ] [-2:5] tan(x), "data.1" with l
 
 This plots "leastsq.dat" with impulses:
         plot 'leastsq.dat' w i
 
 This plots "exper.dat" with errorbars and lines connecting the points:
         plot 'exper.dat' w lines, 'exper.dat' w errorbars
 Here 'exper.dat' should have three or four data columns.
 
 This plots x**2 + y**2 and x**2 - y**2 with the same line type:
         splot x**2 + y**2 with line 1, x**2 - y**2 with line 1
 
 This plots sin(x) and cos(x) with linespoints, using the
 same line type but different point types:
         plot sin(x) with linesp 1 3, cos(x) with linesp 1 4
 
 This plots file "data" with points style 3:
         plot "data" with points 1 3 
 Note that the line style must be specified when specifying the point
 style, even when it is irrelevant. Here the line style is 1 and the
 point style is 3, and the line style is irrelevant.
 
 See `set style` to change the default styles.
3 title
?plot title
?splot title
 A title of each plot appears in the key. By default the title is
 the function or file name as it appears on the plot command line.
 The title can be changed by using the `title` option. This option 
 should precede any `with` option.
 
 Syntax:
         title "<title>"
 
 where <title> is the new title of the plot and must be enclosed in
 quotes. The quotes will not be shown in the key.
 
 Examples:
 
 This plots y=x with the title 'x':
         plot x
 
 This plots the "glass.dat" file with the title 'surface of revolution':
         splot "glass.dat" title 'surface of revolution'
 
 This plots x squared with title "x^2" and "data.1" with title
 'measured data':
         plot x**2 title "x^2", "data.1" t 'measured data'
2 print
?print
 The `print` command prints the value of <expression> to the screen.
 
 Syntax:
         print <expression>
 
 See `expressions`.
2 pwd
?pwd
 The `pwd` command prints the name of the working directory to the screen.
 
 Syntax:
         pwd
2 quit
?quit
 The `exit` and `quit` commands and END-OF-FILE character will exit
 GNUPLOT. All these commands will clear the output device (as the
 `clear` command does) before exiting.
2 replot
?replot
 The `replot` command without arguments repeats the last `plot` or `splot`
 command. This can be useful for viewing a plot with different `set`
 options, or when generating the same plot for several devices.
 
 Arguments specified after a `replot` command will be added onto the last
 `plot` (`splot`) command (with an implied ',' separator) before it is
 repeated. `replot` accepts the same arguments as the `plot` (`splot`)
 commands except that ranges cannot be specified. See `command-line
 editing` for ways to edit the last `plot` (`splot`) command.
2 save
?save
 The `save` command saves user-defined functions, variables, set
 options or all three plus the last `plot` (`splot`) command to the
 specified file.
 
 Syntax:
         save  {<option>} "<filename>"
 
 where <option> is `functions`, `variables` or `set`. If no option is
 used, GNUPLOT saves functions, variables, set options and the last `plot`
 (`splot`) command.
 
 `save`d files are written in text format and may be read by the `load`
 command.
 
 The filename must be enclosed in quotes.
 
 Examples:
 
         save "work.gnu"
         save functions 'func.dat'
         save var 'var.dat'
         save set "options.dat"
2 set-show
?set
?show
 The `set` command sets LOTS of options.
 
 The `show` command shows their settings. `show all` shows all the
 settings.
3 angles
?set angles
?show angles
?angles
 By default, GNUPLOT assumes the independent variable in polar plots
 is in units of radians. If `set angles degrees` is specified before
 `set polar` then the default range is [0:360] and the independent
 variable has units of degrees. This is particularly useful for
 plots of data files. The angle setting also hold for the 3-d
 mapping as set via the `set mapping` command.

 Syntax:
         set angles { degrees | radians }
         show angles
3 arrow
?set arrow
?set noarrow
?show arrow
?arrow
?noarrow
 Arbitrary arrows can be placed on a plot using the `set arrow`
 command.
 
 Syntax:
 
          set arrow {<tag>} {from <sx>,<sy>{,<sz>}} 
                            {to <ex>,<ey>{,<ez>}} {{no}head}
          set noarrow {<tag>}
          show arrow
 
 
 Unspecified coordinates default to 0. The x, y, and z values are in
 the graph's coordinate system. The z coordinate is only used in
 `splot` commands. <tag> is an integer that identifies the arrow. If no
 tag is given, the lowest unused tag value is assigned automatically.
 The tag can be used to delete or change a specific arrow. To change
 any attribute of an existing arrow, use the `set arrow` command with
 the appropriate tag, and specify the parts of the arrow to be
 changed. Specifying nohead requests the arrow be drawn without a head
 (yielding a line segment). By default, arrows have heads.
 
 Arrows outside the plotted boundaries are permitted but may cause
 device errors.
 
 Examples:
 
 To set an arrow pointing from the origin to (1,2), use:
          set arrow to 1,2
 To set an arrow from (-10,4,2) to (-5,5,3), and tag the arrow number
 3, use:
          set arrow 3 from -10,4,2 to -5,5,3
 To change the preceding arrow begin at 1,1,1, without an arrow head,
 use:
          set arrow 3 from 1,1,1 nohead
 To delete arrow number 2 use:
          set noarrow 2
 To delete all arrows use:
          set noarrow
 To show all arrows (in tag order) use:
          show arrow
3 autoscale
?set autoscale
?set noautoscale
?show autoscale
?autoscale
?noautoscale
 Auto scaling may be set individually on the x, y or z axis
 or globally on all axes. The default is to autoscale all axes.
 
 When autoscaling, the plot range is automatically computed and the
 dependent axis (y for a `plot` and z for `splot`) is scaled to
 include the range of the function or data being plotted.
 
 If autoscaling of the dependent axis (y or z) is not set, the
 current y or z range is used.
 
 See `set yrange` or `set zrange`.
 
 Autoscaling the independent variables (x for `plot` and x,y for
 `splot`) is a request to set the domain to match any data file being
 plotted. If there are no data files then autoscaling an independent
 variable has no effect. In other words, in the absence of a data
 file, functions alone do not affect the x range (or the y range if
 plotting z = f(x,y)).
 
 See `set xrange`, or `set yrange`.
 
 The behavior of autoscaling remains consistent in parametric mode,
 however, there are more dependent variables and hence more control
 over x, y, and z plot scales. In parametric mode, the independent or
 dummy variable is t for `plot`s and u,v for `splot`s.  Autoscale in
 parametric mode, then, controls all ranges (t, u, v, x, y, and z) and
 allows x, y, and z to be fully autoscaled.
 
 See `set parametric`.
 
 Syntax:
         set autoscale <axes>
         set noautoscale <axes>
         show autoscale
 
 where <axes> is either `x`, `y`, `z` or `xy`. If <axes> is not given
 then all axes are assumed.
 
 Examples:
 
 This sets autoscaling of the y axis. x axis autoscaling is not
 affected.
         set autoscale y
 
 This sets autoscaling of the x and y axes.
         set autoscale xy
 
 This sets autoscaling of the x, y and z axes.
         set autoscale
 
 This disables autoscaling of the x, y and z axes.
         set noautoscale
 
 This disables autoscaling of the z axis only.
         set noautoscale z
4 parametric mode
?autoscale parametric
?set autoscale t
 When in parametric mode (`set parametric`) the xrange is as
 fully scalable as the yrange. In other words, in parametric
 mode the x axis can be automatically scaled to fit the range
 of the parametric function that is being plotted. Of course,
 the y axis can also be automatically scaled just as in the
 non-parametric case. If autoscaling on the x axis is not set,
 the current x range is used.
 
 When there is a mix of data files and functions, the xrange of
 the functions is selected as that of the data files if autoscale
 is true for x. While this keeps the behavior compatible with
 non-parametric plotting, it may not be retained in the future.
 The problem is that, in parametric mode, the x and y ranges are
 not as distinguishable as in the non-parametric mode and this
 behavior may not be the most useful.
 
 For completeness a last command `set autoscale t` is accepted.
 However, the effect of this "scaling" is very minor. When
 GNUPLOT determines that the t range would be empty it makes a
 small adjustment if autoscaling is true. Otherwise, GNUPLOT
 gives an error. Such behavior may, in fact, not be very useful
 and the command `set autoscale t` is certainly questionable.
 
 `splot` extends the above idea similarly. If autoscaling is set then
 x, y, and z ranges are computed and each axis scaled to fit the
 resulting data.
3 border
?set border
?set noborder
?show border
?border
?noborder
 The `set border` and `set noborder` commands controls the display of
 the plot borders for the `plot` and `splot` commands.
 
 Syntax:
         set border
         set noborder
         show border
3 clip
?set clip
?set noclip
?show clip
?clip
?noclip
 GNUPLOT can clip data points and lines that are near the boundaries
 of a plot. 
 
 Syntax:
         set clip <clip-type>
         set noclip <clip-type>
         show clip

 Three clip types are supported by GNUPLOT: `points`, `one`, and `two`.
 One, two, or all three clip types may be active for a single plot.

 The `points` clip type forces GNUPLOT to clip (actually, not plot at
 all) data points that fall within but too close to the boundaries
 (this is so the large symbols used for points will not extend outside
 the boundary lines). Without clipping points near the boundaries may
 look bad; try adjusting the x and y ranges.

 Setting the `one` clip type causes GNUPLOT to plot the line segments
 which have only one of the two endpoints with the plotting region.
 Only the in-range portion of the line is drawn.  The alternative is to
 not draw any portion of the line segment.

 Some lines may have both endpoints out of range, but pass through the
 plotting area. Setting the `two` clip-type allows the visible portion
 of these lines to be drawn.
 
 In no case is a line drawn outside the plotting area.

 The defaults are `noclip points`, `clip one`, and `noclip two`.

 To check the state of all forms of clipping, use
         show clip

 For backward compatibility with older versions, the following forms
 are also permitted.
        set clip
        set noclip
 `set clip` is synonymous with `set clip points`. `set noclip` turns
 off all three types of clipping.
3 cntrparam
?set cntrparam
?show cntrparam
?cntrparam
 Sets the different parameters for the contouring plot (see also `contour`).
 
 Syntax:
         set cntrparam { { linear | cubicspline | bspline } |
                         points <n> |
                         levels <n> |
                         order <n> }
 
 This command controls the way contours are plotted. <n> should be an
 integral constant expression. The parameters are:
 
 `linear`, `cubicspline`, `bspline` - Controls type of approximation or
 interpolation. If `linear`, then the contours are drawn piecewise
 linear, as extracted from the surface directly. If `cubicspline`, then
 piecewise linear contours are interpolated to form a somewhat smoother
 contours, but which may undulate. The third option is the uniform
 `bspline`, which only approximates the piecewise linear data but is
 guaranteed to be smoother.
 
 `points` - Eventually all drawings are done with piecewise linear
 strokes.  This number controls the number of points used to
 approximate a curve.  Relevant for `cubicspline` and `bspline` modes
 only.
 
 `levels` - Number of contour levels. If the surface is bounded by zmin
 and zmax then contours will be generated from zmin+dz to zmax-dz
 in steps of size dz, where dz = (zmax - zmin) / (levels + 1).
 
 `order`  - Order of the bspline approximation to be used. The bigger this
 order is, the smoother the resulting contour.  (Of course, higher order
 bspline curves will move further away from the original peicewise linear
 data.)  This option is relevant for `bspline` mode only. Allowed values are 
 integers in the range from 2 (linear) to 10.
3 contour
?set contour
?show contour
?contour
 Enable contour drawing for surfaces. This option is available for `splot`
 only.
 
 Syntax:
         set contour { base | surface | both }
         set nocontour
 
 If no option is provided to `set contour`, the default is `base`.
 The three options specify where to draw the contours: `base` draws
 the contours on the grid base where the x/ytics are placed, `surface`
 draws the contours on the surfaces themselves, and `both` draws the
 contours on both the base and the surface.
 
 See also `set cntrparam` for the parameters that affect the drawing of 
 contours.
3 data style
?set data style
?show data style
?data style
 The `set data style` command changes the default plotting style
 for data plots.

 Syntax:
         set data style 
         show data style 
         set data style <style-choice>

 In the first case, `set data style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show data style` shows the current default
 plotting style for data.  `set data style dots` would actually 
 change the default plotting style.  See also `plot`.
3 dummy
?set dummy
?show dummy
?dummy
 By default, GNUPLOT assumes that the independent variable for the
 `plot` command is x, and the independent variables for the `splot`
 command are x and y. They are called the dummy variables because it
 is just a notation to indicate the independent variables. The `set
 dummy` command changes these default dummy variable names. For
 example, it may be more convenient to call the dummy variable t
 when plotting time functions:
 
         set dummy t
         plot sin(t), cos(t)
 
 Syntax:
         set dummy <dummy-var>{,<dummy-var>}
         show dummy
 
 Examples:
         set dummy u,v
         set dummy ,s
 
 to set both dummy variables to u and v or set only the second
 variable to s.
 
 The `set parametric` command also changes the dummy variables (to t
 for `plot` and u,v for `splot`s).
 
3 format
?set format
?show format
?format
 The format of the tic-mark labels can be set with the `set format`
 command. The default format for both axes is "%g", but other formats
 such as "%.2f" or "%3.0fm" are often desirable. Anything accepted by
 printf when given a double precision number, and then accepted by the
 terminal, will work. In particular, the formats f, e, and g will work,
 and the d, o, x, c, s, and u formats will not work.
 
 Syntax:
         set format {<axes>} {"<format-string>"}
         show format
 
 where <axes> is either `x`, `y`, `z`, `xy`, or nothing (which is the
 same as `xy`). The length of the string representing a ticmark (after
 formatting with printf) is restricted to 100 characters.  If the
 format string is omitted, the format will be returned to the default
 "%g". For LaTeX users, the format "$%g$" is often desirable.  If the
 empty string "" is used, no label will be plotted with each tic,
 though the tic mark will still be plotted. To eliminate all tic marks,
 use `set noxtics` or `set noytics`.
 
 See also `set xtics` and `set ytics` for more control over tic labels.
3 function style
?set function style
?show function style
?function style
 The `set function style` command changes the default plotting style
 for functions.

 Syntax:
         set function style 
         show function style 
         set function style <style-choice>

 In the first case, `set function style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show function style` shows the current default
 plotting style for functions.  `set function style linespoints`
 would actually change the default plotting style.  See also `plot`.
3 functions
?show functions
 The `show functions` command lists all user-defined functions and
 their definitions.
 
 Syntax:
         show functions
3 grid
?set grid
?show grid
?grid
 The optional `set grid` draws a grid at the tic marks with the axis
 linetype.
 
 Syntax:
         set grid
         set nogrid
         show grid
3 hidden3d
?set hidden3d
?show hidden3d
 The `set hidden3d` command enables hidden line removal for explicit
 surface plotting (see `splot`).
 Hidden line removal may be used for both explicit functions
 and for explicit data where gnuplot plot is in nonparametric mode (see
 `set parametric`).
 
 When this flag is set both the surface hidden portion and possibly
 its hidden contours (see `set contour`) as well as the hidden grid will be
 removed. Labels and arrows are always visible and are unaffected by this
 command.
 
 Each surface has its hidden part removed with respect to itself, if more
 than one surface is ploted. This mode is meaningfull when surfaces are
 plotted using line style drawing only.

 Syntax:
         set hidden3d
         set nohidden3d
         show hidden3d
3 isosamples
?set isosamples
?show isosamples
?isosamples
 An isoline is a curve parametrized by one of the surface parameters
 while the other surface parameter is fixed. Isolines are a simple
 means to display a surface. By fixing the u parameter of surface
 s(u,v), the iso-u lines of the form c(v) = s(u0,v) are produced, and
 by fixing the v parameter, the iso-v lines of the form c(u) = s(u,v0)
 are produced.
 
 The isoline density of surfaces may be changed by the `set isosamples`
 command. By default, sampling is set to 10 isolines per u or v axis.
 A higher sampling rate will produce more accurate plots, but will take
 longer. This parameter has no effect on data file plotting.
 
 Syntax:
         set isosamples <expression>
         show isosamples
3 key
?set key
?show key
?key
 The `set key` enables a key describing curves on a plot.  By default
 the key is placed in the upper right corner of the plot.
 
 Syntax:
         set key
         set key <x>,<y>{,<z>}
         set nokey
         show key
 
 The coordinates <x>, <y> (and <z> for `splot`s) specify the location
 of the key on the plot. The key is drawn as a sequence of lines, with
 one plot described on each line. On the right hand side of each line
 is a representation that attempts to mimic the way the curve is
 plotted.  On the left side of each line is the text description,
 obtained from the `plot` command. See `plot title` to change this
 description. The lines are vertically arranged so an imaginary
 straight line divides the left- and right-hand sides of the key. It is
 the coordinates of this line that are specified with the `set key`
 command. In a `plot`, only the x and y coordinates are used to specify
 the line position.  For a `splot`, x, y and z are all being used as a
 3-d location mapped using the same mapping as the plot itself to form
 the required 2-d screen position of the imaginary line.
 
 Some or all of the key may be outside of the plot boundary, although
 this may interfere with other labels and may cause an error on some
 devices.
 
 Examples:
 
 This places the key at the default location:
         set key
 This disables the key:
         set nokey
 This places a key at coordinates 2,3.5,2
         set key 2,3.5,2
3 label
?set label
?set nolabel
?show label
?label
?nolabel
 Arbitrary labels can be placed on the plot using the `set label`
 command.  If the z coordinate is given on a `plot` it is ignored; if
 it is missing on a `splot` it is assumed to be 0.
 
 Syntax:
 
          set label {<tag>} {"<label_text>"} {at <x>,<y>{,<z>}}
                            {<justification>}
          set nolabel {<tag>}
          show label
 
 
 The text defaults to "", and the position to 0,0,0.  The <x>, <y>, and
 <z> values are in the graph's coordinate system.  The tag is an
 integer that is used to identify the label. If no <tag> is given, the
 lowest unused tag value is assigned automatically. The tag can be used
 to delete or change a specific label. To change any attribute of an
 existing label, use the `set label` command with the appropriate tag,
 and specify the parts of the label to be changed.
 
 By default, the text is placed flush left against the point x,y,z.
 To adjust the way the label is positioned with respect to the point
 x,y,z, add the parameter <justification>, which may be `left`, `right`
 or `center`, indicating that the point is to be at the left, right or
 center of the text. Labels outside the plotted boundaries are
 permitted but may interfere with axes labels or other text.
 
 Examples:
 
 To set a label at (1,2) to "y=x" use:
          set label "y=x" at 1,2
 To set a label "y=x^2" with the right of the text at (2,3,4), and tag
 the label number 3, use:
          set label 3 "y=x^2" at 2,3,4 right
 To change the preceding label to center justification, use:
          set label 3 center
 To delete label number 2 use:
          set nolabel 2
 To delete all labels use:
          set nolabel
 To show all labels (in tag order) use:
          show label
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 logscale
?set logscale
?set nologscale
?show logscale
?logscale
?nologscale
 Log scaling may be set on the x, y, and z axes.
 
 Syntax:
         set logscale <axes>
         set nologscale <axes>
         show logscale
 
 where <axes> may be any combinations of `x`, `y`, and `z`, in any
 order.  If <axes> is not given then all three axes are assumed.  The
 command `set logscale` turns on log scaling on the specified axes,
 while `set nologscale` turns off log scaling.
 
 Examples:
 
 To enable log scaling in both x and z axes:
        set logscale xz
 To disable z axis log scaling:
        set nologscale z
3 mapping
?set mapping
?show mapping
?mapping
 
 Syntax:
         set mapping { cartesian | spherical | cylindrical }
 
 Data for `splot`s are usually in regular Euclidean space and are
 provided in Cartesian coordinates. Such 3-d data require three
 coordinates (x, y and z) or one coordinate (only z) in each line in
 the data file.  In order to be able to use spherical or cylindrical
 coordinate systems, use the `set mapping` command. In both cases two
 coordinates are expected in each line of the data. For a spherical
 coordinate system, these are theta and phi (in units as specified by
 `set angles`) and the mapping is:
 
         x = cos( theta ) * cos( phi )
         y = sin( theta ) * cos( phi )
         z = sin( phi )
 
 For a cylindrical coordinate system, the mapping uses two variables,
 theta (in units as specified by `set angles`) and z:
 
         x = cos( theta )
         y = sin( theta )
         z = z
 
 Again, note that mapping will affect data file `splot`s only.
3 offsets
?set offsets
?show offsets
?offsets
 The amount of the graph that the plot takes up may be controlled to
 some extent with the `set offsets` command. This command takes four
 offset arguments: <left>, <right>, <top> and <bottom>. By default,
 each offset is 0. Each offset may be a constant or an expression. Left
 and right offsets are given in units of the x axis, while top and
 bottom offsets are given in units of the y axis. The plot of sin(x),
 displayed with offsets of 0, 0, 2, 2 will take up 1/3 of the
 displayed y axis. Offsets are particularly useful with polar
 coordinates as a means of compensating for aspect ratio distortion.
 Offsets are ignored in `splot`s.
 
 Syntax:
         set offsets <left>, <right>, <top>, <bottom>
         show offsets
3 output
?set output
?show output
?output
 By default, plots are displayed to the standard output. The `set
 output` command redirects the display to the specified file or
 device.
 
 Syntax:
         set output {"<filename>"}
         show output
 
 The filename must be enclosed in quotes. If the filename is
 omitted, output will be sent to the standard output.

 On machines with popen functions (UNIX), output can be piped
 through a shell command if the first letter of the filename
 is '|'.  For instance,
 
 Syntax:
         set output "|lpr -Plaser filename"
         set output "|lp -dlaser filename"

 (On MSDOS machines, set output "prn" will direct the output
 to the default printer.)

3 parametric
?set parametric
?set noparametric
?show parametric
?parametric
?noparametric
 The `set parametric` command changes the meaning of `plot` (`splot`)
 from normal functions to parametric functions. The command
 `set noparametric` changes the plotting style back to normal,
 single-valued expression plotting.
 
 In 2-d plotting, a parametric function is determined by a pair
 of parametric functions operating on a parameter. An example
 of a 2-d parametric function would be plot sin(t),cos(t) (which
 defines a circle).
 
 For 3-d plotting, the surface is described as x=f(u,v), y=g(u,v),
 z=h(u,v). Therefore a triplet of functions are required. An example of
 3-d parametric function would be cos(u)*cos(v),cos(u)*sin(v),sin(u)
 (which defines a sphere). It takes three parametric function
 specifications in terms of the parametric dummy arguments to describe
 a single graph.
 
 The total set of possible plots is a superset of the simple f(x)
 style plots, since the two (three) functions can describe the
 x and y (and z) values to be computed separately. In fact,
 plots of the type t,f(t) (u,v,f(u,v)) are equivalent to those
 produced with f(x) when the x values are computed using the
 identity function as the first function.
 
 Note that the order the parametric functions are specified is
 xfunction, yfunction (and zfunction) and that each operates over the
 common parametric domain.
 
 Also, the `set parametric` function implies a new range of values.
 Whereas the normal f(x) and f(x,y) style plotting assume an xrange
 and yrange (and zrange), the parametric mode additionally specifies a
 trange, urange, and vrange. These ranges may be set
 directly with `set trange`, `set urange` and `set vrange`, or by
 specifying the range on the `plot` or `splot` commands. Currently
 the default range for these parametric variables is [-5:5].
 Setting the ranges to something more meaningful is expected.
3 polar
?set polar
?set nopolar
?show polar
?polar
?nopolar
 The `set polar` command changes the meaning of the plot from
 rectangular coordinates to polar coordinates. In polar coordinates,
 the dummy variable (x) is an angle. The range of this angle is changed
 from whatever it was to [0:2*pi], or, if degree unit has been selected,
 to [0:360] (see `set angles`).
 
 The command `set nopolar` changes the meaning of the plot back to the
 default rectangular coordinate system. The range of x is changed from
 whatever it was to [-10:10].
 
 The `set polar` command is not supported for `splot`s.  See the
 `set mapping` command for similar functionality for `splot`s.
 
 While in polar coordinates the meaning of an expression in x is really
 r = f(x), where x is an angle of rotation. The xrange controls the
 domain (the angle) of the function, and the yrange controls the range
 (the radius). The plot is plotted in a rectangular box, and the x and
 y axes are both in units of the radius. Thus, the yrange controls both
 dimensions of the plot output. The tics and units are written along
 the axes rather than at the left and bottom. These unit are offset by
 <rmin> specified by the `rrange` (See `set rrange`). It is not
 possible to specify different output dimensions in the x or y
 directions. The yrange can be used to shift the plot diagonally to
 display only the first or third quadrants.
 
 Syntax:
         set polar
         set nopolar
         show polar
 Example:
         set polar
         plot x*sin(x)
         plot [-2*pi:2*pi] [-3:3] x*sin(x)
 The first plot uses the default polar angular domain of 0 to 2*pi.
 The radius (and the size of the plot) is scaled automatically. The
 second plot expands the domain, and restricts the range of the radius
 (and the size of the plot) to [-3:3].
3 rrange
?set rrange
?show rrange
?rrange
 The `set rrange` command sets the radial range used to compute x and y
 values when in polar mode. If not in polar mode (see `set polar`) then
 this range is not used. Use of this command offsets the polar
 singularity to the <rmin> value and shifts the units on the axes tic
 marks. For instance, `set rrange [-40:40]` would set the origin to -40
 and would plot values of radial values between -40 to 40. Thus, if
 360 degrees of data were plotted, then the plot would extend 80 units
 in radially from the origin.  To view the entire plot,  a 
 `set yrange [-80:80]` command would create a square viewport with
 a circular plot tangent at the axes.  Because `xrange` is used
 specify the angular extent, only a square viewport can be specified
 by `yrange`.  For instance, `set yrange [0:80]` would display the
 first quadrant and `set yrange [-80:0]` would display the third
 quadrant.  Any square viewport of any size can be specified but it
 is constrained to be centered on a 45 degree line.
 
 This range may also be specified on the `plot` command line when in
 polar mode.
 
 Syntax:
         set rrange [{<rmin> : <rmax>}]
 
 where <rmin> and <rmax> terms are constants or expressions.
 
 Both the <rmin> and <rmax> terms are optional. Anything omitted will
 not be changed, so 
         set rrange [:10]
 changes rmax to 10 without affecting rmin.
3 samples
?set samples
?show samples
?samples
 The sampling rate of functions may be changed by the `set samples`
 command. By default, sampling is set to 100 points. A higher sampling
 rate will produce more accurate plots, but will take longer. This
 parameter no longer has any effect on data-file plotting.
 
 Syntax:
         set samples <expression>
         show samples
3 size
?set size
?show size
?size
 The `set size` command scales the displayed size of the plot.  On some
 terminals, changing the size of the plot will result in text being
 misplaced. Increasing the size of the plot may produce strange
 results. Decreasing is safer.
 
 Syntax:
 
         set size {<xscale>,<yscale>}
         show size
 
 The <xscale> and <yscale> values are the scaling factors for the size.
 The defaults (1,1) are selected if the scaling factors are omitted.
 
 Examples: 
 
 To set the size to normal size use:
         set size
 To make the plot half size use:
         set size 0.5,0.5
 To make a landscape plot have a 1:1 aspect ratio in polar mode use:
         set size 0.721,1.0
 To show the size use:
         show size
 
 For the LaTeX and Fig terminals the default size (scale factor 1,1)
 is 5 inches wide by 3 inches high. The big Fig terminal (`bfig`) is 7
 inches wide by 5 inches high. The postscript default is landscape mode
 10 inches wide and 7 inches high. 
 Note that the size of the plot includes the space used by the labels; 
 the plotting area itself is smaller. 
3 style
?set style
?show style
?style
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis to each point. The `dots` style plots a tiny dot at
 each data point; this is useful for scatter plots with many points.
 
 The `errorbars` style is relevant only for to data file `plot`s. It is
 treated like `points` for function `plot`s and `splot`s. For data file
 `plot`s, `errorbars` is like `points`, except that a vertical error
 bar is also drawn: for each point (x,y), a line is drawn from (x,ylow)
 to (x,yhigh). A tic mark is placed at the ends of the error bar. The
 ylow and yhigh values are read from the data file's third and fourth
 columns, or as specified with the `using` option to plot.  See `plot
 errorbars` for more information.
 
 Default styles are chosen with the `set function style` and `set
 data style` commands. See `plot style` for information about how
 to override the default plotting style for individual functions.
 
 Syntax:
         set function style <style>
         set data style <style>
         show function style
         show data style
 
 where <style> is `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`.
3 surface
?set surface
?set nosurface
?show surface
?surface
 `set surface` controls the display of surfaces. It is useful if
 contours are to be displayed by themselves. Whenever `set nosurface`
 is issued, no surface isolines/mesh will be drawn. See also `set
 contour`.
 
 Syntax:
         set surface
         set nosurface
         show surface
3 terminal
?set terminal
?show terminal
?terminal
 GNUPLOT supports many different graphics devices. Use the `set
 terminal` command to select the type of device for which GNUPLOT
 will produce output.
 
 Syntax:
         set terminal {<terminal-type>}
         show terminal
 
 If <terminal-type> is omitted, GNUPLOT will list the available
 terminal types. <terminal-type> may be abbreviated.
 
 Use `set output` to redirect this output to a file or device.

 Several terminals have additional options. For example, see `dumb`,
 `iris4d`, `hpljii` or `postscript`.
4 dumb
?set terminal dumb
?dumb
 The dumb terminal driver has an optional size specification.

 Syntax:
         set terminal dumb {<xsize> <ysize>}

 where <xsize> and <ysize> set the size of the dumb terminals. Default
 is 79 by 24.

 Examples:
         set term dumb
         set term dumb 79 49 #(VGA screen - why would anyone want to do that!?)
 
4 hpljii
?set terminal hpljii
?hpljii
 The HP LaserJet II and HP DeskJet drivers have a single option.

 Syntax:
         set terminal hpljii {<resolution>}
         set terminal hpdj   {<resolution>}

 where <resolution> is the resolution of the output in dots per inch.
 It must be `75`, `100`, `150` or `300`.

 Example:
         set terminal hpljii 150
 
4 iris4d
?set terminal iris4d
?iris4d
 The iris4d driver can operate in two modes.

 Syntax:
         set terminal iris4d {24}

 If the hardware supports only 8 bits, use the default `set terminal
 iris4d`. If, however, the hardware supports 24 bits (8 per
 red/green/blue), use `set terminal iris4d 24`.

 When using 24-bit mode, the colors can be directly specified via the
 file .gnuplot_iris4d that is searched in the current directory and
 then in the home directory specified by the HOME environment variable.
 This file holds RGB values for the background, border, labels and nine
 plotting colors, in that order. For example, here is a file containing
 the default colors:
 
         85   85   85     /* Back Ground */
         0    0    0      /* Boundary */
         170  0    170    /* Labeling */
         85   255  255    /* Plot Color 1 */
         170  0    0      /* Plot Color 2 */
         0    170  0      /* Plot Color 3 */
         255  85   255    /* Plot Color 4 */
         255  255  85     /* Plot Color 5 */
         255  85   85     /* Plot Color 6 */
         85   255  85     /* Plot Color 7 */
         0    170  170    /* Plot Color 8 */
         170  170  0      /* Plot Color 9 */
 
 This file has exactly 12 lines of RGB triples. No empty lines are
 allowed and anything after the third number in line is ignored.
 
4 pbm
?set terminal pbm
?pbm
 Several options may be set in the PBMplus driver.

 Syntax:
         set terminal pbm {<fontsize>}
         set terminal pgm {<fontsize>}
         set terminal ppm {<fontsize>}

 where <fontsize> is `small`, `medium`, or `large`. 
 Default size is 640 pixels wide and 480 pixels high.
 The pbm output is a portable bitmap (one bit per pixel).
 The pgm output is a portable graymap (three bits per pixel). 	
 The ppm output is a portable pixmap (color, four bits per pixel).
 The output of these drivers can be used with Jef Poskanzer's 
 excellent PBMPLUS package which provides programs to convert
 the above PBMPLUS formats to GIF, TIFF, MacPaint, Macintosh PICT,
 PCX, X11 bitmap and many others. 

 Examples:
 
         set term pbm small
         set size 2,2
         set term ppm medium
 
4 postscript
?set terminal postscript
?postscript
 Several options may be set in the PostScript driver.

 Syntax:
         set terminal postscript {<mode>} {<color>}
                                 {"<fontname>"} {<fontsize>}

 where <mode> is `landscape`, `portrait`, `eps` or `default`. 
 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `landscape`, `monochrome`, "Courier", and 14pt.
 Default size of PostScript plot is landscape mode 10 inches wide 
 and 7 inches high.

 To get EPS output, use the `eps` mode and make only one plot per file.
 In `eps` mode the whole plot is halved in size; the fonts are half the 
 given size, and the plot is 5 inches wide and 3.5 inches high.

 Examples:
 
         set term postscript default       # old postscript
         set term postscript landscape 22  # old psbig
         set term postscript eps 14   # old epsf1
         set term postscript eps 22   # old epsf2
         set size 0.7,1.4
         set term post portrait color "Times-Roman" 14 
 
4 aifm
?set terminal aifm
?aifm
 Several options may be set in the Adobe Illustrator 3.0 driver.

 Syntax:
         set terminal aifm {<color>}
                                 {"<fontname>"} {<fontsize>}

 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `monochrome`, "Courier", and 14pt.

 Also, since AI does not really support multiple pages, multiple 
 graphs will be output directly on one another.  However, each graph 
 will be grouped individually, making it easy to separate them inside 
 AI (just pick them up and move them).

 Examples:
 
         set term aifm 
         set term aifm 22  
         set size 0.7,1.4
         set term aifm color "Times-Roman" 14 
 
4 table
?set terminal table
?table
 Instead of producing a picture, term type 'table' prints out
 the evaluation results in a multicolumn ASCII table of X Y Z values.
 For those times when you really want to see the numbers, now you
 can see them on the screen or save to a file.

3 tics
?set tics
?show tics
?tics
 By default, tics are drawn inwards from the border on all four sides.
 The `set tics` command can be used to change the tics to be 
 drawn outwards on the left and bottom borders only.
 This is useful when doing impulse plots.
 
 Syntax:
         set tics {<direction>}
         show tics
 
 where <direction> may be `in` or `out`. `set tics` defaults to `in`.
 
 See also the `set xtics`, `set ytics`, and `set ztics` command for more
 control of tic marks.
?set ticslevel
?show ticslevel
?ticslevel
 Using splot, in 3-d plots, one can adjust the relative height of the
 vertical (Z) axis using `set ticslevel`. The numeric argument provided
 specifies the location of the bottom of the scale. a zero will put it
 on the bottom grid and any positive number somewhere along the z axis.
 
 Syntax:
         set ticslevel {<level>}
         show tics
 
 where <level> is a non negative numeric argument. For example,

         set ticslevel 0.5

 sets the tics level to the default value.
 
 See also the `set view`.
3 time
?set time
?show time
?time
 The optional `set time` places the time and date of the plot either
 at the top or bottom of the left margin. The exact location is
 device dependent.
 
 Syntax:
         set time {<xoff>}{,<yoff>}
         set notime
         show time
 
 Specifying constants <xoff> or <yoff> as optional offsets for the time
 will move the time <xoff> or <yoff> character screen coordinates. For
 example,
 
         set time ,-3
 
 will change only the y offset of the time, moving the title down by
 roughly the height of three characters.
 
3 title
?set title
?show title
?title
 The `set title` command produces a plot title that is centered at the
 top of the plot. Using the optional x,y screen offsets, the title
 can be placed anywhere on the plot. `set title` with no parameters
 clears the title.
 
 Syntax:
          set title {"<title-text>"} {<xoff>}{,<yoff>}
          show title
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 title will move the title <xoff> or <yoff> character screen
 coordinates. Note these are screen coordinates and not plot
 coordinates. For example,
 
          set title ,-1
 
 will change only the y offset of the title, moving the title down by
 roughly the height of one character.
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 trange
?set trange
?show trange
?trange
 The `set trange` command sets the parametric range used to compute
 x and y values when in parametric mode. If not in parametric mode
 (see `set parametric`) then this range is not used. This command
 does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `plot` command line when
 in parametric mode.
 
 Syntax:
         set trange [{<tmin> : <tmax>}]
 
 where <tmin> and <tmax> terms are constants or expressions.
 
 Both the <tmin> and <tmax> terms are optional. Anything omitted will
 not be changed, so 
         set trange [:10]
 changes tmax to 10 without affecting tmin.  See also `set urange` and
 `set parametric`.
3 urange
?set urange
?show urange
?urange
 The `set urange` and `set vrange` commands sets the parametric ranges used 
 to compute x, y, and z values when in `splot` parametric mode. If not in 
 parametric mode (see `set parametric`) then these ranges are not used. This 
 command does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `splot` command line when
 in parametric mode.  See `plot` for more information
 
 Syntax:
         set urange [{<umin> : <umax>}]
 
 where <umin> and <umax> terms are constants or expressions.
 
 Both the <umin> and <umax> terms are optional. Anything omitted will
 not be changed, so 
         set urange [:10]
 changes umax to 10 without affecting umin.  See also `set trange`.
3 variables
?show variables
 The `show variables` command lists all user-defined variables and
 their values.
 
 Syntax:
         show variables
3 view
?set view
?show view
?view
 The `set view` command sets the view point for `splot`s. This
 command controls the way the 3-d coordinates of the plot are mapped
 into the 2-d screen space. This command provides controls to both
 rotation and scaling of the plotted data but supports orthographic
 projections only.
 
 Syntax:
         set view <rot_x> {,{<rot_z>}{,{<scale>}{,<scale_z>}}}
         show view
 
 where <rot_x> and <rot_z> control the rotation angles (in degrees)
 along a virtual 3-d coordinate system aligned with the screen such
 that the screen horizontal axis is x, screen vertical axis is y, and
 the axis perpendicular to the screen is z. <rot_x> is bounded to the
 [0:180] range with a default of 60 degrees, while <rot_z> is bounded
 to the [0:360] range with a default of 30 degrees. <scale> controls
 the scaling of the entire `splot`, while <scale_z> scales the z axis
 only. Both scales default to 1.0.
 
 Examples:
         set view 60, 30, 1, 1
         set view ,,0.5
 
 The first sets all the four default values. The second changes 
 only scale, to 0.5.

 See also `set ticslevel`.
3 vrange
?set vrange
?show vrange
?vrange
 The `set vrange` command is similar to the `set urange` command.
 Please see `set urange`.
3 xlabel
?set xlabel
?show xlabel
?xlabel
 The `set xlabel` command sets the x-axis label that is centered along
 the x axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set xlabel` with no parameters clears
 the label.
 
 Syntax: 
          set xlabel {"<label>"} {<xoff>}{,<yoff>}
          show xlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set xlabel -1
 
 will change only the x offset of the xlabel, moving the label roughly
 one character width to the left.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 xrange
?set xrange
?show xrange
?xrange
 The `set xrange` command sets the horizontal range that will be
 displayed. This command turns x axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set xrange [{<xmin> : <xmax>}]
 
 where <xmin> and <xmax> terms are constants or expressions.
 
 Both the <xmin> and <xmax> terms are optional. Anything omitted will
 not be changed, so 
         set xrange [:10]
 changes xmax to 10 without affecting xmin.
3 xtics
?set xtics
?set noxtics
?show xtics
?xtics
?noxtics
 Fine control of the x axis tic marks is possible with the
 `set xtics` command. The x-axis tic marks may be turned off with the
 `set noxtics` command. They may be turned on (the default state) with
 `set xtics`.
 
 Syntax:
          set xtics { {<start>, <incr>{, <end>}} |
                      {({"<label>"} <pos> {, {"<label>"} <pos>}...)} }
          set noxtics
          show xtics

 The <start>, <incr>, <end> form specifies that a series of tics will
 be plotted on the x axis between the x values <start> and <end>
 with an increment of <incr>. If <end> is not given it is assumed to be
 infinity. The increment may be negative. For example,
           set xtics 0,.5,10
 makes tics at 0, 0.5, 1, 1.5, ..., 9.5, 10.
 
 The ("<label>" <pos>, ...) form allows arbitrary tic positions or
 non-numeric tic labels. A set of tics are a set of positions, each
 with its own optional label. Note that the label is a string enclosed
 by quotes, and may be a constant string, such as "hello", or contain
 formatting information for the tic number (which is the same as the
 position), such as "%3f clients". See `set format` for more
 information about this case. The label may even be empty.
 Examples:
          set xtics ("low" 0, "medium" 50, "high" 100)
          set xtics (1,2,4,8,16,32,64,128,256,512,1024)
          set xtics ("bottom" 0, "" 10, "top" 20)
 
 Tics will only be plotted when in range.
 
 The `set ytics` and `set noytics` commands work identically.
 See also the `set format` command.
3 xzeroaxis
?set xzeroaxis
?set noxzeroaxis
?show xzeroaxis
?xzeroaxis
?noxzeroaxis
 `set xzeroaxis` draws the x-axis. By default, this option is on.
 `set noxzeroaxis` causes GNUPLOT to omit the x-axis.
 
 Syntax:
         set xzeroaxis
         set noxzeroaxis
         show xzeroaxis
3 ylabel
?set ylabel
?show ylabel
?ylabel
 The `set ylabel` command sets the y-axis label.  The position of this
 label depends on the terminal, and can be one of the following three
 positions (the position can be adjusted with optional parameters).
 
 1. Horizontal text flushed left at the top left of the plot.
 Terminals that cannot rotate text will probably use this method.
 
 2. Vertical text centered vertically at the left of the plot.
 Terminals that can rotate text will probably use this method.
 
 3. Horizontal text centered vertically at the left of the plot.
 The LaTeX and EEPIC drivers use this method. The user must insert 
 line breaks using \\ to prevent the ylabel from overwriting
 the plot. To produce a vertical row of characters, add \\
 between every printing character (but this is ugly).
 
 Syntax:  
          set ylabel {"<label>"} {<xoff>}{,<yoff>}
          show ylabel
 
 With no parameters, the label is cleared. Specifying constants <xoff>
 or <yoff> as optional offsets for the label will move the label <xoff>
 or <yoff> character screen coordinates. For example,
 
          set ylabel -1
 
 will change only the x offset of the ylabel, moving the label roughly
 one character width left of its default position. This is especially
 useful with the LaTeX driver.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 yrange
?set yrange
?show yrange
?yrange
 The `set yrange` command sets the vertical range that will be
 displayed. This command turns y axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set yrange [{<ymin> : <ymax>}]
 
 where <ymin> and <ymax> terms are constants or expressions.
 
 Both the <ymin> and <ymax> terms are optional. Anything omitted will
 not be changed, so 
         set yrange [:10]
 changes ymax to 10 without affecting ymin.
3 ytics
?set ytics
?set noytics
?show ytics
?ytics
?noytics
 The `set ytics` and `set noytics` commands are similar to the `set xtics`
 and `set noxtics` commands. Please see `set xtics`.
3 yzeroaxis
?set yzeroaxis
?set noyzeroaxis
?show yzeroaxis
?yzeroaxis
?noyzeroaxis
 `set yzeroaxis` draws the y-axis. By default, this option is on.
 `set noyzeroaxis` causes GNUPLOT to omit the y-axis.
 
 Syntax:
         set yzeroaxis
         set noyzeroaxis
         show yzeroaxis
3 zero
?set zero
?show zero
?zero
 The `zero` value is the default threshold for values approaching 0.0.
 GNUPLOT will not plot a point if its imaginary part is greater in
 magnitude than the `zero` threshold. Axis ranges cannot be less than
 `zero`. The default `zero` value is 1e-8. This can be changed with
 the `set zero` command.

 Syntax:
         set zero <expression>
         show zero
3 zeroaxis
?set zeroaxis
?set nozeroaxis
?show zeroaxis
?zeroaxis
?nozeroaxis
 `set zeroaxis` draws the x-axis and y-axis. By default, this option is
 on.  `set nozeroaxis` causes GNUPLOT to omit the axes, and is
 equivalent to `set noxzeroaxis; set noyzeroaxis.`
 
 Syntax:
         set zeroaxis
         set nozeroaxis
         show zeroaxis
 See `set xzeroaxis` and `set yzeroaxis`.
3 zlabel
?set zlabel
?show zlabel
?zlabel
 The `set zlabel` command sets the z-axis label that is centered along
 the z axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set zlabel` with no parameters clears
 the label.
 
 Syntax: 
          set zlabel {"<label>"} {<xoff>}{,<yoff>}
          show zlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set zlabel ,1
 
 will change only the y offset of the zlabel, moving the label roughly
 one character height up.
 
 The zlabel will be drawn whenever surfaces or contours are plotted,
 in the space above the grid level.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 zrange
?set zrange
?show zrange
?zrange
 The `set zrange` command sets the vertical range that will be
 displayed. This command turns z axis autoscaling off.  The zrange is
 used only by `splot` and is ignored by `plot`.
 
 This range may also be specified on the `splot` command line.
 
 Syntax:
         set zrange [{<zmin> : <zmax>}]
 
 where <zmin> and <zmax> terms are constants or expressions.
 
 Both the <zmin> and <zmax> terms are optional. Anything omitted will
 not be changed, so
         set zrange [2:]
 changes zmin to 2 without affecting zmax.
3 ztics
?set ztics
?set noztics
?show ztics
?ztics
?noztics
 The `set ztics` and `set noztics` commands are similar to the `set
 xtics` and `set noxtics` commands. Please see `set xtics`.
2 shell
?shell
 The `shell` command spawns an interactive shell. To return to
 GNUPLOT, type `logout` if using VMS, `exit` or the END-OF-FILE
 character if using Unix, `endcli` if using AmigaDOS, or `exit` if
 using MS-DOS.
 
 A single shell command may be spawned by preceding it with the !
 character ($ if using VMS) at the beginning of a command line.
 Control will return immediately to GNUPLOT after this command is
 executed. For example, in VMS, AmigaDOS, or MS-DOS,
 
      ! dir
 
 prints a directory listing and then returns to GNUPLOT.
2 splot
 Three-dimensional surface and contour plotting is available in
 GNUPLOT with the `splot` command. See the `plot` command for features
 common to the `plot` command.
 
 See also `set contour`, `set cntrparam`, and `set surface`.
2 start-up
?startup
?start
?.gnuplot
 When GNUPLOT is run, it looks for an initialization file to load.
 This file is called `.gnuplot` on Unix and AmigaDOS systems, and
 `GNUPLOT.INI` on other systems. If this file is not found in the
 current directory, the program will look for it in the home directory
 (under AmigaDOS and MS-DOS, the environment variable GNUPLOT should
 contain the name of this directory).
 
 If this file is found, GNUPLOT executes the commands in this file.
 This is most useful for setting the terminal type and defining any
 functions or variables that are used often.
2 substitution
?substitution
 Command-line substitution is specified by a system command enclosed in
 backquotes. This command is spawned and the output it produces
 replaces the name of the command (and backquotes) on the command line.
 
 Newlines in the output produced by the spawned command are replaced
 with blanks.
 
 Command-line substitution can be used anywhere on the GNUPLOT command
 line.
 
 Example:
 
 This will run the program `leastsq` and replace `leastsq` (including
 backquotes) on the command line with its output:
 
          f(x) = `leastsq`
 
 or, in VMS
 
          f(x) = `run leastsq`
2 user-defined
?userdefined
?variables
 New user-defined variables and functions of one or two variables may be 
 declared and used anywhere.
 
 User-defined function syntax:
         <function-name> ( <dummy-var1> {,<dummy-var2>} ) =  <expression>
 
 where <expression> is defined in terms of <dummy-var1> and <dummy-var2>.

 User-defined variable syntax:
         <variable-name> = <constant-expression>
 
 Examples:
         w = 2
         q = floor(tan(pi/2 - 0.1))
         f(x) = sin(w*x)
         sinc(x) = sin(pi*x)/(pi*x)
         delta(t) = (t == 0)
         ramp(t) = (t > 0) ? t : 0
         min(a,b) = (a < b) ? a : b
         comb(n,k) = n!/(k!*(n-k)!)
 
 Note that the variable `pi` is already defined.
 
 See `show functions` and `show variables`.
2 bugs
?bugs
 The bessel functions do not work for complex arguments.
 
 The gamma function does not work for complex arguments.
 
 There is a bug in the stdio library for old Sun operating systems
 (SunOS Sys4-3.2). The "%g" format for 'printf' sometimes incorrectly
 prints numbers (e.g., 200000.0 as "2"). Thus, tic mark labels may be
 incorrect on a Sun4 version of GNUPLOT. A work-around is to rescale
 the data or use the `set format` command to change the tic mark format
 to "%7.0f" or some other appropriate format. This appears to have been
 fixed in SunOS 4.0.
 
 Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
 and SunOS 4.0, the 'sscanf' routine incorrectly parses "00 12" with
 the format "%f %f" and reads 0 and 0 instead of 0 and 12. This
 affects data input. If the data file contains x coordinates that are
 zero but are specified like '00', '000', etc, then you will read the
 wrong y values. Check any data files or upgrade the SunOS.
 It appears to have been fixed in SunOS 4.1.1.
 
 Microsoft C 5.1 has a nasty bug associated with the %g format for
 printf. When any of the formats "%.2g", "%.1g", "%.0g", "%.g" are
 used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.
 Numbers that should be printed in the %e format are incorrectly 
 printed in the %f format, with the wrong number of zeros after the 
 decimal point.

 To work around this problem, use the %e or %f formats explicitly.
 
 GNUPLOT, when compiled with Microsoft C, did not work correctly on two
 VGA displays that were tested. The CGA, EGA and VGA drivers should 
 probably be rewritten to use the Microsoft C graphics library.
 GNUPLOT compiled with Turbo C uses the Turbo C graphics drivers and 
 does work correctly with VGA displays.
 
 VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented %g 
 format for printf. The numbers are printed numerically correct, but 
 may not be in the requested format. The K&R second edition says that 
 for the %g format, %e is used if the exponent is less than -4 or greater 
 than or equal to the precision. The VAX uses %e format if the exponent 
 is less than -1. The VAX appears to take no notice of the precision 
 when deciding whether to use %e or %f for numbers less than 1.
 To work around this problem, use the %e or %f formats explicitly.
 From the VAX C 2.4 release notes:
 e,E,f,F,g,G  Result will always contain a decimal  point.
 For g and G, trailing zeros will not be removed from the result.
 
 VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
 %g format than release 2.4, but not much. Trailing decimal points are 
 now removed, but trailing zeros are still not removed from %g numbers 
 in exponential format.

 ULTRIX X11R3 has a bug that causes the X11 driver to display "every
 other" plot.  The bug seems to be fixed in DEC's release of X11R4 so
 newer releases of ULTRIX don't seem to have the problem.  Solutions for 
 older sites include upgrading the X11 libraries (from DEC or direct from 
 MIT) or defining ULTRIX_KLUDGE when compiling the x11.trm file.  Note 
 that the kludge is not an ideal fix, however.

 The constant HUGE was incorrectly defined in the NeXT OS 2.0 operating
 system.  HUGE should be set to 1e38 in plot.h. This error has been
 corrected in the 2.1 version of NeXT OS.

 Some older models of HP plotters do not have a page eject command 'PG'.
 The current HPGL driver uses this command in HPGL_reset.  This may need
 to be removed for these plotters.  The current PCL5 driver uses HPGL/2
 for text as well as graphics.  This should be modified to use scalable
 PCL fonts.

 Please report any bugs to bug-gnuplot@ames.arc.nasa.gov.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.gih version [192e5dd2b9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
?
 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 a line, separated by semicolons (;).
 Strings are indicated with quotes.  They may be either single or double
 quotation marks, e.g.,

          load "filename"
          cd 'dir'
 
 Any command-line arguments are assumed to be names of files containing 
 GNUPLOT commands, with the exception of standard X11 arguments, which
 are processed first. Each file is loaded with the `load` command, in the
 order specified. GNUPLOT exits after the last file is processed.  When
 no load files are named, gnuplot enters into an interactive mode.
 
 Commands may extend over several input lines, by ending each 
 line but the last with a backslash (\). The backslash must be the LAST
 character on each line. The effect is as if the backslash and newline
 were not there. That is, no white space is implied, nor is a comment
 terminated. Therefore, commenting out a continued line comments out
 the entire command (see `comment`).
 
 In this documentation, curly braces ({}) denote optional arguments to
 many commands, and a vertical bar (|) separates mutually exclusive
 choices.  GNUPLOT keywords or help topics are indicated by backquotes
 or `boldface` (where available).  Angle brackets (<>) are used to mark
 replaceable tokens.
 
 For help on any topic, type `help` followed by the name of the topic.

 The new GNUPLOT user should begin by reading about the `plot`
 command (type `help plot`).
?cd
 The `cd` command changes the working directory.
 
 Syntax:
         cd "<directory-name>"
 
 The directory name must be enclosed in quotes.
 
 Examples:
         cd 'subdir'
         cd ".."
?clear
 The `clear` command erases the current screen or output device as
 specified by `set output`. This usually generates a formfeed on
 hardcopy devices. Use `set terminal` to set the device type.
?line-editing
?editing
?history
 The Unix and IBM PC versions of GNUPLOT support command-line editing.
 Also, a history mechanism allows previous commands to be edited, and
 re-executed. After the command line has been edited, a newline or
 carriage return will enter the entire line regardless of where the
 cursor is positioned.

 The editing commands are as follows:
 
 `Line editing`:
 
 ^B moves back a single character.
 ^F moves forward a single character.
 ^A moves to the beginning of the line.
 ^E moves to the end of the line.
 ^H and DEL delete the previous character.
 ^D deletes the current character.
 ^K deletes from current position to the end of line.
 ^L,^R redraws line in case it gets trashed.
 ^U deletes the entire line.
 ^W deletes the last word.

 `History`:
 
 ^P moves back through history.
 ^N moves forward through history.

 On the IBM PC the use of a TSR program such as DOSEDIT or CED may be
 desired for line editing. For such a case GNUPLOT may be compiled with
 no line editing capability (default makefile setup). Set READLINE in the
 makefile and add readline.obj to the link file if GNUPLOT line editing
 is to be used for the IBM PC. The following arrow keys may be used
 on the IBM PC version if readline is used:
 
 Left  Arrow     - same as ^B.
 Right Arrow     - same as ^F.
 Ctl Left  Arrow - same as ^A.
 Ctl Right Arrow - same as ^E.
 Up    Arrow     - same as ^P.
 Down  Arrow     - same as ^N.
 (The readline function in gnuplot is not the same as the readline used
 in GNU BASH and GNU EMACS.  It is somewhat compatible however.) 
?comments
 Comments are supported as follows: a # may appear in most places in a line
 and GNUPLOT will ignore the rest of the line. It will not have this
 effect inside quotes, inside numbers (including complex numbers), inside
 command substitutions, etc. In short, it works anywhere it makes sense
 to work.
?environment
 A number of shell environment variables are understood by GNUPLOT.
 None of these are required, but may be useful.
 
 If GNUTERM is defined, it is used as the name of the terminal type to
 be used. This overrides any terminal type sensed by GNUPLOT on start
 up, but is itself overridden by the .gnuplot (or equivalent) start-up
 file (see `start-up`), and of course by later explicit changes.
 
 On Unix, AmigaDOS, and MS-DOS, GNUHELP may be defined to be the pathname
 of the HELP file (gnuplot.gih).

 On VMS, the symbol GNUPLOT$HELP should be defined as the name of 
 the help library for GNUPLOT.
 
 On Unix, HOME is used as the name of a directory to search for 
 a .gnuplot file if none is found in the current directory.
 On AmigaDOS and MS-DOS, GNUPLOT is used. On VMS, SYS$LOGIN: is used.
 See help start-up.
 
 On Unix, PAGER is used as an output filter for help messages.
 
 On Unix and AmigaDOS, SHELL is used for the `shell` command. On MS-DOS,
 COMSPEC is used for the `shell` command.

 On AmigaDOS, GNUFONT is used for the screen font.  For example:
 "setenv GNUFONT sapphire/14".

 On MS-DOS, if the BGI interface is used, the variable `BGI` is used to point 
 to the full path to the BGI drivers directory. Furthermore SVGA is used to
 name the Super VGA BGI driver in 800x600 res., and its mode of operation
 as 'Name.Mode'.
 For example, if the Super VGA driver is C:\TC\BGI\SVGADRV.BGI and mode 3 is
 used for 800x600 res., then: 'set BGI=C:\TC\BGI' and 'set SVGA=SVGADRV.3'.
?exit
?quit
 The commands `exit` and `quit` and the END-OF-FILE character
 will exit GNUPLOT. All these commands will clear the output device
 (as the `clear` command does) before exiting.
?expressions
 In general, any mathematical expression accepted by C, FORTRAN,
 Pascal, or BASIC is valid. The precedence of these operators is
 determined by the specifications of the C programming language.
 White space (spaces and tabs) is ignored inside expressions.
 
 Complex constants may be expressed as the {<real>,<imag>}, where <real>
 and <imag> must be numerical constants. For example, {3,2}
 represents 3 + 2i; {0,1} represents `i` itself. The curly braces 
 are explicitly required here.
?expressions functions
?functions
 The functions in GNUPLOT are the same as the corresponding functions
 in the Unix math library, except that all functions accept integer,
 real, and complex arguments, unless otherwise noted. The `sgn`
 function is also supported, as in BASIC.
?expressions functions abs
?functions abs
?abs
 The `abs` function returns the absolute value of its argument. The
 returned value is of the same type as the argument.
 
 For complex arguments, abs(x) is defined as the length of x in the
 complex plane [i.e.,  sqrt(real(x)**2 + imag(x)**2) ].
?expressions functions acos
?functions acos
?acos
 The `acos` function returns the arc cosine (inverse cosine) of its
 argument. `acos` returns its argument in radians.
?expressions functions arg
?functions arg
?arg
 The `arg` function returns the phase of a complex number, in radians.
?expressions functions asin
?functions asin
?asin
 The `asin` function returns the arc sin (inverse sin) of its argument.
 `asin` returns its argument in radians.
?expressions functions atan
?functions atan
?atan
 The `atan` function returns the arc tangent (inverse tangent) of its
 argument. `atan` returns its argument in radians.
?expressions functions besj0
?functions besj0
?besj0
 The `besj0` function returns the j0th Bessel function of its argument.
 `besj0` expects its argument to be in radians.
?expressions functions besj1
?functions besj1
?besj1
 The `besj1` function returns the j1st Bessel function of its argument.
 `besj1` expects its argument to be in radians.
?expressions functions besy0
?functions besy0
?besy0
 The `besy0` function returns the y0th Bessel function of its argument.
 `besy0` expects its argument to be in radians.
?expressions functions besy1
?functions besy1
?besy1
 The `besy1` function returns the y1st Bessel function of its argument.
 `besy1` expects its argument to be in radians.
?expressions functions ceil
?functions ceil
?ceil
 The `ceil` function returns the smallest integer that is not less than its
 argument. For complex numbers, `ceil` returns the smallest integer
 not less than the real part of its argument.
?expressions functions cos
?functions cos
?cos
 The `cos` function returns the cosine of its argument. `cos` expects its
 argument to be in radians.
?expressions functions cosh
?functions cosh
?cosh
 The `cosh` function returns the hyperbolic cosine of its argument.
 `cosh` expects its argument to be in radians.
?expressions functions exp
?functions exp
?exp
 The `exp` function returns the exponential function of its argument
 (`e` raised to the power of its argument).
?expressions functions floor
?functions floor
?floor
 The `floor` function returns the largest integer not greater than its
 argument. For complex numbers, `floor` returns the largest
 integer not greater than the real part of its argument.
?expressions functions gamma
?functions gamma
?gamma
 The `gamma` function returns the gamma function of the real part of
 its argument. For integer n, gamma(n+1) = n! .
 If the argument is a complex value, the imaginary component is ignored.
?expressions functions imag
?functions imag
?imag
 The `imag` function returns the imaginary part of its argument as a
 real number.
?expressions functions int
?functions int
?int
 The `int` function returns the integer part of its argument, truncated
 toward zero.
?expressions functions log
?functions log
?log
 The `log` function returns the natural logarithm (base `e`) of its
 argument.
?expressions functions log10
?functions log10
?log10
 The `log10` function returns the logarithm (base 10) of its argument.
?expressions functions real
?functions real
?real
 The `real` function returns the real part of its argument.
?expressions functions sgn
?functions sgn
?sgn
 The `sgn` function returns 1 if its argument is positive, -1 if its
 argument is negative, and 0 if its argument is 0. If the argument
 is a complex value, the imaginary component is ignored.
?expressions functions sin
?functions sin
?sin
 The `sin` function returns the sine of its argument. `sin` expects its
 argument to be in radians.
?expressions functions sinh
?functions sinh
?sinh
 The `sinh` function returns the hyperbolic sine of its argument. `sinh`
 expects its argument to be in radians.
?expressions functions sqrt
?functions sqrt
?sqrt
 The `sqrt` function returns the square root of its argument.
?expressions functions tan
?functions tan
?tan
 The `tan` function returns the tangent of its argument. `tan` expects
 its argument to be in radians.
?expressions functions tanh
?functions tanh
?tanh
 The `tanh` function returns the hyperbolic tangent of its argument.
 `tanh` expects its argument to be in radians.
?expressions operators
?operators
 The operators in GNUPLOT are the same as the corresponding operators
 in the C programming language, except that all operators accept
 integer, real, and complex arguments, unless otherwise noted.
 The ** operator (exponentiation) is supported, as in FORTRAN.
 
 Parentheses may be used to change order of evaluation.
?expressions operators binary
?operators binary
?binary
 The following is a list of all the binary operators and their
 usages:
 
  Symbol      Example      Explanation
   **          a**b          exponentiation
   *           a*b           multiplication
   /           a/b           division
   %           a%b         * modulo
   +           a+b           addition
   -           a-b           subtraction
   ==          a==b          equality
   !=          a!=b          inequality
   &           a&b         * bitwise AND
   ^           a^b         * bitwise exclusive OR
   |           a|b         * bitwise inclusive OR
   &&          a&&b        * logical AND
   ||          a||b        * logical OR
   ?:          a?b:c       * ternary operation
 
 (*) Starred explanations indicate that the operator requires
 integer arguments.
 
 Logical AND (&&) and OR (||) short-circuit the way they do in C.
 That is, the second && operand is not evaluated if the first is
 false; the second || operand is not evaluated if the first is true.
 
 The ternary operator evaluates its first argument (a). If it is
 true (non-zero) the second argument (b) is evaluated and returned,
 otherwise the third argument (c) is evaluated and returned.
?expressions operators unary
?operators unary
?unary
 The following is a list of all the unary operators and their
 usages:
 
  Symbol     Example      Explanation
   -           -a          unary minus
   ~           ~a        * one's complement
   !           !a        * logical negation
   !           a!        * factorial
 
 (*) Starred explanations indicate that the operator requires an
 integer argument.
 
 The factorial operator returns a real number to allow a greater range.
?help
 The `help` command displays on-line help. To specify information on a
 particular topic use the syntax:
 
         help {<topic>}
 
 If <topic> is not specified, a short message is printed about
 GNUPLOT. After help for the requested topic is given, help for a
 subtopic may be requested by typing its name, extending the help
 request. After that subtopic has been printed, the request may be
 extended again, or simply pressing return goes back one level to the
 previous topic. Eventually, the GNUPLOT command line will return.
?load
 The `load` command executes each line of the specified input file as
 if it had been typed in interactively. Files created by the `save`
 command can later be `load`ed. Any text file containing valid
 commands can be created and then executed by the `load` command.
 Files being `load`ed may themselves contain `load` commands. See
 `comment` for information about comments in commands.
 
 The `load` command must be the last command on the line.
 
 Syntax:
         load "<input-file>"
 
 The name of the input file must be enclosed in quotes.
 
 Examples:
 
         load 'work.gnu'
         load "func.dat"
 
 The `load` command is performed implicitly on any file names given as
 arguments to GNUPLOT. These are loaded in the order specified, and
 then GNUPLOT exits.
?pause
 The `pause` command displays any text associated with the command and
 then waits a specified amount of time or until the carriage return is
 pressed.  `pause` is especially useful in conjunction with `load` files.

 Syntax:
         pause <time> {"<string>"}

 <time> may be any integer constant or expression. Choosing -1 will
 wait until a carriage return is hit, zero (0) won't pause at all, and
 a positive integer will wait the specified number of seconds.
 
 Note: Since `pause` is not part of the plot it may interact with
 different device drivers differently (depending upon how text and
 graphics are mixed).
 
 Examples:
         pause -1    # Wait until a carriage return is hit
         pause 3     # Wait three seconds
         pause -1  "Hit return to continue"
         pause 10  "Isn't this pretty?  It's a cubic-spline."
 
?plot
?splot
 `plot` and `splot` are the primary commands of the program. They plot
 functions and data in many, many ways. `plot` is used to plot 2-d
 functions and data, while `splot` plots 3-d surfaces and data.

 Syntax:
 
         plot {ranges}  <function> {title} {style}
                     {, <function> {title} {style}...}
 
         splot {ranges}  <function> {title} {style}
                      {, <function> {title} {style}...}
 
 where <function> is either a mathematical expression, the name of a
 data file enclosed in quotes, or a pair (`plot`) or triple (`splot`)
 of mathematical expressions in the case of parametric functions.
 User-defined functions and variables may also be defined here.
 
 `plot` and `splot` commands can be as simple as
 
         plot sin(x)
 
 and
 
         splot x * y
 
 or as complex as (!)
 
         plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
?plot datafile
?plot data-file
?splot datafile
?splot data-file
?datafile
?data-file
?data
 Discrete data contained in a file can displayed by specifying the
 name of the data file (enclosed in quotes) on the `plot` or `splot`
 command line. Data files should contain one data point per line.
 Lines beginning with # (or ! on VMS) will be treated as comments
 and ignored. For `plot`s, each data point represents an (x,y)
 pair. For `splot`s, each point is an (x,y,z) triple. For `plot`s with
 error bars (see `plot errorbars`), each data point is either
 (x,y,ydelta) or (x,y,ylow,yhigh). In all cases, the numbers on each
 line of a data file must be separated by blank space. This blank
 space divides each line into columns.

 For `plot`s the x value may be omitted, and for `splot`s the x
 and y values may be omitted. In either case the omitted values are
 assigned the current coordinate number. Coordinate numbers start at 0
 and are incremented for each data point read.

 To specify other formats, see `plot datafile using`.
 
 In the `plot` command, blank lines in the data file cause a break in
 the plot. There will be no line drawn between the preceding and
 following points if the plot style is `lines` or `linespoints` (see
 `plot style`). This does not change the plot style, as would plotting
 the data as separate curves.
 
 This example compares the data in the file population.dat to a
 theoretical curve:
 
         pop(x) = 103*exp((1965-x)/10)
         plot [1960:1990] 'population.dat', pop(x)
 
 The file population.dat might contain:
 
         # Gnu population in Antarctica since 1965
         1965   103
         1970   55
         1975   34
         1980   24
         1985   10
 
 When a data file is plotted, `samples` and `iso_samples` are ignored.
 Curves plotted using the `plot` command are automatically extended to
 hold the entire curve. Similarly grid data plotted using the `splot`
 command is automatically extended, using the assumption that isolines
 are separated by blank lines (a line with only a CR/LF in it).
 
 Implicitly, there are two types of 3-d datafiles. If all the isolines
 are of the same length, the data is assumed to be a grid data, i.e.,
 the data has a grid topology. Cross isolines in the other parametric
 direction (the ith cross isoline passes thru the ith point of all the
 provided isolines) will also be drawn for grid data. (Note contouring
 is available for grid data only.) If all the isolines are not of the
 same length, no cross isolines will be drawn and contouring that data
 is impossible.
 
 For splot if 3-d datafile and using format (see `splot datafile using`)
 specify only z (height field), a non parametric mode must be specified.
 If, on the other hand, x, y, and z are all specified, a parametric
 mode should be selected (see `set parametric`) since data is defining a
 parametric surface.

 A simple example of plotting a 3-d data file is
 
         set parametric
         splot 'glass.dat'
 
 or
 
         set noparametric
         splot 'datafile.dat'
 
 where the file datafile.dat might contain:
 
         # The valley of the Gnu.
         10
         10
         10
 
         10
         5
         10
 
         10
         1
         10
 
         10
         0
         10
 
 Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ).
 Rows are separated by blank lines.

 On some computer systems with a popen function (UNIX), the datafile
 can be piped through a shell command by starting the file name
 with a '<'.  For example:

         pop(x) = 103*exp(x/10)
         plot '< awk "{print $1-1965 $2}" population.dat', pop(x)

 would plot the same information as the first population example
 but with years since 1965 as the x axis.
 
 For more information about 3-d plotting, see `splot`.
?plot datafile using
?plot data-file using
?splot datafile using
?splot data-file using
?using
 The format of data within a file can be selected with the `using` 
 option. An explicit scanf string can be used, or simpler column
 choices can be made.
 
 Syntax:
 
         plot "datafile" { using { <ycol> |
                                   <xcol>:<ycol> |
                                   <xcol>:<ycol>:<ydelta> |
                                   <xcol>:<ycol>:<ylow>:<yhigh> }
                                 {"<scanf string>"} } ...

 and

         splot "datafile" { using { <xcol>:<ycol>:<zcol> | <zcol> }
                                  {"<scanf string>"} } ...
 
 <xcol>, <ycol>, and <zcol> explicitly select the columns to plot from
 a space or tab separated multicolumn data file. If only <ycol> is
 selected for `plot`, <xcol> defaults to 1. If only <zcol> is selected
 for `splot`, then only that column is read from the file. An <xcol> of
 0 forces <ycol> to be plotted versus its coordinate number. <xcol>,
 <ycol>, and <zcol> can be entered as constants or expressions.

 If errorbars (see also `plot errorbars`) are used for `plot`s,
 ydelta (for example, a +/- error) should be provided as the third
 column, or ylow and yhigh as third and fourth columns.  These columns
 must follow the x and y columns.

 Scanf strings override any <xcol>:<ycol>(:<zcol>) choices, except for
 ordering of input, e.g.,
         plot "datafile" using 2:1 "%f%*f%f"
 causes the first column to be y and the third column to be x.

 If the scanf string is omitted, the default is generated based on the
 <xcol>:<ycol>(:<zcol>) choices. If the `using` option is omitted, "%f%f"
 is used for `plot` ("%f%f%f%f" for `errorbar` `plot`s) and "%f%f%f" is
 used for `splot`.
 
 Examples:
 
         plot "MyData" using "%*f%f%*20[^\n]%f" with lines

 Data are read from the file "MyData" using the format
 "%*f%f%*20[^\n]%f". The meaning of this format is: "%*f" ignore the
 first number, "%f" then read in the second and assign to x,
 "%*20[^\n]" then ignore 20 non-newline characters, "%f" then read in
 the y value.

         n=3;
         plot "MyData", "MyData" using n 

 causes GNUPLOT to plot the second and third columns of MyData versus
 the first column. The command 'n=4; replot' would then plot the second
 and fourth columns of MyData versus the first column.
 
         splot "glass.dat" using 1

 causes GNUPLOT to plot the first coordinate of the points of glass.dat
 as the z coordinate while ignoring the other two coordinates.
 
 Note: GNUPLOT first reads a line of the data file into a buffer and 
 then does a 
         sscanf(input_buffer, scanf_string, &x, &y{, &z});
 where 'x', 'y', and 'z' are of type 'float'. Any scanf string that
 specifies two (three for `splot`, three or four for `errorbars`) float
 numbers may be used.
?plot errorbars
?errorbars
 Error bars are supported for 2-d data file plots by reading one or
 two additional columns specifying ydelta or ylow and yhigh
 respectively. No support exists for x error bars or any error bars
 for `splot`s.

 In the default situation, GNUPLOT expects to see three or four
 numbers on each line of the data file, either (x, y, ydelta) or 
 (x, y, ylow, yhigh). The x coordinate must be specified. The order
 of the numbers must be exactly as given above. Data files in this
 format can easily be plotted with error bars:

         plot "data.dat" with errorbars

 The error bar is a vertical line plotted from (x, ylow) to (x,
 yhigh). If ydelta is specified instead of ylow and yhigh, 
 ylow=y-ydelta and yhigh=y+ydelta are derived. If there
 are only two numbers on the line, yhigh and ylow are both set to
 y. To get lines plotted between the data points, `plot` the
 data file twice, once with errorbars and once with lines.

 If y autoscaling is on, the y range will be adjusted to fit the
 error bars.

 The `using` option may be used to specify how columns of the data file
 are to be assigned to x, y, ydelta, ylow, and yhigh. The x column must
 be provided and both the x and y columns must appear before the
 errorbar columns. If three column numbers are given, they are x, y,
 and ydelta. If four columns are given, they are x, y, ylow, and
 yhigh.

 Examples:
 
         plot "data.dat" using 1:2:3:4 with errorbars
         plot "data.dat" using 3:2:6 with errorbars
         plot "data.dat" using 3:4:8:7 with errorbars
 
 The first example reads, x, y, ylow, and yhigh, from columns 1, 2, 3,
 and 4. This is equivalent to the default.  The second example reads x
 from the third column, y from second and ydelta from the sixth column.
 The third example reads x from the third column, y from the fourth,
 ylow from the eighth, and yhigh from seventh columns.
 
 See also `plot using` and `plot style`.
?plot parametric
?splot parametric
?parametric
 When in parametric mode (`set parametric`) mathematical expressions must
 be given in pairs for `plot` and in triplets for `splot`:
         plot sin(t),t**2
 or
         splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
 
 Data files are plotted as before, except any preceding parametric
 function must be fully specified before a data file is given as a
 plot. In other words, the x parametric function (sin(t) above) and
 the y parametric function (t**2 above) must not be interrupted with
 any modifiers or data functions; doing so will generate a syntax error
 stating that the parametric function is not fully specified.
 
 Ranges take on a different meaning when in parametric mode. The first
 range on the `plot` command is the `trange`, the next is the `xrange`,
 and the last is the `yrange`. For `splot` the order is `urange`,
 `vrange`, `xrange`, `yrange`, and finally `zrange`. The following
 `plot` command shows setting the `trange` to [-pi:pi], the `xrange` to
 [-1.3:1.3] and the `yrange` to [-1:1] for the duration of the plot:
         plot [-pi:pi] [-1.3:1.3] [-1:1] sin(t),t**2
 
 Other modifiers, such as `with` and `title`, may be specified only
 after the parametric function has been completed:
         plot sin(t),t**2 title 'Parametric example' with linespoints
?splot ranges
?plot ranges
?ranges
 The optional range specifies the region of the plot that will be
 displayed.
 
 Ranges may be provided on the `plot` and `splot` command line and
 affect only that plot, or in the `set xrange`, `set yrange`, etc.,
 commands, to change the default ranges for future plots.
 
 Syntax:
         [{<dummy-var> =} {<xmin> : <xmax>}] { [{<ymin> : <ymax>}] }
 
 where <dummy-var> is the independent variable (the defaults are x and
 y, but this may be changed with `set dummy`) and the min and max
 terms can be constant expressions.
 
 Both the min and max terms are optional. The ':' is also optional
 if neither a min nor a max term is specified. This allows '[ ]' to
 be used as a null range specification.
 
 Specifying a range in the `plot` command line turns autoscaling for
 that axis off for that plot. Using one of the `set` range commands
 turns autoscaling off for that axis for future plots, unless changed
 later. (See `set autoscale`).
 
 Examples:
 
 This uses the current ranges:
         plot cos(x)
 
 This sets the x range only:
         plot [-10:30] sin(pi*x)/(pi*x)
 
 This is the same, but uses t as the dummy-variable:
         plot [t = -10 :30]  sin(pi*t)/(pi*t)
 
 This sets both the x and y ranges:
         plot [-pi:pi] [-3:3]  tan(x), 1/x
 
 This sets only the y range, and turns off autoscaling on both axes:
         plot [ ] [-2:sin(5)*-8] sin(x)**besj0(x)
 
 This sets xmax and ymin only:
         plot [:200] [-pi:]  exp(sin(x))
 
 This sets the x, y, and z ranges:
         splot [0:3] [1:4] [-1:1] x*y
?plot style
?splot style
?style
?plot with
?with
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis (or from the grid base for `splot`) to each point. The
 `dots` style plots a tiny dot at each point; this is useful for
 scatter plots with many points.

 The `errorbars` style is only relevant to 2-d data file plotting. It
 is treated like `points` for `splot`s and function `plot`s. For data
 `plot`s, `errorbars` is like `points`, except that a vertical error 
 bar is also drawn: for each point (x,y), a line is drawn from
 (x,ylow) to (x,yhigh). A tic mark is placed at the ends of the error
 bar. The ylow and yhigh values are read from the data file's columns,
 as specified with the `using` option to plot. See `plot errorbars` for
 more information.
 
 Default styles are chosen with the `set function style` and
 `set data style` commands.
 
 By default, each function and data file will use a different 
 line type and point type, up to the maximum number of available 
 types. All terminal drivers support at least six different point
 types, and re-use them, in order, if more than six are required.
 The LaTeX driver supplies an additional six point types (all variants
 of a circle), and thus will only repeat after twelve curves are
 plotted with points.
 
 If desired, the style and (optionally) the line type and point type
 used for a curve can be specified.

 Syntax:
 
         with <style> {<linetype> {<pointtype>}}
 
 where <style> is either `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`. The <linetype> and <pointtype> are positive
 integer constants or expressions and specify the line type and point
 type to be used for the plot. Line type 1 is the first line type used
 by default, line type 2 is the second line type used by default, etc.
 
 Examples:
 
 This plots sin(x) with impulses:
         plot sin(x) with impulses
 
 This plots x*y with points, x**2 + y**2 default:
         splot x*y w points, x**2 + y**2
 
 This plots tan(x) with the default function style, "data.1" with lines:
         plot [ ] [-2:5] tan(x), "data.1" with l
 
 This plots "leastsq.dat" with impulses:
         plot 'leastsq.dat' w i
 
 This plots "exper.dat" with errorbars and lines connecting the points:
         plot 'exper.dat' w lines, 'exper.dat' w errorbars
 Here 'exper.dat' should have three or four data columns.
 
 This plots x**2 + y**2 and x**2 - y**2 with the same line type:
         splot x**2 + y**2 with line 1, x**2 - y**2 with line 1
 
 This plots sin(x) and cos(x) with linespoints, using the
 same line type but different point types:
         plot sin(x) with linesp 1 3, cos(x) with linesp 1 4
 
 This plots file "data" with points style 3:
         plot "data" with points 1 3 
 Note that the line style must be specified when specifying the point
 style, even when it is irrelevant. Here the line style is 1 and the
 point style is 3, and the line style is irrelevant.
 
 See `set style` to change the default styles.
?plot title
?splot title
 A title of each plot appears in the key. By default the title is
 the function or file name as it appears on the plot command line.
 The title can be changed by using the `title` option. This option 
 should precede any `with` option.
 
 Syntax:
         title "<title>"
 
 where <title> is the new title of the plot and must be enclosed in
 quotes. The quotes will not be shown in the key.
 
 Examples:
 
 This plots y=x with the title 'x':
         plot x
 
 This plots the "glass.dat" file with the title 'surface of revolution':
         splot "glass.dat" title 'surface of revolution'
 
 This plots x squared with title "x^2" and "data.1" with title
 'measured data':
         plot x**2 title "x^2", "data.1" t 'measured data'
?print
 The `print` command prints the value of <expression> to the screen.
 
 Syntax:
         print <expression>
 
 See `expressions`.
?pwd
 The `pwd` command prints the name of the working directory to the screen.
 
 Syntax:
         pwd
?quit
 The `exit` and `quit` commands and END-OF-FILE character will exit
 GNUPLOT. All these commands will clear the output device (as the
 `clear` command does) before exiting.
?replot
 The `replot` command without arguments repeats the last `plot` or `splot`
 command. This can be useful for viewing a plot with different `set`
 options, or when generating the same plot for several devices.
 
 Arguments specified after a `replot` command will be added onto the last
 `plot` (`splot`) command (with an implied ',' separator) before it is
 repeated. `replot` accepts the same arguments as the `plot` (`splot`)
 commands except that ranges cannot be specified. See `command-line
 editing` for ways to edit the last `plot` (`splot`) command.
?save
 The `save` command saves user-defined functions, variables, set
 options or all three plus the last `plot` (`splot`) command to the
 specified file.
 
 Syntax:
         save  {<option>} "<filename>"
 
 where <option> is `functions`, `variables` or `set`. If no option is
 used, GNUPLOT saves functions, variables, set options and the last `plot`
 (`splot`) command.
 
 `save`d files are written in text format and may be read by the `load`
 command.
 
 The filename must be enclosed in quotes.
 
 Examples:
 
         save "work.gnu"
         save functions 'func.dat'
         save var 'var.dat'
         save set "options.dat"
?set
?show
 The `set` command sets LOTS of options.
 
 The `show` command shows their settings. `show all` shows all the
 settings.
?set angles
?show angles
?angles
 By default, GNUPLOT assumes the independent variable in polar plots
 is in units of radians. If `set angles degrees` is specified before
 `set polar` then the default range is [0:360] and the independent
 variable has units of degrees. This is particularly useful for
 plots of data files. The angle setting also hold for the 3-d
 mapping as set via the `set mapping` command.

 Syntax:
         set angles { degrees | radians }
         show angles
?set arrow
?set noarrow
?show arrow
?arrow
?noarrow
 Arbitrary arrows can be placed on a plot using the `set arrow`
 command.
 
 Syntax:
 
          set arrow {<tag>} {from <sx>,<sy>{,<sz>}} 
                            {to <ex>,<ey>{,<ez>}} {{no}head}
          set noarrow {<tag>}
          show arrow
 
 
 Unspecified coordinates default to 0. The x, y, and z values are in
 the graph's coordinate system. The z coordinate is only used in
 `splot` commands. <tag> is an integer that identifies the arrow. If no
 tag is given, the lowest unused tag value is assigned automatically.
 The tag can be used to delete or change a specific arrow. To change
 any attribute of an existing arrow, use the `set arrow` command with
 the appropriate tag, and specify the parts of the arrow to be
 changed. Specifying nohead requests the arrow be drawn without a head
 (yielding a line segment). By default, arrows have heads.
 
 Arrows outside the plotted boundaries are permitted but may cause
 device errors.
 
 Examples:
 
 To set an arrow pointing from the origin to (1,2), use:
          set arrow to 1,2
 To set an arrow from (-10,4,2) to (-5,5,3), and tag the arrow number
 3, use:
          set arrow 3 from -10,4,2 to -5,5,3
 To change the preceding arrow begin at 1,1,1, without an arrow head,
 use:
          set arrow 3 from 1,1,1 nohead
 To delete arrow number 2 use:
          set noarrow 2
 To delete all arrows use:
          set noarrow
 To show all arrows (in tag order) use:
          show arrow
?set autoscale
?set noautoscale
?show autoscale
?autoscale
?noautoscale
 Auto scaling may be set individually on the x, y or z axis
 or globally on all axes. The default is to autoscale all axes.
 
 When autoscaling, the plot range is automatically computed and the
 dependent axis (y for a `plot` and z for `splot`) is scaled to
 include the range of the function or data being plotted.
 
 If autoscaling of the dependent axis (y or z) is not set, the
 current y or z range is used.
 
 See `set yrange` or `set zrange`.
 
 Autoscaling the independent variables (x for `plot` and x,y for
 `splot`) is a request to set the domain to match any data file being
 plotted. If there are no data files then autoscaling an independent
 variable has no effect. In other words, in the absence of a data
 file, functions alone do not affect the x range (or the y range if
 plotting z = f(x,y)).
 
 See `set xrange`, or `set yrange`.
 
 The behavior of autoscaling remains consistent in parametric mode,
 however, there are more dependent variables and hence more control
 over x, y, and z plot scales. In parametric mode, the independent or
 dummy variable is t for `plot`s and u,v for `splot`s.  Autoscale in
 parametric mode, then, controls all ranges (t, u, v, x, y, and z) and
 allows x, y, and z to be fully autoscaled.
 
 See `set parametric`.
 
 Syntax:
         set autoscale <axes>
         set noautoscale <axes>
         show autoscale
 
 where <axes> is either `x`, `y`, `z` or `xy`. If <axes> is not given
 then all axes are assumed.
 
 Examples:
 
 This sets autoscaling of the y axis. x axis autoscaling is not
 affected.
         set autoscale y
 
 This sets autoscaling of the x and y axes.
         set autoscale xy
 
 This sets autoscaling of the x, y and z axes.
         set autoscale
 
 This disables autoscaling of the x, y and z axes.
         set noautoscale
 
 This disables autoscaling of the z axis only.
         set noautoscale z
?autoscale parametric
?set autoscale t
 When in parametric mode (`set parametric`) the xrange is as
 fully scalable as the yrange. In other words, in parametric
 mode the x axis can be automatically scaled to fit the range
 of the parametric function that is being plotted. Of course,
 the y axis can also be automatically scaled just as in the
 non-parametric case. If autoscaling on the x axis is not set,
 the current x range is used.
 
 When there is a mix of data files and functions, the xrange of
 the functions is selected as that of the data files if autoscale
 is true for x. While this keeps the behavior compatible with
 non-parametric plotting, it may not be retained in the future.
 The problem is that, in parametric mode, the x and y ranges are
 not as distinguishable as in the non-parametric mode and this
 behavior may not be the most useful.
 
 For completeness a last command `set autoscale t` is accepted.
 However, the effect of this "scaling" is very minor. When
 GNUPLOT determines that the t range would be empty it makes a
 small adjustment if autoscaling is true. Otherwise, GNUPLOT
 gives an error. Such behavior may, in fact, not be very useful
 and the command `set autoscale t` is certainly questionable.
 
 `splot` extends the above idea similarly. If autoscaling is set then
 x, y, and z ranges are computed and each axis scaled to fit the
 resulting data.
?set border
?set noborder
?show border
?border
?noborder
 The `set border` and `set noborder` commands controls the display of
 the plot borders for the `plot` and `splot` commands.
 
 Syntax:
         set border
         set noborder
         show border
?set clip
?set noclip
?show clip
?clip
?noclip
 GNUPLOT can clip data points and lines that are near the boundaries
 of a plot. 
 
 Syntax:
         set clip <clip-type>
         set noclip <clip-type>
         show clip

 Three clip types are supported by GNUPLOT: `points`, `one`, and `two`.
 One, two, or all three clip types may be active for a single plot.

 The `points` clip type forces GNUPLOT to clip (actually, not plot at
 all) data points that fall within but too close to the boundaries
 (this is so the large symbols used for points will not extend outside
 the boundary lines). Without clipping points near the boundaries may
 look bad; try adjusting the x and y ranges.

 Setting the `one` clip type causes GNUPLOT to plot the line segments
 which have only one of the two endpoints with the plotting region.
 Only the in-range portion of the line is drawn.  The alternative is to
 not draw any portion of the line segment.

 Some lines may have both endpoints out of range, but pass through the
 plotting area. Setting the `two` clip-type allows the visible portion
 of these lines to be drawn.
 
 In no case is a line drawn outside the plotting area.

 The defaults are `noclip points`, `clip one`, and `noclip two`.

 To check the state of all forms of clipping, use
         show clip

 For backward compatibility with older versions, the following forms
 are also permitted.
        set clip
        set noclip
 `set clip` is synonymous with `set clip points`. `set noclip` turns
 off all three types of clipping.
?set cntrparam
?show cntrparam
?cntrparam
 Sets the different parameters for the contouring plot (see also `contour`).
 
 Syntax:
         set cntrparam { { linear | cubicspline | bspline } |
                         points <n> |
                         levels <n> |
                         order <n> }
 
 This command controls the way contours are plotted. <n> should be an
 integral constant expression. The parameters are:
 
 `linear`, `cubicspline`, `bspline` - Controls type of approximation or
 interpolation. If `linear`, then the contours are drawn piecewise
 linear, as extracted from the surface directly. If `cubicspline`, then
 piecewise linear contours are interpolated to form a somewhat smoother
 contours, but which may undulate. The third option is the uniform
 `bspline`, which only approximates the piecewise linear data but is
 guaranteed to be smoother.
 
 `points` - Eventually all drawings are done with piecewise linear
 strokes.  This number controls the number of points used to
 approximate a curve.  Relevant for `cubicspline` and `bspline` modes
 only.
 
 `levels` - Number of contour levels. If the surface is bounded by zmin
 and zmax then contours will be generated from zmin+dz to zmax-dz
 in steps of size dz, where dz = (zmax - zmin) / (levels + 1).
 
 `order`  - Order of the bspline approximation to be used. The bigger this
 order is, the smoother the resulting contour.  (Of course, higher order
 bspline curves will move further away from the original peicewise linear
 data.)  This option is relevant for `bspline` mode only. Allowed values are 
 integers in the range from 2 (linear) to 10.
?set contour
?show contour
?contour
 Enable contour drawing for surfaces. This option is available for `splot`
 only.
 
 Syntax:
         set contour { base | surface | both }
         set nocontour
 
 If no option is provided to `set contour`, the default is `base`.
 The three options specify where to draw the contours: `base` draws
 the contours on the grid base where the x/ytics are placed, `surface`
 draws the contours on the surfaces themselves, and `both` draws the
 contours on both the base and the surface.
 
 See also `set cntrparam` for the parameters that affect the drawing of 
 contours.
?set data style
?show data style
?data style
 The `set data style` command changes the default plotting style
 for data plots.

 Syntax:
         set data style 
         show data style 
         set data style <style-choice>

 In the first case, `set data style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show data style` shows the current default
 plotting style for data.  `set data style dots` would actually 
 change the default plotting style.  See also `plot`.
?set dummy
?show dummy
?dummy
 By default, GNUPLOT assumes that the independent variable for the
 `plot` command is x, and the independent variables for the `splot`
 command are x and y. They are called the dummy variables because it
 is just a notation to indicate the independent variables. The `set
 dummy` command changes these default dummy variable names. For
 example, it may be more convenient to call the dummy variable t
 when plotting time functions:
 
         set dummy t
         plot sin(t), cos(t)
 
 Syntax:
         set dummy <dummy-var>{,<dummy-var>}
         show dummy
 
 Examples:
         set dummy u,v
         set dummy ,s
 
 to set both dummy variables to u and v or set only the second
 variable to s.
 
 The `set parametric` command also changes the dummy variables (to t
 for `plot` and u,v for `splot`s).
 
?set format
?show format
?format
 The format of the tic-mark labels can be set with the `set format`
 command. The default format for both axes is "%g", but other formats
 such as "%.2f" or "%3.0fm" are often desirable. Anything accepted by
 printf when given a double precision number, and then accepted by the
 terminal, will work. In particular, the formats f, e, and g will work,
 and the d, o, x, c, s, and u formats will not work.
 
 Syntax:
         set format {<axes>} {"<format-string>"}
         show format
 
 where <axes> is either `x`, `y`, `z`, `xy`, or nothing (which is the
 same as `xy`). The length of the string representing a ticmark (after
 formatting with printf) is restricted to 100 characters.  If the
 format string is omitted, the format will be returned to the default
 "%g". For LaTeX users, the format "$%g$" is often desirable.  If the
 empty string "" is used, no label will be plotted with each tic,
 though the tic mark will still be plotted. To eliminate all tic marks,
 use `set noxtics` or `set noytics`.
 
 See also `set xtics` and `set ytics` for more control over tic labels.
?set function style
?show function style
?function style
 The `set function style` command changes the default plotting style
 for functions.

 Syntax:
         set function style 
         show function style 
         set function style <style-choice>

 In the first case, `set function style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show function style` shows the current default
 plotting style for functions.  `set function style linespoints`
 would actually change the default plotting style.  See also `plot`.
?show functions
 The `show functions` command lists all user-defined functions and
 their definitions.
 
 Syntax:
         show functions
?set grid
?show grid
?grid
 The optional `set grid` draws a grid at the tic marks with the axis
 linetype.
 
 Syntax:
         set grid
         set nogrid
         show grid
?set hidden3d
?show hidden3d
 The `set hidden3d` command enables hidden line removal for explicit
 surface plotting (see `splot`).
 Hidden line removal may be used for both explicit functions
 and for explicit data where gnuplot plot is in nonparametric mode (see
 `set parametric`).
 
 When this flag is set both the surface hidden portion and possibly
 its hidden contours (see `set contour`) as well as the hidden grid will be
 removed. Labels and arrows are always visible and are unaffected by this
 command.
 
 Each surface has its hidden part removed with respect to itself, if more
 than one surface is ploted. This mode is meaningfull when surfaces are
 plotted using line style drawing only.

 Syntax:
         set hidden3d
         set nohidden3d
         show hidden3d
?set isosamples
?show isosamples
?isosamples
 An isoline is a curve parametrized by one of the surface parameters
 while the other surface parameter is fixed. Isolines are a simple
 means to display a surface. By fixing the u parameter of surface
 s(u,v), the iso-u lines of the form c(v) = s(u0,v) are produced, and
 by fixing the v parameter, the iso-v lines of the form c(u) = s(u,v0)
 are produced.
 
 The isoline density of surfaces may be changed by the `set isosamples`
 command. By default, sampling is set to 10 isolines per u or v axis.
 A higher sampling rate will produce more accurate plots, but will take
 longer. This parameter has no effect on data file plotting.
 
 Syntax:
         set isosamples <expression>
         show isosamples
?set key
?show key
?key
 The `set key` enables a key describing curves on a plot.  By default
 the key is placed in the upper right corner of the plot.
 
 Syntax:
         set key
         set key <x>,<y>{,<z>}
         set nokey
         show key
 
 The coordinates <x>, <y> (and <z> for `splot`s) specify the location
 of the key on the plot. The key is drawn as a sequence of lines, with
 one plot described on each line. On the right hand side of each line
 is a representation that attempts to mimic the way the curve is
 plotted.  On the left side of each line is the text description,
 obtained from the `plot` command. See `plot title` to change this
 description. The lines are vertically arranged so an imaginary
 straight line divides the left- and right-hand sides of the key. It is
 the coordinates of this line that are specified with the `set key`
 command. In a `plot`, only the x and y coordinates are used to specify
 the line position.  For a `splot`, x, y and z are all being used as a
 3-d location mapped using the same mapping as the plot itself to form
 the required 2-d screen position of the imaginary line.
 
 Some or all of the key may be outside of the plot boundary, although
 this may interfere with other labels and may cause an error on some
 devices.
 
 Examples:
 
 This places the key at the default location:
         set key
 This disables the key:
         set nokey
 This places a key at coordinates 2,3.5,2
         set key 2,3.5,2
?set label
?set nolabel
?show label
?label
?nolabel
 Arbitrary labels can be placed on the plot using the `set label`
 command.  If the z coordinate is given on a `plot` it is ignored; if
 it is missing on a `splot` it is assumed to be 0.
 
 Syntax:
 
          set label {<tag>} {"<label_text>"} {at <x>,<y>{,<z>}}
                            {<justification>}
          set nolabel {<tag>}
          show label
 
 
 The text defaults to "", and the position to 0,0,0.  The <x>, <y>, and
 <z> values are in the graph's coordinate system.  The tag is an
 integer that is used to identify the label. If no <tag> is given, the
 lowest unused tag value is assigned automatically. The tag can be used
 to delete or change a specific label. To change any attribute of an
 existing label, use the `set label` command with the appropriate tag,
 and specify the parts of the label to be changed.
 
 By default, the text is placed flush left against the point x,y,z.
 To adjust the way the label is positioned with respect to the point
 x,y,z, add the parameter <justification>, which may be `left`, `right`
 or `center`, indicating that the point is to be at the left, right or
 center of the text. Labels outside the plotted boundaries are
 permitted but may interfere with axes labels or other text.
 
 Examples:
 
 To set a label at (1,2) to "y=x" use:
          set label "y=x" at 1,2
 To set a label "y=x^2" with the right of the text at (2,3,4), and tag
 the label number 3, use:
          set label 3 "y=x^2" at 2,3,4 right
 To change the preceding label to center justification, use:
          set label 3 center
 To delete label number 2 use:
          set nolabel 2
 To delete all labels use:
          set nolabel
 To show all labels (in tag order) use:
          show label
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
?set logscale
?set nologscale
?show logscale
?logscale
?nologscale
 Log scaling may be set on the x, y, and z axes.
 
 Syntax:
         set logscale <axes>
         set nologscale <axes>
         show logscale
 
 where <axes> may be any combinations of `x`, `y`, and `z`, in any
 order.  If <axes> is not given then all three axes are assumed.  The
 command `set logscale` turns on log scaling on the specified axes,
 while `set nologscale` turns off log scaling.
 
 Examples:
 
 To enable log scaling in both x and z axes:
        set logscale xz
 To disable z axis log scaling:
        set nologscale z
?set mapping
?show mapping
?mapping
 
 Syntax:
         set mapping { cartesian | spherical | cylindrical }
 
 Data for `splot`s are usually in regular Euclidean space and are
 provided in Cartesian coordinates. Such 3-d data require three
 coordinates (x, y and z) or one coordinate (only z) in each line in
 the data file.  In order to be able to use spherical or cylindrical
 coordinate systems, use the `set mapping` command. In both cases two
 coordinates are expected in each line of the data. For a spherical
 coordinate system, these are theta and phi (in units as specified by
 `set angles`) and the mapping is:
 
         x = cos( theta ) * cos( phi )
         y = sin( theta ) * cos( phi )
         z = sin( phi )
 
 For a cylindrical coordinate system, the mapping uses two variables,
 theta (in units as specified by `set angles`) and z:
 
         x = cos( theta )
         y = sin( theta )
         z = z
 
 Again, note that mapping will affect data file `splot`s only.
?set offsets
?show offsets
?offsets
 The amount of the graph that the plot takes up may be controlled to
 some extent with the `set offsets` command. This command takes four
 offset arguments: <left>, <right>, <top> and <bottom>. By default,
 each offset is 0. Each offset may be a constant or an expression. Left
 and right offsets are given in units of the x axis, while top and
 bottom offsets are given in units of the y axis. The plot of sin(x),
 displayed with offsets of 0, 0, 2, 2 will take up 1/3 of the
 displayed y axis. Offsets are particularly useful with polar
 coordinates as a means of compensating for aspect ratio distortion.
 Offsets are ignored in `splot`s.
 
 Syntax:
         set offsets <left>, <right>, <top>, <bottom>
         show offsets
?set output
?show output
?output
 By default, plots are displayed to the standard output. The `set
 output` command redirects the display to the specified file or
 device.
 
 Syntax:
         set output {"<filename>"}
         show output
 
 The filename must be enclosed in quotes. If the filename is
 omitted, output will be sent to the standard output.

 On machines with popen functions (UNIX), output can be piped
 through a shell command if the first letter of the filename
 is '|'.  For instance,
 
 Syntax:
         set output "|lpr -Plaser filename"
         set output "|lp -dlaser filename"

 (On MSDOS machines, set output "prn" will direct the output
 to the default printer.)

?set parametric
?set noparametric
?show parametric
?parametric
?noparametric
 The `set parametric` command changes the meaning of `plot` (`splot`)
 from normal functions to parametric functions. The command
 `set noparametric` changes the plotting style back to normal,
 single-valued expression plotting.
 
 In 2-d plotting, a parametric function is determined by a pair
 of parametric functions operating on a parameter. An example
 of a 2-d parametric function would be plot sin(t),cos(t) (which
 defines a circle).
 
 For 3-d plotting, the surface is described as x=f(u,v), y=g(u,v),
 z=h(u,v). Therefore a triplet of functions are required. An example of
 3-d parametric function would be cos(u)*cos(v),cos(u)*sin(v),sin(u)
 (which defines a sphere). It takes three parametric function
 specifications in terms of the parametric dummy arguments to describe
 a single graph.
 
 The total set of possible plots is a superset of the simple f(x)
 style plots, since the two (three) functions can describe the
 x and y (and z) values to be computed separately. In fact,
 plots of the type t,f(t) (u,v,f(u,v)) are equivalent to those
 produced with f(x) when the x values are computed using the
 identity function as the first function.
 
 Note that the order the parametric functions are specified is
 xfunction, yfunction (and zfunction) and that each operates over the
 common parametric domain.
 
 Also, the `set parametric` function implies a new range of values.
 Whereas the normal f(x) and f(x,y) style plotting assume an xrange
 and yrange (and zrange), the parametric mode additionally specifies a
 trange, urange, and vrange. These ranges may be set
 directly with `set trange`, `set urange` and `set vrange`, or by
 specifying the range on the `plot` or `splot` commands. Currently
 the default range for these parametric variables is [-5:5].
 Setting the ranges to something more meaningful is expected.
?set polar
?set nopolar
?show polar
?polar
?nopolar
 The `set polar` command changes the meaning of the plot from
 rectangular coordinates to polar coordinates. In polar coordinates,
 the dummy variable (x) is an angle. The range of this angle is changed
 from whatever it was to [0:2*pi], or, if degree unit has been selected,
 to [0:360] (see `set angles`).
 
 The command `set nopolar` changes the meaning of the plot back to the
 default rectangular coordinate system. The range of x is changed from
 whatever it was to [-10:10].
 
 The `set polar` command is not supported for `splot`s.  See the
 `set mapping` command for similar functionality for `splot`s.
 
 While in polar coordinates the meaning of an expression in x is really
 r = f(x), where x is an angle of rotation. The xrange controls the
 domain (the angle) of the function, and the yrange controls the range
 (the radius). The plot is plotted in a rectangular box, and the x and
 y axes are both in units of the radius. Thus, the yrange controls both
 dimensions of the plot output. The tics and units are written along
 the axes rather than at the left and bottom. These unit are offset by
 <rmin> specified by the `rrange` (See `set rrange`). It is not
 possible to specify different output dimensions in the x or y
 directions. The yrange can be used to shift the plot diagonally to
 display only the first or third quadrants.
 
 Syntax:
         set polar
         set nopolar
         show polar
 Example:
         set polar
         plot x*sin(x)
         plot [-2*pi:2*pi] [-3:3] x*sin(x)
 The first plot uses the default polar angular domain of 0 to 2*pi.
 The radius (and the size of the plot) is scaled automatically. The
 second plot expands the domain, and restricts the range of the radius
 (and the size of the plot) to [-3:3].
?set rrange
?show rrange
?rrange
 The `set rrange` command sets the radial range used to compute x and y
 values when in polar mode. If not in polar mode (see `set polar`) then
 this range is not used. Use of this command offsets the polar
 singularity to the <rmin> value and shifts the units on the axes tic
 marks. For instance, `set rrange [-40:40]` would set the origin to -40
 and would plot values of radial values between -40 to 40. Thus, if
 360 degrees of data were plotted, then the plot would extend 80 units
 in radially from the origin.  To view the entire plot,  a 
 `set yrange [-80:80]` command would create a square viewport with
 a circular plot tangent at the axes.  Because `xrange` is used
 specify the angular extent, only a square viewport can be specified
 by `yrange`.  For instance, `set yrange [0:80]` would display the
 first quadrant and `set yrange [-80:0]` would display the third
 quadrant.  Any square viewport of any size can be specified but it
 is constrained to be centered on a 45 degree line.
 
 This range may also be specified on the `plot` command line when in
 polar mode.
 
 Syntax:
         set rrange [{<rmin> : <rmax>}]
 
 where <rmin> and <rmax> terms are constants or expressions.
 
 Both the <rmin> and <rmax> terms are optional. Anything omitted will
 not be changed, so 
         set rrange [:10]
 changes rmax to 10 without affecting rmin.
?set samples
?show samples
?samples
 The sampling rate of functions may be changed by the `set samples`
 command. By default, sampling is set to 100 points. A higher sampling
 rate will produce more accurate plots, but will take longer. This
 parameter no longer has any effect on data-file plotting.
 
 Syntax:
         set samples <expression>
         show samples
?set size
?show size
?size
 The `set size` command scales the displayed size of the plot.  On some
 terminals, changing the size of the plot will result in text being
 misplaced. Increasing the size of the plot may produce strange
 results. Decreasing is safer.
 
 Syntax:
 
         set size {<xscale>,<yscale>}
         show size
 
 The <xscale> and <yscale> values are the scaling factors for the size.
 The defaults (1,1) are selected if the scaling factors are omitted.
 
 Examples: 
 
 To set the size to normal size use:
         set size
 To make the plot half size use:
         set size 0.5,0.5
 To make a landscape plot have a 1:1 aspect ratio in polar mode use:
         set size 0.721,1.0
 To show the size use:
         show size
 
 For the LaTeX and Fig terminals the default size (scale factor 1,1)
 is 5 inches wide by 3 inches high. The big Fig terminal (`bfig`) is 7
 inches wide by 5 inches high. The postscript default is landscape mode
 10 inches wide and 7 inches high. 
 Note that the size of the plot includes the space used by the labels; 
 the plotting area itself is smaller. 
?set style
?show style
?style
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis to each point. The `dots` style plots a tiny dot at
 each data point; this is useful for scatter plots with many points.
 
 The `errorbars` style is relevant only for to data file `plot`s. It is
 treated like `points` for function `plot`s and `splot`s. For data file
 `plot`s, `errorbars` is like `points`, except that a vertical error
 bar is also drawn: for each point (x,y), a line is drawn from (x,ylow)
 to (x,yhigh). A tic mark is placed at the ends of the error bar. The
 ylow and yhigh values are read from the data file's third and fourth
 columns, or as specified with the `using` option to plot.  See `plot
 errorbars` for more information.
 
 Default styles are chosen with the `set function style` and `set
 data style` commands. See `plot style` for information about how
 to override the default plotting style for individual functions.
 
 Syntax:
         set function style <style>
         set data style <style>
         show function style
         show data style
 
 where <style> is `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`.
?set surface
?set nosurface
?show surface
?surface
 `set surface` controls the display of surfaces. It is useful if
 contours are to be displayed by themselves. Whenever `set nosurface`
 is issued, no surface isolines/mesh will be drawn. See also `set
 contour`.
 
 Syntax:
         set surface
         set nosurface
         show surface
?set terminal
?show terminal
?terminal
 GNUPLOT supports many different graphics devices. Use the `set
 terminal` command to select the type of device for which GNUPLOT
 will produce output.
 
 Syntax:
         set terminal {<terminal-type>}
         show terminal
 
 If <terminal-type> is omitted, GNUPLOT will list the available
 terminal types. <terminal-type> may be abbreviated.
 
 Use `set output` to redirect this output to a file or device.

 Several terminals have additional options. For example, see `dumb`,
 `iris4d`, `hpljii` or `postscript`.
?set terminal dumb
?dumb
 The dumb terminal driver has an optional size specification.

 Syntax:
         set terminal dumb {<xsize> <ysize>}

 where <xsize> and <ysize> set the size of the dumb terminals. Default
 is 79 by 24.

 Examples:
         set term dumb
         set term dumb 79 49 #(VGA screen - why would anyone want to do that!?)
 
?set terminal hpljii
?hpljii
 The HP LaserJet II and HP DeskJet drivers have a single option.

 Syntax:
         set terminal hpljii {<resolution>}
         set terminal hpdj   {<resolution>}

 where <resolution> is the resolution of the output in dots per inch.
 It must be `75`, `100`, `150` or `300`.

 Example:
         set terminal hpljii 150
 
?set terminal iris4d
?iris4d
 The iris4d driver can operate in two modes.

 Syntax:
         set terminal iris4d {24}

 If the hardware supports only 8 bits, use the default `set terminal
 iris4d`. If, however, the hardware supports 24 bits (8 per
 red/green/blue), use `set terminal iris4d 24`.

 When using 24-bit mode, the colors can be directly specified via the
 file .gnuplot_iris4d that is searched in the current directory and
 then in the home directory specified by the HOME environment variable.
 This file holds RGB values for the background, border, labels and nine
 plotting colors, in that order. For example, here is a file containing
 the default colors:
 
         85   85   85     /* Back Ground */
         0    0    0      /* Boundary */
         170  0    170    /* Labeling */
         85   255  255    /* Plot Color 1 */
         170  0    0      /* Plot Color 2 */
         0    170  0      /* Plot Color 3 */
         255  85   255    /* Plot Color 4 */
         255  255  85     /* Plot Color 5 */
         255  85   85     /* Plot Color 6 */
         85   255  85     /* Plot Color 7 */
         0    170  170    /* Plot Color 8 */
         170  170  0      /* Plot Color 9 */
 
 This file has exactly 12 lines of RGB triples. No empty lines are
 allowed and anything after the third number in line is ignored.
 
?set terminal pbm
?pbm
 Several options may be set in the PBMplus driver.

 Syntax:
         set terminal pbm {<fontsize>}
         set terminal pgm {<fontsize>}
         set terminal ppm {<fontsize>}

 where <fontsize> is `small`, `medium`, or `large`. 
 Default size is 640 pixels wide and 480 pixels high.
 The pbm output is a portable bitmap (one bit per pixel).
 The pgm output is a portable graymap (three bits per pixel). 	
 The ppm output is a portable pixmap (color, four bits per pixel).
 The output of these drivers can be used with Jef Poskanzer's 
 excellent PBMPLUS package which provides programs to convert
 the above PBMPLUS formats to GIF, TIFF, MacPaint, Macintosh PICT,
 PCX, X11 bitmap and many others. 

 Examples:
 
         set term pbm small
         set size 2,2
         set term ppm medium
 
?set terminal postscript
?postscript
 Several options may be set in the PostScript driver.

 Syntax:
         set terminal postscript {<mode>} {<color>}
                                 {"<fontname>"} {<fontsize>}

 where <mode> is `landscape`, `portrait`, `eps` or `default`. 
 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `landscape`, `monochrome`, "Courier", and 14pt.
 Default size of PostScript plot is landscape mode 10 inches wide 
 and 7 inches high.

 To get EPS output, use the `eps` mode and make only one plot per file.
 In `eps` mode the whole plot is halved in size; the fonts are half the 
 given size, and the plot is 5 inches wide and 3.5 inches high.

 Examples:
 
         set term postscript default       # old postscript
         set term postscript landscape 22  # old psbig
         set term postscript eps 14   # old epsf1
         set term postscript eps 22   # old epsf2
         set size 0.7,1.4
         set term post portrait color "Times-Roman" 14 
 
?set terminal aifm
?aifm
 Several options may be set in the Adobe Illustrator 3.0 driver.

 Syntax:
         set terminal aifm {<color>}
                                 {"<fontname>"} {<fontsize>}

 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `monochrome`, "Courier", and 14pt.

 Also, since AI does not really support multiple pages, multiple 
 graphs will be output directly on one another.  However, each graph 
 will be grouped individually, making it easy to separate them inside 
 AI (just pick them up and move them).

 Examples:
 
         set term aifm 
         set term aifm 22  
         set size 0.7,1.4
         set term aifm color "Times-Roman" 14 
 
?set terminal table
?table
 Instead of producing a picture, term type 'table' prints out
 the evaluation results in a multicolumn ASCII table of X Y Z values.
 For those times when you really want to see the numbers, now you
 can see them on the screen or save to a file.

?set tics
?show tics
?tics
 By default, tics are drawn inwards from the border on all four sides.
 The `set tics` command can be used to change the tics to be 
 drawn outwards on the left and bottom borders only.
 This is useful when doing impulse plots.
 
 Syntax:
         set tics {<direction>}
         show tics
 
 where <direction> may be `in` or `out`. `set tics` defaults to `in`.
 
 See also the `set xtics`, `set ytics`, and `set ztics` command for more
 control of tic marks.
?set ticslevel
?show ticslevel
?ticslevel
 Using splot, in 3-d plots, one can adjust the relative height of the
 vertical (Z) axis using `set ticslevel`. The numeric argument provided
 specifies the location of the bottom of the scale. a zero will put it
 on the bottom grid and any positive number somewhere along the z axis.
 
 Syntax:
         set ticslevel {<level>}
         show tics
 
 where <level> is a non negative numeric argument. For example,

         set ticslevel 0.5

 sets the tics level to the default value.
 
 See also the `set view`.
?set time
?show time
?time
 The optional `set time` places the time and date of the plot either
 at the top or bottom of the left margin. The exact location is
 device dependent.
 
 Syntax:
         set time {<xoff>}{,<yoff>}
         set notime
         show time
 
 Specifying constants <xoff> or <yoff> as optional offsets for the time
 will move the time <xoff> or <yoff> character screen coordinates. For
 example,
 
         set time ,-3
 
 will change only the y offset of the time, moving the title down by
 roughly the height of three characters.
 
?set title
?show title
?title
 The `set title` command produces a plot title that is centered at the
 top of the plot. Using the optional x,y screen offsets, the title
 can be placed anywhere on the plot. `set title` with no parameters
 clears the title.
 
 Syntax:
          set title {"<title-text>"} {<xoff>}{,<yoff>}
          show title
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 title will move the title <xoff> or <yoff> character screen
 coordinates. Note these are screen coordinates and not plot
 coordinates. For example,
 
          set title ,-1
 
 will change only the y offset of the title, moving the title down by
 roughly the height of one character.
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
?set trange
?show trange
?trange
 The `set trange` command sets the parametric range used to compute
 x and y values when in parametric mode. If not in parametric mode
 (see `set parametric`) then this range is not used. This command
 does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `plot` command line when
 in parametric mode.
 
 Syntax:
         set trange [{<tmin> : <tmax>}]
 
 where <tmin> and <tmax> terms are constants or expressions.
 
 Both the <tmin> and <tmax> terms are optional. Anything omitted will
 not be changed, so 
         set trange [:10]
 changes tmax to 10 without affecting tmin.  See also `set urange` and
 `set parametric`.
?set urange
?show urange
?urange
 The `set urange` and `set vrange` commands sets the parametric ranges used 
 to compute x, y, and z values when in `splot` parametric mode. If not in 
 parametric mode (see `set parametric`) then these ranges are not used. This 
 command does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `splot` command line when
 in parametric mode.  See `plot` for more information
 
 Syntax:
         set urange [{<umin> : <umax>}]
 
 where <umin> and <umax> terms are constants or expressions.
 
 Both the <umin> and <umax> terms are optional. Anything omitted will
 not be changed, so 
         set urange [:10]
 changes umax to 10 without affecting umin.  See also `set trange`.
?show variables
 The `show variables` command lists all user-defined variables and
 their values.
 
 Syntax:
         show variables
?set view
?show view
?view
 The `set view` command sets the view point for `splot`s. This
 command controls the way the 3-d coordinates of the plot are mapped
 into the 2-d screen space. This command provides controls to both
 rotation and scaling of the plotted data but supports orthographic
 projections only.
 
 Syntax:
         set view <rot_x> {,{<rot_z>}{,{<scale>}{,<scale_z>}}}
         show view
 
 where <rot_x> and <rot_z> control the rotation angles (in degrees)
 along a virtual 3-d coordinate system aligned with the screen such
 that the screen horizontal axis is x, screen vertical axis is y, and
 the axis perpendicular to the screen is z. <rot_x> is bounded to the
 [0:180] range with a default of 60 degrees, while <rot_z> is bounded
 to the [0:360] range with a default of 30 degrees. <scale> controls
 the scaling of the entire `splot`, while <scale_z> scales the z axis
 only. Both scales default to 1.0.
 
 Examples:
         set view 60, 30, 1, 1
         set view ,,0.5
 
 The first sets all the four default values. The second changes 
 only scale, to 0.5.

 See also `set ticslevel`.
?set vrange
?show vrange
?vrange
 The `set vrange` command is similar to the `set urange` command.
 Please see `set urange`.
?set xlabel
?show xlabel
?xlabel
 The `set xlabel` command sets the x-axis label that is centered along
 the x axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set xlabel` with no parameters clears
 the label.
 
 Syntax: 
          set xlabel {"<label>"} {<xoff>}{,<yoff>}
          show xlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set xlabel -1
 
 will change only the x offset of the xlabel, moving the label roughly
 one character width to the left.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
?set xrange
?show xrange
?xrange
 The `set xrange` command sets the horizontal range that will be
 displayed. This command turns x axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set xrange [{<xmin> : <xmax>}]
 
 where <xmin> and <xmax> terms are constants or expressions.
 
 Both the <xmin> and <xmax> terms are optional. Anything omitted will
 not be changed, so 
         set xrange [:10]
 changes xmax to 10 without affecting xmin.
?set xtics
?set noxtics
?show xtics
?xtics
?noxtics
 Fine control of the x axis tic marks is possible with the
 `set xtics` command. The x-axis tic marks may be turned off with the
 `set noxtics` command. They may be turned on (the default state) with
 `set xtics`.
 
 Syntax:
          set xtics { {<start>, <incr>{, <end>}} |
                      {({"<label>"} <pos> {, {"<label>"} <pos>}...)} }
          set noxtics
          show xtics

 The <start>, <incr>, <end> form specifies that a series of tics will
 be plotted on the x axis between the x values <start> and <end>
 with an increment of <incr>. If <end> is not given it is assumed to be
 infinity. The increment may be negative. For example,
           set xtics 0,.5,10
 makes tics at 0, 0.5, 1, 1.5, ..., 9.5, 10.
 
 The ("<label>" <pos>, ...) form allows arbitrary tic positions or
 non-numeric tic labels. A set of tics are a set of positions, each
 with its own optional label. Note that the label is a string enclosed
 by quotes, and may be a constant string, such as "hello", or contain
 formatting information for the tic number (which is the same as the
 position), such as "%3f clients". See `set format` for more
 information about this case. The label may even be empty.
 Examples:
          set xtics ("low" 0, "medium" 50, "high" 100)
          set xtics (1,2,4,8,16,32,64,128,256,512,1024)
          set xtics ("bottom" 0, "" 10, "top" 20)
 
 Tics will only be plotted when in range.
 
 The `set ytics` and `set noytics` commands work identically.
 See also the `set format` command.
?set xzeroaxis
?set noxzeroaxis
?show xzeroaxis
?xzeroaxis
?noxzeroaxis
 `set xzeroaxis` draws the x-axis. By default, this option is on.
 `set noxzeroaxis` causes GNUPLOT to omit the x-axis.
 
 Syntax:
         set xzeroaxis
         set noxzeroaxis
         show xzeroaxis
?set ylabel
?show ylabel
?ylabel
 The `set ylabel` command sets the y-axis label.  The position of this
 label depends on the terminal, and can be one of the following three
 positions (the position can be adjusted with optional parameters).
 
 1. Horizontal text flushed left at the top left of the plot.
 Terminals that cannot rotate text will probably use this method.
 
 2. Vertical text centered vertically at the left of the plot.
 Terminals that can rotate text will probably use this method.
 
 3. Horizontal text centered vertically at the left of the plot.
 The LaTeX and EEPIC drivers use this method. The user must insert 
 line breaks using \\ to prevent the ylabel from overwriting
 the plot. To produce a vertical row of characters, add \\
 between every printing character (but this is ugly).
 
 Syntax:  
          set ylabel {"<label>"} {<xoff>}{,<yoff>}
          show ylabel
 
 With no parameters, the label is cleared. Specifying constants <xoff>
 or <yoff> as optional offsets for the label will move the label <xoff>
 or <yoff> character screen coordinates. For example,
 
          set ylabel -1
 
 will change only the x offset of the ylabel, moving the label roughly
 one character width left of its default position. This is especially
 useful with the LaTeX driver.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
?set yrange
?show yrange
?yrange
 The `set yrange` command sets the vertical range that will be
 displayed. This command turns y axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set yrange [{<ymin> : <ymax>}]
 
 where <ymin> and <ymax> terms are constants or expressions.
 
 Both the <ymin> and <ymax> terms are optional. Anything omitted will
 not be changed, so 
         set yrange [:10]
 changes ymax to 10 without affecting ymin.
?set ytics
?set noytics
?show ytics
?ytics
?noytics
 The `set ytics` and `set noytics` commands are similar to the `set xtics`
 and `set noxtics` commands. Please see `set xtics`.
?set yzeroaxis
?set noyzeroaxis
?show yzeroaxis
?yzeroaxis
?noyzeroaxis
 `set yzeroaxis` draws the y-axis. By default, this option is on.
 `set noyzeroaxis` causes GNUPLOT to omit the y-axis.
 
 Syntax:
         set yzeroaxis
         set noyzeroaxis
         show yzeroaxis
?set zero
?show zero
?zero
 The `zero` value is the default threshold for values approaching 0.0.
 GNUPLOT will not plot a point if its imaginary part is greater in
 magnitude than the `zero` threshold. Axis ranges cannot be less than
 `zero`. The default `zero` value is 1e-8. This can be changed with
 the `set zero` command.

 Syntax:
         set zero <expression>
         show zero
?set zeroaxis
?set nozeroaxis
?show zeroaxis
?zeroaxis
?nozeroaxis
 `set zeroaxis` draws the x-axis and y-axis. By default, this option is
 on.  `set nozeroaxis` causes GNUPLOT to omit the axes, and is
 equivalent to `set noxzeroaxis; set noyzeroaxis.`
 
 Syntax:
         set zeroaxis
         set nozeroaxis
         show zeroaxis
 See `set xzeroaxis` and `set yzeroaxis`.
?set zlabel
?show zlabel
?zlabel
 The `set zlabel` command sets the z-axis label that is centered along
 the z axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set zlabel` with no parameters clears
 the label.
 
 Syntax: 
          set zlabel {"<label>"} {<xoff>}{,<yoff>}
          show zlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set zlabel ,1
 
 will change only the y offset of the zlabel, moving the label roughly
 one character height up.
 
 The zlabel will be drawn whenever surfaces or contours are plotted,
 in the space above the grid level.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
?set zrange
?show zrange
?zrange
 The `set zrange` command sets the vertical range that will be
 displayed. This command turns z axis autoscaling off.  The zrange is
 used only by `splot` and is ignored by `plot`.
 
 This range may also be specified on the `splot` command line.
 
 Syntax:
         set zrange [{<zmin> : <zmax>}]
 
 where <zmin> and <zmax> terms are constants or expressions.
 
 Both the <zmin> and <zmax> terms are optional. Anything omitted will
 not be changed, so
         set zrange [2:]
 changes zmin to 2 without affecting zmax.
?set ztics
?set noztics
?show ztics
?ztics
?noztics
 The `set ztics` and `set noztics` commands are similar to the `set
 xtics` and `set noxtics` commands. Please see `set xtics`.
?shell
 The `shell` command spawns an interactive shell. To return to
 GNUPLOT, type `logout` if using VMS, `exit` or the END-OF-FILE
 character if using Unix, `endcli` if using AmigaDOS, or `exit` if
 using MS-DOS.
 
 A single shell command may be spawned by preceding it with the !
 character ($ if using VMS) at the beginning of a command line.
 Control will return immediately to GNUPLOT after this command is
 executed. For example, in VMS, AmigaDOS, or MS-DOS,
 
      ! dir
 
 prints a directory listing and then returns to GNUPLOT.
 Three-dimensional surface and contour plotting is available in
 GNUPLOT with the `splot` command. See the `plot` command for features
 common to the `plot` command.
 
 See also `set contour`, `set cntrparam`, and `set surface`.
?startup
?start
?.gnuplot
 When GNUPLOT is run, it looks for an initialization file to load.
 This file is called `.gnuplot` on Unix and AmigaDOS systems, and
 `GNUPLOT.INI` on other systems. If this file is not found in the
 current directory, the program will look for it in the home directory
 (under AmigaDOS and MS-DOS, the environment variable GNUPLOT should
 contain the name of this directory).
 
 If this file is found, GNUPLOT executes the commands in this file.
 This is most useful for setting the terminal type and defining any
 functions or variables that are used often.
?substitution
 Command-line substitution is specified by a system command enclosed in
 backquotes. This command is spawned and the output it produces
 replaces the name of the command (and backquotes) on the command line.
 
 Newlines in the output produced by the spawned command are replaced
 with blanks.
 
 Command-line substitution can be used anywhere on the GNUPLOT command
 line.
 
 Example:
 
 This will run the program `leastsq` and replace `leastsq` (including
 backquotes) on the command line with its output:
 
          f(x) = `leastsq`
 
 or, in VMS
 
          f(x) = `run leastsq`
?userdefined
?variables
 New user-defined variables and functions of one or two variables may be 
 declared and used anywhere.
 
 User-defined function syntax:
         <function-name> ( <dummy-var1> {,<dummy-var2>} ) =  <expression>
 
 where <expression> is defined in terms of <dummy-var1> and <dummy-var2>.

 User-defined variable syntax:
         <variable-name> = <constant-expression>
 
 Examples:
         w = 2
         q = floor(tan(pi/2 - 0.1))
         f(x) = sin(w*x)
         sinc(x) = sin(pi*x)/(pi*x)
         delta(t) = (t == 0)
         ramp(t) = (t > 0) ? t : 0
         min(a,b) = (a < b) ? a : b
         comb(n,k) = n!/(k!*(n-k)!)
 
 Note that the variable `pi` is already defined.
 
 See `show functions` and `show variables`.
?bugs
 The bessel functions do not work for complex arguments.
 
 The gamma function does not work for complex arguments.
 
 There is a bug in the stdio library for old Sun operating systems
 (SunOS Sys4-3.2). The "%g" format for 'printf' sometimes incorrectly
 prints numbers (e.g., 200000.0 as "2"). Thus, tic mark labels may be
 incorrect on a Sun4 version of GNUPLOT. A work-around is to rescale
 the data or use the `set format` command to change the tic mark format
 to "%7.0f" or some other appropriate format. This appears to have been
 fixed in SunOS 4.0.
 
 Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
 and SunOS 4.0, the 'sscanf' routine incorrectly parses "00 12" with
 the format "%f %f" and reads 0 and 0 instead of 0 and 12. This
 affects data input. If the data file contains x coordinates that are
 zero but are specified like '00', '000', etc, then you will read the
 wrong y values. Check any data files or upgrade the SunOS.
 It appears to have been fixed in SunOS 4.1.1.
 
 Microsoft C 5.1 has a nasty bug associated with the %g format for
 printf. When any of the formats "%.2g", "%.1g", "%.0g", "%.g" are
 used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.
 Numbers that should be printed in the %e format are incorrectly 
 printed in the %f format, with the wrong number of zeros after the 
 decimal point.

 To work around this problem, use the %e or %f formats explicitly.
 
 GNUPLOT, when compiled with Microsoft C, did not work correctly on two
 VGA displays that were tested. The CGA, EGA and VGA drivers should 
 probably be rewritten to use the Microsoft C graphics library.
 GNUPLOT compiled with Turbo C uses the Turbo C graphics drivers and 
 does work correctly with VGA displays.
 
 VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented %g 
 format for printf. The numbers are printed numerically correct, but 
 may not be in the requested format. The K&R second edition says that 
 for the %g format, %e is used if the exponent is less than -4 or greater 
 than or equal to the precision. The VAX uses %e format if the exponent 
 is less than -1. The VAX appears to take no notice of the precision 
 when deciding whether to use %e or %f for numbers less than 1.
 To work around this problem, use the %e or %f formats explicitly.
 From the VAX C 2.4 release notes:
 e,E,f,F,g,G  Result will always contain a decimal  point.
 For g and G, trailing zeros will not be removed from the result.
 
 VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
 %g format than release 2.4, but not much. Trailing decimal points are 
 now removed, but trailing zeros are still not removed from %g numbers 
 in exponential format.

 ULTRIX X11R3 has a bug that causes the X11 driver to display "every
 other" plot.  The bug seems to be fixed in DEC's release of X11R4 so
 newer releases of ULTRIX don't seem to have the problem.  Solutions for 
 older sites include upgrading the X11 libraries (from DEC or direct from 
 MIT) or defining ULTRIX_KLUDGE when compiling the x11.trm file.  Note 
 that the kludge is not an ideal fix, however.

 The constant HUGE was incorrectly defined in the NeXT OS 2.0 operating
 system.  HUGE should be set to 1e38 in plot.h. This error has been
 corrected in the 2.1 version of NeXT OS.

 Some older models of HP plotters do not have a page eject command 'PG'.
 The current HPGL driver uses this command in HPGL_reset.  This may need
 to be removed for these plotters.  The current PCL5 driver uses HPGL/2
 for text as well as graphics.  This should be modified to use scalable
 PCL fonts.

 Please report any bugs to bug-gnuplot@ames.arc.nasa.gov.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.hlp version [ae8ea4b5ae].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
1 gnuplot
 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 a line, separated by semicolons (;).
 Strings are indicated with quotes.  They may be either single or double
 quotation marks, e.g.,

          load "filename"
          cd 'dir'
 
 Any command-line arguments are assumed to be names of files containing 
 GNUPLOT commands, with the exception of standard X11 arguments, which
 are processed first. Each file is loaded with the `load` command, in the
 order specified. GNUPLOT exits after the last file is processed.  When
 no load files are named, gnuplot enters into an interactive mode.
 
 Commands may extend over several input lines, by ending each 
 line but the last with a backslash (\). The backslash must be the LAST
 character on each line. The effect is as if the backslash and newline
 were not there. That is, no white space is implied, nor is a comment
 terminated. Therefore, commenting out a continued line comments out
 the entire command (see `comment`).
 
 In this documentation, curly braces ({}) denote optional arguments to
 many commands, and a vertical bar (|) separates mutually exclusive
 choices.  GNUPLOT keywords or help topics are indicated by backquotes
 or `boldface` (where available).  Angle brackets (<>) are used to mark
 replaceable tokens.
 
 For help on any topic, type `help` followed by the name of the topic.

 The new GNUPLOT user should begin by reading about the `plot`
 command (type `help plot`).
2 cd
 The `cd` command changes the working directory.
 
 Syntax:
         cd "<directory-name>"
 
 The directory name must be enclosed in quotes.
 
 Examples:
         cd 'subdir'
         cd ".."
2 clear
 The `clear` command erases the current screen or output device as
 specified by `set output`. This usually generates a formfeed on
 hardcopy devices. Use `set terminal` to set the device type.
2 command-line editing
 The Unix and IBM PC versions of GNUPLOT support command-line editing.
 Also, a history mechanism allows previous commands to be edited, and
 re-executed. After the command line has been edited, a newline or
 carriage return will enter the entire line regardless of where the
 cursor is positioned.

 The editing commands are as follows:
 
 `Line editing`:
 
 ^B moves back a single character.
 ^F moves forward a single character.
 ^A moves to the beginning of the line.
 ^E moves to the end of the line.
 ^H and DEL delete the previous character.
 ^D deletes the current character.
 ^K deletes from current position to the end of line.
 ^L,^R redraws line in case it gets trashed.
 ^U deletes the entire line.
 ^W deletes the last word.

 `History`:
 
 ^P moves back through history.
 ^N moves forward through history.

 On the IBM PC the use of a TSR program such as DOSEDIT or CED may be
 desired for line editing. For such a case GNUPLOT may be compiled with
 no line editing capability (default makefile setup). Set READLINE in the
 makefile and add readline.obj to the link file if GNUPLOT line editing
 is to be used for the IBM PC. The following arrow keys may be used
 on the IBM PC version if readline is used:
 
 Left  Arrow     - same as ^B.
 Right Arrow     - same as ^F.
 Ctl Left  Arrow - same as ^A.
 Ctl Right Arrow - same as ^E.
 Up    Arrow     - same as ^P.
 Down  Arrow     - same as ^N.
 (The readline function in gnuplot is not the same as the readline used
 in GNU BASH and GNU EMACS.  It is somewhat compatible however.) 
2 comment
 Comments are supported as follows: a # may appear in most places in a line
 and GNUPLOT will ignore the rest of the line. It will not have this
 effect inside quotes, inside numbers (including complex numbers), inside
 command substitutions, etc. In short, it works anywhere it makes sense
 to work.
2 environment
 A number of shell environment variables are understood by GNUPLOT.
 None of these are required, but may be useful.
 
 If GNUTERM is defined, it is used as the name of the terminal type to
 be used. This overrides any terminal type sensed by GNUPLOT on start
 up, but is itself overridden by the .gnuplot (or equivalent) start-up
 file (see `start-up`), and of course by later explicit changes.
 
 On Unix, AmigaDOS, and MS-DOS, GNUHELP may be defined to be the pathname
 of the HELP file (gnuplot.gih).

 On VMS, the symbol GNUPLOT$HELP should be defined as the name of 
 the help library for GNUPLOT.
 
 On Unix, HOME is used as the name of a directory to search for 
 a .gnuplot file if none is found in the current directory.
 On AmigaDOS and MS-DOS, GNUPLOT is used. On VMS, SYS$LOGIN: is used.
 See help start-up.
 
 On Unix, PAGER is used as an output filter for help messages.
 
 On Unix and AmigaDOS, SHELL is used for the `shell` command. On MS-DOS,
 COMSPEC is used for the `shell` command.

 On AmigaDOS, GNUFONT is used for the screen font.  For example:
 "setenv GNUFONT sapphire/14".

 On MS-DOS, if the BGI interface is used, the variable `BGI` is used to point 
 to the full path to the BGI drivers directory. Furthermore SVGA is used to
 name the Super VGA BGI driver in 800x600 res., and its mode of operation
 as 'Name.Mode'.
 For example, if the Super VGA driver is C:\TC\BGI\SVGADRV.BGI and mode 3 is
 used for 800x600 res., then: 'set BGI=C:\TC\BGI' and 'set SVGA=SVGADRV.3'.
2 exit
 The commands `exit` and `quit` and the END-OF-FILE character
 will exit GNUPLOT. All these commands will clear the output device
 (as the `clear` command does) before exiting.
2 expressions
 In general, any mathematical expression accepted by C, FORTRAN,
 Pascal, or BASIC is valid. The precedence of these operators is
 determined by the specifications of the C programming language.
 White space (spaces and tabs) is ignored inside expressions.
 
 Complex constants may be expressed as the {<real>,<imag>}, where <real>
 and <imag> must be numerical constants. For example, {3,2}
 represents 3 + 2i; {0,1} represents `i` itself. The curly braces 
 are explicitly required here.
3 functions
 The functions in GNUPLOT are the same as the corresponding functions
 in the Unix math library, except that all functions accept integer,
 real, and complex arguments, unless otherwise noted. The `sgn`
 function is also supported, as in BASIC.
4 abs
 The `abs` function returns the absolute value of its argument. The
 returned value is of the same type as the argument.
 
 For complex arguments, abs(x) is defined as the length of x in the
 complex plane [i.e.,  sqrt(real(x)**2 + imag(x)**2) ].
4 acos
 The `acos` function returns the arc cosine (inverse cosine) of its
 argument. `acos` returns its argument in radians.
4 arg
 The `arg` function returns the phase of a complex number, in radians.
4 asin
 The `asin` function returns the arc sin (inverse sin) of its argument.
 `asin` returns its argument in radians.
4 atan
 The `atan` function returns the arc tangent (inverse tangent) of its
 argument. `atan` returns its argument in radians.
4 besj0
 The `besj0` function returns the j0th Bessel function of its argument.
 `besj0` expects its argument to be in radians.
4 besj1
 The `besj1` function returns the j1st Bessel function of its argument.
 `besj1` expects its argument to be in radians.
4 besy0
 The `besy0` function returns the y0th Bessel function of its argument.
 `besy0` expects its argument to be in radians.
4 besy1
 The `besy1` function returns the y1st Bessel function of its argument.
 `besy1` expects its argument to be in radians.
4 ceil
 The `ceil` function returns the smallest integer that is not less than its
 argument. For complex numbers, `ceil` returns the smallest integer
 not less than the real part of its argument.
4 cos
 The `cos` function returns the cosine of its argument. `cos` expects its
 argument to be in radians.
4 cosh
 The `cosh` function returns the hyperbolic cosine of its argument.
 `cosh` expects its argument to be in radians.
4 exp
 The `exp` function returns the exponential function of its argument
 (`e` raised to the power of its argument).
4 floor
 The `floor` function returns the largest integer not greater than its
 argument. For complex numbers, `floor` returns the largest
 integer not greater than the real part of its argument.
4 gamma
 The `gamma` function returns the gamma function of the real part of
 its argument. For integer n, gamma(n+1) = n! .
 If the argument is a complex value, the imaginary component is ignored.
4 imag
 The `imag` function returns the imaginary part of its argument as a
 real number.
4 int
 The `int` function returns the integer part of its argument, truncated
 toward zero.
4 log
 The `log` function returns the natural logarithm (base `e`) of its
 argument.
4 log10
 The `log10` function returns the logarithm (base 10) of its argument.
4 real
 The `real` function returns the real part of its argument.
4 sgn
 The `sgn` function returns 1 if its argument is positive, -1 if its
 argument is negative, and 0 if its argument is 0. If the argument
 is a complex value, the imaginary component is ignored.
4 sin
 The `sin` function returns the sine of its argument. `sin` expects its
 argument to be in radians.
4 sinh
 The `sinh` function returns the hyperbolic sine of its argument. `sinh`
 expects its argument to be in radians.
4 sqrt
 The `sqrt` function returns the square root of its argument.
4 tan
 The `tan` function returns the tangent of its argument. `tan` expects
 its argument to be in radians.
4 tanh
 The `tanh` function returns the hyperbolic tangent of its argument.
 `tanh` expects its argument to be in radians.
3 operators
 The operators in GNUPLOT are the same as the corresponding operators
 in the C programming language, except that all operators accept
 integer, real, and complex arguments, unless otherwise noted.
 The ** operator (exponentiation) is supported, as in FORTRAN.
 
 Parentheses may be used to change order of evaluation.
4 binary
 The following is a list of all the binary operators and their
 usages:
 
  Symbol      Example      Explanation
   **          a**b          exponentiation
   *           a*b           multiplication
   /           a/b           division
   %           a%b         * modulo
   +           a+b           addition
   -           a-b           subtraction
   ==          a==b          equality
   !=          a!=b          inequality
   &           a&b         * bitwise AND
   ^           a^b         * bitwise exclusive OR
   |           a|b         * bitwise inclusive OR
   &&          a&&b        * logical AND
   ||          a||b        * logical OR
   ?:          a?b:c       * ternary operation
 
 (*) Starred explanations indicate that the operator requires
 integer arguments.
 
 Logical AND (&&) and OR (||) short-circuit the way they do in C.
 That is, the second && operand is not evaluated if the first is
 false; the second || operand is not evaluated if the first is true.
 
 The ternary operator evaluates its first argument (a). If it is
 true (non-zero) the second argument (b) is evaluated and returned,
 otherwise the third argument (c) is evaluated and returned.
4 unary
 The following is a list of all the unary operators and their
 usages:
 
  Symbol     Example      Explanation
   -           -a          unary minus
   ~           ~a        * one's complement
   !           !a        * logical negation
   !           a!        * factorial
 
 (*) Starred explanations indicate that the operator requires an
 integer argument.
 
 The factorial operator returns a real number to allow a greater range.
2 help
 The `help` command displays on-line help. To specify information on a
 particular topic use the syntax:
 
         help {<topic>}
 
 If <topic> is not specified, a short message is printed about
 GNUPLOT. After help for the requested topic is given, help for a
 subtopic may be requested by typing its name, extending the help
 request. After that subtopic has been printed, the request may be
 extended again, or simply pressing return goes back one level to the
 previous topic. Eventually, the GNUPLOT command line will return.
2 load
 The `load` command executes each line of the specified input file as
 if it had been typed in interactively. Files created by the `save`
 command can later be `load`ed. Any text file containing valid
 commands can be created and then executed by the `load` command.
 Files being `load`ed may themselves contain `load` commands. See
 `comment` for information about comments in commands.
 
 The `load` command must be the last command on the line.
 
 Syntax:
         load "<input-file>"
 
 The name of the input file must be enclosed in quotes.
 
 Examples:
 
         load 'work.gnu'
         load "func.dat"
 
 The `load` command is performed implicitly on any file names given as
 arguments to GNUPLOT. These are loaded in the order specified, and
 then GNUPLOT exits.
2 pause
 The `pause` command displays any text associated with the command and
 then waits a specified amount of time or until the carriage return is
 pressed.  `pause` is especially useful in conjunction with `load` files.

 Syntax:
         pause <time> {"<string>"}

 <time> may be any integer constant or expression. Choosing -1 will
 wait until a carriage return is hit, zero (0) won't pause at all, and
 a positive integer will wait the specified number of seconds.
 
 Note: Since `pause` is not part of the plot it may interact with
 different device drivers differently (depending upon how text and
 graphics are mixed).
 
 Examples:
         pause -1    # Wait until a carriage return is hit
         pause 3     # Wait three seconds
         pause -1  "Hit return to continue"
         pause 10  "Isn't this pretty?  It's a cubic-spline."
 
2 plot
 `plot` and `splot` are the primary commands of the program. They plot
 functions and data in many, many ways. `plot` is used to plot 2-d
 functions and data, while `splot` plots 3-d surfaces and data.

 Syntax:
 
         plot {ranges}  <function> {title} {style}
                     {, <function> {title} {style}...}
 
         splot {ranges}  <function> {title} {style}
                      {, <function> {title} {style}...}
 
 where <function> is either a mathematical expression, the name of a
 data file enclosed in quotes, or a pair (`plot`) or triple (`splot`)
 of mathematical expressions in the case of parametric functions.
 User-defined functions and variables may also be defined here.
 
 `plot` and `splot` commands can be as simple as
 
         plot sin(x)
 
 and
 
         splot x * y
 
 or as complex as (!)
 
         plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
3 data-file
 Discrete data contained in a file can displayed by specifying the
 name of the data file (enclosed in quotes) on the `plot` or `splot`
 command line. Data files should contain one data point per line.
 Lines beginning with # (or ! on VMS) will be treated as comments
 and ignored. For `plot`s, each data point represents an (x,y)
 pair. For `splot`s, each point is an (x,y,z) triple. For `plot`s with
 error bars (see `plot errorbars`), each data point is either
 (x,y,ydelta) or (x,y,ylow,yhigh). In all cases, the numbers on each
 line of a data file must be separated by blank space. This blank
 space divides each line into columns.

 For `plot`s the x value may be omitted, and for `splot`s the x
 and y values may be omitted. In either case the omitted values are
 assigned the current coordinate number. Coordinate numbers start at 0
 and are incremented for each data point read.

 To specify other formats, see `plot datafile using`.
 
 In the `plot` command, blank lines in the data file cause a break in
 the plot. There will be no line drawn between the preceding and
 following points if the plot style is `lines` or `linespoints` (see
 `plot style`). This does not change the plot style, as would plotting
 the data as separate curves.
 
 This example compares the data in the file population.dat to a
 theoretical curve:
 
         pop(x) = 103*exp((1965-x)/10)
         plot [1960:1990] 'population.dat', pop(x)
 
 The file population.dat might contain:
 
         # Gnu population in Antarctica since 1965
         1965   103
         1970   55
         1975   34
         1980   24
         1985   10
 
 When a data file is plotted, `samples` and `iso_samples` are ignored.
 Curves plotted using the `plot` command are automatically extended to
 hold the entire curve. Similarly grid data plotted using the `splot`
 command is automatically extended, using the assumption that isolines
 are separated by blank lines (a line with only a CR/LF in it).
 
 Implicitly, there are two types of 3-d datafiles. If all the isolines
 are of the same length, the data is assumed to be a grid data, i.e.,
 the data has a grid topology. Cross isolines in the other parametric
 direction (the ith cross isoline passes thru the ith point of all the
 provided isolines) will also be drawn for grid data. (Note contouring
 is available for grid data only.) If all the isolines are not of the
 same length, no cross isolines will be drawn and contouring that data
 is impossible.
 
 For splot if 3-d datafile and using format (see `splot datafile using`)
 specify only z (height field), a non parametric mode must be specified.
 If, on the other hand, x, y, and z are all specified, a parametric
 mode should be selected (see `set parametric`) since data is defining a
 parametric surface.

 A simple example of plotting a 3-d data file is
 
         set parametric
         splot 'glass.dat'
 
 or
 
         set noparametric
         splot 'datafile.dat'
 
 where the file datafile.dat might contain:
 
         # The valley of the Gnu.
         10
         10
         10
 
         10
         5
         10
 
         10
         1
         10
 
         10
         0
         10
 
 Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ).
 Rows are separated by blank lines.

 On some computer systems with a popen function (UNIX), the datafile
 can be piped through a shell command by starting the file name
 with a '<'.  For example:

         pop(x) = 103*exp(x/10)
         plot '< awk "{print $1-1965 $2}" population.dat', pop(x)

 would plot the same information as the first population example
 but with years since 1965 as the x axis.
 
 For more information about 3-d plotting, see `splot`.
4 using
 The format of data within a file can be selected with the `using` 
 option. An explicit scanf string can be used, or simpler column
 choices can be made.
 
 Syntax:
 
         plot "datafile" { using { <ycol> |
                                   <xcol>:<ycol> |
                                   <xcol>:<ycol>:<ydelta> |
                                   <xcol>:<ycol>:<ylow>:<yhigh> }
                                 {"<scanf string>"} } ...

 and

         splot "datafile" { using { <xcol>:<ycol>:<zcol> | <zcol> }
                                  {"<scanf string>"} } ...
 
 <xcol>, <ycol>, and <zcol> explicitly select the columns to plot from
 a space or tab separated multicolumn data file. If only <ycol> is
 selected for `plot`, <xcol> defaults to 1. If only <zcol> is selected
 for `splot`, then only that column is read from the file. An <xcol> of
 0 forces <ycol> to be plotted versus its coordinate number. <xcol>,
 <ycol>, and <zcol> can be entered as constants or expressions.

 If errorbars (see also `plot errorbars`) are used for `plot`s,
 ydelta (for example, a +/- error) should be provided as the third
 column, or ylow and yhigh as third and fourth columns.  These columns
 must follow the x and y columns.

 Scanf strings override any <xcol>:<ycol>(:<zcol>) choices, except for
 ordering of input, e.g.,
         plot "datafile" using 2:1 "%f%*f%f"
 causes the first column to be y and the third column to be x.

 If the scanf string is omitted, the default is generated based on the
 <xcol>:<ycol>(:<zcol>) choices. If the `using` option is omitted, "%f%f"
 is used for `plot` ("%f%f%f%f" for `errorbar` `plot`s) and "%f%f%f" is
 used for `splot`.
 
 Examples:
 
         plot "MyData" using "%*f%f%*20[^\n]%f" with lines

 Data are read from the file "MyData" using the format
 "%*f%f%*20[^\n]%f". The meaning of this format is: "%*f" ignore the
 first number, "%f" then read in the second and assign to x,
 "%*20[^\n]" then ignore 20 non-newline characters, "%f" then read in
 the y value.

         n=3;
         plot "MyData", "MyData" using n 

 causes GNUPLOT to plot the second and third columns of MyData versus
 the first column. The command 'n=4; replot' would then plot the second
 and fourth columns of MyData versus the first column.
 
         splot "glass.dat" using 1

 causes GNUPLOT to plot the first coordinate of the points of glass.dat
 as the z coordinate while ignoring the other two coordinates.
 
 Note: GNUPLOT first reads a line of the data file into a buffer and 
 then does a 
         sscanf(input_buffer, scanf_string, &x, &y{, &z});
 where 'x', 'y', and 'z' are of type 'float'. Any scanf string that
 specifies two (three for `splot`, three or four for `errorbars`) float
 numbers may be used.
3 errorbars
 Error bars are supported for 2-d data file plots by reading one or
 two additional columns specifying ydelta or ylow and yhigh
 respectively. No support exists for x error bars or any error bars
 for `splot`s.

 In the default situation, GNUPLOT expects to see three or four
 numbers on each line of the data file, either (x, y, ydelta) or 
 (x, y, ylow, yhigh). The x coordinate must be specified. The order
 of the numbers must be exactly as given above. Data files in this
 format can easily be plotted with error bars:

         plot "data.dat" with errorbars

 The error bar is a vertical line plotted from (x, ylow) to (x,
 yhigh). If ydelta is specified instead of ylow and yhigh, 
 ylow=y-ydelta and yhigh=y+ydelta are derived. If there
 are only two numbers on the line, yhigh and ylow are both set to
 y. To get lines plotted between the data points, `plot` the
 data file twice, once with errorbars and once with lines.

 If y autoscaling is on, the y range will be adjusted to fit the
 error bars.

 The `using` option may be used to specify how columns of the data file
 are to be assigned to x, y, ydelta, ylow, and yhigh. The x column must
 be provided and both the x and y columns must appear before the
 errorbar columns. If three column numbers are given, they are x, y,
 and ydelta. If four columns are given, they are x, y, ylow, and
 yhigh.

 Examples:
 
         plot "data.dat" using 1:2:3:4 with errorbars
         plot "data.dat" using 3:2:6 with errorbars
         plot "data.dat" using 3:4:8:7 with errorbars
 
 The first example reads, x, y, ylow, and yhigh, from columns 1, 2, 3,
 and 4. This is equivalent to the default.  The second example reads x
 from the third column, y from second and ydelta from the sixth column.
 The third example reads x from the third column, y from the fourth,
 ylow from the eighth, and yhigh from seventh columns.
 
 See also `plot using` and `plot style`.
3 parametric
 When in parametric mode (`set parametric`) mathematical expressions must
 be given in pairs for `plot` and in triplets for `splot`:
         plot sin(t),t**2
 or
         splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
 
 Data files are plotted as before, except any preceding parametric
 function must be fully specified before a data file is given as a
 plot. In other words, the x parametric function (sin(t) above) and
 the y parametric function (t**2 above) must not be interrupted with
 any modifiers or data functions; doing so will generate a syntax error
 stating that the parametric function is not fully specified.
 
 Ranges take on a different meaning when in parametric mode. The first
 range on the `plot` command is the `trange`, the next is the `xrange`,
 and the last is the `yrange`. For `splot` the order is `urange`,
 `vrange`, `xrange`, `yrange`, and finally `zrange`. The following
 `plot` command shows setting the `trange` to [-pi:pi], the `xrange` to
 [-1.3:1.3] and the `yrange` to [-1:1] for the duration of the plot:
         plot [-pi:pi] [-1.3:1.3] [-1:1] sin(t),t**2
 
 Other modifiers, such as `with` and `title`, may be specified only
 after the parametric function has been completed:
         plot sin(t),t**2 title 'Parametric example' with linespoints
3 ranges
 The optional range specifies the region of the plot that will be
 displayed.
 
 Ranges may be provided on the `plot` and `splot` command line and
 affect only that plot, or in the `set xrange`, `set yrange`, etc.,
 commands, to change the default ranges for future plots.
 
 Syntax:
         [{<dummy-var> =} {<xmin> : <xmax>}] { [{<ymin> : <ymax>}] }
 
 where <dummy-var> is the independent variable (the defaults are x and
 y, but this may be changed with `set dummy`) and the min and max
 terms can be constant expressions.
 
 Both the min and max terms are optional. The ':' is also optional
 if neither a min nor a max term is specified. This allows '[ ]' to
 be used as a null range specification.
 
 Specifying a range in the `plot` command line turns autoscaling for
 that axis off for that plot. Using one of the `set` range commands
 turns autoscaling off for that axis for future plots, unless changed
 later. (See `set autoscale`).
 
 Examples:
 
 This uses the current ranges:
         plot cos(x)
 
 This sets the x range only:
         plot [-10:30] sin(pi*x)/(pi*x)
 
 This is the same, but uses t as the dummy-variable:
         plot [t = -10 :30]  sin(pi*t)/(pi*t)
 
 This sets both the x and y ranges:
         plot [-pi:pi] [-3:3]  tan(x), 1/x
 
 This sets only the y range, and turns off autoscaling on both axes:
         plot [ ] [-2:sin(5)*-8] sin(x)**besj0(x)
 
 This sets xmax and ymin only:
         plot [:200] [-pi:]  exp(sin(x))
 
 This sets the x, y, and z ranges:
         splot [0:3] [1:4] [-1:1] x*y
3 style
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis (or from the grid base for `splot`) to each point. The
 `dots` style plots a tiny dot at each point; this is useful for
 scatter plots with many points.

 The `errorbars` style is only relevant to 2-d data file plotting. It
 is treated like `points` for `splot`s and function `plot`s. For data
 `plot`s, `errorbars` is like `points`, except that a vertical error 
 bar is also drawn: for each point (x,y), a line is drawn from
 (x,ylow) to (x,yhigh). A tic mark is placed at the ends of the error
 bar. The ylow and yhigh values are read from the data file's columns,
 as specified with the `using` option to plot. See `plot errorbars` for
 more information.
 
 Default styles are chosen with the `set function style` and
 `set data style` commands.
 
 By default, each function and data file will use a different 
 line type and point type, up to the maximum number of available 
 types. All terminal drivers support at least six different point
 types, and re-use them, in order, if more than six are required.
 The LaTeX driver supplies an additional six point types (all variants
 of a circle), and thus will only repeat after twelve curves are
 plotted with points.
 
 If desired, the style and (optionally) the line type and point type
 used for a curve can be specified.

 Syntax:
 
         with <style> {<linetype> {<pointtype>}}
 
 where <style> is either `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`. The <linetype> and <pointtype> are positive
 integer constants or expressions and specify the line type and point
 type to be used for the plot. Line type 1 is the first line type used
 by default, line type 2 is the second line type used by default, etc.
 
 Examples:
 
 This plots sin(x) with impulses:
         plot sin(x) with impulses
 
 This plots x*y with points, x**2 + y**2 default:
         splot x*y w points, x**2 + y**2
 
 This plots tan(x) with the default function style, "data.1" with lines:
         plot [ ] [-2:5] tan(x), "data.1" with l
 
 This plots "leastsq.dat" with impulses:
         plot 'leastsq.dat' w i
 
 This plots "exper.dat" with errorbars and lines connecting the points:
         plot 'exper.dat' w lines, 'exper.dat' w errorbars
 Here 'exper.dat' should have three or four data columns.
 
 This plots x**2 + y**2 and x**2 - y**2 with the same line type:
         splot x**2 + y**2 with line 1, x**2 - y**2 with line 1
 
 This plots sin(x) and cos(x) with linespoints, using the
 same line type but different point types:
         plot sin(x) with linesp 1 3, cos(x) with linesp 1 4
 
 This plots file "data" with points style 3:
         plot "data" with points 1 3 
 Note that the line style must be specified when specifying the point
 style, even when it is irrelevant. Here the line style is 1 and the
 point style is 3, and the line style is irrelevant.
 
 See `set style` to change the default styles.
3 title
 A title of each plot appears in the key. By default the title is
 the function or file name as it appears on the plot command line.
 The title can be changed by using the `title` option. This option 
 should precede any `with` option.
 
 Syntax:
         title "<title>"
 
 where <title> is the new title of the plot and must be enclosed in
 quotes. The quotes will not be shown in the key.
 
 Examples:
 
 This plots y=x with the title 'x':
         plot x
 
 This plots the "glass.dat" file with the title 'surface of revolution':
         splot "glass.dat" title 'surface of revolution'
 
 This plots x squared with title "x^2" and "data.1" with title
 'measured data':
         plot x**2 title "x^2", "data.1" t 'measured data'
2 print
 The `print` command prints the value of <expression> to the screen.
 
 Syntax:
         print <expression>
 
 See `expressions`.
2 pwd
 The `pwd` command prints the name of the working directory to the screen.
 
 Syntax:
         pwd
2 quit
 The `exit` and `quit` commands and END-OF-FILE character will exit
 GNUPLOT. All these commands will clear the output device (as the
 `clear` command does) before exiting.
2 replot
 The `replot` command without arguments repeats the last `plot` or `splot`
 command. This can be useful for viewing a plot with different `set`
 options, or when generating the same plot for several devices.
 
 Arguments specified after a `replot` command will be added onto the last
 `plot` (`splot`) command (with an implied ',' separator) before it is
 repeated. `replot` accepts the same arguments as the `plot` (`splot`)
 commands except that ranges cannot be specified. See `command-line
 editing` for ways to edit the last `plot` (`splot`) command.
2 save
 The `save` command saves user-defined functions, variables, set
 options or all three plus the last `plot` (`splot`) command to the
 specified file.
 
 Syntax:
         save  {<option>} "<filename>"
 
 where <option> is `functions`, `variables` or `set`. If no option is
 used, GNUPLOT saves functions, variables, set options and the last `plot`
 (`splot`) command.
 
 `save`d files are written in text format and may be read by the `load`
 command.
 
 The filename must be enclosed in quotes.
 
 Examples:
 
         save "work.gnu"
         save functions 'func.dat'
         save var 'var.dat'
         save set "options.dat"
2 set-show
 The `set` command sets LOTS of options.
 
 The `show` command shows their settings. `show all` shows all the
 settings.
3 angles
 By default, GNUPLOT assumes the independent variable in polar plots
 is in units of radians. If `set angles degrees` is specified before
 `set polar` then the default range is [0:360] and the independent
 variable has units of degrees. This is particularly useful for
 plots of data files. The angle setting also hold for the 3-d
 mapping as set via the `set mapping` command.

 Syntax:
         set angles { degrees | radians }
         show angles
3 arrow
 Arbitrary arrows can be placed on a plot using the `set arrow`
 command.
 
 Syntax:
 
          set arrow {<tag>} {from <sx>,<sy>{,<sz>}} 
                            {to <ex>,<ey>{,<ez>}} {{no}head}
          set noarrow {<tag>}
          show arrow
 
 
 Unspecified coordinates default to 0. The x, y, and z values are in
 the graph's coordinate system. The z coordinate is only used in
 `splot` commands. <tag> is an integer that identifies the arrow. If no
 tag is given, the lowest unused tag value is assigned automatically.
 The tag can be used to delete or change a specific arrow. To change
 any attribute of an existing arrow, use the `set arrow` command with
 the appropriate tag, and specify the parts of the arrow to be
 changed. Specifying nohead requests the arrow be drawn without a head
 (yielding a line segment). By default, arrows have heads.
 
 Arrows outside the plotted boundaries are permitted but may cause
 device errors.
 
 Examples:
 
 To set an arrow pointing from the origin to (1,2), use:
          set arrow to 1,2
 To set an arrow from (-10,4,2) to (-5,5,3), and tag the arrow number
 3, use:
          set arrow 3 from -10,4,2 to -5,5,3
 To change the preceding arrow begin at 1,1,1, without an arrow head,
 use:
          set arrow 3 from 1,1,1 nohead
 To delete arrow number 2 use:
          set noarrow 2
 To delete all arrows use:
          set noarrow
 To show all arrows (in tag order) use:
          show arrow
3 autoscale
 Auto scaling may be set individually on the x, y or z axis
 or globally on all axes. The default is to autoscale all axes.
 
 When autoscaling, the plot range is automatically computed and the
 dependent axis (y for a `plot` and z for `splot`) is scaled to
 include the range of the function or data being plotted.
 
 If autoscaling of the dependent axis (y or z) is not set, the
 current y or z range is used.
 
 See `set yrange` or `set zrange`.
 
 Autoscaling the independent variables (x for `plot` and x,y for
 `splot`) is a request to set the domain to match any data file being
 plotted. If there are no data files then autoscaling an independent
 variable has no effect. In other words, in the absence of a data
 file, functions alone do not affect the x range (or the y range if
 plotting z = f(x,y)).
 
 See `set xrange`, or `set yrange`.
 
 The behavior of autoscaling remains consistent in parametric mode,
 however, there are more dependent variables and hence more control
 over x, y, and z plot scales. In parametric mode, the independent or
 dummy variable is t for `plot`s and u,v for `splot`s.  Autoscale in
 parametric mode, then, controls all ranges (t, u, v, x, y, and z) and
 allows x, y, and z to be fully autoscaled.
 
 See `set parametric`.
 
 Syntax:
         set autoscale <axes>
         set noautoscale <axes>
         show autoscale
 
 where <axes> is either `x`, `y`, `z` or `xy`. If <axes> is not given
 then all axes are assumed.
 
 Examples:
 
 This sets autoscaling of the y axis. x axis autoscaling is not
 affected.
         set autoscale y
 
 This sets autoscaling of the x and y axes.
         set autoscale xy
 
 This sets autoscaling of the x, y and z axes.
         set autoscale
 
 This disables autoscaling of the x, y and z axes.
         set noautoscale
 
 This disables autoscaling of the z axis only.
         set noautoscale z
4 parametric mode
 When in parametric mode (`set parametric`) the xrange is as
 fully scalable as the yrange. In other words, in parametric
 mode the x axis can be automatically scaled to fit the range
 of the parametric function that is being plotted. Of course,
 the y axis can also be automatically scaled just as in the
 non-parametric case. If autoscaling on the x axis is not set,
 the current x range is used.
 
 When there is a mix of data files and functions, the xrange of
 the functions is selected as that of the data files if autoscale
 is true for x. While this keeps the behavior compatible with
 non-parametric plotting, it may not be retained in the future.
 The problem is that, in parametric mode, the x and y ranges are
 not as distinguishable as in the non-parametric mode and this
 behavior may not be the most useful.
 
 For completeness a last command `set autoscale t` is accepted.
 However, the effect of this "scaling" is very minor. When
 GNUPLOT determines that the t range would be empty it makes a
 small adjustment if autoscaling is true. Otherwise, GNUPLOT
 gives an error. Such behavior may, in fact, not be very useful
 and the command `set autoscale t` is certainly questionable.
 
 `splot` extends the above idea similarly. If autoscaling is set then
 x, y, and z ranges are computed and each axis scaled to fit the
 resulting data.
3 border
 The `set border` and `set noborder` commands controls the display of
 the plot borders for the `plot` and `splot` commands.
 
 Syntax:
         set border
         set noborder
         show border
3 clip
 GNUPLOT can clip data points and lines that are near the boundaries
 of a plot. 
 
 Syntax:
         set clip <clip-type>
         set noclip <clip-type>
         show clip

 Three clip types are supported by GNUPLOT: `points`, `one`, and `two`.
 One, two, or all three clip types may be active for a single plot.

 The `points` clip type forces GNUPLOT to clip (actually, not plot at
 all) data points that fall within but too close to the boundaries
 (this is so the large symbols used for points will not extend outside
 the boundary lines). Without clipping points near the boundaries may
 look bad; try adjusting the x and y ranges.

 Setting the `one` clip type causes GNUPLOT to plot the line segments
 which have only one of the two endpoints with the plotting region.
 Only the in-range portion of the line is drawn.  The alternative is to
 not draw any portion of the line segment.

 Some lines may have both endpoints out of range, but pass through the
 plotting area. Setting the `two` clip-type allows the visible portion
 of these lines to be drawn.
 
 In no case is a line drawn outside the plotting area.

 The defaults are `noclip points`, `clip one`, and `noclip two`.

 To check the state of all forms of clipping, use
         show clip

 For backward compatibility with older versions, the following forms
 are also permitted.
        set clip
        set noclip
 `set clip` is synonymous with `set clip points`. `set noclip` turns
 off all three types of clipping.
3 cntrparam
 Sets the different parameters for the contouring plot (see also `contour`).
 
 Syntax:
         set cntrparam { { linear | cubicspline | bspline } |
                         points <n> |
                         levels <n> |
                         order <n> }
 
 This command controls the way contours are plotted. <n> should be an
 integral constant expression. The parameters are:
 
 `linear`, `cubicspline`, `bspline` - Controls type of approximation or
 interpolation. If `linear`, then the contours are drawn piecewise
 linear, as extracted from the surface directly. If `cubicspline`, then
 piecewise linear contours are interpolated to form a somewhat smoother
 contours, but which may undulate. The third option is the uniform
 `bspline`, which only approximates the piecewise linear data but is
 guaranteed to be smoother.
 
 `points` - Eventually all drawings are done with piecewise linear
 strokes.  This number controls the number of points used to
 approximate a curve.  Relevant for `cubicspline` and `bspline` modes
 only.
 
 `levels` - Number of contour levels. If the surface is bounded by zmin
 and zmax then contours will be generated from zmin+dz to zmax-dz
 in steps of size dz, where dz = (zmax - zmin) / (levels + 1).
 
 `order`  - Order of the bspline approximation to be used. The bigger this
 order is, the smoother the resulting contour.  (Of course, higher order
 bspline curves will move further away from the original peicewise linear
 data.)  This option is relevant for `bspline` mode only. Allowed values are 
 integers in the range from 2 (linear) to 10.
3 contour
 Enable contour drawing for surfaces. This option is available for `splot`
 only.
 
 Syntax:
         set contour { base | surface | both }
         set nocontour
 
 If no option is provided to `set contour`, the default is `base`.
 The three options specify where to draw the contours: `base` draws
 the contours on the grid base where the x/ytics are placed, `surface`
 draws the contours on the surfaces themselves, and `both` draws the
 contours on both the base and the surface.
 
 See also `set cntrparam` for the parameters that affect the drawing of 
 contours.
3 data style
 The `set data style` command changes the default plotting style
 for data plots.

 Syntax:
         set data style 
         show data style 
         set data style <style-choice>

 In the first case, `set data style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show data style` shows the current default
 plotting style for data.  `set data style dots` would actually 
 change the default plotting style.  See also `plot`.
3 dummy
 By default, GNUPLOT assumes that the independent variable for the
 `plot` command is x, and the independent variables for the `splot`
 command are x and y. They are called the dummy variables because it
 is just a notation to indicate the independent variables. The `set
 dummy` command changes these default dummy variable names. For
 example, it may be more convenient to call the dummy variable t
 when plotting time functions:
 
         set dummy t
         plot sin(t), cos(t)
 
 Syntax:
         set dummy <dummy-var>{,<dummy-var>}
         show dummy
 
 Examples:
         set dummy u,v
         set dummy ,s
 
 to set both dummy variables to u and v or set only the second
 variable to s.
 
 The `set parametric` command also changes the dummy variables (to t
 for `plot` and u,v for `splot`s).
 
3 format
 The format of the tic-mark labels can be set with the `set format`
 command. The default format for both axes is "%g", but other formats
 such as "%.2f" or "%3.0fm" are often desirable. Anything accepted by
 printf when given a double precision number, and then accepted by the
 terminal, will work. In particular, the formats f, e, and g will work,
 and the d, o, x, c, s, and u formats will not work.
 
 Syntax:
         set format {<axes>} {"<format-string>"}
         show format
 
 where <axes> is either `x`, `y`, `z`, `xy`, or nothing (which is the
 same as `xy`). The length of the string representing a ticmark (after
 formatting with printf) is restricted to 100 characters.  If the
 format string is omitted, the format will be returned to the default
 "%g". For LaTeX users, the format "$%g$" is often desirable.  If the
 empty string "" is used, no label will be plotted with each tic,
 though the tic mark will still be plotted. To eliminate all tic marks,
 use `set noxtics` or `set noytics`.
 
 See also `set xtics` and `set ytics` for more control over tic labels.
3 function style
 The `set function style` command changes the default plotting style
 for functions.

 Syntax:
         set function style 
         show function style 
         set function style <style-choice>

 In the first case, `set function style` returns the possible style
 choices:  `lines`, `points`, `linespoints`, `dots`, `impulses`, 
 or `errorbars`.  `show function style` shows the current default
 plotting style for functions.  `set function style linespoints`
 would actually change the default plotting style.  See also `plot`.
3 functions
 The `show functions` command lists all user-defined functions and
 their definitions.
 
 Syntax:
         show functions
3 grid
 The optional `set grid` draws a grid at the tic marks with the axis
 linetype.
 
 Syntax:
         set grid
         set nogrid
         show grid
3 hidden3d
 The `set hidden3d` command enables hidden line removal for explicit
 surface plotting (see `splot`).
 Hidden line removal may be used for both explicit functions
 and for explicit data where gnuplot plot is in nonparametric mode (see
 `set parametric`).
 
 When this flag is set both the surface hidden portion and possibly
 its hidden contours (see `set contour`) as well as the hidden grid will be
 removed. Labels and arrows are always visible and are unaffected by this
 command.
 
 Each surface has its hidden part removed with respect to itself, if more
 than one surface is ploted. This mode is meaningfull when surfaces are
 plotted using line style drawing only.

 Syntax:
         set hidden3d
         set nohidden3d
         show hidden3d
3 isosamples
 An isoline is a curve parametrized by one of the surface parameters
 while the other surface parameter is fixed. Isolines are a simple
 means to display a surface. By fixing the u parameter of surface
 s(u,v), the iso-u lines of the form c(v) = s(u0,v) are produced, and
 by fixing the v parameter, the iso-v lines of the form c(u) = s(u,v0)
 are produced.
 
 The isoline density of surfaces may be changed by the `set isosamples`
 command. By default, sampling is set to 10 isolines per u or v axis.
 A higher sampling rate will produce more accurate plots, but will take
 longer. This parameter has no effect on data file plotting.
 
 Syntax:
         set isosamples <expression>
         show isosamples
3 key
 The `set key` enables a key describing curves on a plot.  By default
 the key is placed in the upper right corner of the plot.
 
 Syntax:
         set key
         set key <x>,<y>{,<z>}
         set nokey
         show key
 
 The coordinates <x>, <y> (and <z> for `splot`s) specify the location
 of the key on the plot. The key is drawn as a sequence of lines, with
 one plot described on each line. On the right hand side of each line
 is a representation that attempts to mimic the way the curve is
 plotted.  On the left side of each line is the text description,
 obtained from the `plot` command. See `plot title` to change this
 description. The lines are vertically arranged so an imaginary
 straight line divides the left- and right-hand sides of the key. It is
 the coordinates of this line that are specified with the `set key`
 command. In a `plot`, only the x and y coordinates are used to specify
 the line position.  For a `splot`, x, y and z are all being used as a
 3-d location mapped using the same mapping as the plot itself to form
 the required 2-d screen position of the imaginary line.
 
 Some or all of the key may be outside of the plot boundary, although
 this may interfere with other labels and may cause an error on some
 devices.
 
 Examples:
 
 This places the key at the default location:
         set key
 This disables the key:
         set nokey
 This places a key at coordinates 2,3.5,2
         set key 2,3.5,2
3 label
 Arbitrary labels can be placed on the plot using the `set label`
 command.  If the z coordinate is given on a `plot` it is ignored; if
 it is missing on a `splot` it is assumed to be 0.
 
 Syntax:
 
          set label {<tag>} {"<label_text>"} {at <x>,<y>{,<z>}}
                            {<justification>}
          set nolabel {<tag>}
          show label
 
 
 The text defaults to "", and the position to 0,0,0.  The <x>, <y>, and
 <z> values are in the graph's coordinate system.  The tag is an
 integer that is used to identify the label. If no <tag> is given, the
 lowest unused tag value is assigned automatically. The tag can be used
 to delete or change a specific label. To change any attribute of an
 existing label, use the `set label` command with the appropriate tag,
 and specify the parts of the label to be changed.
 
 By default, the text is placed flush left against the point x,y,z.
 To adjust the way the label is positioned with respect to the point
 x,y,z, add the parameter <justification>, which may be `left`, `right`
 or `center`, indicating that the point is to be at the left, right or
 center of the text. Labels outside the plotted boundaries are
 permitted but may interfere with axes labels or other text.
 
 Examples:
 
 To set a label at (1,2) to "y=x" use:
          set label "y=x" at 1,2
 To set a label "y=x^2" with the right of the text at (2,3,4), and tag
 the label number 3, use:
          set label 3 "y=x^2" at 2,3,4 right
 To change the preceding label to center justification, use:
          set label 3 center
 To delete label number 2 use:
          set nolabel 2
 To delete all labels use:
          set nolabel
 To show all labels (in tag order) use:
          show label
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 logscale
 Log scaling may be set on the x, y, and z axes.
 
 Syntax:
         set logscale <axes>
         set nologscale <axes>
         show logscale
 
 where <axes> may be any combinations of `x`, `y`, and `z`, in any
 order.  If <axes> is not given then all three axes are assumed.  The
 command `set logscale` turns on log scaling on the specified axes,
 while `set nologscale` turns off log scaling.
 
 Examples:
 
 To enable log scaling in both x and z axes:
        set logscale xz
 To disable z axis log scaling:
        set nologscale z
3 mapping
 
 Syntax:
         set mapping { cartesian | spherical | cylindrical }
 
 Data for `splot`s are usually in regular Euclidean space and are
 provided in Cartesian coordinates. Such 3-d data require three
 coordinates (x, y and z) or one coordinate (only z) in each line in
 the data file.  In order to be able to use spherical or cylindrical
 coordinate systems, use the `set mapping` command. In both cases two
 coordinates are expected in each line of the data. For a spherical
 coordinate system, these are theta and phi (in units as specified by
 `set angles`) and the mapping is:
 
         x = cos( theta ) * cos( phi )
         y = sin( theta ) * cos( phi )
         z = sin( phi )
 
 For a cylindrical coordinate system, the mapping uses two variables,
 theta (in units as specified by `set angles`) and z:
 
         x = cos( theta )
         y = sin( theta )
         z = z
 
 Again, note that mapping will affect data file `splot`s only.
3 offsets
 The amount of the graph that the plot takes up may be controlled to
 some extent with the `set offsets` command. This command takes four
 offset arguments: <left>, <right>, <top> and <bottom>. By default,
 each offset is 0. Each offset may be a constant or an expression. Left
 and right offsets are given in units of the x axis, while top and
 bottom offsets are given in units of the y axis. The plot of sin(x),
 displayed with offsets of 0, 0, 2, 2 will take up 1/3 of the
 displayed y axis. Offsets are particularly useful with polar
 coordinates as a means of compensating for aspect ratio distortion.
 Offsets are ignored in `splot`s.
 
 Syntax:
         set offsets <left>, <right>, <top>, <bottom>
         show offsets
3 output
 By default, plots are displayed to the standard output. The `set
 output` command redirects the display to the specified file or
 device.
 
 Syntax:
         set output {"<filename>"}
         show output
 
 The filename must be enclosed in quotes. If the filename is
 omitted, output will be sent to the standard output.

 On machines with popen functions (UNIX), output can be piped
 through a shell command if the first letter of the filename
 is '|'.  For instance,
 
 Syntax:
         set output "|lpr -Plaser filename"
         set output "|lp -dlaser filename"

 (On MSDOS machines, set output "prn" will direct the output
 to the default printer.)

3 parametric
 The `set parametric` command changes the meaning of `plot` (`splot`)
 from normal functions to parametric functions. The command
 `set noparametric` changes the plotting style back to normal,
 single-valued expression plotting.
 
 In 2-d plotting, a parametric function is determined by a pair
 of parametric functions operating on a parameter. An example
 of a 2-d parametric function would be plot sin(t),cos(t) (which
 defines a circle).
 
 For 3-d plotting, the surface is described as x=f(u,v), y=g(u,v),
 z=h(u,v). Therefore a triplet of functions are required. An example of
 3-d parametric function would be cos(u)*cos(v),cos(u)*sin(v),sin(u)
 (which defines a sphere). It takes three parametric function
 specifications in terms of the parametric dummy arguments to describe
 a single graph.
 
 The total set of possible plots is a superset of the simple f(x)
 style plots, since the two (three) functions can describe the
 x and y (and z) values to be computed separately. In fact,
 plots of the type t,f(t) (u,v,f(u,v)) are equivalent to those
 produced with f(x) when the x values are computed using the
 identity function as the first function.
 
 Note that the order the parametric functions are specified is
 xfunction, yfunction (and zfunction) and that each operates over the
 common parametric domain.
 
 Also, the `set parametric` function implies a new range of values.
 Whereas the normal f(x) and f(x,y) style plotting assume an xrange
 and yrange (and zrange), the parametric mode additionally specifies a
 trange, urange, and vrange. These ranges may be set
 directly with `set trange`, `set urange` and `set vrange`, or by
 specifying the range on the `plot` or `splot` commands. Currently
 the default range for these parametric variables is [-5:5].
 Setting the ranges to something more meaningful is expected.
3 polar
 The `set polar` command changes the meaning of the plot from
 rectangular coordinates to polar coordinates. In polar coordinates,
 the dummy variable (x) is an angle. The range of this angle is changed
 from whatever it was to [0:2*pi], or, if degree unit has been selected,
 to [0:360] (see `set angles`).
 
 The command `set nopolar` changes the meaning of the plot back to the
 default rectangular coordinate system. The range of x is changed from
 whatever it was to [-10:10].
 
 The `set polar` command is not supported for `splot`s.  See the
 `set mapping` command for similar functionality for `splot`s.
 
 While in polar coordinates the meaning of an expression in x is really
 r = f(x), where x is an angle of rotation. The xrange controls the
 domain (the angle) of the function, and the yrange controls the range
 (the radius). The plot is plotted in a rectangular box, and the x and
 y axes are both in units of the radius. Thus, the yrange controls both
 dimensions of the plot output. The tics and units are written along
 the axes rather than at the left and bottom. These unit are offset by
 <rmin> specified by the `rrange` (See `set rrange`). It is not
 possible to specify different output dimensions in the x or y
 directions. The yrange can be used to shift the plot diagonally to
 display only the first or third quadrants.
 
 Syntax:
         set polar
         set nopolar
         show polar
 Example:
         set polar
         plot x*sin(x)
         plot [-2*pi:2*pi] [-3:3] x*sin(x)
 The first plot uses the default polar angular domain of 0 to 2*pi.
 The radius (and the size of the plot) is scaled automatically. The
 second plot expands the domain, and restricts the range of the radius
 (and the size of the plot) to [-3:3].
3 rrange
 The `set rrange` command sets the radial range used to compute x and y
 values when in polar mode. If not in polar mode (see `set polar`) then
 this range is not used. Use of this command offsets the polar
 singularity to the <rmin> value and shifts the units on the axes tic
 marks. For instance, `set rrange [-40:40]` would set the origin to -40
 and would plot values of radial values between -40 to 40. Thus, if
 360 degrees of data were plotted, then the plot would extend 80 units
 in radially from the origin.  To view the entire plot,  a 
 `set yrange [-80:80]` command would create a square viewport with
 a circular plot tangent at the axes.  Because `xrange` is used
 specify the angular extent, only a square viewport can be specified
 by `yrange`.  For instance, `set yrange [0:80]` would display the
 first quadrant and `set yrange [-80:0]` would display the third
 quadrant.  Any square viewport of any size can be specified but it
 is constrained to be centered on a 45 degree line.
 
 This range may also be specified on the `plot` command line when in
 polar mode.
 
 Syntax:
         set rrange [{<rmin> : <rmax>}]
 
 where <rmin> and <rmax> terms are constants or expressions.
 
 Both the <rmin> and <rmax> terms are optional. Anything omitted will
 not be changed, so 
         set rrange [:10]
 changes rmax to 10 without affecting rmin.
3 samples
 The sampling rate of functions may be changed by the `set samples`
 command. By default, sampling is set to 100 points. A higher sampling
 rate will produce more accurate plots, but will take longer. This
 parameter no longer has any effect on data-file plotting.
 
 Syntax:
         set samples <expression>
         show samples
3 size
 The `set size` command scales the displayed size of the plot.  On some
 terminals, changing the size of the plot will result in text being
 misplaced. Increasing the size of the plot may produce strange
 results. Decreasing is safer.
 
 Syntax:
 
         set size {<xscale>,<yscale>}
         show size
 
 The <xscale> and <yscale> values are the scaling factors for the size.
 The defaults (1,1) are selected if the scaling factors are omitted.
 
 Examples: 
 
 To set the size to normal size use:
         set size
 To make the plot half size use:
         set size 0.5,0.5
 To make a landscape plot have a 1:1 aspect ratio in polar mode use:
         set size 0.721,1.0
 To show the size use:
         show size
 
 For the LaTeX and Fig terminals the default size (scale factor 1,1)
 is 5 inches wide by 3 inches high. The big Fig terminal (`bfig`) is 7
 inches wide by 5 inches high. The postscript default is landscape mode
 10 inches wide and 7 inches high. 
 Note that the size of the plot includes the space used by the labels; 
 the plotting area itself is smaller. 
3 style
 Plots may be displayed in one of six styles: `lines`, `points`,
 `linespoints`, `impulses`, `dots`, or `errorbars`. The `lines` style
 connects adjacent points with lines. The `points` style displays a
 small symbol at each point. The `linespoints` style does both
 `lines` and `points`. The `impulses` style displays a vertical line
 from the x axis to each point. The `dots` style plots a tiny dot at
 each data point; this is useful for scatter plots with many points.
 
 The `errorbars` style is relevant only for to data file `plot`s. It is
 treated like `points` for function `plot`s and `splot`s. For data file
 `plot`s, `errorbars` is like `points`, except that a vertical error
 bar is also drawn: for each point (x,y), a line is drawn from (x,ylow)
 to (x,yhigh). A tic mark is placed at the ends of the error bar. The
 ylow and yhigh values are read from the data file's third and fourth
 columns, or as specified with the `using` option to plot.  See `plot
 errorbars` for more information.
 
 Default styles are chosen with the `set function style` and `set
 data style` commands. See `plot style` for information about how
 to override the default plotting style for individual functions.
 
 Syntax:
         set function style <style>
         set data style <style>
         show function style
         show data style
 
 where <style> is `lines`, `points`, `linespoints`, `impulses`,
 `dots`, or `errorbars`.
3 surface
 `set surface` controls the display of surfaces. It is useful if
 contours are to be displayed by themselves. Whenever `set nosurface`
 is issued, no surface isolines/mesh will be drawn. See also `set
 contour`.
 
 Syntax:
         set surface
         set nosurface
         show surface
3 terminal
 GNUPLOT supports many different graphics devices. Use the `set
 terminal` command to select the type of device for which GNUPLOT
 will produce output.
 
 Syntax:
         set terminal {<terminal-type>}
         show terminal
 
 If <terminal-type> is omitted, GNUPLOT will list the available
 terminal types. <terminal-type> may be abbreviated.
 
 Use `set output` to redirect this output to a file or device.

 Several terminals have additional options. For example, see `dumb`,
 `iris4d`, `hpljii` or `postscript`.
4 dumb
 The dumb terminal driver has an optional size specification.

 Syntax:
         set terminal dumb {<xsize> <ysize>}

 where <xsize> and <ysize> set the size of the dumb terminals. Default
 is 79 by 24.

 Examples:
         set term dumb
         set term dumb 79 49 #(VGA screen - why would anyone want to do that!?)
 
4 hpljii
 The HP LaserJet II and HP DeskJet drivers have a single option.

 Syntax:
         set terminal hpljii {<resolution>}
         set terminal hpdj   {<resolution>}

 where <resolution> is the resolution of the output in dots per inch.
 It must be `75`, `100`, `150` or `300`.

 Example:
         set terminal hpljii 150
 
4 iris4d
 The iris4d driver can operate in two modes.

 Syntax:
         set terminal iris4d {24}

 If the hardware supports only 8 bits, use the default `set terminal
 iris4d`. If, however, the hardware supports 24 bits (8 per
 red/green/blue), use `set terminal iris4d 24`.

 When using 24-bit mode, the colors can be directly specified via the
 file .gnuplot_iris4d that is searched in the current directory and
 then in the home directory specified by the HOME environment variable.
 This file holds RGB values for the background, border, labels and nine
 plotting colors, in that order. For example, here is a file containing
 the default colors:
 
         85   85   85     /* Back Ground */
         0    0    0      /* Boundary */
         170  0    170    /* Labeling */
         85   255  255    /* Plot Color 1 */
         170  0    0      /* Plot Color 2 */
         0    170  0      /* Plot Color 3 */
         255  85   255    /* Plot Color 4 */
         255  255  85     /* Plot Color 5 */
         255  85   85     /* Plot Color 6 */
         85   255  85     /* Plot Color 7 */
         0    170  170    /* Plot Color 8 */
         170  170  0      /* Plot Color 9 */
 
 This file has exactly 12 lines of RGB triples. No empty lines are
 allowed and anything after the third number in line is ignored.
 
4 pbm
 Several options may be set in the PBMplus driver.

 Syntax:
         set terminal pbm {<fontsize>}
         set terminal pgm {<fontsize>}
         set terminal ppm {<fontsize>}

 where <fontsize> is `small`, `medium`, or `large`. 
 Default size is 640 pixels wide and 480 pixels high.
 The pbm output is a portable bitmap (one bit per pixel).
 The pgm output is a portable graymap (three bits per pixel). 	
 The ppm output is a portable pixmap (color, four bits per pixel).
 The output of these drivers can be used with Jef Poskanzer's 
 excellent PBMPLUS package which provides programs to convert
 the above PBMPLUS formats to GIF, TIFF, MacPaint, Macintosh PICT,
 PCX, X11 bitmap and many others. 

 Examples:
 
         set term pbm small
         set size 2,2
         set term ppm medium
 
4 postscript
 Several options may be set in the PostScript driver.

 Syntax:
         set terminal postscript {<mode>} {<color>}
                                 {"<fontname>"} {<fontsize>}

 where <mode> is `landscape`, `portrait`, `eps` or `default`. 
 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `landscape`, `monochrome`, "Courier", and 14pt.
 Default size of PostScript plot is landscape mode 10 inches wide 
 and 7 inches high.

 To get EPS output, use the `eps` mode and make only one plot per file.
 In `eps` mode the whole plot is halved in size; the fonts are half the 
 given size, and the plot is 5 inches wide and 3.5 inches high.

 Examples:
 
         set term postscript default       # old postscript
         set term postscript landscape 22  # old psbig
         set term postscript eps 14   # old epsf1
         set term postscript eps 22   # old epsf2
         set size 0.7,1.4
         set term post portrait color "Times-Roman" 14 
 
4 aifm
 Several options may be set in the Adobe Illustrator 3.0 driver.

 Syntax:
         set terminal aifm {<color>}
                                 {"<fontname>"} {<fontsize>}

 Selecting default sets all options to their defaults.
 <color> is either `color` or `monochrome`.
 "<fontname>" is the name of a valid PostScript font.
 <fontsize> is the size of the font in PostScript points, before 
 scaling by the `set size` command.
 Defaults are `monochrome`, "Courier", and 14pt.

 Also, since AI does not really support multiple pages, multiple 
 graphs will be output directly on one another.  However, each graph 
 will be grouped individually, making it easy to separate them inside 
 AI (just pick them up and move them).

 Examples:
 
         set term aifm 
         set term aifm 22  
         set size 0.7,1.4
         set term aifm color "Times-Roman" 14 
 
4 table
 Instead of producing a picture, term type 'table' prints out
 the evaluation results in a multicolumn ASCII table of X Y Z values.
 For those times when you really want to see the numbers, now you
 can see them on the screen or save to a file.

3 tics
 By default, tics are drawn inwards from the border on all four sides.
 The `set tics` command can be used to change the tics to be 
 drawn outwards on the left and bottom borders only.
 This is useful when doing impulse plots.
 
 Syntax:
         set tics {<direction>}
         show tics
 
 where <direction> may be `in` or `out`. `set tics` defaults to `in`.
 
 See also the `set xtics`, `set ytics`, and `set ztics` command for more
 control of tic marks.
 Using splot, in 3-d plots, one can adjust the relative height of the
 vertical (Z) axis using `set ticslevel`. The numeric argument provided
 specifies the location of the bottom of the scale. a zero will put it
 on the bottom grid and any positive number somewhere along the z axis.
 
 Syntax:
         set ticslevel {<level>}
         show tics
 
 where <level> is a non negative numeric argument. For example,

         set ticslevel 0.5

 sets the tics level to the default value.
 
 See also the `set view`.
3 time
 The optional `set time` places the time and date of the plot either
 at the top or bottom of the left margin. The exact location is
 device dependent.
 
 Syntax:
         set time {<xoff>}{,<yoff>}
         set notime
         show time
 
 Specifying constants <xoff> or <yoff> as optional offsets for the time
 will move the time <xoff> or <yoff> character screen coordinates. For
 example,
 
         set time ,-3
 
 will change only the y offset of the time, moving the title down by
 roughly the height of three characters.
 
3 title
 The `set title` command produces a plot title that is centered at the
 top of the plot. Using the optional x,y screen offsets, the title
 can be placed anywhere on the plot. `set title` with no parameters
 clears the title.
 
 Syntax:
          set title {"<title-text>"} {<xoff>}{,<yoff>}
          show title
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 title will move the title <xoff> or <yoff> character screen
 coordinates. Note these are screen coordinates and not plot
 coordinates. For example,
 
          set title ,-1
 
 will change only the y offset of the title, moving the title down by
 roughly the height of one character.
 
 (The Latex, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 trange
 The `set trange` command sets the parametric range used to compute
 x and y values when in parametric mode. If not in parametric mode
 (see `set parametric`) then this range is not used. This command
 does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `plot` command line when
 in parametric mode.
 
 Syntax:
         set trange [{<tmin> : <tmax>}]
 
 where <tmin> and <tmax> terms are constants or expressions.
 
 Both the <tmin> and <tmax> terms are optional. Anything omitted will
 not be changed, so 
         set trange [:10]
 changes tmax to 10 without affecting tmin.  See also `set urange` and
 `set parametric`.
3 urange
 The `set urange` and `set vrange` commands sets the parametric ranges used 
 to compute x, y, and z values when in `splot` parametric mode. If not in 
 parametric mode (see `set parametric`) then these ranges are not used. This 
 command does not affect x/y autoscaling or x/y ranges.
 
 This range may also be specified on the `splot` command line when
 in parametric mode.  See `plot` for more information
 
 Syntax:
         set urange [{<umin> : <umax>}]
 
 where <umin> and <umax> terms are constants or expressions.
 
 Both the <umin> and <umax> terms are optional. Anything omitted will
 not be changed, so 
         set urange [:10]
 changes umax to 10 without affecting umin.  See also `set trange`.
3 variables
 The `show variables` command lists all user-defined variables and
 their values.
 
 Syntax:
         show variables
3 view
 The `set view` command sets the view point for `splot`s. This
 command controls the way the 3-d coordinates of the plot are mapped
 into the 2-d screen space. This command provides controls to both
 rotation and scaling of the plotted data but supports orthographic
 projections only.
 
 Syntax:
         set view <rot_x> {,{<rot_z>}{,{<scale>}{,<scale_z>}}}
         show view
 
 where <rot_x> and <rot_z> control the rotation angles (in degrees)
 along a virtual 3-d coordinate system aligned with the screen such
 that the screen horizontal axis is x, screen vertical axis is y, and
 the axis perpendicular to the screen is z. <rot_x> is bounded to the
 [0:180] range with a default of 60 degrees, while <rot_z> is bounded
 to the [0:360] range with a default of 30 degrees. <scale> controls
 the scaling of the entire `splot`, while <scale_z> scales the z axis
 only. Both scales default to 1.0.
 
 Examples:
         set view 60, 30, 1, 1
         set view ,,0.5
 
 The first sets all the four default values. The second changes 
 only scale, to 0.5.

 See also `set ticslevel`.
3 vrange
 The `set vrange` command is similar to the `set urange` command.
 Please see `set urange`.
3 xlabel
 The `set xlabel` command sets the x-axis label that is centered along
 the x axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set xlabel` with no parameters clears
 the label.
 
 Syntax: 
          set xlabel {"<label>"} {<xoff>}{,<yoff>}
          show xlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set xlabel -1
 
 will change only the x offset of the xlabel, moving the label roughly
 one character width to the left.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 xrange
 The `set xrange` command sets the horizontal range that will be
 displayed. This command turns x axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set xrange [{<xmin> : <xmax>}]
 
 where <xmin> and <xmax> terms are constants or expressions.
 
 Both the <xmin> and <xmax> terms are optional. Anything omitted will
 not be changed, so 
         set xrange [:10]
 changes xmax to 10 without affecting xmin.
3 xtics
 Fine control of the x axis tic marks is possible with the
 `set xtics` command. The x-axis tic marks may be turned off with the
 `set noxtics` command. They may be turned on (the default state) with
 `set xtics`.
 
 Syntax:
          set xtics { {<start>, <incr>{, <end>}} |
                      {({"<label>"} <pos> {, {"<label>"} <pos>}...)} }
          set noxtics
          show xtics

 The <start>, <incr>, <end> form specifies that a series of tics will
 be plotted on the x axis between the x values <start> and <end>
 with an increment of <incr>. If <end> is not given it is assumed to be
 infinity. The increment may be negative. For example,
           set xtics 0,.5,10
 makes tics at 0, 0.5, 1, 1.5, ..., 9.5, 10.
 
 The ("<label>" <pos>, ...) form allows arbitrary tic positions or
 non-numeric tic labels. A set of tics are a set of positions, each
 with its own optional label. Note that the label is a string enclosed
 by quotes, and may be a constant string, such as "hello", or contain
 formatting information for the tic number (which is the same as the
 position), such as "%3f clients". See `set format` for more
 information about this case. The label may even be empty.
 Examples:
          set xtics ("low" 0, "medium" 50, "high" 100)
          set xtics (1,2,4,8,16,32,64,128,256,512,1024)
          set xtics ("bottom" 0, "" 10, "top" 20)
 
 Tics will only be plotted when in range.
 
 The `set ytics` and `set noytics` commands work identically.
 See also the `set format` command.
3 xzeroaxis
 `set xzeroaxis` draws the x-axis. By default, this option is on.
 `set noxzeroaxis` causes GNUPLOT to omit the x-axis.
 
 Syntax:
         set xzeroaxis
         set noxzeroaxis
         show xzeroaxis
3 ylabel
 The `set ylabel` command sets the y-axis label.  The position of this
 label depends on the terminal, and can be one of the following three
 positions (the position can be adjusted with optional parameters).
 
 1. Horizontal text flushed left at the top left of the plot.
 Terminals that cannot rotate text will probably use this method.
 
 2. Vertical text centered vertically at the left of the plot.
 Terminals that can rotate text will probably use this method.
 
 3. Horizontal text centered vertically at the left of the plot.
 The LaTeX and EEPIC drivers use this method. The user must insert 
 line breaks using \\ to prevent the ylabel from overwriting
 the plot. To produce a vertical row of characters, add \\
 between every printing character (but this is ugly).
 
 Syntax:  
          set ylabel {"<label>"} {<xoff>}{,<yoff>}
          show ylabel
 
 With no parameters, the label is cleared. Specifying constants <xoff>
 or <yoff> as optional offsets for the label will move the label <xoff>
 or <yoff> character screen coordinates. For example,
 
          set ylabel -1
 
 will change only the x offset of the ylabel, moving the label roughly
 one character width left of its default position. This is especially
 useful with the LaTeX driver.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 yrange
 The `set yrange` command sets the vertical range that will be
 displayed. This command turns y axis autoscaling off.
 
 This range may also be specified on the `plot` command line.
 
 Syntax:
         set yrange [{<ymin> : <ymax>}]
 
 where <ymin> and <ymax> terms are constants or expressions.
 
 Both the <ymin> and <ymax> terms are optional. Anything omitted will
 not be changed, so 
         set yrange [:10]
 changes ymax to 10 without affecting ymin.
3 ytics
 The `set ytics` and `set noytics` commands are similar to the `set xtics`
 and `set noxtics` commands. Please see `set xtics`.
3 yzeroaxis
 `set yzeroaxis` draws the y-axis. By default, this option is on.
 `set noyzeroaxis` causes GNUPLOT to omit the y-axis.
 
 Syntax:
         set yzeroaxis
         set noyzeroaxis
         show yzeroaxis
3 zero
 The `zero` value is the default threshold for values approaching 0.0.
 GNUPLOT will not plot a point if its imaginary part is greater in
 magnitude than the `zero` threshold. Axis ranges cannot be less than
 `zero`. The default `zero` value is 1e-8. This can be changed with
 the `set zero` command.

 Syntax:
         set zero <expression>
         show zero
3 zeroaxis
 `set zeroaxis` draws the x-axis and y-axis. By default, this option is
 on.  `set nozeroaxis` causes GNUPLOT to omit the axes, and is
 equivalent to `set noxzeroaxis; set noyzeroaxis.`
 
 Syntax:
         set zeroaxis
         set nozeroaxis
         show zeroaxis
 See `set xzeroaxis` and `set yzeroaxis`.
3 zlabel
 The `set zlabel` command sets the z-axis label that is centered along
 the z axis. Using the optional x,y screen offsets, the label can be
 placed anywhere on the plot. `set zlabel` with no parameters clears
 the label.
 
 Syntax: 
          set zlabel {"<label>"} {<xoff>}{,<yoff>}
          show zlabel
 
 Specifying constants <xoff> or <yoff> as optional offsets for the
 label will move the label <xoff> or <yoff> character screen
 coordinates. For example,
 
          set zlabel ,1
 
 will change only the y offset of the zlabel, moving the label roughly
 one character height up.
 
 The zlabel will be drawn whenever surfaces or contours are plotted,
 in the space above the grid level.
 
 (The LaTeX, EEPIC, and Imagen drivers allow \\ in a string to specify
 a newline.)
3 zrange
 The `set zrange` command sets the vertical range that will be
 displayed. This command turns z axis autoscaling off.  The zrange is
 used only by `splot` and is ignored by `plot`.
 
 This range may also be specified on the `splot` command line.
 
 Syntax:
         set zrange [{<zmin> : <zmax>}]
 
 where <zmin> and <zmax> terms are constants or expressions.
 
 Both the <zmin> and <zmax> terms are optional. Anything omitted will
 not be changed, so
         set zrange [2:]
 changes zmin to 2 without affecting zmax.
3 ztics
 The `set ztics` and `set noztics` commands are similar to the `set
 xtics` and `set noxtics` commands. Please see `set xtics`.
2 shell
 The `shell` command spawns an interactive shell. To return to
 GNUPLOT, type `logout` if using VMS, `exit` or the END-OF-FILE
 character if using Unix, `endcli` if using AmigaDOS, or `exit` if
 using MS-DOS.
 
 A single shell command may be spawned by preceding it with the !
 character ($ if using VMS) at the beginning of a command line.
 Control will return immediately to GNUPLOT after this command is
 executed. For example, in VMS, AmigaDOS, or MS-DOS,
 
      ! dir
 
 prints a directory listing and then returns to GNUPLOT.
2 splot
 Three-dimensional surface and contour plotting is available in
 GNUPLOT with the `splot` command. See the `plot` command for features
 common to the `plot` command.
 
 See also `set contour`, `set cntrparam`, and `set surface`.
2 start-up
 When GNUPLOT is run, it looks for an initialization file to load.
 This file is called `.gnuplot` on Unix and AmigaDOS systems, and
 `GNUPLOT.INI` on other systems. If this file is not found in the
 current directory, the program will look for it in the home directory
 (under AmigaDOS and MS-DOS, the environment variable GNUPLOT should
 contain the name of this directory).
 
 If this file is found, GNUPLOT executes the commands in this file.
 This is most useful for setting the terminal type and defining any
 functions or variables that are used often.
2 substitution
 Command-line substitution is specified by a system command enclosed in
 backquotes. This command is spawned and the output it produces
 replaces the name of the command (and backquotes) on the command line.
 
 Newlines in the output produced by the spawned command are replaced
 with blanks.
 
 Command-line substitution can be used anywhere on the GNUPLOT command
 line.
 
 Example:
 
 This will run the program `leastsq` and replace `leastsq` (including
 backquotes) on the command line with its output:
 
          f(x) = `leastsq`
 
 or, in VMS
 
          f(x) = `run leastsq`
2 user-defined
 New user-defined variables and functions of one or two variables may be 
 declared and used anywhere.
 
 User-defined function syntax:
         <function-name> ( <dummy-var1> {,<dummy-var2>} ) =  <expression>
 
 where <expression> is defined in terms of <dummy-var1> and <dummy-var2>.

 User-defined variable syntax:
         <variable-name> = <constant-expression>
 
 Examples:
         w = 2
         q = floor(tan(pi/2 - 0.1))
         f(x) = sin(w*x)
         sinc(x) = sin(pi*x)/(pi*x)
         delta(t) = (t == 0)
         ramp(t) = (t > 0) ? t : 0
         min(a,b) = (a < b) ? a : b
         comb(n,k) = n!/(k!*(n-k)!)
 
 Note that the variable `pi` is already defined.
 
 See `show functions` and `show variables`.
2 bugs
 The bessel functions do not work for complex arguments.
 
 The gamma function does not work for complex arguments.
 
 There is a bug in the stdio library for old Sun operating systems
 (SunOS Sys4-3.2). The "%g" format for 'printf' sometimes incorrectly
 prints numbers (e.g., 200000.0 as "2"). Thus, tic mark labels may be
 incorrect on a Sun4 version of GNUPLOT. A work-around is to rescale
 the data or use the `set format` command to change the tic mark format
 to "%7.0f" or some other appropriate format. This appears to have been
 fixed in SunOS 4.0.
 
 Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
 and SunOS 4.0, the 'sscanf' routine incorrectly parses "00 12" with
 the format "%f %f" and reads 0 and 0 instead of 0 and 12. This
 affects data input. If the data file contains x coordinates that are
 zero but are specified like '00', '000', etc, then you will read the
 wrong y values. Check any data files or upgrade the SunOS.
 It appears to have been fixed in SunOS 4.1.1.
 
 Microsoft C 5.1 has a nasty bug associated with the %g format for
 printf. When any of the formats "%.2g", "%.1g", "%.0g", "%.g" are
 used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.
 Numbers that should be printed in the %e format are incorrectly 
 printed in the %f format, with the wrong number of zeros after the 
 decimal point.

 To work around this problem, use the %e or %f formats explicitly.
 
 GNUPLOT, when compiled with Microsoft C, did not work correctly on two
 VGA displays that were tested. The CGA, EGA and VGA drivers should 
 probably be rewritten to use the Microsoft C graphics library.
 GNUPLOT compiled with Turbo C uses the Turbo C graphics drivers and 
 does work correctly with VGA displays.
 
 VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented %g 
 format for printf. The numbers are printed numerically correct, but 
 may not be in the requested format. The K&R second edition says that 
 for the %g format, %e is used if the exponent is less than -4 or greater 
 than or equal to the precision. The VAX uses %e format if the exponent 
 is less than -1. The VAX appears to take no notice of the precision 
 when deciding whether to use %e or %f for numbers less than 1.
 To work around this problem, use the %e or %f formats explicitly.
 From the VAX C 2.4 release notes:
 e,E,f,F,g,G  Result will always contain a decimal  point.
 For g and G, trailing zeros will not be removed from the result.
 
 VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
 %g format than release 2.4, but not much. Trailing decimal points are 
 now removed, but trailing zeros are still not removed from %g numbers 
 in exponential format.

 ULTRIX X11R3 has a bug that causes the X11 driver to display "every
 other" plot.  The bug seems to be fixed in DEC's release of X11R4 so
 newer releases of ULTRIX don't seem to have the problem.  Solutions for 
 older sites include upgrading the X11 libraries (from DEC or direct from 
 MIT) or defining ULTRIX_KLUDGE when compiling the x11.trm file.  Note 
 that the kludge is not an ideal fix, however.

 The constant HUGE was incorrectly defined in the NeXT OS 2.0 operating
 system.  HUGE should be set to 1e38 in plot.h. This error has been
 corrected in the 2.1 version of NeXT OS.

 Some older models of HP plotters do not have a page eject command 'PG'.
 The current HPGL driver uses this command in HPGL_reset.  This may need
 to be removed for these plotters.  The current PCL5 driver uses HPGL/2
 for text as well as graphics.  This should be modified to use scalable
 PCL fonts.

 Please report any bugs to bug-gnuplot@ames.arc.nasa.gov.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.log version [cc93b1d07d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
This is TeX, C Version 3.141 (format=lplain 92.7.16)  30 OCT 1992 17:58
**gnuplot
(gnuplot.tex
LaTeX Version 2.09 <25 March 1992>
(titlepage.tex (/silo/tex/inputs/latex.new/sty/article.sty
Standard Document Style `article' <14 Jan 92>.
(/silo/tex/inputs/latex.new/sty/art10.sty)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
) (toc_entry.sty
`toc_entry.sty' 1.0 of 13 Dec 90
\twonum=\skip41
\threenum=\skip42
\fournum=\skip43
\fivenum=\skip44
\sixnum=\skip45
) (gnuplot.aux) [1

] (gnuplot.toc [2] [3])
\tf@toc=\write3
 [4]) [1] [2]
Overfull \hbox (4.10852pt too wide) in paragraph at lines 145--151
\tenrm mode of op-er-a-tion as 'Name.Mode'. For ex-am-ple, if the Su-per VGA dr
iver is C:$\tensy n$\tenrm TC$\tensy n$\tenrm BGI$\tensy n$\tenrm SVGADRV.BGI

\hbox(7.5+2.5)x451.6875, glue set - 1.0
.\tenrm m
.\tenrm o
.\kern0.27779
.\tenrm d
.\tenrm e
.etc.

[3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
[19] [20] [21] [22] [23] [24] [25] [26] [27] [28]
Overfull \hbox (12.37064pt too wide) in paragraph at lines 1901--1907
[]\tenrm Selecting de-fault sets all op-tions to their de-faults. $\tenmi <$\te
nrm color$\tenmi >$ \tenrm is ei-ther \tenbf color \tenrm or \tenbf monochrome\
tenrm . ''$\tenmi <$\tenrm fontname$\tenmi >$\tenrm ''

\hbox(6.94444+1.94444)x451.6875, glue set - 1.0
.\hbox(0.0+0.0)x0.0
.\tenrm S
.\tenrm e
.\tenrm l
.\tenrm e
.etc.

[29] [30] [31] [32] [33] [34] [35] [36] [37] [38] (gnuplot.aux) ) 
Here is how much of TeX's memory you used:
 184 strings out of 11973
 1781 string characters out of 87090
 37583 words of memory out of 262141
 2128 multiletter control sequences out of 9500
 19304 words of font info for 73 fonts, out of 100000 for 255
 14 hyphenation exceptions out of 607
 15i,10n,16p,166b,248s stack positions out of 300i,40n,60p,3000b,4000s

Output written on gnuplot.dvi (42 pages, 139616 bytes).
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































Deleted r34.1/plot/docs/gnuplot.tex version [0479ec0501].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
\input{titlepage.tex}
\section{Gnuplot}
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 a line, separated by semicolons (;).
Strings are indicated with quotes.  They may be either single or double
quotation marks, e.g.,

\begin{verbatim}
         load "filename"
         cd 'dir'
\end{verbatim}

Any command-line arguments are assumed to be names of files containing 
GNUPLOT commands, with the exception of standard X11 arguments, which
are processed first. Each file is loaded with the {\bf load} command, in the
order specified. GNUPLOT exits after the last file is processed.  When
no load files are named, gnuplot enters into an interactive mode.

Commands may extend over several input lines, by ending each 
line but the last with a backslash ($\backslash$). The backslash must be the LAST
character on each line. The effect is as if the backslash and newline
were not there. That is, no white space is implied, nor is a comment
terminated. Therefore, commenting out a continued line comments out
the entire command (see {\bf comment}).

In this documentation, curly braces (\{\}) denote optional arguments to
many commands, and a vertical bar ($|$) separates mutually exclusive
choices.  GNUPLOT keywords or help topics are indicated by backquotes
or {\bf boldface} (where available).  Angle brackets ($<$$>$) are used to mark
replaceable tokens.

For help on any topic, type {\bf help} followed by the name of the topic.

The new GNUPLOT user should begin by reading about the {\bf plot}
command (type {\bf help plot}).
\section{Cd}
The {\bf cd} command changes the working directory.

Syntax:
\begin{verbatim}
        cd "<directory-name>"
\end{verbatim}

The directory name must be enclosed in quotes.

Examples:
\begin{verbatim}
        cd 'subdir'
        cd ".."
\end{verbatim}
\section{Clear}
The {\bf clear} command erases the current screen or output device as
specified by {\bf set output}. This usually generates a formfeed on
hardcopy devices. Use {\bf set terminal} to set the device type.
\section{Command-line editing}
The Unix and IBM PC versions of GNUPLOT support command-line editing.
Also, a history mechanism allows previous commands to be edited, and
re-executed. After the command line has been edited, a newline or
carriage return will enter the entire line regardless of where the
cursor is positioned.

The editing commands are as follows:


\begin{center}
\begin{tabular}{|ccl|} \hline
Character && Function \\ \hline 
\multicolumn{3}{|c|}{Line Editing}\\
\verb~^B~ && move back a single character.\\
\verb~^F~ && move forward a single character.\\
\verb~^A~ && move to the beginning of the line.\\
\verb~^E~ && move to the end of the line.\\
\verb~^H, DEL~ && delete the previous character.\\
\verb~^D~ && delete the current character.\\
\verb~^K~ && delete from current position to the end of line.\\
\verb~^L, ^R~ && redraw line in case it gets trashed.\\
\verb~^U~ && delete the entire line. \\
\verb~^W~ && delete from the current word to the end of line. \\ \hline
\multicolumn{3}{|c|}{History} \\
\verb~^P~ && move back through history.\\
\verb~^N~ && move forward through history.\\
\hline
\end{tabular}
\end{center}

On the IBM PC the use of a TSR program such as DOSEDIT or CED may be
desired for line editing. For such a case GNUPLOT may be compiled with
no line editing capability (default makefile setup). Set READLINE in the
makefile and add readline.obj to the link file if GNUPLOT line editing
is to be used for the IBM PC. The following arrow keys may be used
on the IBM PC version if readline is used:


\begin{center}
\begin{tabular}{|ccl|} \hline
Arrow key & Function & \\ \hline 
Left      & same as \verb~^B~. & \\
Right     & same as \verb~^F~. & \\
Ctl Left  & same as \verb~^A~. & \\
Ctl Right & same as \verb~^E~. & \\
Up        & same as \verb~^P~. & \\
Down      & same as \verb~^N~. & \\
\hline
\end{tabular}
\end{center}
(The readline function in gnuplot is not the same as the readline used
in GNU BASH and GNU EMACS.  It is somewhat compatible however.) 
\section{Comment}
Comments are supported as follows: a \# may appear in most places in a line
and GNUPLOT will ignore the rest of the line. It will not have this
effect inside quotes, inside numbers (including complex numbers), inside
command substitutions, etc. In short, it works anywhere it makes sense
to work.
\section{Environment}
A number of shell environment variables are understood by GNUPLOT.
None of these are required, but may be useful.

If GNUTERM is defined, it is used as the name of the terminal type to
be used. This overrides any terminal type sensed by GNUPLOT on start
up, but is itself overridden by the .gnuplot (or equivalent) start-up
file (see {\bf start-up}), and of course by later explicit changes.

On Unix, AmigaDOS, and MS-DOS, GNUHELP may be defined to be the pathname
of the HELP file (gnuplot.gih).

On VMS, the symbol GNUPLOT\$HELP should be defined as the name of 
the help library for GNUPLOT.

On Unix, HOME is used as the name of a directory to search for 
a .gnuplot file if none is found in the current directory.
On AmigaDOS and MS-DOS, GNUPLOT is used. On VMS, SYS\$LOGIN: is used.
See help start-up.

On Unix, PAGER is used as an output filter for help messages.

On Unix and AmigaDOS, SHELL is used for the {\bf shell} command. On MS-DOS,
COMSPEC is used for the {\bf shell} command.

On AmigaDOS, GNUFONT is used for the screen font.  For example:
``setenv GNUFONT sapphire/14''.

On MS-DOS, if the BGI interface is used, the variable {\bf BGI} is used to point 
to the full path to the BGI drivers directory. Furthermore SVGA is used to
name the Super VGA BGI driver in 800x600 res., and its mode of operation
as 'Name.Mode'.
For example, if the Super VGA driver is C:$\backslash$TC$\backslash$BGI$\backslash$SVGADRV.BGI and mode 3 is
used for 800x600 res., then: 'set BGI=C:$\backslash$TC$\backslash$BGI' and 'set SVGA=SVGADRV.3'.
\section{Exit}
The commands {\bf exit} and {\bf quit} and the END-OF-FILE character
will exit GNUPLOT. All these commands will clear the output device
(as the {\bf clear} command does) before exiting.
\section{Expressions}
In general, any mathematical expression accepted by C, FORTRAN,
Pascal, or BASIC is valid. The precedence of these operators is
determined by the specifications of the C programming language.
White space (spaces and tabs) is ignored inside expressions.

Complex constants may be expressed as the \{$<$real$>$,$<$imag$>$\}, where $<$real$>$
and $<$imag$>$ must be numerical constants. For example, \{3,2\}
represents 3 + 2i; \{0,1\} represents {\bf i} itself. The curly braces 
are explicitly required here.
\subsection{Functions}
The functions in GNUPLOT are the same as the corresponding functions
in the Unix math library, except that all functions accept integer,
real, and complex arguments, unless otherwise noted. The {\bf sgn}
function is also supported, as in BASIC.

\begin{center}
\begin{tabular}{|ccl|} \hline
Function & Arguments & Returns \\ \hline
abs(x) & any  &  absolute value of {\tt x}, $|x|$; same type \\
abs(x) & complex &  length of {\tt x}, $\sqrt{{\mbox{real}(x)^{2} +
\mbox{imag}(x)^{2}}}$ \\
acos(x) & any  & $\cos^{-1} x$ (inverse cosine) in radians \\
arg(x) & complex & the phase of $x$ in radians\\
asin(x) & any  & $\sin^{-1} x$ (inverse sin) in radians \\
atan(x) & any  & $\tan^{-1} x$ (inverse tangent) in radians \\
besj0(x) & radians &  $j_{0}$ Bessel function of $x$ \\
besj1(x) & radians & $j_{1}$ Bessel function of $x$ \\
besy0(x) & radians & $y_{0}$ Bessel function of $x$ \\
besy1(x) & radians & $y_{1}$ Bessel function of $x$ \\
ceil(x) & any & $\lceil x \rceil$, smallest integer not less than $x$
(real part) \\
cos(x) & radians & $\cos x$, cosine of $x$ \\
cosh(x) & radians & $\cosh x$, hyperbolic cosine of $x$ \\
exp(x) & any & $e^{x}$,  exponential function of $x$ \\
floor(x) & any & $\lfloor x \rfloor$,  largest integer not greater
than $x$ (real part) \\
gamma(x) & any & $\Gamma(\mbox{real}(x))$,  gamma function of real($x$) \\
imag(x) & complex &  imaginary part of $x$ as a real number \\
int(x) & real &  integer part of $x$, truncated toward zero \\
log(x) & any & $\log_{e} x$,  natural logarithm (base $e$) of $x$ \\
log10(x) & any & $\log_{10} x$,  logarithm (base $10$) of $x$ \\
real(x) & any &  real part of $x$ \\
sgn(x) & any & 1 if $x>0$, -1 if $x<0$, 0 if $x=0$. imag($x$) ignored \\
sin(x) & radians & $\sin x$, sine of $x$ \\
sinh(x) & radians & $\sinh x$, hyperbolic sine $x$ \\
sqrt(x) & any & $\sqrt{x}$,  square root of $x$ \\
tan(x) & radians & $\tan x$,  tangent of $x$ \\
tanh(x) & radians & $\tanh x$, hyperbolic tangent of $x$\\
\hline
\end{tabular}
\end{center}
\subsection{Operators}
The operators in GNUPLOT are the same as the corresponding operators
in the C programming language, except that all operators accept
integer, real, and complex arguments, unless otherwise noted.
The ** operator (exponentiation) is supported, as in FORTRAN.

Parentheses may be used to change order of evaluation.
\subsubsection{Binary}
The following is a list of all the binary operators and their
usages:


\begin{center}
\begin{tabular}{|ccl|} \hline
\multicolumn{3}{|c|}{Binary Operators} \\
Symbol & Example & Explanation \\ \hline
\verb~**~ & \verb~a**b~ & exponentiation\\
\verb~*~ & \verb~a*b~ & multiplication\\
\verb~/~ & \verb~a/b~ & division\\
\verb~%~ & \verb~a%b~ & * modulo\\
\verb~+~ & \verb~a+b~ & addition\\
\verb~-~ & \verb~a-b~ & subtraction\\
\verb~==~ & \verb~a==b~ & equality\\
\verb~!=~ & \verb~a!=b~ & inequality\\
\verb~&~ & \verb~a&b~ & * bitwise AND\\
\verb~^~ & \verb~a^b~ & * bitwise exclusive OR\\
\verb~|~ & \verb~a|b~ & * bitwise inclusive OR\\
\verb~&&~ & \verb~a&&b~ & * logical AND\\
\verb~||~ & \verb~a||b~ & * logical OR\\
\verb~?:~ & \verb~a?b:c~ & * ternary operation\\
\hline
\end{tabular}
\end{center}
(*) Starred explanations indicate that the operator requires
integer arguments.

Logical AND (\&\&) and OR ($|$$|$) short-circuit the way they do in C.
That is, the second \&\& operand is not evaluated if the first is
false; the second $|$$|$ operand is not evaluated if the first is true.

The ternary operator evaluates its first argument (a). If it is
true (non-zero) the second argument (b) is evaluated and returned,
otherwise the third argument (c) is evaluated and returned.
\subsubsection{Unary}
The following is a list of all the unary operators and their
usages:


\begin{center}
\begin{tabular}{|ccl|} \hline
\multicolumn{3}{|c|}{Unary Operators}\\
Symbol & Example & Explanation \\ \hline
\verb@-@ & \verb@-a@ & unary minus \\
\verb@~@ & \verb@~a@ & * one's complement \\
\verb@!@ & \verb@!a@ & * logical negation \\
\verb@!@ & \verb@a!@ & * factorial \\
\hline
\end{tabular}
\end{center}
(*) Starred explanations indicate that the operator requires an
integer argument.

The factorial operator returns a real number to allow a greater range.
\section{Help}
The {\bf help} command displays on-line help. To specify information on a
particular topic use the syntax:

\begin{verbatim}
        help {<topic>}
\end{verbatim}

If $<$topic$>$ is not specified, a short message is printed about
GNUPLOT. After help for the requested topic is given, help for a
subtopic may be requested by typing its name, extending the help
request. After that subtopic has been printed, the request may be
extended again, or simply pressing return goes back one level to the
previous topic. Eventually, the GNUPLOT command line will return.
\section{Load}
The {\bf load} command executes each line of the specified input file as
if it had been typed in interactively. Files created by the {\bf save}
command can later be {\bf load}ed. Any text file containing valid
commands can be created and then executed by the {\bf load} command.
Files being {\bf load}ed may themselves contain {\bf load} commands. See
{\bf comment} for information about comments in commands.

The {\bf load} command must be the last command on the line.

Syntax:
\begin{verbatim}
        load "<input-file>"
\end{verbatim}

The name of the input file must be enclosed in quotes.

Examples:

\begin{verbatim}
        load 'work.gnu'
        load "func.dat"
\end{verbatim}

The {\bf load} command is performed implicitly on any file names given as
arguments to GNUPLOT. These are loaded in the order specified, and
then GNUPLOT exits.
\section{Pause}
The {\bf pause} command displays any text associated with the command and
then waits a specified amount of time or until the carriage return is
pressed.  {\bf pause} is especially useful in conjunction with {\bf load} files.

Syntax:
\begin{verbatim}
        pause <time> {"<string>"}
\end{verbatim}

$<$time$>$ may be any integer constant or expression. Choosing -1 will
wait until a carriage return is hit, zero (0) won't pause at all, and
a positive integer will wait the specified number of seconds.

Note: Since {\bf pause} is not part of the plot it may interact with
different device drivers differently (depending upon how text and
graphics are mixed).

Examples:
\begin{verbatim}
        pause -1    # Wait until a carriage return is hit
        pause 3     # Wait three seconds
        pause -1  "Hit return to continue"
        pause 10  "Isn't this pretty?  It's a cubic-spline."
\end{verbatim}

\section{Plot}
{\bf plot} and {\bf splot} are the primary commands of the program. They plot
functions and data in many, many ways. {\bf plot} is used to plot 2-d
functions and data, while {\bf splot} plots 3-d surfaces and data.

Syntax:

\begin{verbatim}
        plot {ranges}  <function> {title} {style}
                    {, <function> {title} {style}...}
\end{verbatim}

\begin{verbatim}
        splot {ranges}  <function> {title} {style}
                     {, <function> {title} {style}...}
\end{verbatim}

where $<$function$>$ is either a mathematical expression, the name of a
data file enclosed in quotes, or a pair ({\bf plot}) or triple ({\bf splot})
of mathematical expressions in the case of parametric functions.
User-defined functions and variables may also be defined here.

{\bf plot} and {\bf splot} commands can be as simple as

\begin{verbatim}
        plot sin(x)
\end{verbatim}

and

\begin{verbatim}
        splot x * y
\end{verbatim}

or as complex as (!)

\begin{verbatim}
        plot [t=1:10] [-pi:pi*2] tan(t),"data.1" with lines,t**2 with points
\end{verbatim}
\subsection{Data-file}
Discrete data contained in a file can displayed by specifying the
name of the data file (enclosed in quotes) on the {\bf plot} or {\bf splot}
command line. Data files should contain one data point per line.
Lines beginning with \# (or ! on VMS) will be treated as comments
and ignored. For {\bf plot}s, each data point represents an (x,y)
pair. For {\bf splot}s, each point is an (x,y,z) triple. For {\bf plot}s with
error bars (see {\bf plot errorbars}), each data point is either
(x,y,ydelta) or (x,y,ylow,yhigh). In all cases, the numbers on each
line of a data file must be separated by blank space. This blank
space divides each line into columns.

For {\bf plot}s the x value may be omitted, and for {\bf splot}s the x
and y values may be omitted. In either case the omitted values are
assigned the current coordinate number. Coordinate numbers start at 0
and are incremented for each data point read.

To specify other formats, see {\bf plot datafile using}.

In the {\bf plot} command, blank lines in the data file cause a break in
the plot. There will be no line drawn between the preceding and
following points if the plot style is {\bf lines} or {\bf linespoints} (see
{\bf plot style}). This does not change the plot style, as would plotting
the data as separate curves.

This example compares the data in the file population.dat to a
theoretical curve:

\begin{verbatim}
        pop(x) = 103*exp((1965-x)/10)
        plot [1960:1990] 'population.dat', pop(x)
\end{verbatim}

The file population.dat might contain:

\begin{verbatim}
        # Gnu population in Antarctica since 1965
        1965   103
        1970   55
        1975   34
        1980   24
        1985   10
\end{verbatim}

When a data file is plotted, {\bf samples} and {\bf iso\_samples} are ignored.
Curves plotted using the {\bf plot} command are automatically extended to
hold the entire curve. Similarly grid data plotted using the {\bf splot}
command is automatically extended, using the assumption that isolines
are separated by blank lines (a line with only a CR/LF in it).

Implicitly, there are two types of 3-d datafiles. If all the isolines
are of the same length, the data is assumed to be a grid data, i.e.,
the data has a grid topology. Cross isolines in the other parametric
direction (the ith cross isoline passes thru the ith point of all the
provided isolines) will also be drawn for grid data. (Note contouring
is available for grid data only.) If all the isolines are not of the
same length, no cross isolines will be drawn and contouring that data
is impossible.

For splot if 3-d datafile and using format (see {\bf splot datafile using})
specify only z (height field), a non parametric mode must be specified.
If, on the other hand, x, y, and z are all specified, a parametric
mode should be selected (see {\bf set parametric}) since data is defining a
parametric surface.

A simple example of plotting a 3-d data file is

\begin{verbatim}
        set parametric
        splot 'glass.dat'
\end{verbatim}

or

\begin{verbatim}
        set noparametric
        splot 'datafile.dat'
\end{verbatim}

where the file datafile.dat might contain:

\begin{verbatim}
        # The valley of the Gnu.
        10
        10
        10
\end{verbatim}

\begin{verbatim}
        10
        5
        10
\end{verbatim}

\begin{verbatim}
        10
        1
        10
\end{verbatim}

\begin{verbatim}
        10
        0
        10
\end{verbatim}

Note datafile.dat defines a 4 by 3 grid ( 4 rows of 3 points each ).
Rows are separated by blank lines.

On some computer systems with a popen function (UNIX), the datafile
can be piped through a shell command by starting the file name
with a '$<$'.  For example:

\begin{verbatim}
        pop(x) = 103*exp(x/10)
        plot '< awk "{print $1-1965 $2}" population.dat', pop(x)
\end{verbatim}

would plot the same information as the first population example
but with years since 1965 as the x axis.

For more information about 3-d plotting, see {\bf splot}.
\subsubsection{Using}
The format of data within a file can be selected with the {\bf using} 
option. An explicit scanf string can be used, or simpler column
choices can be made.

Syntax:

\begin{verbatim}
        plot "datafile" { using { <ycol> |
                                  <xcol>:<ycol> |
                                  <xcol>:<ycol>:<ydelta> |
                                  <xcol>:<ycol>:<ylow>:<yhigh> }
                                {"<scanf string>"} } ...
\end{verbatim}

and

\begin{verbatim}
        splot "datafile" { using { <xcol>:<ycol>:<zcol> | <zcol> }
                                 {"<scanf string>"} } ...
\end{verbatim}

$<$xcol$>$, $<$ycol$>$, and $<$zcol$>$ explicitly select the columns to plot from
a space or tab separated multicolumn data file. If only $<$ycol$>$ is
selected for {\bf plot}, $<$xcol$>$ defaults to 1. If only $<$zcol$>$ is selected
for {\bf splot}, then only that column is read from the file. An $<$xcol$>$ of
0 forces $<$ycol$>$ to be plotted versus its coordinate number. $<$xcol$>$,
$<$ycol$>$, and $<$zcol$>$ can be entered as constants or expressions.

If errorbars (see also {\bf plot errorbars}) are used for {\bf plot}s,
ydelta (for example, a +/- error) should be provided as the third
column, or ylow and yhigh as third and fourth columns.  These columns
must follow the x and y columns.

Scanf strings override any $<$xcol$>$:$<$ycol$>$(:$<$zcol$>$) choices, except for
ordering of input, e.g.,
\begin{verbatim}
        plot "datafile" using 2:1 "%f%*f%f"
\end{verbatim}
causes the first column to be y and the third column to be x.

If the scanf string is omitted, the default is generated based on the
$<$xcol$>$:$<$ycol$>$(:$<$zcol$>$) choices. If the {\bf using} option is omitted, ''\%f\%f''
is used for {\bf plot} (''\%f\%f\%f\%f'' for {\bf errorbar} {\bf plot}s) and ''\%f\%f\%f'' is
used for {\bf splot}.

Examples:

\begin{verbatim}
        plot "MyData" using "%*f%f%*20[^\n]%f" with lines
\end{verbatim}

Data are read from the file ``MyData'' using the format
''\%*f\%f\%*20[\verb+^+$\backslash$n]\%f''. The meaning of this format is: ''\%*f'' ignore the
first number, ''\%f'' then read in the second and assign to x,
''\%*20[\verb+^+$\backslash$n]'' then ignore 20 non-newline characters, ''\%f'' then read in
the y value.

\begin{verbatim}
        n=3;
        plot "MyData", "MyData" using n 
\end{verbatim}

causes GNUPLOT to plot the second and third columns of MyData versus
the first column. The command 'n=4; replot' would then plot the second
and fourth columns of MyData versus the first column.

\begin{verbatim}
        splot "glass.dat" using 1
\end{verbatim}

causes GNUPLOT to plot the first coordinate of the points of glass.dat
as the z coordinate while ignoring the other two coordinates.

Note: GNUPLOT first reads a line of the data file into a buffer and 
then does a 
\begin{verbatim}
        sscanf(input_buffer, scanf_string, &x, &y{, &z});
\end{verbatim}
where 'x', 'y', and 'z' are of type 'float'. Any scanf string that
specifies two (three for {\bf splot}, three or four for {\bf errorbars}) float
numbers may be used.
\subsection{Errorbars}
Error bars are supported for 2-d data file plots by reading one or
two additional columns specifying ydelta or ylow and yhigh
respectively. No support exists for x error bars or any error bars
for {\bf splot}s.

In the default situation, GNUPLOT expects to see three or four
numbers on each line of the data file, either (x, y, ydelta) or 
(x, y, ylow, yhigh). The x coordinate must be specified. The order
of the numbers must be exactly as given above. Data files in this
format can easily be plotted with error bars:

\begin{verbatim}
        plot "data.dat" with errorbars
\end{verbatim}

The error bar is a vertical line plotted from (x, ylow) to (x,
yhigh). If ydelta is specified instead of ylow and yhigh, 
ylow=y-ydelta and yhigh=y+ydelta are derived. If there
are only two numbers on the line, yhigh and ylow are both set to
y. To get lines plotted between the data points, {\bf plot} the
data file twice, once with errorbars and once with lines.

If y autoscaling is on, the y range will be adjusted to fit the
error bars.

The {\bf using} option may be used to specify how columns of the data file
are to be assigned to x, y, ydelta, ylow, and yhigh. The x column must
be provided and both the x and y columns must appear before the
errorbar columns. If three column numbers are given, they are x, y,
and ydelta. If four columns are given, they are x, y, ylow, and
yhigh.

Examples:

\begin{verbatim}
        plot "data.dat" using 1:2:3:4 with errorbars
        plot "data.dat" using 3:2:6 with errorbars
        plot "data.dat" using 3:4:8:7 with errorbars
\end{verbatim}

The first example reads, x, y, ylow, and yhigh, from columns 1, 2, 3,
and 4. This is equivalent to the default.  The second example reads x
from the third column, y from second and ydelta from the sixth column.
The third example reads x from the third column, y from the fourth,
ylow from the eighth, and yhigh from seventh columns.

See also {\bf plot using} and {\bf plot style}.
\subsection{Parametric}
When in parametric mode ({\bf set parametric}) mathematical expressions must
be given in pairs for {\bf plot} and in triplets for {\bf splot}:
\begin{verbatim}
        plot sin(t),t**2
\end{verbatim}
or
\begin{verbatim}
        splot cos(u)*cos(v),cos(u)*sin(v),sin(u)
\end{verbatim}

Data files are plotted as before, except any preceding parametric
function must be fully specified before a data file is given as a
plot. In other words, the x parametric function (sin(t) above) and
the y parametric function (t**2 above) must not be interrupted with
any modifiers or data functions; doing so will generate a syntax error
stating that the parametric function is not fully specified.

Ranges take on a different meaning when in parametric mode. The first
range on the {\bf plot} command is the {\bf trange}, the next is the {\bf xrange},
and the last is the {\bf yrange}. For {\bf splot} the order is {\bf urange},
{\bf vrange}, {\bf xrange}, {\bf yrange}, and finally {\bf zrange}. The following
{\bf plot} command shows setting the {\bf trange} to [-pi:pi], the {\bf xrange} to
[-1.3:1.3] and the {\bf yrange} to [-1:1] for the duration of the plot:
\begin{verbatim}
        plot [-pi:pi] [-1.3:1.3] [-1:1] sin(t),t**2
\end{verbatim}

Other modifiers, such as {\bf with} and {\bf title}, may be specified only
after the parametric function has been completed:
\begin{verbatim}
        plot sin(t),t**2 title 'Parametric example' with linespoints
\end{verbatim}
\subsection{Ranges}
The optional range specifies the region of the plot that will be
displayed.

Ranges may be provided on the {\bf plot} and {\bf splot} command line and
affect only that plot, or in the {\bf set xrange}, {\bf set yrange}, etc.,
commands, to change the default ranges for future plots.

Syntax:
\begin{verbatim}
        [{<dummy-var> =} {<xmin> : <xmax>}] { [{<ymin> : <ymax>}] }
\end{verbatim}

where $<$dummy-var$>$ is the independent variable (the defaults are x and
y, but this may be changed with {\bf set dummy}) and the min and max
terms can be constant expressions.

Both the min and max terms are optional. The ':' is also optional
if neither a min nor a max term is specified. This allows '[ ]' to
be used as a null range specification.

Specifying a range in the {\bf plot} command line turns autoscaling for
that axis off for that plot. Using one of the {\bf set} range commands
turns autoscaling off for that axis for future plots, unless changed
later. (See {\bf set autoscale}).

Examples:

This uses the current ranges:
\begin{verbatim}
        plot cos(x)
\end{verbatim}

This sets the x range only:
\begin{verbatim}
        plot [-10:30] sin(pi*x)/(pi*x)
\end{verbatim}

This is the same, but uses t as the dummy-variable:
\begin{verbatim}
        plot [t = -10 :30]  sin(pi*t)/(pi*t)
\end{verbatim}

This sets both the x and y ranges:
\begin{verbatim}
        plot [-pi:pi] [-3:3]  tan(x), 1/x
\end{verbatim}

This sets only the y range, and turns off autoscaling on both axes:
\begin{verbatim}
        plot [ ] [-2:sin(5)*-8] sin(x)**besj0(x)
\end{verbatim}

This sets xmax and ymin only:
\begin{verbatim}
        plot [:200] [-pi:]  exp(sin(x))
\end{verbatim}

This sets the x, y, and z ranges:
\begin{verbatim}
        splot [0:3] [1:4] [-1:1] x*y
\end{verbatim}
\subsection{Style}
Plots may be displayed in one of six styles: {\bf lines}, {\bf points},
{\bf linespoints}, {\bf impulses}, {\bf dots}, or {\bf errorbars}. The {\bf lines} style
connects adjacent points with lines. The {\bf points} style displays a
small symbol at each point. The {\bf linespoints} style does both
{\bf lines} and {\bf points}. The {\bf impulses} style displays a vertical line
from the x axis (or from the grid base for {\bf splot}) to each point. The
{\bf dots} style plots a tiny dot at each point; this is useful for
scatter plots with many points.

The {\bf errorbars} style is only relevant to 2-d data file plotting. It
is treated like {\bf points} for {\bf splot}s and function {\bf plot}s. For data
{\bf plot}s, {\bf errorbars} is like {\bf points}, except that a vertical error 
bar is also drawn: for each point (x,y), a line is drawn from
(x,ylow) to (x,yhigh). A tic mark is placed at the ends of the error
bar. The ylow and yhigh values are read from the data file's columns,
as specified with the {\bf using} option to plot. See {\bf plot errorbars} for
more information.

Default styles are chosen with the {\bf set function style} and
{\bf set data style} commands.

By default, each function and data file will use a different 
line type and point type, up to the maximum number of available 
types. All terminal drivers support at least six different point
types, and re-use them, in order, if more than six are required.
The LaTeX driver supplies an additional six point types (all variants
of a circle), and thus will only repeat after twelve curves are
plotted with points.

If desired, the style and (optionally) the line type and point type
used for a curve can be specified.

Syntax:

\begin{verbatim}
        with <style> {<linetype> {<pointtype>}}
\end{verbatim}

where $<$style$>$ is either {\bf lines}, {\bf points}, {\bf linespoints}, {\bf impulses},
{\bf dots}, or {\bf errorbars}. The $<$linetype$>$ and $<$pointtype$>$ are positive
integer constants or expressions and specify the line type and point
type to be used for the plot. Line type 1 is the first line type used
by default, line type 2 is the second line type used by default, etc.

Examples:

This plots sin(x) with impulses:
\begin{verbatim}
        plot sin(x) with impulses
\end{verbatim}

This plots x*y with points, x**2 + y**2 default:
\begin{verbatim}
        splot x*y w points, x**2 + y**2
\end{verbatim}

This plots tan(x) with the default function style, ``data.1'' with lines:
\begin{verbatim}
        plot [ ] [-2:5] tan(x), "data.1" with l
\end{verbatim}

This plots ``leastsq.dat'' with impulses:
\begin{verbatim}
        plot 'leastsq.dat' w i
\end{verbatim}

This plots ``exper.dat'' with errorbars and lines connecting the points:
\begin{verbatim}
        plot 'exper.dat' w lines, 'exper.dat' w errorbars
\end{verbatim}
Here 'exper.dat' should have three or four data columns.

This plots x**2 + y**2 and x**2 - y**2 with the same line type:
\begin{verbatim}
        splot x**2 + y**2 with line 1, x**2 - y**2 with line 1
\end{verbatim}

This plots sin(x) and cos(x) with linespoints, using the
same line type but different point types:
\begin{verbatim}
        plot sin(x) with linesp 1 3, cos(x) with linesp 1 4
\end{verbatim}

This plots file ``data'' with points style 3:
\begin{verbatim}
        plot "data" with points 1 3 
\end{verbatim}
Note that the line style must be specified when specifying the point
style, even when it is irrelevant. Here the line style is 1 and the
point style is 3, and the line style is irrelevant.

See {\bf set style} to change the default styles.
\subsection{Title}
A title of each plot appears in the key. By default the title is
the function or file name as it appears on the plot command line.
The title can be changed by using the {\bf title} option. This option 
should precede any {\bf with} option.

Syntax:
\begin{verbatim}
        title "<title>"
\end{verbatim}

where $<$title$>$ is the new title of the plot and must be enclosed in
quotes. The quotes will not be shown in the key.

Examples:

This plots y=x with the title 'x':
\begin{verbatim}
        plot x
\end{verbatim}

This plots the ``glass.dat'' file with the title 'surface of revolution':
\begin{verbatim}
        splot "glass.dat" title 'surface of revolution'
\end{verbatim}

This plots x squared with title ``x\verb+^+2'' and ``data.1'' with title
'measured data':
\begin{verbatim}
        plot x**2 title "x^2", "data.1" t 'measured data'
\end{verbatim}
\section{Print}
The {\bf print} command prints the value of $<$expression$>$ to the screen.

Syntax:
\begin{verbatim}
        print <expression>
\end{verbatim}

See {\bf expressions}.
\section{Pwd}
The {\bf pwd} command prints the name of the working directory to the screen.

Syntax:
\begin{verbatim}
        pwd
\end{verbatim}
\section{Quit}
The {\bf exit} and {\bf quit} commands and END-OF-FILE character will exit
GNUPLOT. All these commands will clear the output device (as the
{\bf clear} command does) before exiting.
\section{Replot}
The {\bf replot} command without arguments repeats the last {\bf plot} or {\bf splot}
command. This can be useful for viewing a plot with different {\bf set}
options, or when generating the same plot for several devices.

Arguments specified after a {\bf replot} command will be added onto the last
{\bf plot} ({\bf splot}) command (with an implied ',' separator) before it is
repeated. {\bf replot} accepts the same arguments as the {\bf plot} ({\bf splot})
commands except that ranges cannot be specified. See {\bf command-line
editing} for ways to edit the last {\bf plot} ({\bf splot}) command.
\section{Save}
The {\bf save} command saves user-defined functions, variables, set
options or all three plus the last {\bf plot} ({\bf splot}) command to the
specified file.

Syntax:
\begin{verbatim}
        save  {<option>} "<filename>"
\end{verbatim}

where $<$option$>$ is {\bf functions}, {\bf variables} or {\bf set}. If no option is
used, GNUPLOT saves functions, variables, set options and the last {\bf plot}
({\bf splot}) command.

{\bf save}d files are written in text format and may be read by the {\bf load}
command.

The filename must be enclosed in quotes.

Examples:

\begin{verbatim}
        save "work.gnu"
        save functions 'func.dat'
        save var 'var.dat'
        save set "options.dat"
\end{verbatim}
\section{Set-show}
The {\bf set} command sets LOTS of options.

The {\bf show} command shows their settings. {\bf show all} shows all the
settings.
\subsection{Angles}
By default, GNUPLOT assumes the independent variable in polar plots
is in units of radians. If {\bf set angles degrees} is specified before
{\bf set polar} then the default range is [0:360] and the independent
variable has units of degrees. This is particularly useful for
plots of data files. The angle setting also hold for the 3-d
mapping as set via the {\bf set mapping} command.

Syntax:
\begin{verbatim}
        set angles { degrees | radians }
        show angles
\end{verbatim}
\subsection{Arrow}
Arbitrary arrows can be placed on a plot using the {\bf set arrow}
command.

Syntax:

\begin{verbatim}
         set arrow {<tag>} {from <sx>,<sy>{,<sz>}} 
                           {to <ex>,<ey>{,<ez>}} {{no}head}
         set noarrow {<tag>}
         show arrow
\end{verbatim}


Unspecified coordinates default to 0. The x, y, and z values are in
the graph's coordinate system. The z coordinate is only used in
{\bf splot} commands. $<$tag$>$ is an integer that identifies the arrow. If no
tag is given, the lowest unused tag value is assigned automatically.
The tag can be used to delete or change a specific arrow. To change
any attribute of an existing arrow, use the {\bf set arrow} command with
the appropriate tag, and specify the parts of the arrow to be
changed. Specifying nohead requests the arrow be drawn without a head
(yielding a line segment). By default, arrows have heads.

Arrows outside the plotted boundaries are permitted but may cause
device errors.

Examples:

To set an arrow pointing from the origin to (1,2), use:
\begin{verbatim}
         set arrow to 1,2
\end{verbatim}
To set an arrow from (-10,4,2) to (-5,5,3), and tag the arrow number
3, use:
\begin{verbatim}
         set arrow 3 from -10,4,2 to -5,5,3
\end{verbatim}
To change the preceding arrow begin at 1,1,1, without an arrow head,
use:
\begin{verbatim}
         set arrow 3 from 1,1,1 nohead
\end{verbatim}
To delete arrow number 2 use:
\begin{verbatim}
         set noarrow 2
\end{verbatim}
To delete all arrows use:
\begin{verbatim}
         set noarrow
\end{verbatim}
To show all arrows (in tag order) use:
\begin{verbatim}
         show arrow
\end{verbatim}
\subsection{Autoscale}
Auto scaling may be set individually on the x, y or z axis
or globally on all axes. The default is to autoscale all axes.

When autoscaling, the plot range is automatically computed and the
dependent axis (y for a {\bf plot} and z for {\bf splot}) is scaled to
include the range of the function or data being plotted.

If autoscaling of the dependent axis (y or z) is not set, the
current y or z range is used.

See {\bf set yrange} or {\bf set zrange}.

Autoscaling the independent variables (x for {\bf plot} and x,y for
{\bf splot}) is a request to set the domain to match any data file being
plotted. If there are no data files then autoscaling an independent
variable has no effect. In other words, in the absence of a data
file, functions alone do not affect the x range (or the y range if
plotting z = f(x,y)).

See {\bf set xrange}, or {\bf set yrange}.

The behavior of autoscaling remains consistent in parametric mode,
however, there are more dependent variables and hence more control
over x, y, and z plot scales. In parametric mode, the independent or
dummy variable is t for {\bf plot}s and u,v for {\bf splot}s.  Autoscale in
parametric mode, then, controls all ranges (t, u, v, x, y, and z) and
allows x, y, and z to be fully autoscaled.

See {\bf set parametric}.

Syntax:
\begin{verbatim}
        set autoscale <axes>
        set noautoscale <axes>
        show autoscale
\end{verbatim}

where $<$axes$>$ is either {\bf x}, {\bf y}, {\bf z} or {\bf xy}. If $<$axes$>$ is not given
then all axes are assumed.

Examples:

This sets autoscaling of the y axis. x axis autoscaling is not
affected.
\begin{verbatim}
        set autoscale y
\end{verbatim}

This sets autoscaling of the x and y axes.
\begin{verbatim}
        set autoscale xy
\end{verbatim}

This sets autoscaling of the x, y and z axes.
\begin{verbatim}
        set autoscale
\end{verbatim}

This disables autoscaling of the x, y and z axes.
\begin{verbatim}
        set noautoscale
\end{verbatim}

This disables autoscaling of the z axis only.
\begin{verbatim}
        set noautoscale z
\end{verbatim}
\subsubsection{Parametric mode}
When in parametric mode ({\bf set parametric}) the xrange is as
fully scalable as the yrange. In other words, in parametric
mode the x axis can be automatically scaled to fit the range
of the parametric function that is being plotted. Of course,
the y axis can also be automatically scaled just as in the
non-parametric case. If autoscaling on the x axis is not set,
the current x range is used.

When there is a mix of data files and functions, the xrange of
the functions is selected as that of the data files if autoscale
is true for x. While this keeps the behavior compatible with
non-parametric plotting, it may not be retained in the future.
The problem is that, in parametric mode, the x and y ranges are
not as distinguishable as in the non-parametric mode and this
behavior may not be the most useful.

For completeness a last command {\bf set autoscale t} is accepted.
However, the effect of this ``scaling'' is very minor. When
GNUPLOT determines that the t range would be empty it makes a
small adjustment if autoscaling is true. Otherwise, GNUPLOT
gives an error. Such behavior may, in fact, not be very useful
and the command {\bf set autoscale t} is certainly questionable.

{\bf splot} extends the above idea similarly. If autoscaling is set then
x, y, and z ranges are computed and each axis scaled to fit the
resulting data.
\subsection{Border}
The {\bf set border} and {\bf set noborder} commands controls the display of
the plot borders for the {\bf plot} and {\bf splot} commands.

Syntax:
\begin{verbatim}
        set border
        set noborder
        show border
\end{verbatim}
\subsection{Clip}
GNUPLOT can clip data points and lines that are near the boundaries
of a plot. 

Syntax:
\begin{verbatim}
        set clip <clip-type>
        set noclip <clip-type>
        show clip
\end{verbatim}

Three clip types are supported by GNUPLOT: {\bf points}, {\bf one}, and {\bf two}.
One, two, or all three clip types may be active for a single plot.

The {\bf points} clip type forces GNUPLOT to clip (actually, not plot at
all) data points that fall within but too close to the boundaries
(this is so the large symbols used for points will not extend outside
the boundary lines). Without clipping points near the boundaries may
look bad; try adjusting the x and y ranges.

Setting the {\bf one} clip type causes GNUPLOT to plot the line segments
which have only one of the two endpoints with the plotting region.
Only the in-range portion of the line is drawn.  The alternative is to
not draw any portion of the line segment.

Some lines may have both endpoints out of range, but pass through the
plotting area. Setting the {\bf two} clip-type allows the visible portion
of these lines to be drawn.

In no case is a line drawn outside the plotting area.

The defaults are {\bf noclip points}, {\bf clip one}, and {\bf noclip two}.

To check the state of all forms of clipping, use
\begin{verbatim}
        show clip
\end{verbatim}

For backward compatibility with older versions, the following forms
are also permitted.
\begin{verbatim}
       set clip
       set noclip
\end{verbatim}
{\bf set clip} is synonymous with {\bf set clip points}. {\bf set noclip} turns
off all three types of clipping.
\subsection{Cntrparam}
Sets the different parameters for the contouring plot (see also {\bf contour}).

Syntax:
\begin{verbatim}
        set cntrparam { { linear | cubicspline | bspline } |
                        points <n> |
                        levels <n> |
                        order <n> }
\end{verbatim}

This command controls the way contours are plotted. $<$n$>$ should be an
integral constant expression. The parameters are:

{\bf linear}, {\bf cubicspline}, {\bf bspline} - Controls type of approximation or
interpolation. If {\bf linear}, then the contours are drawn piecewise
linear, as extracted from the surface directly. If {\bf cubicspline}, then
piecewise linear contours are interpolated to form a somewhat smoother
contours, but which may undulate. The third option is the uniform
{\bf bspline}, which only approximates the piecewise linear data but is
guaranteed to be smoother.

{\bf points} - Eventually all drawings are done with piecewise linear
strokes.  This number controls the number of points used to
approximate a curve.  Relevant for {\bf cubicspline} and {\bf bspline} modes
only.

{\bf levels} - Number of contour levels. If the surface is bounded by zmin
and zmax then contours will be generated from zmin+dz to zmax-dz
in steps of size dz, where dz = (zmax - zmin) / (levels + 1).

{\bf order}  - Order of the bspline approximation to be used. The bigger this
order is, the smoother the resulting contour.  (Of course, higher order
bspline curves will move further away from the original peicewise linear
data.)  This option is relevant for {\bf bspline} mode only. Allowed values are 
integers in the range from 2 (linear) to 10.
\subsection{Contour}
Enable contour drawing for surfaces. This option is available for {\bf splot}
only.

Syntax:
\begin{verbatim}
        set contour { base | surface | both }
        set nocontour
\end{verbatim}

If no option is provided to {\bf set contour}, the default is {\bf base}.
The three options specify where to draw the contours: {\bf base} draws
the contours on the grid base where the x/ytics are placed, {\bf surface}
draws the contours on the surfaces themselves, and {\bf both} draws the
contours on both the base and the surface.

See also {\bf set cntrparam} for the parameters that affect the drawing of 
contours.
\subsection{Data style}
The {\bf set data style} command changes the default plotting style
for data plots.

Syntax:
\begin{verbatim}
        set data style 
        show data style 
        set data style <style-choice>
\end{verbatim}

In the first case, {\bf set data style} returns the possible style
choices:  {\bf lines}, {\bf points}, {\bf linespoints}, {\bf dots}, {\bf impulses}, 
or {\bf errorbars}.  {\bf show data style} shows the current default
plotting style for data.  {\bf set data style dots} would actually 
change the default plotting style.  See also {\bf plot}.
\subsection{Dummy}
By default, GNUPLOT assumes that the independent variable for the
{\bf plot} command is x, and the independent variables for the {\bf splot}
command are x and y. They are called the dummy variables because it
is just a notation to indicate the independent variables. The {\bf set
dummy} command changes these default dummy variable names. For
example, it may be more convenient to call the dummy variable t
when plotting time functions:

\begin{verbatim}
        set dummy t
        plot sin(t), cos(t)
\end{verbatim}

Syntax:
\begin{verbatim}
        set dummy <dummy-var>{,<dummy-var>}
        show dummy
\end{verbatim}

Examples:
\begin{verbatim}
        set dummy u,v
        set dummy ,s
\end{verbatim}

to set both dummy variables to u and v or set only the second
variable to s.

The {\bf set parametric} command also changes the dummy variables (to t
for {\bf plot} and u,v for {\bf splot}s).

\subsection{Format}
The format of the tic-mark labels can be set with the {\bf set format}
command. The default format for both axes is ''\%g'', but other formats
such as ''\%.2f'' or ''\%3.0fm'' are often desirable. Anything accepted by
printf when given a double precision number, and then accepted by the
terminal, will work. In particular, the formats f, e, and g will work,
and the d, o, x, c, s, and u formats will not work.

Syntax:
\begin{verbatim}
        set format {<axes>} {"<format-string>"}
        show format
\end{verbatim}

where $<$axes$>$ is either {\bf x}, {\bf y}, {\bf z}, {\bf xy}, or nothing (which is the
same as {\bf xy}). The length of the string representing a ticmark (after
formatting with printf) is restricted to 100 characters.  If the
format string is omitted, the format will be returned to the default
''\%g''. For LaTeX users, the format ''\$\%g\$'' is often desirable.  If the
empty string '''' is used, no label will be plotted with each tic,
though the tic mark will still be plotted. To eliminate all tic marks,
use {\bf set noxtics} or {\bf set noytics}.

See also {\bf set xtics} and {\bf set ytics} for more control over tic labels.
\subsection{Function style}
The {\bf set function style} command changes the default plotting style
for functions.

Syntax:
\begin{verbatim}
        set function style 
        show function style 
        set function style <style-choice>
\end{verbatim}

In the first case, {\bf set function style} returns the possible style
choices:  {\bf lines}, {\bf points}, {\bf linespoints}, {\bf dots}, {\bf impulses}, 
or {\bf errorbars}.  {\bf show function style} shows the current default
plotting style for functions.  {\bf set function style linespoints}
would actually change the default plotting style.  See also {\bf plot}.
\subsection{Functions}
The {\bf show functions} command lists all user-defined functions and
their definitions.

Syntax:
\begin{verbatim}
        show functions
\end{verbatim}
\subsection{Grid}
The optional {\bf set grid} draws a grid at the tic marks with the axis
linetype.

Syntax:
\begin{verbatim}
        set grid
        set nogrid
        show grid
\end{verbatim}
\subsection{Hidden3d}
The {\bf set hidden3d} command enables hidden line removal for explicit
surface plotting (see {\bf splot}).
Hidden line removal may be used for both explicit functions
and for explicit data where gnuplot plot is in nonparametric mode (see
{\bf set parametric}).

When this flag is set both the surface hidden portion and possibly
its hidden contours (see {\bf set contour}) as well as the hidden grid will be
removed. Labels and arrows are always visible and are unaffected by this
command.

Each surface has its hidden part removed with respect to itself, if more
than one surface is ploted. This mode is meaningfull when surfaces are
plotted using line style drawing only.

Syntax:
\begin{verbatim}
        set hidden3d
        set nohidden3d
        show hidden3d
\end{verbatim}
\subsection{Isosamples}
An isoline is a curve parametrized by one of the surface parameters
while the other surface parameter is fixed. Isolines are a simple
means to display a surface. By fixing the u parameter of surface
s(u,v), the iso-u lines of the form c(v) = s(u0,v) are produced, and
by fixing the v parameter, the iso-v lines of the form c(u) = s(u,v0)
are produced.

The isoline density of surfaces may be changed by the {\bf set isosamples}
command. By default, sampling is set to 10 isolines per u or v axis.
A higher sampling rate will produce more accurate plots, but will take
longer. This parameter has no effect on data file plotting.

Syntax:
\begin{verbatim}
        set isosamples <expression>
        show isosamples
\end{verbatim}
\subsection{Key}
The {\bf set key} enables a key describing curves on a plot.  By default
the key is placed in the upper right corner of the plot.

Syntax:
\begin{verbatim}
        set key
        set key <x>,<y>{,<z>}
        set nokey
        show key
\end{verbatim}

The coordinates $<$x$>$, $<$y$>$ (and $<$z$>$ for {\bf splot}s) specify the location
of the key on the plot. The key is drawn as a sequence of lines, with
one plot described on each line. On the right hand side of each line
is a representation that attempts to mimic the way the curve is
plotted.  On the left side of each line is the text description,
obtained from the {\bf plot} command. See {\bf plot title} to change this
description. The lines are vertically arranged so an imaginary
straight line divides the left- and right-hand sides of the key. It is
the coordinates of this line that are specified with the {\bf set key}
command. In a {\bf plot}, only the x and y coordinates are used to specify
the line position.  For a {\bf splot}, x, y and z are all being used as a
3-d location mapped using the same mapping as the plot itself to form
the required 2-d screen position of the imaginary line.

Some or all of the key may be outside of the plot boundary, although
this may interfere with other labels and may cause an error on some
devices.

Examples:

This places the key at the default location:
\begin{verbatim}
        set key
\end{verbatim}
This disables the key:
\begin{verbatim}
        set nokey
\end{verbatim}
This places a key at coordinates 2,3.5,2
\begin{verbatim}
        set key 2,3.5,2
\end{verbatim}
\subsection{Label}
Arbitrary labels can be placed on the plot using the {\bf set label}
command.  If the z coordinate is given on a {\bf plot} it is ignored; if
it is missing on a {\bf splot} it is assumed to be 0.

Syntax:

\begin{verbatim}
         set label {<tag>} {"<label_text>"} {at <x>,<y>{,<z>}}
                           {<justification>}
         set nolabel {<tag>}
         show label
\end{verbatim}


The text defaults to '''', and the position to 0,0,0.  The $<$x$>$, $<$y$>$, and
$<$z$>$ values are in the graph's coordinate system.  The tag is an
integer that is used to identify the label. If no $<$tag$>$ is given, the
lowest unused tag value is assigned automatically. The tag can be used
to delete or change a specific label. To change any attribute of an
existing label, use the {\bf set label} command with the appropriate tag,
and specify the parts of the label to be changed.

By default, the text is placed flush left against the point x,y,z.
To adjust the way the label is positioned with respect to the point
x,y,z, add the parameter $<$justification$>$, which may be {\bf left}, {\bf right}
or {\bf center}, indicating that the point is to be at the left, right or
center of the text. Labels outside the plotted boundaries are
permitted but may interfere with axes labels or other text.

Examples:

To set a label at (1,2) to ``y=x'' use:
\begin{verbatim}
         set label "y=x" at 1,2
\end{verbatim}
To set a label ``y=x\verb+^+2'' with the right of the text at (2,3,4), and tag
the label number 3, use:
\begin{verbatim}
         set label 3 "y=x^2" at 2,3,4 right
\end{verbatim}
To change the preceding label to center justification, use:
\begin{verbatim}
         set label 3 center
\end{verbatim}
To delete label number 2 use:
\begin{verbatim}
         set nolabel 2
\end{verbatim}
To delete all labels use:
\begin{verbatim}
         set nolabel
\end{verbatim}
To show all labels (in tag order) use:
\begin{verbatim}
         show label
\end{verbatim}

(The Latex, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline.)
\subsection{Logscale}
Log scaling may be set on the x, y, and z axes.

Syntax:
\begin{verbatim}
        set logscale <axes>
        set nologscale <axes>
        show logscale
\end{verbatim}

where $<$axes$>$ may be any combinations of {\bf x}, {\bf y}, and {\bf z}, in any
order.  If $<$axes$>$ is not given then all three axes are assumed.  The
command {\bf set logscale} turns on log scaling on the specified axes,
while {\bf set nologscale} turns off log scaling.

Examples:

To enable log scaling in both x and z axes:
\begin{verbatim}
       set logscale xz
\end{verbatim}
To disable z axis log scaling:
\begin{verbatim}
       set nologscale z
\end{verbatim}
\subsection{Mapping}

Syntax:
\begin{verbatim}
        set mapping { cartesian | spherical | cylindrical }
\end{verbatim}

Data for {\bf splot}s are usually in regular Euclidean space and are
provided in Cartesian coordinates. Such 3-d data require three
coordinates (x, y and z) or one coordinate (only z) in each line in
the data file.  In order to be able to use spherical or cylindrical
coordinate systems, use the {\bf set mapping} command. In both cases two
coordinates are expected in each line of the data. For a spherical
coordinate system, these are theta and phi (in units as specified by
{\bf set angles}) and the mapping is:

\begin{verbatim}
        x = cos( theta ) * cos( phi )
        y = sin( theta ) * cos( phi )
        z = sin( phi )
\end{verbatim}

For a cylindrical coordinate system, the mapping uses two variables,
theta (in units as specified by {\bf set angles}) and z:

\begin{verbatim}
        x = cos( theta )
        y = sin( theta )
        z = z
\end{verbatim}

Again, note that mapping will affect data file {\bf splot}s only.
\subsection{Offsets}
The amount of the graph that the plot takes up may be controlled to
some extent with the {\bf set offsets} command. This command takes four
offset arguments: $<$left$>$, $<$right$>$, $<$top$>$ and $<$bottom$>$. By default,
each offset is 0. Each offset may be a constant or an expression. Left
and right offsets are given in units of the x axis, while top and
bottom offsets are given in units of the y axis. The plot of sin(x),
displayed with offsets of 0, 0, 2, 2 will take up 1/3 of the
displayed y axis. Offsets are particularly useful with polar
coordinates as a means of compensating for aspect ratio distortion.
Offsets are ignored in {\bf splot}s.

Syntax:
\begin{verbatim}
        set offsets <left>, <right>, <top>, <bottom>
        show offsets
\end{verbatim}
\subsection{Output}
By default, plots are displayed to the standard output. The {\bf set
output} command redirects the display to the specified file or
device.

Syntax:
\begin{verbatim}
        set output {"<filename>"}
        show output
\end{verbatim}

The filename must be enclosed in quotes. If the filename is
omitted, output will be sent to the standard output.

On machines with popen functions (UNIX), output can be piped
through a shell command if the first letter of the filename
is '$|$'.  For instance,

Syntax:
\begin{verbatim}
        set output "|lpr -Plaser filename"
        set output "|lp -dlaser filename"
\end{verbatim}

(On MSDOS machines, set output ``prn'' will direct the output
to the default printer.)

\subsection{Parametric}
The {\bf set parametric} command changes the meaning of {\bf plot} ({\bf splot})
from normal functions to parametric functions. The command
{\bf set noparametric} changes the plotting style back to normal,
single-valued expression plotting.

In 2-d plotting, a parametric function is determined by a pair
of parametric functions operating on a parameter. An example
of a 2-d parametric function would be plot sin(t),cos(t) (which
defines a circle).

For 3-d plotting, the surface is described as x=f(u,v), y=g(u,v),
z=h(u,v). Therefore a triplet of functions are required. An example of
3-d parametric function would be cos(u)*cos(v),cos(u)*sin(v),sin(u)
(which defines a sphere). It takes three parametric function
specifications in terms of the parametric dummy arguments to describe
a single graph.

The total set of possible plots is a superset of the simple f(x)
style plots, since the two (three) functions can describe the
x and y (and z) values to be computed separately. In fact,
plots of the type t,f(t) (u,v,f(u,v)) are equivalent to those
produced with f(x) when the x values are computed using the
identity function as the first function.

Note that the order the parametric functions are specified is
xfunction, yfunction (and zfunction) and that each operates over the
common parametric domain.

Also, the {\bf set parametric} function implies a new range of values.
Whereas the normal f(x) and f(x,y) style plotting assume an xrange
and yrange (and zrange), the parametric mode additionally specifies a
trange, urange, and vrange. These ranges may be set
directly with {\bf set trange}, {\bf set urange} and {\bf set vrange}, or by
specifying the range on the {\bf plot} or {\bf splot} commands. Currently
the default range for these parametric variables is [-5:5].
Setting the ranges to something more meaningful is expected.
\subsection{Polar}
The {\bf set polar} command changes the meaning of the plot from
rectangular coordinates to polar coordinates. In polar coordinates,
the dummy variable (x) is an angle. The range of this angle is changed
from whatever it was to [0:2*pi], or, if degree unit has been selected,
to [0:360] (see {\bf set angles}).

The command {\bf set nopolar} changes the meaning of the plot back to the
default rectangular coordinate system. The range of x is changed from
whatever it was to [-10:10].

The {\bf set polar} command is not supported for {\bf splot}s.  See the
{\bf set mapping} command for similar functionality for {\bf splot}s.

While in polar coordinates the meaning of an expression in x is really
r = f(x), where x is an angle of rotation. The xrange controls the
domain (the angle) of the function, and the yrange controls the range
(the radius). The plot is plotted in a rectangular box, and the x and
y axes are both in units of the radius. Thus, the yrange controls both
dimensions of the plot output. The tics and units are written along
the axes rather than at the left and bottom. These unit are offset by
$<$rmin$>$ specified by the {\bf rrange} (See {\bf set rrange}). It is not
possible to specify different output dimensions in the x or y
directions. The yrange can be used to shift the plot diagonally to
display only the first or third quadrants.

Syntax:
\begin{verbatim}
        set polar
        set nopolar
        show polar
\end{verbatim}
Example:
\begin{verbatim}
        set polar
        plot x*sin(x)
        plot [-2*pi:2*pi] [-3:3] x*sin(x)
\end{verbatim}
The first plot uses the default polar angular domain of 0 to 2*pi.
The radius (and the size of the plot) is scaled automatically. The
second plot expands the domain, and restricts the range of the radius
(and the size of the plot) to [-3:3].
\subsection{Rrange}
The {\bf set rrange} command sets the radial range used to compute x and y
values when in polar mode. If not in polar mode (see {\bf set polar}) then
this range is not used. Use of this command offsets the polar
singularity to the $<$rmin$>$ value and shifts the units on the axes tic
marks. For instance, {\bf set rrange [-40:40]} would set the origin to -40
and would plot values of radial values between -40 to 40. Thus, if
360 degrees of data were plotted, then the plot would extend 80 units
in radially from the origin.  To view the entire plot,  a 
{\bf set yrange [-80:80]} command would create a square viewport with
a circular plot tangent at the axes.  Because {\bf xrange} is used
specify the angular extent, only a square viewport can be specified
by {\bf yrange}.  For instance, {\bf set yrange [0:80]} would display the
first quadrant and {\bf set yrange [-80:0]} would display the third
quadrant.  Any square viewport of any size can be specified but it
is constrained to be centered on a 45 degree line.

This range may also be specified on the {\bf plot} command line when in
polar mode.

Syntax:
\begin{verbatim}
        set rrange [{<rmin> : <rmax>}]
\end{verbatim}

where $<$rmin$>$ and $<$rmax$>$ terms are constants or expressions.

Both the $<$rmin$>$ and $<$rmax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set rrange [:10]
\end{verbatim}
changes rmax to 10 without affecting rmin.
\subsection{Samples}
The sampling rate of functions may be changed by the {\bf set samples}
command. By default, sampling is set to 100 points. A higher sampling
rate will produce more accurate plots, but will take longer. This
parameter no longer has any effect on data-file plotting.

Syntax:
\begin{verbatim}
        set samples <expression>
        show samples
\end{verbatim}
\subsection{Size}
The {\bf set size} command scales the displayed size of the plot.  On some
terminals, changing the size of the plot will result in text being
misplaced. Increasing the size of the plot may produce strange
results. Decreasing is safer.

Syntax:

\begin{verbatim}
        set size {<xscale>,<yscale>}
        show size
\end{verbatim}

The $<$xscale$>$ and $<$yscale$>$ values are the scaling factors for the size.
The defaults (1,1) are selected if the scaling factors are omitted.

Examples: 

To set the size to normal size use:
\begin{verbatim}
        set size
\end{verbatim}
To make the plot half size use:
\begin{verbatim}
        set size 0.5,0.5
\end{verbatim}
To make a landscape plot have a 1:1 aspect ratio in polar mode use:
\begin{verbatim}
        set size 0.721,1.0
\end{verbatim}
To show the size use:
\begin{verbatim}
        show size
\end{verbatim}

For the LaTeX and Fig terminals the default size (scale factor 1,1)
is 5 inches wide by 3 inches high. The big Fig terminal ({\bf bfig}) is 7
inches wide by 5 inches high. The postscript default is landscape mode
10 inches wide and 7 inches high. 
Note that the size of the plot includes the space used by the labels; 
the plotting area itself is smaller. 
\subsection{Style}
Plots may be displayed in one of six styles: {\bf lines}, {\bf points},
{\bf linespoints}, {\bf impulses}, {\bf dots}, or {\bf errorbars}. The {\bf lines} style
connects adjacent points with lines. The {\bf points} style displays a
small symbol at each point. The {\bf linespoints} style does both
{\bf lines} and {\bf points}. The {\bf impulses} style displays a vertical line
from the x axis to each point. The {\bf dots} style plots a tiny dot at
each data point; this is useful for scatter plots with many points.

The {\bf errorbars} style is relevant only for to data file {\bf plot}s. It is
treated like {\bf points} for function {\bf plot}s and {\bf splot}s. For data file
{\bf plot}s, {\bf errorbars} is like {\bf points}, except that a vertical error
bar is also drawn: for each point (x,y), a line is drawn from (x,ylow)
to (x,yhigh). A tic mark is placed at the ends of the error bar. The
ylow and yhigh values are read from the data file's third and fourth
columns, or as specified with the {\bf using} option to plot.  See {\bf plot
errorbars} for more information.

Default styles are chosen with the {\bf set function style} and {\bf set
data style} commands. See {\bf plot style} for information about how
to override the default plotting style for individual functions.

Syntax:
\begin{verbatim}
        set function style <style>
        set data style <style>
        show function style
        show data style
\end{verbatim}

where $<$style$>$ is {\bf lines}, {\bf points}, {\bf linespoints}, {\bf impulses},
{\bf dots}, or {\bf errorbars}.
\subsection{Surface}
{\bf set surface} controls the display of surfaces. It is useful if
contours are to be displayed by themselves. Whenever {\bf set nosurface}
is issued, no surface isolines/mesh will be drawn. See also {\bf set
contour}.

Syntax:
\begin{verbatim}
        set surface
        set nosurface
        show surface
\end{verbatim}
\subsection{Terminal}
GNUPLOT supports many different graphics devices. Use the {\bf set
terminal} command to select the type of device for which GNUPLOT
will produce output.

Syntax:
\begin{verbatim}
        set terminal {<terminal-type>}
        show terminal
\end{verbatim}

If $<$terminal-type$>$ is omitted, GNUPLOT will list the available
terminal types. $<$terminal-type$>$ may be abbreviated.

Use {\bf set output} to redirect this output to a file or device.

Several terminals have additional options. For example, see {\bf dumb},
{\bf iris4d}, {\bf hpljii} or {\bf postscript}.
\subsubsection{Dumb}
The dumb terminal driver has an optional size specification.

Syntax:
\begin{verbatim}
        set terminal dumb {<xsize> <ysize>}
\end{verbatim}

where $<$xsize$>$ and $<$ysize$>$ set the size of the dumb terminals. Default
is 79 by 24.

Examples:
\begin{verbatim}
        set term dumb
        set term dumb 79 49 #(VGA screen - why would anyone want to do that!?)
\end{verbatim}

\subsubsection{Hpljii}
The HP LaserJet II and HP DeskJet drivers have a single option.

Syntax:
\begin{verbatim}
        set terminal hpljii {<resolution>}
        set terminal hpdj   {<resolution>}
\end{verbatim}

where $<$resolution$>$ is the resolution of the output in dots per inch.
It must be {\bf 75}, {\bf 100}, {\bf 150} or {\bf 300}.

Example:
\begin{verbatim}
        set terminal hpljii 150
\end{verbatim}

\subsubsection{Iris4d}
The iris4d driver can operate in two modes.

Syntax:
\begin{verbatim}
        set terminal iris4d {24}
\end{verbatim}

If the hardware supports only 8 bits, use the default {\bf set terminal
iris4d}. If, however, the hardware supports 24 bits (8 per
red/green/blue), use {\bf set terminal iris4d 24}.

When using 24-bit mode, the colors can be directly specified via the
file .gnuplot\_iris4d that is searched in the current directory and
then in the home directory specified by the HOME environment variable.
This file holds RGB values for the background, border, labels and nine
plotting colors, in that order. For example, here is a file containing
the default colors:

\begin{verbatim}
        85   85   85     /* Back Ground */
        0    0    0      /* Boundary */
        170  0    170    /* Labeling */
        85   255  255    /* Plot Color 1 */
        170  0    0      /* Plot Color 2 */
        0    170  0      /* Plot Color 3 */
        255  85   255    /* Plot Color 4 */
        255  255  85     /* Plot Color 5 */
        255  85   85     /* Plot Color 6 */
        85   255  85     /* Plot Color 7 */
        0    170  170    /* Plot Color 8 */
        170  170  0      /* Plot Color 9 */
\end{verbatim}

This file has exactly 12 lines of RGB triples. No empty lines are
allowed and anything after the third number in line is ignored.

\subsubsection{Pbm}
Several options may be set in the PBMplus driver.

Syntax:
\begin{verbatim}
        set terminal pbm {<fontsize>}
        set terminal pgm {<fontsize>}
        set terminal ppm {<fontsize>}
\end{verbatim}

where $<$fontsize$>$ is {\bf small}, {\bf medium}, or {\bf large}. 
Default size is 640 pixels wide and 480 pixels high.
The pbm output is a portable bitmap (one bit per pixel).
The pgm output is a portable graymap (three bits per pixel). 	
The ppm output is a portable pixmap (color, four bits per pixel).
The output of these drivers can be used with Jef Poskanzer's 
excellent PBMPLUS package which provides programs to convert
the above PBMPLUS formats to GIF, TIFF, MacPaint, Macintosh PICT,
PCX, X11 bitmap and many others. 

Examples:

\begin{verbatim}
        set term pbm small
        set size 2,2
        set term ppm medium
\end{verbatim}

\subsubsection{Postscript}
Several options may be set in the PostScript driver.

Syntax:
\begin{verbatim}
        set terminal postscript {<mode>} {<color>}
                                {"<fontname>"} {<fontsize>}
\end{verbatim}

where $<$mode$>$ is {\bf landscape}, {\bf portrait}, {\bf eps} or {\bf default}. 
Selecting default sets all options to their defaults.
$<$color$>$ is either {\bf color} or {\bf monochrome}.
''$<$fontname$>$'' is the name of a valid PostScript font.
$<$fontsize$>$ is the size of the font in PostScript points, before 
scaling by the {\bf set size} command.
Defaults are {\bf landscape}, {\bf monochrome}, ``Courier'', and 14pt.
Default size of PostScript plot is landscape mode 10 inches wide 
and 7 inches high.

To get EPS output, use the {\bf eps} mode and make only one plot per file.
In {\bf eps} mode the whole plot is halved in size; the fonts are half the 
given size, and the plot is 5 inches wide and 3.5 inches high.

Examples:

\begin{verbatim}
        set term postscript default       # old postscript
        set term postscript landscape 22  # old psbig
        set term postscript eps 14   # old epsf1
        set term postscript eps 22   # old epsf2
        set size 0.7,1.4
        set term post portrait color "Times-Roman" 14 
\end{verbatim}

\subsubsection{Aifm}
Several options may be set in the Adobe Illustrator 3.0 driver.

Syntax:
\begin{verbatim}
        set terminal aifm {<color>}
                                {"<fontname>"} {<fontsize>}
\end{verbatim}

Selecting default sets all options to their defaults.
$<$color$>$ is either {\bf color} or {\bf monochrome}.
''$<$fontname$>$'' is the name of a valid PostScript font.
$<$fontsize$>$ is the size of the font in PostScript points, before 
scaling by the {\bf set size} command.
Defaults are {\bf monochrome}, ``Courier'', and 14pt.

Also, since AI does not really support multiple pages, multiple 
graphs will be output directly on one another.  However, each graph 
will be grouped individually, making it easy to separate them inside 
AI (just pick them up and move them).

Examples:

\begin{verbatim}
        set term aifm 
        set term aifm 22  
        set size 0.7,1.4
        set term aifm color "Times-Roman" 14 
\end{verbatim}

\subsubsection{Table}
Instead of producing a picture, term type 'table' prints out
the evaluation results in a multicolumn ASCII table of X Y Z values.
For those times when you really want to see the numbers, now you
can see them on the screen or save to a file.

\subsection{Tics}
By default, tics are drawn inwards from the border on all four sides.
The {\bf set tics} command can be used to change the tics to be 
drawn outwards on the left and bottom borders only.
This is useful when doing impulse plots.

Syntax:
\begin{verbatim}
        set tics {<direction>}
        show tics
\end{verbatim}

where $<$direction$>$ may be {\bf in} or {\bf out}. {\bf set tics} defaults to {\bf in}.

See also the {\bf set xtics}, {\bf set ytics}, and {\bf set ztics} command for more
control of tic marks.
Using splot, in 3-d plots, one can adjust the relative height of the
vertical (Z) axis using {\bf set ticslevel}. The numeric argument provided
specifies the location of the bottom of the scale. a zero will put it
on the bottom grid and any positive number somewhere along the z axis.

Syntax:
\begin{verbatim}
        set ticslevel {<level>}
        show tics
\end{verbatim}

where $<$level$>$ is a non negative numeric argument. For example,

\begin{verbatim}
        set ticslevel 0.5
\end{verbatim}

sets the tics level to the default value.

See also the {\bf set view}.
\subsection{Time}
The optional {\bf set time} places the time and date of the plot either
at the top or bottom of the left margin. The exact location is
device dependent.

Syntax:
\begin{verbatim}
        set time {<xoff>}{,<yoff>}
        set notime
        show time
\end{verbatim}

Specifying constants $<$xoff$>$ or $<$yoff$>$ as optional offsets for the time
will move the time $<$xoff$>$ or $<$yoff$>$ character screen coordinates. For
example,

\begin{verbatim}
        set time ,-3
\end{verbatim}

will change only the y offset of the time, moving the title down by
roughly the height of three characters.

\subsection{Title}
The {\bf set title} command produces a plot title that is centered at the
top of the plot. Using the optional x,y screen offsets, the title
can be placed anywhere on the plot. {\bf set title} with no parameters
clears the title.

Syntax:
\begin{verbatim}
         set title {"<title-text>"} {<xoff>}{,<yoff>}
         show title
\end{verbatim}

Specifying constants $<$xoff$>$ or $<$yoff$>$ as optional offsets for the
title will move the title $<$xoff$>$ or $<$yoff$>$ character screen
coordinates. Note these are screen coordinates and not plot
coordinates. For example,

\begin{verbatim}
         set title ,-1
\end{verbatim}

will change only the y offset of the title, moving the title down by
roughly the height of one character.

(The Latex, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline.)
\subsection{Trange}
The {\bf set trange} command sets the parametric range used to compute
x and y values when in parametric mode. If not in parametric mode
(see {\bf set parametric}) then this range is not used. This command
does not affect x/y autoscaling or x/y ranges.

This range may also be specified on the {\bf plot} command line when
in parametric mode.

Syntax:
\begin{verbatim}
        set trange [{<tmin> : <tmax>}]
\end{verbatim}

where $<$tmin$>$ and $<$tmax$>$ terms are constants or expressions.

Both the $<$tmin$>$ and $<$tmax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set trange [:10]
\end{verbatim}
changes tmax to 10 without affecting tmin.  See also {\bf set urange} and
{\bf set parametric}.
\subsection{Urange}
The {\bf set urange} and {\bf set vrange} commands sets the parametric ranges used 
to compute x, y, and z values when in {\bf splot} parametric mode. If not in 
parametric mode (see {\bf set parametric}) then these ranges are not used. This 
command does not affect x/y autoscaling or x/y ranges.

This range may also be specified on the {\bf splot} command line when
in parametric mode.  See {\bf plot} for more information

Syntax:
\begin{verbatim}
        set urange [{<umin> : <umax>}]
\end{verbatim}

where $<$umin$>$ and $<$umax$>$ terms are constants or expressions.

Both the $<$umin$>$ and $<$umax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set urange [:10]
\end{verbatim}
changes umax to 10 without affecting umin.  See also {\bf set trange}.
\subsection{Variables}
The {\bf show variables} command lists all user-defined variables and
their values.

Syntax:
\begin{verbatim}
        show variables
\end{verbatim}
\subsection{View}
The {\bf set view} command sets the view point for {\bf splot}s. This
command controls the way the 3-d coordinates of the plot are mapped
into the 2-d screen space. This command provides controls to both
rotation and scaling of the plotted data but supports orthographic
projections only.

Syntax:
\begin{verbatim}
        set view <rot_x> {,{<rot_z>}{,{<scale>}{,<scale_z>}}}
        show view
\end{verbatim}

where $<$rot\_x$>$ and $<$rot\_z$>$ control the rotation angles (in degrees)
along a virtual 3-d coordinate system aligned with the screen such
that the screen horizontal axis is x, screen vertical axis is y, and
the axis perpendicular to the screen is z. $<$rot\_x$>$ is bounded to the
[0:180] range with a default of 60 degrees, while $<$rot\_z$>$ is bounded
to the [0:360] range with a default of 30 degrees. $<$scale$>$ controls
the scaling of the entire {\bf splot}, while $<$scale\_z$>$ scales the z axis
only. Both scales default to 1.0.

Examples:
\begin{verbatim}
        set view 60, 30, 1, 1
        set view ,,0.5
\end{verbatim}

The first sets all the four default values. The second changes 
only scale, to 0.5.

See also {\bf set ticslevel}.
\subsection{Vrange}
The {\bf set vrange} command is similar to the {\bf set urange} command.
Please see {\bf set urange}.
\subsection{Xlabel}
The {\bf set xlabel} command sets the x-axis label that is centered along
the x axis. Using the optional x,y screen offsets, the label can be
placed anywhere on the plot. {\bf set xlabel} with no parameters clears
the label.

Syntax: 
\begin{verbatim}
         set xlabel {"<label>"} {<xoff>}{,<yoff>}
         show xlabel
\end{verbatim}

Specifying constants $<$xoff$>$ or $<$yoff$>$ as optional offsets for the
label will move the label $<$xoff$>$ or $<$yoff$>$ character screen
coordinates. For example,

\begin{verbatim}
         set xlabel -1
\end{verbatim}

will change only the x offset of the xlabel, moving the label roughly
one character width to the left.

(The LaTeX, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline.)
\subsection{Xrange}
The {\bf set xrange} command sets the horizontal range that will be
displayed. This command turns x axis autoscaling off.

This range may also be specified on the {\bf plot} command line.

Syntax:
\begin{verbatim}
        set xrange [{<xmin> : <xmax>}]
\end{verbatim}

where $<$xmin$>$ and $<$xmax$>$ terms are constants or expressions.

Both the $<$xmin$>$ and $<$xmax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set xrange [:10]
\end{verbatim}
changes xmax to 10 without affecting xmin.
\subsection{Xtics}
Fine control of the x axis tic marks is possible with the
{\bf set xtics} command. The x-axis tic marks may be turned off with the
{\bf set noxtics} command. They may be turned on (the default state) with
{\bf set xtics}.

Syntax:
\begin{verbatim}
         set xtics { {<start>, <incr>{, <end>}} |
                     {({"<label>"} <pos> {, {"<label>"} <pos>}...)} }
         set noxtics
         show xtics
\end{verbatim}

The $<$start$>$, $<$incr$>$, $<$end$>$ form specifies that a series of tics will
be plotted on the x axis between the x values $<$start$>$ and $<$end$>$
with an increment of $<$incr$>$. If $<$end$>$ is not given it is assumed to be
infinity. The increment may be negative. For example,
\begin{verbatim}
          set xtics 0,.5,10
\end{verbatim}
makes tics at 0, 0.5, 1, 1.5, ..., 9.5, 10.

The (''$<$label$>$'' $<$pos$>$, ...) form allows arbitrary tic positions or
non-numeric tic labels. A set of tics are a set of positions, each
with its own optional label. Note that the label is a string enclosed
by quotes, and may be a constant string, such as ``hello'', or contain
formatting information for the tic number (which is the same as the
position), such as ''\%3f clients''. See {\bf set format} for more
information about this case. The label may even be empty.
Examples:
\begin{verbatim}
         set xtics ("low" 0, "medium" 50, "high" 100)
         set xtics (1,2,4,8,16,32,64,128,256,512,1024)
         set xtics ("bottom" 0, "" 10, "top" 20)
\end{verbatim}

Tics will only be plotted when in range.

The {\bf set ytics} and {\bf set noytics} commands work identically.
See also the {\bf set format} command.
\subsection{Xzeroaxis}
{\bf set xzeroaxis} draws the x-axis. By default, this option is on.
{\bf set noxzeroaxis} causes GNUPLOT to omit the x-axis.

Syntax:
\begin{verbatim}
        set xzeroaxis
        set noxzeroaxis
        show xzeroaxis
\end{verbatim}
\subsection{Ylabel}
The {\bf set ylabel} command sets the y-axis label.  The position of this
label depends on the terminal, and can be one of the following three
positions (the position can be adjusted with optional parameters).

1. Horizontal text flushed left at the top left of the plot.
Terminals that cannot rotate text will probably use this method.

2. Vertical text centered vertically at the left of the plot.
Terminals that can rotate text will probably use this method.

3. Horizontal text centered vertically at the left of the plot.
The LaTeX and EEPIC drivers use this method. The user must insert 
line breaks using $\backslash$$\backslash$ to prevent the ylabel from overwriting
the plot. To produce a vertical row of characters, add $\backslash$$\backslash$
between every printing character (but this is ugly).

Syntax:  
\begin{verbatim}
         set ylabel {"<label>"} {<xoff>}{,<yoff>}
         show ylabel
\end{verbatim}

With no parameters, the label is cleared. Specifying constants $<$xoff$>$
or $<$yoff$>$ as optional offsets for the label will move the label $<$xoff$>$
or $<$yoff$>$ character screen coordinates. For example,

\begin{verbatim}
         set ylabel -1
\end{verbatim}

will change only the x offset of the ylabel, moving the label roughly
one character width left of its default position. This is especially
useful with the LaTeX driver.

(The LaTeX, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline.)
\subsection{Yrange}
The {\bf set yrange} command sets the vertical range that will be
displayed. This command turns y axis autoscaling off.

This range may also be specified on the {\bf plot} command line.

Syntax:
\begin{verbatim}
        set yrange [{<ymin> : <ymax>}]
\end{verbatim}

where $<$ymin$>$ and $<$ymax$>$ terms are constants or expressions.

Both the $<$ymin$>$ and $<$ymax$>$ terms are optional. Anything omitted will
not be changed, so 
\begin{verbatim}
        set yrange [:10]
\end{verbatim}
changes ymax to 10 without affecting ymin.
\subsection{Ytics}
The {\bf set ytics} and {\bf set noytics} commands are similar to the {\bf set xtics}
and {\bf set noxtics} commands. Please see {\bf set xtics}.
\subsection{Yzeroaxis}
{\bf set yzeroaxis} draws the y-axis. By default, this option is on.
{\bf set noyzeroaxis} causes GNUPLOT to omit the y-axis.

Syntax:
\begin{verbatim}
        set yzeroaxis
        set noyzeroaxis
        show yzeroaxis
\end{verbatim}
\subsection{Zero}
The {\bf zero} value is the default threshold for values approaching 0.0.
GNUPLOT will not plot a point if its imaginary part is greater in
magnitude than the {\bf zero} threshold. Axis ranges cannot be less than
{\bf zero}. The default {\bf zero} value is 1e-8. This can be changed with
the {\bf set zero} command.

Syntax:
\begin{verbatim}
        set zero <expression>
        show zero
\end{verbatim}
\subsection{Zeroaxis}
{\bf set zeroaxis} draws the x-axis and y-axis. By default, this option is
on.  {\bf set nozeroaxis} causes GNUPLOT to omit the axes, and is
equivalent to {\bf set noxzeroaxis; set noyzeroaxis.}

Syntax:
\begin{verbatim}
        set zeroaxis
        set nozeroaxis
        show zeroaxis
\end{verbatim}
See {\bf set xzeroaxis} and {\bf set yzeroaxis}.
\subsection{Zlabel}
The {\bf set zlabel} command sets the z-axis label that is centered along
the z axis. Using the optional x,y screen offsets, the label can be
placed anywhere on the plot. {\bf set zlabel} with no parameters clears
the label.

Syntax: 
\begin{verbatim}
         set zlabel {"<label>"} {<xoff>}{,<yoff>}
         show zlabel
\end{verbatim}

Specifying constants $<$xoff$>$ or $<$yoff$>$ as optional offsets for the
label will move the label $<$xoff$>$ or $<$yoff$>$ character screen
coordinates. For example,

\begin{verbatim}
         set zlabel ,1
\end{verbatim}

will change only the y offset of the zlabel, moving the label roughly
one character height up.

The zlabel will be drawn whenever surfaces or contours are plotted,
in the space above the grid level.

(The LaTeX, EEPIC, and Imagen drivers allow $\backslash$$\backslash$ in a string to specify
a newline.)
\subsection{Zrange}
The {\bf set zrange} command sets the vertical range that will be
displayed. This command turns z axis autoscaling off.  The zrange is
used only by {\bf splot} and is ignored by {\bf plot}.

This range may also be specified on the {\bf splot} command line.

Syntax:
\begin{verbatim}
        set zrange [{<zmin> : <zmax>}]
\end{verbatim}

where $<$zmin$>$ and $<$zmax$>$ terms are constants or expressions.

Both the $<$zmin$>$ and $<$zmax$>$ terms are optional. Anything omitted will
not be changed, so
\begin{verbatim}
        set zrange [2:]
\end{verbatim}
changes zmin to 2 without affecting zmax.
\subsection{Ztics}
The {\bf set ztics} and {\bf set noztics} commands are similar to the {\bf set
xtics} and {\bf set noxtics} commands. Please see {\bf set xtics}.
\section{Shell}
The {\bf shell} command spawns an interactive shell. To return to
GNUPLOT, type {\bf logout} if using VMS, {\bf exit} or the END-OF-FILE
character if using Unix, {\bf endcli} if using AmigaDOS, or {\bf exit} if
using MS-DOS.

A single shell command may be spawned by preceding it with the !
character (\$ if using VMS) at the beginning of a command line.
Control will return immediately to GNUPLOT after this command is
executed. For example, in VMS, AmigaDOS, or MS-DOS,

\begin{verbatim}
     ! dir
\end{verbatim}

prints a directory listing and then returns to GNUPLOT.
\section{Splot}
Three-dimensional surface and contour plotting is available in
GNUPLOT with the {\bf splot} command. See the {\bf plot} command for features
common to the {\bf plot} command.

See also {\bf set contour}, {\bf set cntrparam}, and {\bf set surface}.
\section{Start-up}
When GNUPLOT is run, it looks for an initialization file to load.
This file is called {\bf .gnuplot} on Unix and AmigaDOS systems, and
{\bf GNUPLOT.INI} on other systems. If this file is not found in the
current directory, the program will look for it in the home directory
(under AmigaDOS and MS-DOS, the environment variable GNUPLOT should
contain the name of this directory).

If this file is found, GNUPLOT executes the commands in this file.
This is most useful for setting the terminal type and defining any
functions or variables that are used often.
\section{Substitution}
Command-line substitution is specified by a system command enclosed in
backquotes. This command is spawned and the output it produces
replaces the name of the command (and backquotes) on the command line.

Newlines in the output produced by the spawned command are replaced
with blanks.

Command-line substitution can be used anywhere on the GNUPLOT command
line.

Example:

This will run the program {\bf leastsq} and replace {\bf leastsq} (including
backquotes) on the command line with its output:

\begin{verbatim}
         f(x) = `leastsq`
\end{verbatim}

or, in VMS

\begin{verbatim}
         f(x) = `run leastsq`
\end{verbatim}
\section{User-defined}
New user-defined variables and functions of one or two variables may be 
declared and used anywhere.

User-defined function syntax:
\begin{verbatim}
        <function-name> ( <dummy-var1> {,<dummy-var2>} ) =  <expression>
\end{verbatim}

where $<$expression$>$ is defined in terms of $<$dummy-var1$>$ and $<$dummy-var2$>$.

User-defined variable syntax:
\begin{verbatim}
        <variable-name> = <constant-expression>
\end{verbatim}

Examples:
\begin{verbatim}
        w = 2
        q = floor(tan(pi/2 - 0.1))
        f(x) = sin(w*x)
        sinc(x) = sin(pi*x)/(pi*x)
        delta(t) = (t == 0)
        ramp(t) = (t > 0) ? t : 0
        min(a,b) = (a < b) ? a : b
        comb(n,k) = n!/(k!*(n-k)!)
\end{verbatim}

Note that the variable {\bf pi} is already defined.

See {\bf show functions} and {\bf show variables}.
\section{Bugs}
The bessel functions do not work for complex arguments.

The gamma function does not work for complex arguments.

There is a bug in the stdio library for old Sun operating systems
(SunOS Sys4-3.2). The ''\%g'' format for 'printf' sometimes incorrectly
prints numbers (e.g., 200000.0 as ``2''). Thus, tic mark labels may be
incorrect on a Sun4 version of GNUPLOT. A work-around is to rescale
the data or use the {\bf set format} command to change the tic mark format
to ''\%7.0f'' or some other appropriate format. This appears to have been
fixed in SunOS 4.0.

Another bug: On a Sun3 under SunOS 4.0, and on Sun4's under Sys4-3.2
and SunOS 4.0, the 'sscanf' routine incorrectly parses ``00 12'' with
the format ''\%f \%f'' and reads 0 and 0 instead of 0 and 12. This
affects data input. If the data file contains x coordinates that are
zero but are specified like '00', '000', etc, then you will read the
wrong y values. Check any data files or upgrade the SunOS.
It appears to have been fixed in SunOS 4.1.1.

Microsoft C 5.1 has a nasty bug associated with the \%g format for
printf. When any of the formats ''\%.2g'', ''\%.1g'', ''\%.0g'', ''\%.g'' are
used, printf will incorrectly print numbers in the range 1e-4 to 1e-1.
Numbers that should be printed in the \%e format are incorrectly 
printed in the \%f format, with the wrong number of zeros after the 
decimal point.

To work around this problem, use the \%e or \%f formats explicitly.

GNUPLOT, when compiled with Microsoft C, did not work correctly on two
VGA displays that were tested. The CGA, EGA and VGA drivers should 
probably be rewritten to use the Microsoft C graphics library.
GNUPLOT compiled with Turbo C uses the Turbo C graphics drivers and 
does work correctly with VGA displays.

VAX/VMS 4.7 C compiler release 2.4 also has a poorly implemented \%g 
format for printf. The numbers are printed numerically correct, but 
may not be in the requested format. The K\&R second edition says that 
for the \%g format, \%e is used if the exponent is less than -4 or greater 
than or equal to the precision. The VAX uses \%e format if the exponent 
is less than -1. The VAX appears to take no notice of the precision 
when deciding whether to use \%e or \%f for numbers less than 1.
To work around this problem, use the \%e or \%f formats explicitly.
From the VAX C 2.4 release notes:
e,E,f,F,g,G  Result will always contain a decimal  point.
For g and G, trailing zeros will not be removed from the result.

VAX/VMS 5.2 C compiler release 3.0 has a slightly better implemented
\%g format than release 2.4, but not much. Trailing decimal points are 
now removed, but trailing zeros are still not removed from \%g numbers 
in exponential format.

ULTRIX X11R3 has a bug that causes the X11 driver to display ``every
other'' plot.  The bug seems to be fixed in DEC's release of X11R4 so
newer releases of ULTRIX don't seem to have the problem.  Solutions for 
older sites include upgrading the X11 libraries (from DEC or direct from 
MIT) or defining ULTRIX\_KLUDGE when compiling the x11.trm file.  Note 
that the kludge is not an ideal fix, however.

The constant HUGE was incorrectly defined in the NeXT OS 2.0 operating
system.  HUGE should be set to 1e38 in plot.h. This error has been
corrected in the 2.1 version of NeXT OS.

Some older models of HP plotters do not have a page eject command 'PG'.
The current HPGL driver uses this command in HPGL\_reset.  This may need
to be removed for these plotters.  The current PCL5 driver uses HPGL/2
for text as well as graphics.  This should be modified to use scalable
PCL fonts.

Please report any bugs to bug-gnuplot@ames.arc.nasa.gov.
\end{document}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/gnuplot.toc version [81f4be542e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
\contentsline {section}{\numberline {1}Gnuplot}{1}
\contentsline {section}{\numberline {2}Cd}{1}
\contentsline {section}{\numberline {3}Clear}{1}
\contentsline {section}{\numberline {4}Command-line editing}{1}
\contentsline {section}{\numberline {5}Comment}{2}
\contentsline {section}{\numberline {6}Environment}{2}
\contentsline {section}{\numberline {7}Exit}{3}
\contentsline {section}{\numberline {8}Expressions}{3}
\contentsline {subsection}{\numberline {8.1}Functions}{3}
\contentsline {subsection}{\numberline {8.2}Operators}{4}
\contentsline {subsubsection}{\numberline {8.2.1}Binary}{4}
\contentsline {subsubsection}{\numberline {8.2.2}Unary}{5}
\contentsline {section}{\numberline {9}Help}{5}
\contentsline {section}{\numberline {10}Load}{6}
\contentsline {section}{\numberline {11}Pause}{6}
\contentsline {section}{\numberline {12}Plot}{6}
\contentsline {subsection}{\numberline {12.1}Data-file}{7}
\contentsline {subsubsection}{\numberline {12.1.1}Using}{8}
\contentsline {subsection}{\numberline {12.2}Errorbars}{10}
\contentsline {subsection}{\numberline {12.3}Parametric}{10}
\contentsline {subsection}{\numberline {12.4}Ranges}{11}
\contentsline {subsection}{\numberline {12.5}Style}{12}
\contentsline {subsection}{\numberline {12.6}Title}{13}
\contentsline {section}{\numberline {13}Print}{13}
\contentsline {section}{\numberline {14}Pwd}{13}
\contentsline {section}{\numberline {15}Quit}{14}
\contentsline {section}{\numberline {16}Replot}{14}
\contentsline {section}{\numberline {17}Save}{14}
\contentsline {section}{\numberline {18}Set-show}{14}
\contentsline {subsection}{\numberline {18.1}Angles}{14}
\contentsline {subsection}{\numberline {18.2}Arrow}{15}
\contentsline {subsection}{\numberline {18.3}Autoscale}{15}
\contentsline {subsubsection}{\numberline {18.3.1}Parametric mode}{16}
\contentsline {subsection}{\numberline {18.4}Border}{17}
\contentsline {subsection}{\numberline {18.5}Clip}{17}
\contentsline {subsection}{\numberline {18.6}Cntrparam}{17}
\contentsline {subsection}{\numberline {18.7}Contour}{18}
\contentsline {subsection}{\numberline {18.8}Data style}{18}
\contentsline {subsection}{\numberline {18.9}Dummy}{18}
\contentsline {subsection}{\numberline {18.10}Format}{19}
\contentsline {subsection}{\numberline {18.11}Function style}{19}
\contentsline {subsection}{\numberline {18.12}Functions}{19}
\contentsline {subsection}{\numberline {18.13}Grid}{20}
\contentsline {subsection}{\numberline {18.14}Hidden3d}{20}
\contentsline {subsection}{\numberline {18.15}Isosamples}{20}
\contentsline {subsection}{\numberline {18.16}Key}{20}
\contentsline {subsection}{\numberline {18.17}Label}{21}
\contentsline {subsection}{\numberline {18.18}Logscale}{22}
\contentsline {subsection}{\numberline {18.19}Mapping}{22}
\contentsline {subsection}{\numberline {18.20}Offsets}{23}
\contentsline {subsection}{\numberline {18.21}Output}{23}
\contentsline {subsection}{\numberline {18.22}Parametric}{23}
\contentsline {subsection}{\numberline {18.23}Polar}{24}
\contentsline {subsection}{\numberline {18.24}Rrange}{25}
\contentsline {subsection}{\numberline {18.25}Samples}{25}
\contentsline {subsection}{\numberline {18.26}Size}{25}
\contentsline {subsection}{\numberline {18.27}Style}{26}
\contentsline {subsection}{\numberline {18.28}Surface}{26}
\contentsline {subsection}{\numberline {18.29}Terminal}{27}
\contentsline {subsubsection}{\numberline {18.29.1}Dumb}{27}
\contentsline {subsubsection}{\numberline {18.29.2}Hpljii}{27}
\contentsline {subsubsection}{\numberline {18.29.3}Iris4d}{27}
\contentsline {subsubsection}{\numberline {18.29.4}Pbm}{28}
\contentsline {subsubsection}{\numberline {18.29.5}Postscript}{28}
\contentsline {subsubsection}{\numberline {18.29.6}Aifm}{29}
\contentsline {subsubsection}{\numberline {18.29.7}Table}{29}
\contentsline {subsection}{\numberline {18.30}Tics}{29}
\contentsline {subsection}{\numberline {18.31}Time}{30}
\contentsline {subsection}{\numberline {18.32}Title}{30}
\contentsline {subsection}{\numberline {18.33}Trange}{31}
\contentsline {subsection}{\numberline {18.34}Urange}{31}
\contentsline {subsection}{\numberline {18.35}Variables}{31}
\contentsline {subsection}{\numberline {18.36}View}{31}
\contentsline {subsection}{\numberline {18.37}Vrange}{32}
\contentsline {subsection}{\numberline {18.38}Xlabel}{32}
\contentsline {subsection}{\numberline {18.39}Xrange}{32}
\contentsline {subsection}{\numberline {18.40}Xtics}{33}
\contentsline {subsection}{\numberline {18.41}Xzeroaxis}{33}
\contentsline {subsection}{\numberline {18.42}Ylabel}{33}
\contentsline {subsection}{\numberline {18.43}Yrange}{34}
\contentsline {subsection}{\numberline {18.44}Ytics}{34}
\contentsline {subsection}{\numberline {18.45}Yzeroaxis}{34}
\contentsline {subsection}{\numberline {18.46}Zero}{35}
\contentsline {subsection}{\numberline {18.47}Zeroaxis}{35}
\contentsline {subsection}{\numberline {18.48}Zlabel}{35}
\contentsline {subsection}{\numberline {18.49}Zrange}{35}
\contentsline {subsection}{\numberline {18.50}Ztics}{36}
\contentsline {section}{\numberline {19}Shell}{36}
\contentsline {section}{\numberline {20}Splot}{36}
\contentsline {section}{\numberline {21}Start-up}{36}
\contentsline {section}{\numberline {22}Substitution}{36}
\contentsline {section}{\numberline {23}User-defined}{37}
\contentsline {section}{\numberline {24}Bugs}{37}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































Deleted r34.1/plot/docs/lasergnu.1 version [a9a3ad3c28].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.TH LASERGNU l 
.SH NAME
lasergnu \- send gnuplot output to a printer
.SH SYNOPSIS
.B lasergnu
[ flags ] plot-command...
.SH DESCRIPTION
.I lasergnu
runs
.IR gnuplot (1)
in an environment to produce typeset output on an IMAGEN  or
Postscript printer.
.PP
The 
.B gnuplot
commands
.B plot-command
are performed and the output sent to the printer. 
If the 
.B -f
option specifies a file for input, the plot command is optional. 
The command-line plot commands are executed prior to any in the
file(s).
.PP
For example, to plot the function
.I sin(x)
from -1 to +1, and to use printer im1, use the command
.br
.nf
    lasergnu -Pim1 'plot [-1:1] sin(x) with lines'
.fi
To execute the gnuplot command file
.I myplot,
on the postscript printer lw0, use the command
.br
.nf
    lasergnu -Plw0 -p -f myplot
.fi
The following switches are recognized:
.TP
.BI \-p
Use the postscript language to make the plot, instead of Impress.
This is for use on Postscript printers only. This uses a double-size
plot in landscape mode as the default.
.TP
.BI \-P\0 printer
The output of this program is intended for 
.I printer.
\ If the file is being spooled, this determines the printer it is spooled
to (default: $LASER).
Be sure to use the -p flag if the printer is a postscript printer.
.TP
.BI \-f\0 file
Take gnuplot commands from the named file.
Multiple files  may be supplied with separate -f options.
.TP
.BI  \-t\0 title
Specify the title of the plot.
.TP
.BI \-b
Do not print a banner page.
.TP
.BI \-J
Do not print a banner page.
.TP
.B \-help
Prints a list of options.
.SH SEE ALSO
gnuplot(l), lpr(1)
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































Deleted r34.1/plot/docs/latextut/Makefile version [eaa0e5623c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Makefile for gnuplot LaTeX tutorial
# To make the manual from scratch, we run latex two times
all: tutorial.dvi done

done:
	latex tutorial
	echo > done

# To touch it up after changes:
remake: tutorial.dvi

# Always runs latex, e.g., to get labels right
force: 
	latex tutorial

tutorial.dvi: eg1.tex eg2.tex eg3.tex eg4.tex eg5.tex eg6.tex linepoint.tex \
	tutorial.tex header.tex
	latex tutorial
	rm -f done

.SUFFIXES: .tex .plt

.plt.tex:
	gnuplot $<

clean:
	rm -f *~ *.log eg?.tex linepoint.tex

spotless:
	rm -f *~ *.log *.aux *.dvi eg?.tex linepoint.tex done
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































Deleted r34.1/plot/docs/latextut/eg1.plt version [34b9c728ca].

1
2
3
set terminal latex
set output "eg1.tex"
plot [-3.14:3.14] sin(x)
<
<
<






Deleted r34.1/plot/docs/latextut/eg2.plt version [1fad00942b].

1
2
3
4
5
6
7
8
set terminal latex
set output "eg2.tex"
set size 5/5., 4/3.
set format xy "$%g$"
set title "This is a plot of $y=sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "This is\\the\\$y$ axis"
plot [0:6.28] [0:1] sin(x)
<
<
<
<
<
<
<
<
















Deleted r34.1/plot/docs/latextut/eg3.dat version [43e3505cc1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-20.000000 -9.125028
-19.000000 -9.109280
-18.000000 -9.091787
-17.000000 -9.072243
-16.000000 -9.050265
-15.000000 -9.025369
-14.000000 -8.996933
-13.000000 -8.964147
-12.000000 -8.925931
-11.000000 -8.880819
-10.000000 -8.826766
-9.000000 -8.760835
-8.000000 -8.678648
-7.000000 -8.573396
-6.000000 -8.433886
-5.000000 -8.240405
-4.000000 -7.954906
-3.000000 -7.494275
-2.000000 -6.642892
-1.000000 -4.712389
0.000000 0.000000
1.000000 4.712389
2.000000 6.642892
3.000000 7.494275
4.000000 7.954906
5.000000 8.240405
6.000000 8.433886
7.000000 8.573396
8.000000 8.678648
9.000000 8.760835
10.000000 8.826766
11.000000 8.880819
12.000000 8.925931
13.000000 8.964147
14.000000 8.996933
15.000000 9.025369
16.000000 9.050265
17.000000 9.072243
18.000000 9.091787
19.000000 9.109280
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































Deleted r34.1/plot/docs/latextut/eg3.plt version [fea98e65e0].

1
2
3
4
5
6
7
8
set terminal latex
set output "eg3.tex"
set format xy "$%g$"
set title "This is another plot"
set xlabel "$x$ axis"
set ylabel "$y$ axis"
set key 15,-10
plot x with lines, "eg3.dat" with linespoints
<
<
<
<
<
<
<
<
















Deleted r34.1/plot/docs/latextut/eg4.plt version [abe97b88dd].

1
2
3
4
5
6
7
8
9
10
set terminal latex
set output "eg4.tex"
set format y "$%g$"
set format x "$%.2f$"
set title "This is $\sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "$\sin(x)$"
set nokey
set xtics -pi, pi/4
plot [-pi:pi] [-1:1] sin(x)
<
<
<
<
<
<
<
<
<
<




















Deleted r34.1/plot/docs/latextut/eg5.plt version [0dc7898cbf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
set terminal latex
set output "eg5.tex"
set format y "$%g$"
set format x "$%4.1f\pi$"
set noclip points
set title "This is $\sin(x)$"
set xlabel "This is the $x$ axis"
set ylabel "$\sin(x)$"
set nokey
set xtics ("$-\pi$" -pi,\
 "$-\frac{\pi}{2}$" -pi/2,\
 "0" 0,\
 "$\frac{\pi}{2}$" pi/2,\
 "$\pi$" pi)
plot [-pi:pi] [-1:1] sin(x)
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























Deleted r34.1/plot/docs/latextut/eg6.plt version [b644daffda].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
set terminal latex
set output "eg6.tex"
set size 3.5/5, 3/3.
set format y "$%g$"
set format x "$%5.1f\mu$"
set title "This is a title"
set xlabel "This is the $x$ axis"
set ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
set label "Data" at -5,-5 right
set arrow from -5,-5 to -3.3,-6.7
set key -4,8
set xtic -10,5,10
plot [-10:10] [-10:10] "eg3.dat" title "Data File"  with linespoints 1 7,\
   3*exp(-x*x)+1  title "$3e^{-x^{2}}+1$" with lines 4
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























Deleted r34.1/plot/docs/latextut/header.tex version [ef33e1a867].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% 
% Header file for tutorial.tex
%

% Spacing
\newcommand{\singlespace}
  {\addtolength{\baselineskip}{-.333\baselineskip}}
\newcommand{\doublespace}
  {\addtolength{\baselineskip}{.5\baselineskip}}

% Spacing for the whole document 
\newcommand{\currentspace}{} % use this for single space
% \newcommand{\currentspace}{\doubleespace} % use this for double space

% Common abbreviations
% (Remember to put '\ ' after if an interword space is
%  desired rather than end-of-sentence space. Same for '.etc)' ).
\newcommand{\eg}{{\em e.g.}}		% e.g.
\newcommand{\ie}{{\em i.e.}}		% i.e.
\newcommand{\etc}{{\em etc.}}		% etc.
\newcommand{\vs}{{\em vs.}}		% vs.
\newcommand{\usec}{{$\mu$}sec}	% microseconds

% \boxfigure{pos}{wid}{text}:  A figure with a box around it
%
% pos	the usual figure placement arg: eg. htbp
% wid	the width of the figure, in some units: eg. 5in
% text	the contents of the figure, including picture/caption/label/etc
%
\newlength{\boxwidth}
\newcommand{\boxfigure}[3]{
	\begin{figure}[#1]
		\setlength{\boxwidth}{#2}
		\addtolength{\boxwidth}{.1in}

		\centering
		\framebox[\boxwidth]{
			\begin{minipage}{#2}
			#3
			\end{minipage}
		}
	\end{figure}  
}

% use \fullboxwidth for arg 2 of boxfigure to get box of size \textwidth

% To show a syntax for a gnutex command
\newenvironment{syntax}{\begin{quote}\tt}{\end{quote}}

\documentstyle[titlepage,11pt]{article}

% Margins
\sloppy
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9in}
\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}

% see above
\newlength{\fullboxwidth}
\setlength{\fullboxwidth}{\textwidth}
\addtolength{\fullboxwidth}{-0.1in}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































Deleted r34.1/plot/docs/latextut/linepoint.plt version [fbcf551dda].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Plots all line types and point types
set term latex
set out "linepoint.tex"
set clip points
set dummy t,y
set nokey
set parametric
set samples 14	 # for trange 0:13, we get 14 points: 0, 1, ..., 13
set function style lines
set xtics 1,1,12
set ytics 1,1,6
set title "Up to 6 line types and 12 point types"
set trange [0 : 13]
set xlabel "Points"
set xrange [0 : 13]
set ylabel "Lines"
set yrange [0 : 7]
plot t,1, t,2, t,3, t,4, t,5, t,6, 1,t w p, 2,t w p, 3,t w p, 4,t w p,5,t w p, 6,t w p, 7,t w p, 8,t w p, 9,t w p, 10,t w p, 11,t w p, 12,t w p
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted r34.1/plot/docs/latextut/tutorial.tex version [0f86d910b5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
% 
% Tutorial for GNUPLOT plotting program, for LaTeX users
% David Kotz (David.Kotz@Dartmouth.edu)
% Duke University Computer Science Department
%
% NOTE: If LaTeX runs out of memory processing plots,
% add ``with lines 4'' to each curve in eg*.plt and rerun make.
%

% some header info
\input{header}

\begin{document}

\title{\LaTeX\ and the GNUPLOT Plotting 
Program\thanks{This document describes GNUPLOT version 3.0. All plots
in this document were made with that version of GNUPLOT.} }
\author{David Kotz \\ \verb+David.Kotz@Dartmouth.edu+}
\date{July 3, 1991}

\maketitle

\pagestyle{myheadings}
\markright{GNUPLOT \LaTeX\ Tutorial Version 3.0}

\currentspace % defined in header.tex

\section{Introduction and History}

GNUPLOT was originally developed by Colin Kelley and Thomas Williams
in 1986 to plot functions and data files on a variety of terminals.
In 1988 and 1989 I created an alternate version, known as Gnu\TeX,
that supported a new ``terminal type'' called {\tt latex}, so gnuplot
would output \LaTeX\ code. The plot could then be included in a
\LaTeX\ document. I added a number of embellishments, supported only
by the {\tt latex} terminal, allowing the user to produce
publication-quality plots.

In late 1989 and early 1990 Gnu\TeX\ and a number of other GNUPLOT
variants were merged together into a new release of GNUPLOT, 2.0. This
includes, among many other improvements, a \LaTeX\ driver derived from
the one in Gnu\TeX. Former Gnu\TeX\ users are referred to
Section~\ref{oldusers} for information about adapting to GNUPLOT.
Anyone interested in using GNUPLOT with \LaTeX\ should read the next
section, a tutorial, and the primary GNUPLOT manual.

The reader should note that the \LaTeX\ picture environments output by
GNUPLOT can be quite large and complicated, and can easily exceed the
memory capacity of \TeX. If an enlarged version of \TeX\ is available,
it is wise to use it. Otherwise, keep your plots simple and add
\verb+\clearpage+ to your document where necessary.

There is also a new EEPIC driver ({\tt eepic}), intended for use with
the EEPIC macro package for \LaTeX. EEPIC allows for much more
efficient line-drawing, runs through \LaTeX\ faster, and uses less
memory.  See Section~\ref{s:eepic} for more information.

There is a small package of auxiliary files (makefiles and scripts)
that I find useful for making \LaTeX\ plots with GNUPLOT. This is
available for \verb+ftp+ as \verb+pub/gnuplot-latex.shar+ from
\verb+cs.duke.edu+. I can mail copies (see the end of this paper for
information).

\section{Using GNUPLOT for \LaTeX: a Tutorial}

GNUPLOT is by nature an interactive program. Users making plots for
\LaTeX\ will generally not use GNUPLOT interactively.  Whenever hard
copy is desired from GNUPLOT, the program need not be run on a
graphics terminal. In this case the output is directed to a file or
pipe, then sent to the appropriate output device. For example, output
from the terminal type {\tt unixplot} may be sent to a program
interpreting the Unix plotting standard. The terminal types {\tt
imagen} and {\tt postscript} may be used for output to printers
understanding those languages. (A shell script ({\tt lasergnu}) is
supplied with the distribution that will accept a GNUPLOT command or
input file and send the output to an Imagen or Postscript laser
printer. This script may have been adapted to your site.) The terminal
type {\tt fig} outputs FIG code that can be read by the Fig graphics
program and translated into forms usable in both \TeX\ and
\LaTeX\ documents.

We now ignore the interactive nature of GNUPLOT and provide the input
to GNUPLOT from a file, \ie,
\begin{verbatim}
      gnuplot gnu.input
\end{verbatim}
In this example, all of the commands to GNUPLOT are contained in the
file {\tt gnu.input}. Multiple filenames may be supplied to GNUPLOT
this way, read in the order they are given.  The output (one or more
plots) may be piped to another program or redirected to a file.
Usually, however, we direct the output explicitly with an instruction
to GNUPLOT (the {\tt set output} command). GNUPLOT continues to print
error messages to the terminal (stderr).

\paragraph{Example 1:} Here is a first example, producing a plot for
this document. The GNUPLOT input file is given below, and the output
appears as Figure~\ref{eg1}. The input file defines the output to be
in \LaTeX, gives a file name for the output, and plots $y=sin(x)$ for
$x$ on $[-\pi,\pi]$. To produce the figure, I simply
\verb+\input{eg1}+ in a {\tt center} environment in a {\tt figure}
environment. In following examples, I will enclose the figure in a box
to make it look a little better.

\singlespace
\begin{verbatim}
    set terminal latex
    set output "eg1.tex"
    plot [-3.14:3.14] sin(x)
\end{verbatim}
\currentspace

\begin{figure}[htbp]
  \begin{center}
    \input{eg1}
  \end{center}
  \caption{A first example: $y=sin(x)$} 
  \label{eg1}
\end{figure}

Note that GNUPLOT has drawn in the axes, labeled the tic marks for us,
scaled the $y$ axis automatically, and added a key in the
upper-right-hand corner (this may be moved with the {\tt set key}
command, and removed with {\tt set nokey}).

This is the default line style for the \LaTeX\ driver.  Because of the
limited picture capabilities of \LaTeX, many dots are required to
approximate drawing a solid line. This may overload the memory of many
\TeX\ implementations. There are other line types available that draw
dotted lines and use much less memory. The EEPIC driver draws solid
lines with much less memory usage.

\paragraph{Example 2:} Now we will embellish the plot a little with
some labels.  This input file produces Figure~\ref{eg2}.

\singlespace
\begin{verbatim}
    set terminal latex
    set output "eg2.tex"
    set size 5/5., 4/3.
    set format xy "$%g$"
    set title "This is a plot of $y=sin(x)$"
    set xlabel "This is the $x$ axis"
    set ylabel "This is\\the\\$y$ axis"
    plot [0:6.28] [0:1] sin(x)
\end{verbatim}
\currentspace

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{eg2}
  \end{center}
  \caption{A more fancy example.}
  \label{eg2}
}

We have specified the plot to be 5 inches wide and 4 inches tall with
the {\tt set size} command. This is the size of the area used by the
plot, {\em including} space for the labels.  In the first example,
this size was the default 5 inches by 3 inches. By specifying the
scaling factors of 1 (or 5/5) and 1.3333 (or 4/3), we obtain the
desired plot size. 

We have requested that the format used by the $x$- and $y$-axis tic
mark labels be in \LaTeX\ math mode. This makes the labels look a
little better. The default is \verb+set format xy "%g"+. The \verb+%g+
represents the general-purpose floating point formatting specification
for the {\tt printf} function in C. Any valid floating-point
formatting specification, or \LaTeX\ command, is allowed in the
format.

A title for the plot and labels for the axes were set up in the next
three commands.  Note that they are processed by \LaTeX\ and so may
have math mode and other symbols in them. The ylabel may have multiple
lines, delineated with \verb+\\+.  The ylabel can be moved around with
optional offset parameters (see {\tt set ylabel} in the GNUPLOT
manual). Typically, the ylabel needs to be moved to the left to avoid
interfering with the left-hand side of the plot.  Once these labels
are set up, they will be used for all subsequent plot commands until
they are changed. These labels are also supported by the other
terminal types, but (of course) any \LaTeX\ code in the string will
not be interpreted. We have also defined the range of both $x$ (now
$[0,2\pi]$) and $y$ (here $[0,1]$).

So far we have plotted one curve, $y=\sin(x)$, on one plot. In
GNUPLOT, each {\tt plot} command generates a new plot. If the output
is to a screen, the screen is cleared. If to a printer, a new page is
produced. In the {\tt latex} case, a new picture is started. It is not
likely that \LaTeX\ users will want this to happen, so generally each
plot has its own input file and is kept in a separate output ({\tt
.tex}) file for inclusion at different places in the document.

\paragraph{Example 3:} To place more than one curve on a plot, use one
{\tt plot} statement and separate the description of each curve by a
comma. In our next example, we will plot both a function and a data
file on the same plot. This plot is shown in Figure~\ref{eg3}.

\singlespace
\begin{verbatim}
    set terminal latex
    set output "eg3.tex"
    set format xy "$%g$"
    set title "This is another plot"
    set xlabel "$x$ axis"
    set ylabel "$y$ axis"
    set key 15,-10
    plot x with lines, "eg3.dat" with linespoints
\end{verbatim}
\currentspace

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{eg3}
  \end{center}
  \caption{An example with two curves on the same plot.}
  \label{eg3}
}

Here you will see that the $x$ range was not specified. The $x$ range
is determined automatically, unless specified by the user.  In
this case, it is defined by the range of the data file
\verb+"eg3.dat"+. The function is plotted over the same range. If no
data files or $x$ range are supplied, the default range of $[-10:10]$
is used. We have also moved the key to a different position.  The
function $y=x$ is plotted ``with lines'', which is the default plot
style for functions, and is shown here to illustrate the plot style
option.  The data file {\tt eg3.dat} is plotted with style {\tt
linespoints}, a style like {\tt lines} that also plots a symbol at
each data point.

There is a style called {\tt points} that only plots the symbols at
data points, and another called {\tt dots} that plots a tiny dot for
each data point.  The {\tt points} and {\tt linespoints} styles
produce a different point symbol for each curve on the plot (for up to
twelve symbols, after which they are re-used; see
Figure~\ref{linepoint} for a complete list). The {\tt lines} and {\tt
linespoints} styles use a different line style for each curve on the
plot (in this example the dots have different spacing). The
style {\tt impulses} draws a perpendicular from each point to the
$x$-axis. Finally, the {\tt errorbars} style can draw error bars at
each data point (see the GNUPLOT manual). 

\paragraph{Example 4:} In the above plots of $\sin(x)$, it would make
more sense to label the axis in units of $\pi$. The position and
labels of the tic labels may be specified by the user, with the {\tt
set xtics} and {\tt set ytics} commands. This is demonstrated by
the following example, shown in Figure~\ref{eg4}.

\singlespace
\begin{verbatim}
    set terminal latex
    set output "eg4.tex"
    set format y "$%g$"
    set format x "$%.2f$"
    set title "This is $\sin(x)$"
    set xlabel "This is the $x$ axis"
    set ylabel "$\sin(x)$"
    set nokey
    set xtics -pi, pi/4
    plot [-pi:pi] [-1:1] sin(x)
\end{verbatim}
\currentspace

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{eg4}
  \end{center}
  \caption{An example of the {\tt set xtics} command.}
  \label{eg4}
}

Since {\tt pi} is a predefined variable in GNUPLOT, we can use it
anywhere we may use an expression. The {\tt set xtics} command here
specifies that the tics on the $x$ axis start at $-\pi$ and increment
by $\pi/4$. Since no end point is given, the tics continue to the
right edge. We have also turned off the key, and changed the format to
restrict the $x$-axis tic labels to 2 decimal places.

With a little more work, the plot can look even better.  Another form
of this command allows us to specify the label and position of each
tic individually.  Replacing the above {\tt set xtics} command with
the following gives us Figure~\ref{eg5}. We also make use of the line
continuation character, the backslash (\verb+\+), to spread out this
command for readability.

\singlespace
\begin{verbatim}
    set xtics ("$-\pi$" -pi,\
     "$-\frac{\pi}{2}$" -pi/2,\
     "0" 0,\
     "$\frac{\pi}{2}$" pi/2,\
     "$\pi$" pi)
\end{verbatim}
\currentspace

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{eg5}
  \end{center}
  \caption{A fancy example of the {\tt set xtics} command.}
  \label{eg5}
}

\paragraph{Going further:} You should now be able to make a variety of
plots for your \LaTeX\ document. We will present a final example
without explanation that showcases some of the capabilities of
GNUPLOT. You may find documentation for the various commands in the
GNUPLOT manual, though hopefully this example is somewhat
self-explanatory. This is shown in Figure~\ref{eg6}.

\singlespace
\begin{verbatim}
    set terminal latex
    set output "eg6.tex"
    set size 3.5/5, 3/3.
    set format y "$%g$"
    set format x "$%5.1f\mu$"
    set title "This is a title"
    set xlabel "This is the $x$ axis"
    set ylabel "This is\\a longer\\version\\ of\\the $y$\\ axis"
    set label "Data" at -5,-5 right
    set arrow from -5,-5 to -3.3,-6.7
    set key -4,8
    set xtic -10,5,10
    plot [-10:10] [-10:10] "eg3.dat" title "Data File"  with linespoints 1 7,\
       3*exp(-x*x)+1  title "$3e^{-x^{2}}+1$" with lines 4
\end{verbatim}
\currentspace

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{eg6}
  \end{center}
  \caption{An example of many features.}
  \label{eg6}
}

\paragraph{Line and point types:} For reference, we show all of the
line and point types available in Figure~\ref{linepoint}.

\boxfigure{htbp}{\fullboxwidth}{
  \begin{center}
    \input{linepoint}
  \end{center}
  \caption{All of the line and point types in the \LaTeX\ driver.}
  \label{linepoint}
}

\subsection{Summary --- Use with \LaTeX}
In summary, to use the \LaTeX\ facilities of GNUPLOT, the first
command to GNUPLOT should be
\begin{syntax}
    set terminal latex
\end{syntax}
and the output of GNUPLOT should be directed to a file, for example,
\begin{verbatim}
    set output "plot.tex"
\end{verbatim}
This may be anything you like but it should have a {\tt .tex} extension,
of course. Then the size of the plot should be given. For example, the
command 
\begin{verbatim}
    set size 1,2
\end{verbatim}
tells GNUPLOT to use a 5 inch wide by 6 inch high box for the plot.
The numbers given are {\em scale factors}, not the actual size.  The
default is 5 inches by 3 inches.  This is the size of the complete
plot, including all labels.

When finished, the file will contain all of the plots you have
specified (you probably only want one plot per file). This file can
then be used in a \LaTeX\ document, \eg,

\singlespace
\begin{verbatim}
    \begin {figure}
      \begin{center}
        \input{plot}
      \end{center}
    \end {figure}
\end{verbatim}
\currentspace
This puts the plot into a figure. 

You will also want to read about the following commands: {\tt set
title, set xlabel, set ylabel, set key, set label, set xtics, set
ytics}, and {\tt set clip}.  These are all described in the regular
GNUPLOT manual.

\section{Use with EEPIC}
\label{s:eepic}
EEPIC is a macro package extending the picture environment of \LaTeX.
If you have the EPIC or EEPIC macros, and your {\tt dvi} translator
supports the {\em tpic\/} \verb+\special+s, then you can save \LaTeX\
memory.  With EEPIC pictures, the {\tt plot.tex} file will be smaller,
\LaTeX\ will run much faster (and need much less memory), and the {\tt
dvi} file will be smaller. The quality of the output is about the
same. If you change the source, you can generate some more interesting
line styles.

To use EEPIC, set GNUPLOT's terminal type to {\tt eepic} instead of
{\tt latex}, and use GNUPLOT as before. The line styles will change.
Include the file {\tt plot.tex} in your document as before, along with
the document style options {\tt [epic,eepic]}.

\section{For Former Gnu\TeX\ Users}
\label{oldusers}

Former Gnu\TeX\ users may be pleased with many of the new features
(many inspired by your suggestions!), but will also find many changes.
GNUPLOT will {\em not\/} run all Gnu\TeX\ input files unchanged.
Several Gnu\TeX\ features were not included in GNUPLOT because they
were specific to the \LaTeX\ driver. I encourage you to use the newer
GNUPLOT.  A translator is available that attempts to translate your
old Gnu\TeX\ 1.6 input files into GNUPLOT 3.0 files. You can ftp it
from \verb+cs.duke.edu+ as \verb+dist/sources/gnuplot/gnut2p.tar.Z+.
This file also contains directions and a list of changes from Gnu\TeX\
to GNUPLOT.

\section{Contact}
Please contact me at \verb+David.Kotz@Dartmouth.edu+ with any comments you may
have on GNUPLOT's \LaTeX\ driver. For general GNUPLOT questions, send
mail to the GNUPLOT mailing list
(\verb+pixar!info-gnuplot@ucbvax.berkeley.edu+). 


\end{document}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/docs/titlepage.ms version [45a39eef88].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
.nr HM 3.2i
.TL
GNUPLOT
.br
An Interactive Plotting Program
.sp
.AU
Thomas Williams & Colin Kelley
.br
   Version 3.0 organized by: Gershon Elber
.br
   Version 3.0 major contributors (alphabetic order):
.br
  John Campbell
.br
  Gershon Elber
.br
  David Kotz
.br
  Ed Kubaitis
.br
  Russell Lang
.br
  Tom Tkacik
.br
  Alex Woo

.AI
   Mailing list for comments: info-gnuplot@ames.arc.nasa.gov
.br
   Mailing list for bug reports: bug-gnuplot@ames.arc.nasa.gov
\*(DY
.br






This manual is for GNUPLOT version 3.2
.AB no
.AE
.LP
.nr HM 1.2i
.ds CH
.ds LH GNUPLOT 3.2
.ds RH %
.\".nr PS 12
.\".nr VS 13
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































Deleted r34.1/plot/docs/titlepage.tex version [34a33e1447].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%
% $Id: titlepage.tex,v 3.26 1992/03/25 04:53:29 woo Exp woo $
%
\documentstyle[toc_entry]{article}
\setlength{\textwidth}{6.25in}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\topmargin}{-0.5in}
\setlength{\textheight}{9in}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\adjustarticle
\begin{document}

\pagestyle{empty}
   \rule{0in}{3in}
   \begin{center}
   {\huge\bf GNUPLOT}\\
   \vspace{3ex}
   {\Large An Interactive Plotting Program}\\
   \vspace{2ex}
   \large
   Thomas Williams \& Colin Kelley\\
   \vspace{2ex}
   Version 3.0 organized by: Gershon Elber \\
   Version 3.0 major contributors (alphabetic order):\\
  John Campbell\\
  Gershon Elber\\
  David Kotz\\
  Ed Kubaitis\\
  Russell Lang\\
  Tom Tkacik\\
  Alex Woo\\

   \vspace{3ex}
   Mailing list for comments: \verb+info-gnuplot@ames.arc.nasa.gov+\\
   Mailing list for bug reports: \verb+bug-gnuplot@ames.arc.nasa.gov+

   \vfill
   {\small This manual is for GNUPLOT version 3.2}

   \end{center}
\newpage

\tableofcontents
\newpage

\setcounter{page}{1}
\pagestyle{myheadings}
\markboth{GNUPLOT 3.2}{GNUPLOT 3.2}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































Deleted r34.1/plot/docs/toc_entry.sty version [7c09b8d6ef].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%
% $Id: toc_entry.sty,v 3.26 1992/03/25 04:53:29 woo Exp woo $
%
% TOC_ENTRY.STY of 13 Dec 90
% written by Stefan Timphus
%
% Will produce the right space for sectionnumbers in the tableofcontents
% Necessary for entries where the number for each kind of section
% is greater 10 (e.g. "12.14.18 Sectionname")
% When using the original definition the first letter of the sectionname
% overwrites the last number of the sectionnumber
%
% call adjustments with command \adjustSTYLENAME
%
 
\typeout{`toc_entry.sty' 1.0 of 13 Dec 90}
 
%
% HERE ARE THE ORIGINAL DEFINITIONS
%
 
% article.sty
%
%\def\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}
%\def\l@subsubsection{\@dottedtocline{3}{3.8em}{3.2em}}
%\def\l@paragraph{\@dottedtocline{4}{7.0em}{4.1em}}
%\def\l@subparagraph{\@dottedtocline{5}{10em}{5em}}
 
% report.sty and book.sty
%
%\def\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
%\def\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
%\def\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
%\def\l@paragraph{\@dottedtocline{4}{10em}{5em}}
%\def\l@subparagraph{\@dottedtocline{5}{12em}{6em}}
 
%
% MODIFICATIONS
%
 
\newlength{\twonum}
        \settowidth{\twonum}{99.99.}
\newlength{\threenum}
        \settowidth{\threenum}{99.99.99.}
\newlength{\fournum}
        \settowidth{\fournum}{99.99.99.99.}
\newlength{\fivenum}
        \settowidth{\fivenum}{99.99.99.99.99.}
\newlength{\sixnum}
        \settowidth{\sixnum}{99.99.99.99.99.99.}
 
\newcommand{\adjustarticle}
{\def\l@subsection{\@dottedtocline{2}{1.5em}{\twonum}}
\def\l@subsubsection{\@dottedtocline{3}{4.0em}{\threenum}}
\def\l@paragraph{\@dottedtocline{4}{7.8em}{\fournum}}
\def\l@subparagraph{\@dottedtocline{5}{10.4em}{\fivenum}}}
 
\newcommand{\adjustreport}
{\def\l@section{\@dottedtocline{1}{1.5em}{\twonum}}
\def\l@subsection{\@dottedtocline{2}{4.0em}{\threenum}}
\def\l@subsubsection{\@dottedtocline{3}{7.8em}{\fournum}}
\def\l@paragraph{\@dottedtocline{4}{10.4em}{\fivenum}}
\def\l@subparagraph{\@dottedtocline{5}{12.6em}{\sixnum}}}
 
\newcommand{\adjustbook}{\adjustreport}
 
% end of TOC_ENTRY.STY
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































Deleted r34.1/plot/eval.c version [77dec6fd04].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef lint
static char *RCSid = "$Id: eval.c,v 3.26 92/03/24 22:34:32 woo Exp Locker: woo $";
#endif

/* GNUPLOT - eval.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include "plot.h"

extern int c_token;
extern struct ft_entry ft[];
extern struct udvt_entry *first_udv;
extern struct udft_entry *first_udf;
extern struct at_type at;
extern struct lexical_unit token[];

struct value *integer();



struct udvt_entry *
add_udv(t_num)  /* find or add value and return pointer */
int t_num;
{
register struct udvt_entry **udv_ptr = &first_udv;

	/* check if it's already in the table... */

	while (*udv_ptr) {
		if (equals(t_num,(*udv_ptr)->udv_name))
			return(*udv_ptr);
		udv_ptr = &((*udv_ptr)->next_udv);
	}

	*udv_ptr = (struct udvt_entry *)
	  alloc((unsigned int)sizeof(struct udvt_entry), "value");
	(*udv_ptr)->next_udv = NULL;
	copy_str((*udv_ptr)->udv_name,t_num);
	(*udv_ptr)->udv_value.type = INT;	/* not necessary, but safe! */
	(*udv_ptr)->udv_undef = TRUE;
	return(*udv_ptr);
}


struct udft_entry *
add_udf(t_num)  /* find or add function and return pointer */
int t_num; /* index to token[] */
{
register struct udft_entry **udf_ptr = &first_udf;

	while (*udf_ptr) {
		if (equals(t_num,(*udf_ptr)->udf_name))
			return(*udf_ptr);
		udf_ptr = &((*udf_ptr)->next_udf);
	}
     *udf_ptr = (struct udft_entry *)
	  alloc((unsigned int)sizeof(struct udft_entry), "function");
	(*udf_ptr)->next_udf = (struct udft_entry *) NULL;
	(*udf_ptr)->definition = NULL;
	(*udf_ptr)->at = NULL;
	copy_str((*udf_ptr)->udf_name,t_num);
	(void) integer(&((*udf_ptr)->dummy_values[0]), 0);
	(void) integer(&((*udf_ptr)->dummy_values[1]), 0);
	return(*udf_ptr);
}


union argument *
add_action(sf_index)
enum operators sf_index;		/* index of p-code function */
{
	if (at.a_count >= MAX_AT_LEN)
		int_error("action table overflow",NO_CARET);
	at.actions[at.a_count].index = sf_index;
	return(&(at.actions[at.a_count++].arg));
}


int standard(t_num)  /* return standard function index or 0 */
{
register int i;
	for (i = (int)SF_START; ft[i].f_name != NULL; i++) {
		if (equals(t_num,ft[i].f_name))
			return(i);
	}
	return(0);
}

 

execute_at(at_ptr)
struct at_type *at_ptr;
{
register int i,index,count,offset;

	count = at_ptr->a_count;
	for (i = 0; i < count;) {
		index = (int)at_ptr->actions[i].index;
		offset = (*ft[index].func)(&(at_ptr->actions[i].arg));
		if (is_jump(index))
			i += offset;
		else
			i++;
	}
}

/*

 'ft' is a table containing C functions within this program. 

 An 'action_table' contains pointers to these functions and arguments to be
 passed to them. 

 at_ptr is a pointer to the action table which must be executed (evaluated)

 so the iterated line exectues the function indexed by the at_ptr and 
 passes the address of the argument which is pointed to by the arg_ptr 

*/
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































Deleted r34.1/plot/gnuplot version [4167b202e2].

cannot compute difference between binary files

Deleted r34.1/plot/gnuplot.el version [8720c477a1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
; 
; gnu-plot.el - Definitions of GNU-PLOT mode for emacs editor.
; 
; Author:	Gershon Elber
; 		Computer Science Dept.
; 		University of Utah
; Date:	Tue May 14 1991
; Copyright (c) 1991, 1992, Gershon Elber
;
; This file defines an environment to run edit and execute GNU-PLOT programs.
; Such a program should have a '.gp' extension in order it to be in
; gnu-plot-mode major mode. Two new functions are provided to communicate
; between the editted file and the plotting program:
; 1. send-line-to-gnu-plot - sends a single line to the plotting program for
;    execution. The line sent is the line the cursor is on,
;    Bounded to Meta-E by default.
; 2. send-region-to-gnu-plot - sends the region from the current mark
;    (mark-marker) to current position (point-marker) to the plotting program.
;    This function is convenient for sending a large block of commands.
;    Bounded to Meta-R by default.
; Both functions checks for existance of a buffer named gnu-plot-program
; and a process named "gnu-plot" hooked to it, and will restart a new process
; or buffer if none exists. The program to execute as process "gnu-plot" is
; defined by the gnu-plot-program constant below.
;

(defvar gnu-plot-program "gnuplot"
  "*The executable to run for gnu-plot-program buffer.")

(defvar gnu-plot-echo-program t
  "*Control echo of executed commands to gnu-plot-program buffer.")

(defvar gnu-plot-mode-map nil "")
(if gnu-plot-mode-map
    ()
  (setq gnu-plot-mode-map (make-sparse-keymap))
  (define-key gnu-plot-mode-map "\M-e" 'send-line-to-gnu-plot)
  (define-key gnu-plot-mode-map "\M-r" 'send-region-to-gnu-plot))

;;;
;;; Define the gnu-plot-mode
;;;
(defun gnu-plot-mode ()
  "Major mode for editing and executing GNU-PLOT files.

see send-line-to-gnu-plot and send-region-to-gnu-plot for more."
  (interactive)
  (use-local-map gnu-plot-mode-map)
  (setq major-mode 'gnu-plot-mode)
  (setq mode-name "Gnu-Plot")
  (run-hooks 'gnu-plot-mode-hook))

;;;
;;; Define send-line-to-gnu-plot - send from current cursor position to next
;;; semicolin detected.
;;;
(defun send-line-to-gnu-plot ()
  "Sends one line of code from current buffer to the GNU-PLOT program.

Use to execute a line in the GNU-PLOT plotting program. The line sent is
the line the cursor (point) is on.

The GNU-PLOT plotting program buffer name is gnu-plot-program and the 
process name is 'gnu-plot'. If none exists, a new one is created.

The name of the gnu-plot program program to execute is stored in
gnu-plot-program variable and may be changed."
  (interactive)
  (if (equal major-mode 'gnu-plot-mode)
    (progn
      (make-gnu-plot-buffer)        ; In case we should start a new one.
      (beginning-of-line)
      (let ((start-mark (point-marker)))
	(next-line 1)
	(let* ((crnt-buffer (buffer-name))
	       (end-mark (point-marker))
	       (string-copy (buffer-substring start-mark end-mark)))
	  (switch-to-buffer-other-window (get-buffer "gnu-plot-program"))
	  (end-of-buffer)
	  (if gnu-plot-echo-program
	    (insert string-copy))
	  (set-marker (process-mark (get-process "gnu-plot")) (point-marker))
	  (if (not (pos-visible-in-window-p))
	    (recenter 3))
	  (switch-to-buffer-other-window (get-buffer crnt-buffer))
	  (process-send-region "gnu-plot" start-mark end-mark)
	  (goto-char end-mark))))
    (message "Should be invoked in gnu-plot-mode only.")))

;;;
;;; Define send-region-to-gnu-plot - send from current cursor position to
;;; current marker.
;;;
(defun send-region-to-gnu-plot ()
  "Sends a region of code from current buffer to the GNU-PLOT program.

When this function is invoked on an GNU-PLOT file it send the region
from current point to current mark to the gnu-plot plotting program.

The GNU-PLOT plotting program buffer name is gnu-plot-program and the
process name is 'gnu-plot'. If none exists, a new one is created.

The name of the gnu-plot program program to execute is stored in
gnu-plot-program variable and may be changed."
  (interactive)
  (if (equal major-mode 'gnu-plot-mode)
    (progn
      (make-gnu-plot-buffer)     ; In case we should start a new one.
      (copy-region-as-kill (mark-marker) (point-marker))
      (let ((crnt-buffer (buffer-name)))
	(switch-to-buffer-other-window (get-buffer "gnu-plot-program"))
	(end-of-buffer)
	(if gnu-plot-echo-program
	  (yank))
	(set-marker (process-mark (get-process "gnu-plot")) (point-marker))
	(if (not (pos-visible-in-window-p))
	  (recenter 3))
	(switch-to-buffer-other-window (get-buffer crnt-buffer))
	(process-send-region "gnu-plot" (mark-marker) (point-marker))))
    (message "Should be invoked in gnu-plot-mode only.")))

;;;
;;; Switch to "gnu-plot-program" buffer if exists. If not, creates one and
;;; execute the program defined by gnu-plot-program.
;;;
(defun make-gnu-plot-buffer ()
  "Switch to gnu-plot-program buffer or create one if none exists"
  (interactive)
  (if (get-buffer "gnu-plot-program")
    (if (not (get-process "gnu-plot"))
      (progn
	(message "Starting GNU-PLOT plotting program...")
	(start-process "gnu-plot" "gnu-plot-program" gnu-plot-program)
	(process-send-string "gnu-plot" "\n")
	(message "Done.")))
    (progn
      (message "Starting GNU-PLOT plotting program...")
      (start-process "gnu-plot" "gnu-plot-program" gnu-plot-program)
      (process-send-string "gnu-plot" "\n")
      (message "Done."))))

;;;
;;; Autoload gnu-plot-mode on any file with gp extension. 
;;;
(setq auto-mode-alist (append '(("\\.gp$" . gnu-plot-mode))
			      auto-mode-alist))
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































Deleted r34.1/plot/gnuplot_x11 version [dfa1c979ac].

cannot compute difference between binary files

Deleted r34.1/plot/gnuplot_x11.c version [6ca370660e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
#ifndef lint
static char *RCSid = "$Id: gnuplot_x11.c,v 3.26 92/03/24 22:35:52 woo Exp Locker: woo $";
#endif

/*-----------------------------------------------------------------------------
 *   gnuplot_x11 - X11 outboard terminal driver for gnuplot 3
 *
 *   Requires installation of companion inboard x11 driver in gnuplot/term.c
 *
 *   Acknowledgements: 
 *      Chris Peterson (MIT)
 *      Dana Chee (Bellcore) 
 *      Arthur Smith (Cornell)
 *      Hendri Hondorp (University of Twente, The Netherlands)
 *      Bill Kucharski (Solbourne)
 *      Charlie Kline (University of Illinois)
 *      O'Reilly & Associates: X Window System - Volumes 1 & 2
 *
 *   This code is provided as is and with no warranties of any kind.
 *       
 *   Ed Kubaitis (ejk@uiuc.edu)
 *   Computing & Communications Services Office 
 *   University of Illinois, Urbana
 *---------------------------------------------------------------------------*/

#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
 
#include <stdio.h>
#include <signal.h>

#ifndef FD_SET
#ifndef OLD_SELECT
#include <sys/select.h>
#else   /* OLD_SELECT */
#define FD_SET(n, p)    ((p)->fds_bits[0] |= (1 << ((n) % 32)))
#define FD_CLR(n, p)    ((p)->fds_bits[0] &= ~(1 << ((n) % 32)))
#define FD_ISSET(n, p)  ((p)->fds_bits[0] & (1 << ((n) % 32)))
#define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
#endif  /* OLD_SELECT */
#endif  /* FD_SET */

#include <errno.h>
extern int errno;

#define FallbackFont "fixed"
#define Ncolors 13
unsigned long colors[Ncolors];

char dashes[10][5] = { {0}, {1,6,0}, 
   {0}, {4,2,0}, {1,3,0}, {4,4,0}, {1,5,0}, {4,4,4,1,0}, {4,2,0}, {1,3,0}
   };

Display *dpy; int scr; Window win, root;
Visual *vis; GC gc = (GC)0; Pixmap pixmap; XFontStruct *font;
unsigned int W = 640, H = 450; int D, gX = 100, gY = 100;

Bool Mono = 0, Gray = 0, Rv = 0, Clear = 0;
char Name[64] = "gnuplot";
char Class[64] = "Gnuplot";

int cx=0, cy=0, vchar, nc = 0, ncalloc = 0;
double xscale, yscale;
#define X(x) (int) (x * xscale)
#define Y(y) (int) ((4095-y) * yscale)
enum JUSTIFY { LEFT, CENTRE, RIGHT } jmode;

#define Nbuf 1024
char buf[Nbuf], **commands = (char **)0;

FILE *X11_ipc = stdin;
char X11_ipcpath[32];


/*-----------------------------------------------------------------------------
 *   main program 
 *---------------------------------------------------------------------------*/

main(argc, argv) int argc; char *argv[]; {

   preset(argc, argv);
   mainloop();
   exit(0);

   }

/*-----------------------------------------------------------------------------
 *   mainloop - process X events and input from gnuplot
 *
 *   On systems with a fully implemented select(), select is used (without
 *   timeout) to sense both input from the X server network connection and
 *   pipe input from gnuplot. On platforms with an incomplete or faulty 
 *   select(), select (with timeout) is used for the server, and a temporary 
 *   file rather than a pipe is used for gnuplot input.
 *---------------------------------------------------------------------------*/

mainloop() {
   int nf, nfds, cn = ConnectionNumber(dpy), in = fileno(X11_ipc);
   struct timeval timeout, *timer = (struct timeval *)0;
   fd_set rset, tset;
   unsigned long all = 0xffffffff;
   XEvent xe;

   FD_ZERO(&rset);
   FD_SET(cn, &rset);

#ifndef CRIPPLED_SELECT
   FD_SET(in, &rset);
   nfds = (cn > in) ? cn + 1 : in + 1;
#else  /* CRIPPLED_SELECT */
   timeout.tv_sec = 1;
   timeout.tv_usec = 0;
   timer = &timeout;
   sprintf(X11_ipcpath, "/tmp/Gnuplot_%d", getppid());
   nfds = cn + 1;
#endif /* CRIPPLED_SELECT */

   while(1) {
      tset = rset;
      nf = select(nfds, &tset, (fd_set *)0, (fd_set *)0, timer);
      if (nf < 0) {
	 if (errno == EINTR) continue;
	 fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno);
	 exit(1);
	 }
      nf > 0 && XNoOp(dpy);
      if (FD_ISSET(cn, &tset)) {
	 while (XCheckMaskEvent(dpy, all, &xe)) {
	    (xe.type == ConfigureNotify)  && resize(&xe); 
	    }
	 }
#ifndef CRIPPLED_SELECT
      FD_ISSET(in, &tset) && accept();
#else  /* CRIPPLED_SELECT */
      if ((X11_ipc = fopen(X11_ipcpath, "r"))) {
	 unlink(X11_ipcpath);
	 accept();
	 fclose(X11_ipc);
	 }
#endif /* CRIPPLED_SELECT */
      }
   }

/*-----------------------------------------------------------------------------
 *   accept - accept & record new plot from gnuplot inboard X11 driver
 *---------------------------------------------------------------------------*/

accept() {

   while (fgets(buf, Nbuf, X11_ipc)) {
     if (*buf == 'G') {                           /* enter graphics mode */
	 if (commands) {
	    int n; for (n=0; n<nc; n++) free(commands[n]);
	    free(commands);
	    }
	 commands = (char **)0; nc = ncalloc = 0;
         }
      else if (*buf == 'E') { display(); break; } /* leave graphics mode */
      else if (*buf == 'R') { exit(0); }          /* leave X11/x11 mode  */
      else {                                      /* record command      */
	 char *p;
	 if (nc >= ncalloc) {
	    ncalloc = ncalloc*2 + 1;
	    commands = (commands)
	       ? (char **)realloc(commands, ncalloc * sizeof(char *))
	       : (char **)malloc(sizeof(char *));
	    }
	 p = (char *)malloc((unsigned)strlen(buf)+1);
	 if (!commands || !p) {
	    fprintf(stderr, "gnuplot: can't get memory. X11 aborted.\n");
	    exit(1);
	    }
	 commands[nc++] = strcpy(p, buf);
	 }
      }
   if (feof(X11_ipc) || ferror(X11_ipc)) exit(1);
   }

/*-----------------------------------------------------------------------------
 *   display - display last plot from gnuplot inboard X11 driver
 *---------------------------------------------------------------------------*/

display() {
   int n, x, y, sw, sl, lt, width, type;
   char *buf, *str;

   if (!nc) return;

   /* set scaling factor between internal driver & window geometry */
   xscale = (double)W / 4096.;  yscale = (double)H / 4096.;  

   /* create new pixmap & GC */
   if (gc) { XFreeGC(dpy, gc); XFreePixmap(dpy, pixmap); }
   pixmap = XCreatePixmap(dpy, root, W, H, D);
   gc = XCreateGC(dpy, pixmap, 0, (XGCValues *)0);
   XSetFont(dpy, gc, font->fid);

   /* set pixmap background */
   XSetForeground(dpy, gc, colors[0]);
   XFillRectangle(dpy, pixmap, gc, 0, 0, W, H);
   XSetBackground(dpy, gc, colors[0]);

   /* set new pixmap as window background */
   XSetWindowBackgroundPixmap(dpy, win, pixmap);

   /* momentarily clear the window first if requested */
   if (Clear) {
      XClearWindow(dpy, win);
      XFlush(dpy);
      }

   /* loop over accumulated commands from inboard driver */
   for (n=0; n<nc; n++) {
      buf = commands[n];

      /*   X11_vector(x,y) - draw vector  */
      if (*buf == 'V') { 
	 sscanf(buf, "V%4d%4d", &x, &y);  
	 XDrawLine(dpy, pixmap, gc, X(cx), Y(cy), X(x), Y(y));
	 cx = x; cy = y;
	 }

      /*   X11_move(x,y) - move  */
      else if (*buf == 'M') 
	 sscanf(buf, "M%4d%4d", &cx, &cy);  

      /*   X11_put_text(x,y,str) - draw text   */
      else if (*buf == 'T') { 
	 sscanf(buf, "T%4d%4d", &x, &y);  
	 str = buf + 9; sl = strlen(str) - 1;
	 sw = XTextWidth(font, str, sl);
	 switch(jmode) {
	    case LEFT:   sw = 0;     break;
	    case CENTRE: sw = -sw/2; break;
	    case RIGHT:  sw = -sw;   break;
	    }
	 XSetForeground(dpy, gc, colors[2]);
	 XDrawString(dpy, pixmap, gc, X(x)+sw, Y(y)+vchar/3, str, sl);
	 XSetForeground(dpy, gc, colors[lt+3]);
	 }

      /*   X11_justify_text(mode) - set text justification mode  */
      else if (*buf == 'J') 
	 sscanf(buf, "J%4d", &jmode);

      /*   X11_linetype(type) - set line type  */
      else if (*buf == 'L') { 
	 sscanf(buf, "L%4d", &lt);
	 lt = (lt%8)+2;
	 width = (lt == 0) ? 2 : 0;
	 if (!Mono) {
	    if (lt != 1) 
	       type = LineSolid;
	    else {
	       type = LineOnOffDash;
	       XSetDashes(dpy, gc, 0, dashes[lt], strlen(dashes[lt]));
	       }
	    XSetForeground(dpy, gc, colors[lt+3]);
	    }
	 else {
	    type  = (lt == 0 || lt == 2) ? LineSolid : LineOnOffDash;
	    if (dashes[lt][0])
	       XSetDashes(dpy, gc, 0, dashes[lt], strlen(dashes[lt]));
	    }
	 XSetLineAttributes( dpy,gc, width, type, CapButt, JoinBevel);
	 }
      }

   /* trigger exposure of background pixmap */
   XClearWindow(dpy,win);
   XFlush(dpy);
   }

/*-----------------------------------------------------------------------------
 *   resize - rescale last plot if window resized
 *---------------------------------------------------------------------------*/

Bool init = True;

resize(xce) XConfigureEvent *xce; {
   if (!init || xce->width != W || xce->height != H) {
      W = xce->width; H = xce->height;
      display();
      init = True;
      }
   }


/*-----------------------------------------------------------------------------
 *   preset - determine options, open display, create window
 *---------------------------------------------------------------------------*/

#define On(v) ( !strcmp(v,"on") || !strcmp(v,"true") || \
		!strcmp(v,"On") || !strcmp(v,"True") )

#define AppDefDir "/usr/lib/X11/app-defaults"
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif

static XrmDatabase dbCmd, dbApp, dbDef, dbEnv, db = (XrmDatabase)0;

char *pr_GetR(), *getenv(), *type[20];
XrmValue value;

#define Nopt 25
static XrmOptionDescRec options[] = {
   {"-mono",             ".mono",             XrmoptionNoArg,   "on" },
   {"-gray",             ".gray",             XrmoptionNoArg,   "on" },
   {"-clear",            ".clear",            XrmoptionNoArg,   "on" },
   {"-display",          ".display",          XrmoptionSepArg,  NULL },
   {"-name",             ".name",             XrmoptionSepArg,  NULL },
   {"-geometry",         "*geometry",         XrmoptionSepArg,  NULL },
   {"-background",       "*background",       XrmoptionSepArg,  NULL },
   {"-bg",               "*background",       XrmoptionSepArg,  NULL },
   {"-foreground",       "*foreground",       XrmoptionSepArg,  NULL },
   {"-fg",               "*foreground",       XrmoptionSepArg,  NULL },
   {"-bordercolor",      "*bordercolor",      XrmoptionSepArg,  NULL },
   {"-bd",               "*bordercolor",      XrmoptionSepArg,  NULL },
   {"-borderwidth",      ".borderwidth",      XrmoptionSepArg,  NULL },
   {"-bw",               ".borderwidth",      XrmoptionSepArg,  NULL },
   {"-font",             "*font",             XrmoptionSepArg,  NULL },
   {"-fn",               "*font",             XrmoptionSepArg,  NULL },
   {"-reverse",          "*reverseVideo",     XrmoptionNoArg,   "on" },
   {"-rv",               "*reverseVideo",     XrmoptionNoArg,   "on" },
   {"+rv",               "*reverseVideo",     XrmoptionNoArg,   "off"},
   {"-iconic",           "*iconic",           XrmoptionNoArg,   "on" },
   {"-synchronous",      "*synchronous",      XrmoptionNoArg,   "on" },
   {"-xnllanguage",      "*xnllanguage",      XrmoptionSepArg,  NULL },
   {"-selectionTimeout", "*selectionTimeout", XrmoptionSepArg,  NULL },
   {"-title",            ".title",            XrmoptionSepArg,  NULL },
   {"-xrm",              NULL,                XrmoptionResArg,  NULL },
   };

preset(argc, argv) int argc; char *argv[]; {
   int Argc = argc; char **Argv = argv;

   char *display = getenv("DISPLAY"),  *home = getenv("HOME");
   char *server_defaults, *env, buf[256];

   /*---set to ignore ^C and ^Z----------------------------------------------*/

   signal(SIGINT, SIG_IGN);
#ifdef SIGTSTP
   signal(SIGTSTP, SIG_IGN);
#endif

   /*---prescan arguments for "-name"----------------------------------------*/

   while(++Argv, --Argc > 0) {
      if (!strcmp(*Argv, "-name") && Argc > 1) {
	 strncpy(Name, Argv[1], 64);
	 strncpy(Class, Argv[1], 64);
	 if (Class[0] >= 'a' && Class[0] <= 'z') Class[0] -= 0x20;
	 }
      }
   Argc = argc; Argv = argv;

   /*---parse command line---------------------------------------------------*/

   XrmInitialize();
   XrmParseCommand(&dbCmd, options, Nopt, Name, &Argc, Argv);
   if (Argc > 1) {
      fprintf(stderr, "\ngnuplot: bad option: %s\n", Argv[1]);
      fprintf(stderr, "gnuplot: X11 aborted.\n");
      exit(1);
      }
   if (pr_GetR(dbCmd, ".display")) display = value.addr;

   /*---open display---------------------------------------------------------*/

   dpy = XOpenDisplay(display); 
   if (!dpy) {
      fprintf(stderr, "\ngnuplot: unable to open display '%s'\n", display);
      fprintf(stderr, "gnuplot: X11 aborted.\n");
      exit(1);
      }
   scr = DefaultScreen(dpy);
   vis = DefaultVisual(dpy,scr);
   D = DefaultDepth(dpy,scr);
   root = DefaultRootWindow(dpy);
   server_defaults = XResourceManagerString(dpy);

   /*---get application defaults--(subset of Xt processing)------------------*/

   sprintf(buf, "%s/%s", AppDefDir, "Gnuplot");
   dbApp = XrmGetFileDatabase(buf);
   XrmMergeDatabases(dbApp, &db);

   /*---get server or ~/.Xdefaults-------------------------------------------*/

   if (server_defaults)
      dbDef = XrmGetStringDatabase(server_defaults);
   else {
      sprintf(buf, "%s/.Xdefaults", home);
      dbDef = XrmGetFileDatabase(buf);
      }
   XrmMergeDatabases(dbDef, &db);

   /*---get XENVIRONMENT or  ~/.Xdefaults-hostname---------------------------*/

   if (env = getenv("XENVIRONMENT")) 
      dbEnv = XrmGetFileDatabase(env);
   else {
      char *p, host[MAXHOSTNAMELEN];
      if (gethostname(host, MAXHOSTNAMELEN) < 0) {
	 fprintf(stderr, "gnuplot: gethostname failed. X11 aborted.\n");
	 exit(1);
	 }
      if (p = index(host, '.')) *p = '\0';
      sprintf(buf, "%s/.Xdefaults-%s", home, host);
      dbEnv = XrmGetFileDatabase(buf);
      }
   XrmMergeDatabases(dbEnv, &db);

   /*---merge command line options-------------------------------------------*/

   XrmMergeDatabases(dbCmd, &db);

   /*---determine geometry, font and colors----------------------------------*/

   pr_geometry();
   pr_font();
   pr_color();

   /*---create window--------------------------------------------------------*/

   pr_window();

   } 

/*-----------------------------------------------------------------------------
 *   pr_GetR - get resource from database using "-name" option (if any)
 *---------------------------------------------------------------------------*/

char *
pr_GetR(db, resource) XrmDatabase db; char *resource; {
   char name[128], class[128], *rc;

   strcpy(name, Name); strcat(name, resource);
   strcpy(class, Class); strcat(class, resource);
   rc = XrmGetResource(db, name, class, type, &value)
      ? (char *)value.addr 
      : (char *)0;
   return(rc);
   }

/*-----------------------------------------------------------------------------
 *   pr_color - determine color values
 *---------------------------------------------------------------------------*/

char color_keys[Ncolors][30] =   { 
   "background", "bordercolor", "text", "border", "axis", 
   "line1", "line2", "line3",  "line4", 
   "line5", "line6", "line7",  "line8" 
   };
char color_values[Ncolors][30] = { 
   "white", "black",  "black",  "black",  "black", 
   "red",   "green",  "blue",   "magenta", 
   "cyan",  "sienna", "orange", "coral" 
   };
char gray_values[Ncolors][30] = { 
   "black",   "white",  "white",  "gray50", "gray50",
   "gray100", "gray60", "gray80", "gray40", 
   "gray90",  "gray50", "gray70", "gray30" 
   };

pr_color() {
   unsigned long black = BlackPixel(dpy, scr), white = WhitePixel(dpy,scr);
   char option[20], *v, *type = (Gray) ? "Gray" : "Color";
   XColor used, exact;
   Colormap cmap;
   int n;

   pr_GetR(db, ".mono")         && On(value.addr) && Mono++;
   pr_GetR(db, ".gray")         && On(value.addr) && Gray++;
   pr_GetR(db, ".reverseVideo") && On(value.addr) && Rv++;

   if (!Gray && (vis->class == GrayScale || vis->class == StaticGray)) Mono++;

   if (!Mono) {
      cmap = DefaultColormap(dpy, scr);
      for (n=0; n<Ncolors; n++) {
	 strcpy(option, ".");
	 strcat(option, color_keys[n]);
	 (n > 1) && strcat(option, type);
	 v = pr_GetR(db, option) 
	     ? value.addr
	     : ((Gray) ? gray_values[n] : color_values[n]);
	 if (XAllocNamedColor(dpy, cmap, v, &used, &exact))
	    colors[n] = used.pixel;
	 else {
	    fprintf(stderr, "\ngnuplot: can't allocate %s:%s\n", option, v);
	    fprintf(stderr, "gnuplot: reverting to monochrome\n");
	    Mono++; break;
	    }
	 }
      }
   if (Mono) {
      colors[0] = (Rv) ? black : white ;
      for (n=1; n<Ncolors; n++)  colors[n] = (Rv) ? white : black;
      }
   }

/*-----------------------------------------------------------------------------
 *   pr_font - determine font          
 *---------------------------------------------------------------------------*/

pr_font() {
   char *fontname = pr_GetR(db, ".font");

   if (!fontname) fontname = FallbackFont;
   font = XLoadQueryFont(dpy, fontname);
   if (!font) {
      fprintf(stderr, "\ngnuplot: can't load font '%s'\n", fontname);
      fprintf(stderr, "gnuplot: using font '%s' instead.\n", FallbackFont);
      font = XLoadQueryFont(dpy, FallbackFont);
      if (!font) {
	 fprintf(stderr, "gnuplot: can't load font '%s'\n", FallbackFont);
	 fprintf(stderr, "gnuplot: no useable font - X11 aborted.\n");
         exit(1);
	 }
      }
   vchar = font->ascent + font->descent;
   }

/*-----------------------------------------------------------------------------
 *   pr_geometry - determine window geometry      
 *---------------------------------------------------------------------------*/

pr_geometry() {
   char *geometry = pr_GetR(db, ".geometry");
   int x, y, flags;
   unsigned int w, h; 

   if (geometry) {
      flags = XParseGeometry(geometry, &x, &y, &w, &h);

      if (flags & WidthValue)  W = w;
      if (flags & HeightValue) H = h;
      if (flags & XValue) {
	 if (flags & XNegative) x += DisplayWidth(dpy,scr);
	 gX = x;
	 }
      if (flags & YValue) {
	 if (flags & YNegative) y += DisplayHeight(dpy,scr);
	 gY = y;
	 }
      }
   }

/*-----------------------------------------------------------------------------
 *   pr_window - create window 
 *---------------------------------------------------------------------------*/

pr_window() {
   char *title =  pr_GetR(db, ".title");
   XSizeHints hints;

   win = XCreateSimpleWindow(dpy, root, gX, gY, W, H, 2, colors[1], colors[0]);

   pr_GetR(db, ".clear") && On(value.addr) && Clear++;

   hints.flags = PPosition;
   hints.x = gX; hints.y = gY;
   XSetNormalHints(dpy, win, &hints);

   if (pr_GetR(db, ".iconic") && On(value.addr)) {
      XWMHints wmh;

      wmh.flags = StateHint ;
      wmh.initial_state = IconicState;
      XSetWMHints(dpy, win, &wmh);
      } 

   XStoreName(dpy, win, ((title) ? title : Class));

   XSelectInput(dpy, win, StructureNotifyMask);
   XMapWindow(dpy, win);
   
   }
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/graph3d.c version [1daa5da67e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
#ifndef lint
static char *RCSid = "$Id: graph3d.c,v 3.26 92/03/24 22:34:27 woo Exp Locker: woo $";
#endif

/* GNUPLOT - graph3d.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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:
 *       Gershon Elber and many others.
 *
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <time.h>
#include "plot.h"
#include "setshow.h"

extern char *strcpy(),*strncpy(),*strcat(),*ctime(),*tdate;
#ifdef AMIGA_AC_5
extern time_t dated;
#else
#ifdef VMS
extern time_t dated,time();
#else
extern long dated,time();
#endif
#endif

/*
 * hidden_line_type_above, hidden_line_type_below - controls type of lines
 *   for above and below parts of the surface.
 * hidden_no_update - if TRUE lines will be hidden line removed but they
 *   are not assumed to be part of the surface (i.e. grid) and therefore
 *   do not influence the hidings.
 * hidden_max_index - length of hidden_low_bound and hidden_high_bound vecs.
 * hidden_first_row - TRUE if we are now drawing the first row of the surface.
 * hidden_active - TRUE if hidden lines are to be removed.
 * hidden_low_bound, hidden_high_bound - two vectors of size hidden_max_index
 *   that hold the above and below floating horisons.
 */
static int hidden_line_type_above, hidden_line_type_below, hidden_no_update;
static int hidden_max_index, hidden_first_row, hidden_active = FALSE;
static int *hidden_low_bound, *hidden_high_bound;
#define HIDDEN_BOUND(x)		(x < 0 ? 0 : x >= hidden_max_index ? \
				             hidden_max_index - 1 : x)
#define HIDDEN_LOW_BOUND(x) (hidden_low_bound[HIDDEN_BOUND(x)])
#define HIDDEN_HIGH_BOUND(x) (hidden_high_bound[HIDDEN_BOUND(x)])
#define SET_HIDDEN_BOUND(vec, x, y) (vec[HIDDEN_BOUND(x)] = y)

static plot3d_impulses();
static plot3d_lines();
static plot3d_points();
static plot3d_dots();
static cntr3d_impulses();
static cntr3d_lines();
static cntr3d_points();
static cntr3d_dots();
static update_extrema_pts();
static draw_parametric_grid();
static draw_non_param_grid();
static draw_bottom_grid();
static draw_3dxtics();
static draw_3dytics();
static draw_3dztics();
static draw_series_3dxtics();
static draw_series_3dytics();
static draw_series_3dztics();
static draw_set_3dxtics();
static draw_set_3dytics();
static draw_set_3dztics();
static xtick();
static ytick();
static ztick();
static setlinestyle();

#ifndef max		/* Lattice C has max() in math.h, but shouldn't! */
#define max(a,b) ((a > b) ? a : b)
#endif

#ifndef min
#define min(a,b) ((a < b) ? a : b)
#endif

#define inrange(z,min,max) ((min<max) ? ((z>=min)&&(z<=max)) : ((z>=max)&&(z<=min)) )

#define apx_eq(x,y) (fabs(x-y) < 0.001)
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define sqr(x) ((x) * (x))

/* Define the boundary of the plot
 * These are computed at each call to do_plot, and are constant over
 * the period of one do_plot. They actually only change when the term
 * type changes and when the 'set size' factors change. 
 */
static int xleft, xright, ybot, ytop, xmiddle, ymiddle, xscaler, yscaler;

/* Boundary and scale factors, in user coordinates */
/* x_min3d, x_max3d, y_min3d, y_max3d, z_min3d, z_max3d are local to this
 * file and are not the same as variables of the same names in other files
 */
static double x_min3d, x_max3d, y_min3d, y_max3d, z_min3d, z_max3d;
static double xscale3d, yscale3d, zscale3d;
static double real_z_min3d, real_z_max3d;
static double min_sy_ox,min_sy_oy; /* obj. coords. for xy tics placement. */
static double min_sx_ox,min_sx_oy; /* obj. coords. for z tics placement. */

typedef double transform_matrix[4][4];
static transform_matrix trans_mat;

/* (DFK) Watch for cancellation error near zero on axes labels */
#define SIGNIF (0.01)		/* less than one hundredth of a tic mark */
#define CheckZero(x,tic) (fabs(x) < ((tic) * SIGNIF) ? 0.0 : (x))
#define NearlyEqual(x,y,tic) (fabs((x)-(y)) < ((tic) * SIGNIF))

/* And the functions to map from user to terminal coordinates */
#define map_x(x) (int)(x+0.5) /* maps floating point x to screen */ 
#define map_y(y) (int)(y+0.5)	/* same for y */

/* And the functions to map from user 3D space into normalized -1..1 */
#define map_x3d(x) ((x-x_min3d)*xscale3d-1.0)
#define map_y3d(y) ((y-y_min3d)*yscale3d-1.0)
#define map_z3d(z) ((z-z_min3d)*zscale3d-1.0)

static mat_unit(mat)
transform_matrix mat;
{
    int i, j;

    for (i = 0; i < 4; i++) for (j = 0; j < 4; j++)
	if (i == j)
	    mat[i][j] = 1.0;
	else
	    mat[i][j] = 0.0;
}

static mat_trans(tx, ty, tz, mat)
double tx, ty, tz;
transform_matrix mat;
{
     mat_unit(mat);                                 /* Make it unit matrix. */
     mat[3][0] = tx;
     mat[3][1] = ty;
     mat[3][2] = tz;
}

static mat_scale(sx, sy, sz, mat)
double sx, sy, sz;
transform_matrix mat;
{
     mat_unit(mat);                                 /* Make it unit matrix. */
     mat[0][0] = sx;
     mat[1][1] = sy;
     mat[2][2] = sz;
}

static mat_rot_x(teta, mat)
double teta;
transform_matrix mat;
{
    double cos_teta, sin_teta;

    teta *= Pi / 180.0;
    cos_teta = cos(teta);
    sin_teta = sin(teta);

    mat_unit(mat);                                  /* Make it unit matrix. */
    mat[1][1] = cos_teta;
    mat[1][2] = -sin_teta;
    mat[2][1] = sin_teta;
    mat[2][2] = cos_teta;
}

static mat_rot_y(teta, mat)
double teta;
transform_matrix mat;
{
    double cos_teta, sin_teta;

    teta *= Pi / 180.0;
    cos_teta = cos(teta);
    sin_teta = sin(teta);

    mat_unit(mat);                                  /* Make it unit matrix. */
    mat[0][0] = cos_teta;
    mat[0][2] = -sin_teta;
    mat[2][0] = sin_teta;
    mat[2][2] = cos_teta;
}

static mat_rot_z(teta, mat)
double teta;
transform_matrix mat;
{
    double cos_teta, sin_teta;

    teta *= Pi / 180.0;
    cos_teta = cos(teta);
    sin_teta = sin(teta);

    mat_unit(mat);                                  /* Make it unit matrix. */
    mat[0][0] = cos_teta;
    mat[0][1] = -sin_teta;
    mat[1][0] = sin_teta;
    mat[1][1] = cos_teta;
}

/* Multiply two transform_matrix. Result can be one of two operands. */
void mat_mult(mat_res, mat1, mat2)
transform_matrix mat_res, mat1, mat2;
{
    int i, j, k;
    transform_matrix mat_res_temp;

    for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
        mat_res_temp[i][j] = 0;
        for (k = 0; k < 4; k++) mat_res_temp[i][j] += mat1[i][k] * mat2[k][j];
    }
    for (i = 0; i < 4; i++) for (j = 0; j < 4; j++)
	mat_res[i][j] = mat_res_temp[i][j];
}

/* And the functions to map from user 3D space to terminal coordinates */
static int map3d_xy(x, y, z, xt, yt)
double x, y, z;
int *xt, *yt;
{
    int i,j;
    double v[4], res[4],		     /* Homogeneous coords. vectors. */
	w = trans_mat[3][3];

    v[0] = map_x3d(x); /* Normalize object space to -1..1 */
    v[1] = map_y3d(y);
    v[2] = map_z3d(z);
    v[3] = 1.0;

    for (i = 0; i < 2; i++) {	             /* Dont use the third axes (z). */
        res[i] = trans_mat[3][i];     /* Initiate it with the weight factor. */
        for (j = 0; j < 3; j++) res[i] += v[j] * trans_mat[j][i];
    }

    for (i = 0; i < 3; i++) w += v[i] * trans_mat[i][3];
    if (w == 0) w = 1e-5;

    *xt = ((int) (res[0] * xscaler / w)) + xmiddle;
    *yt = ((int) (res[1] * yscaler / w)) + ymiddle;
}

/* And the functions to map from user 3D space to terminal z coordinate */
static double map3d_z(x, y, z)
double x, y, z;
{
    int i;
    double v[4], res,			     /* Homogeneous coords. vectors. */
	w = trans_mat[3][3];

    v[0] = map_x3d(x); /* Normalize object space to -1..1 */
    v[1] = map_y3d(y);
    v[2] = map_z3d(z);
    v[3] = 1.0;

    res = trans_mat[3][2];     	      /* Initiate it with the weight factor. */
    for (i = 0; i < 3; i++) res += v[i] * trans_mat[i][2];

    return res;
}

/* Initialize the line style using the current device and set hidden styles  */
/* to it as well if hidden line removal is enabled.			     */
static setlinestyle(style)
int style;
{
    register struct termentry *t = &term_tbl[term];

    (*t->linetype)(style);
    if (hidden3d) {
	hidden_line_type_above = style;
	hidden_line_type_below = style;
    }
}

/* Initialize the necessary steps for hidden line removal. This algorithm    */
/* is based on the "floating horizon" explicit surfaces hidden line removal. */
static void init_hidden_line_removal()
{
    hidden_max_index = xright - xleft + 1;
    hidden_low_bound = (int *) alloc(sizeof(int) * hidden_max_index, "hidden");
    hidden_high_bound = (int *) alloc(sizeof(int) * hidden_max_index, "hidden");
}

/* Reset the hidden line data to a fresh start.				     */
static void reset_hidden_line_removal()
{
    int i;

    for (i = 0; i < hidden_max_index; i++) {
    	hidden_low_bound[i] = ytop;
    	hidden_high_bound[i] = ybot;
    }
}

/* Terminates the hidden line removal process. Free any memory allocated by  */
/* init_hidden_line_removal above.					     */
static void term_hidden_line_removal()
{
    free(hidden_low_bound);
    free(hidden_high_bound);
}

/* Given a list of parallel iso_curves, make sure the first one is closest   */
/* to viewer or reverse in place the list otherwise.			     */
/* Returns a pointer to the new ordered list.				     */
static struct iso_curve *reorder_hidden_one_iso_list(orig_list)
struct iso_curve *orig_list;
{
	double first_crv_first_ptz, first_crv_last_ptz,
	       last_crv_first_ptz, last_crv_last_ptz;
	struct iso_curve *first_crv = orig_list, *last_crv;

	for (last_crv = first_crv; last_crv->next; last_crv = last_crv->next);

	first_crv_first_ptz = map3d_z(first_crv->points[0].x,
				      first_crv->points[0].y,
				      0.0);
	first_crv_last_ptz = map3d_z(first_crv->points[first_crv->p_count-1].x,
				     first_crv->points[first_crv->p_count-1].y,
				     0.0);

	last_crv_first_ptz = map3d_z(last_crv->points[0].x,
				     last_crv->points[0].y,
				     0.0);
	last_crv_last_ptz = map3d_z(last_crv->points[last_crv->p_count-1].x,
				    last_crv->points[last_crv->p_count-1].y,
				    0.0);

	/* If first curve is in front of last - do nothing. */
	if ((first_crv_first_ptz > last_crv_first_ptz &&
	     first_crv_first_ptz > last_crv_last_ptz) ||
	    (first_crv_last_ptz > last_crv_first_ptz &&
	     first_crv_last_ptz > last_crv_last_ptz))
	    return orig_list;
	else {
	    struct iso_curve *icrv1, *icrv2, *icrv3;

	    /* Need to reverse the list order: */
	    for (icrv1 = orig_list, icrv2 = icrv1->next; icrv2 != NULL; ) {
		icrv3 = icrv2->next;
		icrv2->next = icrv1;
		icrv1 = icrv2;
	    	icrv2 = icrv3;
	    }

	    orig_list->next = NULL; /* Now it is the last element. */

	    return icrv1;
	}
}

/* Reorder the list of iso_curves in the surface plot, so it will be drawn   */
/* from near iso curve to far one in both direction.			     */
/* Returned is a pointer to new order iso curve list.			     */
static struct iso_curve *reorder_hidden_iso_curves(plot, num_iso_lines)
	struct surface_points *plot;
	int num_iso_lines;
{
	int i;
	struct iso_curve *iso_list1 = plot->iso_crvs, *itmp = iso_list1, *iso_list2;

	for (i = 1; i < num_iso_lines; i++) itmp = itmp->next;
	iso_list2 = itmp->next;
	itmp->next = NULL;

	iso_list1 = reorder_hidden_one_iso_list(iso_list1);
	iso_list2 = reorder_hidden_one_iso_list(iso_list2);
	for (itmp = iso_list1; itmp->next; itmp = itmp->next);
	itmp->next = iso_list2;

	plot->iso_crvs = iso_list1;

	return iso_list1;
}

/* Plot a line after removing is hidden part(s). */
static void hidden_line_plot_aux(x1, y1, x2, y2, style)
int x1, y1, x2, y2, style;
{
    register struct termentry *t = &term_tbl[term];

    if (x2 < x1 || (x2 == x1 && y1 == y2)) return;

    (*t->linetype)(style);
    (*t->move)(x1,y1);
    (*t->vector)(x2,y2);
}

/* Plot a line after removing is hidden part(s). */
static void hidden_line_plot(x1, y1, x2, y2)
int x1, y1, x2, y2;
{
    int x, last_x, last_y, visible_above, visible_below;
    float dy, y;

    if (x1 > x2) {
	x = x1;
	x1 = x2;
	x2 = x;

	y = y1;
	y1 = y2;
	y2 = y;
    }

    if (hidden_first_row) {
	/* All is visible and drawn as visible above. */
	dy = x1 != x2 ? ((float) (y2 - y1)) / ((float) (x2 - x1)) : VERYLARGE;

	for (x = x1, y = y1; x <= x2; x++, y = y1 + (x - x1) * dy) {
	    SET_HIDDEN_BOUND(hidden_high_bound, x, (int) y);
	    SET_HIDDEN_BOUND(hidden_low_bound, x, (int) y);
	}
        hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_above);
    }
    else {
	if (x1 == x2) {
	    if (y1 > y2) {
		y = y1;
		y1 = y2;
		y2 = y;
	    }

	    /* Clip properly this verical line to right bounds. Note clipping
	     * may produce upto two segments.
	     */
	    if (y1 <= HIDDEN_LOW_BOUND(x1) && y2 <= HIDDEN_LOW_BOUND(x1))
		hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_below);
	    else if (y1 >= HIDDEN_HIGH_BOUND(x1) && y2 >= HIDDEN_HIGH_BOUND(x1))  
		hidden_line_plot_aux(x1, y1, x2, y2, hidden_line_type_above);
	    else {
	        if (y1 < HIDDEN_LOW_BOUND(x1) && y2 > HIDDEN_LOW_BOUND(x1))
		    hidden_line_plot_aux(x1, y1, x2, HIDDEN_LOW_BOUND(x1),
				         hidden_line_type_below);
	        if (y2 > HIDDEN_HIGH_BOUND(x1) && y1 < HIDDEN_HIGH_BOUND(x1))
		    hidden_line_plot_aux(x1, HIDDEN_HIGH_BOUND(x1), x2, y2,
				         hidden_line_type_above);
	    }
	    return;
	}
	else
	    dy = ((float) (y2 - y1)) / ((float) (x2 - x1));

	visible_above = y1 >= HIDDEN_HIGH_BOUND(x1);
	visible_below = y1 <= HIDDEN_LOW_BOUND(x1);
	if (visible_above || visible_below) {
	    if (visible_above && visible_below) visible_below = FALSE;
	    last_x = x1;
	    last_y = y1;
	}
    	for (x = x1, y = y1; x < x2; x++, y += dy)
	{
	    if (y >= HIDDEN_HIGH_BOUND(x)) {
		if (visible_below) {
		    hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
					 hidden_line_type_below);
		    visible_below = FALSE;
		}
		if (!visible_above) {
		    visible_above = TRUE;
		    last_x = x;
		    last_y = (int) y;
		}
		if (!hidden_no_update)
		    SET_HIDDEN_BOUND(hidden_high_bound, x, (int) y);
	    }
	    else if (y <= HIDDEN_LOW_BOUND(x)) {
		if (visible_above) {
		    hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
					 hidden_line_type_above);
		    visible_above = FALSE;

		}
		if (!visible_below) {
		    visible_below = TRUE;
		    last_x = x;
		    last_y = (int) y;
		}
		if (!hidden_no_update)
		    SET_HIDDEN_BOUND(hidden_low_bound, x, (int) y);
	    }
	    else {
		if (visible_above) {
		    hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
					 hidden_line_type_above);
		    visible_above = visible_below = FALSE;
		}
		else if (visible_below) {
		    hidden_line_plot_aux(last_x, last_y, x - 1, (int) (y - dy),
					 hidden_line_type_below);
		    visible_below = FALSE;
		}
	    }
	}

	if (visible_above) {
	    hidden_line_plot_aux(last_x, last_y, x2, y2,
				 hidden_line_type_above);
	}
	else if (visible_below) {
	    hidden_line_plot_aux(last_x, last_y, x2, y2,
				 hidden_line_type_below);
	}
    }
}

/* Test a single point to be within the xleft,xright,ybot,ytop bbox.
 * Sets the returned integers 4 l.s.b. as follows:
 * bit 0 if to the left of xleft.
 * bit 1 if to the right of xright.
 * bit 2 if above of ytop.
 * bit 3 if below of ybot.
 * 0 is returned if inside.
 */
static int clip_point_for_clip_line(x, y)
int x, y;
{
    int ret_val = 0;

    if (x < xleft) ret_val |= 0x01;
    if (x > xright) ret_val |= 0x02;
    if (y < ybot) ret_val |= 0x04;
    if (y > ytop) ret_val |= 0x08;

    return ret_val;
}

/* Test a single point to be within the xleft,xright,ybot,ytop bbox.
 * and it is not hidden if hidden lines are to be removed.
 */
static int clip_point(x, y)
int x, y;
{
    if (hidden_active &&
	HIDDEN_LOW_BOUND(x) <= y && HIDDEN_HIGH_BOUND(x) >= y)
	return FALSE;

    return clip_point_for_clip_line(x, y);
}

/* Clip the given line to drawing coords defined as xleft,xright,ybot,ytop.
 *   This routine uses the cohen & sutherland bit mapping for fast clipping -
 * see "Principles of Interactive Computer Graphics" Newman & Sproull page 65.
 */
static void draw_clip_line(x1, y1, x2, y2)
int x1, y1, x2, y2;
{
    int x, y, dx, dy, x_intr[2], y_intr[2], count, pos1, pos2;
    register struct termentry *t = &term_tbl[term];

    pos1 = clip_point_for_clip_line(x1, y1);
    pos2 = clip_point_for_clip_line(x2, y2);
    if (pos1 || pos2) {
	if (pos1 & pos2) return;		  /* segment is totally out. */

	/* Here part of the segment MAY be inside. test the intersection
	 * of this segment with the 4 boundaries for hopefully 2 intersections
	 * in. If non found segment is totaly out.
	 */
	count = 0;
	dx = x2 - x1;
	dy = y2 - y1;

	/* Find intersections with the x parallel bbox lines: */
	if (dy != 0) {
	    x = (ybot - y2) * dx / dy + x2;        /* Test for ybot boundary. */
	    if (x >= xleft && x <= xright) {
		x_intr[count] = x;
		y_intr[count++] = ybot;
	    }
	    x = (ytop - y2) * dx / dy + x2;        /* Test for ytop boundary. */
	    if (x >= xleft && x <= xright) {
		x_intr[count] = x;
		y_intr[count++] = ytop;
	    }
	}

	/* Find intersections with the y parallel bbox lines: */
	if (dx != 0) {
	    y = (xleft - x2) * dy / dx + y2;      /* Test for xleft boundary. */
	    if (y >= ybot && y <= ytop) {
		x_intr[count] = xleft;
		y_intr[count++] = y;
	    }
	    y = (xright - x2) * dy / dx + y2;    /* Test for xright boundary. */
	    if (y >= ybot && y <= ytop) {
		x_intr[count] = xright;
		y_intr[count++] = y;
	    }
	}

	if (count == 2) {
	    int x_max, x_min, y_max, y_min;

	    x_min = min(x1, x2);
	    x_max = max(x1, x2);
	    y_min = min(y1, y2);
	    y_max = max(y1, y2);

	    if (pos1 && pos2) {		       /* Both were out - update both */
		x1 = x_intr[0];
		y1 = y_intr[0];
		x2 = x_intr[1];
		y2 = y_intr[1];
	    }
	    else if (pos1) {	       /* Only x1/y1 was out - update only it */
		if (dx * (x2 - x_intr[0]) + dy * (y2 - y_intr[0]) > 0) {
		    x1 = x_intr[0];
		    y1 = y_intr[0];
		}
		else {
		    x1 = x_intr[1];
		    y1 = y_intr[1];
		}
	    }
	    else {	       	       /* Only x2/y2 was out - update only it */
		if (dx * (x_intr[0] - x1) + dy * (y_intr[0] - x1) > 0) {
		    x2 = x_intr[0];
		    y2 = y_intr[0];
		}
		else {
		    x2 = x_intr[1];
		    y2 = y_intr[1];
		}
	    }

	    if (x1 < x_min || x1 > x_max ||
		x2 < x_min || x2 > x_max ||
		y1 < y_min || y1 > y_max ||
		y2 < y_min || y2 > y_max) return;
	}
	else
	    return;
    }

    if (hidden_active) {
	hidden_line_plot(x1, y1, x2, y2);
    }
    else {
	(*t->move)(x1,y1);
	(*t->vector)(x2,y2);
    }
}

/* Two routine to emulate move/vector sequence using line drawing routine. */
static int move_pos_x, move_pos_y;

static void clip_move(x,y)
int x,y;
{
    move_pos_x = x;
    move_pos_y = y;
}

static void clip_vector(x,y)
int x,y;
{
    draw_clip_line(move_pos_x,move_pos_y, x, y);
    move_pos_x = x;
    move_pos_y = y;
}

/* And text clipping routine. */
static void clip_put_text(x, y, str)
int x,y;
char *str;
{
    register struct termentry *t = &term_tbl[term];

    if (clip_point(x, y)) return;

    (*t->put_text)(x,y,str);
}

/* (DFK) For some reason, the Sun386i compiler screws up with the CheckLog 
 * macro, so I write it as a function on that machine.
 */
#ifndef sun386
/* (DFK) Use 10^x if logscale is in effect, else x */
#define CheckLog(log, x) ((log) ? pow(10., (x)) : (x))
#else
static double
CheckLog(log, x)
     BOOLEAN log;
     double x;
{
  if (log)
    return(pow(10., x));
  else
    return(x);
}
#endif /* sun386 */

static double
LogScale(coord, islog, what, axis)
	double coord;			/* the value */
	BOOLEAN islog;			/* is this axis in logscale? */
	char *what;			/* what is the coord for? */
	char *axis;			/* which axis is this for ("x" or "y")? */
{
    if (islog) {
	   if (coord <= 0.0) {
		  char errbuf[100];		/* place to write error message */
		(void) sprintf(errbuf,"%s has %s coord of %g; must be above 0 for log scale!",
				what, axis, coord);
		  (*term_tbl[term].text)();
		  (void) fflush(outfile);
		  int_error(errbuf, NO_CARET);
	   } else
		return(log10(coord));
    }
    return(coord);
}

/* borders of plotting area */
/* computed once on every call to do_plot */
static boundary3d(scaling)
	BOOLEAN scaling;		/* TRUE if terminal is doing the scaling */
{
    register struct termentry *t = &term_tbl[term];
    xleft = (t->h_char)*2 + (t->h_tic);
    xright = (scaling ? 1 : xsize) * (t->xmax) - (t->h_char)*2 - (t->h_tic);
    ybot = (t->v_char)*5/2 + 1;
    ytop = (scaling ? 1 : ysize) * (t->ymax) - (t->v_char)*5/2 - 1;
    xmiddle = (xright + xleft) / 2;
    ymiddle = (ytop + ybot) / 2;
    xscaler = (xright - xleft) / 2;
    yscaler = (ytop - ybot) / 2;
}

static double dbl_raise(x,y)
double x;
int y;
{
register int i;
double val;

	val = 1.0;
	for (i=0; i < abs(y); i++)
		val *= x;
	if (y < 0 ) return (1.0/val);
	return(val);
}


static double make_3dtics(tmin,tmax,axis,logscale)
double tmin,tmax;
int axis;
BOOLEAN logscale;
{
int len,x1,y1,x2,y2;
register double xr,xnorm,tics,tic,l10;

	xr = fabs(tmin-tmax);

	/* Compute length of axis in screen space coords. */
	switch (axis) {
		case 'x':
			map3d_xy(tmin,0.0,0.0,&x1,&y1);
			map3d_xy(tmax,0.0,0.0,&x2,&y2);
			break;
		case 'y':
			map3d_xy(0.0,tmin,0.0,&x1,&y1);
			map3d_xy(0.0,tmax,0.0,&x2,&y2);
			break;
		case 'z':
			map3d_xy(0.0,0.0,tmin,&x1,&y1);
			map3d_xy(0.0,0.0,tmax,&x2,&y2);
			break;
	}

	if (((long) (x1-x2))*(x1-x2) + ((long) (y1-y2))*(y1-y2) <
	    sqr(3L * term_tbl[term].h_char))
		return -1.0;                  			/* No tics! */

	l10 = log10(xr);
	if (logscale) {
		tic = dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
		if (tic < 1.0)
			tic = 1.0;
	} else {
		xnorm = pow(10.0,l10-(double)((l10 >= 0.0 ) ? (int)l10 : ((int)l10-1)));
		if (xnorm <= 5)
			tics = 0.5;
		else tics = 1.0;
		tic = tics * dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
	}
	return(tic);
}

do_3dplot(plots, pcount, min_x, max_x, min_y, max_y, min_z, max_z)
struct surface_points *plots;
int pcount;			/* count of plots in linked list */
double min_x, max_x;
double min_y, max_y;
double min_z, max_z;
{
register struct termentry *t = &term_tbl[term];
register int surface, xaxis_y, yaxis_x;
register struct surface_points *this_plot;
int xl, yl;
			/* only a Pyramid would have this many registers! */
double xtemp, ytemp, ztemp, temp;
struct text_label *this_label;
struct arrow_def *this_arrow;
BOOLEAN scaling;
transform_matrix mat;

/* Initiate transformation matrix using the global view variables. */
    mat_rot_z(surface_rot_z, trans_mat);
    mat_rot_x(surface_rot_x, mat);
    mat_mult(trans_mat, trans_mat, mat);
    mat_scale(surface_scale / 2.0, surface_scale / 2.0, surface_scale / 2.0, mat);
    mat_mult(trans_mat, trans_mat, mat);

/* modify min_z/max_z so it will zscale properly. */
    ztemp = (max_z - min_z) / (2.0 * surface_zscale);
    temp = (max_z + min_z) / 2.0;
    min_z = temp - ztemp;
    max_z = temp + ztemp;

/* store these in variables global to this file */
/* otherwise, we have to pass them around a lot */
    x_min3d = min_x;
    x_max3d = max_x;
    y_min3d = min_y;
    y_max3d = max_y;
    z_min3d = min_z;
    z_max3d = max_z;

    if (polar)
	int_error("Can not splot in polar coordinate system.", NO_CARET);

    if (z_min3d == VERYLARGE || z_max3d == -VERYLARGE ||
	x_min3d == VERYLARGE || x_max3d == -VERYLARGE ||
	y_min3d == VERYLARGE || y_max3d == -VERYLARGE)
        int_error("all points undefined!", NO_CARET);

    /* If we are to draw the bottom grid make sure zmin is updated properly. */
    if (xtics || ytics || grid)
	z_min3d -= (max_z - min_z) * ticslevel;

/*  This used be x_max3d == x_min3d, but that caused an infinite loop once. */
    if (fabs(x_max3d - x_min3d) < zero)
	int_error("x_min3d should not equal x_max3d!",NO_CARET);
    if (fabs(y_max3d - y_min3d) < zero)
	int_error("y_min3d should not equal y_max3d!",NO_CARET);
    if (fabs(z_max3d - z_min3d) < zero)
	int_error("z_min3d should not equal z_max3d!",NO_CARET);

    if (hidden3d) {
	struct surface_points *plot;
	
        /* Verify data is hidden line removable - nonparametric + grid based. */
    	for (plot = plots; plot != NULL; plot = plot->next_sp) {
	    if (parametric ||
	        (plot->plot_type == DATA3D && !plot->has_grid_topology))
	        int_error("Cannot hidden line remove parametric surface or non grid data\n", NO_CARET);
        }
    }

/* INITIALIZE TERMINAL */
    if (!term_init) {
	(*t->init)();
	term_init = TRUE;
    }
    screen_ok = FALSE;
    scaling = (*t->scale)(xsize, ysize);
    (*t->graphics)();

    /* now compute boundary for plot (xleft, xright, ytop, ybot) */
    boundary3d(scaling);

/* SCALE FACTORS */
	zscale3d = 2.0/(z_max3d - z_min3d);
	yscale3d = 2.0/(y_max3d - y_min3d);
	xscale3d = 2.0/(x_max3d - x_min3d);

	(*t->linetype)(-2); /* border linetype */

/* PLACE TITLE */
	if (*title != 0) {
		int x, y;

		x = title_xoffset * t->h_char;
		y = title_yoffset * t->v_char;

		if ((*t->justify_text)(CENTRE)) 
			(*t->put_text)(x+(xleft+xright)/2, 
				       y+ytop+(t->v_char), title);
		else
			(*t->put_text)(x+(xleft+xright)/2 - strlen(title)*(t->h_char)/2,
				       y+ytop+(t->v_char), title);
	}

/* PLACE TIMEDATE */
	if (timedate) {
		int x, y;

		x = time_xoffset * t->h_char;
		y = time_yoffset * t->v_char;
		dated = time( (long *) 0);
		tdate = ctime( &dated);
		tdate[24]='\0';
		if ((*t->text_angle)(1)) {
			if ((*t->justify_text)(CENTRE)) {
				(*t->put_text)(x+(t->v_char),
						 y+ybot+4*(t->v_char), tdate);
			}
			else {
				(*t->put_text)(x+(t->v_char),
						 y+ybot+4*(t->v_char)-(t->h_char)*strlen(ylabel)/2, 
						 tdate);
			}
		}
		else {
			(void)(*t->justify_text)(LEFT);
			(*t->put_text)(x,
						 y+ybot-3*(t->v_char), tdate);
		}
		(void)(*t->text_angle)(0);
	}

/* PLACE LABELS */
    for (this_label = first_label; this_label!=NULL;
			this_label=this_label->next ) {
	    int x,y;

	    xtemp = LogScale(this_label->x, log_x, "label", "x");
	    ytemp = LogScale(this_label->y, log_y, "label", "y");
	    ztemp = LogScale(this_label->z, log_z, "label", "z");
    	    map3d_xy(xtemp,ytemp,ztemp, &x, &y);

		if ((*t->justify_text)(this_label->pos)) {
			(*t->put_text)(x,y,this_label->text);
		}
		else {
			switch(this_label->pos) {
				case  LEFT:
					(*t->put_text)(x,y,this_label->text);
					break;
				case CENTRE:
					(*t->put_text)(x -
						(t->h_char)*strlen(this_label->text)/2,
						y, this_label->text);
					break;
				case RIGHT:
					(*t->put_text)(x -
						(t->h_char)*strlen(this_label->text),
						y, this_label->text);
					break;
			}
		 }
	 }

/* PLACE ARROWS */
    (*t->linetype)(0);	/* arrow line type */
    for (this_arrow = first_arrow; this_arrow!=NULL;
	    this_arrow = this_arrow->next ) {
	int sx,sy,ex,ey;

	xtemp = LogScale(this_arrow->sx, log_x, "arrow", "x");
	ytemp = LogScale(this_arrow->sy, log_y, "arrow", "y");
	ztemp = LogScale(this_arrow->sz, log_y, "arrow", "z");
	map3d_xy(xtemp,ytemp,ztemp, &sx, &sy);

	xtemp = LogScale(this_arrow->ex, log_x, "arrow", "x");
	ytemp = LogScale(this_arrow->ey, log_y, "arrow", "y");
	ztemp = LogScale(this_arrow->ez, log_y, "arrow", "z");
	map3d_xy(xtemp,ytemp,ztemp, &ex, &ey);

	(*t->arrow)(sx, sy, ex, ey, this_arrow->head);
    }

    if (hidden3d) {
	init_hidden_line_removal();
	reset_hidden_line_removal();
	hidden_active = TRUE;
    }

/* DRAW SURFACES AND CONTOURS */
	real_z_min3d = min_z;
	real_z_max3d = max_z;
	if (key == -1) {
	    xl = xright  - (t->h_tic) - (t->h_char)*5;
	    yl = ytop - (t->v_tic) - (t->v_char);
	}
	if (key == 1) {
	    xtemp = LogScale(key_x, log_x, "key", "x");
	    ytemp = LogScale(key_y, log_y, "key", "y");
	    ztemp = LogScale(key_z, log_z, "key", "z");
	    map3d_xy(xtemp,ytemp,ztemp, &xl, &yl);
	}

	this_plot = plots;
	for (surface = 0;
	     surface < pcount;
	     this_plot = this_plot->next_sp, surface++) {
		if ( hidden3d )
		    hidden_no_update = FALSE;

		if (draw_surface) {
		    (*t->linetype)(this_plot->line_type);
		    if (hidden3d) {
			hidden_line_type_above = this_plot->line_type;
			hidden_line_type_below = this_plot->line_type + 1;
		    }
		    
		    if (key != 0) {
			if ((*t->justify_text)(RIGHT)) {
			    clip_put_text(xl,
					  yl,this_plot->title);
			}
			else {
			    if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
					xleft, xright))
				clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
					      yl,this_plot->title);
			}
		    }
		    
		    switch(this_plot->plot_style) {
		        case IMPULSES: {
			    if (key != 0) {
				clip_move(xl+(t->h_char),yl);
				clip_vector(xl+4*(t->h_char),yl);
			    }
			    plot3d_impulses(this_plot);
			    break;
			}
			case LINES: {
			    if (key != 0) {
				clip_move(xl+(int)(t->h_char),yl);
				clip_vector(xl+(int)(4*(t->h_char)),yl);
			    }
			    plot3d_lines(this_plot);
			    break;
			}
			case ERRORBARS:	/* ignored; treat like points */
			case POINTS: {
			    if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
				(*t->point)(xl+2*(t->h_char),yl,
					    this_plot->point_type);
			    }
			    plot3d_points(this_plot);
			    break;
			}
			case LINESPOINTS: {
			    /* put lines */
			    if (key != 0) {
				clip_move(xl+(t->h_char),yl);
				clip_vector(xl+4*(t->h_char),yl);
			    }
			    plot3d_lines(this_plot);
			
			    /* put points */
			    if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
				(*t->point)(xl+2*(t->h_char),yl,
					    this_plot->point_type);
			    }
			    plot3d_points(this_plot);
			    break;
			}
			case DOTS: {
			    if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
				(*t->point)(xl+2*(t->h_char),yl, -1);
			    }
			    plot3d_dots(this_plot);
			    break;
			}
		    }
		    yl = yl - (t->v_char);
		}

		if ( hidden3d ) {
		    hidden_no_update = TRUE;
		    hidden_line_type_above = this_plot->line_type + (hidden3d ? 2 : 1);
		    hidden_line_type_below = this_plot->line_type + (hidden3d ? 2 : 1);
		}

		if (draw_contour && this_plot->contours != NULL) {
			struct gnuplot_contours *cntrs = this_plot->contours;

			(*t->linetype)(this_plot->line_type + (hidden3d ? 2 : 1));

			if (key != 0) {
				if ((*t->justify_text)(RIGHT)) {
					clip_put_text(xl,
						yl,this_plot->title);
				}
				else {
				    if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
							 xleft, xright))
					 clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
								 yl,this_plot->title);
				}
				switch(this_plot->plot_style) {
					case IMPULSES:
						clip_move(xl+(t->h_char),yl);
						clip_vector(xl+4*(t->h_char),yl);
						break;
					case LINES:
						clip_move(xl+(int)(t->h_char),yl);
						clip_vector(xl+(int)(4*(t->h_char)),yl);
						break;
					case ERRORBARS: /* ignored; treat like points */
					case POINTS:
						if (!clip_point(xl+2*(t->h_char),yl)) {
						     (*t->point)(xl+2*(t->h_char),yl,
								    this_plot->point_type);
						}
						break;
					case LINESPOINTS:
						clip_move(xl+(int)(t->h_char),yl);
						clip_vector(xl+(int)(4*(t->h_char)),yl);
						break;
					case DOTS:
						if (!clip_point(xl+2*(t->h_char),yl)) {
						     (*t->point)(xl+2*(t->h_char),yl, -1);
						}
						break;
				}
			}

			while (cntrs) {
				switch(this_plot->plot_style) {
					case IMPULSES:
			   			cntr3d_impulses(cntrs, this_plot);
						break;
					case LINES:
						cntr3d_lines(cntrs);
						break;
					case ERRORBARS: /* ignored; treat like points */
					case POINTS:
						cntr3d_points(cntrs, this_plot);
						break;
					case LINESPOINTS:
						cntr3d_lines(cntrs);
						cntr3d_points(cntrs, this_plot);
						break;
					case DOTS:
						cntr3d_dots(cntrs);
						break;
				}
				cntrs = cntrs->next;
			}
			if (key != 0) yl = yl - (t->v_char);
		}

		if (surface == 0)
		    draw_bottom_grid(this_plot,real_z_min3d,real_z_max3d);
	}
	(*t->text)();
	(void) fflush(outfile);

	if (hidden3d) {
	    term_hidden_line_removal();
	    hidden_active = FALSE;
	}
}

/* plot3d_impulses:
 * Plot the surfaces in IMPULSES style
 */
static plot3d_impulses(plot)
	struct surface_points *plot;
{
    int i;				/* point index */
    int x,y,x0,y0;			/* point in terminal coordinates */
    struct termentry *t = &term_tbl[term];
    struct iso_curve *icrvs = plot->iso_crvs;

    while ( icrvs ) {
	struct coordinate *points = icrvs->points;

	for (i = 0; i < icrvs->p_count; i++) {
	    if (real_z_max3d<points[i].z)
		real_z_max3d=points[i].z;
	    if (real_z_min3d>points[i].z)
		real_z_min3d=points[i].z;

	    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
	    map3d_xy(points[i].x, points[i].y, z_min3d, &x0, &y0);

	    clip_move(x0,y0);
	    clip_vector(x,y);
	}

	icrvs = icrvs->next;
    }
}

/* plot3d_lines:
 * Plot the surfaces in LINES style
 */
static plot3d_lines(plot)
	struct surface_points *plot;
{
    int i, iso_count, num_iso_lines;
    int x,y;				/* point in terminal coordinates */
    struct termentry *t = &term_tbl[term];
    struct iso_curve *icrvs = plot->iso_crvs,
	   *first_row_icrv, *last_row_icrv, *first_col_icrv, *icrv;
    struct coordinate *points;

    if (hidden3d) {
	hidden_no_update = FALSE;

	if (plot->plot_type == FUNC3D)
	    num_iso_lines = iso_samples;
	else
	    num_iso_lines = plot->num_iso_read;

	icrvs = reorder_hidden_iso_curves(plot, num_iso_lines);

	first_row_icrv = icrvs;
	for (last_row_icrv = icrvs, i = 1;
	     i++ < num_iso_lines;
	     last_row_icrv = last_row_icrv->next);
	first_col_icrv = last_row_icrv->next;
	reset_hidden_line_removal();

	iso_count = 1;
    }

    while (icrvs) {
	if (hidden3d) {
	    if (iso_count == 1 || iso_count == num_iso_lines + 1) {
		hidden_first_row = TRUE;

		/* Draw other boundary so low/high bounds will be complete: */
		icrv = iso_count == 1 ? first_col_icrv : first_row_icrv;
		for (i = 0, points = icrv->points; i < icrv->p_count; i++) {
		    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);

		    if (i > 0)
			clip_vector(x,y);
		    else
			clip_move(x,y);
		}
	    }
	    else
		hidden_first_row = FALSE;
	    iso_count++;
	}

	for (i = 0, points = icrvs->points; i < icrvs->p_count; i++) {
	    if (real_z_max3d<points[i].z)
		real_z_max3d=points[i].z;
	    if (real_z_min3d>points[i].z)
		real_z_min3d=points[i].z;

	    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);

	    if (i > 0)
		clip_vector(x,y);
	    else
		clip_move(x,y);
	}

	icrvs = icrvs->next;
    }

    if (hidden3d) {
	/* Draw other boundary so low/high bounds will be complete: */
	for (i = 0, points = last_row_icrv->points;
	     i < last_row_icrv->p_count; i++) {
	    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);

	    if (i > 0)
		clip_vector(x,y);
	    else
		clip_move(x,y);
	}
    }
}

/* plot3d_points:
 * Plot the surfaces in POINTS style
 */
static plot3d_points(plot)
	struct surface_points *plot;
{
    int i,x,y;
    struct termentry *t = &term_tbl[term];
    struct iso_curve *icrvs = plot->iso_crvs;

    while ( icrvs ) {
	struct coordinate *points = icrvs->points;

	for (i = 0; i < icrvs->p_count; i++) {
	    if (real_z_max3d<points[i].z)
		real_z_max3d=points[i].z;
	    if (real_z_min3d>points[i].z)
		real_z_min3d=points[i].z;

	    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);

	    if (!clip_point(x,y))
		(*t->point)(x,y, plot->point_type);
	}

	icrvs = icrvs->next;
    }
}

/* plot3d_dots:
 * Plot the surfaces in DOTS style
 */
static plot3d_dots(plot)
	struct surface_points *plot;
{
    int i,x,y;
    struct termentry *t = &term_tbl[term];
    struct iso_curve *icrvs = plot->iso_crvs;

    while ( icrvs ) {
	struct coordinate *points = icrvs->points;

    	for (i = 0; i < icrvs->p_count; i++) {
	    if (real_z_max3d<points[i].z)
		real_z_max3d=points[i].z;
	    if (real_z_min3d>points[i].z)
    		real_z_min3d=points[i].z;

    	    map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);

    	    if (!clip_point(x,y))
		(*t->point)(x,y, -1);
    	}

	icrvs = icrvs->next;
    }
}

/* cntr3d_impulses:
 * Plot a surface contour in IMPULSES style
 */
static cntr3d_impulses(cntr, plot)
	struct gnuplot_contours *cntr;
	struct surface_points *plot;
{
    int i,j,k;				/* point index */
    int x,y,x0,y0;			/* point in terminal coordinates */
    struct termentry *t = &term_tbl[term];

    if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
		     &x, &y);
	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
		     &x0, &y0);

	    clip_move(x0,y0);
	    clip_vector(x,y);
	}
    }
    else
	cntr3d_points(cntr, plot);   /* Must be on base grid, so do points. */
}

/* cntr3d_lines:
 * Plot a surface contour in LINES style
 */
static cntr3d_lines(cntr)
	struct gnuplot_contours *cntr;
{
    int i,j,k;				/* point index */
    int x,y;				/* point in terminal coordinates */
    struct termentry *t = &term_tbl[term];

    if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
    		     &x, &y);

    	    if (i > 0)
    		clip_vector(x,y);
	    else
		clip_move(x,y);
    	}
    }

    if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
    		     &x, &y);

    	    if (i > 0)
    		clip_vector(x,y);
	    else
		clip_move(x,y);
    	}
    }
}

/* cntr3d_points:
 * Plot a surface contour in POINTS style
 */
static cntr3d_points(cntr, plot)
	struct gnuplot_contours *cntr;
	struct surface_points *plot;
{
    int i,j,k;
    int x,y;
    struct termentry *t = &term_tbl[term];

    if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
    		     &x, &y);

	    if (!clip_point(x,y))
		(*t->point)(x,y, plot->point_type);
    	}
    }

    if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
    		     &x, &y);

	    if (!clip_point(x,y))
		(*t->point)(x,y, plot->point_type);
    	}
    }
}

/* cntr3d_dots:
 * Plot a surface contour in DOTS style
 */
static cntr3d_dots(cntr)
	struct gnuplot_contours *cntr;
{
    int i,j,k;
    int x,y;
    struct termentry *t = &term_tbl[term];

    if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
    		     &x, &y);

	    if (!clip_point(x,y))
		(*t->point)(x,y, -1);
    	}
    }

    if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
	for (i = 0; i < cntr->num_pts; i++) {
	    if (real_z_max3d<cntr->coords[i].z)
		real_z_max3d=cntr->coords[i].z;
	    if (real_z_min3d>cntr->coords[i].z)
		real_z_min3d=cntr->coords[i].z;

    	    map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
    		     &x, &y);

	    if (!clip_point(x,y))
		(*t->point)(x,y, -1);
    	}
    }
}

static update_extrema_pts(ix, iy, min_sx_x, min_sx_y, min_sy_x, min_sy_y,
			  x, y)
	int ix, iy, *min_sx_x, *min_sx_y, *min_sy_x, *min_sy_y;
	double x, y;
{

    if (*min_sx_x > ix + 2 ||         /* find (bottom) left corner of grid */
	(abs(*min_sx_x - ix) <= 2 && *min_sx_y > iy)) {
	*min_sx_x = ix;
	*min_sx_y = iy;
	min_sx_ox = x;
	min_sx_oy = y;
    }
    if (*min_sy_y > iy + 2 ||         /* find bottom (right) corner of grid */
	(abs(*min_sy_y - iy) <= 2 && *min_sy_x < ix)) {
	*min_sy_x = ix;
	*min_sy_y = iy;
	min_sy_ox = x;
	min_sy_oy = y;
    }
}

/* Draw the bottom grid for the parametric case. */
static draw_parametric_grid(plot)
	struct surface_points *plot;
{
    int i,ix,iy,			/* point in terminal coordinates */
	min_sx_x = 10000,min_sx_y = 10000,min_sy_x = 10000,min_sy_y = 10000,
        grid_iso = plot->plot_type == DATA3D && plot->has_grid_topology ?
					plot->num_iso_read : iso_samples;
    double x,y,dx,dy;
    struct termentry *t = &term_tbl[term];

    if (grid && plot->has_grid_topology) {
    	x = x_min3d;
    	y = y_min3d;

	dx = (x_max3d-x_min3d) / (grid_iso-1);
	dy = (y_max3d-y_min3d) / (grid_iso-1);

	for (i = 0; i < grid_iso; i++) {
	        if (i == 0 || i == grid_iso-1)	        
		    setlinestyle(-2);
		else
		    setlinestyle(-1);
		map3d_xy(x_min3d, y, z_min3d, &ix, &iy);
		clip_move(ix,iy);
		update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
				   &min_sy_x,&min_sy_y,x_min3d,y);

		map3d_xy(x_max3d, y, z_min3d, &ix, &iy);
		clip_vector(ix,iy);
		update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
				   &min_sy_x,&min_sy_y,x_max3d,y);

		y += dy;
	}

	for (i = 0; i < grid_iso; i++) {
	        if (i == 0 || i == grid_iso-1)
		    setlinestyle(-2);
		else
		    setlinestyle(-1);
		map3d_xy(x, y_min3d, z_min3d, &ix, &iy);
		clip_move(ix,iy);
		update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
				   &min_sy_x,&min_sy_y,x,y_min3d);

		map3d_xy(x, y_max3d, z_min3d, &ix, &iy);
		clip_vector(ix,iy);
		update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
				   &min_sy_x,&min_sy_y,x,y_max3d);

		x += dx;
	}
    }
    else {
	setlinestyle(-2);

	map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
	clip_move(ix,iy);
	update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
			   &min_sy_x,&min_sy_y,x_min3d,y_min3d);

	map3d_xy(x_max3d, y_min3d, z_min3d, &ix, &iy);
	clip_vector(ix,iy);
	update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
			   &min_sy_x,&min_sy_y,x_max3d,y_min3d);

	map3d_xy(x_max3d, y_max3d, z_min3d, &ix, &iy);
	clip_vector(ix,iy);
	update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
			   &min_sy_x,&min_sy_y,x_max3d,y_max3d);

	map3d_xy(x_min3d, y_max3d, z_min3d, &ix, &iy);
	clip_vector(ix,iy);
	update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
			   &min_sy_x,&min_sy_y,x_min3d,y_max3d);


	map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
	clip_vector(ix,iy);
    }
}

/* Draw the bottom grid for non parametric case. */
static draw_non_param_grid(plot)
	struct surface_points *plot;
{
    int i,is_boundary=TRUE,crv_count=0,
	x,y,				/* point in terminal coordinates */
	min_sx_x = 10000,min_sx_y = 10000,min_sy_x = 10000,min_sy_y = 10000,
        grid_samples = plot->plot_type == DATA3D && plot->has_grid_topology ?
					plot->iso_crvs->p_count : samples,
        grid_iso = plot->plot_type == DATA3D && plot->has_grid_topology ?
					plot->num_iso_read : iso_samples;
    struct termentry *t = &term_tbl[term];
    struct iso_curve *icrvs = plot->iso_crvs;

    while ( icrvs ) {
	struct coordinate *points = icrvs->points;
	int saved_hidden_active = hidden_active;
	double z1 = map3d_z(points[0].x, points[0].y, 0.0),
	       z2 = map3d_z(points[icrvs->p_count-1].x,
                            points[icrvs->p_count-1].y, 0.0);

	for (i = 0; i < icrvs->p_count; i += icrvs->p_count-1) {
	    map3d_xy(points[i].x, points[i].y, z_min3d, &x, &y);
	    if (is_boundary) {
		setlinestyle(-2);
	    }
	    else {
	        setlinestyle(-1);
	    }

	    if (i > 0) {
	    	clip_vector(x,y);
	    }
	    else {
	    	clip_move(x,y);
	    }

	    if (draw_surface &&
	        is_boundary &&
	    	(i == 0 || i == icrvs->p_count-1)) {
	    	int x1,y1;		    /* point in terminal coordinates */

		/* Draw a vertical line to surface corner from grid corner. */
	    	map3d_xy(points[i].x, points[i].y, points[i].z, &x1, &y1);
	    	if (hidden3d) {
		    if ((i == 0 && z1 > z2) ||
		        (i == icrvs->p_count-1 && z2 > z1)) {
		        hidden_active = FALSE; /* This one is always visible. */
		    }	    		
	    	}
	    	clip_vector(x1,y1);
	    	clip_move(x,y);
		hidden_active = saved_hidden_active;
		update_extrema_pts(x,y,&min_sx_x,&min_sx_y, &min_sy_x,&min_sy_y,
				   points[i].x,points[i].y);
	    }
	}

	if (grid) {
	    crv_count++;
	    icrvs = icrvs->next;
	    is_boundary = crv_count == grid_iso - 1 ||
			  crv_count == grid_iso ||
			  (icrvs && icrvs->next == NULL);
	}
	else {
	    switch (crv_count++) {
		case 0:
		    for (i = 0; i < grid_iso - 1; i++)
			icrvs = icrvs->next;
		    break;
		case 1:
		    icrvs = icrvs->next;
		    break;
		case 2:
		    while (icrvs->next)
			icrvs = icrvs->next;
		    break;
		case 3:
		    icrvs = NULL;
		    break;
	    }
    	}
    }
}

/* Draw the bottom grid that hold the tic marks for 3d surface. */
static draw_bottom_grid(plot, min_z, max_z)
	struct surface_points *plot;
	double min_z, max_z;
{
    int i,j,k;				/* point index */
    int x,y,min_x = 10000,min_y = 10000;/* point in terminal coordinates */
    double xtic,ytic,ztic;
    struct termentry *t = &term_tbl[term];

    xtic = make_3dtics(x_min3d,x_max3d,'x',log_x);
    ytic = make_3dtics(y_min3d,y_max3d,'y',log_y);
    ztic = make_3dtics(min_z,max_z,'z',log_z);

    if (draw_border)
	if (parametric || !plot->has_grid_topology)
	    draw_parametric_grid(plot);
	else
	    draw_non_param_grid(plot);

    setlinestyle(-2); /* border linetype */

/* label x axis tics */
    if (xtics && xtic > 0.0) {
    	switch (xticdef.type) {
    	    case TIC_COMPUTED:
 		if (x_min3d < x_max3d)
		    draw_3dxtics(xtic * floor(x_min3d/xtic),
    				 xtic,
    				 xtic * ceil(x_max3d/xtic),
    				 min_sy_oy);
    	    	else
		    draw_3dxtics(xtic * floor(x_max3d/xtic),
    				 xtic,
    				 xtic * ceil(x_min3d/xtic),
    				 min_sy_oy);
    		break;
	    case TIC_SERIES:
		draw_series_3dxtics(xticdef.def.series.start, 
				    xticdef.def.series.incr, 
				    xticdef.def.series.end,
				    min_sy_oy);
		break;
	    case TIC_USER:
		draw_set_3dxtics(xticdef.def.user,
				 min_sy_oy);
		break;
    	    default:
    		(*t->text)();
    		(void) fflush(outfile);
    		int_error("unknown tic type in xticdef in do_3dplot", NO_CARET);
    		break;		/* NOTREACHED */
    	}
    }
/* label y axis tics */
    if (ytics && ytic > 0.0) {
    	switch (yticdef.type) {
    	    case TIC_COMPUTED:
 		if (y_min3d < y_max3d)
		    draw_3dytics(ytic * floor(y_min3d/ytic),
    				 ytic,
    				 ytic * ceil(y_max3d/ytic),
    				 min_sy_ox);
    	    	else
		    draw_3dytics(ytic * floor(y_max3d/ytic),
    				 ytic,
    				 ytic * ceil(y_min3d/ytic),
    				 min_sy_ox);
    		break;
	    case TIC_SERIES:
		draw_series_3dytics(yticdef.def.series.start, 
				    yticdef.def.series.incr, 
				    yticdef.def.series.end,
				    min_sy_ox);
		break;
	    case TIC_USER:
		draw_set_3dytics(yticdef.def.user,
				 min_sy_ox);
		break;
    	    default:
    		(*t->text)();
    		(void) fflush(outfile);
    		int_error("unknown tic type in yticdef in do_3dplot", NO_CARET);
    		break;		/* NOTREACHED */
    	}
    }
/* label z axis tics */
    if (ztics && ztic > 0.0 && (draw_surface ||
				draw_contour == CONTOUR_SRF ||
				draw_contour == CONTOUR_BOTH)) {
    	switch (zticdef.type) {
    	    case TIC_COMPUTED:
 		if (min_z < max_z)
		    draw_3dztics(ztic * floor(min_z/ztic),
    				 ztic,
    				 ztic * ceil(max_z/ztic),
				 min_sx_ox,
    				 min_sx_oy,
    				 min_z,
				 max_z);
    	    	else
		    draw_3dztics(ztic * floor(max_z/ztic),
    				 ztic,
    				 ztic * ceil(min_z/ztic),
    				 min_sx_ox,
				 min_sx_oy,
    				 max_z,
				 min_z);
    		break;
	    case TIC_SERIES:
		draw_series_3dztics(zticdef.def.series.start, 
				    zticdef.def.series.incr, 
				    zticdef.def.series.end,
				    min_sx_ox,
				    min_sx_oy,
				    min_z,
				    max_z);

		break;
	    case TIC_USER:
		draw_set_3dztics(zticdef.def.user,
				 min_sx_ox,
    				 min_sx_oy,
    				 min_z,
				 max_z);
		break;
    	    default:
    		(*t->text)();
    		(void) fflush(outfile);
    		int_error("unknown tic type in zticdef in do_3dplot", NO_CARET);
    		break;		/* NOTREACHED */
    	}
    }

/* PLACE XLABEL - along the middle grid X axis */
    if (strlen(xlabel) > 0) {
	   int x1,y1;
	   double step = apx_eq( min_sy_oy, y_min3d ) ?	(y_max3d-y_min3d)/4
						      : (y_min3d-y_max3d)/4;
    	   map3d_xy((x_min3d+x_max3d)/2,min_sy_oy-step, z_min3d,&x1,&y1);
	   x1 += xlabel_xoffset * t->h_char;
	   y1 += xlabel_yoffset * t->v_char;
	   if ((*t->justify_text)(CENTRE))
		clip_put_text(x1,y1,xlabel);
	   else
		clip_put_text(x1 - strlen(xlabel)*(t->h_char)/2,y1,xlabel);
    }

/* PLACE YLABEL - along the middle grid Y axis */
    if (strlen(ylabel) > 0) {
	   int x1,y1;
	   double step = apx_eq( min_sy_ox, x_min3d ) ?	(x_max3d-x_min3d)/4
						      : (x_min3d-x_max3d)/4;
    	   map3d_xy(min_sy_ox-step,(y_min3d+y_max3d)/2,z_min3d,&x1,&y1);
	   x1 += ylabel_xoffset * t->h_char;
	   y1 += ylabel_yoffset * t->v_char;
	   if ((*t->justify_text)(CENTRE))
		clip_put_text(x1,y1,ylabel);
	   else
		clip_put_text(x1 - strlen(ylabel)*(t->h_char)/2,y1,ylabel);
    }

/* PLACE ZLABEL - along the middle grid Z axis */
    if (strlen(zlabel) > 0 &&
        (draw_surface ||
	 draw_contour == CONTOUR_SRF ||
	 draw_contour == CONTOUR_BOTH)) {
    	   map3d_xy(min_sx_ox,min_sx_oy,max_z + (max_z-min_z)/4, &x, &y);

	   x += zlabel_xoffset * t->h_char;
	   y += zlabel_yoffset * t->v_char;
	   if ((*t->justify_text)(CENTRE))
		clip_put_text(x,y,zlabel);
	   else
		clip_put_text(x - strlen(zlabel)*(t->h_char)/2,y,zlabel);
    }
}

/* DRAW_3DXTICS: draw a regular tic series, x axis */
static draw_3dxtics(start, incr, end, ypos)
	double start, incr, end, ypos; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace;
	int ltic;		/* for mini log tics */
	double lticplace;	/* for mini log tics */

	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
		if (ticplace < x_min3d || ticplace > x_max3d) continue;
		xtick(ticplace, xformat, incr, 1.0, ypos);
		if (log_x && incr == 1.0) {
			/* add mini-ticks to log scale ticmarks */
			for (ltic = 2; ltic <= 9; ltic++) {
				lticplace = ticplace+log10((double)ltic);
				xtick(lticplace, "\0", incr, 0.5, ypos);
			}
		}
	}
}

/* DRAW_3DYTICS: draw a regular tic series, y axis */
static draw_3dytics(start, incr, end, xpos)
	double start, incr, end, xpos; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace;
	int ltic;		/* for mini log tics */
	double lticplace;	/* for mini log tics */

	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
		if (ticplace < y_min3d || ticplace > y_max3d) continue;
		ytick(ticplace, yformat, incr, 1.0, xpos);
		if (log_y && incr == 1.0) {
			/* add mini-ticks to log scale ticmarks */
			for (ltic = 2; ltic <= 9; ltic++) {
				lticplace = ticplace+log10((double)ltic);
				ytick(lticplace, "\0", incr, 0.5, xpos);
			}
		}
	}
}

/* DRAW_3DZTICS: draw a regular tic series, z axis */
static draw_3dztics(start, incr, end, xpos, ypos, z_min, z_max)
	double start, incr, end, xpos, ypos, z_min, z_max;
		/* assume start < end, incr > 0 */
{
	int x, y;
	double ticplace;
	int ltic;		/* for mini log tics */
	double lticplace;	/* for mini log tics */
	register struct termentry *t = &term_tbl[term];

	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
		if (ticplace < z_min || ticplace > z_max) continue;

		ztick(ticplace, zformat, incr, 1.0, xpos, ypos);
		if (log_z && incr == 1.0) {
			/* add mini-ticks to log scale ticmarks */
			for (ltic = 2; ltic <= 9; ltic++) {
				lticplace = ticplace+log10((double)ltic);
				ztick(lticplace, "\0", incr, 0.5, xpos, ypos);
			}
		}
	}

	/* Make sure the vertical line is fully drawn. */
	setlinestyle(-2);	/* axis line type */

	map3d_xy(xpos, ypos, z_min3d, &x, &y);
	clip_move(x,y);
	map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
	clip_vector(x,y);

	setlinestyle(-1); /* border linetype */
}

/* DRAW_SERIES_3DXTICS: draw a user tic series, x axis */
static draw_series_3dxtics(start, incr, end, ypos)
		double start, incr, end, ypos; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace, place;
	double ticmin, ticmax;	/* for checking if tic is almost inrange */
	double spacing = log_x ? log10(incr) : incr;

	if (end == VERYLARGE)
		end = max(CheckLog(log_x, x_min3d), CheckLog(log_x, x_max3d));
	else
	  /* limit to right side of plot */
	  end = min(end, max(CheckLog(log_x, x_min3d), CheckLog(log_x, x_max3d)));

	/* to allow for rounding errors */
	ticmin = min(x_min3d,x_max3d) - SIGNIF*incr;
	ticmax = max(x_min3d,x_max3d) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
	    place = (log_x ? log10(ticplace) : ticplace);
	    if ( inrange(place,ticmin,ticmax) )
		 xtick(place, xformat, spacing, 1.0, ypos);
	}
}

/* DRAW_SERIES_3DYTICS: draw a user tic series, y axis */
static draw_series_3dytics(start, incr, end, xpos)
		double start, incr, end, xpos; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace, place;
	double ticmin, ticmax;	/* for checking if tic is almost inrange */
	double spacing = log_y ? log10(incr) : incr;

	if (end == VERYLARGE)
		end = max(CheckLog(log_y, y_min3d), CheckLog(log_y, y_max3d));
	else
	  /* limit to right side of plot */
	  end = min(end, max(CheckLog(log_y, y_min3d), CheckLog(log_y, y_max3d)));

	/* to allow for rounding errors */
	ticmin = min(y_min3d,y_max3d) - SIGNIF*incr;
	ticmax = max(y_min3d,y_max3d) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
	    place = (log_y ? log10(ticplace) : ticplace);
	    if ( inrange(place,ticmin,ticmax) )
		 ytick(place, xformat, spacing, 1.0, xpos);
	}
}

/* DRAW_SERIES_3DZTICS: draw a user tic series, z axis */
static draw_series_3dztics(start, incr, end, xpos, ypos, z_min, z_max)
		double start, incr, end; /* tic series definition */
		double xpos, ypos, z_min, z_max;
		/* assume start < end, incr > 0 */
{
	int x, y;
	double ticplace, place;
	double ticmin, ticmax;	/* for checking if tic is almost inrange */
	double spacing = log_x ? log10(incr) : incr;
	register struct termentry *t = &term_tbl[term];

	if (end == VERYLARGE)
		end = max(CheckLog(log_z, z_min), CheckLog(log_z, z_max));
	else
	  /* limit to right side of plot */
	  end = min(end, max(CheckLog(log_z, z_min), CheckLog(log_z, z_max)));

	/* to allow for rounding errors */
	ticmin = min(z_min,z_max) - SIGNIF*incr;
	ticmax = max(z_min,z_max) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
	    place = (log_z ? log10(ticplace) : ticplace);
	    if ( inrange(place,ticmin,ticmax) )
		 ztick(place, zformat, spacing, 1.0, xpos, ypos);
	}

	/* Make sure the vertical line is fully drawn. */
	setlinestyle(-2);	/* axis line type */

	map3d_xy(xpos, ypos, z_min3d, &x, &y);
	clip_move(x,y);
	map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
	clip_vector(x,y);

	setlinestyle(-1); /* border linetype */
}

/* DRAW_SET_3DXTICS: draw a user tic set, x axis */
static draw_set_3dxtics(list, ypos)
	struct ticmark *list;	/* list of tic marks */
	double ypos;
{
    double ticplace;
    double incr = (x_max3d - x_min3d) / 10;
    /* global x_min3d, x_max3d, xscale, y_min3d, y_max3d, yscale */

    while (list != NULL) {
	   ticplace = (log_x ? log10(list->position) : list->position);
	   if ( inrange(ticplace, x_min3d, x_max3d) 		/* in range */
		  || NearlyEqual(ticplace, x_min3d, incr)	/* == x_min */
		  || NearlyEqual(ticplace, x_max3d, incr))	/* == x_max */
		xtick(ticplace, list->label, incr, 1.0, ypos);

	   list = list->next;
    }
}

/* DRAW_SET_3DYTICS: draw a user tic set, y axis */
static draw_set_3dytics(list, xpos)
	struct ticmark *list;	/* list of tic marks */
	double xpos;
{
    double ticplace;
    double incr = (y_max3d - y_min3d) / 10;
    /* global x_min3d, x_max3d, xscale, y_min3d, y_max3d, yscale */

    while (list != NULL) {
	   ticplace = (log_y ? log10(list->position) : list->position);
	   if ( inrange(ticplace, y_min3d, y_max3d) 		  /* in range */
		  || NearlyEqual(ticplace, y_min3d, incr)	/* == y_min3d */
		  || NearlyEqual(ticplace, y_max3d, incr))	/* == y_max3d */
		ytick(ticplace, list->label, incr, 1.0, xpos);

	   list = list->next;
    }
}

/* DRAW_SET_3DZTICS: draw a user tic set, z axis */
static draw_set_3dztics(list, xpos, ypos, z_min, z_max)
	struct ticmark *list;	/* list of tic marks */
	double xpos, ypos, z_min, z_max;
{
    int x, y;
    double ticplace;
    double incr = (z_max - z_min) / 10;
    register struct termentry *t = &term_tbl[term];

    while (list != NULL) {
	   ticplace = (log_z ? log10(list->position) : list->position);
	   if ( inrange(ticplace, z_min, z_max) 		/* in range */
		  || NearlyEqual(ticplace, z_min, incr)		/* == z_min */
		  || NearlyEqual(ticplace, z_max, incr))	/* == z_max */
		ztick(ticplace, list->label, incr, 1.0, xpos, ypos);

	   list = list->next;
    }

    /* Make sure the vertical line is fully drawn. */
    setlinestyle(-2);	/* axis line type */

    map3d_xy(xpos, ypos, z_min, &x, &y);
    clip_move(x,y);
    map3d_xy(xpos, ypos, z_max+(log_z ? incr : 0.0), &x, &y);
    clip_vector(x,y);

    setlinestyle(-1); /* border linetype */
}

/* draw and label a x-axis ticmark */
static xtick(place, text, spacing, ticscale, ypos)
        double place;                   /* where on axis to put it */
        char *text;                     /* optional text label */
        double spacing;         /* something to use with checkzero */
        double ticscale;         /* scale factor for tic mark (0..1] */
	double ypos;
{
    register struct termentry *t = &term_tbl[term];
    char ticlabel[101];
    int x0,y0,x1,y1,x2,y2,x3,y3;
    int ticsize = (int)((t->h_tic) * ticscale);
    double v[2], len;

    place = CheckZero(place,spacing); /* to fix rounding error near zero */

    if (place > x_max3d || place < x_min3d) return;

    map3d_xy(place, ypos, z_min3d, &x0, &y0);
    /* need to figure out which is in. pick the middle point along the */
    /* axis as in.						       */
    map3d_xy(place, (y_max3d + y_min3d) / 2, z_min3d, &x1, &y1);

    /* compute a vector of length 1 into the grid: */
    v[0] = x1 - x0;
    v[1] = y1 - y0;
    len = sqrt(v[0] * v[0] + v[1] * v[1]);
    v[0] /= len;
    v[1] /= len;

    if (tic_in) {
	x1 = x0;
	y1 = y0;
	x2 = x1 + ((int) (v[0] * ticsize));
	y2 = y1 + ((int) (v[1] * ticsize));
    	x3 = x0 - ((int) (v[0] * ticsize * 3)); /* compute text position */
    	y3 = y0 - ((int) (v[1] * ticsize * 3));
    } else {
	x1 = x0;
	y1 = y0;
	x2 = x0 - ((int) (v[0] * ticsize));
	y2 = y0 - ((int) (v[1] * ticsize));
    	x3 = x0 - ((int) (v[0] * ticsize * 4)); /* compute text position */
    	y3 = y0 - ((int) (v[1] * ticsize * 4));
    }
    clip_move(x1,y1);
    clip_vector(x2,y2);

    /* label the ticmark */
    if (text == NULL)
	 text = xformat;

    (void) sprintf(ticlabel, text, CheckLog(log_x, place));
    if (apx_eq(v[0], 0.0)) {
    	if ((*t->justify_text)(CENTRE)) {
    	    clip_put_text(x3,y3,ticlabel);
    	} else {
    	    clip_put_text(x3-(t->h_char)*strlen(ticlabel)/2,y3,ticlabel);
    	}
    }
    else if (v[0] > 0) {
    	if ((*t->justify_text)(RIGHT)) {
    	    clip_put_text(x3,y3,ticlabel);
    	} else {
    	    clip_put_text(x3-(t->h_char)*strlen(ticlabel),y3,ticlabel);
    	}
    } else {
    	(*t->justify_text)(LEFT);
	clip_put_text(x3,y3,ticlabel);
    }
}

/* draw and label a y-axis ticmark */
static ytick(place, text, spacing, ticscale, xpos)
        double place;                   /* where on axis to put it */
        char *text;                     /* optional text label */
        double spacing;         /* something to use with checkzero */
        double ticscale;         /* scale factor for tic mark (0..1] */
	double xpos;
{
    register struct termentry *t = &term_tbl[term];
    char ticlabel[101];
    int x0,y0,x1,y1,x2,y2,x3,y3;
    int ticsize = (int)((t->h_tic) * ticscale);
    double v[2], len;

    place = CheckZero(place,spacing); /* to fix rounding error near zero */

    if (place > y_max3d || place < y_min3d) return;

    map3d_xy(xpos, place, z_min3d, &x0, &y0);
    /* need to figure out which is in. pick the middle point along the */
    /* axis as in.						       */
    map3d_xy((x_max3d + x_min3d) / 2, place, z_min3d, &x1, &y1);

    /* compute a vector of length 1 into the grid: */
    v[0] = x1 - x0;
    v[1] = y1 - y0;
    len = sqrt(v[0] * v[0] + v[1] * v[1]);
    v[0] /= len;
    v[1] /= len;

    if (tic_in) {
	x1 = x0;
	y1 = y0;
	x2 = x1 + ((int) (v[0] * ticsize));
	y2 = y1 + ((int) (v[1] * ticsize));
    	x3 = x0 - ((int) (v[0] * ticsize * 3)); /* compute text position */
    	y3 = y0 - ((int) (v[1] * ticsize * 3));
    } else {
	x1 = x0;
	y1 = y0;
	x2 = x0 - ((int) (v[0] * ticsize));
	y2 = y0 - ((int) (v[1] * ticsize));
    	x3 = x0 - ((int) (v[0] * ticsize * 4)); /* compute text position */
    	y3 = y0 - ((int) (v[1] * ticsize * 4));
    }
    clip_move(x1,y1);
    clip_vector(x2,y2);

    /* label the ticmark */
    if (text == NULL)
	 text = yformat;

    (void) sprintf(ticlabel, text, CheckLog(log_y, place));
    if (apx_eq(v[0], 0.0)) {
    	if ((*t->justify_text)(CENTRE)) {
    	    clip_put_text(x3,y3,ticlabel);
    	} else {
    	    clip_put_text(x3-(t->h_char)*strlen(ticlabel)/2,y3,ticlabel);
    	}
    }
    else if (v[0] > 0) {
    	if ((*t->justify_text)(RIGHT)) {
    	    clip_put_text(x3,y3,ticlabel);
    	} else {
    	    clip_put_text(x3-(t->h_char)*strlen(ticlabel),y3,ticlabel);
    	}
    } else {
    	(*t->justify_text)(LEFT);
	clip_put_text(x3,y3,ticlabel);
    }
}

/* draw and label a z-axis ticmark */
static ztick(place, text, spacing, ticscale, xpos, ypos)
        double place;                   /* where on axis to put it */
        char *text;                     /* optional text label */
        double spacing;         /* something to use with checkzero */
        double ticscale;         /* scale factor for tic mark (0..1] */
	double xpos, ypos;
{
    register struct termentry *t = &term_tbl[term];
    char ticlabel[101];
    int x0,y0,x1,y1,x2,y2,x3,y3;
    int ticsize = (int)((t->h_tic) * ticscale);

    place = CheckZero(place,spacing); /* to fix rounding error near zero */

    map3d_xy(xpos, ypos, place, &x0, &y0);

    if (tic_in) {
	x1 = x0;
	y1 = y0;
	x2 = x0 + ticsize;
	y2 = y0;
    	x3 = x0 - ticsize;
    	y3 = y0;
    } else {
	x1 = x0;
	y1 = y0;
	x2 = x0 - ticsize;
	y2 = y0;
    	x3 = x0 - ticsize * 2; /* compute text position */
    	y3 = y0;
    }
    clip_move(x1,y1);
    clip_vector(x2,y2);

    /* label the ticmark */
    if (text == NULL)
	 text = zformat;

    (void) sprintf(ticlabel, text, CheckLog(log_z, place));
    if ((*t->justify_text)(RIGHT)) {
        clip_put_text(x3,y3,ticlabel);
    } else {
        clip_put_text(x3-(t->h_char)*(strlen(ticlabel)+1),y3,ticlabel);
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/graphics.c version [7771093f05].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
#ifndef lint
static char *RCSid = "$Id: graphics.c,v 3.26 92/03/24 22:34:25 woo Exp Locker: woo $";
#endif

/* GNUPLOT - graphics.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <time.h>
#include "plot.h"
#include "setshow.h"

extern char *strcpy(),*strncpy(),*strcat(),*ctime();
char *tdate;
#ifdef AMIGA_AC_5
time_t dated;
#else
#ifdef VMS
time_t dated,time();
#else
long dated,time();
#endif
#endif

void plot_impulses();
void plot_lines();
void plot_points();
void plot_dots();
void plot_bars();
void edge_intersect();
BOOLEAN two_edge_intersect();

/* for plotting error bars */
#define ERRORBARTIC (t->h_tic/2) /* half the width of error bar tic mark */

#ifndef max		/* Lattice C has max() in math.h, but shouldn't! */
#define max(a,b) ((a > b) ? a : b)
#endif

#ifndef min
#define min(a,b) ((a < b) ? a : b)
#endif

#define inrange(z,min,max) ((min<max) ? ((z>=min)&&(z<=max)) : ((z>=max)&&(z<=min)) )

/* True if a and b have the same sign or zero (positive or negative) */
#define samesign(a,b) ((a) * (b) >= 0)

/* Define the boundary of the plot
 * These are computed at each call to do_plot, and are constant over
 * the period of one do_plot. They actually only change when the term
 * type changes and when the 'set size' factors change. 
 */
static int xleft, xright, ybot, ytop;

/* Boundary and scale factors, in user coordinates */
/* x_min, x_max, y_min, y_max are local to this file and
 * are not the same as variables of the same names in other files
 */
static double x_min, x_max, y_min, y_max;
static double xscale, yscale;

/* And the functions to map from user to terminal coordinates */
#define map_x(x) (int)(xleft+(x-x_min)*xscale+0.5) /* maps floating point x to screen */ 
#define map_y(y) (int)(ybot+(y-y_min)*yscale+0.5)	/* same for y */

/* (DFK) Watch for cancellation error near zero on axes labels */
#define SIGNIF (0.01)		/* less than one hundredth of a tic mark */
#define CheckZero(x,tic) (fabs(x) < ((tic) * SIGNIF) ? 0.0 : (x))
#define NearlyEqual(x,y,tic) (fabs((x)-(y)) < ((tic) * SIGNIF))

/* (DFK) For some reason, the Sun386i compiler screws up with the CheckLog 
 * macro, so I write it as a function on that machine.
 */
#ifndef sun386
/* (DFK) Use 10^x if logscale is in effect, else x */
#define CheckLog(log, x) ((log) ? pow(10., (x)) : (x))
#else
static double
CheckLog(log, x)
     BOOLEAN log;
     double x;
{
  if (log)
    return(pow(10., x));
  else
    return(x);
}
#endif /* sun386 */

double
LogScale(coord, islog, what, axis)
	double coord;			/* the value */
	BOOLEAN islog;			/* is this axis in logscale? */
	char *what;			/* what is the coord for? */
	char *axis;			/* which axis is this for ("x" or "y")? */
{
    if (islog) {
	   if (coord <= 0.0) {
		  char errbuf[100];		/* place to write error message */
		(void) sprintf(errbuf,"%s has %s coord of %g; must be above 0 for log scale!",
				what, axis, coord);
		  (*term_tbl[term].text)();
		  (void) fflush(outfile);
		  int_error(errbuf, NO_CARET);
	   } else
		return(log10(coord));
    }
    return(coord);
}

/* borders of plotting area */
/* computed once on every call to do_plot */
boundary(scaling)
	BOOLEAN scaling;		/* TRUE if terminal is doing the scaling */
{
    register struct termentry *t = &term_tbl[term];
    xleft = (t->h_char)*12;
    xright = (scaling ? 1 : xsize) * (t->xmax) - (t->h_char)*2 - (t->h_tic);
    ybot = (t->v_char)*7/2 + 1;
    ytop = (scaling ? 1 : ysize) * (t->ymax) - (t->v_char)*5/2 - 1;
}


double dbl_raise(x,y)
double x;
int y;
{
register int i;
double val;

	val = 1.0;
	for (i=0; i < abs(y); i++)
		val *= x;
	if (y < 0 ) return (1.0/val);
	return(val);
}


double make_tics(tmin,tmax,logscale)
double tmin,tmax;
BOOLEAN logscale;
{
register double xr,xnorm,tics,tic,l10;

	xr = fabs(tmin-tmax);
	
	l10 = log10(xr);
	if (logscale) {
		tic = dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
		if (tic < 1.0)
			tic = 1.0;
	} else {
		xnorm = pow(10.0,l10-(double)((l10 >= 0.0 ) ? (int)l10 : ((int)l10-1)));
		if (xnorm <= 2)
			tics = 0.2;
		else if (xnorm <= 5)
			tics = 0.5;
		else tics = 1.0;	
		tic = tics * dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
	}
	return(tic);
}


do_plot(plots, pcount, min_x, max_x, min_y, max_y)
struct curve_points *plots;
int pcount;			/* count of plots in linked list */
double min_x, max_x;
double min_y, max_y;
{
register struct termentry *t = &term_tbl[term];
register int curve, xaxis_y, yaxis_x;
register struct curve_points *this_plot;
register double ytic, xtic;
register int xl, yl;
			/* only a Pyramid would have this many registers! */
double xtemp, ytemp;
struct text_label *this_label;
struct arrow_def *this_arrow;
BOOLEAN scaling;

/* store these in variables global to this file */
/* otherwise, we have to pass them around a lot */
     x_min = min_x;
     x_max = max_x; 
     y_min = min_y;
     y_max = max_y;

	if (polar) {
	    /* will possibly change x_min, x_max, y_min, y_max */
	    polar_xform(plots,pcount);
	}

	if (y_min == VERYLARGE || y_max == -VERYLARGE ||
	    x_min == VERYLARGE || x_max == -VERYLARGE)
		int_error("all points undefined!", NO_CARET);

/*	Apply the desired viewport offsets. */
     if (y_min < y_max) {
	    y_min -= boff;
	    y_max += toff;
	} else {
	    y_max -= boff;
	    y_min += toff;
	}
     if (x_min < x_max) {
	    x_min -= loff;
	    x_max += roff;
	} else {
	    x_max -= loff;
	    x_min += roff;
	}

/* SETUP RANGES, SCALES AND TIC PLACES */
    if (ytics && yticdef.type == TIC_COMPUTED) {
	   ytic = make_tics(y_min,y_max,log_y);
    
	   if (autoscale_ly) {
		  if (y_min < y_max) {
			 y_min = ytic * floor(y_min/ytic);       
			 y_max = ytic * ceil(y_max/ytic);
		  }
		  else {			/* reverse axis */
			 y_min = ytic * ceil(y_min/ytic);       
			 y_max = ytic * floor(y_max/ytic);
		  }
	   }
    }

    if (xtics && xticdef.type == TIC_COMPUTED) {
	   xtic = make_tics(x_min,x_max,log_x);
	   
	   if (autoscale_lx) {
		  if (x_min < x_max) {
			 x_min = xtic * floor(x_min/xtic);	
			 x_max = xtic * ceil(x_max/xtic);
		  } else {
			 x_min = xtic * ceil(x_min/xtic);
			 x_max = xtic * floor(x_max/xtic);	
		  }
	   }
    }

/*	This used be x_max == x_min, but that caused an infinite loop once. */
	if (fabs(x_max - x_min) < zero)
		int_error("x_min should not equal x_max!",NO_CARET);
	if (fabs(y_max - y_min) < zero)
		int_error("y_min should not equal y_max!",NO_CARET);

/* INITIALIZE TERMINAL */
	if (!term_init) {
		(*t->init)();
		term_init = TRUE;
	}
	screen_ok = FALSE;
#ifdef AMIGA_LC_5_1
     scaling = (*t->scale)((double)xsize, (double)ysize);
#else
     scaling = (*t->scale)(xsize, ysize);
#endif
	(*t->graphics)();

     /* now compute boundary for plot (xleft, xright, ytop, ybot) */
     boundary(scaling);

/* SCALE FACTORS */
	yscale = (ytop - ybot)/(y_max - y_min);
	xscale = (xright - xleft)/(x_max - x_min);
	
/* DRAW AXES */
	(*t->linetype)(-1);	/* axis line type */
	xaxis_y = map_y(0.0);
	yaxis_x = map_x(0.0); 

	if (xaxis_y < ybot)
		xaxis_y = ybot;				/* save for impulse plotting */
	else if (xaxis_y >= ytop)
		xaxis_y = ytop ;
	else if (xzeroaxis && !log_y) {
		(*t->move)(xleft,xaxis_y);
		(*t->vector)(xright,xaxis_y);
	}

	if (yzeroaxis && !log_x && yaxis_x >= xleft && yaxis_x < xright ) {
		(*t->move)(yaxis_x,ybot);
		(*t->vector)(yaxis_x,ytop);
	}

/* DRAW TICS */
	(*t->linetype)(-2); /* border linetype */

    /* label y axis tics */
     if (ytics) {
	    switch (yticdef.type) {
		   case TIC_COMPUTED: {
 			  if (y_min < y_max)
			    draw_ytics(ytic * floor(y_min/ytic),
						ytic,
						ytic * ceil(y_max/ytic));
			  else
			    draw_ytics(ytic * floor(y_max/ytic),
						ytic,
						ytic * ceil(y_min/ytic));

			  break;
		   }
		   case TIC_SERIES: {
			  draw_series_ytics(yticdef.def.series.start, 
							yticdef.def.series.incr, 
							yticdef.def.series.end);
			  break;
		   }
		   case TIC_USER: {
			  draw_set_ytics(yticdef.def.user);
			  break;
		   }
		   default: {
			  (*t->text)();
	  		  (void) fflush(outfile);
			  int_error("unknown tic type in yticdef in do_plot", NO_CARET);
			  break;		/* NOTREACHED */
		   }
	    }
	}

    /* label x axis tics */
     if (xtics) {
	    switch (xticdef.type) {
		   case TIC_COMPUTED: {
 			  if (x_min < x_max)
			    draw_xtics(xtic * floor(x_min/xtic),
						xtic,
						xtic * ceil(x_max/xtic));
			  else
			    draw_xtics(xtic * floor(x_max/xtic),
						xtic,
						xtic * ceil(x_min/xtic));

			  break;
		   }
		   case TIC_SERIES: {
			  draw_series_xtics(xticdef.def.series.start, 
							xticdef.def.series.incr, 
							xticdef.def.series.end);
			  break;
		   }
		   case TIC_USER: {
			  draw_set_xtics(xticdef.def.user);
			  break;
		   }
		   default: {
			  (*t->text)();
			  (void) fflush(outfile);
			  int_error("unknown tic type in xticdef in do_plot", NO_CARET);
			  break;		/* NOTREACHED */
		   }
	    }
	}

/* DRAW PLOT BORDER */
	(*t->linetype)(-2); /* border linetype */
	if (draw_border) {
		(*t->move)(xleft,ybot);
		(*t->vector)(xright,ybot);
		(*t->vector)(xright,ytop);
		(*t->vector)(xleft,ytop);
		(*t->vector)(xleft,ybot);
	}

/* PLACE YLABEL */
	if (strlen(ylabel) > 0) {
		int x, y;

		x = ylabel_xoffset * t->h_char;
		y = ylabel_yoffset * t->v_char;
		if ((*t->text_angle)(1)) {
			if ((*t->justify_text)(CENTRE)) {
				(*t->put_text)(x+(t->v_char),
						 y+(ytop+ybot)/2, ylabel);
			}
			else {
				(*t->put_text)(x+(t->v_char),
					       y+(ytop+ybot)/2-(t->h_char)*strlen(ylabel)/2, 
						 ylabel);
			}
		}
		else {
			(void)(*t->justify_text)(LEFT);
			(*t->put_text)(x,y+ytop+(t->v_char), ylabel);
		}
		(void)(*t->text_angle)(0);
	}

/* PLACE XLABEL */
    if (strlen(xlabel) > 0) {
		int x, y;

		x = xlabel_xoffset * t->h_char;
		y = xlabel_yoffset * t->v_char;

    		if ((*t->justify_text)(CENTRE)) 
			(*t->put_text)(x+(xleft+xright)/2,
				       y+ybot-2*(t->v_char), xlabel);
    		else
			(*t->put_text)(x+(xleft+xright)/2 - strlen(xlabel)*(t->h_char)/2,
    				       y+ybot-2*(t->v_char), xlabel);
    }

/* PLACE TITLE */
    if (strlen(title) > 0) {
		int x, y;

		x = title_xoffset * t->h_char;
		y = title_yoffset * t->v_char;

    		if ((*t->justify_text)(CENTRE))
			(*t->put_text)(x+(xleft+xright)/2,
				       y+ytop+(t->v_char), title);
    		else
			(*t->put_text)(x+(xleft+xright)/2 - strlen(title)*(t->h_char)/2,
				       y+ytop+(t->v_char), title);
    }


/* PLACE TIMEDATE */
	if (timedate) {
		int x, y;

		x = time_xoffset * t->h_char;
		y = time_yoffset * t->v_char;
		dated = time( (long *) 0);
		tdate = ctime( &dated);
		tdate[24]='\0';
		if ((*t->text_angle)(1)) {
			if ((*t->justify_text)(CENTRE)) {
				(*t->put_text)(x+(t->v_char),
						 y+ybot+4*(t->v_char), tdate);
			}
			else {
				(*t->put_text)(x+(t->v_char),
						 y+ybot+4*(t->v_char)-(t->h_char)*strlen(ylabel)/2, 
						 tdate);
			}
		}
		else {
			(void)(*t->justify_text)(LEFT);
			(*t->put_text)(x,
						 y+ybot-3*(t->v_char), tdate);
		}
		(void)(*t->text_angle)(0);
	}

/* PLACE LABELS */
    for (this_label = first_label; this_label!=NULL;
			this_label=this_label->next ) {
	     xtemp = LogScale(this_label->x, log_x, "label", "x");
	     ytemp = LogScale(this_label->y, log_y, "label", "y");
		if ((*t->justify_text)(this_label->pos)) {
			(*t->put_text)(map_x(xtemp),map_y(ytemp),this_label->text);
		}
		else {
			switch(this_label->pos) {
				case  LEFT:
					(*t->put_text)(map_x(xtemp),map_y(ytemp),
						this_label->text);
					break;
				case CENTRE:
					(*t->put_text)(map_x(xtemp)-
						(t->h_char)*strlen(this_label->text)/2,
						map_y(ytemp), this_label->text);
					break;
				case RIGHT:
					(*t->put_text)(map_x(xtemp)-
						(t->h_char)*strlen(this_label->text),
						map_y(ytemp), this_label->text);
					break;
			}
		 }
	 }

/* PLACE ARROWS */
    (*t->linetype)(0);	/* arrow line type */
    for (this_arrow = first_arrow; this_arrow!=NULL;
	    this_arrow = this_arrow->next ) {
	   int sx = map_x(LogScale(this_arrow->sx, log_x, "arrow", "x"));
	   int sy = map_y(LogScale(this_arrow->sy, log_y, "arrow", "y"));
	   int ex = map_x(LogScale(this_arrow->ex, log_x, "arrow", "x"));
	   int ey = map_y(LogScale(this_arrow->ey, log_y, "arrow", "y"));
	   
	   (*t->arrow)(sx, sy, ex, ey, this_arrow->head);
    }


/* DRAW CURVES */
	if (key == -1) {
	    xl = xright  - (t->h_tic) - (t->h_char)*5;
	    yl = ytop - (t->v_tic) - (t->v_char);
	}
	if (key == 1) {
	    xl = map_x( LogScale(key_x, log_x, "key", "x") );
	    yl = map_y( LogScale(key_y, log_y, "key", "y") );
	}

	this_plot = plots;
	for (curve = 0; curve < pcount; this_plot = this_plot->next_cp, curve++) {
		(*t->linetype)(this_plot->line_type);
		if (key != 0) {
			if ((*t->justify_text)(RIGHT)) {
				(*t->put_text)(xl,
					yl,this_plot->title);
			}
			else {
			    if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
						 xleft, xright))
				 (*t->put_text)(xl-(t->h_char)*strlen(this_plot->title),
							 yl,this_plot->title);
			}
		}

		switch(this_plot->plot_style) {
		    case IMPULSES: {
			   if (key != 0) {
				  (*t->move)(xl+(t->h_char),yl);
				  (*t->vector)(xl+4*(t->h_char),yl);
			   }
			   plot_impulses(this_plot, yaxis_x, xaxis_y);
			   break;
		    }
		    case LINES: {
			   if (key != 0) {
				  (*t->move)(xl+(int)(t->h_char),yl);
				  (*t->vector)(xl+(int)(4*(t->h_char)),yl);
			   }
			   plot_lines(this_plot);
			   break;
		    }
		    case POINTS: {
			   if (key != 0) {
				  (*t->point)(xl+2*(t->h_char),yl,
						    this_plot->point_type);
			   }
			   plot_points(this_plot);
			   break;
		    }
		    case LINESPOINTS: {
			   /* put lines */
			   if (key != 0) {
				  (*t->move)(xl+(t->h_char),yl);
				  (*t->vector)(xl+4*(t->h_char),yl);
			   }
			   plot_lines(this_plot);

			   /* put points */
			   if (key != 0) {
				  (*t->point)(xl+2*(t->h_char),yl,
						    this_plot->point_type);
			   }
			   plot_points(this_plot);
			   break;
		    }
		    case DOTS: {
			   if (key != 0) {
				  (*t->point)(xl+2*(t->h_char),yl, -1);
			   }
			   plot_dots(this_plot);
			   break;
		    }
		    case ERRORBARS: {
			   if (key != 0) {
				  (*t->point)(xl+2*(t->h_char),yl,
						    this_plot->point_type);
			   }
			   plot_points(this_plot);

			   /* for functions, just like POINTS */
			   if (this_plot->plot_type == DATA) {
				  if (key != 0) {
					 (*t->move)(xl+(t->h_char),yl);
					 (*t->vector)(xl+4*(t->h_char),yl);
					 (*t->move)(xl+(t->h_char),yl+ERRORBARTIC);
					 (*t->vector)(xl+(t->h_char),yl-ERRORBARTIC);
					 (*t->move)(xl+4*(t->h_char),yl+ERRORBARTIC);
					 (*t->vector)(xl+4*(t->h_char),yl-ERRORBARTIC);
				  }
				  plot_bars(this_plot);
			   }
			   break;
		    }
		}
		yl = yl - (t->v_char);
	}
	(*t->text)();
	(void) fflush(outfile);
}

/* plot_impulses:
 * Plot the curves in IMPULSES style
 */
void
plot_impulses(plot, yaxis_x, xaxis_y)
	struct curve_points *plot;
	int yaxis_x, xaxis_y;
{
    int i;
    int x,y;
    struct termentry *t = &term_tbl[term];

    for (i = 0; i < plot->p_count; i++) {
	   switch (plot->points[i].type) {
		  case INRANGE: {
			 x = map_x(plot->points[i].x);
			 y = map_y(plot->points[i].y);
			 break;
		  }
		  case OUTRANGE: {
			 if (!inrange(plot->points[i].x, x_min,x_max))
			   continue;
			 x = map_x(plot->points[i].x);
			 if ((y_min < y_max 
				 && plot->points[i].y < y_min)
				|| (y_max < y_min 
				    && plot->points[i].y > y_min))
			   y = map_y(y_min);
			 if ((y_min < y_max 
				 && plot->points[i].y > y_max)
				|| (y_max<y_min 
				    && plot->points[i].y < y_max))
			   y = map_y(y_max);
			 break;
		  }
		  default:		/* just a safety */
		  case UNDEFINED: {
			 continue;
		  }
	   }
				    
	   if (polar)
	      (*t->move)(yaxis_x,xaxis_y);
	   else
	      (*t->move)(x,xaxis_y);
	   (*t->vector)(x,y);
    }

}

/* plot_lines:
 * Plot the curves in LINES style
 */
void
plot_lines(plot)
	struct curve_points *plot;
{
    int i;				/* point index */
    int x,y;				/* point in terminal coordinates */
    struct termentry *t = &term_tbl[term];
    enum coord_type prev = UNDEFINED; /* type of previous point */
    double ex, ey;			/* an edge point */
    double lx[2], ly[2];		/* two edge points */

    for (i = 0; i < plot->p_count; i++) {
	   switch (plot->points[i].type) {
		  case INRANGE: {
			 x = map_x(plot->points[i].x);
			 y = map_y(plot->points[i].y);

			 if (prev == INRANGE) {
				(*t->vector)(x,y);
			 } else if (prev == OUTRANGE) {
				/* from outrange to inrange */
				if (!clip_lines1) {
				    (*t->move)(x,y);
				} else {
				    edge_intersect(plot->points, i, &ex, &ey);
				    (*t->move)(map_x(ex), map_y(ey));
				    (*t->vector)(x,y);
				}
			 } else {		/* prev == UNDEFINED */
				(*t->move)(x,y);
				(*t->vector)(x,y);
			 }
				    
			 break;
		  }
		  case OUTRANGE: {
			 if (prev == INRANGE) {
				/* from inrange to outrange */
				if (clip_lines1) {
				    edge_intersect(plot->points, i, &ex, &ey);
				    (*t->vector)(map_x(ex), map_y(ey));
				}
			 } else if (prev == OUTRANGE) {
				/* from outrange to outrange */
				if (clip_lines2) {
				    if (two_edge_intersect(plot->points, i, lx, ly)) {
					   (*t->move)(map_x(lx[0]), map_y(ly[0]));
					   (*t->vector)(map_x(lx[1]), map_y(ly[1]));
				    }
				}
			 }
			 break;
		  }
		  default:		/* just a safety */
		  case UNDEFINED: {
			 break;
		  }
	   }
	   prev = plot->points[i].type;
    }
}

/* plot_bars:
 * Plot the curves in ERRORBARS style
 *  we just plot the bars; the points are plotted in plot_points
 */
void
plot_bars(plot)
	struct curve_points *plot;
{
    int i;				/* point index */
    struct termentry *t = &term_tbl[term];
    double x;				/* position of the bar */
    double ylow, yhigh;		/* the ends of the bars */
    unsigned int xM, ylowM, yhighM; /* the mapped version of above */
    BOOLEAN low_inrange, high_inrange;
    int tic = ERRORBARTIC;
    
    for (i = 0; i < plot->p_count; i++) {
	   /* undefined points don't count */
	   if (plot->points[i].type == UNDEFINED)
		continue;

	   /* check to see if in xrange */
	   x = plot->points[i].x;
	   if (! inrange(x, x_min, x_max))
		continue;
	   xM = map_x(x);

	   /* find low and high points of bar, and check yrange */
	   yhigh = plot->points[i].yhigh;
	   ylow = plot->points[i].ylow;

	   high_inrange = inrange(yhigh, y_min,y_max);
	   low_inrange = inrange(ylow, y_min,y_max);

	   /* compute the plot position of yhigh */
	   if (high_inrange)
		yhighM = map_y(yhigh);
	   else if (samesign(yhigh-y_max, y_max-y_min))
		yhighM = map_y(y_max);
	   else
		yhighM = map_y(y_min);
	   
	   /* compute the plot position of ylow */
	   if (low_inrange)
		ylowM = map_y(ylow);
	   else if (samesign(ylow-y_max, y_max-y_min))
		ylowM = map_y(y_max);
	   else
		ylowM = map_y(y_min);

	   if (!high_inrange && !low_inrange && ylowM == yhighM)
		/* both out of range on the same side */
		  continue;

	   /* by here everything has been mapped */
	   (*t->move)(xM, ylowM);
	   (*t->vector)(xM, yhighM); /* draw the main bar */
	   (*t->move)(xM-tic, ylowM); /* draw the bottom tic */
	   (*t->vector)(xM+tic, ylowM);
	   (*t->move)(xM-tic, yhighM); /* draw the top tic */
	   (*t->vector)(xM+tic, yhighM);
    }
}

/* plot_points:
 * Plot the curves in POINTS style
 */
void
plot_points(plot)
	struct curve_points *plot;
{
    int i;
    int x,y;
    struct termentry *t = &term_tbl[term];

    for (i = 0; i < plot->p_count; i++) {
	   if (plot->points[i].type == INRANGE) {
		  x = map_x(plot->points[i].x);
		  y = map_y(plot->points[i].y);
		  /* do clipping if necessary */
		  if (!clip_points ||
			 (   x >= xleft + t->h_tic  && y >= ybot + t->v_tic 
			  && x <= xright - t->h_tic && y <= ytop - t->v_tic))
		    (*t->point)(x,y, plot->point_type);
	   }
    }
}

/* plot_dots:
 * Plot the curves in DOTS style
 */
void
plot_dots(plot)
	struct curve_points *plot;
{
    int i;
    int x,y;
    struct termentry *t = &term_tbl[term];

    for (i = 0; i < plot->p_count; i++) {
	   if (plot->points[i].type == INRANGE) {
		  x = map_x(plot->points[i].x);
		  y = map_y(plot->points[i].y);
		  /* point type -1 is a dot */
		  (*t->point)(x,y, -1);
	   }
    }
}

/* single edge intersection algorithm */
/* Given two points, one inside and one outside the plot, return
 * the point where an edge of the plot intersects the line segment defined 
 * by the two points.
 */
void
edge_intersect(points, i, ex, ey)
	struct coordinate *points; /* the points array */
	int i;				/* line segment from point i-1 to point i */
	double *ex, *ey;		/* the point where it crosses an edge */
{
    /* global x_min, x_max, y_min, x_max */
    double ax = points[i-1].x;
    double ay = points[i-1].y;
    double bx = points[i].x;
    double by = points[i].y;
    double x, y;			/* possible intersection point */

    if (by == ay) {
	   /* horizontal line */
	   /* assume inrange(by, y_min, y_max) */
	   *ey = by;		/* == ay */

	   if (inrange(x_max, ax, bx))
		*ex = x_max;
	   else if (inrange(x_min, ax, bx))
		*ex = x_min;
	   else {
		(*term_tbl[term].text)();
	    (void) fflush(outfile);
		int_error("error in edge_intersect", NO_CARET);
	   }
	   return;
    } else if (bx == ax) {
	   /* vertical line */
	   /* assume inrange(bx, x_min, x_max) */
	   *ex = bx;		/* == ax */

	   if (inrange(y_max, ay, by))
		*ey = y_max;
	   else if (inrange(y_min, ay, by))
		*ey = y_min;
	   else {
		(*term_tbl[term].text)();
	    (void) fflush(outfile);
		int_error("error in edge_intersect", NO_CARET);
	   }
	   return;
    }

    /* slanted line of some kind */

    /* does it intersect y_min edge */
    if (inrange(y_min, ay, by) && y_min != ay && y_min != by) {
	   x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
	   if (inrange(x, x_min, x_max)) {
		  *ex = x;
		  *ey = y_min;
		  return;			/* yes */
	   }
    }
    
    /* does it intersect y_max edge */
    if (inrange(y_max, ay, by) && y_max != ay && y_max != by) {
	   x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
	   if (inrange(x, x_min, x_max)) {
		  *ex = x;
		  *ey = y_max;
		  return;			/* yes */
	   }
    }

    /* does it intersect x_min edge */
    if (inrange(x_min, ax, bx) && x_min != ax && x_min != bx) {
	   y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
	   if (inrange(y, y_min, y_max)) {
		  *ex = x_min;
		  *ey = y;
		  return;
	   }
    }

    /* does it intersect x_max edge */
    if (inrange(x_max, ax, bx) && x_max != ax && x_max != bx) {
	   y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
	   if (inrange(y, y_min, y_max)) {
		  *ex = x_max;
		  *ey = y;
		  return;
	   }
    }

    /* It is possible for one or two of the [ab][xy] values to be -VERYLARGE.
	* If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned 
	* FALSE above. Otherwise we fall through all the tests above. 
	* If two are -VERYLARGE, it is ax=ay=-VERYLARGE or bx=by=-VERYLARGE 
	* since either a or b must be INRANGE. 
	* Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
	* Handle them carefully here. As yet we have no way for them to be 
	* +VERYLARGE.
	*/
    if (ax == -VERYLARGE) {
	   if (ay != -VERYLARGE) {
		  *ex = min(x_min, x_max);
		  *ey = by;
		  return;
	   }
    } else if (bx == -VERYLARGE) {
	   if (by != -VERYLARGE) {
		  *ex = min(x_min, x_max);
		  *ey = ay;
		  return;
	   }
    } else if (ay == -VERYLARGE) {
	   /* note we know ax != -VERYLARGE */
	   *ex = bx;
	   *ey = min(y_min, y_max);
	   return;
    } else if (by == -VERYLARGE) {
	   /* note we know bx != -VERYLARGE */
	   *ex = ax;
	   *ey = min(y_min, y_max);
	   return;
    }

    /* If we reach here, then either one point is (-VERYLARGE,-VERYLARGE), 
	* or the inrange point is on the edge, and
     * the line segment from the outrange point does not cross any 
	* other edges to get there. In either case, we return the inrange 
	* point as the 'edge' intersection point. This will basically draw
	* line.
	*/
    if (points[i].type == INRANGE) {
	   *ex = bx; 
	   *ey = by;
    } else {
	   *ex = ax; 
	   *ey = ay;
    }
    return;
}

/* double edge intersection algorithm */
/* Given two points, both outside the plot, return
 * the points where an edge of the plot intersects the line segment defined 
 * by the two points. There may be zero, one, two, or an infinite number
 * of intersection points. (One means an intersection at a corner, infinite
 * means overlaying the edge itself). We return FALSE when there is nothing
 * to draw (zero intersections), and TRUE when there is something to 
 * draw (the one-point case is a degenerate of the two-point case and we do 
 * not distinguish it - we draw it anyway).
 */
BOOLEAN				/* any intersection? */
two_edge_intersect(points, i, lx, ly)
	struct coordinate *points; /* the points array */
	int i;				/* line segment from point i-1 to point i */
	double *lx, *ly;		/* lx[2], ly[2]: points where it crosses edges */
{
    /* global x_min, x_max, y_min, x_max */
    double ax = points[i-1].x;
    double ay = points[i-1].y;
    double bx = points[i].x;
    double by = points[i].y;
    double x, y;			/* possible intersection point */
    BOOLEAN intersect = FALSE;

    if (by == ay) {
	   /* horizontal line */
	   /* y coord must be in range, and line must span both x_min and x_max */
	   /* note that spanning x_min implies spanning x_max */
	   if (inrange(by, y_min, y_max) && inrange(x_min, ax, bx)) {
		  *lx++ = x_min;
		  *ly++ = by;
		  *lx++ = x_max;
		  *ly++ = by;
		  return(TRUE);
	   } else
		return(FALSE);
    } else if (bx == ax) {
	   /* vertical line */
	   /* x coord must be in range, and line must span both y_min and y_max */
	   /* note that spanning y_min implies spanning y_max */
	   if (inrange(bx, x_min, x_max) && inrange(y_min, ay, by)) {
		  *lx++ = bx;
		  *ly++ = y_min;
		  *lx++ = bx;
		  *ly++ = y_max;
		  return(TRUE);
	   } else
		return(FALSE);
    }

    /* slanted line of some kind */
    /* there can be only zero or two intersections below */

    /* does it intersect y_min edge */
    if (inrange(y_min, ay, by)) {
	   x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
	   if (inrange(x, x_min, x_max)) {
		  *lx++ = x;
		  *ly++ = y_min;
		  intersect = TRUE;
	   }
    }
    
    /* does it intersect y_max edge */
    if (inrange(y_max, ay, by)) {
	   x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
	   if (inrange(x, x_min, x_max)) {
		  *lx++ = x;
		  *ly++ = y_max;
		  intersect = TRUE;
	   }
    }

    /* does it intersect x_min edge */
    if (inrange(x_min, ax, bx)) {
	   y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
	   if (inrange(y, y_min, y_max)) {
		  *lx++ = x_min;
		  *ly++ = y;
		  intersect = TRUE;
	   }
    }

    /* does it intersect x_max edge */
    if (inrange(x_max, ax, bx)) {
	   y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
	   if (inrange(y, y_min, y_max)) {
		  *lx++ = x_max;
		  *ly++ = y;
		  intersect = TRUE;
	   }
    }

    if (intersect)
	 return(TRUE);

    /* It is possible for one or more of the [ab][xy] values to be -VERYLARGE.
	* If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned
	* FALSE above.
	* Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
	* Otherwise we fall through all the tests above. 
	* Handle them carefully here. As yet we have no way for them to be +VERYLARGE.
	*/
    if (ax == -VERYLARGE) {
	   if (ay != -VERYLARGE
		  && inrange(by, y_min, y_max) && inrange(x_max, ax, bx)) {
		  *lx++ = x_min;
		  *ly = by;
		  *lx++ = x_max;
		  *ly = by;
		  intersect = TRUE;
	   }
    } else if (bx == -VERYLARGE) {
	   if (by != -VERYLARGE
		  && inrange(ay, y_min, y_max) && inrange(x_max, ax, bx)) {
		  *lx++ = x_min;
		  *ly = ay;
		  *lx++ = x_max;
		  *ly = ay;
		  intersect = TRUE;
	   }
    } else if (ay == -VERYLARGE) {
	   /* note we know ax != -VERYLARGE */
	   if (inrange(bx, x_min, x_max) && inrange(y_max, ay, by)) {
		  *lx++ = bx;
		  *ly = y_min;
		  *lx++ = bx;
		  *ly = y_max;
		  intersect = TRUE;
	   }
    } else if (by == -VERYLARGE) {
	   /* note we know bx != -VERYLARGE */
	   if (inrange(ax, x_min, x_max) && inrange(y_max, ay, by)) {
		  *lx++ = ax;
		  *ly = y_min;
		  *lx++ = ax;
		  *ly = y_max;
		  intersect = TRUE;
	   }
    }

    return(intersect);
}

/* Polar transform of all curves */
/* Original code by John Campbell (CAMPBELL@NAUVAX.bitnet) */
polar_xform (plots, pcount)
	struct curve_points *plots;
	int pcount;			/* count of curves in plots array */
{
     struct curve_points *this_plot;
     int curve;			/* loop var, for curves */
     register int i, p_cnt;	/* loop/limit var, for points */
     struct coordinate *pnts;	/* abbrev. for points array */
	double x, y;			/* new cartesian value */
	BOOLEAN anydefined = FALSE;
	double d2r;

	if(angles_format == ANGLES_DEGREES){
		d2r = DEG2RAD;
	} else {
		d2r = 1.0;
	}

/*
	Cycle through all the plots converting polar to rectangular.
     If autoscaling, adjust max and mins. Ignore previous values.
	If not autoscaling, use the yrange for both x and y ranges.
*/
	if (autoscale_ly) {
	    x_min = VERYLARGE;
	    y_min = VERYLARGE;
	    x_max = -VERYLARGE;
	    y_max = -VERYLARGE;
	    autoscale_lx = TRUE;
	} else {
	    x_min = y_min;
	    x_max = y_max;
	}
    
	this_plot = plots;
	for (curve = 0; curve < pcount; this_plot = this_plot->next_cp, curve++) {
		p_cnt = this_plot->p_count;
        pnts = &(this_plot->points[0]);

	/*	Convert to cartesian all points in this curve. */
		for (i = 0; i < p_cnt; i++) {
			if (pnts[i].type != UNDEFINED) {
			     anydefined = TRUE;
			     /* modify points to reset origin and from degrees */
			     pnts[i].y -= rmin;
			     pnts[i].x *= d2r;
			     /* convert to cartesian coordinates */
				x = pnts[i].y*cos(pnts[i].x);
				y = pnts[i].y*sin(pnts[i].x);
				pnts[i].x = x;
				pnts[i].y = y;
				if (autoscale_ly) {
				    if (x_min > x) x_min = x;
				    if (x_max < x) x_max = x;
				    if (y_min > y) y_min = y;
				    if (y_max < y) y_max = y;
				    pnts[i].type = INRANGE;
				} else if(inrange(x, x_min, x_max) && inrange(y, y_min, y_max))
				  pnts[i].type = INRANGE;
				else
				  pnts[i].type = OUTRANGE;
			}
		}	
	}

	if (autoscale_lx && anydefined && fabs(x_max - x_min) < zero) {
	    /* This happens at least for the plot of 1/cos(x) (vertical line). */
	    fprintf(stderr, "Warning: empty x range [%g:%g], ", x_min,x_max);
	    if (x_min == 0.0) {
		   x_min = -1; 
		   x_max = 1;
	    } else {
		   x_min *= 0.9;
		   x_max *= 1.1;
	    }
	    fprintf(stderr, "adjusting to [%g:%g]\n", x_min,x_max);
	}
	if (autoscale_ly && anydefined && fabs(y_max - y_min) < zero) {
	    /* This happens at least for the plot of 1/sin(x) (horiz. line). */
	    fprintf(stderr, "Warning: empty y range [%g:%g], ", y_min, y_max);
	    if (y_min == 0.0) {
		   y_min = -1;
		   y_max = 1;
	    } else {
		   y_min *= 0.9;
		   y_max *= 1.1;
	    }
	    fprintf(stderr, "adjusting to [%g:%g]\n", y_min, y_max);
	}
}

/* DRAW_YTICS: draw a regular tic series, y axis */
draw_ytics(start, incr, end)
		double start, incr, end; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace;
	int ltic;			/* for mini log tics */
	double lticplace;	/* for mini log tics */
	double ticmin, ticmax;	/* for checking if tic is almost inrange */

	if (end == VERYLARGE)            /* for user-def series */
		end = max(y_min,y_max);

	/* limit to right side of plot */
	end = min(end, max(y_min,y_max));

	/* to allow for rounding errors */
	ticmin = min(y_min,y_max) - SIGNIF*incr;
	ticmax = max(y_min,y_max) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
		if ( inrange(ticplace,ticmin,ticmax) )
			ytick(ticplace, yformat, incr, 1.0);
		if (log_y && incr == 1.0) {
			/* add mini-ticks to log scale ticmarks */
		    int lstart, linc;
		    if ((end - start) >= 10)
		    {
			lstart = 10; /* No little ticks */
			linc = 5;
		    }
		    else if((end - start) >= 5)
		    {
			lstart = 2; /* 4 per decade */
			linc = 3;
		    }
		    else
		    {
			lstart = 2; /* 9 per decade */
			linc = 1;
		    }
		    for (ltic = lstart; ltic <= 9; ltic += linc) {
				lticplace = ticplace+log10((double)ltic);
				if ( inrange(lticplace,ticmin,ticmax) )
					ytick(lticplace, "\0", incr, 0.5);
		    }
		}
	}
}

/* DRAW_XTICS: draw a regular tic series, x axis */
draw_xtics(start, incr, end)
		double start, incr, end; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace;
	int ltic;			/* for mini log tics */
	double lticplace;	/* for mini log tics */
	double ticmin, ticmax;	/* for checking if tic is almost inrange */

	if (end == VERYLARGE)            /* for user-def series */
		end = max(x_min,x_max);

	/* limit to right side of plot */
	end = min(end, max(x_min,x_max));

	/* to allow for rounding errors */
	ticmin = min(x_min,x_max) - SIGNIF*incr;
	ticmax = max(x_min,x_max) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
		if ( inrange(ticplace,ticmin,ticmax) )
			xtick(ticplace, xformat, incr, 1.0);
		if (log_x && incr == 1.0) {
			/* add mini-ticks to log scale ticmarks */
		    int lstart, linc;
		    if ((end - start) >= 10)
		    {
			lstart = 10; /* No little ticks */
			linc = 5;
		    }
		    else if((end - start) >= 5)
		    {
			lstart = 2; /* 4 per decade */
			linc = 3;
		    }
		    else
		    {
			lstart = 2; /* 9 per decade */
			linc = 1;
		    }
		    for (ltic = lstart; ltic <= 9; ltic += linc) {
				lticplace = ticplace+log10((double)ltic);
				if ( inrange(lticplace,ticmin,ticmax) )
					xtick(lticplace, "\0", incr, 0.5);
			}
		}
	}
}

/* DRAW_SERIES_YTICS: draw a user tic series, y axis */
draw_series_ytics(start, incr, end)
		double start, incr, end; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace, place;
	double ticmin, ticmax;	/* for checking if tic is almost inrange */
	double spacing = log_y ? log10(incr) : incr;

	if (end == VERYLARGE)
		end = max(CheckLog(log_y, y_min), CheckLog(log_y, y_max));
	else
	  /* limit to right side of plot */
	  end = min(end, max(CheckLog(log_y, y_min), CheckLog(log_y, y_max)));

	/* to allow for rounding errors */
	ticmin = min(y_min,y_max) - SIGNIF*incr;
	ticmax = max(y_min,y_max) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
	    place = (log_y ? log10(ticplace) : ticplace);
	    if ( inrange(place,ticmin,ticmax) )
		 ytick(place, yformat, spacing, 1.0);
	}
}


/* DRAW_SERIES_XTICS: draw a user tic series, x axis */
draw_series_xtics(start, incr, end)
		double start, incr, end; /* tic series definition */
		/* assume start < end, incr > 0 */
{
	double ticplace, place;
	double ticmin, ticmax;	/* for checking if tic is almost inrange */
	double spacing = log_x ? log10(incr) : incr;

	if (end == VERYLARGE)
		end = max(CheckLog(log_x, x_min), CheckLog(log_x, x_max));
	else
	  /* limit to right side of plot */
	  end = min(end, max(CheckLog(log_x, x_min), CheckLog(log_x, x_max)));

	/* to allow for rounding errors */
	ticmin = min(x_min,x_max) - SIGNIF*incr;
	ticmax = max(x_min,x_max) + SIGNIF*incr;
	end = end + SIGNIF*incr; 

	for (ticplace = start; ticplace <= end; ticplace +=incr) {
	    place = (log_x ? log10(ticplace) : ticplace);
	    if ( inrange(place,ticmin,ticmax) )
		 xtick(place, xformat, spacing, 1.0);
	}
}

/* DRAW_SET_YTICS: draw a user tic set, y axis */
draw_set_ytics(list)
	struct ticmark *list;	/* list of tic marks */
{
    double ticplace;
    double incr = (y_max - y_min) / 10;
    /* global x_min, x_max, xscale, y_min, y_max, yscale */

    while (list != NULL) {
	   ticplace = (log_y ? log10(list->position) : list->position);
	   if ( inrange(ticplace, y_min, y_max) 		/* in range */
		  || NearlyEqual(ticplace, y_min, incr)	/* == y_min */
		  || NearlyEqual(ticplace, y_max, incr))	/* == y_max */
		ytick(ticplace, list->label, incr, 1.0);

	   list = list->next;
    }
}

/* DRAW_SET_XTICS: draw a user tic set, x axis */
draw_set_xtics(list)
	struct ticmark *list;	/* list of tic marks */
{
    double ticplace;
    double incr = (x_max - x_min) / 10;
    /* global x_min, x_max, xscale, y_min, y_max, yscale */

    while (list != NULL) {
	   ticplace = (log_x ? log10(list->position) : list->position);
	   if ( inrange(ticplace, x_min, x_max) 		/* in range */
		  || NearlyEqual(ticplace, x_min, incr)	/* == x_min */
		  || NearlyEqual(ticplace, x_max, incr))	/* == x_max */
		xtick(ticplace, list->label, incr, 1.0);

	   list = list->next;
    }
}

/* draw and label a y-axis ticmark */
ytick(place, text, spacing, ticscale)
        double place;                   /* where on axis to put it */
        char *text;                     /* optional text label */
        double spacing;         /* something to use with checkzero */
        double ticscale;         /* scale factor for tic mark (0..1] */
{
    register struct termentry *t = &term_tbl[term];
    char ticlabel[101];
    int ticsize = (int)((t->h_tic) * ticscale);

	place = CheckZero(place,spacing); /* to fix rounding error near zero */
    if (grid) {
           (*t->linetype)(-1);  /* axis line type */
           /* do not put a rectangular grid on a polar plot */
	   if( !polar){
	     (*t->move)(xleft, map_y(place));
	     (*t->vector)(xright, map_y(place));
           }
	   (*t->linetype)(-2); /* border linetype */
    }
    if (tic_in) {
      /* if polar plot, put the tics along the axes */
      if( polar){
           (*t->move)(map_x(ZERO),map_y(place));
           (*t->vector)(map_x(ZERO) + ticsize, map_y(place));
           (*t->move)(map_x(ZERO), map_y(place));
           (*t->vector)(map_x(ZERO) - ticsize, map_y(place));
	 } else {
	   (*t->move)(xleft, map_y(place));
           (*t->vector)(xleft + ticsize, map_y(place));
           (*t->move)(xright, map_y(place));
           (*t->vector)(xright - ticsize, map_y(place));
	 }
    } else {
      if( polar){
           (*t->move)(map_x(ZERO), map_y(place));
           (*t->vector)(map_x(ZERO) - ticsize, map_y(place));
	 }else{
           (*t->move)(xleft, map_y(place));
           (*t->vector)(xleft - ticsize, map_y(place));
	 }
    }

    /* label the ticmark */
    if (text == NULL) 
	 text = yformat;
    
    if( polar){
      (void) sprintf(ticlabel, text, CheckLog(log_y,fabs( place)+rmin));
      if ((*t->justify_text)(RIGHT)) {
	   (*t->put_text)(map_x(ZERO)-(t->h_char),
				   map_y(place), ticlabel);
	 } else {
	   (*t->put_text)(map_x(ZERO)-(t->h_char)*(strlen(ticlabel)+1),
				   map_y(place), ticlabel);
	 }
    } else {
    
      (void) sprintf(ticlabel, text, CheckLog(log_y, place));
      if ((*t->justify_text)(RIGHT)) {
	   (*t->put_text)(xleft-(t->h_char),
				   map_y(place), ticlabel);
	 } else {
	   (*t->put_text)(xleft-(t->h_char)*(strlen(ticlabel)+1),
				   map_y(place), ticlabel);
	 }
    }
}

/* draw and label an x-axis ticmark */
xtick(place, text, spacing, ticscale)
        double place;                   /* where on axis to put it */
        char *text;                     /* optional text label */
        double spacing;         /* something to use with checkzero */
        double ticscale;         /* scale factor for tic mark (0..1] */
{
    register struct termentry *t = &term_tbl[term];
    char ticlabel[101];
    int ticsize = (int)((t->v_tic) * ticscale);

	place = CheckZero(place,spacing); /* to fix rounding error near zero */
    if (grid) {
           (*t->linetype)(-1);  /* axis line type */
           if( !polar){
	     (*t->move)(map_x(place), ybot);
	     (*t->vector)(map_x(place), ytop);
           }
	   (*t->linetype)(-2); /* border linetype */
    }
    if (tic_in) {
      if( polar){
           (*t->move)(map_x(place), map_y(ZERO));
           (*t->vector)(map_x(place), map_y(ZERO) + ticsize);
           (*t->move)(map_x(place), map_y(ZERO));
           (*t->vector)(map_x(place), map_y(ZERO) - ticsize);
	 } else{
           (*t->move)(map_x(place), ybot);
           (*t->vector)(map_x(place), ybot + ticsize);
           (*t->move)(map_x(place), ytop);
           (*t->vector)(map_x(place), ytop - ticsize);
	 }
    } else {
      if( polar){
           (*t->move)(map_x(place), map_y(ZERO));
           (*t->vector)(map_x(place), map_y(ZERO) - ticsize);
	 }else{
           (*t->move)(map_x(place), ybot);
           (*t->vector)(map_x(place), ybot - ticsize);
	 }
    }
    
    /* label the ticmark */
    if (text == NULL)
	 text = xformat;

    if(polar){
      (void) sprintf(ticlabel, text, CheckLog(log_x, fabs(place)+rmin));
      if ((*t->justify_text)(CENTRE)) {
	   (*t->put_text)(map_x(place),
				   map_y(ZERO)-(t->v_char), ticlabel);
	 } else {
	   (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
				   map_y(ZERO)-(t->v_char), ticlabel);
	 }
    }else{

      (void) sprintf(ticlabel, text, CheckLog(log_x, place));
      if ((*t->justify_text)(CENTRE)) {
	   (*t->put_text)(map_x(place),
				   ybot-(t->v_char), ticlabel);
	 } else {
	   (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
				   ybot-(t->v_char), ticlabel);
	 }
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/header.mac version [dc067b321b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
if1
LARGE	equ 1			; define your memory model here

ifdef	SMALL
	; default, so do nothing
	else

ifdef	MEDIUM
	LARGE_CODE equ 1
	else

ifdef	COMPACT
	LARGE_DATA equ 1
	else

ifdef	LARGE
	LARGE_DATA equ 1
	LARGE_CODE equ 1

else
	%out No memory model defined--assuming SMALL

endif	; LARGE
endif	; COMPACT
endif	; MEDIUM
endif	; SMALL


beginproc macro procname

ifdef	LARGE_CODE
	procname proc far
else
	procname proc near
endif	; LARGE_CODE

	endm	; beginproc


endif	; if1


_TEXT	SEGMENT	BYTE PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT WORD PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT WORD PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT WORD PUBLIC 'BSS'
_BSS	ENDS

DGROUP	GROUP	CONST, _BSS, _DATA
	assume cs:_text, ds:dgroup, ss:dgroup, es:dgroup

; define X as the offset of first argument on stack frame

ifdef LARGE_CODE
	X	equ 6			; return offset and segment + old BP
else
	X	equ 4			; return offset + old BP
endif	; LARGE_CODE
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































Deleted r34.1/plot/help.c version [c6f916e3ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
#ifndef lint
static char *RCSid = "$Id: help.c,v 3.26 92/03/24 22:34:24 woo Exp Locker: woo $";
#endif

/* GNUPLOT - help.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>

extern int errno;

extern int strcmp();
extern int strlen();
extern char *strcpy();
extern char *strncpy();
extern char *strcat();
extern char *strncat();
extern char *getenv();
extern FILE *fopen();
extern char *malloc();

extern int instring();

#define	SAME	0	/* for strcmp() */

#include "help.h"	/* values passed back */

/* help -- help subsystem that understands defined keywords
**
** Looks for the desired keyword in the help file at runtime, so you
** can give extra help or supply local customizations by merely editing
** the help file.
**
** The original (single-file) idea and algorithm is by John D. Johnson,
** Hewlett-Packard Company.  Thanx and a tip of the Hatlo hat!
**
** Much extension by David Kotz for use in gnutex, and then in gnuplot.
** Added output paging support, both unix and builtin. Rewrote completely
** to read helpfile into memory, avoiding reread of help file. 12/89.
**
** Modified by Russell Lang to avoid reading completely into memory
** if MSDOS defined.  This uses much less memory.  6/91
**
** The help file looks like this (the question marks are really in column 1):
**
** 	?topic
** 	This line is printed when the user wants help on "topic".
** 	?keyword
** 	?Keyword
** 	?KEYWORD
** 	These lines will be printed on the screen if the user wanted
** 	help on "keyword", "Keyword", or "KEYWORD".  No casefolding is
**	done on the keywords.
** 	?subject
** 	?alias
** 	This line is printed for help on "subject" and "alias".
** 	?
**	??
** 	Since there is a null keyword for this line, this section
** 	is printed when the user wants general help (when a help
** 	keyword isn't given).  A command summary is usually here.
**	Notice that the null keyword is equivalent to a "?" keyword
**	here, because of the '?' and '??' topic lines above.
**   If multiple keywords are given, the first is considered the 
**   'primary' keyword. This affects a listing of available topics.
** 	?last-subject
** 	Note that help sections are terminated by the start of the next
** 	'?' entry or by EOF.  So you can't have a leading '?' on a line
** 	of any help section.  You can re-define the magic character to
**	recognize in column 1, though, if '?' is too useful.  (Try ^A.)
*/

#define	KEYFLAG	'?'	/* leading char in help file topic lines */

/*
** Calling sequence:
**	int result;		# 0 == success
**	char *keyword;		# topic to give help on
**	char *pathname;		# path of help file
**      int subtopics;		# set to TRUE if only subtopics to be listed
**				# returns TRUE if subtopics were found
**	result = help(keyword, pathname, &subtopics);
** Sample:
**	cmd = "search\n";
**	helpfile = "/usr/local/lib/program/program.help";
**	subtopics = FALSE;
**	if (help(cmd, helpfile, &subtopics) != H_FOUND)
**		printf("Sorry, no help for %s", cmd);
**
**
** Speed this up by replacing the stdio calls with open/close/read/write.
*/
#ifdef	WDLEN
#  define	PATHSIZE	WDLEN
#else
#  define	PATHSIZE	BUFSIZ
#endif

typedef int boolean;
#ifndef TRUE
#define TRUE (1)
#define FALSE (0)
#endif

typedef struct line_s LINEBUF;
struct line_s {
    char *line;			/* the text of this line */
    LINEBUF *next;			/* the next line */
};

typedef struct linkey_s LINKEY;
struct linkey_s {
    char *key;				/* the name of this key */
    long pos;			    /* ftell position */
    LINEBUF *text;			/* the text for this key */
    boolean primary;		/* TRUE -> is a primary name for a text block */
    LINKEY *next;			/* the next key in linked list */
};

typedef struct key_s KEY;
struct key_s {
    char *key;				/* the name of this key */
    long pos;			    /* ftell position */
    LINEBUF *text;			/* the text for this key */
    boolean primary;		/* TRUE -> is a primary name for a text block */
};
static LINKEY *keylist = NULL;	/* linked list of keys */
static KEY *keys = NULL;		/* array of keys */
static int keycount = 0;		/* number of keys */
static FILE *helpfp = NULL;

static int LoadHelp();
static void sortkeys();
static int keycomp();
static LINEBUF *storeline();
static LINKEY *storekey();
static KEY *FindHelp();
static boolean Ambiguous();

/* Help output */
static void PrintHelp();
static void ShowSubtopics();
static void StartOutput();
static void OutLine();
static void EndOutput();
static FILE *outfile;		/* for unix pager, if any */
static int pagelines;		/* count for builtin pager */
#define SCREENSIZE 24		/* lines on screen (most have at least 24) */

/* help:
 * print a help message 
 * also print available subtopics, if subtopics is TRUE
 */
help(keyword, path, subtopics)
	char *keyword;		/* on this topic */
	char *path;			/* from this file */
	boolean *subtopics;	/* (in) - subtopics only? */
						/* (out) - are there subtopics? */
{
    static char oldpath[PATHSIZE] = "";	/* previous help file */
    int status;			/* result of LoadHelp */
    KEY *key;			/* key that matches keyword */

    /*
	** Load the help file if necessary (say, first time we enter this routine,
	** or if the help file changes from the last time we were called).
	** Also may occur if in-memory copy was freed.
	** Calling routine may access errno to determine cause of H_ERROR.
	*/
    errno = 0;
    if (strncmp(oldpath, path, PATHSIZE) != SAME)
	 FreeHelp();
    if (keys == NULL) {
	   status = LoadHelp(path);
	   if (status == H_ERROR)
		return(status);

	   /* save the new path in oldpath */
	   if (strlen(path) < PATHSIZE)
		(void) strcpy(oldpath, path);
	   else {				/* not enough room in oldpath, sigh */
		  (void) strncpy(oldpath, path, PATHSIZE - 1);
		  oldpath[PATHSIZE - 1] = '\0';
	   }
    }

    /* look for the keyword in the help file */
    key = FindHelp(keyword);
    if (key != NULL) {
	   /* found the keyword: print help and return */
	   PrintHelp(key, subtopics);
	   status = H_FOUND;
    } else {
	   status = H_NOTFOUND;
    }

    return(status);
}

/* we only read the file once, into memory
 * except for MSDOS when we don't read all the file -
 * just the keys and location of the text
 */
static int
LoadHelp(path)
	char *path;
{
    LINKEY *key;			/* this key */
    long pos;				/* ftell location within help file */
    char buf[BUFSIZ];		/* line from help file */
    LINEBUF *head;			/* head of text list  */
    LINEBUF *firsthead = NULL;
    boolean primary;		/* first ? line of a set is primary */
    boolean flag;

    if ((helpfp = fopen(path, "r")) == NULL) {
	   /* can't open help file, so error exit */
	   return (H_ERROR);
    }

    /*
	** The help file is open.  Look in there for the keyword.
	*/
    (void) fgets(buf, BUFSIZ - 1, helpfp);
    while (!feof(helpfp)) {
	   /*
	    ** Make an entry for each synonym keyword
	    */
	   primary = TRUE;
	   while (buf[0] == KEYFLAG) {
		  key = storekey(buf+1);	/* store this key */
	      key->primary = primary;
	      key->text = NULL;			/* fill in with real value later */
	      key->pos = 0;				/* fill in with real value later */
		  primary = FALSE;
		  pos = ftell(helpfp);
		  if (fgets(buf, BUFSIZ - 1, helpfp) == (char *)NULL)
		    break;
	   }
	   /*
	    ** Now store the text for this entry.
	    ** buf already contains the first line of text.
	    */
#ifndef MSDOS
	   firsthead = storeline(buf);
	   head = firsthead;
#endif
	   while ( (fgets(buf, BUFSIZ - 1, helpfp) != (char *)NULL)
		&& (buf[0] != KEYFLAG) ){
#ifndef MSDOS
		  /* save text line */
		  head->next = storeline(buf);
		  head = head->next;
#endif
	   }
	   /* make each synonym key point to the same text */
	   do {
	      key->pos = pos;
	      key->text = firsthead;
	      flag = key->primary;
	      key = key->next;
	   } while ( flag!=TRUE  &&  key!=NULL );
    }
#ifndef MSDOS
    (void) fclose(helpfp);
#endif

    /* we sort the keys so we can use binary search later */
    sortkeys();
	return(H_FOUND); /* ok */
}

/* make a new line buffer and save this string there */
static LINEBUF *
storeline(text)
	char *text;
{
    LINEBUF *new;

    new = (LINEBUF *)malloc(sizeof(LINEBUF));
    if (new == NULL)
	 int_error("not enough memory to store help file", -1);
    if (text != NULL) {
	   new->line = (char *) malloc((unsigned int)(strlen(text)+1));
	   if (new->line == NULL)
		int_error("not enough memory to store help file", -1);
	   (void) strcpy(new->line, text);
    } else
	 new->line = NULL;

    new->next = NULL;

    return(new);
}

/* Add this keyword to the keys list, with the given text */
static LINKEY *
storekey(key)
	char *key;
{
    LINKEY *new;

    key[strlen(key)-1] = '\0'; /* cut off \n  */

    new = (LINKEY *)malloc(sizeof(LINKEY));
    if (new == NULL)
	 int_error("not enough memory to store help file", -1);
    new->key = (char *) malloc((unsigned int)(strlen(key)+1));
    if (new->key == NULL)
	 int_error("not enough memory to store help file", -1);
    (void) strcpy(new->key, key);

    /* add to front of list */
    new->next = keylist;
    keylist = new;
    keycount++;
	return(new);
}

/* we sort the keys so we can use binary search later */
/* We have a linked list of keys and the number.
 * to sort them we need an array, so we reform them into an array,
 * and then throw away the list.
 */
static void
sortkeys()
{
    LINKEY *p,*n;			/* pointers to linked list */
    int i;				/* index into key array */
    
    /* allocate the array */
    keys = (KEY *)malloc((unsigned int)((keycount+1) * sizeof(KEY)));
    if (keys == NULL)
	 int_error("not enough memory to store help file", -1);
    
    /* copy info from list to array, freeing list */
    for (p = keylist, i = 0; p != NULL; p = n, i++) {
	   keys[i].key = p->key;
	   keys[i].pos = p->pos;
	   keys[i].text = p->text;
	   keys[i].primary = p->primary;
	   n = p->next;
	   free( (char *)p );
    }

    /* a null entry to terminate subtopic searches */
    keys[keycount].key = NULL;
    keys[keycount].pos = 0;
    keys[keycount].text = NULL;

    /* sort the array */
    /* note that it only moves objects of size (two pointers + long + int) */
    /* it moves no strings */
    qsort((char *)keys, keycount, sizeof(KEY), keycomp);
}

static int
keycomp(a, b)
	KEY *a,*b;
{
    return (strcmp(a->key, b->key));
}

/* Free the help file from memory. */
/* May be called externally if space is needed */
void
FreeHelp()
{
    int i;				/* index into keys[] */
    LINEBUF *t, *next;

    if (keys == NULL)
	 return;

    for (i = 0; i < keycount; i++) {
	   free( (char *)keys[i].key );
	   if (keys[i].primary)   /* only try to release text once! */
	   for (t = keys[i].text; t != NULL; t = next) {
		  free( (char *)t->line );
		  next = t->next;
		  free( (char *)t );
	   }
    }
    free( (char *)keys );
    keys = NULL;
    keycount = 0;
#ifdef MSDOS
    (void) fclose(helpfp);
#endif
}

/* FindHelp:
 *  Find the key that matches the keyword.
 *  The keys[] array is sorted by key.
 *  We could use a binary search, but a linear search will aid our
 *  attempt to allow abbreviations. We search for the first thing that
 *  matches all the text we're given. If not an exact match, then
 *  it is an abbreviated match, and there must be no other abbreviated
 *  matches -- for if there are, the abbreviation is ambiguous. 
 *  We print the ambiguous matches in that case, and return not found.
 */
static KEY *				/* NULL if not found */
FindHelp(keyword)
	char *keyword;			/* string we look for */
{
    KEY *key;
    int len = strlen(keyword);
    int compare;

    for (key = keys, compare = 1; key->key != NULL && compare > 0; key++) {
	   compare = strncmp(keyword, key->key, len);
	   if (compare == 0)	/* we have a match! */
		if (!Ambiguous(key, len)) {
		    /* non-ambiguous abbreviation */
		    (void) strcpy(keyword, key->key); /* give back the full spelling */
		    return(key);		/* found!! */
		}
    }

    /* not found, or ambiguous */
    return(NULL);
}

/* Ambiguous:
 * Check the key for ambiguity up to the given length.
 * It is ambiguous if it is not a complete string and there are other
 * keys following it with the same leading substring.
 */
static boolean
Ambiguous(key, len)
	KEY *key;
	int len;
{
    char *first;
    char *prev;
    boolean status = FALSE;	/* assume not ambiguous */
    int compare;
    int sublen;

    if (key->key[len] == '\0')
	 return(FALSE);
    
    for (prev = first = key->key, compare = 0, key++;
	    key->key != NULL && compare == 0; key++) {
	   compare = strncmp(first, key->key, len);
	   if (compare == 0) {
		  /* So this key matches the first one, up to len.
		   * But is it different enough from the previous one
		   * to bother printing it as a separate choice?
		   */
		  sublen = instring(prev+len, ' ');
		  if (strncmp(key->key, prev, len+sublen) != 0) {
			 /* yup, this is different up to the next space */
			 if (!status) {
				/* first one we have printed is special */
				fprintf(stderr, 
					   "Ambiguous request '%.*s'; possible matches:\n",
					   len, first);
				fprintf(stderr, "\t%s\n", prev);
				status = TRUE;
			 }
			 fprintf(stderr, "\t%s\n", key->key);
			 prev = key->key;
		  }
	   }
    }
    
    return(status);
}

/* PrintHelp:
 * print the text for key
 */
static void
PrintHelp(key, subtopics)
	KEY *key;
	boolean *subtopics;		/* (in) - subtopics only? */
						/* (out) - are there subtopics? */
{
    LINEBUF *t;
#ifdef MSDOS
    char buf[BUFSIZ];		/* line from help file */
#endif

    StartOutput();

    if (subtopics == NULL || !*subtopics) {
#ifdef MSDOS
	   fseek(helpfp,key->pos,0);
	   while ( (fgets(buf, BUFSIZ - 1, helpfp) != (char *)NULL)
			&& (buf[0] != KEYFLAG) ) {
		  OutLine(buf);
	   }
#else
	   for (t = key->text; t != NULL; t = t->next)
		OutLine(t->line);		/* print text line */
#endif
    }

    ShowSubtopics(key, subtopics);
    OutLine("\n");

    EndOutput();
}

/* ShowSubtopics:
 *  Print a list of subtopic names
 */
#define PER_LINE 4

static void
ShowSubtopics(key, subtopics)
	KEY *key;				/* the topic */
	boolean *subtopics;		/* (out) are there any subtopics */
{
    int subt = 0;			/* printed any subtopics yet? */
    KEY *subkey;			/* subtopic key */
    int len;				/* length of key name */
    char line[BUFSIZ];		/* subtopic output line */
    char *start;			/* position of subname in key name */
    int sublen;			/* length of subname */
    int pos;
    char *prev = NULL;		/* the last thing we put on the list */

    *line = '\0';
    len = strlen(key->key);

    for (subkey = key+1; subkey->key != NULL; subkey++) {
	   if (strncmp(subkey->key, key->key, len) == 0) {
		  /* find this subtopic name */
		  start = subkey->key + len;
		  if (len > 0)
		    if (*start == ' ')
			 start++;		/* skip space */
		    else
			 break;		/* not the same topic after all  */
		  else			/* here we are looking for main topics */
		    if (!subkey->primary)
			 continue;	/* not a main topic */
		  sublen = instring(start, ' ');
		  if (prev == NULL || strncmp(start, prev, sublen) != 0) {
			 if (subt == 0) {
				subt++;
				if (len)
				  (void) sprintf(line, "\nSubtopics available for %s:\n", 
						key->key);
				else
				  (void) sprintf(line, "\nHelp topics available:\n");
				OutLine(line);
				*line = '\0';
				pos = 0;
			 }
			 if (pos == PER_LINE) {
				(void) strcat(line, "\n");
				OutLine(line);
				*line = '\0';
				pos = 0;
			 }
			 (void) strcat(line, "\t");
			 (void) strncat(line, start, sublen);
			 pos++;
			 prev = start;
		  }
	   } else {
		  /* new topic */
		  break;
	   }
    }
    
    /* put out the last line */
    if (subt > 0 && pos > 0) {
	   (void) strcat(line, "\n");
	   OutLine(line);
    }
    
/*
    if (subt == 0) {
	   OutLine("\n");
	   OutLine("No subtopics available\n");
    }
*/
    
    if (subtopics)
	 *subtopics = (subt != 0);
}


/* StartOutput:
 * Open a file pointer to a pipe to user's $PAGER, if there is one,
 * otherwise use our own pager.
 */
static void
StartOutput()
{
#ifdef unix
    char *pager_name = getenv("PAGER");
    extern FILE *popen();

    if (pager_name != NULL && *pager_name != '\0')
	 if ((outfile = popen(pager_name, "w")) != (FILE *)NULL)
	   return;			/* success */
    outfile = stderr;
    /* fall through to built-in pager */
#endif

    /* built-in pager */
    pagelines = 0;
}

/* write a line of help output  */
/* line should contain only one \n, at the end */
static void
OutLine(line)
	char *line;
{
    int c;				/* dummy input char */
#ifdef unix
    if (outfile != stderr) {
	   fputs(line, outfile);
	   return;
    }
#endif

    /* built-in dumb pager */
    /* leave room for prompt line */
    if (pagelines >= SCREENSIZE - 2) {
	   fprintf(stderr,"Press return for more: ");
	   do 
		c = getchar();
	   while (c != EOF && c != '\n');
	   pagelines = 0;
    }
    fputs(line, stderr);
    pagelines++;
}

static void
EndOutput()
{
#ifdef unix
    extern int pclose();

    if (outfile != stderr)
	 (void) pclose(outfile);
#endif
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/help.h version [0f306d3186].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * $Id: help.h,v 3.26 92/03/24 22:34:14 woo Exp Locker: woo $
 */

/* GNUPLOT - help.h */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

/* Exit status returned by help() */
#define	H_FOUND		0	/* found the keyword */
#define	H_NOTFOUND	1	/* didn't find the keyword */
#define	H_ERROR		(-1)	/* didn't find the help file */

extern void FreeHelp();		/* use this if you need memory */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































Deleted r34.1/plot/hrcgraph.asm version [5722eb1550].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
TITLE	Hercules graphics module

;	Michael Gordon - 8-Dec-86
;
; Certain routines were taken from the Hercules BIOS of	Dave Tutelman - 8/86
; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
;
; modified slightly by Colin Kelley - 22-Dec-86
;	added header.mac, parameterized declarations
; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
; modified by Russell Lang 3 Jun 1988
;	added H_init

include header.mac

if1
include lineproc.mac
endif


GPg1_Base equ 0B800h	; Graphics page 1 base address

_text	segment

	public _H_line, _H_color, _H_mask, _HVmode, _H_puts
	public _H_init

HCfg_Switch equ	03BFH	; Configuration Switch - software switch 
			; to select graphics card memory map

beginproc _H_init
	mov al, 03H	; allow graphics in b8000:bffff
	mov dx, HCfg_Switch
	out dx, al
	ret
_H_init endp

hpixel	proc near
	ror word ptr bmask,1
	jc cont
	ret
cont:
	push ax
	push bx
	push cx
	push dx
	push si
	mov cx,ax		; x
	mov dx,bx		; y
;
; [couldn't this be done faster with a lookup table? -cdk]
;
	; first compute the address of byte to be modified
	; = 90*[row/4] + [col/8] + 2^D*[row/4] + 2^F*page
	mov	bh,cl		; col (low order) in BH
	mov	bl,dl		; row (low order) in BL
	and	bx,0703H	; mask the col & row remainders
IFDEF iAPX286
	shr	cx,3		; col / 8
	shr	dx,2		; row / 4
	mov	al,90
	mul	dx		; AX = 90*[ row/4 ]
	add	ax,cx		;  ... + col/8
	shl	bl,5		; align row remainder
ELSE			; same as above, obscure but fast for 8086
	shr	cx,1		; divide col by 8
	shr	cx,1
	shr	cx,1
	shr	dx,1		; divide row by 4
	shr	dx,1
	shl	dx,1		; begin fast multiply by 90 (1011010 B)
	mov	ax,dx
	shl	dx,1
	shl	dx,1
	add	ax,dx
	shl	dx,1
	add	ax,dx
	shl	dx,1
	shl	dx,1
	add	ax,dx		; end fast multiply by 90
	add	ax,cx		; add on the col/8
	shl	bl,1		; align row remainder
	shl	bl,1
	shl	bl,1
	shl	bl,1
	shl	bl,1
ENDIF
	add	ah,bl		; use aligned row remainder
end_adr_calc:			; address of byte is now in AX
	mov	dx,GPg1_Base	; base of pixel display to DX
	mov	es,dx		; ...and thence to segment reg
	mov	si,ax		; address of byte w/ pixel to index reg
	mov	cl,bh		; bit addr in byte
	mov	al,80H		; '1000 0000' in AL 
	shr	al,cl		; shift mask to line up with bit to read/write
set_pix:			; set the pixel
	or	es:[si],al	; or the mask with the right byte
	pop si
	pop dx
	pop cx
	pop bx
	pop ax
	ret
hpixel endp

lineproc _H_line, hpixel

;
; clear - clear page 1 of the screen buffer to zero (effectively, blank
;	the screen)
;
clear   proc near
	push es
	push ax
	push cx
	push di
	mov ax, GPg1_Base
	mov es, ax
	xor di, di
	mov cx, 4000h
	xor ax, ax
	cld
	rep stosw			; zero out screen page
	pop di
	pop cx
	pop ax
	pop es
	ret
clear	endp

beginproc _H_color
	push bp
	mov bp,sp
	mov al,[bp+X]			; color
	mov byte ptr color,al
	pop bp
	ret
_H_color endp

beginproc _H_mask
	push bp
	mov bp,sp
	mov ax,[bp+X]			; mask
	mov word ptr bmask,ax
	pop bp
	ret
_H_mask endp

HCtrl_Port	equ	03B8H	; Hercules 6845 control port IO addr
HIndx_Port	equ	03B4H	; Hercules 6845 index port IO addr
HScrn_Enable	equ	008h	; Control port bit to enable video
HCh_Mode	equ	020h	; Character output mode
HGr_Mode	equ	082h	; Graphics output mode page 1

parm_count equ 12

beginproc _HVmode
	push bp
	mov bp, sp
	push si
	mov ax, [bp+X]
	or ah, al
	mov al, HCh_Mode		; Assume character mode is wanted
	mov si, offset dgroup:HCh_Parms
	cmp ah, 0			; nonzero means switch to graphics
	jz vmode_ok
	call near ptr clear		; clear the graphics page
	mov al, HGr_Mode
	mov si, offset dgroup:HGr_Parms
vmode_ok:
	mov dx, HCtrl_Port
	out dx, al			; Set Hercules board to proper mode
	call near ptr setParms		; Set the 6845 parameters
	or al, HScrn_Enable		; Enable the video output
	out dx, al
	pop si
	pop bp
	ret
_HVmode	endp

setParms proc near		; Send 6845 parms to Hercules board
	push ax
	push dx
	push si			
	mov dx, HIndx_Port	; Index port addr -> DX
	mov ah, 0		; 0 -> parameter counter
sp_loop:
	mov al, ah
	out dx, al		; output to 6845 addr register
	inc dx			; next output to data register
	mov al, [si]		; next control byte -> al
	inc si
	out dx, al		; output control byte
	dec dx			; 6845 index addr -> dx
	inc ah			; bump addr
	cmp ah, parm_count
	jnz sp_loop
	pop si
	pop dx
	pop ax
	ret
setParms endp

; H_puts - print text in graphics mode
;
;	cx = row
;	bx = column
;	si = address of string (null terminated) to print

beginproc _H_puts
	push bp
	mov bp, sp
	push si
	push ds
	mov si, [bp+X]			; string offset

ifdef LARGE_DATA
	mov ds, [bp+X+2]		; string segment
	mov cx, [bp+X+4]		; row
	mov bx, [bp+X+6]		; col
else
	mov cx, [bp+X+2]		; row
	mov bx, [bp+X+4]		; col
endif

ploop:	lodsb				; get next char
	or	al, al			; end of display?
	je	pdone
	call near ptr display
	inc	bx			; bump to next column
	jmp	ploop
pdone:	pop ds
	pop si
	pop bp
	ret
_H_puts	endp

;
; display - output an 8x8 character from the IBM ROM to the Herc board
;
; AX = char, BX = column (0-89), CX = row(0-42)  ** all preserved **
;
CON8	db	8
CON180	db	180
IBMROM	equ	0F000h
CHARTAB	equ	0FA6Eh

display	proc near
	push	ds			; save the lot
	push	es
	push	ax
	push	bx
	push	cx
	push	dx
	push	si
	push	di

; setup ds -> IBM ROM, and si -> index into IBM ROM character table located
;	at 0fa6eh in the ROM

	and	ax, 07fh
	mul	cs:CON8			; mult by 8 bytes of table per char
	mov	si, ax
	mov	ax, IBMROM
	mov	ds, ax
	assume	ds:nothing
	add	si, CHARTAB		; add offset of character table

; compute index into Hercules screen memory for scan line 0.  The remaining
;	seven scan lines are all at fixed offsets from the first.
;
;	Since graphics mode treats the screen as sets of 16x4 "characters",
;	we need to map an 8x8 real character onto the front or back of
;	a pair of graphics "characters".  The first four scan lines of our
;	8x8 character will map to the top graphics "character", and the second
;	four scan lines map to the graphics character on the "line" (4 scan
;	lines high) below it.
;
;	For some exotic hardware reason (probably speed), all scan line 0
;	bits (i.e. every fourth scan line) are stored in memory locations
;	0-2000h in the screen buffer.  All scan line 1 bits are stored
;	2000h-4000h.  Within these banks, they are stored by rows.  The first
;	scan line on the screen (scan line 0 of graphics character row 0)
;	is the first 45 words of memory in the screen buffer.  The next 45
;	words are the first scan line graphics row 1, and since graphics
;	"characters" are 4 bits high, this second scan line is physically
;	the fifth scan line displayed on the screen.
;
;	SO, to display an 8x8 character, the 1st and 5th rows of dots are
;	both scan line 0 of the graphics "character", the 2nd and 6th are
;	scan line 1, and so on.
;
;	The column (0-89) tells which byte in a scan line we need to load.
;	Since it takes two rows of graphics characters to hold one row of
;	our characters, column+90 is a index to scan line 4 rows of pixels
;	higher (n+4).  Thus 180 bytes of screen memory in any bank (0h, 2000h,
;	4000h, 6000h) represent a row of 8x8 characters.
;	
;	The starting location in screen memory for the first scan line of
;	a character to be displayed will be:  	(row*180)+column
;	The 5th scan line will be at:		(row*180)+column+90
;
;	The second and 6th scan lines will be at the above offsets plus
;	the bank offset of 2000h.  The third and 7th, add 4000h and finally
;	the 4th and 8th, add 6000h.
;
	mov	ax, GPg1_Base
	mov	es, ax			; es = hercules page 0
	mov	ax, cx			; get row
	mul	cs:CON180		; mult by 180(10)
	mov	di, ax			; di = index reg
	cld				; insure right direction

;output 8 segments of character to video ram

	lodsb				; line 0
	mov	es:[di+bx], al
	lodsb
	mov	es:[di+bx+2000h], al	; line 1
	lodsb
	mov	es:[di+bx+4000h], al	; line 2
	lodsb
	mov	es:[di+bx+6000h], al	; line 3
	lodsb
	mov	es:[di+bx+90], al	; line 4
	lodsb
	mov	es:[di+bx+2000h+90], al	; line 5
	lodsb
	mov	es:[di+bx+4000h+90], al	; line 6
	lodsb
	mov	es:[di+bx+6000h+90], al	; line 7

	pop	di
	pop	si
	pop	dx
	pop	cx
	pop	bx
	pop	ax
	pop	es
	pop	ds
	ret
display	endp

_text	ends

_data	segment
bmask	dw -1
color	db 1
_data	ends

const	segment
HCh_Parms db 	61H, 50H, 52H, 0FH, 19H, 06H, 19H, 19H, 02H, 0DH, 0BH, 0CH
HGr_Parms db	35H, 2DH, 2EH, 07H, 5BH, 02H, 57H, 57H, 02H, 03H, 00H, 00H
const	ends

	end


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/internal.c version [179872e958].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
#ifndef lint
static char *RCSid = "$Id: internal.c,v 3.26 92/03/24 22:34:29 woo Exp Locker: woo $";
#endif

/* GNUPLOT - internal.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <math.h>
#include <stdio.h>
#include "plot.h"

BOOLEAN undefined;

char *strcpy();

struct value *pop(), *complex(), *integer();
double magnitude(), angle(), real();

struct value stack[STACK_DEPTH];

int s_p = -1;   /* stack pointer */


/*
 * System V and MSC 4.0 call this when they wants to print an error message.
 * Don't!
 */
#ifndef _CRAY
#ifdef MSDOS
#ifdef __TURBOC__
int matherr()	/* Turbo C */
#else
int matherr(x)	/* MSC 5.1 */
struct exception *x;
#endif /* TURBOC */
#else /* not MSDOS */
#ifdef apollo
int matherr(struct exception *x)	/* apollo */
#else /* apollo */
#ifdef AMIGA_LC_5_1
int matherr(x)	/* AMIGA_LC_5_1 */
struct exception *x;
#else    /* Most everyone else (not apollo). */
int matherr()
#endif /* AMIGA_LC_5_1 */
#endif /* apollo */
#endif /* MSDOS */
{
	return (undefined = TRUE);		/* don't print error message */
}
#endif /* not _CRAY */


reset_stack()
{
	s_p = -1;
}


check_stack()	/* make sure stack's empty */
{
	if (s_p != -1)
		fprintf(stderr,"\nwarning:  internal error--stack not empty!\n");
}


struct value *pop(x)
struct value *x;
{
	if (s_p  < 0 )
		int_error("stack underflow",NO_CARET);
	*x = stack[s_p--];
	return(x);
}


push(x)
struct value *x;
{
	if (s_p == STACK_DEPTH - 1)
		int_error("stack overflow",NO_CARET);
	stack[++s_p] = *x;
}


#define ERR_VAR "undefined variable: "

f_push(x)
union argument *x;		/* contains pointer to value to push; */
{
static char err_str[sizeof(ERR_VAR) + MAX_ID_LEN] = ERR_VAR;
struct udvt_entry *udv;

	udv = x->udv_arg;
	if (udv->udv_undef) {	 /* undefined */
		(void) strcpy(&err_str[sizeof(ERR_VAR) - 1], udv->udv_name);
		int_error(err_str,NO_CARET);
	}
	push(&(udv->udv_value));
}


f_pushc(x)
union argument *x;
{
	push(&(x->v_arg));
}


f_pushd1(x)
union argument *x;
{
	push(&(x->udf_arg->dummy_values[0]));
}


f_pushd2(x)
union argument *x;
{
	push(&(x->udf_arg->dummy_values[1]));
}


#define ERR_FUN "undefined function: "

f_call(x)  /* execute a udf */
union argument *x;
{
static char err_str[sizeof(ERR_FUN) + MAX_ID_LEN] = ERR_FUN;
register struct udft_entry *udf;
struct value save_dummy;

	udf = x->udf_arg;
	if (!udf->at) { /* undefined */
		(void) strcpy(&err_str[sizeof(ERR_FUN) - 1],
				udf->udf_name);
		int_error(err_str,NO_CARET);
	}
	save_dummy = udf->dummy_values[0];
	(void) pop(&(udf->dummy_values[0]));

	execute_at(udf->at);
	udf->dummy_values[0] = save_dummy;
}

f_call2(x)  /* execute a udf of two variables */
union argument *x;
{
static char err_str[sizeof(ERR_FUN) + MAX_ID_LEN] = ERR_FUN;
register struct udft_entry *udf;
struct value save_dummy0, save_dummy1;

	udf = x->udf_arg;
	if (!udf->at) { /* undefined */
		(void) strcpy(&err_str[sizeof(ERR_FUN) - 1],
				udf->udf_name);
		int_error(err_str,NO_CARET);
	}
	save_dummy1 = udf->dummy_values[1];
	save_dummy0 = udf->dummy_values[0];
	(void) pop(&(udf->dummy_values[1]));
	(void) pop(&(udf->dummy_values[0]));

	execute_at(udf->at);
	udf->dummy_values[1] = save_dummy1;
	udf->dummy_values[0] = save_dummy0;
}


static int_check(v)
struct value *v;
{
	if (v->type != INT)
		int_error("non-integer passed to boolean operator",NO_CARET);
}


f_lnot()
{
struct value a;
	int_check(pop(&a));
	push(integer(&a,!a.v.int_val) );
}


f_bnot()
{
struct value a;
	int_check(pop(&a));
	push( integer(&a,~a.v.int_val) );
}


f_bool()
{			/* converts top-of-stack to boolean */
	int_check(&top_of_stack);
	top_of_stack.v.int_val = !!top_of_stack.v.int_val;
}


f_lor()
{
struct value a,b;
	int_check(pop(&b));
	int_check(pop(&a));
	push( integer(&a,a.v.int_val || b.v.int_val) );
}

f_land()
{
struct value a,b;
	int_check(pop(&b));
	int_check(pop(&a));
	push( integer(&a,a.v.int_val && b.v.int_val) );
}


f_bor()
{
struct value a,b;
	int_check(pop(&b));
	int_check(pop(&a));
	push( integer(&a,a.v.int_val | b.v.int_val) );
}


f_xor()
{
struct value a,b;
	int_check(pop(&b));
	int_check(pop(&a));
	push( integer(&a,a.v.int_val ^ b.v.int_val) );
}


f_band()
{
struct value a,b;
	int_check(pop(&b));
	int_check(pop(&a));
	push( integer(&a,a.v.int_val & b.v.int_val) );
}


f_uminus()
{
struct value a;
	(void) pop(&a);
	switch(a.type) {
		case INT:
			a.v.int_val = -a.v.int_val;
			break;
		case CMPLX:
			a.v.cmplx_val.real =
				-a.v.cmplx_val.real;
			a.v.cmplx_val.imag =
				-a.v.cmplx_val.imag;
	}
	push(&a);
}


f_eq() /* note: floating point equality is rare because of roundoff error! */
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val ==
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val ==
						b.v.cmplx_val.real &&
					   b.v.cmplx_val.imag == 0.0);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (b.v.int_val == a.v.cmplx_val.real &&
					   a.v.cmplx_val.imag == 0.0);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real==
						b.v.cmplx_val.real &&
						a.v.cmplx_val.imag==
						b.v.cmplx_val.imag);
			}
	}
	push(integer(&a,result));
}


f_ne()
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val !=
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val !=
						b.v.cmplx_val.real ||
					   b.v.cmplx_val.imag != 0.0);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (b.v.int_val !=
						a.v.cmplx_val.real ||
					   a.v.cmplx_val.imag != 0.0);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real !=
						b.v.cmplx_val.real ||
						a.v.cmplx_val.imag !=
						b.v.cmplx_val.imag);
			}
	}
	push(integer(&a,result));
}


f_gt()
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val >
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val >
						b.v.cmplx_val.real);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (a.v.cmplx_val.real >
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real >
						b.v.cmplx_val.real);
			}
	}
	push(integer(&a,result));
}


f_lt()
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val <
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val <
						b.v.cmplx_val.real);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (a.v.cmplx_val.real <
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real <
						b.v.cmplx_val.real);
			}
	}
	push(integer(&a,result));
}


f_ge()
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val >=
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val >=
						b.v.cmplx_val.real);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (a.v.cmplx_val.real >=
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real >=
						b.v.cmplx_val.real);
			}
	}
	push(integer(&a,result));
}


f_le()
{
struct value a, b;
	register int result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					result = (a.v.int_val <=
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.int_val <=
						b.v.cmplx_val.real);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					result = (a.v.cmplx_val.real <=
						b.v.int_val);
					break;
				case CMPLX:
					result = (a.v.cmplx_val.real <=
						b.v.cmplx_val.real);
			}
	}
	push(integer(&a,result));
}


f_plus()
{
struct value a, b, result;
	(void) pop(&b);
	(void) pop(&a);
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					(void) integer(&result,a.v.int_val +
						b.v.int_val);
					break;
				case CMPLX:
					(void) complex(&result,a.v.int_val +
						b.v.cmplx_val.real,
					   b.v.cmplx_val.imag);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					(void) complex(&result,b.v.int_val +
						a.v.cmplx_val.real,
					   a.v.cmplx_val.imag);
					break;
				case CMPLX:
					(void) complex(&result,a.v.cmplx_val.real+
						b.v.cmplx_val.real,
						a.v.cmplx_val.imag+
						b.v.cmplx_val.imag);
			}
	}
	push(&result);
}


f_minus()
{
struct value a, b, result;
	(void) pop(&b);
	(void) pop(&a);		/* now do a - b */
	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					(void) integer(&result,a.v.int_val -
						b.v.int_val);
					break;
				case CMPLX:
					(void) complex(&result,a.v.int_val -
						b.v.cmplx_val.real,
					   -b.v.cmplx_val.imag);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					(void) complex(&result,a.v.cmplx_val.real -
						b.v.int_val,
					    a.v.cmplx_val.imag);
					break;
				case CMPLX:
					(void) complex(&result,a.v.cmplx_val.real-
						b.v.cmplx_val.real,
						a.v.cmplx_val.imag-
						b.v.cmplx_val.imag);
			}
	}
	push(&result);
}


f_mult()
{
struct value a, b, result;
	(void) pop(&b);
	(void) pop(&a);	/* now do a*b */

	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					(void) integer(&result,a.v.int_val *
						b.v.int_val);
					break;
				case CMPLX:
					(void) complex(&result,a.v.int_val *
						b.v.cmplx_val.real,
						a.v.int_val *
						b.v.cmplx_val.imag);
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					(void) complex(&result,b.v.int_val *
						a.v.cmplx_val.real,
						b.v.int_val *
						a.v.cmplx_val.imag);
					break;
				case CMPLX:
					(void) complex(&result,a.v.cmplx_val.real*
						b.v.cmplx_val.real-
						a.v.cmplx_val.imag*
						b.v.cmplx_val.imag,
						a.v.cmplx_val.real*
						b.v.cmplx_val.imag+
						a.v.cmplx_val.imag*
						b.v.cmplx_val.real);
			}
	}
	push(&result);
}


f_div()
{
struct value a, b, result;
register double square;
	(void) pop(&b);
	(void) pop(&a);	/* now do a/b */

	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					if (b.v.int_val)
					  (void) integer(&result,a.v.int_val /
						b.v.int_val);
					else {
					  (void) integer(&result,0);
					  undefined = TRUE;
					}
					break;
				case CMPLX:
					square = b.v.cmplx_val.real*
						b.v.cmplx_val.real +
						b.v.cmplx_val.imag*
						b.v.cmplx_val.imag;
					if (square)
						(void) complex(&result,a.v.int_val*
						b.v.cmplx_val.real/square,
						-a.v.int_val*
						b.v.cmplx_val.imag/square);
					else {
						(void) complex(&result,0.0,0.0);
						undefined = TRUE;
					}
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					if (b.v.int_val)
					  
					  (void) complex(&result,a.v.cmplx_val.real/
						b.v.int_val,
						a.v.cmplx_val.imag/
						b.v.int_val);
					else {
						(void) complex(&result,0.0,0.0);
						undefined = TRUE;
					}
					break;
				case CMPLX:
					square = b.v.cmplx_val.real*
						b.v.cmplx_val.real +
						b.v.cmplx_val.imag*
						b.v.cmplx_val.imag;
					if (square)
					(void) complex(&result,(a.v.cmplx_val.real*
						b.v.cmplx_val.real+
						a.v.cmplx_val.imag*
						b.v.cmplx_val.imag)/square,
						(a.v.cmplx_val.imag*
						b.v.cmplx_val.real-
						a.v.cmplx_val.real*
						b.v.cmplx_val.imag)/
							square);
					else {
						(void) complex(&result,0.0,0.0);
						undefined = TRUE;
					}
			}
	}
	push(&result);
}


f_mod()
{
struct value a, b;
	(void) pop(&b);
	(void) pop(&a);	/* now do a%b */

	if (a.type != INT || b.type != INT)
		int_error("can only mod ints",NO_CARET);
	if (b.v.int_val)
		push(integer(&a,a.v.int_val % b.v.int_val));
	else {
		push(integer(&a,0));
		undefined = TRUE;
	}
}


f_power()
{
struct value a, b, result;
register int i, t, count;
register double mag, ang;
	(void) pop(&b);
	(void) pop(&a);	/* now find a**b */

	switch(a.type) {
		case INT:
			switch (b.type) {
				case INT:
					count = abs(b.v.int_val);
					t = 1;
					for(i = 0; i < count; i++)
						t *= a.v.int_val;
					if (b.v.int_val >= 0)
						(void) integer(&result,t);
					else
					  if (t != 0)
					    (void) complex(&result,1.0/t,0.0);
					  else {
						 undefined = TRUE;
						 (void) complex(&result, 0.0, 0.0);
					  }
					break;
				case CMPLX:
					mag =
					  pow(magnitude(&a),fabs(b.v.cmplx_val.real));
					if (b.v.cmplx_val.real < 0.0)
					  if (mag != 0.0)
					    mag = 1.0/mag;
					  else 
					    undefined = TRUE;
					mag *= exp(-b.v.cmplx_val.imag*angle(&a));
					ang = b.v.cmplx_val.real*angle(&a) +
					      b.v.cmplx_val.imag*log(magnitude(&a));
					(void) complex(&result,mag*cos(ang),
						mag*sin(ang));
			}
			break;
		case CMPLX:
			switch (b.type) {
				case INT:
					if (a.v.cmplx_val.imag == 0.0) {
						mag = pow(a.v.cmplx_val.real,(double)abs(b.v.int_val));
						if (b.v.int_val < 0)
						  if (mag != 0.0)
						    mag = 1.0/mag;
						  else 
						    undefined = TRUE;
						(void) complex(&result,mag,0.0);
					}
					else {
						/* not so good, but...! */
						mag = pow(magnitude(&a),(double)abs(b.v.int_val));
						if (b.v.int_val < 0)
						  if (mag != 0.0)
						    mag = 1.0/mag;
						  else 
						    undefined = TRUE;
						ang = angle(&a)*b.v.int_val;
						(void) complex(&result,mag*cos(ang),
							mag*sin(ang));
					}
					break;
				case CMPLX:
					mag = pow(magnitude(&a),fabs(b.v.cmplx_val.real));
					if (b.v.cmplx_val.real < 0.0)
					  if (mag != 0.0)
					    mag = 1.0/mag;
					  else 
					    undefined = TRUE;
					mag *= exp(-b.v.cmplx_val.imag*angle(&a));
					ang = b.v.cmplx_val.real*angle(&a) +
					      b.v.cmplx_val.imag*log(magnitude(&a));
					(void) complex(&result,mag*cos(ang),
						mag*sin(ang));
			}
	}
	push(&result);
}


f_factorial()
{
struct value a;
register int i;
register double val;

	(void) pop(&a);	/* find a! (factorial) */

	switch (a.type) {
		case INT:
			val = 1.0;
			for (i = a.v.int_val; i > 1; i--)  /*fpe's should catch overflows*/
				val *= i;
			break;
		default:
			int_error("factorial (!) argument must be an integer",
			NO_CARET);
		}

	push(complex(&a,val,0.0));
			
}


int
f_jump(x)
union argument *x;
{
	return(x->j_arg);
}


int
f_jumpz(x)
union argument *x;
{
struct value a;
	int_check(&top_of_stack);
	if (top_of_stack.v.int_val) {	/* non-zero */
		(void) pop(&a);
		return 1;				/* no jump */
	}
	else
		return(x->j_arg);		/* leave the argument on TOS */
}


int
f_jumpnz(x)
union argument *x;
{
struct value a;
	int_check(&top_of_stack);
	if (top_of_stack.v.int_val)	/* non-zero */
		return(x->j_arg);		/* leave the argument on TOS */
	else {
		(void) pop(&a);
		return 1;				/* no jump */
	}
}


int
f_jtern(x)
union argument *x;
{
struct value a;

	int_check(pop(&a));
	if (a.v.int_val)
		return(1);				/* no jump; fall through to TRUE code */
	else
		return(x->j_arg);		/* go jump to FALSE code */
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/lasergnu version [22cda9de82].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/csh -f
#
# $Id: lasergnu,v 3.26 92/03/24 22:37:01 woo Exp Locker: woo $
#
#
# Print gnuplot output on an Imagen or Postscript laser printer.

set print_banner = on	# Print a banner page unless told otherwise.
set input_files = ()    # the plot input command files
set lpr_opts = ()	    # options to lpr

# Default printer set by shell variable PRINTER.
if (! $?PRINTER) then 
    if ($?LASER) then
   	   set PRINTER=$LASER
    else
    	   set PRINTER="lw0"
    endif
endif
set printer = (-P$PRINTER)

# File for plot commands, and for plot output
set TMP=/tmp/plot$$
set outfile=$TMP.out	# the output file
onintr cleanup

# default is Imagen mode for Imagen printer; see -p option
set setterm="set terminal imagen"
set LANG="-Limpress"

set usage="usage: lasergnu [-Pprinter] [-b] [-p] [-t title] [-f file] ['plot command']...."

# Loop through the command-line arguments.

top:
	if ($#argv > 0) then

		switch ("$argv[1]")

		case -b*:	# Do not print a banner page.
		case -J*:	# Compatible with imprint.
			set print_banner = off
    	   	  	set lpr_opts=($lpr_opts -h)
			shift argv
			goto top

		case -f?*:	# Specify file containing plot commands
			set input_files = ($input_files `echo $argv[1] | sed 's/^-f//'`)
			shift argv
			goto top

		case -f:	# Specify file containing plot commands
			shift argv
			if ($#argv > 0) then
				set input_files = ($input_files $argv[1])
				shift argv
			else
				echo "Usage: -f file ..."
				echo "Type    lasergnu -help    for help."
				exit (1)
			endif
			goto top

		case -t?*:	# Specify title of plot
			echo set title \""`echo $argv[1] | sed 's/^-t//'`"\" >> $TMP
			shift argv
			goto top

		case -t:	# Specify title of plot
			shift argv
			if ($#argv > 0) then
				echo set title \""$1"\" >> $TMP
				shift argv
			else
				echo "Usage: -t title ..."
				echo "Type    lasergnu -help    for help."
				exit (1)
			endif
			goto top
          case -help:
			echo "$usage"
			exit(1)

		case -P?*:	# Set the printer, exactly as by itroff.
			set printer = $argv[1]
			shift argv
			goto top

		case -P:	# Set the printer, exactly as by itroff.
			shift argv
			if ($#argv > 0) then
				set printer = (-P$argv[1])
				shift argv
			else
				echo "Usage: -P printer ..."
				echo "Type    lasergnu -help    for help."
				exit (1)
			endif
			goto top

                # use impress 
    	   case -I:
	   		 echo Imagen is the default mode now
			 shift argv
	   		 goto top

                # use postscript instead of impress language
    	   case -p:
	   		 set setterm="set term postscript"
	   		 set LANG="-Lpostscript"
			 shift argv
	   		 goto top

		case -?*:
			echo "I do not recognize option $argv[1]."
			echo "$usage"
			exit (1)

		default:
	          echo "$argv[1]"	>> $TMP
			shift argv
			goto top

		endsw
	endif

# try to devine the printer type
if ($printer =~ -Plw*) then
    set setterm="set term postscript"
    set LANG="-Lpostscript"
endif

if ($printer =~ -Pim*) then
    set setterm="set term imagen"
    set LANG="-Limpress"
endif

# Set up input file
echo $setterm > $TMP.plt
echo set output \"$outfile\" >> $TMP.plt
if (-e $TMP) cat $TMP >> $TMP.plt

# If input file is specified AND command line contains plot commands, then
#	do command line args first, then plot commands in input file.
gnuplot $TMP.plt $input_files

if ($status == 0 && -e $outfile && ! -z $outfile) then
    # The printer is whatever printer was last specified,
    # or the default printer if none was specified.
    if ($LANG == -Limpress) then
        /usr/local/bin/ipr $LANG $printer \
    	   -D"jobheader $print_banner" \
    	   -D"pagereversal on" \
    	   -D"program lasergnu" $outfile
    else if ($LANG == -Lpostscript) then
    	   lpr $lpr_opts $printer $outfile
    endif
else
    echo "lasergnu: error in plotting or empty plot; nothing printed."
endif

cleanup:
rm -f $TMP* $outfile
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































Deleted r34.1/plot/lineproc.mac version [fd0d64c98d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
; lineproc.mac
; MASM macro definition for Bresenham line-drawing routine
; Colin Kelley
; January 13, 1987


INCAX	equ 40h			; for Self-Modifying Code
INCBX	equ 43h
DECAX	equ 48h
DECBX	equ 4bh

; usage:
;   lineproc linename, pixelname
;
; where linemane is the name you want for the proc, and pixelname is the
;   name of the routine that linename is to call to set pixels
;

lineproc macro linename, pixelname
beginproc linename

	push bp
	mov bp,sp
	push si
	push di
	mov ax,[bp+X]		; x1
	mov bx,[bp+X+2]		; y1
	mov cx,[bp+X+4]		; x2
	mov si,[bp+X+6]		; y2

	cmp ax,cx		; x1,x2
	jne i19
	cmp bx,si		; y1,y2
	jne i19

	call pixelname

	jmp i28
i19:
	mov dx,ax		; dx,x1
	sub dx,cx		; x2
	jnc noabsx
	neg dx
noabsx:
	mov di,bx		; dy,y1
	sub di,si		; y2
	jnc noabsy
	neg di			; dy
noabsy:
	cmp dx,di		; dx,dy
	jb i21			; go iterate y's
;
; iterate x's
;
	cmp bx,si		; y1,y2
	jb forwardy
	mov byte ptr cs:yinc1,DECBX
	jmp short i22
forwardy:
	mov byte ptr cs:yinc1,INCBX
i22:
	cmp ax,cx		; x1,x2
	jae l20004
	mov byte ptr cs:xinc1,INCAX
	jmp short l20005
l20004:
	mov byte ptr cs:xinc1,DECAX
l20005:
	mov bp,dx		; sum,dx
	shr bp,1		; sum
d23:
	cmp ax,cx		; x1,x2
	je i28			; done
xinc1:	inc ax			; may become inc or dec
	add bp,di		; sum,dy
	cmp bp,dx
	jb i27
	sub bp,dx		; sum,dx
yinc1:	inc bx			; may become inc or dec
i27:
	call pixelname
	jmp short d23

;
; else iterate y's
;
i21:
	cmp ax,cx		; x1,x2
	jae l20006
	mov byte ptr cs:xinc2,INCAX
	jmp short l20007
l20006:
	mov byte ptr cs:xinc2,DECAX
l20007:
	cmp bx,si		; y1,y2
	jb forwardy2
	mov byte ptr cs:yinc2,DECBX
	jmp short i29
forwardy2:
	mov byte ptr cs:yinc2,INCBX
i29:
	mov bp,di		; sum,dy
	shr bp,1		; sum,1
d30:
	cmp bx,si		; y1,y2
	je i28
yinc2:	inc bx			; may become inc or dec
	add bp,dx		; sum,dx
	cmp bp,di		; sum,dy
	jb i34
	sub bp,di		; sum,dy
xinc2:	inc ax			; may become inc or dec
i34:
	call near ptr pixelname
	jmp short d30
;
; clean up and exit
;
i28:
	pop di
	pop si
	pop bp
	ret

linename endp
	endm
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































Deleted r34.1/plot/linkopt.amg version [1bb83bd06e].

1
2
3
4
5
6
7
FROM LIB:c.o
     bitmap.o command.o eval.o graphics.o help.o internal.o misc.o parse.o
     plot.o scanner.o setshow.o standard.o term.o util.o version.o contour.o
     graph3d.o
TO gnuplot
LIB LIB:lcmieee.lib LIB:lcnb.lib
VERBOSE
<
<
<
<
<
<
<














Deleted r34.1/plot/linkopt.msc version [8248bb9b7c].

1
2
3
4
5
pcgraph+hrcgraph+corgraph+bitmap+term+graphics+graph3d+contour+
plot+setshow+command+help+internal+misc+
parse+eval+scanner+standard+util+version
gnuplot
nul;
<
<
<
<
<










Deleted r34.1/plot/linkopt.tc version [dea42a2994].

1
2
3
4
5
6
7
8
9
c:\tc\lib\C0l +
bitmap command eval graphics graph3d help internal misc parse +
plot scanner setshow standard term util version contour +
egavgaf hercf cgaf attf +
,gnuplot,gnuplot, +
c:\tc\lib\emu +
c:\tc\lib\mathl +
c:\tc\lib\cl +
c:\tc\lib\graphics
<
<
<
<
<
<
<
<
<


















Deleted r34.1/plot/linkopt.tco version [7ede6d6dfe].

1
2
3
4
5
6
7
8
9
10
c:\tc\lib\C0l +
/o bitmap command eval graphics graph3d help internal misc parse +
plot scanner setshow standard term util version contour +
/o- egavgaf hercf cgaf attf +
,gnuplot,gnuplot, +
c:\tc\lib\overlay +
c:\tc\lib\emu +
c:\tc\lib\mathl +
c:\tc\lib\cl +
c:\tc\lib\graphics
<
<
<
<
<
<
<
<
<
<




















Deleted r34.1/plot/linkopt.vms version [d20ee8c667].

1
sys$library:vaxcrtl/share
<


Deleted r34.1/plot/makefile.amg version [55168d01df].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Makefile for SAS/C 5.10 on the Amiga
#
# $Id: makefile.amg,v 3.26 92/03/24 22:36:53 woo Exp Locker: woo $
#
#

CC = lc

# Remove '-fi' if you don't want to use the better Commodore math-routines.
# If you do so, you'll have to change 'lcmieee.lib' to 'lcm.lib' in
# "linkopt.amg"
CFLAGS = -b0 -dAMIGA_LC_5_1 -dNOGAMMA -dMEMSET -dMEMCPY -j85i -j88i -fi

.c.o:
	$(CC) $(CFLAGS) $<

OBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o help.o \
	internal.o misc.o parse.o plot.o scanner.o setshow.o \
	standard.o term.o util.o version.o

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.o internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/aed.trm term/cgi.trm term/dumb.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 term/vws.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pbm.trm term/pc.trm \
	term/amiga.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 gnuplot_x11.c
CSOURCE8 = contour.c

gnuplot: $(OBJS)
	blink with linkopt.amg

bitmap.o: bitmap.c bitmap.h plot.h
command.o: command.c plot.h setshow.h help.h
contour.o: contour.c plot.h
eval.o: eval.c plot.h
graph3d.o: graph3d.c plot.h setshow.h
graphics.o: graphics.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 help.h
parse.o: parse.c plot.h
plot.o: plot.c plot.h setshow.h
scanner.o: scanner.c plot.h
setshow.o: setshow.c plot.h setshow.h
standard.o: standard.c plot.h
term.o: term.c term.h plot.h setshow.c bitmap.h $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
util.o: util.c plot.h
version.o: version.c
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted r34.1/plot/makefile.ami version [ca2ed567d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#
# $Id: makefile.ami,v 3.26 92/03/24 22:36:54 woo Exp Locker: woo $
#
#
#   Makefile for the Amiga             Pat R. Empleo
#                                      Sept 1991
#      Manx Aztec C 5.2 beta version
#
#   Usage:
#
#      make -f makefile.ami
#
#

# where to install help file gnuplot.gih
HELPDEST=GNUPLOT:docs/gnuplot.gih
# Where to send email about bugs and comments (locally)
EMAIL="bug-gnuplot@ames.arc.nasa.gov"

#
# Manx Aztec C v5.2 compiler options
#
# -DVFORK  We use this switch to invoke fexecv()
#
CC     = cc
CFLAGS = -DVFORK -DNOGAMMA -DMEMSET -DMEMCPY -DAMIGA_AC_5 -fa -sab -wosw -MR

#
# Manx Aztec C v5.2 linker options
#
LD   = ln
LIBS = -lma -lc

#
# Terminal (device) support --- see term.h
#
TERMFLAGS = -Iterm

#
# List of object files except term.o, version.o
#
OBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o help.o \
	   internal.o misc.o parse.o plot.o scanner.o \
	   setshow.o standard.o util.o  

#
# List of sources
#
CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/amiga.trm 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 \
	term/apollo.trm term/gpr.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pbm.trm term/pc.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 term/bigfig.trm term/vws.trm gnuplot_x11.c
CSOURCE8 = contour.c

#
# Docs
#
DOCS1 = docs/Makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entry.sty \
	docs/titlepage.ms docs/titlepage.tex
DOCS2 = docs/gnuplot.doc
DOCS3 = docs/latextut/Makefile docs/latextut/eg1.plt \
	docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
	docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
	docs/latextut/header.tex docs/latextut/tutorial.tex \
	docs/latextut/linepoint.plt

#
# Targets
#

default: gnuplot doc

gnuplot: $(OBJS) term.o version.o
	$(LD) $(OBJS) term.o version.o $(LIBS) -o gnuplot

doc:
	cd docs
	make -f makefile.ami gih

#
# Dependencies
#
plot.o: plot.c
	$(CC) $(CFLAGS) plot.c

term.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) term.c

version.o:
	$(CC) $(CFLAGS) -DCONTACT=$(EMAIL) version.c

$(OBJS): plot.h
	$(CC) $(CFLAGS) $*.c

command.o:
	$(CC) $(CFLAGS) -c command.c -DHELPFILE="$(HELPDEST)"

command.o help.o misc.o: help.h

command.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h

bitmap.o term.o: bitmap.h

#
# misc
#
clean:
	delete #?.o

veryclean: spotless

spotless:
	delete #?.o gnuplot

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































Deleted r34.1/plot/makefile.msc version [15c775544f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#
# $Id: makefile.msc,v 3.26 92/03/24 22:36:31 woo Exp Locker: woo $
#
# Make file for use with Microsoft C  Version 5.10
# and Microsoft Program Maintenance Utility  Version 4.07
# 

# where to place gnuplot.gih helpfile
HELPFILE = gnuplot.gih

# /c  means don't link
# /AL means large memory model (large code, large data)
# /DPC means define symbol PC
CFLAGS = /c /AL /DPC #/DMSDOS #/Zi #/Od

# see other terminal defines in term.h
TERMFLAGS = 

# /NOE means NO EXTernal Dictionary
# /EX  means pack EXE file
# /ST:10000 means stack size 10000 bytes
LINKFLAGS = /NOE /EX /ST:10000 #/codeview 

OBJS = 	bitmap.obj command.obj contour.obj eval.obj graphics.obj graph3d.obj \
	help.obj internal.obj misc.obj parse.obj plot.obj readline.obj \
	scanner.obj setshow.obj standard.obj term.obj util.obj version.obj \
	pcgraph.obj hrcgraph.obj corgraph.obj

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\pc.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.obj:
	cl $(CFLAGS) $*.c

.asm.obj:
	masm $*;

pcgraph.obj: pcgraph.asm header.mac lineproc.mac

corgraph.obj: corgraph.asm header.mac lineproc.mac

hrcgraph.obj: hrcgraph.asm header.mac lineproc.mac

bitmap.obj: bitmap.c bitmap.h plot.h

command.obj: command.c plot.h setshow.h help.h
	cl $(CFLAGS) /DHELPFILE=\"$(HELPFILE)\" command.c

contour.obj: contour.c plot.h

eval.obj: eval.c plot.h

graphics.obj: graphics.c plot.h setshow.h

graph3d.obj: graphics.c plot.h setshow.h

help.obj: help.c plot.h help.h

internal.obj: internal.c plot.h

misc.obj: misc.c plot.h setshow.h

parse.obj: parse.c plot.h

plot.obj: plot.c plot.h setshow.h

readline.obj: readline.c

scanner.obj: scanner.c plot.h

setshow.obj: setshow.c plot.h setshow.h

standard.obj: standard.c plot.h

term.obj: term.c term.h plot.h setshow.h bitmap.h $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	cl $(CFLAGS) $(TERMFLAGS) /Iterm term.c

util.obj: util.c plot.h

version.obj: version.c

# convert gnuplot.doc to gnuplot.gih
doc2gih.exe: docs\doc2gih.c
	cl docs\doc2gih.c

$(HELPFILE): doc2gih.exe docs\gnuplot.doc
	doc2gih docs\gnuplot.doc $(HELPFILE)

# Object files in link command line are ordered to avoid far jumps.
# use linkopt.msc to avoid command-line overflow

gnuplot.exe: $(OBJS)
 link $(LINKFLAGS) @linkopt.msc
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































Deleted r34.1/plot/makefile.tc version [bff8cf0cc3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#
# $Id: makefile.tc,v 3.26 92/03/24 22:36:32 woo Exp Locker: woo $
#
#
# make file for Borland C++ 2.0/Turbo C++ 1.0/Turbo C 2.0
# uses Borland proprietry overlay manager
# Modified from the TurboC makefile by Maurice Castro
# The compile and link includes debug flags.  Take them out if you
# do not want them included  (-y -v -M, /m /s /v /l)

# where to place gnuplot.gih helpfile
HELPFILE = gnuplot.gih
# location of Turbo C compiler
# if this is changed then linkopt.tc/linkopt.tco will need to be edited.
TC = c:\tc
# name of C compiler
CC = bcc
#CC = tcc
# location of TLINK.EXE and TCC.EXE or BCC.EXE
BIN = $(TC)\bin\\
#BIN =
# location of BGI files,
# change this line if not in TC directory, i.e. $(TC)\bgi
BGI = $(TC)\bgi
# location of bgiobj.exe tool - convertion of BGI to a linkable OBJ file.
BGIOBJ = $(TC)\bgi\\
#BGIOBJ =

# -c means don't link, -f means emulate 8087 if not present
# -ml means use large model (large code, large data)
# -M means produce link map
# -y means include line numbers for debugger
# -v means include debug info
# -w- means ignore warnings and do not report them
# -DREADLINE to use the history/line editing capability. If you want this 
#    capability add -DREADLINE to CFLAGS then add 'readline' to linkopt.tc
#    and to linkopt.tco in the /o section.
CFLAGS = -c -f -ml -M -y -v -w- -I$(TC)\include -DMSDOS -DPC
TERMFLAGS =

# With Overlay Support
#OVLY1 = -Y
#OVLY2 = -Yo
# Without Overlay Support
OVLY1 =
OVLY2 =


OBJS = 	bitmap.obj command.obj contour.obj eval.obj graphics.obj graph3d.obj \
	help.obj internal.obj misc.obj parse.obj plot.obj readline.obj \
	scanner.obj setshow.obj standard.obj term.obj util.obj version.obj \
	cgaf.obj egavgaf.obj hercf.obj attf.obj

CSOURCE5 = term\aed.trm term\cgi.trm term\dumb.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\pc.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

all: gnuplot.exe $(HELPFILE)

# use linkopt.tc/linkopt.tco to avoid command-line overflow

gnuplot.exe: $(OBJS) 
# With Overlay Support (select one)
#	$(BIN)tlink /m /s /v /l @linkopt.tco
#	$(BIN)tlink @linkopt.tco 
# Without Overlay Support
#	$(BIN)tlink /m /s /v /l @linkopt.tc
	$(BIN)tlink @linkopt.tc 

# default rules

.c.obj:
	$(BIN)$(CC) $(OVLY2) $(CFLAGS) $<

# The default for files is to be compiled for overlaying if OVLY1 and 
# OVLY2 are defined.  plot.c and parse.c are not suitable for overlaying.

bitmap.obj: bitmap.c bitmap.h plot.h

command.obj: command.c plot.h setshow.h help.h
	$(BIN)$(CC) $(OVLY2) $(CFLAGS) -DHELPFILE="$(HELPFILE)" command.c

contour.obj: contour.c plot.h

eval.obj: eval.c plot.h

graphics.obj: graphics.c plot.h setshow.h

graph3d.obj: graphics.c plot.h setshow.h

help.obj: help.c plot.h help.h

internal.obj: internal.c plot.h

misc.obj: misc.c plot.h setshow.h help.h

parse.obj: parse.c plot.h
	$(BIN)$(CC) $(OVLY1) $(CFLAGS) parse.c

plot.obj: plot.c plot.h setshow.h
	$(BIN)$(CC) $(OVLY1) $(CFLAGS) plot.c

readline.obj: readline.c

scanner.obj: scanner.c plot.h

setshow.obj: setshow.c plot.h setshow.h

standard.obj: standard.c plot.h

term.obj: term.c term.h plot.h setshow.c bitmap.h $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(BIN)$(CC) $(OVLY2) $(CFLAGS) $(TERMFLAGS) -Iterm term.c

util.obj: util.c plot.h

version.obj: version.c

# convert gnuplot.doc to gnuplot.gih
$(HELPFILE): doc2gih.exe docs\gnuplot.doc
	doc2gih docs\gnuplot.doc $(HELPFILE)

doc2gih.exe: docs\doc2gih.c
	$(BIN)$(CC) -I$(TC)\include -L$(TC)\lib docs\doc2gih.c

# convert Borland Graphics Interface files to object for linking
cgaf.obj: $(BGI)\cga.bgi
	$(BGIOBJ)bgiobj /F $(BGI)\cga

egavgaf.obj: $(BGI)\egavga.bgi
	$(BGIOBJ)bgiobj /F $(BGI)\egavga

hercf.obj: $(BGI)\herc.bgi
	$(BGIOBJ)bgiobj /F $(BGI)\herc

attf.obj: $(BGI)\att.bgi
	$(BGIOBJ)bgiobj /F $(BGI)\att
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































Deleted r34.1/plot/makefile.unx version [087265c103].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
#
# $Id: makefile.unx,v 3.26 92/03/24 22:36:48 woo Exp Locker: woo $
#
############################################################
#
# GNUPLOT 3.2 Makefile (Unix X11 support) for
#  Apollo/Sun/Dec5000/IBMrs6000/HP9000/SGI/3B1/386IX/Cray
#
# Original version by:
#   oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA)
#   Wed, 3 Jul 91 14:31:37 -0400
#
#>>> Customizing: You must customize part of this makefile for your site.
#>>> Then type 'make' for further instructions.
#>>> Customization instructions look like these lines do (#>>>).
#

TARGET = All # What to make by default

############################################################
#>>> Decide where the binaries and manuals will go. 
# directory where to install executables on 'make install'
DEST=/usr/local/bin
# directory for installing man page on 'make man_install'.
MANDEST=/usr/local/man/manl
# where to install help file gnuplot.gih
HELPDEST=/usr/local/lib/gnuplot.gih
#HELPDEST=docs/gnuplot.gih
# Where to send email about bugs and comments (locally)
EMAIL=bug-gnuplot@ames.arc.nasa.gov

############################################################
#>>> Choose your C compiler and basic compiler flags.
CC     = cc # the C compiler
COPTS  = -O # -O if you trust your compiler's optimizer
LD     =$(CC) $(CFLAGS)	    # default loading command
NPROC  = 2
RCSOLD = 3.25
RCSVER = 3.26
RCSCOM = "gnuplot3.2  release6"

############################################################
#>>> Choose some optional features. 
#>>> At this point there are only two optional features:
# READLINE:
#   If READLINE is defined, then command-line editing is supported.
#   Otherwise, your normal terminal editing is all you get.
#   Some machines will not support this, and they will turn this
#   option off (for example, apollos running SR10.2 or SR10.3 and
#   loaded with BSD4.3 instead of SYS5). Note: problems with 
#   gnuplot prompts have been noted when this feature is selected
#   on IBM RS/6000 AIX, and compile errors are encountered on
#   Sequent Dynix 3 and Convex OS 9.0.
# NOCWDRC:
#   If NOCWDRC is defined, then any .gnuplot in the current directory
#   is not read on startup. This is a security consideration
#   especially for root users ( we recommend you define -DNOCWDRC ).
OPTIONS = -DREADLINE -DNOCWDRC

#>>> Optionally install the lasergnu script.
# Lasergnu is a handy shell script for creating a plot from the
# command line and sending it directly to the printer. It currently
# supports postscript and imagen printers, and probably would need
# tailoring to your site.
# Use lasergnu_install to install lasergnu.
# Use lasergnu_noinstall to not install lasergnu (default).
LASERGNU = lasergnu_install

############################################################
# X11 support
#

#>>> List your X11 libraries
X11LIBS = -lX11

#>>> List where the X11 include directory is found (if other than /usr/include)
X11INCLUDES =

#>>> List additional CFLAGS for X11 compilation
# -DOLD_SELECT if you have an old 4.2 BSD OS (e.g. Sun OS 3.5) and
#   encounter compile error for missing include file <sys/select.h>
X11FLAGS = 

#>>> You shouldn't have to change these, since they are controlled by
#>>> Machine dependent definitions below.
#       Compile option for plot.c and TERMFLAGS, to include X11 support
PLOTXFLAG = -DX11
#       make gnuplot_x11 by default
GNUPLOT_X11 = gnuplot_x11
#       install gnuplot_x11 by default
X11INSTALL = x11_install

############################################################
#>>> Okay, you've changed enough. Now type 'make'.

############################################################
# This is used to pass many of the above definitions to make
# subprocesses. Don't change this.
MY_FLAGS  = CC="$(CC)" 	COPTS="$(COPTS)" DEST="$(DEST)" \
		MANDEST="$(MANDEST)" HELPDEST="$(HELPDEST)" \
		EMAIL="$(EMAIL)" LASERGNU="$(LASERGNU)"

############################################################
# Explanations of CFLAGS definitions.
#  These should not need to be changed by you.
# They are set correctly for each machine below. If your machine
# doesn't fit the one of the patterns, override on the make command
# line or make a new target for it and a new _FLAGS definition. 
#  -DNOVFORK if you're unix and you have don't have vfork()
#  -DMEMSET if you need to use memset() instead of bzero() 
#  -DMEMCPY if your bcopy() is called memcpy()
#  -DNOCOPY if you don't have a memcpy() by any name
#  -DGAMMA=foo if your gamma function is called foo(). Apollos have
#    lgamma(3m). If you don't have gamma(), use -DNOGAMMA.
#    The default is -DGAMMA=gamma.
#  -DGETCWD if your unix uses getcwd() instead of getcd()
#    this is needed by HP-UX and Cray Unicos systems.
#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
#    "every other plot" problem.
#  -DCRIPPLED_SELECT if "select errors" are encountered with X. This
#    option is needed on SVR3 platforms with incomplete support for
#    the BSD select() system call
#  -Dunix is required to explicitly define "unix" for SCO and IBM
#   	   RS/6000 running AIX 3.1 
#  -fswitch if you are compiling on a Sun3 (or even -f68881)
#    (but -fswitch is buggy on some systems, so watch out)

# Defaults in case the user types 'make All' directly
# Should match X11_FLAGS's CFLAGS definition
CFLAGS = $(COPTS) $(OPTIONS)

############################################################
# Terminal (device) support
#
# All devices available to a given machine are compiled in by default.
# This documents the flags available in TERMFLAGS, although TERMFLAGS
# is usually controlled by the machine-dependent definitions below.
# See other terminal defines in term.h.
# Define ULTRIX_KLUDGE if you have the every-other plot problem in Ultrix X11.
#
# -DAPOLLO      Apollo Graphics Primitive Resource (window resize after replot)
# -DGPR         Apollo Graphics Primitive Resource (fixed-size window)
# -DCGI         SCO CGI
# -DIRIS4D      IRIS4D series computer
# -DSUN         Sun Microsystems Workstation
# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
# -DUNIXPLOT    unixplot
# -DX11         X11 Window System (This is $(PLOTXFLAG))
TERMFLAGS = -Iterm -DUNIXPLOT $(PLOTXFLAG) 

############################################################
# Library explanations. 
#  You shouldn't need to adjust this; again, it is handled by the
# machine-dependent definitions below.
#
#  -lplot if you have -DUNIXPLOT in TERMFLAGS
#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
#  -lgl_s if -DIRIS4D in TERMFLAGS
#  -lccgi if -DCGI in TERMFLAGS
LIBS = -lm -lplot

####################################################################
# List of object files except version.o
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 scanner.o \
	   setshow.o standard.o term.o util.o  

NEXTOBJS = EPSView.o EpsViewer.o
############################################################
# Machine-dependent settings.
#
X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

DEC_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) " \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DULTRIX_KLUDGE"

APOLLO_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)  -DGAMMA=lgamma" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="-L/usr/lib/X11 -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DAPOLLO -DGPR"

HP_FLAGS = \
    	   CFLAGS="+O1 $(OPTIONS) -DMEMSET -DMEMCPY  -DGETCWD" \
    	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="-I/usr/include/X11R4" \
    	   X11LIBS="-L/usr/lib/X11R4 -lX11" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11"

SUN_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DSUN"

SUN_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS)" \
    	   LIBS="-lsuntool -lsunwindow -lpixrect $(LIBS)" \
    	   X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS) -DSUN"

SGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
    	   LIBS="-lgl_s -lm" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DIRIS4D"

SGIX11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
    	   LIBS="-lgl_s -lm -lc_s" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="-L/usr/lib/X11 -lX11" \
     	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
     	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11 -DIRIS4D"

CGI_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix" \
    	   LIBS="-lccgi $(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DCGI"

3B1_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " \
    	   PLOTXFLAG=" " GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   LD="ld /lib/crt0s.o /lib/shlib.ifile" \
    	   TERMFLAGS="-Iterm -DUNIXPC"

386IX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS=" " X11INCLUDES=" " \
    	   X11LIBS=" " PLOTXFLAG=" " GNUPLOT_X11=" " \
    	   X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm -DUNIXPLOT"
386IX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DNOVFORK -DTCSETSW -DTCGETS" \
    	   LIBS="$(LIBS) -lcposix" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
    	   X11INSTALL= "$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DUNIXPLOT -DX11"
 	
AIX_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -Dunix -DNOVFORK" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

NEXT_FLAGS = \
    	   CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT" \
           LIBS="-lNeXT_s -lsys_s -lm" \
    	   X11FLAGS="$(X11FLAGS)" \
    	   X11INCLUDES=" " X11LIBS=" " PLOTXFLAG=" " \
    	   GNUPLOT_X11=" " X11INSTALL=x11_noinstall \
    	   TERMFLAGS="-Iterm" OBJS=" $(OBJS) $(NEXTOBJS)"

NEXT_X11_FLAGS = \
    	   CFLAGS="$(COPTS) -DGAMMA=lgamma -DNEXT" \
           LIBS="-lNeXT_s -lsys_s -lm" \
           X11LIBS="-L/usr/lib/X11 -lX11" \
    	   X11INCLUDES="$(X11INCLUDES)" X11FLAGS="$(X11FLAGS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="-Iterm -DX11" OBJS=" $(OBJS) $(NEXTOBJS)"

CRAY_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
	   LIBS="-lm" X11FLAGS=" " \
	   X11INCLUDES=" " \
	   X11LIBS=" " \
	   PLOTXFLAG=" " GNUPLOT_X11=" " \
	   X11INSTALL=x11_noinstall \
	   TERMFLAGS="-Iterm"

CRAY_X11_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DNOVFORK" \
	   LIBS="-lm" X11FLAGS="$(X11FLAGS)" \
	   X11INCLUDES="$(X11INCLUDES)" \
	   X11LIBS="$(X11LIBS)" \
	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
	   X11INSTALL=$(X11INSTALL) \
	   TERMFLAGS="-Iterm -DX11"

PTX_X11_FLAGS = \
	   CFLAGS="$(COPTS) $(OPTIONS) -DGETCWD -DMEMSET -DMEMCPY -DCRIPPLED_SELECT" \
	   LIBS="-lm -lplot" X11FLAGS="$(X11FLAGS)" \
	   X11INCLUDES="$(X11INCLUDES)" \
	   X11LIBS="-lX11 -lseq -lsocket -linet -lnsl" \
	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11="$(GNUPLOT_X11)" \
	   X11INSTALL=$(X11INSTALL) \
	   TERMFLAGS="$(TERMFLAGS)"

CONVEX_X11_FLAGS = \
    	   CFLAGS="$(COPTS) $(OPTIONS) -DHUGE=8.9e307" \
    	   LIBS="$(LIBS)" X11FLAGS="$(X11FLAGS)" X11INCLUDES="$(X11INCLUDES)" \
    	   X11LIBS="$(X11LIBS)" \
    	   PLOTXFLAG="$(PLOTXFLAG)" GNUPLOT_X11=$(GNUPLOT_X11) \
    	   X11INSTALL="$(X11INSTALL)" \
    	   TERMFLAGS="$(TERMFLAGS)"

####################################################################
# List of source files
# Used for makeing shar files, lint, and some dependencies.
DIRS = term demo docs docs/latextut

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = term/amiga.trm 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 \
	term/apollo.trm term/gpr.trm term/ai.trm term/next.trm
CSOURCE6 = term/impcodes.h term/imagen.trm term/object.h \
	term/iris4d.trm term/kyo.trm term/latex.trm term/pbm.trm term/pc.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 term/bigfig.trm term/vws.trm gnuplot_x11.c
CSOURCE8 = contour.c
NEXTSRC  = EPSView.m EPSView.h EpsViewer.m EpsViewer.h
# not C code, but still needed

DEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.demo demo/controls.demo \
	demo/electron.demo demo/glass.dat demo/param.demo demo/polar.demo \
	demo/simple.demo demo/surface1.demo demo/surface2.demo demo/using.dat \
	demo/using.demo demo/world.cor demo/world.dat demo/world.demo \
	demo/err.dat demo/poldat.demo demo/polar.dat demo/errorbar.demo \
	demo/antenna.dat demo/all.demo demo/bivariat.demo demo/hidden.demo

ETC = Copyright README README.gnutex README.amiga makefile.unx makefile.vms  \
	linkopt.amg makefile.amg makefile.ami linkopt.vms buildvms.com \
	lasergnu  README.3d README.x11 README.NeXT \
	term/README History gnuplot.el Intergraph.x11 README.Install

#BETA files (not standard distribution files)
BETA = BETA6
# PC-specific files
PC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
	linkopt.msc linkopt.tc linkopt.tco makefile.msc makefile.tc \
	pcgraph.asm 

# Documentation and help files
DOCS1 = docs/Makefile docs/README docs/checkdoc.c docs/doc2gih.c \
	docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
	docs/gnuplot.1 docs/lasergnu.1 docs/toc_entry.sty \
	docs/titlepage.ms docs/titlepage.tex docs/Makefile.ami
DOCS2 = docs/gnuplot.doc
DOCS3 = docs/latextut/Makefile docs/latextut/eg1.plt \
	docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
	docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
	docs/latextut/header.tex docs/latextut/tutorial.tex \
	docs/latextut/linepoint.plt

#########################################################################
# Default target (informational)
info:
	@echo "Please do a 'make <MACHINE>' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo       for Apollo running SR10.3 with Apollo's X11"
	@echo "dec          for Dec3100/5000 running Ultrix 3.1d with MIT's X11"
	@echo "hp           for HP/9000 700 series running HP/UX 8.0 with MIT's X11R4"
	@echo "sun          for Sun sparcstation running SunOS 4.1 with suntools (no X11) "
	@echo "sun_x11      for Sun sparcstation running SunOS 4.1 with suntools and X11 "
	@echo "sgi          for Silicon Graphics IRIS4D machines (no X11) "
	@echo "sgix11       for Silicon Graphics IRIS4D machines (X11) "
	@echo "next         for NeXT Cube and Slab running NeXTOS 2.0+ (no X11)"
	@echo "next_11      for NeXT Cube and Slab running NeXTOS 2.0+ with X11"
	@echo "3b1          for ATT 3b1 machines (no X11) "
	@echo "386ix        for 386 machines running 386/ix (no X11)"
	@echo "386ix_x11    for 386 machines running 386/ix with T.Roell X386"
	@echo "ibmrs6000    for IBM RS/6000 running Aix 3.1 with IBM's X11"
	@echo "x11          for a generic machine (like a sun or dec) with MIT's X11"
	@echo "cray         for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 (no X11)"
	@echo "cray_x11     for Cray Y-MP or Cray-2 running Unicos 6.0 or 6.1 with X11"
	@echo "ptx_x11      for Sequent Dynix/PTX with MIT X11"
	@echo "convex_x11   for Convex 9.0 with MIT X11"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11"
	@echo "         make apollo"
	@echo "         make apollo       OPTIONS='-DNOCWDRC' "
	@echo "         make apollo       DEST='/usr/um/misc/bin' "
	@echo "         make dec"
	@echo "         make hp"
	@echo "         make next"
	@echo "         make sun          HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make sun          X11INCLUDES='-I/usr/local/include' "
	@echo "         make sun_x11"
	@echo "         make sgi"
	@echo "         make 3b1"
	@echo "         make 386ix"
	@echo "         make ibmrs6000    MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo "         make cray"
	@echo "         make cray_x11"
	@echo 
	@echo "If you just type 'make All' , it will build gnuplot for Unix X11"
	@echo "and the following variables will be used as default:"
	@echo 
	@echo " DEST                     " $(DEST)
	@echo " MANDEST                  " $(MANDEST)
	@echo " HELPDEST                 " $(HELPDEST)
	@echo " EMAIL                    " $(EMAIL)
	@echo " CC                       " $(CC)
	@echo " COPTS                    " $(COPTS)
	@echo " OPTIONS                  " $(OPTIONS)
	@echo " CFLAGS                   " $(CFLAGS)
	@echo " LIBS                     " $(LIBS)
	@echo " X11FLAGS                 " $(X11FLAGS)
	@echo " X11LIBS                  " $(X11LIBS)
	@echo " X11INCLUDES              " $(X11INCLUDES)
	@echo " TERMFLAGS                " $(TERMFLAGS)
	@echo " LASERGNU                 " $(LASERGNU)
	@echo 
	@echo "If you are not familiar with makefiles or just want to know what"
	@echo " 'make <MACHINE>' would  do without actually doing anything, then type"
	@echo " 'make <MACHINE> -n' "
	@echo 

###############################################################
# Targets for each machine

x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(X11_FLAGS)    $(TARGET)

dec:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(DEC_FLAGS)      $(TARGET)

apollo:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(APOLLO_FLAGS)   $(TARGET)

hp:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(HP_FLAGS)       $(TARGET)

next:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_FLAGS)     $(TARGET)

next_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(NEXT_X11_FLAGS)     $(TARGET)

sun:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_FLAGS)      $(TARGET)

sun_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SUN_X11_FLAGS)  $(TARGET)

sgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGI_FLAGS)      $(TARGET)

sgix11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(SGIX11_FLAGS)   $(TARGET)

cgi:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CGI_FLAGS)      $(TARGET)

3b1:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(3B1_FLAGS)      $(TARGET)

386ix:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_FLAGS)    $(TARGET)

386ix_x11: 
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(386IX_X11_FLAGS) $(TARGET)

ibmrs6000:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(AIX_FLAGS)      $(TARGET)

cray:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_FLAGS)     $(TARGET)
cray_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CRAY_X11_FLAGS) $(TARGET)
ptx_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(PTX_X11_FLAGS) $(TARGET)
convex_x11:
	$(MAKE) $(MFLAGS) $(MY_FLAGS) $(CONVEX_X11_FLAGS) $(TARGET)

#############################################################
# Targets that really do something

all:
	@echo "Please just type  'make'  in order to get some information on "
	@echo "how to build gnuplot under Unix and the X Window System."

All:	gnuplot $(GNUPLOT_X11) doc

gnuplot: $(OBJS) version.o
	$(LD) $(OBJS) version.o $(LIBS) -o gnuplot

doc:
	( cd docs; $(MAKE) $(MFLAGS) gnuplot.gih )

gnuplot_x11: gnuplot_x11.c
	$(CC) $(CFLAGS) $(X11FLAGS) $(X11INCLUDES) -o gnuplot_x11 gnuplot_x11.c $(X11LIBS)

################################################################
# Installation instructions

install:
	@echo 
	@echo "Please do a 'make <MACHINE> TARGET=Install' where <MACHINE> is one of the following:"
	@echo 
	@echo "apollo, dec, hp, sun, sun_x11, sgi, sgix11, cgi,"
	@echo "next, next_x11, 3b1, 386ix, 386ix_x11, ibmrs6000,"
	@echo "x11, cray, cray_x11, ptx_x11, convex_x11"
	@echo 
	@echo "Examples:"
	@echo
	@echo "         make x11          TARGET=Install "
	@echo "         make apollo       TARGET=Install "
	@echo "         make dec          TARGET=Install "
	@echo "         make hp           TARGET=Install "
	@echo "         make sun          TARGET=Install HELPDEST='/usr/um/misc/lib/gnuplot.gih' "
	@echo "         make ibmrs6000    TARGET=Install MANDEST='/usr/um/misc/man/man1' COPTS='-O' "
	@echo 
################################################################
# Installation targets

Install: All man_install $(X11INSTALL) $(LASERGNU)
	cp gnuplot     $(DEST)
	strip $(DEST)/gnuplot
	( cd docs; $(MAKE) $(MFLAGS) install-unix HELPDEST=$(HELPDEST) )

x11_install: gnuplot_x11
	cp gnuplot_x11 $(DEST)
	strip $(DEST)/gnuplot_x11

x11_noinstall: 
	@echo "X11 not requested, so gnuplot_x11 program not installed"

man_install: docs/gnuplot.1
	cp docs/gnuplot.1 $(MANDEST)

lasergnu_install: lasergnu docs/lasergnu.1
	cp lasergnu $(DEST)
	chmod 755 $(DEST)/lasergnu
	cp docs/lasergnu.1 $(MANDEST)

lasergnu_noinstall:
	@echo 
	@echo "Lasergnu will not be installed by default."
	@echo "If you think you need the lasergnu script to print"
	@echo " files on the imagen or postscript printers, then"
	@echo " type"
	@echo "      'make <MACHINE> TARGET=Install LASERGNU='lasergnu_install' "
	@echo
	@echo "Lasergnu is really not needed since within gnuplot you can"
	@echo " can create files (in impress or postscript language) and"
	@echo " print them through your favorite print command (lpr, lp, prf, ipr)."
	@echo 

################################################################
# Dependencies

plot.o: plot.c
	$(CC) $(CFLAGS) $(PLOTXFLAG) -c plot.c

term.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) -c term.c

version.o:
	$(CC) $(CFLAGS) -DCONTACT=\"$(EMAIL)\" -c version.c

EpsViewer.o : EpsViewer.h EpsViewer.m EPSView.h
	$(CC) -c EpsViewer.m

EPSView.o : EPSView.h EPSView.m
		$(CC) -c EPSView.m  

$(OBJS): plot.h

command.o: command.c
	$(CC) $(CFLAGS) -c command.c -DHELPFILE=\"$(HELPDEST)\"

command.o help.o misc.o: help.h

command.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h

bitmap.o term.o: bitmap.h

################################################################
# Miscellaneous targets

SOURCES=plot.h help.h setshow.h bitmap.h term.h $(CSOURCE1) $(CSOURCE2) \
	$(CSOURCE3) $(CSOURCE4) $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)\
	 $(CSOURCE8) $(NEXTSRC)

DOCS  = $(DOCS1) $(DOCS2) $(DOCS3)

lint:
	lint -hx $(SOURCES)

clean:
	rm -f *.o *~ *.bak term/*~ term/*.bak
	( cd docs; $(MAKE) $(MFLAGS) clean )
	( cd docs/latextut; $(MAKE) $(MFLAGS) clean )

spotless:
	rm -f *.o *~ *.bak term/*~ term/*.bak TAGS gnuplot gnuplot_x11
	( cd docs; $(MAKE) $(MFLAGS) clean )
	( cd docs/latextut; $(MAKE) $(MFLAGS) spotless )

################################################################
# Making shar files for mailing gnuplot

shar: gnuplot.sh00 gnuplot.sh01 gnuplot.sh02 gnuplot.sh03 gnuplot.sh04 \
	gnuplot.sh05 gnuplot.sh06 gnuplot.sh07 gnuplot.sh08 \
	gnuplot.sh09 gnuplot.sh10 gnuplot.sh11 gnuplot.sh12 \
	gnuplot.sh13 gnuplot.sh14 gnuplot.sh15 

gnuplot.sh00:
	echo '#!/bin/sh' > gnuplot.sh00
	echo '# This is a shell file to make directories' >> gnuplot.sh00
	echo mkdir $(DIRS) >> gnuplot.sh00

gnuplot.sh01: $(ETC)
	shar $(ETC) > gnuplot.sh01

gnuplot.sh02: $(DOCS1)
	shar $(DOCS1) > gnuplot.sh02

gnuplot.sh03: $(DOCS2)
	shar $(DOCS2) > gnuplot.sh03

gnuplot.sh04: $(DOCS3)
	shar $(DOCS3) > gnuplot.sh04

gnuplot.sh05: $(CSOURCE1)
	shar $(CSOURCE1) > gnuplot.sh05

gnuplot.sh06: $(CSOURCE2)
	shar $(CSOURCE2) > gnuplot.sh06

gnuplot.sh07: $(CSOURCE3)
	shar $(CSOURCE3) > gnuplot.sh07

gnuplot.sh08: $(CSOURCE4)
	shar $(CSOURCE4) > gnuplot.sh08

gnuplot.sh09: $(CSOURCE5)
	shar $(CSOURCE5) > gnuplot.sh09

gnuplot.sh10: $(CSOURCE6)
	shar $(CSOURCE6) > gnuplot.sh10

gnuplot.sh11: $(CSOURCE7)
	shar $(CSOURCE7) > gnuplot.sh11

gnuplot.sh12: $(PC)
	shar $(PC) > gnuplot.sh12

gnuplot.sh13: $(CSOURCE8)
	shar $(CSOURCE8) > gnuplot.sh13

gnuplot.sh14: $(DEMOS)
	shar $(DEMOS) > gnuplot.sh14

gnuplot.sh15: $(BETA)
	shar $(BETA) > gnuplot.sh15

tar: $(ETC) $(SOURCES) $(PC) $(DEMOS) $(BETA) $(DOCS)
	$(TAR) cvf /tmp/gnuplot.tar $(ETC) $(SOURCES) $(PC)\
		 $(DEMOS) $(BETA) $(DOCS)
rcsdoc:
	rcs -o-$(RCSOLD) -l$(RCSVER) $(DOCS)

rcs:
	rcs -l$(RCSVER) -c$(RCSCOM) $(ETC) $(SOURCES) $(PC)

ci:
	ci -l$(RCSVER) -m$(RCSCOM) $(SOURCES) $(PC) $(ETC)

cidoc:
	ci -l$(RCSVER) -m$(RCSCOM) $(DOCS)

cidemo:
	ci -l$(RCSVER) -m$(RCSCOM) $(DEMOS)

co:
	co -l -r$(RCSVER) $(ETC) $(SOURCES) $(PC)

codoc:
	co -l -r$(RCSVER) $(DOCS)

codemo:
	co -l -r$(RCSVER) $(DEMOS)

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/makefile.vms version [a1599b68f2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# $Id: makefile.vms,v 3.26 92/03/24 22:36:49 woo Exp Locker: woo $
#
#
#
# GNUPLOT Makefile
# for VMS
# 
# use with the MAKE that was posted by Tony Ivanov (tony@gvgpvd.GVG.TEK.COM)
# in comp.os.vms on 5 December 1988
#

# NOOP  NO Optimiser
CFLAGS = /NOOP/define=(NOGAMMA,MEMSET)

# /define=(<terminal>) in TERMFLAGS iff you wish to support <terminal>
# see other terminal defines in term.h

TERMFLAGS = 

OBJS =  bitmap.obj,command.obj,contour.obj,eval.obj,graphics.obj,graph3d.obj, \
        internal.obj,misc.obj,parse.obj,plot.obj,scanner.obj,setshow.obj, \
        standard.obj,term.obj,util.obj,version.obj

CSOURCE1 = command.c setshow.c 
CSOURCE2 = help.c graphics.c graph3d.c internal.c 
CSOURCE3 = misc.c eval.c parse.c plot.c scanner.c standard.c 
CSOURCE4 = bitmap.c term.c util.c version.c
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]pc.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 gnuplot_x11.c
CSOURCE8 = contour.c

all :   gnuplot.exe gnuplot.hlp gnuplot.hlb


gnuplot.exe : $(OBJS)
        link /exe=gnuplot $(OBJS) ,linkopt.vms/opt

gnuplot.hlp : doc2hlp.exe [.docs]gnuplot.doc [.docs]doc2hlp.com
        $$@[.docs]doc2hlp.com

gnuplot.hlb : gnuplot.hlp
	library/create/help gnuplot.hlb gnuplot.hlp

doc2hlp.exe: [.docs]doc2hlp.c
        cc [.docs]doc2hlp.c
        link doc2hlp,linkopt.vms/opt

term.obj: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
	$(CC) $(CFLAGS) $(TERMFLAGS) term.c

$(OBJS): plot.h

command.obj help.obj misc.obj: help.h

command.obj graphics.obj graph3d.obj misc.obj plot.obj setshow.obj term.obj: setshow.h

bitmap.obj term.obj: bitmap.h

clean :
        purge/log
        del/log *.obj;*
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































Deleted r34.1/plot/misc.c version [4d6789bb8d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
#ifndef lint
static char *RCSid = "$Id: misc.c,v 3.26 92/03/24 22:34:30 woo Exp Locker: woo $";
#endif

/* GNUPLOT - misc.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <math.h>
#include "plot.h"
#include "setshow.h"
#include "help.h"
#ifdef __TURBOC__
#include <graphics.h>
#endif

#ifndef _IBMR2
extern char *malloc();
extern char *realloc();
#endif

extern int c_token;
extern char replot_line[];
extern struct at_type at;
extern struct ft_entry ft[];
extern struct udft_entry *first_udf;
extern struct udvt_entry *first_udv;

extern struct at_type *temp_at();

extern BOOLEAN interactive;
extern char *infile_name;
extern int inline_num;

/* State information for load_file(), to recover from errors
 * and properly handle recursive load_file calls
 */
typedef struct lf_state_struct LFS;
struct lf_state_struct {
    FILE *fp;				/* file pointer for load file */
    char *name;			/* name of file */
    BOOLEAN interactive;		/* value of interactive flag on entry */
    int inline_num;			/* inline_num on entry */
    LFS *prev;				/* defines a stack */
} *lf_head = NULL;			/* NULL if not in load_file */

static BOOLEAN lf_pop();
static void lf_push();

/*
 * instead of <strings.h>
 */
extern int strcmp();

/*
 * Turbo C realloc does not do the right thing. Here is what it should do.
 */
#ifdef __TURBOC__
char *realloc(p, new_size)
	      void *p;
	      size_t new_size;
{
    void *new_p = alloc(new_size, "TC realloc");

    /* Note p may have less than new_size bytes but in this unprotected
     * environment this will work.
     */
    memcpy(new_p, p, new_size);
    free(p);
    return new_p;
}
#endif /* __TURBOC__ */

/*
 * cp_alloc() allocates a curve_points structure that can hold 'num'
 * points.
 */
struct curve_points *
cp_alloc(num)
	int num;
{
    struct curve_points *cp;
    cp = (struct curve_points *) alloc(sizeof(struct curve_points), "curve");
    cp->p_max = (num >= 0 ? num : 0);
    if (num > 0) {
	   cp->points = (struct coordinate *)
		alloc(num * sizeof(struct coordinate), "curve points");
    } else
	   cp->points = (struct coordinate *) NULL;
    cp->next_cp = NULL;
    cp->title = NULL;
    return(cp);
}


/*
 * cp_extend() reallocates a curve_points structure to hold "num"
 * points. This will either expand or shrink the storage.
 */
cp_extend(cp, num)
	struct curve_points *cp;
	int num;
{
    struct coordinate *new;

#ifdef PC
    /* Make sure we do not allocate more than 64k (8088 architecture...)
     * in msdos since we can not address more. Leave some bytes for malloc
     * maintainance.
     */
    if (num > 65500L / sizeof(struct coordinate))
	int_error("Can not allocate more than 64k in msdos", NO_CARET);
#endif /* PC */

    if (num == cp->p_max) return;

    if (num > 0) {
	   if (cp->points == NULL) {
		  cp->points = (struct coordinate *)
		    alloc(num * sizeof(struct coordinate), "curve points");
	   } else {
		  new = (struct coordinate *)
		    realloc(cp->points, num * sizeof(struct coordinate));
		  if (new == (struct coordinate *) NULL) {
			 int_error("No memory available for expanding curve points",
					 NO_CARET);
			 /* NOTREACHED */
		  }
		  cp->points = new;
	   }
	   cp->p_max = num;
    } else {
	   if (cp->points != (struct coordinate *) NULL)
		free(cp->points);
	   cp->points = (struct coordinate *) NULL;
	   cp->p_max = 0;
    }
}

/*
 * cp_free() releases any memory which was previously malloc()'d to hold
 *   curve points (and recursively down the linked list).
 */
cp_free(cp)
struct curve_points *cp;
{
	if (cp) {
		cp_free(cp->next_cp);
		if (cp->title)
			free((char *)cp->title);
		if (cp->points)
			free((char *)cp->points);
		free((char *)cp);
	}
}

/*
 * iso_alloc() allocates a iso_curve structure that can hold 'num'
 * points.
 */
struct iso_curve *
iso_alloc(num)
	int num;
{
    struct iso_curve *ip;
    ip = (struct iso_curve *) alloc(sizeof(struct iso_curve), "iso curve");
    ip->p_max = (num >= 0 ? num : 0);
    if (num > 0) {
	   ip->points = (struct coordinate *)
		alloc(num * sizeof(struct coordinate), "iso curve points");
    } else
	   ip->points = (struct coordinate *) NULL;
    ip->next = NULL;
    return(ip);
}

/*
 * iso_extend() reallocates a iso_curve structure to hold "num"
 * points. This will either expand or shrink the storage.
 */
iso_extend(ip, num)
	struct iso_curve *ip;
	int num;
{
    struct coordinate *new;

    if (num == ip->p_max) return;

#ifdef PC
    /* Make sure we do not allocate more than 64k (8088 architecture...)
     * in msdos since we can not address more. Leave some bytes for malloc
     * maintainance.
     */
    if (num > 65500L / sizeof(struct coordinate))
	int_error("Can not allocate more than 64k in msdos", NO_CARET);
#endif /* PC */

    if (num > 0) {
	   if (ip->points == NULL) {
		  ip->points = (struct coordinate *)
		    alloc(num * sizeof(struct coordinate), "iso curve points");
	   } else {
		  new = (struct coordinate *)
		    realloc(ip->points, num * sizeof(struct coordinate));
		  if (new == (struct coordinate *) NULL) {
			 int_error("No memory available for expanding curve points",
					 NO_CARET);
			 /* NOTREACHED */
		  }
		  ip->points = new;
	   }
	   ip->p_max = num;
    } else {
	   if (ip->points != (struct coordinate *) NULL)
		free(ip->points);
	   ip->points = (struct coordinate *) NULL;
	   ip->p_max = 0;
    }
}

/*
 * iso_free() releases any memory which was previously malloc()'d to hold
 *   iso curve points.
 */
iso_free(ip)
struct iso_curve *ip;
{
	if (ip) {
		if (ip->points)
			free((char *)ip->points);
		free((char *)ip);
	}
}

/*
 * sp_alloc() allocates a surface_points structure that can hold 'num_iso'
 * iso-curves, each of which 'num_samp' samples.
 * if, however num_iso or num_samp is zero no iso curves are allocated.
 */
struct surface_points *
sp_alloc(num_samp,num_iso)
	int num_samp,num_iso;
{
    struct surface_points *sp;

    sp = (struct surface_points *) alloc(sizeof(struct surface_points), "surface");
    sp->next_sp = NULL;
    sp->title = NULL;
    sp->contours = NULL;
    sp->iso_crvs = NULL;
    sp->num_iso_read = 0;

    if (num_iso > 0 && num_samp > 0) {
	int i;
	struct iso_curve *icrv;

	for (i = 0; i < num_iso; i++) {
	    icrv = iso_alloc(num_samp);
	    icrv->next = sp->iso_crvs;
	    sp->iso_crvs = icrv;
	}
    } else
	sp->iso_crvs = (struct iso_curve *) NULL;

    return(sp);
}

/*
 * sp_replace() updates a surface_points structure so it can hold 'num_iso'
 * iso-curves, each of which 'num_samp' samples.
 * if, however num_iso or num_samp is zero no iso curves are allocated.
 */
sp_replace(sp,num_samp,num_iso)
	   struct surface_points *sp;
	   int num_samp,num_iso;
{
    int i;
    struct iso_curve *icrv, *icrvs = sp->iso_crvs;

    while ( icrvs ) {
	icrv = icrvs;
	icrvs = icrvs->next;
	iso_free( icrv );
    }
    sp->iso_crvs = NULL;
    
    if (num_iso > 0 && num_samp > 0) {
	for (i = 0; i < num_iso; i++) {
	    icrv = iso_alloc(num_samp);
	    icrv->next = sp->iso_crvs;
	    sp->iso_crvs = icrv;
	}
    } else
	sp->iso_crvs = (struct iso_curve *) NULL;
}

/*
 * sp_free() releases any memory which was previously malloc()'d to hold
 *   surface points.
 */
sp_free(sp)
struct surface_points *sp;
{
	if (sp) {
		sp_free(sp->next_sp);
		if (sp->title)
			free((char *)sp->title);
		if (sp->contours) {
			struct gnuplot_contours *cntr, *cntrs = sp->contours;

			while (cntrs) {
				cntr = cntrs;
				cntrs = cntrs->next;
				free(cntr->coords);
				free(cntr);
			}
		}
		if (sp->iso_crvs) {
			struct iso_curve *icrv, *icrvs = sp->iso_crvs;

			while (icrvs) {
				icrv = icrvs;
				icrvs = icrvs->next;
				iso_free(icrv);
			}
		}
		free((char *)sp);
	}
}



save_functions(fp)
FILE *fp;
{
register struct udft_entry *udf = first_udf;

	if (fp) {
		while (udf) {
			if (udf->definition)
				fprintf(fp,"%s\n",udf->definition);
			udf = udf->next_udf;
		}
		(void) fclose(fp);
	} else
		os_error("Cannot open save file",c_token);			
}


save_variables(fp)
FILE *fp;
{
register struct udvt_entry *udv = first_udv->next_udv;	/* skip pi */

	if (fp) {
		while (udv) {
			if (!udv->udv_undef) {
				fprintf(fp,"%s = ",udv->udv_name);
				disp_value(fp,&(udv->udv_value));
				(void) putc('\n',fp);
			}
			udv = udv->next_udv;
		}
		(void) fclose(fp);
	} else
		os_error("Cannot open save file",c_token);			
}


save_all(fp)
FILE *fp;
{
register struct udft_entry *udf = first_udf;
register struct udvt_entry *udv = first_udv->next_udv;	/* skip pi */

	if (fp) {
		save_set_all(fp);
		while (udf) {
			if (udf->definition)
				fprintf(fp,"%s\n",udf->definition);
			udf = udf->next_udf;
		}
		while (udv) {
			if (!udv->udv_undef) {
				fprintf(fp,"%s = ",udv->udv_name);
				disp_value(fp,&(udv->udv_value));
				(void) putc('\n',fp);
			}
			udv = udv->next_udv;
		}
		fprintf(fp,"%s\n",replot_line);
		(void) fclose(fp);
	} else
		os_error("Cannot open save file",c_token);			
}


save_set(fp)
FILE *fp;
{
	if (fp) {
		save_set_all(fp);
		(void) fclose(fp);
	} else
		os_error("Cannot open save file",c_token);			
}


save_set_all(fp)
FILE *fp;
{
struct text_label *this_label;
struct arrow_def *this_arrow;
	fprintf(fp,"set terminal %s %s\n", term_tbl[term].name, term_options);
	fprintf(fp,"set output %s\n",strcmp(outstr,"STDOUT")? outstr : "" );
	fprintf(fp,"set %sclip points\n", (clip_points)? "" : "no");
	fprintf(fp,"set %sclip one\n", (clip_lines1)? "" : "no");
	fprintf(fp,"set %sclip two\n", (clip_lines2)? "" : "no");
	fprintf(fp,"set %sborder\n",draw_border ? "" : "no");
	fprintf(fp,"set dummy %s,%s\n",dummy_var[0], dummy_var[1]);
	fprintf(fp,"set format x \"%s\"\n", xformat);
	fprintf(fp,"set format y \"%s\"\n", yformat);
	fprintf(fp,"set format z \"%s\"\n", zformat);
	fprintf(fp,"set %sgrid\n", (grid)? "" : "no");
	switch (key) {
		case -1 : 
			fprintf(fp,"set key\n");
			break;
		case 0 :
			fprintf(fp,"set nokey\n");
			break;
		case 1 :
			fprintf(fp,"set key %g,%g,%g\n",key_x,key_y,key_z);
			break;
	}
	fprintf(fp,"set nolabel\n");
	for (this_label = first_label; this_label != NULL;
			this_label = this_label->next) {
		fprintf(fp,"set label %d \"%s\" at %g,%g,%g ",
			   this_label->tag,
			   this_label->text, this_label->x,
					     this_label->y,
					     this_label->z);
		switch(this_label->pos) {
			case LEFT : 
				fprintf(fp,"left");
				break;
			case CENTRE :
				fprintf(fp,"centre");
				break;
			case RIGHT :
				fprintf(fp,"right");
				break;
		}
		fputc('\n',fp);
	}
	fprintf(fp,"set noarrow\n");
	for (this_arrow = first_arrow; this_arrow != NULL;
			this_arrow = this_arrow->next) {
		fprintf(fp,"set arrow %d from %g,%g,%g to %g,%g,%g%s\n",
			   this_arrow->tag,
			   this_arrow->sx, this_arrow->sy, this_arrow->sz,
			   this_arrow->ex, this_arrow->ey, this_arrow->ez,
			   this_arrow->head ? "" : " nohead");
	}
	fprintf(fp,"set nologscale\n");
	if (log_x||log_y)
	    fprintf(fp,"set logscale %c%c\n", 
		log_x ? 'x' : ' ', log_y ? 'y' : ' ');
	if (log_z) fprintf(fp,"set logscale z\n");
	fprintf(fp,"set offsets %g, %g, %g, %g\n",loff,roff,toff,boff);
	fprintf(fp,"set %spolar\n", (polar)? "" : "no");
	fprintf(fp,"set angles %s\n", (angles_format == ANGLES_RADIANS)?
						"radians" : "degrees");
	fprintf(fp,"set %sparametric\n", (parametric)? "" : "no");
	fprintf(fp,"set view %g, %g, %g, %g\n",
		surface_rot_x, surface_rot_z, surface_scale, surface_zscale);
	fprintf(fp,"set samples %d\n",samples);
	fprintf(fp,"set isosamples %d\n",iso_samples);
	fprintf(fp,"set %ssurface\n",(draw_surface) ? "" : "no");
	fprintf(fp,"set %scontour",(draw_contour) ? "" : "no");
	switch (draw_contour) {
		case CONTOUR_NONE: fprintf(fp, "\n"); break;
		case CONTOUR_BASE: fprintf(fp, " base\n"); break;
		case CONTOUR_SRF:  fprintf(fp, " surface\n"); break;
		case CONTOUR_BOTH: fprintf(fp, " both\n"); break;
	}
	fprintf(fp,"set %shidden3d\n",(hidden3d) ? "" : "no");
	fprintf(fp,"set cntrparam order %d\n", contour_order);
	fprintf(fp,"set cntrparam ");
	switch (contour_kind) {
		case CONTOUR_KIND_LINEAR:    fprintf(fp, "linear\n"); break;
		case CONTOUR_KIND_CUBIC_SPL: fprintf(fp, "cubicspline\n"); break;
		case CONTOUR_KIND_BSPLINE:   fprintf(fp, "bspline\n"); break;
	}
	fprintf(fp,"set cntrparam points %d\n", contour_pts);
	fprintf(fp,"set size %g,%g\n",xsize,ysize);
	fprintf(fp,"set data style ");
	switch (data_style) {
		case LINES: fprintf(fp,"lines\n"); break;
		case POINTS: fprintf(fp,"points\n"); break;
		case IMPULSES: fprintf(fp,"impulses\n"); break;
		case LINESPOINTS: fprintf(fp,"linespoints\n"); break;
		case DOTS: fprintf(fp,"dots\n"); break;
		case ERRORBARS: fprintf(fp,"errorbars\n"); break;
	}
	fprintf(fp,"set function style ");
	switch (func_style) {
		case LINES: fprintf(fp,"lines\n"); break;
		case POINTS: fprintf(fp,"points\n"); break;
		case IMPULSES: fprintf(fp,"impulses\n"); break;
		case LINESPOINTS: fprintf(fp,"linespoints\n"); break;
		case DOTS: fprintf(fp,"dots\n"); break;
		case ERRORBARS: fprintf(fp,"errorbars\n"); break;
	}
	fprintf(fp,"set tics %s\n", (tic_in)? "in" : "out");
	fprintf(fp,"set ticslevel %g\n", ticslevel);
	save_tics(fp, xtics, 'x', &xticdef);
	save_tics(fp, ytics, 'y', &yticdef);
	save_tics(fp, ztics, 'z', &zticdef);
	fprintf(fp,"set title \"%s\" %d,%d\n",title,title_xoffset,title_yoffset);
        if (timedate)
	    fprintf(fp,"set time %d,%d\n",time_xoffset,time_yoffset);
	else
	    fprintf(fp,"set notime\n");
 	fprintf(fp,"set rrange [%g : %g]\n",rmin,rmax);
	fprintf(fp,"set trange [%g : %g]\n",tmin,tmax);
	fprintf(fp,"set xlabel \"%s\" %d,%d\n",xlabel,xlabel_xoffset,xlabel_yoffset);
	fprintf(fp,"set xrange [%g : %g]\n",xmin,xmax);
	fprintf(fp,"set ylabel \"%s\" %d,%d\n",ylabel,ylabel_xoffset,ylabel_yoffset);
	fprintf(fp,"set yrange [%g : %g]\n",ymin,ymax);
	fprintf(fp,"set zlabel \"%s\" %d,%d\n",zlabel,zlabel_xoffset,zlabel_yoffset);
	fprintf(fp,"set zrange [%g : %g]\n",zmin,zmax);
	fprintf(fp,"set %s %c\n", 
		autoscale_r ? "autoscale" : "noautoscale", 'r');
	fprintf(fp,"set %s %c\n", 
		autoscale_t ? "autoscale" : "noautoscale", 't');
	fprintf(fp,"set %s %c%c\n", 
		(autoscale_y||autoscale_x) ? "autoscale" : "noautoscale", 
		autoscale_x ? 'x' : ' ', autoscale_y ? 'y' : ' ');
	fprintf(fp,"set %s %c\n", 
		autoscale_z ? "autoscale" : "noautoscale", 'z');
	fprintf(fp,"set zero %g\n",zero);
}

save_tics(fp, onoff, axis, tdef)
	FILE *fp;
	BOOLEAN onoff;
	char axis;
	struct ticdef *tdef;
{
    if (onoff) {
	   fprintf(fp,"set %ctics", axis);
	   switch(tdef->type) {
		  case TIC_COMPUTED: {
			 break;
		  }
		  case TIC_SERIES: {
		         if (tdef->def.series.end >= VERYLARGE)
			     fprintf(fp, " %g,%g", tdef->def.series.start,
                                        tdef->def.series.incr);
                         else
			     fprintf(fp, " %g,%g,%g", tdef->def.series.start,
                                        tdef->def.series.incr, tdef->def.series.end);
			 break;
		  }
		  case TIC_USER: {
			 register struct ticmark *t;
			 fprintf(fp, " (");
			 for (t = tdef->def.user; t != NULL; t=t->next) {
				if (t->label)
				  fprintf(fp, "\"%s\" ", t->label);
				if (t->next)
				  fprintf(fp, "%g, ", t->position);
				else
				  fprintf(fp, "%g", t->position);
			 }
			 fprintf(fp, ")");
			 break;
		  } 
	   }
	   fprintf(fp, "\n");
    } else {
	   fprintf(fp,"set no%ctics\n", axis);
    }
}

load_file(fp, name)
	FILE *fp;
	char *name;
{
    register int len;
    extern char input_line[];

    int start, left;
    int more;
    int stop = FALSE;

    lf_push(fp);			/* save state for errors and recursion */

    if (fp == (FILE *)NULL) {
	   char errbuf[BUFSIZ];
	   (void) sprintf(errbuf, "Cannot open load file '%s'", name);
	   os_error(errbuf, c_token);
    } else {
	   /* go into non-interactive mode during load */
	   /* will be undone below, or in load_file_error */
	   interactive = FALSE;
	   inline_num = 0;
	   infile_name = name;

	   while (!stop) {		/* read all commands in file */
		  /* read one command */
		  left = MAX_LINE_LEN;
		  start = 0;
		  more = TRUE;

		  while (more) {
			 if (fgets(&(input_line[start]), left, fp) == NULL) {
				stop = TRUE; /* EOF in file */
				input_line[start] = '\0';
				more = FALSE;	
			 } else {
				inline_num++;
				len = strlen(input_line) - 1;
				if (input_line[len] == '\n') { /* remove any newline */
				    input_line[len] = '\0';
				    /* Look, len was 1-1 = 0 before, take care here! */
				    if (len > 0) --len;
				} else if (len+1 >= left)
				  int_error("Input line too long",NO_CARET);
				 
				if (input_line[len] == '\\') { /* line continuation */
				    start = len;
				    left  = MAX_LINE_LEN - start; /* left -=len;*/
				} else
				  more = FALSE;
			 }
		  }

		  if (strlen(input_line) > 0) {
			 screen_ok = FALSE;	/* make sure command line is
							   echoed on error */
			 do_line();
		  }
	   }
    }

    /* pop state */
    (void) lf_pop();		/* also closes file fp */
}

/* pop from load_file state stack */
static BOOLEAN				/* FALSE if stack was empty */
lf_pop()					/* called by load_file and load_file_error */
{
    LFS *lf;

    if (lf_head == NULL)
	 return(FALSE);
    else {
	   lf = lf_head;
	   if (lf->fp != (FILE *)NULL)
		(void) fclose(lf->fp);
	   interactive = lf->interactive;
	   inline_num = lf->inline_num;
	   infile_name = lf->name;
	   lf_head = lf->prev;
	   free((char *)lf);
	   return(TRUE);
    }
}

/* push onto load_file state stack */
/* essentially, we save information needed to undo the load_file changes */
static void
lf_push(fp)			/* called by load_file */
	FILE *fp;
{
    LFS *lf;
    
    lf = (LFS *)alloc(sizeof(LFS), (char *)NULL);
    if (lf == (LFS *)NULL) {
	   if (fp != (FILE *)NULL)
		(void) fclose(fp);		/* it won't be otherwise */
	   int_error("not enough memory to load file", c_token);
    }
	 
    lf->fp = fp;			/* save this file pointer */
    lf->name = infile_name;	/* save current name */
    lf->interactive = interactive;	/* save current state */
    lf->inline_num = inline_num; /* save current line number */
    lf->prev = lf_head;		/* link to stack */
    lf_head = lf;
}

load_file_error()			/* called from main */
{
    /* clean up from error in load_file */
    /* pop off everything on stack */
    while(lf_pop())
	 ;
}

/* find char c in string str; return p such that str[p]==c;
 * if c not in str then p=strlen(str)
 */
int
instring(str, c)
	char *str;
	char c;
{
    int pos = 0;

    while (str != NULL && *str != '\0' && c != *str) {
	   str++; 
	   pos++;
    }
    return (pos);
}

show_functions()
{
register struct udft_entry *udf = first_udf;

	fprintf(stderr,"\n\tUser-Defined Functions:\n");

	while (udf) {
		if (udf->definition)
			fprintf(stderr,"\t%s\n",udf->definition);
		else
			fprintf(stderr,"\t%s is undefined\n",udf->udf_name);
		udf = udf->next_udf;
	}
}


show_at()
{
	(void) putc('\n',stderr);
	disp_at(temp_at(),0);
}


disp_at(curr_at, level)
struct at_type *curr_at;
int level;
{
register int i, j;
register union argument *arg;

	for (i = 0; i < curr_at->a_count; i++) {
		(void) putc('\t',stderr);
		for (j = 0; j < level; j++)
			(void) putc(' ',stderr);	/* indent */

			/* print name of instruction */

		fputs(ft[(int)(curr_at->actions[i].index)].f_name,stderr);
		arg = &(curr_at->actions[i].arg);

			/* now print optional argument */

		switch(curr_at->actions[i].index) {
		  case PUSH:	fprintf(stderr," %s\n", arg->udv_arg->udv_name);
					break;
		  case PUSHC:	(void) putc(' ',stderr);
					disp_value(stderr,&(arg->v_arg));
					(void) putc('\n',stderr);
					break;
		  case PUSHD1:	fprintf(stderr," %c dummy\n",
					  arg->udf_arg->udf_name[0]);
					break;
		  case PUSHD2:	fprintf(stderr," %c dummy\n",
					  arg->udf_arg->udf_name[1]);
					break;
		  case CALL:	fprintf(stderr," %s", arg->udf_arg->udf_name);
					if(level < 6) {
					if (arg->udf_arg->at) {
						(void) putc('\n',stderr);
						disp_at(arg->udf_arg->at,level+2); /* recurse! */
					} else
						fputs(" (undefined)\n",stderr);
					}
					break;
		  case CALL2:	fprintf(stderr," %s", arg->udf_arg->udf_name);
					if(level < 6) {
					if (arg->udf_arg->at) {
						(void) putc('\n',stderr);
						disp_at(arg->udf_arg->at,level+2); /* recurse! */
					} else
						fputs(" (undefined)\n",stderr);
					}
					break;
		  case JUMP:
		  case JUMPZ:
		  case JUMPNZ:
		  case JTERN:
					fprintf(stderr," +%d\n",arg->j_arg);
					break;
		  default:
					(void) putc('\n',stderr);
		}
	}
}


/* alloc:
 * allocate memory 
 * This is a protected version of malloc. It causes an int_error 
 * if there is not enough memory, but first it tries FreeHelp() 
 * to make some room, and tries again. If message is NULL, we 
 * allow NULL return. Otherwise, we handle the error, using the
 * message to create the int_error string. Note cp/sp_extend uses realloc,
 * so it depends on this using malloc().
 */

char *
alloc(size, message)
	unsigned int size;				/* # of bytes */
	char *message;			/* description of what is being allocated */
{
    char *p;				/* the new allocation */
    char errbuf[100];		/* error message string */

    p = malloc(size);
    if (p == (char *)NULL) {
#ifndef vms
	   FreeHelp();			/* out of memory, try to make some room */
#endif
	   
	   p = malloc(size);		/* try again */
	   if (p == (char *)NULL) {
		  /* really out of memory */
		  if (message != NULL) {
			 (void) sprintf(errbuf, "out of memory for %s", message);
			 int_error(errbuf, NO_CARET);
			 /* NOTREACHED */
		  }
		  /* else we return NULL */
	   }
    }

    return(p);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/parse.c version [eda11c42d1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
#ifndef lint
static char *RCSid = "$Id: parse.c,v 3.26 92/03/24 22:34:33 woo Exp Locker: woo $";
#endif

/* GNUPLOT - parse.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include <errno.h>
#include <math.h>
#include "plot.h"

#ifndef vms
#ifndef __ZTC__
extern int errno;
#endif
#endif

extern int num_tokens,c_token;
extern struct lexical_unit token[];
extern char c_dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1];	/* name of current dummy vars */
extern struct udft_entry *dummy_func;	/* pointer to dummy variable's func */

struct value *pop(),*integer(),*complex();
struct at_type *temp_at(), *perm_at();
struct udft_entry *add_udf();
struct udvt_entry *add_udv();
union argument *add_action();

struct at_type at;
static jmp_buf fpe_env;

#define dummy (struct value *) 0

#ifdef __TURBOC__
void fpe()
#else
#if defined( __ZTC__ ) || defined( _CRAY ) || defined( sgi )
void fpe(an_int)
int an_int;
#else
#ifdef NEXT
void fpe(int an_int)
#else
#ifdef sgi
void fpe(int sig, int code, struct sigcontext *sc)
/*void fpe(an_int)
int an_int;*/
#else
fpe()
#endif
#endif
#endif /* __ZTC__ || _CRAY */
#endif
{
#ifdef PC	/* thanks to lotto@wjh12.UUCP for telling us about this  */
	_fpreset();
#endif
	(void) signal(SIGFPE, fpe);
	undefined = TRUE;
	longjmp(fpe_env, TRUE);
}


#ifdef apollo
#include <apollo/base.h>
#include <apollo/pfm.h>
#include <apollo/fault.h>

/*
  On an Apollo, the OS can signal a couple errors that are not mapped
  into SIGFPE, namely signalling NaN and branch on an unordered
  comparison.  I suppose there are others, but none of these are documented,
  so I handle them as they arise.

  Anyway, we need to catch these faults and signal SIGFPE.
*/

pfm_$fh_func_val_t apollo_sigfpe(pfm_$fault_rec_t& fault_rec)
{
    kill(getpid(), SIGFPE);
    return pfm_$continue_fault_handling;
}

apollo_pfm_catch()
{
    status_$t status;
    pfm_$establish_fault_handler(fault_$fp_bsun, pfm_$fh_backstop,
				 apollo_sigfpe, &status);
    pfm_$establish_fault_handler(fault_$fp_sig_nan, pfm_$fh_backstop,
				 apollo_sigfpe, &status);
}
#endif


evaluate_at(at_ptr,val_ptr)
struct at_type *at_ptr;
struct value *val_ptr;
{
	double temp, real();

	undefined = FALSE;
	errno = 0;
	reset_stack();
	if (setjmp(fpe_env))
		return;				/* just bail out */
	(void) signal(SIGFPE, fpe);	/* catch core dumps on FPEs */

	execute_at(at_ptr);

	(void) signal(SIGFPE, SIG_DFL);

	if (errno == EDOM || errno == ERANGE) {
		undefined = TRUE;
	} else {
		(void) pop(val_ptr);
		check_stack();
	}
/* At least one machine (ATT 3b1) computes Inf without a SIGFPE */
	temp = real(val_ptr);
	if (temp > VERYLARGE || temp < -VERYLARGE) {
		undefined = TRUE;
	}
}


struct value *
const_express(valptr)
struct value *valptr;
{
register int tkn = c_token;
	if (END_OF_COMMAND)
		int_error("constant expression required",c_token);
	evaluate_at(temp_at(),valptr);	/* run it and send answer back */
	if (undefined) {
		int_error("undefined value",tkn);
	}
	return(valptr);
}


struct at_type *
temp_at()	/* build a static action table and return its pointer */
{
	at.a_count = 0;		/* reset action table !!! */
	express();
	return(&at);
}


/* build an action table, put it in dynamic memory, and return its pointer */

struct at_type *
perm_at()
{
register struct at_type *at_ptr;
register unsigned int len;

	(void) temp_at();
	len = sizeof(struct at_type) -
		(MAX_AT_LEN - at.a_count)*sizeof(struct at_entry);
	at_ptr = (struct at_type *) alloc(len, "action table");
     (void) memcpy(at_ptr,&at,len);
	return(at_ptr);
}


#ifdef NOCOPY
/*
 * cheap and slow version of memcpy() in case you don't have one
 */
memcpy(dest,src,len)
char *dest,*src;
unsigned int len;
{
	while (len--)
		*dest++ = *src++;
}
#endif /* NOCOPY */


express()  /* full expressions */
{
	xterm();
	xterms();
}

xterm()  /* ? : expressions */
{
	aterm();
	aterms();
}


aterm()
{
	bterm();
	bterms();
}


bterm()
{
	cterm();
	cterms();
}


cterm()
{
	dterm();
	dterms();
}


dterm()
{	
	eterm();
	eterms();
}


eterm()
{
	fterm();
	fterms();
}


fterm()
{
	gterm();
	gterms();
}


gterm()
{
	hterm();
	hterms();
}


hterm()
{
	unary(); /* - things */
	iterms(); /* * / % */
}


factor()
{
register int value;

	if (equals(c_token,"(")) {
		c_token++;
		express();
		if (!equals(c_token,")"))
			int_error("')' expected",c_token);
		c_token++;
	}
	else if (isnumber(c_token)) {
		convert(&(add_action(PUSHC)->v_arg),c_token);
		c_token++;
	}
	else if (isletter(c_token)) {
		if ((c_token+1 < num_tokens)  && equals(c_token+1,"(")) {
			value = standard(c_token);
			if (value) {	/* it's a standard function */
				c_token += 2;
				express();
				if (!equals(c_token,")"))
					int_error("')' expected",c_token);
				c_token++;
				(void) add_action(value);
			}
			else {
				int call_type = (int )CALL;
				value = c_token;
				c_token += 2;
				express();
				if (equals(c_token, ",")) {
					c_token += 1;
					express();
					call_type = (int )CALL2;
				}
				if (!equals(c_token,")"))
					int_error("')' expected",c_token);
				c_token++;
				add_action(call_type)->udf_arg = add_udf(value);
			}
		}
		else {
			if (equals(c_token,c_dummy_var[0])) {
			    c_token++;
			    add_action(PUSHD1)->udf_arg = dummy_func;
			}
			else if (equals(c_token,c_dummy_var[1])) {
			    c_token++;
			    add_action(PUSHD2)->udf_arg = dummy_func;
			}
			else {
			    add_action(PUSH)->udv_arg = add_udv(c_token);
			    c_token++;
			}
		}
	} /* end if letter */
	else
		int_error("invalid expression ",c_token);

	/* add action code for ! (factorial) operator */
	while (equals(c_token,"!")) {
		c_token++;
		(void) add_action(FACTORIAL);
	}
	/* add action code for ** operator */
	if (equals(c_token,"**")) {
			c_token++;
			unary();
			(void) add_action(POWER);
	}

}



xterms()
{  /* create action code for ? : expressions */

	if (equals(c_token,"?")) {
		register int savepc1, savepc2;
		register union argument *argptr1,*argptr2;
		c_token++;
		savepc1 = at.a_count;
		argptr1 = add_action(JTERN);
		express();
		if (!equals(c_token,":"))
			int_error("expecting ':'",c_token);
		c_token++;
		savepc2 = at.a_count;
		argptr2 = add_action(JUMP);
		argptr1->j_arg = at.a_count - savepc1;
		express();
		argptr2->j_arg = at.a_count - savepc2;
	}
}


aterms()
{  /* create action codes for || operator */

	while (equals(c_token,"||")) {
		register int savepc;
		register union argument *argptr;
		c_token++;
		savepc = at.a_count;
		argptr = add_action(JUMPNZ);	/* short-circuit if already TRUE */
		aterm();
		argptr->j_arg = at.a_count - savepc;/* offset for jump */
#if defined(AMIGA_LC_5_1) || defined(AMIGA_AC_5)
		(void) add_action(ABOOL);
#else
		(void) add_action(BOOLE);
#endif
	}
}


bterms()
{ /* create action code for && operator */

	while (equals(c_token,"&&")) {
		register int savepc;
		register union argument *argptr;
		c_token++;
		savepc = at.a_count;
		argptr = add_action(JUMPZ);	/* short-circuit if already FALSE */
		bterm();
		argptr->j_arg = at.a_count - savepc;/* offset for jump */
#if defined(AMIGA_LC_5_1) || defined(AMIGA_AC_5)
		(void) add_action(ABOOL);
#else
		(void) add_action(BOOLE);
#endif
	}
}


cterms()
{ /* create action code for | operator */

	while (equals(c_token,"|")) {
		c_token++;
		cterm();
		(void) add_action(BOR);
	}
}


dterms()
{ /* create action code for ^ operator */

	while (equals(c_token,"^")) {
		c_token++;
		dterm();
		(void) add_action(XOR);
	}
}


eterms()
{ /* create action code for & operator */

	while (equals(c_token,"&")) {
		c_token++;
		eterm();
		(void) add_action(BAND);
	}
}


fterms()
{ /* create action codes for == and != operators */

	while (TRUE) {
		if (equals(c_token,"==")) {
			c_token++;
			fterm();
			(void) add_action(EQ);
		}
		else if (equals(c_token,"!=")) {
			c_token++;
			fterm();
			(void) add_action(NE);
		}
		else break;
	}
}


gterms()
{ /* create action code for < > >= or <= operators */
	
	while (TRUE) {
		/* I hate "else if" statements */
		if (equals(c_token,">")) {
			c_token++;
			gterm();
			(void) add_action(GT);
		}
		else if (equals(c_token,"<")) {
			c_token++;
			gterm();
			(void) add_action(LT);
		}		
		else if (equals(c_token,">=")) {
			c_token++;
			gterm();
			(void) add_action(GE);
		}
		else if (equals(c_token,"<=")) {
			c_token++;
			gterm();
			(void) add_action(LE);
		}
		else break;
	}

}



hterms()
{ /* create action codes for + and - operators */

	while (TRUE) {
			if (equals(c_token,"+")) {
				c_token++;
				hterm();
				(void) add_action(PLUS);
			}
			else if (equals(c_token,"-")) {
				c_token++;
				hterm();
				(void) add_action(MINUS);
			}
			else break;
	}
}


iterms()
{ /* add action code for * / and % operators */

	while (TRUE) {
			if (equals(c_token,"*")) {
				c_token++;
				unary();
				(void) add_action(MULT);
			}
			else if (equals(c_token,"/")) {
				c_token++;
				unary();
				(void) add_action(DIV);
			}
			else if (equals(c_token,"%")) {
				c_token++;
				unary();
				(void) add_action(MOD);
			}
			else break;
	}
}


unary()
{ /* add code for unary operators */
	if (equals(c_token,"!")) {
		c_token++;
		unary();
		(void) add_action(LNOT);
	}
	else if (equals(c_token,"~")) {
		c_token++;
		unary();
		(void) add_action(BNOT);
	}
	else if (equals(c_token,"-")) {
		c_token++;
		unary();
		(void) add_action(UMINUS);
	}
	else
		factor();
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/pcgraph.asm version [ec75d9143c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
TITLE	PC graphics module
;	uses LINEPROC.MAC

;	Michael Gordon - 8-Dec-86
;
; Certain routines were taken from the Hercules BIOS of	Dave Tutelman - 8/86
; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
;
; modified slightly by Colin Kelley - 22-Dec-86
;	added header.mac, parameterized declarations
; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
;
; modified and added to for use in plot(3) routines back end.
; Gil Webster.
;
; Assemble with masm ver. 4.  

include header.mac

if1
include lineproc.mac
endif

GPg1_Base equ 0B800h	; Graphics page 1 base address

	extrn _inter:far

_text	segment

	public _PC_line, _PC_color, _PC_mask, _PC_curloc, _PC_puts, _Vmode
	public _erase, _save_stack, _ss_interrupt

pcpixel proc near
	ror word ptr linemask,1
	jc cont
	ret
cont:
	push ax
	push bx
	push cx
	push dx
	push bp
	mov cx,ax		; x
	mov dx,bx		; y
	mov ah,0ch		; ah = write pixel
	mov al,byte ptr color

	mov bh, 0		; page 0
	int 10h
	pop bp
	pop dx
	pop cx
	pop bx
	pop ax
	ret
pcpixel endp

lineproc _PC_line, pcpixel

;
; erase - clear page 1 of the screen buffer to zero (effectively, blank
;	the screen)
;
beginproc _erase
	push es
	push ax
	push cx
	push di
	mov ax, GPg1_Base
	mov es, ax
	xor di, di
	mov cx, 4000h
	xor ax, ax
	cld
	rep stosw			; zero out screen page
	pop di
	pop cx
	pop ax
	pop es
	ret
_erase endp

beginproc _PC_color
	push bp
	mov bp,sp
	mov al,[bp+X]			; color
	mov byte ptr color,al
	pop bp
	ret
_PC_color endp

beginproc _PC_mask
	push bp
	mov bp,sp
	mov ax,[bp+X]			; mask
	mov word ptr linemask,ax
	pop bp
	ret
_PC_mask endp

beginproc _Vmode
	push bp
	mov bp,sp
	push si
	push di
	mov ax,[bp+X]
	int 10h
	pop di
	pop si
	pop bp
	ret
_Vmode	endp

beginproc _PC_curloc
	push bp
	mov bp,sp
	mov dh, byte ptr [bp+X] ; row number
	mov dl, byte ptr [bp+X+2] ; col number
	mov bh, 0
	mov ah, 2
	int 10h
	pop bp
	ret
_PC_curloc endp

;
; thanks to watale!broehl for finding a bug here--I wasn't pushing BP
;   and reloading AH before INT 10H, which is necessary on genuine IBM
;   boards...
;
beginproc _PC_puts
	push bp
	mov bp,sp
	push si
	mov bl,byte ptr color
	mov si,[bp+X]		; offset

ifdef LARGE_DATA
	mov es,[bp+X+2]		; segment if large or compact data model
endif

puts2:

ifdef LARGE_DATA
	mov al,es:[si]
else
	mov al,[si]
endif
	or al,al
	jz puts3
	mov ah,0eh		; write TTY char
	int 10h
	inc si
	jmp short puts2
puts3:	pop si
	pop bp
	ret
_PC_puts endp


; int kbhit();
;   for those without MSC 4.0
; Use BIOS interrupt 16h to determine if a key is waiting in the buffer.
; Return nonzero if so.
;

beginproc _kbhit
	mov ah, 1		; function code 1 is keyboard test
	int 16h			; keyboard functions
	jnz kbfin		; Exit if char available
	xor ax, ax		; No char:  return zero.
kbfin:	ret
_kbhit	endp


; _save_stack and _ss_interrupt are needed due to a bug in the MSC 4.0
; code when run under MS-DOS 3.x.  Starting with 3.0, MS-DOS automatically
; switches to an internal stack during system calls.  This leaves SS:SP
; pointing at MS-DOS's stack when the ^C interrupt (INT 23H) is triggered.
; MSC should restore its own stack before calling the user signal() routine,
; but it doesn't.
;
; Presumably this code will be unnecessary in later releases of the compiler.
;

; _save_stack saves the current SS:SP to be loaded later by _ss_interrupt.
;

beginproc _save_stack
	mov ax,ss
	mov cs:save_ss,ax
	mov ax,sp
	mov cs:save_sp,ax
	ret
_save_stack endp


; _ss_interrupt is called on ^C (INT 23H).  It restores SS:SP as saved in
; _save_stack and then jumps to the C routine interrupt().
;
beginproc _ss_interrupt
	cli			; no interrupts while the stack is changed!
	mov ax,-1		; self-modifying code again
save_ss	equ this word - 2
	mov ss,ax
	mov sp,-1		; here too
save_sp equ this word - 2
	sti
	jmp far ptr _inter; now it's safe to call the real routine
_ss_interrupt endp


_text	ends


const	segment
linemask dw -1
color	 db 1
const	ends

	end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































Deleted r34.1/plot/plot.c version [e52b38934f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#ifndef lint
static char *RCSid = "$Id: plot.c,v 3.26 92/03/24 22:34:34 woo Exp Locker: woo $";
#endif

/* GNUPLOT - plot.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include "plot.h"
#include "setshow.h"
#ifdef MSDOS
#include <io.h>
#endif
#ifdef vms
#include <unixio.h>
#include <smgdef.h>
extern int vms_vkid;
extern smg$create_virtual_keyboard();
unsigned int status[2] = {1, 0};
#endif
#ifdef AMIGA_LC_5_1
#include <proto/dos.h>
#endif

#ifdef __TURBOC__
#include <graphics.h>
#endif

extern char *getenv(),*strcat(),*strcpy(),*strncpy();

extern char input_line[];
extern int c_token;
extern FILE *outfile;
extern int term;

BOOLEAN interactive = TRUE;	/* FALSE if stdin not a terminal */
BOOLEAN 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

jmp_buf env;

struct value *integer(),*complex();


extern f_push(),f_pushc(),f_pushd1(),f_pushd2(),f_call(),f_call2(),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(),
#ifdef GAMMA
	f_gamma(),
#endif
	f_floor(),f_ceil();


struct ft_entry ft[] = {	/* built-in function table */

/* internal functions: */
	{"push", f_push},	{"pushc", f_pushc},
	{"pushd1", f_pushd1},	{"pushd2", f_pushd2},
	{"call", f_call},	{"call2", f_call2},	{"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},
#ifdef GAMMA
 	{"gamma", f_gamma},
#endif
	{"floor", f_floor},	{"ceil", f_ceil},
	{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 */
#ifdef MSDOS

#define HOME "GNUPLOT"

#else /* MSDOS */

#if defined(AMIGA_AC_5) || defined(AMIGA_LC_5_1)

#define HOME "GNUPLOT"
#else /* AMIGA */

#define HOME "HOME"

#endif /* AMIGA */
#endif /* MSDOS */
#endif /* vms */

#ifdef unix
#define PLOTRC ".gnuplot"
#else /* unix */
#if defined(AMIGA_AC_5) || defined(AMIGA_LC_5_1)
#define PLOTRC ".gnuplot"
#else /* AMIGA */
#define PLOTRC "gnuplot.ini"
#endif /* AMIGA */
#endif /* unix */

#ifdef __TURBOC__
void tc_interrupt()
#else
#if defined( _CRAY ) || defined( sgi )
void inter(an_int)
int an_int;
#else
#ifdef NEXT
void inter(int an_int)
#else
#ifdef sgi
void inter(int sig, int code, struct sigcontext *sc)
#else
inter()
#endif
#endif
#endif
#endif
{
#ifdef MSDOS
#ifdef __TURBOC__
	(void) signal(SIGINT, tc_interrupt);
#else
	void ss_interrupt();
	(void) signal(SIGINT, ss_interrupt);
#endif
#else  /* MSDOS */
	(void) signal(SIGINT, inter);
#endif  /* MSDOS */
	(void) signal(SIGFPE, SIG_DFL);	/* turn off FPE trapping */
	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 */
}


main(argc, argv)
	int argc;
	char **argv;
{
/* Register the Borland Graphics Interface drivers. If they have been */
/* included by the linker.                                            */

#ifdef __TURBOC__
registerfarbgidriver(EGAVGA_driver_far);
registerfarbgidriver(CGA_driver_far);
registerfarbgidriver(Herc_driver_far);
registerfarbgidriver(ATT_driver_far);
#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) complex(&udv_pi.udv_value, Pi, 0.0);

     interactive = FALSE;
     init_terminal();		/* can set term type if it likes */

#ifdef AMIGA_LC_5_1
     if (IsInteractive(Input()) == DOSTRUE) interactive = TRUE;
     else interactive = FALSE;
#else
     interactive = isatty(fileno(stdin));
#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 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)
		 done(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(TRUE)
		 com_line();
	}

     done(IO_SUCCESS);
}

/* Set up to catch interrupts */
interrupt_setup()
{
#ifdef MSDOS
#ifdef __TURBOC__
		(void) signal(SIGINT, tc_interrupt);	/* go there on interrupt char */
#else
		void ss_interrupt();
		save_stack();				/* work-around for MSC 4.0/MSDOS 3.x bug */
		(void) signal(SIGINT, ss_interrupt);
#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;
    static char home[80];
    static char rcfile[sizeof(PLOTRC)+80];

    /* Look for a gnuplot init file in . or home directory */
#ifdef vms
    (void) strcpy(home,HOME);
#else /* vms */
#if defined(AMIGA_AC_5) || defined(AMIGA_LC_5_1)
    strcpy(home,getenv(HOME));
    {
        int h;
        h = strlen(home) - 1;
        if (h >= 0) {
            if ((home[h] != ':') && (home[h] != '/')) {
                home[h] = '/';
                home[h+1] = '\0';
            }
       	}
    }
#else /* AMIGA */
    (void) strcat(strcpy(home,getenv(HOME)),"/");
#endif /* AMIGA */
#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
	   (void) sprintf(rcfile, "%s%s", home, PLOTRC);
	   plotrc = fopen(rcfile,"r");
    }
    if (plotrc)
	 load_file(plotrc, rcfile);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/plot.h version [a404eb1b4e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
/*
 * $Id: plot.h,v 3.26 92/03/24 22:34:13 woo Exp Locker: woo $
 *
 */

/* GNUPLOT - plot.h */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#define PROGRAM "G N U P L O T"
#define PROMPT "gnuplot> "
#if defined(AMIGA_LC_5_1) || defined(AMIGA_AC_5)
#define SHELL "NewShell"
#else /* AMIGA */
#define SHELL "/bin/sh"		/* used if SHELL env variable not set */
#endif /* AMIGA  */

#define SAMPLES 100		/* default number of samples for a plot */
#define ISO_SAMPLES 10		/* default number of isolines per splot */
#define ZERO	1e-8		/* default for 'zero' set option */

#ifndef TERM
/* default terminal is "unknown"; but see init_terminal */
#define TERM "unknown"
#endif

#define TRUE 1
#define FALSE 0


#define Pi 3.141592653589793
#define DEG2RAD (Pi / 180.0)


#define MIN_CRV_POINTS 100		/* minimum size of points[] in curve_points */
#define MIN_SRF_POINTS 1000		/* minimum size of points[] in surface_points */

#define MAX_LINE_LEN 1024	/* maximum number of chars allowed on line */
#define MAX_TOKENS 200
#define MAX_ID_LEN 50		/* max length of an identifier */


#define MAX_AT_LEN 150		/* max number of entries in action table */
#define STACK_DEPTH 100
#define NO_CARET (-1)


#define MAX_NUM_VAR	2	/* Ploting projection of func. of max. two vars. */

#define MAP3D_CARTESIAN		0	/* 3D Data mapping. */
#define MAP3D_SPHERICAL		1
#define MAP3D_CYLINDRICAL	2

#define CONTOUR_NONE	0	/* Where to place contour maps if at all. */
#define CONTOUR_BASE	1
#define CONTOUR_SRF	2
#define CONTOUR_BOTH	3

#define CONTOUR_KIND_LINEAR	0 /* See contour.h in contours subdirectory. */
#define CONTOUR_KIND_CUBIC_SPL	1
#define CONTOUR_KIND_BSPLINE	2

#define ANGLES_RADIANS	0
#define ANGLES_DEGREES	1


#if defined(AMIGA_LC_5_1) || defined(AMIGA_AC_5)
#define OS "Amiga "
#endif


#ifdef vms
#define OS "VMS "
#endif


#ifdef unix
#define OS "unix "
#endif


#ifdef MSDOS
#define OS "MS-DOS "
#endif


#ifndef OS
#define OS ""
#endif


/*
 * Note about VERYLARGE:  This is the upper bound double (or float, if PC)
 * numbers. This flag indicates very large numbers. It doesn't have to 
 * be the absolutely biggest number on the machine.  
 * If your machine doesn't have HUGE, or float.h,
 * define VERYLARGE here. 
 *
 * example:
#define VERYLARGE 1e38
 */

#ifdef PC
#include <float.h>
#define VERYLARGE FLT_MAX
#else
#if defined( vms ) || defined( _CRAY ) || defined( NEXT )
#include <float.h>
#if defined ( NEXT )  /* bug in NeXT OS 2.0 */
#define DBL_MAX 1.7976931348623157e+308 
#endif
#define VERYLARGE DBL_MAX
#else
#if defined(AMIGA_AC_5) || defined(AMIGA_LC_5_1)
#include <math.h>
#define VERYLARGE HUGE
#else
#define VERYLARGE HUGE
#endif
#endif
#endif


#define END_OF_COMMAND (c_token >= num_tokens || equals(c_token,";"))

#ifdef vms


#define is_comment(c) ((c) == '#' || (c) == '!')
#define is_system(c) ((c) == '$')


#else /* vms */


#define is_comment(c) ((c) == '#')
#define is_system(c) ((c) == '!')


#endif /* vms */

/* If you don't have vfork, then undefine this */
#if defined(NOVFORK) || defined(MSDOS)
# undef VFORK
#else
# ifdef unix
#  define VFORK
# endif
#endif

/* 
 * memcpy() comes by many names. The default is now to assume bcopy, 
 * since it is the most common case. Define 
 *  MEMCPY to use memcpy(), 
 *  vms to use the vms function,
 *  NOCOPY to use a handwritten version in parse.c
 */
#ifdef vms
# define memcpy(dest,src,len) lib$movc3(&len,src,dest)
#else
# if defined(MEMCPY) || defined(MSDOS)
   /* use memcpy directly */
# else 
#  ifdef NOCOPY
    /* use the handwritten memcpy in parse.c */
#  else
    /* assume bcopy is in use */
#   define memcpy(dest,src,len) bcopy(src,dest,len)
#  endif /* NOCOPY */
# endif /* MEMCPY || MSDOS */
#endif /* vms */

/*
 * In case you have MEMSET instead of BZERO. If you have something 
 * else, define bzero to that something.
 */
#if defined(MEMSET) || defined(MSDOS)
#define bzero(dest,len)  (void)(memset(dest, (char)NULL, len))
#endif /* MEMSET || MSDOS */

/* Give the name of your gamma function, or undefine it if you have none.  */
#if defined(NOGAMMA) || defined(MSDOS)
# undef GAMMA
#else
# ifndef GAMMA
#  define GAMMA gamma
# endif /* GAMMA */
#endif /* NOGAMMA ||MSDOS */

#define top_of_stack stack[s_p]

typedef int BOOLEAN;

#ifdef __ZTC__
typedef int (*FUNC_PTR)(...);
#else
typedef int (*FUNC_PTR)();
#endif

#if defined(AMIGA_LC_5_1) || defined(AMIGA_AC_5)
enum operators {
	PUSH, PUSHC, PUSHD1, PUSHD2, CALL, CALL2, LNOT, BNOT, UMINUS, LOR, LAND,
	BOR, XOR, BAND, EQ, NE, GT, LT, GE, LE, PLUS, MINUS, MULT, DIV,
	MOD, POWER, FACTORIAL, ABOOL, JUMP, JUMPZ, JUMPNZ, JTERN, SF_START
};
#else
enum operators {
	PUSH, PUSHC, PUSHD1, PUSHD2, CALL, CALL2, LNOT, BNOT, UMINUS, LOR, LAND,
	BOR, XOR, BAND, EQ, NE, GT, LT, GE, LE, PLUS, MINUS, MULT, DIV,
	MOD, POWER, FACTORIAL, BOOLE, JUMP, JUMPZ, JUMPNZ, JTERN, SF_START
};
#endif


#define is_jump(operator) ((operator) >=(int)JUMP && (operator) <(int)SF_START)


enum DATA_TYPES {
	INT, CMPLX
};


enum PLOT_TYPE {
	FUNC, DATA, FUNC3D, DATA3D
};


enum PLOT_STYLE {
	LINES, POINTS, IMPULSES, LINESPOINTS, DOTS, ERRORBARS
};

enum JUSTIFY {
	LEFT, CENTRE, RIGHT
};

struct cmplx {
	double real, imag;
};


struct value {
	enum DATA_TYPES type;
	union {
		int int_val;
		struct cmplx cmplx_val;
	} v;
};


struct lexical_unit {	/* produced by scanner */
	BOOLEAN is_token;	/* true if token, false if a value */ 
	struct value l_val;
	int start_index;	/* index of first char in token */
	int length;			/* length of token in chars */
};


struct ft_entry {		/* standard/internal function table entry */
	char *f_name;		/* pointer to name of this function */
	FUNC_PTR func;		/* address of function to call */
};


struct udft_entry {				/* user-defined function table entry */
	struct udft_entry *next_udf; 		/* pointer to next udf in linked list */
	char udf_name[MAX_ID_LEN+1]; 		/* name of this function entry */
	struct at_type *at;			/* pointer to action table to execute */
	char *definition; 			/* definition of function as typed */
	struct value dummy_values[MAX_NUM_VAR];	/* current value of dummy variables */
};


struct udvt_entry {			/* user-defined value table entry */
	struct udvt_entry *next_udv; /* pointer to next value in linked list */
	char udv_name[MAX_ID_LEN+1]; /* name of this value entry */
	BOOLEAN udv_undef;		/* true if not defined yet */
	struct value udv_value;	/* value it has */
};


union argument {			/* p-code argument */
	int j_arg;				/* offset for jump */
	struct value v_arg;		/* constant value */
	struct udvt_entry *udv_arg;	/* pointer to dummy variable */
	struct udft_entry *udf_arg; /* pointer to udf to execute */
};


struct at_entry {			/* action table entry */
	enum operators index;	/* index of p-code function */
	union argument arg;
};


struct at_type {
	int a_count;				/* count of entries in .actions[] */
	struct at_entry actions[MAX_AT_LEN];
		/* will usually be less than MAX_AT_LEN is malloc()'d copy */
};


/* Defines the type of a coordinate */
/* INRANGE and OUTRANGE points have an x,y point associated with them */
enum coord_type {
    INRANGE,				/* inside plot boundary */
    OUTRANGE,				/* outside plot boundary, but defined */
    UNDEFINED				/* not defined at all */
};
  
#ifdef PC
typedef float coordval;		/* memory is tight on PCs! */
#else
typedef double coordval;
#endif

struct coordinate {
	enum coord_type type;	/* see above */
	coordval x, y, z;
	coordval ylow, yhigh;	/* ignored in 3d */
};

struct curve_points {
	struct curve_points *next_cp;	/* pointer to next plot in linked list */
	enum PLOT_TYPE plot_type;
	enum PLOT_STYLE plot_style;
	char *title;
	int line_type;
	int point_type;
 	int p_max;					/* how many points are allocated */
	int p_count;					/* count of points in points */
	struct coordinate *points;
};

struct gnuplot_contours {
	struct gnuplot_contours *next;
	struct coordinate *coords;
	int num_pts;
};

struct iso_curve {
	struct iso_curve *next;
 	int p_max;					/* how many points are allocated */
	int p_count;					/* count of points in points */
	struct coordinate *points;
};

struct surface_points {
	struct surface_points *next_sp;	/* pointer to next plot in linked list */
	enum PLOT_TYPE plot_type;
	enum PLOT_STYLE plot_style;
	char *title;
	int line_type;
	int point_type;
	int has_grid_topology;
	int num_iso_read;  /* Data files only - num of isolines read from file. */
	struct gnuplot_contours *contours;	/* Not NULL If have contours. */
	struct iso_curve *iso_crvs;
};

struct termentry {
	char *name;
	char *description;
	unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
	FUNC_PTR options,init,reset,text,scale,graphics,move,vector,linetype,
		put_text,text_angle,justify_text,point,arrow;
};


struct text_label {
	struct text_label *next;	/* pointer to next label in linked list */
	int tag;			/* identifies the label */
	double x,y,z;
	enum JUSTIFY pos;
	char text[MAX_LINE_LEN+1];
};

struct arrow_def {
	struct arrow_def *next;	/* pointer to next arrow in linked list */
	int tag;			/* identifies the arrow */
	double sx,sy,sz;		/* start position */
	double ex,ey,ez;		/* end position */
	BOOLEAN head;			/* arrow has a head or not */
};

/* Tic-mark labelling definition; see set xtics */
struct ticdef {
    int type;				/* one of three values below */
#define TIC_COMPUTED 1		/* default; gnuplot figures them */
#define TIC_SERIES 2		/* user-defined series */
#define TIC_USER 3			/* user-defined points */
    union {
	   struct {			/* for TIC_SERIES */
		  double start, incr;
		  double end;		/* ymax, if VERYLARGE */
	   } series;
	   struct ticmark *user;	/* for TIC_USER */
    } def;
};

/* Defines one ticmark for TIC_USER style.
 * If label==NULL, the value is printed with the usual format string.
 * else, it is used as the format string (note that it may be a constant
 * string, like "high" or "low").
 */
struct ticmark {
    double position;		/* where on axis is this */
    char *label;			/* optional (format) string label */
    struct ticmark *next;	/* linked list */
};

/*
 * SS$_NORMAL is "normal completion", STS$M_INHIB_MSG supresses

 * printing a status message.
 * SS$_ABORT is the general abort status code.
 from:	Martin Minow
	decvax!minow
 */
#ifdef	vms
#include		<ssdef.h>
#include		<stsdef.h>
#define	IO_SUCCESS	(SS$_NORMAL | STS$M_INHIB_MSG)
#define	IO_ERROR	SS$_ABORT
#endif /* vms */


#ifndef	IO_SUCCESS	/* DECUS or VMS C will have defined these already */
#define	IO_SUCCESS	0
#endif
#ifndef	IO_ERROR
#define	IO_ERROR	1
#endif

/* Some key global variables */
extern BOOLEAN screen_ok;
extern BOOLEAN term_init;
extern BOOLEAN undefined;
extern struct termentry term_tbl[];

extern char *alloc();
/* allocating and managing curve_points structures */
extern struct curve_points *cp_alloc();
extern int cp_extend();
extern int cp_free();
/* allocating and managing surface_points structures */
extern struct surface_points *sp_alloc();
extern int sp_replace();
extern int sp_free();
/* allocating and managing is_curve structures */
extern struct iso_curve *iso_alloc();
extern int iso_extend();
extern int iso_free();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/readline.c version [96daa073c6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#ifndef lint
static char *RCSid = "$Id: readline.c,v 3.26 92/03/24 22:34:35 woo Exp Locker: woo $";
#endif

/* GNUPLOT - readline.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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:
 *     Tom Tkacik
 *
 *   Msdos port and some enhancements:
 *     Gershon Elber and many others.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#ifdef READLINE

/* a small portable version of GNU's readline */
/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft 
	restrictions */
/* do not need any terminal capabilities except backspace,
/* and space overwrites a character */

/* NANO-EMACS line editing facility */
/* printable characters print as themselves (insert not overwrite) */
/* ^A moves to the beginning of the line */
/* ^B moves back a single character */
/* ^E moves to the end of the line */
/* ^F moves forward a single character */
/* ^K kills from current position to the end of line */
/* ^P moves back through history */
/* ^N moves forward through history */
/* ^H and DEL delete the previous character */
/* ^D deletes the current character, or EOF if line is empty */
/* ^L/^R redraw line in case it gets trashed */
/* ^U kills the entire line */
/* ^W kills last word */
/* LF and CR return the entire line regardless of the cursor postition */
/* EOF with an empty line returns (char *)NULL */

/* all other characters are ignored */

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

/* SIGTSTP defines job control */
/* if there is job control then we need termios.h instead of termio.h */
#ifdef SIGTSTP
#define TERMIOS
#endif


#ifndef MSDOS

/* UNIX specific stuff */
#ifdef TERMIOS
#include <termios.h>
static struct termios orig_termio, rl_termio;
#else
#include <termio.h>
static struct termio orig_termio, rl_termio;
#endif /* TERMIOS */
static int term_set = 0;	/* =1 if rl_termio set */

#else

/* MSDOS specific stuff */
#define getc(stdin) msdos_getch()
static char msdos_getch();

#endif /* MSDOS */


/* is it <string.h> or <strings.h>?   just declare what we need */
extern int strlen();
extern char *strcpy();
extern char *malloc();

#define MAXBUF	1024
#define BACKSPACE 0x08	/* ^H */
#define SPACE	' '

struct hist {
	char *line;
	struct hist *prev;
	struct hist *next;
};

static struct hist *history = NULL;  /* no history yet */
static struct hist *cur_entry = NULL;

static char cur_line[MAXBUF];  /* current contents of the line */
static int cur_pos = 0;	/* current position of the cursor */
static int max_pos = 0;	/* maximum character position */


void add_history();
static void fix_line();
static void redraw_line();
static void clear_line();
static void clear_eoline();
static void copy_line();
static void set_termio();
static void reset_termio();

char *
readline(prompt)
char *prompt;
{

	char cur_char;
	char *new_line;

	/* set the termio so we can do our own input processing */
	set_termio();

	/* print the prompt */
	fputs(prompt, stderr);
	cur_line[0] = '\0';
	cur_pos = 0;
	max_pos = 0;
	cur_entry = NULL;

	/* get characters */
	for(;;) {
		cur_char = getc(stdin);
		if(isprint(cur_char)) {
			int i;
			for(i=max_pos; i>cur_pos; i--) {
				cur_line[i] = cur_line[i-1];
			}
			putc(cur_char, stderr);
			cur_line[cur_pos] = cur_char;
			cur_pos += 1;
			max_pos += 1;
			if (cur_pos < max_pos)
			    fix_line();
			cur_line[max_pos] = '\0';

		/* else interpret unix terminal driver characters */
#ifdef VERASE
		} else if(cur_char == orig_termio.c_cc[VERASE] ){  /* DEL? */
			if(cur_pos > 0) {
				int i;
				cur_pos -= 1;
				putc(BACKSPACE, stderr);
				for(i=cur_pos; i<max_pos; i++)
					cur_line[i] = cur_line[i+1];
				max_pos -= 1;
				fix_line();
			}
#endif /* VERASE */
#ifdef VEOF
		} else if(cur_char == orig_termio.c_cc[VEOF] ){   /* ^D? */
			if(max_pos == 0) {
				reset_termio();
				return((char *)NULL);
			}
			if((cur_pos < max_pos)&&(cur_char == 004)) { /* ^D */
				int i;
				for(i=cur_pos; i<max_pos; i++)
					cur_line[i] = cur_line[i+1];
				max_pos -= 1;
				fix_line();
			}
#endif /* VEOF */
#ifdef VKILL
		} else if(cur_char == orig_termio.c_cc[VKILL] ){  /* ^U? */
			clear_line(prompt);
#endif /* VKILL */
#ifdef VWERASE
		} else if(cur_char == orig_termio.c_cc[VWERASE] ){  /* ^W? */
			while((cur_pos > 0) &&
			      (cur_line[cur_pos-1] == SPACE)) {
				cur_pos -= 1;
				putc(BACKSPACE, stderr);
			}
			while((cur_pos > 0) &&
			      (cur_line[cur_pos-1] != SPACE)) {
				cur_pos -= 1;
				putc(BACKSPACE, stderr);
			}
			clear_eoline();
			max_pos = cur_pos;
#endif /* VWERASE */
#ifdef VREPRINT
		} else if(cur_char == orig_termio.c_cc[VREPRINT] ){  /* ^R? */
			putc('\n',stderr); /* go to a fresh line */
			redraw_line(prompt);
#else
#ifdef VRPRNT   /* on Ultrix VREPRINT is VRPRNT */
		} else if(cur_char == orig_termio.c_cc[VRPRNT] ){  /* ^R? */
			putc('\n',stderr); /* go to a fresh line */
			redraw_line(prompt);
#endif /* VRPRNT */
#endif /* VREPRINT */
#ifdef VSUSP
		} else if(cur_char == orig_termio.c_cc[VSUSP]) {
			reset_termio();
			kill(0, SIGTSTP);

			/* process stops here */

			set_termio();
			/* print the prompt */
			redraw_line(prompt);
#endif /* VSUSP */
		} else {
			/* do normal editing commands */
			/* some of these are also done above */
			int i;
			switch(cur_char) {
			    case EOF:
				reset_termio();
				return((char *)NULL);
			    case 001: /* ^A */
				while(cur_pos > 0) {
					cur_pos -= 1;
					putc(BACKSPACE, stderr);
				}
				break;
			    case 002: /* ^B */
				if(cur_pos > 0) {
					cur_pos -= 1;
					putc(BACKSPACE, stderr);
				}
				break;
			    case 005: /* ^E */
				while(cur_pos < max_pos) {
					putc(cur_line[cur_pos], stderr);
					cur_pos += 1;
				}
				break;
			    case 006: /* ^F */
				if(cur_pos < max_pos) {
					putc(cur_line[cur_pos], stderr);
					cur_pos += 1;
				}
				break;
			    case 013: /* ^K */
				clear_eoline();
				max_pos = cur_pos;
				break;
			    case 020: /* ^P */
				if(history != NULL) {
					if(cur_entry == NULL) {
						cur_entry = history;
						clear_line(prompt);
						copy_line(cur_entry->line);
					} else if(cur_entry->prev != NULL) {
						cur_entry = cur_entry->prev;
						clear_line(prompt);
						copy_line(cur_entry->line);
					}
				}
				break;
			    case 016: /* ^N */
				if(cur_entry != NULL) {
					cur_entry = cur_entry->next;
					clear_line(prompt);
					if(cur_entry != NULL) 
						copy_line(cur_entry->line);
					else
						cur_pos = max_pos = 0;
				}
				break;
			    case 014: /* ^L */
			    case 022: /* ^R */
				putc('\n',stderr); /* go to a fresh line */
				redraw_line(prompt);
				break;
			    case 0177: /* DEL */
			    case 010: /* ^H */
				if(cur_pos > 0) {
					cur_pos -= 1;
					putc(BACKSPACE, stderr);
					for(i=cur_pos; i<max_pos; i++)
						cur_line[i] = cur_line[i+1];
					max_pos -= 1;
					fix_line();
				}
				break;
			    case 004: /* ^D */
				if(max_pos == 0) {
					reset_termio();
					return((char *)NULL);
				}
				if(cur_pos < max_pos) {
					for(i=cur_pos; i<max_pos; i++)
						cur_line[i] = cur_line[i+1];
					max_pos -= 1;
					fix_line();
				}
				break;
			    case 025:  /* ^U */
				clear_line(prompt);
				break;
			    case 027:  /* ^W */
				while((cur_pos > 0) &&
				      (cur_line[cur_pos-1] == SPACE)) {
					cur_pos -= 1;
					putc(BACKSPACE, stderr);
				}
				while((cur_pos > 0) &&
				      (cur_line[cur_pos-1] != SPACE)) {
					cur_pos -= 1;
					putc(BACKSPACE, stderr);
				}
				clear_eoline();
				max_pos = cur_pos;
				break;
				break;
			    case '\n': /* ^J */
			    case '\r': /* ^M */
				cur_line[max_pos+1] = '\0';
				putc('\n', stderr);
				new_line = malloc(strlen(cur_line)+1);
				strcpy(new_line,cur_line);
				reset_termio();
				return(new_line);
			    default:
				break;
			}
		}
	}
}

/* fix up the line from cur_pos to max_pos */
/* do not need any terminal capabilities except backspace,
/* and space overwrites a character */
static void
fix_line()
{
	int i;

	/* write tail of string */
	for(i=cur_pos; i<max_pos; i++)
		putc(cur_line[i], stderr);

	/* write a space at the end of the line in case we deleted one */
	putc(SPACE, stderr);

	/* backup to original position */
	for(i=max_pos+1; i>cur_pos; i--)
		putc(BACKSPACE, stderr);

}

/* redraw the entire line, putting the cursor where it belongs */
static void
redraw_line(prompt)
char *prompt;
{
	int i;

	fputs(prompt, stderr);
	fputs(cur_line, stderr);

	/* put the cursor where it belongs */
	for(i=max_pos; i>cur_pos; i--)
		putc(BACKSPACE, stderr);
}

/* clear cur_line and the screen line */
static void
clear_line(prompt)
char *prompt;
{
	int i;
	for(i=0; i<max_pos; i++)
		cur_line[i] = '\0';

	for(i=cur_pos; i>0; i--)
		putc(BACKSPACE, stderr);

	for(i=0; i<max_pos; i++)
		putc(SPACE, stderr);

	putc('\r', stderr);
	fputs(prompt, stderr);

	cur_pos = 0;
	max_pos = 0;
}

/* clear to end of line and the screen end of line */
static void
clear_eoline(prompt)
char *prompt;
{
	int i;
	for(i=cur_pos; i<max_pos; i++)
		cur_line[i] = '\0';

	for(i=cur_pos; i<max_pos; i++)
		putc(SPACE, stderr);
	for(i=cur_pos; i<max_pos; i++)
		putc(BACKSPACE, stderr);
}

/* copy line to cur_line, draw it and set cur_pos and max_pos */
static void
copy_line(line)
char *line;
{
	strcpy(cur_line, line);
	fputs(cur_line, stderr);
	cur_pos = max_pos = strlen(cur_line);
}

/* add line to the history */
void
add_history(line)
char *line;
{
	struct hist *entry;
	entry = (struct hist *)malloc(sizeof(struct hist));
	entry->line = malloc((unsigned int)strlen(line)+1);
	strcpy(entry->line, line);

	entry->prev = history;
	entry->next = NULL;
	if(history != NULL) {
		history->next = entry;
	}
	history = entry;
}

#ifdef MSDOS

/* Convert Arrow keystrokes to Control characters: */
static  char
msdos_getch()
{
    char c = getch();

    if (c == 0) {
	c = getch(); /* Get the extended code. */
	switch (c) {
	    case 75: /* Left Arrow. */
		c = 002;
		break;
	    case 77: /* Right Arrow. */
		c = 006;
		break;
	    case 72: /* Up Arrow. */
		c = 020;
		break;
	    case 80: /* Down Arrow. */
		c = 016;
		break;
	    case 115: /* Ctl Left Arrow. */
	    case 71: /* Home */
		c = 001;
		break;
	    case 116: /* Ctl Right Arrow. */
	    case 79: /* End */
		c = 005;
		break;
	    case 83: /* Delete */
		c = 004;
		break;
	    default:
		c = 0;
		break;
	}
    }
    else if (c == 033) { /* ESC */
	c = 025;
    }


    return c;
}

#endif /* MSDOS */

/* set termio so we can do our own input processing */
static void
set_termio()
{
#ifndef MSDOS
	if(term_set == 0) {
#ifdef TERMIOS
#ifdef TCGETS
		ioctl(0, TCGETS, &orig_termio);
#else
		tcgetattr(0, &orig_termio);
#endif /* TCGETS */
#else
		ioctl(0, TCGETA, &orig_termio);
#endif /* TERMIOS */
		rl_termio = orig_termio;

		rl_termio.c_iflag &= ~(BRKINT|PARMRK|INPCK|IUCLC|IXON|IXOFF);
		rl_termio.c_iflag |=  (IGNBRK|IGNPAR);

		rl_termio.c_oflag &= ~(ONOCR);

		rl_termio.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|NOFLSH);
		rl_termio.c_lflag |=  (ISIG);

		rl_termio.c_cc[VMIN] = 1;
		rl_termio.c_cc[VTIME] = 0;

#ifdef VSUSP
		/* disable suspending process on ^Z */
		rl_termio.c_cc[VSUSP] = 0;
#endif /* VSUSP */

#ifdef TERMIOS
#ifdef TCSETSW
		ioctl(0, TCSETSW, &rl_termio);
#else
		tcsetattr(0, TCSADRAIN, &rl_termio);
#endif /* TCSETSW */
#else
		ioctl(0, TCSETAW, &rl_termio);
#endif /* TERMIOS */
		term_set = 1;
	}
#endif /* MSDOS */
}

static void
reset_termio()
{
#ifndef MSDOS
	if(term_set == 1) {
#ifdef TERMIOS
#ifdef TCSETSW
		ioctl(0, TCSETSW, &orig_termio);
#else
		tcsetattr(0, TCSADRAIN, &orig_termio);
#endif /* TCSETSW */
#else
		ioctl(0, TCSETAW, &orig_termio);
#endif /* TERMIOS */
		term_set = 0;
	}
#endif /* MSDOS */
}
#endif /* READLINE */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/scanner.c version [2549b086fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#ifndef lint
static char *RCSid = "$Id: scanner.c,v 3.26 92/03/24 22:34:36 woo Exp Locker: woo $";
#endif

/* GNUPLOT - scanner.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

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

#ifdef AMIGA_AC_5
#define O_RDONLY	0
int open(const char * _name, int _mode, ...);
int close(int);
#endif

#ifdef vms

#include stdio
#include descrip
#include errno

#define MAILBOX "PLOT$MAILBOX"
#define pclose(f) fclose(f)

#endif /* vms */


#define isident(c) (isalnum(c) || (c) == '_')

#ifndef STDOUT
#define STDOUT 1
#endif

#define LBRACE '{'
#define RBRACE '}'

#define APPEND_TOKEN {token[t_num].length++; current++;}

#define SCAN_IDENTIFIER while (isident(expression[current + 1]))\
				APPEND_TOKEN

extern struct lexical_unit token[MAX_TOKENS];

static int t_num;	/* number of token I'm working on */

char *strcat(), *strcpy(), *strncpy();

/*
 * scanner() breaks expression[] into lexical units, storing them in token[].
 *   The total number of tokens found is returned as the function value.
 *   Scanning will stop when '\0' is found in expression[], or when token[]
 *     is full.
 *
 *	 Scanning is performed by following rules:
 *
 *	Current char	token should contain
 *     -------------    -----------------------
 *	1.  alpha,_	all following alpha-numerics
 *	2.  digit	0 or more following digits, 0 or 1 decimal point,
 *				0 or more digits, 0 or 1 'e' or 'E',
 *				0 or more digits.
 *	3.  ^,+,-,/	only current char
 *	    %,~,(,)
 *	    [,],;,:,
 *	    ?,comma
 *	4.  &,|,=,*	current char; also next if next is same
 *	5.  !,<,>	current char; also next if next is =
 *	6.  ", '	all chars up until matching quote
 *	7.  #		this token cuts off scanning of the line (DFK).
 *
 *			white space between tokens is ignored
 */
scanner(expression)
char expression[];
{
register int current;	/* index of current char in expression[] */
register int quote;
char brace;

	for (current = t_num = 0;
	    t_num < MAX_TOKENS && expression[current] != '\0';
	    current++) {
again:
		if (isspace(expression[current]))
			continue;						/* skip the whitespace */
		token[t_num].start_index = current;
		token[t_num].length = 1;
		token[t_num].is_token = TRUE;	/* to start with...*/

		if (expression[current] == '`') {
			substitute(&expression[current],MAX_LINE_LEN - current);
			goto again;
		}
		/* allow _ to be the first character of an identifier */
		if (isalpha(expression[current]) || expression[current] == '_') {
			SCAN_IDENTIFIER;
		} else if (isdigit(expression[current]) || expression[current] == '.'){
			token[t_num].is_token = FALSE;
			token[t_num].length = get_num(&expression[current]);
			current += (token[t_num].length - 1);
		} else if (expression[current] == LBRACE) {
			token[t_num].is_token = FALSE;
			token[t_num].l_val.type = CMPLX;
			if ((sscanf(&expression[++current],"%lf , %lf %c",
				&token[t_num].l_val.v.cmplx_val.real,
				&token[t_num].l_val.v.cmplx_val.imag,
				&brace) != 3) || (brace != RBRACE))
					int_error("invalid complex constant",t_num);
			token[t_num].length += 2;
			while (expression[++current] != RBRACE) {
				token[t_num].length++;
				if (expression[current] == '\0')			/* { for vi % */
					int_error("no matching '}'", t_num);
			}
		} else if (expression[current] == '\'' || expression[current] == '\"'){
			token[t_num].length++;
			quote = expression[current];
			while (expression[++current] != quote) {
				if (!expression[current]) {
					expression[current] = quote;
					expression[current+1] = '\0';
					break;
				} else
					token[t_num].length++;
			}
		} else switch (expression[current]) {
		     case '#':		/* DFK: add comments to gnuplot */
		    	  goto endline; /* ignore the rest of the line */
			case '^':
			case '+':
			case '-':
			case '/':
			case '%':
			case '~':
			case '(':
			case ')':
			case '[':
			case ']':
			case ';':
			case ':':
			case '?':
			case ',':
				break;
			case '&':
			case '|':
			case '=':
			case '*':
				if (expression[current] == expression[current + 1])
					APPEND_TOKEN;
				break;
			case '!':
			case '<':
			case '>':
				if (expression[current + 1] == '=')
					APPEND_TOKEN;
				break;
			default:
				int_error("invalid character",t_num);
			}
		++t_num;	/* next token if not white space */
	}

endline:					/* comments jump here to ignore line */

/* Now kludge an extra token which points to '\0' at end of expression[].
   This is useful so printerror() looks nice even if we've fallen off the
   line. */

		token[t_num].start_index = current;
		token[t_num].length = 0;
	return(t_num);
}


get_num(str)
char str[];
{
double atof();
register int count = 0;
long atol();
register long lval;

	token[t_num].is_token = FALSE;
	token[t_num].l_val.type = INT;		/* assume unless . or E found */
	while (isdigit(str[count]))
		count++;
	if (str[count] == '.') {
		token[t_num].l_val.type = CMPLX;
		while (isdigit(str[++count]))	/* swallow up digits until non-digit */
			;
		/* now str[count] is other than a digit */
	}
	if (str[count] == 'e' || str[count] == 'E') {
		token[t_num].l_val.type = CMPLX;
/* modified if statement to allow + sign in exponent
   rjl 26 July 1988 */
		count++;
		if (str[count] == '-' || str[count] == '+')
			count++;
		if (!isdigit(str[count])) {
			token[t_num].start_index += count;
			int_error("expecting exponent",t_num);
		}
		while (isdigit(str[++count]))
			;
	}
	if (token[t_num].l_val.type == INT) {
 		lval = atol(str);
		if ((token[t_num].l_val.v.int_val = lval) != lval)
			int_error("integer overflow; change to floating point",t_num);
	} else {
		token[t_num].l_val.v.cmplx_val.imag = 0.0;
		token[t_num].l_val.v.cmplx_val.real = atof(str);
	}
	return(count);
}


#ifdef MSDOS

#ifdef __ZTC__
substitute(char *str,int max)
#else
substitute()
#endif
{
	int_error("substitution not supported by MS-DOS!",t_num);
}

#else /* MSDOS */
#ifdef AMIGA_LC_5_1
substitute()
{
	int_error("substitution not supported by AmigaDOS!",t_num);
}

#else /* AMIGA_LC_5_1 */

substitute(str,max)			/* substitute output from ` ` */
char *str;
int max;
{
register char *last;
register int i,c;
register FILE *f;
#ifdef AMIGA_AC_5
int fd;
#else
FILE *popen();
#endif
static char pgm[MAX_LINE_LEN+1],output[MAX_LINE_LEN+1];

#ifdef vms
int chan;
static $DESCRIPTOR(pgmdsc,pgm);
static $DESCRIPTOR(lognamedsc,MAILBOX);
#endif /* vms */

	i = 0;
	last = str;
	while (*(++last) != '`') {
		if (*last == '\0')
			int_error("unmatched `",t_num);
		pgm[i++] = *last;
	}
	pgm[i] = '\0';		/* end with null */
	max -= strlen(last);	/* max is now the max length of output sub. */
  
#ifdef vms
  	pgmdsc.dsc$w_length = i;
   	if (!((vaxc$errno = sys$crembx(0,&chan,0,0,0,0,&lognamedsc)) & 1))
   		os_error("sys$crembx failed",NO_CARET);
   
   	if (!((vaxc$errno = lib$spawn(&pgmdsc,0,&lognamedsc,&1)) & 1))
   		os_error("lib$spawn failed",NO_CARET);
   
   	if ((f = fopen(MAILBOX,"r")) == NULL)
   		os_error("mailbox open failed",NO_CARET);
#else /* vms */
#ifdef AMIGA_AC_5
  	if ((fd = open(pgm,"O_RDONLY")) == -1)
#else
  	if ((f = popen(pgm,"r")) == NULL)
#endif
  		os_error("popen failed",NO_CARET);
#endif /* vms */

	i = 0;
	while ((c = getc(f)) != EOF) {
		output[i++] = ((c == '\n') ? ' ' : c);	/* newlines become blanks*/
		if (i == max) {
#ifdef AMIGA_AC_5
			(void) close(fd);
#else
			(void) pclose(f);
#endif
			int_error("substitution overflow", t_num);
		}
	}
#ifdef AMIGA_AC_5
	(void) close(fd);
#else
	(void) pclose(f);
#endif
	if (i + strlen(last) > max)
		int_error("substitution overflowed rest of line", t_num);
	(void) strncpy(output+i,last+1,MAX_LINE_LEN-i);
									/* tack on rest of line to output */
	(void) strcpy(str,output);				/* now replace ` ` with output */
	screen_ok = FALSE;
}
#endif /* AMIGA_LC_5_1 */
#endif /* MS-DOS */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/setshow.c version [51a9d66b72].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
#ifndef lint
static char *RCSid = "$Id: setshow.c,v 3.26 92/03/24 22:34:20 woo Exp Locker: woo $";
#endif

/* GNUPLOT - setshow.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include <math.h>
#include "plot.h"
#include "setshow.h"

#define DEF_FORMAT   "%g"	/* default format for tic mark labels */
#define SIGNIF (0.01)		/* less than one hundredth of a tic mark */

/*
 * global variables to hold status of 'set' options
 *
 */
BOOLEAN			autoscale_r	= TRUE;
BOOLEAN			autoscale_t	= TRUE;
BOOLEAN			autoscale_u	= TRUE;
BOOLEAN			autoscale_v	= TRUE;
BOOLEAN			autoscale_x	= TRUE;
BOOLEAN			autoscale_y	= TRUE;
BOOLEAN			autoscale_z	= TRUE;
BOOLEAN			autoscale_lt	= TRUE;
BOOLEAN			autoscale_lu	= TRUE;
BOOLEAN			autoscale_lv	= TRUE;
BOOLEAN			autoscale_lx	= TRUE;
BOOLEAN			autoscale_ly	= TRUE;
BOOLEAN			autoscale_lz	= TRUE;
BOOLEAN 	  	clip_points	= FALSE;
BOOLEAN 	  	clip_lines1	= TRUE;
BOOLEAN 	  	clip_lines2	= FALSE;
BOOLEAN			draw_border	= TRUE;
BOOLEAN			draw_surface    = TRUE;
BOOLEAN			timedate    = FALSE;
char			dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1] = { "x", "y" };
char			xformat[MAX_ID_LEN+1] = DEF_FORMAT;
char			yformat[MAX_ID_LEN+1] = DEF_FORMAT;
char			zformat[MAX_ID_LEN+1] = DEF_FORMAT;
enum			PLOT_STYLE data_style	= POINTS,
			func_style	= LINES;
BOOLEAN			grid		= FALSE;
int				key			= -1;	/* default position */
double			key_x, key_y, key_z;	/* user specified position for key */
BOOLEAN			log_x		= FALSE,
			log_y		= FALSE,
			log_z		= FALSE;
FILE*			outfile;
char			outstr[MAX_ID_LEN+1] = "STDOUT";
BOOLEAN			parametric	= FALSE;
BOOLEAN			polar		= FALSE;
BOOLEAN			hidden3d	= FALSE;
int			angles_format	= ANGLES_RADIANS;
int			mapping3d	= MAP3D_CARTESIAN;
int			samples		= SAMPLES;
int			iso_samples	= ISO_SAMPLES;
float			xsize		= 1.0;  /* scale factor for size */
float			ysize		= 1.0;  /* scale factor for size */
float			zsize		= 1.0;  /* scale factor for size */
float			surface_rot_z   = 30.0; /* Default 3d transform. */
float			surface_rot_x   = 60.0;
float			surface_scale   = 1.0;
float			surface_zscale  = 1.0;
int			term		= 0;		/* unknown term is 0 */
char			term_options[MAX_ID_LEN+1] = "";
char			title[MAX_LINE_LEN+1] = "";
char			xlabel[MAX_LINE_LEN+1] = "";
char			ylabel[MAX_LINE_LEN+1] = "";
char			zlabel[MAX_LINE_LEN+1] = "";
int			time_xoffset	= 0;
int			time_yoffset	= 0;
int			title_xoffset	= 0;
int			title_yoffset	= 0;
int			xlabel_xoffset	= 0;
int			xlabel_yoffset	= 0;
int			ylabel_xoffset	= 0;
int			ylabel_yoffset	= 0;
int			zlabel_xoffset	= 0;
int			zlabel_yoffset	= 0;
double			rmin		= -0.0,
			rmax		=  10.0,
			tmin		= -5.0,
			tmax		=  5.0,
			umin		= -5.0,
			umax		= 5.0,
			vmin		= -5.0,
			vmax		= 5.0,
			xmin		= -10.0,
			xmax		= 10.0,
			ymin		= -10.0,
			ymax		= 10.0,
			zmin		= -10.0,
			zmax		= 10.0;
double			loff		= 0.0,
			roff		= 0.0,
			toff		= 0.0,
			boff		= 0.0;
int			draw_contour	= CONTOUR_NONE;
int			contour_pts	= 5;
int			contour_kind	= CONTOUR_KIND_LINEAR;
int			contour_order	= 4;
int			contour_levels	= 5;
double			zero = ZERO;			/* zero threshold, not 0! */

BOOLEAN xzeroaxis = TRUE;
BOOLEAN yzeroaxis = TRUE;

BOOLEAN xtics = TRUE;
BOOLEAN ytics = TRUE;
BOOLEAN ztics = TRUE;

float ticslevel = 0.5;

struct ticdef xticdef = {TIC_COMPUTED};
struct ticdef yticdef = {TIC_COMPUTED};
struct ticdef zticdef = {TIC_COMPUTED};

BOOLEAN			tic_in		= TRUE;

struct text_label *first_label = NULL;
struct arrow_def *first_arrow = NULL;

/*** other things we need *****/
extern char *strcpy(),*strcat();
extern int strlen();
extern FILE *popen();

/* input data, parsing variables */
extern struct lexical_unit token[];
extern char input_line[];
extern int num_tokens, c_token;
extern BOOLEAN interactive;	/* from plot.c */

extern char replot_line[];
extern struct udvt_entry *first_udv;
extern BOOLEAN is_3d_plot;

extern double magnitude(),real();
extern struct value *const_express();

/******** Local functions ********/
static void set_xyzlabel();
static void set_label();
static void set_nolabel();
static void set_arrow();
static void set_noarrow();
static void load_tics();
static void load_tic_user();
static void free_marklist();
static void load_tic_series();
static void load_offsets();

static void show_style(), show_range(), show_zero(), show_border();
static void show_offsets(), show_output(), show_samples(), show_isosamples();
static void show_view(), show_size(), show_title(), show_xlabel();
static void show_angles();
static void show_ylabel(), show_zlabel(), show_xzeroaxis(), show_yzeroaxis();
static void show_label(), show_arrow(), show_grid(), show_key();
static void show_polar(), show_parametric(), show_tics(), show_ticdef();
static void show_time(), show_term(), show_plot(), show_autoscale(), show_clip();
static void show_contour(), show_mapping(), show_format(), show_logscale();
static void show_variables(), show_surface(), show_hidden3d();
static void delete_label();
static int assign_label_tag();
static void delete_arrow();
static int assign_arrow_tag();
static BOOLEAN set_one(), set_two(), set_three();
static BOOLEAN show_one(), show_two();

/******** The 'set' command ********/
void
set_command()
{
    c_token++;

    if (!set_one() && !set_two() && !set_three())
	int_error(
	"valid set options:  'angles' '{no}arrow', {no}autoscale', \n\
	'{no}border', '{no}clip', 'cntrparam', '{no}contour', 'data style', \n\
	'dummy', 'format', 'function style', '{no}grid', '{no}hidden3d', \n\
	'isosamples', '{no}key', '{no}label', '{no}logscale', 'mapping', \n\
	'offsets', 'output', '{no}parametric', '{no}polar', 'rrange', \n\
	'samples', 'size', '{no}surface', 'terminal', 'tics', 'ticslevel', \n\
	'{no}time', 'title', 'trange', 'urange', 'view', 'vrange', 'xlabel', \n\
	'xrange', '{no}xtics', '{no}xzeroaxis', 'ylabel', 'yrange', \n\
	'{no}ytics', '{no}yzeroaxis', 'zero', '{no}zeroaxis', 'zlabel', \n\
	'zrange', '{no}ztics'", c_token);
}

/* return TRUE if a command match, FALSE if not */
static BOOLEAN
set_one()
{
	if (almost_equals(c_token,"ar$row")) {
		c_token++;
		set_arrow();
	}
	else if (almost_equals(c_token,"noar$row")) {
		c_token++;
		set_noarrow();
	}
     else if (almost_equals(c_token,"au$toscale")) {
	    c_token++;
	    if (END_OF_COMMAND) {
		   autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = TRUE;
	    } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
		   autoscale_x = autoscale_y = TRUE;
		   c_token++;
	    } else if (equals(c_token, "r")) {
		   autoscale_r = TRUE;
		   c_token++;
	    } else if (equals(c_token, "t")) {
		   autoscale_t = TRUE;
		   c_token++;
	    } else if (equals(c_token, "x")) {
		   autoscale_x = TRUE;
		   c_token++;
	    } else if (equals(c_token, "y")) {
		   autoscale_y = TRUE;
		   c_token++;
	    } else if (equals(c_token, "z")) {
		   autoscale_z = TRUE;
		   c_token++;
	    }
	} 
	else if (almost_equals(c_token,"noau$toscale")) {
	    c_token++;
	    if (END_OF_COMMAND) {
		   autoscale_r=autoscale_t = autoscale_x = autoscale_y = autoscale_z = FALSE;
	    } else if (equals(c_token, "xy") || equals(c_token, "tyx")) {
		   autoscale_x = autoscale_y = FALSE;
		   c_token++;
	    } else if (equals(c_token, "r")) {
		   autoscale_r = FALSE;
		   c_token++;
	    } else if (equals(c_token, "t")) {
		   autoscale_t = FALSE;
		   c_token++;
	    } else if (equals(c_token, "x")) {
		   autoscale_x = FALSE;
		   c_token++;
	    } else if (equals(c_token, "y")) {
		   autoscale_y = FALSE;
		   c_token++;
	    } else if (equals(c_token, "z")) {
		   autoscale_z = FALSE;
		   c_token++;
	    }
	} 
	else if (almost_equals(c_token,"bor$der")) {
	    draw_border = TRUE;
	    c_token++;
	}
	else if (almost_equals(c_token,"nobor$der")) {
	    draw_border = FALSE;
	    c_token++;
	}
	else if (almost_equals(c_token,"c$lip")) {
	    c_token++;
	    if (END_OF_COMMAND)
		 /* assuming same as points */
		 clip_points = TRUE;
	    else if (almost_equals(c_token, "p$oints"))
		 clip_points = TRUE;
	    else if (almost_equals(c_token, "o$ne"))
		 clip_lines1 = TRUE;
	    else if (almost_equals(c_token, "t$wo"))
		 clip_lines2 = TRUE;
	    else
		 int_error("expecting 'points', 'one', or 'two'", c_token);
	    c_token++;
	}
	else if (almost_equals(c_token,"noc$lip")) {
	    c_token++;
	    if (END_OF_COMMAND) {
		   /* same as all three */
		   clip_points = FALSE;
		   clip_lines1 = FALSE;
		   clip_lines2 = FALSE;
	    } else if (almost_equals(c_token, "p$oints"))
		 clip_points = FALSE;
	    else if (almost_equals(c_token, "o$ne"))
		 clip_lines1 = FALSE;
	    else if (almost_equals(c_token, "t$wo"))
		 clip_lines2 = FALSE;
	    else
		 int_error("expecting 'points', 'one', or 'two'", c_token);
	    c_token++;
	}
	else if (almost_equals(c_token,"hi$dden3d")) {
	    hidden3d = TRUE;
	    c_token++;
	}
	else if (almost_equals(c_token,"nohi$dden3d")) {
	    hidden3d = FALSE;
	    c_token++;
	}
	else if (almost_equals(c_token,"ma$pping3d")) {
	    c_token++;
	    if (END_OF_COMMAND)
		 /* assuming same as points */
		 mapping3d = MAP3D_CARTESIAN;
	    else if (almost_equals(c_token, "ca$rtesian"))
		 mapping3d = MAP3D_CARTESIAN;
	    else if (almost_equals(c_token, "s$pherical"))
		 mapping3d = MAP3D_SPHERICAL;
	    else if (almost_equals(c_token, "cy$lindrical"))
		 mapping3d = MAP3D_CYLINDRICAL;
	    else
		 int_error("expecting 'cartesian', 'spherical', or 'cylindrical'", c_token);
	    c_token++;
	}
	else if (almost_equals(c_token,"co$ntour")) {
	    c_token++;
	    if (END_OF_COMMAND)
		 /* assuming same as points */
		 draw_contour = CONTOUR_BASE;
	    else if (almost_equals(c_token, "ba$se"))
		 draw_contour = CONTOUR_BASE;
	    else if (almost_equals(c_token, "s$urface"))
		 draw_contour = CONTOUR_SRF;
	    else if (almost_equals(c_token, "bo$th"))
		 draw_contour = CONTOUR_BOTH;
	    else
		 int_error("expecting 'base', 'surface', or 'both'", c_token);
	    c_token++;
	}
	else if (almost_equals(c_token,"noco$ntour")) {
	    c_token++;
	    draw_contour = CONTOUR_NONE;
	}
	else if (almost_equals(c_token,"cntrp$aram")) {
	    struct value a;

	    c_token++;
	    if (END_OF_COMMAND) {
		 /* assuming same as defaults */
		 contour_pts = 5;
		 contour_kind = CONTOUR_KIND_LINEAR;
		 contour_order = 4;
		 contour_levels = 5;
	    }
	    else if (almost_equals(c_token, "p$oints")) {
		 c_token++;
		 contour_pts = (int) real(const_express(&a));
	    }
	    else if (almost_equals(c_token, "li$near")) {
		 c_token++;
		 contour_kind = CONTOUR_KIND_LINEAR;
	    }
	    else if (almost_equals(c_token, "c$ubicspline")) {
		 c_token++;
		 contour_kind = CONTOUR_KIND_CUBIC_SPL;
	    }
	    else if (almost_equals(c_token, "b$spline")) {
		 c_token++;
		 contour_kind = CONTOUR_KIND_BSPLINE;
	    }
	    else if (almost_equals(c_token, "le$vels")) {
		 c_token++;
		 contour_levels = (int) real(const_express(&a));
	    }
	    else if (almost_equals(c_token, "o$rder")) {
		 int order;
		 c_token++;
		 order = (int) real(const_express(&a));
		 if ( order < 2 || order > 10 )
		     int_error("bspline order must be in [2..10] range.", c_token);
		 contour_order = order;
	    }
	    else
		 int_error("expecting 'linear', 'cubicspline', 'bspline', 'points', 'levels' or 'order'", c_token);
	    c_token++;
	}
	else if (almost_equals(c_token,"d$ata")) {
		c_token++;
		if (!almost_equals(c_token,"s$tyle"))
			int_error("expecting keyword 'style'",c_token);
		data_style = get_style();
	}
	else if (almost_equals(c_token,"d$ummy")) {
		c_token++;
		if (END_OF_COMMAND)
			int_error("expecting dummy variable name", c_token);
		else {
			if (!equals(c_token,","))
				copy_str(dummy_var[0],c_token++);
			if (!END_OF_COMMAND && equals(c_token,",")) {
				c_token++;
				if (END_OF_COMMAND)
					int_error("expecting second dummy variable name", c_token);
				copy_str(dummy_var[1],c_token++);
		    	}
		}
	}
	else if (almost_equals(c_token,"fo$rmat")) {
		BOOLEAN setx, sety, setz;
		c_token++;
		if (equals(c_token,"x")) {
			setx = TRUE; sety = setz = FALSE;
			c_token++;
		}
		else if (equals(c_token,"y")) {
			setx = setz = FALSE; sety = TRUE;
			c_token++;
		}
		else if (equals(c_token,"z")) {
			setx = sety = FALSE; setz = TRUE;
			c_token++;
		}
		else if (equals(c_token,"xy") || equals(c_token,"yx")) {
			setx = sety = TRUE; setz = FALSE;
			c_token++;
		}
		else if (isstring(c_token) || END_OF_COMMAND) {
			/* Assume he wants all */
			setx = sety = setz = TRUE;
		}
		if (END_OF_COMMAND) {
			if (setx)
				(void) strcpy(xformat,DEF_FORMAT);
			if (sety)
				(void) strcpy(yformat,DEF_FORMAT);
			if (setz)
				(void) strcpy(zformat,DEF_FORMAT);
		}
		else {
			if (!isstring(c_token))
			  int_error("expecting format string",c_token);
			else {
				if (setx)
				 quote_str(xformat,c_token);
				if (sety)
				 quote_str(yformat,c_token);
				if (setz)
				 quote_str(zformat,c_token);
				c_token++;
			}
		}
	}
	else if (almost_equals(c_token,"fu$nction")) {
		c_token++;
		if (!almost_equals(c_token,"s$tyle"))
			int_error("expecting keyword 'style'",c_token);
		func_style = get_style();
	}
	else if (almost_equals(c_token,"la$bel")) {
		c_token++;
		set_label();
	}
	else if (almost_equals(c_token,"nola$bel")) {
		c_token++;
		set_nolabel();
	}
	else if (almost_equals(c_token,"lo$gscale")) {
		c_token++;
	    if (END_OF_COMMAND) {
		   log_x = log_y = log_z = TRUE;
	    } else {
		   if (chr_in_str(c_token, 'x'))
		       log_x = TRUE;
		   if (chr_in_str(c_token, 'y'))
		       log_y = TRUE;
		   if (chr_in_str(c_token, 'z'))
		       log_z = TRUE;
		   c_token++;
	    }
	}
	else if (almost_equals(c_token,"nolo$gscale")) {
	    c_token++;
	    if (END_OF_COMMAND) {
		log_x = log_y = log_z = FALSE;
	    } else {
		if (chr_in_str(c_token, 'x'))
		    log_x = FALSE;
		if (chr_in_str(c_token, 'y'))
		    log_y = FALSE;
		if (chr_in_str(c_token, 'z'))
		    log_z = FALSE;
		c_token++;
	    }
	} 
	else if (almost_equals(c_token,"of$fsets")) {
		c_token++;
		if (END_OF_COMMAND) {
			loff = roff = toff = boff = 0.0;  /* Reset offsets */
		}
		else {
			load_offsets (&loff,&roff,&toff,&boff);
		}
	}
	else
		return(FALSE);	/* no command match */
	return(TRUE);
}


/* return TRUE if a command match, FALSE if not */
static BOOLEAN
set_two()
{
     char testfile[MAX_LINE_LEN+1];
#ifdef unix
     static BOOLEAN pipe_open = FALSE;
#endif

	if (almost_equals(c_token,"o$utput")) {
		register FILE *f;

		c_token++;
		if (term && term_init)
			(*term_tbl[term].reset)();
		if (END_OF_COMMAND) {	/* no file specified */
 			UP_redirect (4);
			if (outfile != stdout) { /* Never close stdout */
#ifdef unix
				if ( pipe_open ) {
					(void) pclose(outfile);
					pipe_open = FALSE;
				} else
#endif
					(void) fclose(outfile);
			}
			outfile = stdout; /* Don't dup... */
			term_init = FALSE;
			(void) strcpy(outstr,"STDOUT");
		} else if (!isstring(c_token))
			int_error("expecting filename",c_token);
		else {
			quote_str(testfile,c_token);
#ifdef unix
			if ( *testfile == '|' ) {
			  if ((f = popen(testfile+1,"w")) == (FILE *)NULL)
			    os_error("cannot create pipe; output not changed",c_token);
			  else
			    pipe_open = TRUE;
			} else
#endif
			  if ((f = fopen(testfile,"w")) == (FILE *)NULL)
			    os_error("cannot open file; output not changed",c_token);
			if (outfile != stdout) /* Never close stdout */
				(void) fclose(outfile);
			outfile = f;
			term_init = FALSE;
			outstr[0] = '\'';
			(void) strcat(strcpy(outstr+1,testfile),"'");
 			UP_redirect (1);
		}
		c_token++;
	}
	else if (almost_equals(c_token,"tit$le")) {
		set_xyzlabel(title,&title_xoffset,&title_yoffset);
	}
	else if (almost_equals(c_token,"xl$abel")) {
		set_xyzlabel(xlabel,&xlabel_xoffset,&xlabel_yoffset);
	}
	else if (almost_equals(c_token,"yl$abel")) {
		set_xyzlabel(ylabel,&ylabel_xoffset,&ylabel_yoffset);
	}
	else if (almost_equals(c_token,"zl$abel")) {
		set_xyzlabel(zlabel,&zlabel_xoffset,&zlabel_yoffset);
	}
	else if (almost_equals(c_token,"xzero$axis")) {
		c_token++;
		xzeroaxis = TRUE;
	} 
	else if (almost_equals(c_token,"yzero$axis")) {
		c_token++;
		yzeroaxis = TRUE;
	} 
	else if (almost_equals(c_token,"zeroa$xis")) {
		c_token++;
		yzeroaxis = TRUE;
		xzeroaxis = TRUE;
	} 
	else if (almost_equals(c_token,"noxzero$axis")) {
		c_token++;
		xzeroaxis = FALSE;
	} 
	else if (almost_equals(c_token,"noyzero$axis")) {
		c_token++;
		yzeroaxis = FALSE;
	} 
	else if (almost_equals(c_token,"nozero$axis")) {
		c_token++;
		xzeroaxis = FALSE;
		yzeroaxis = FALSE;
	} 
	else if (almost_equals(c_token,"par$ametric")) {
	    if (!parametric) {
		   parametric = TRUE;
		   strcpy (dummy_var[0], "t");
		   strcpy (dummy_var[1], "y");
	  	   (void) fprintf(stderr,"\n\tdummy variable is t for curves, u/v for surfaces\n");
	    }
	    c_token++;
	}
	else if (almost_equals(c_token,"nopar$ametric")) {
	    if (parametric) {
		   parametric = FALSE;
		   strcpy (dummy_var[0], "x");
		   strcpy (dummy_var[1], "y");
	  	   (void) fprintf(stderr,"\n\tdummy variable is x for curves, x/y for surfaces\n");
	    }
	    c_token++;
	}
	else if (almost_equals(c_token,"pol$ar")) {
	    if (!polar) {
			polar = TRUE;
			if (parametric) {
				tmin = 0.0;
				tmax = 2*Pi;
			} else if (angles_format == ANGLES_DEGREES) {
				xmin = 0.0;
				xmax = 360.0;
			} else {
				xmin = 0.0;
				xmax = 2*Pi;
			}
	    }
	    c_token++;
	}
	else if (almost_equals(c_token,"nopo$lar")) {
	    if (polar) {
			polar = FALSE;
			if (parametric) {
				tmin = -5.0;
				tmax = 5.0;
			} else {
				xmin = -10.0;
				xmax = 10.0;
			}
	    }
	    c_token++;
	}
	else if (almost_equals(c_token,"an$gles")) {
	    c_token++;
	    if (END_OF_COMMAND) {
		/* assuming same as defaults */
		angles_format = ANGLES_RADIANS;
	    }
	    else if (almost_equals(c_token, "r$adians")) {
		angles_format = ANGLES_RADIANS;
		c_token++;
	    }
	    else if (almost_equals(c_token, "d$egrees")) {
		angles_format = ANGLES_DEGREES;
		c_token++;
	    }
	    else
		 int_error("expecting 'radians' or 'degrees'", c_token);
	}
	else if (almost_equals(c_token,"g$rid")) {
		grid = TRUE;
		c_token++;
	}
	else if (almost_equals(c_token,"nog$rid")) {
		grid = FALSE;
		c_token++;
	}
	else if (almost_equals(c_token,"su$rface")) {
		draw_surface = TRUE;
		c_token++;
	}
	else if (almost_equals(c_token,"nosu$rface")) {
		draw_surface = FALSE;
		c_token++;
	}
	else if (almost_equals(c_token,"k$ey")) {
		struct value a;
		c_token++;
		if (END_OF_COMMAND) {
			key = -1;
		} 
		else {
			key_x = real(const_express(&a));
			if (!equals(c_token,","))
				int_error("',' expected",c_token);
			c_token++;
			key_y = real(const_express(&a));
			if (equals(c_token,","))
			{
			        c_token++;
				key_z = real(const_express(&a));
			}
			key = 1;
		} 
	}
	else if (almost_equals(c_token,"nok$ey")) {
		key = 0;
		c_token++;
	}
	else if (almost_equals(c_token,"tic$s")) {
		tic_in = TRUE;
		c_token++;
		if (almost_equals(c_token,"i$n")) {
			tic_in = TRUE;
			c_token++;
		}
		else if (almost_equals(c_token,"o$ut")) {
			tic_in = FALSE;
			c_token++;
		}
	}
     else if (almost_equals(c_token,"xt$ics")) {
	    xtics = TRUE;
	    c_token++;
	    if (END_OF_COMMAND) { /* reset to default */
		   if (xticdef.type == TIC_USER) {
			  free_marklist(xticdef.def.user);
			  xticdef.def.user = NULL;
		   }
		   xticdef.type = TIC_COMPUTED;
	    }
	    else
		 load_tics(&xticdef);
	} 
     else if (almost_equals(c_token,"noxt$ics")) {
	    xtics = FALSE;
	    c_token++;
	} 
     else if (almost_equals(c_token,"yt$ics")) {
	    ytics = TRUE;
	    c_token++;
	    if (END_OF_COMMAND) { /* reset to default */
		   if (yticdef.type == TIC_USER) {
			  free_marklist(yticdef.def.user);
			  yticdef.def.user = NULL;
		   }
		   yticdef.type = TIC_COMPUTED;
	    }
	    else
		 load_tics(&yticdef);
	} 
     else if (almost_equals(c_token,"noyt$ics")) {
	    ytics = FALSE;
	    c_token++;
	} 
     else if (almost_equals(c_token,"zt$ics")) {
	    ztics = TRUE;
	    c_token++;
	    if (END_OF_COMMAND) { /* reset to default */
		   if (zticdef.type == TIC_USER) {
			  free_marklist(zticdef.def.user);
			  zticdef.def.user = NULL;
		   }
		   zticdef.type = TIC_COMPUTED;
	    }
	    else
		 load_tics(&zticdef);
	} 
     else if (almost_equals(c_token,"nozt$ics")) {
	    ztics = FALSE;
	    c_token++;
	} 
    else if (almost_equals(c_token,"ticsl$evel")) {
		double tlvl;
		struct value a;

		c_token++;
		tlvl = real(const_express(&a));
		if (tlvl < 0.0)
			int_error("tics level must be > 0; ticslevel unchanged",
				c_token);
		else {
			ticslevel = tlvl;
		}
    }
    else
	return(FALSE);	/* no command match */

    return(TRUE);
}
 


/* return TRUE if a command match, FALSE if not */
static BOOLEAN
set_three()
{
     if (almost_equals(c_token,"sa$mples")) {
		register int tsamp;
		struct value a;

		c_token++;
		tsamp = (int)magnitude(const_express(&a));
		if (tsamp < 2)
			int_error("sampling rate must be > 1; sampling unchanged",
				c_token);
		else {
		        extern struct surface_points *first_3dplot;
			register struct surface_points *f_3dp = first_3dplot;

			first_3dplot = NULL;
			sp_free(f_3dp);

			samples = tsamp;
		}
    }
    else if (almost_equals(c_token,"isosa$mples")) {
		register int tsamp;
		struct value a;

		c_token++;
		tsamp = (int)magnitude(const_express(&a));
		if (tsamp < 2)
			int_error("sampling rate must be > 1; sampling unchanged",
				c_token);
		else {
		        extern struct curve_points *first_plot;
		        extern struct surface_points *first_3dplot;
			register struct curve_points *f_p = first_plot;
			register struct surface_points *f_3dp = first_3dplot;

			first_plot = NULL;
			first_3dplot = NULL;
			cp_free(f_p);
			sp_free(f_3dp);

			iso_samples = tsamp;
		}
    }
    else if (almost_equals(c_token,"si$ze")) {
		struct value s;
		c_token++;
		if (END_OF_COMMAND) {
			xsize = 1.0;
			ysize = 1.0;
		} 
		else {
				xsize=real(const_express(&s));
				if (!equals(c_token,","))
					int_error("',' expected",c_token);
				c_token++;
				ysize=real(const_express(&s));
		} 
	} 
	else if (almost_equals(c_token,"t$erminal")) {
		c_token++;
		if (END_OF_COMMAND) {
			list_terms();
			screen_ok = FALSE;
		}
		else {
			if (term && term_init) {
				(*term_tbl[term].reset)();
				(void) fflush(outfile);
			}
			term = set_term(c_token);
			c_token++;

			/* get optional mode parameters */
			if (term)
				(*term_tbl[term].options)();
			if (interactive && *term_options)
				fprintf(stderr,"Options are '%s'\n",term_options);
		}
	}
	else if (almost_equals(c_token,"tim$e")) {
		timedate = TRUE;
		c_token++;
		if (!END_OF_COMMAND) {
			struct value a;
			int x, y;

			/* We have x,y offsets specified */
			if (!equals(c_token,","))
			    time_xoffset = (int)real(const_express(&a));
			if (!END_OF_COMMAND && equals(c_token,",")) {
				c_token++;
				time_yoffset = (int)real(const_express(&a));
			}
		}
	}
	else if (almost_equals(c_token,"not$ime")) {
		timedate = FALSE;
		c_token++;
	}
	else if (almost_equals(c_token,"rr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&rmin,&rmax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_r = FALSE;
	}
	else if (almost_equals(c_token,"tr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&tmin,&tmax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_t = FALSE;
	}
	else if (almost_equals(c_token,"ur$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&umin,&umax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_u = FALSE;
	}
	else if (almost_equals(c_token,"vi$ew")) {
		int i;
		BOOLEAN was_comma = TRUE;
		double local_vals[4];
		struct value a;

		local_vals[0] = surface_rot_x;
		local_vals[1] = surface_rot_z;
		local_vals[2] = surface_scale;
		local_vals[3] = surface_zscale;
		c_token++;
		for (i = 0; i < 4 && !(END_OF_COMMAND);) {
			if (equals(c_token,",")) {
				if (was_comma) i++;
				was_comma = TRUE;
				c_token++;
			}
			else {
				if (!was_comma)
					int_error("',' expected",c_token);
				local_vals[i] = real(const_express(&a));
				i++;
				was_comma = FALSE;
			}
		}

		if (local_vals[0] < 0 || local_vals[0] > 180)
			int_error("rot_x must be in [0:180] degrees range; view unchanged",
				  c_token);
		if (local_vals[1] < 0 || local_vals[1] > 360)
			int_error("rot_z must be in [0:360] degrees range; view unchanged",
				  c_token);
		if (local_vals[2] < 1e-6)
			int_error("scale must be > 0; view unchanged", c_token);
		if (local_vals[3] < 1e-6)
			int_error("zscale must be > 0; view unchanged", c_token);

		surface_rot_x = local_vals[0];
		surface_rot_z = local_vals[1];
		surface_scale = local_vals[2];
		surface_zscale = local_vals[3];
	}
	else if (almost_equals(c_token,"vr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&vmin,&vmax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_v = FALSE;
	}
	else if (almost_equals(c_token,"xr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&xmin,&xmax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_x = FALSE;
	}
	else if (almost_equals(c_token,"yr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&ymin,&ymax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_y = FALSE;
	}
	else if (almost_equals(c_token,"zr$ange")) {
	     BOOLEAN changed;
		c_token++;
		if (!equals(c_token,"["))
			int_error("expecting '['",c_token);
		c_token++;
		changed = load_range(&zmin,&zmax);
		if (!equals(c_token,"]"))
		  int_error("expecting ']'",c_token);
		c_token++;
		if (changed)
		  autoscale_z = FALSE;
	}
	else if (almost_equals(c_token,"z$ero")) {
		struct value a;
		c_token++;
		zero = magnitude(const_express(&a));
	}
	else
		return(FALSE);	/* no command match */
	return(TRUE);
}

/*********** Support functions for set_command ***********/

/* process a 'set {x/y/z}label command */
/* set {x/y/z}label {label_text} {x}{,y} */
static void set_xyzlabel(str,xpos,ypos)
char *str;
int *xpos,*ypos;
{
	c_token++;
	if (END_OF_COMMAND) {	/* no label specified */
		str[0] = '\0';
	} else {
		if (isstring(c_token)) {
			/* We have string specified - grab it. */
			quotel_str(str,c_token);
			c_token++;
		}
		if (!END_OF_COMMAND) {
			struct value a;
			int x, y;

			/* We have x,y offsets specified */
			if (!equals(c_token,","))
			    *xpos = (int)real(const_express(&a));
			if (!END_OF_COMMAND && equals(c_token,",")) {
				c_token++;
				*ypos = (int)real(const_express(&a));
			}
		}
	}
}

/* process a 'set label' command */
/* set label {tag} {label_text} {at x,y} {pos} */
static void
set_label()
{
    struct value a;
    struct text_label *this_label = NULL;
    struct text_label *new_label = NULL;
    struct text_label *prev_label = NULL;
    double x, y, z;
    char text[MAX_LINE_LEN+1];
    enum JUSTIFY just;
    int tag;
    BOOLEAN set_text, set_position, set_just;

    /* get tag */
    if (!END_OF_COMMAND 
	   && !isstring(c_token) 
	   && !equals(c_token, "at")
	   && !equals(c_token, "left")
	   && !equals(c_token, "center")
	   && !equals(c_token, "centre")
	   && !equals(c_token, "right")) {
	   /* must be a tag expression! */
	   tag = (int)real(const_express(&a));
	   if (tag <= 0)
		int_error("tag must be > zero", c_token);
    } else
	 tag = assign_label_tag(); /* default next tag */
	 
    /* get text */
    if (!END_OF_COMMAND && isstring(c_token)) {
	   /* get text */
	   quotel_str(text, c_token);
	   c_token++;
	   set_text = TRUE;
    } else {
	   text[0] = '\0';		/* default no text */
	   set_text = FALSE;
    }
	 
    /* get justification - what the heck, let him put it here */
    if (!END_OF_COMMAND && !equals(c_token, "at")) {
	   if (almost_equals(c_token,"l$eft")) {
		  just = LEFT;
	   }
	   else if (almost_equals(c_token,"c$entre")
			  || almost_equals(c_token,"c$enter")) {
		  just = CENTRE;
	   }
	   else if (almost_equals(c_token,"r$ight")) {
		  just = RIGHT;
	   }
	   else
		int_error("bad syntax in set label", c_token);
	   c_token++;
	   set_just = TRUE;
    } else {
	   just = LEFT;			/* default left justified */
	   set_just = FALSE;
    } 

    /* get position */
    if (!END_OF_COMMAND && equals(c_token, "at")) {
	   c_token++;
	   if (END_OF_COMMAND)
		int_error("coordinates expected", c_token);
	   /* get coordinates */
	   x = real(const_express(&a));
	   if (!equals(c_token,","))
		int_error("',' expected",c_token);
	   c_token++;
	   y = real(const_express(&a));
	   if (equals(c_token,",")) {
		c_token++;
		z = real(const_express(&a));
	   }
	   else
	        z = 0;
	   set_position = TRUE;
    } else {
	   x = y = z = 0;			/* default at origin */
	   set_position = FALSE;
    }

    /* get justification */
    if (!END_OF_COMMAND) {
	   if (set_just)
		int_error("only one justification is allowed", c_token);
	   if (almost_equals(c_token,"l$eft")) {
		  just = LEFT;
	   }
	   else if (almost_equals(c_token,"c$entre")
			  || almost_equals(c_token,"c$enter")) {
		  just = CENTRE;
	   }
	   else if (almost_equals(c_token,"r$ight")) {
		  just = RIGHT;
	   }
	   else
		int_error("bad syntax in set label", c_token);
	   c_token++;
	   set_just = TRUE;
    } 

    if (!END_OF_COMMAND)
	 int_error("extraenous or out-of-order arguments in set label", c_token);

    /* OK! add label */
    if (first_label != NULL) { /* skip to last label */
	   for (this_label = first_label; this_label != NULL ; 
		   prev_label = this_label, this_label = this_label->next)
		/* is this the label we want? */
		if (tag <= this_label->tag)
		  break;
    }
    if (this_label != NULL && tag == this_label->tag) {
	   /* changing the label */
	   if (set_position) {
		  this_label->x = x;
		  this_label->y = y;
		  this_label->z = z;
	   }
	   if (set_text)
		(void) strcpy(this_label->text, text);
	   if (set_just)
		this_label->pos = just;
    } else {
	   /* adding the label */
	   new_label = (struct text_label *) 
		alloc ( (unsigned int) sizeof(struct text_label), "label");
	   if (prev_label != NULL)
		prev_label->next = new_label; /* add it to end of list */
	   else 
		first_label = new_label; /* make it start of list */
	   new_label->tag = tag;
	   new_label->next = this_label;
	   new_label->x = x;
	   new_label->y = y;
	   new_label->z = z;
	   (void) strcpy(new_label->text, text);
	   new_label->pos = just;
    }
}

/* process 'set nolabel' command */
/* set nolabel {tag} */
static void
set_nolabel()
{
    struct value a;
    struct text_label *this_label;
    struct text_label *prev_label; 
    int tag;

    if (END_OF_COMMAND) {
	   /* delete all labels */
	   while (first_label != NULL)
		delete_label((struct text_label *)NULL,first_label);
    }
    else {
	   /* get tag */
	   tag = (int)real(const_express(&a));
	   if (!END_OF_COMMAND)
		int_error("extraneous arguments to set nolabel", c_token);
	   for (this_label = first_label, prev_label = NULL;
		   this_label != NULL;
		   prev_label = this_label, this_label = this_label->next) {
		  if (this_label->tag == tag) {
			 delete_label(prev_label,this_label);
			 return;		/* exit, our job is done */
		  }
	   }
	   int_error("label not found", c_token);
    }
}

/* assign a new label tag */
/* labels are kept sorted by tag number, so this is easy */
static int				/* the lowest unassigned tag number */
assign_label_tag()
{
    struct text_label *this_label;
    int last = 0;			/* previous tag value */

    for (this_label = first_label; this_label != NULL;
	    this_label = this_label->next)
	 if (this_label->tag == last+1)
	   last++;
	 else
	   break;
    
    return (last+1);
}

/* delete label from linked list started by first_label.
 * called with pointers to the previous label (prev) and the 
 * label to delete (this).
 * If there is no previous label (the label to delete is
 * first_label) then call with prev = NULL.
 */
static void
delete_label(prev,this)
	struct text_label *prev, *this;
{
    if (this!=NULL)	{		/* there really is something to delete */
	   if (prev!=NULL)		/* there is a previous label */
		prev->next = this->next; 
	   else				/* this = first_label so change first_label */
		first_label = this->next;
	   free((char *)this);
    }
}


/* process a 'set arrow' command */
/* set arrow {tag} {from x,y} {to x,y} {{no}head} */
static void
set_arrow()
{
    struct value a;
    struct arrow_def *this_arrow = NULL;
    struct arrow_def *new_arrow = NULL;
    struct arrow_def *prev_arrow = NULL;
    double sx, sy, sz;
    double ex, ey, ez;
    int tag;
    BOOLEAN set_start, set_end, head = 1;

    /* get tag */
    if (!END_OF_COMMAND 
	   && !equals(c_token, "from")
	   && !equals(c_token, "to")) {
	   /* must be a tag expression! */
	   tag = (int)real(const_express(&a));
	   if (tag <= 0)
		int_error("tag must be > zero", c_token);
    } else
	 tag = assign_arrow_tag(); /* default next tag */
	 
    /* get start position */
    if (!END_OF_COMMAND && equals(c_token, "from")) {
	   c_token++;
	   if (END_OF_COMMAND)
		int_error("start coordinates expected", c_token);
	   /* get coordinates */
	   sx = real(const_express(&a));
	   if (!equals(c_token,","))
		int_error("',' expected",c_token);
	   c_token++;
	   sy = real(const_express(&a));
	   if (equals(c_token,",")) {
		c_token++;
		sz = real(const_express(&a));
	   }
	   else
	       sz = 0;
	   set_start = TRUE;
    } else {
	   sx = sy = sz = 0;			/* default at origin */
	   set_start = FALSE;
    }

    /* get end position */
    if (!END_OF_COMMAND && equals(c_token, "to")) {
	   c_token++;
	   if (END_OF_COMMAND)
		int_error("end coordinates expected", c_token);
	   /* get coordinates */
	   ex = real(const_express(&a));
	   if (!equals(c_token,","))
		int_error("',' expected",c_token);
	   c_token++;
	   ey = real(const_express(&a));
	   if (equals(c_token,",")) {
		c_token++;
		ez = real(const_express(&a));
	   }
	   else
		ez = 0;
	   set_end = TRUE;
    } else {
	   ex = ey = ez = 0;			/* default at origin */
	   set_end = FALSE;
    }

    /* get start position - what the heck, either order is ok */
    if (!END_OF_COMMAND && equals(c_token, "from")) {
	   if (set_start)
		int_error("only one 'from' is allowed", c_token);
	   c_token++;
	   if (END_OF_COMMAND)
		int_error("start coordinates expected", c_token);
	   /* get coordinates */
	   sx = real(const_express(&a));
	   if (!equals(c_token,","))
		int_error("',' expected",c_token);
	   c_token++;
	   sy = real(const_express(&a));
	   if (equals(c_token,",")) {
		c_token++;
		sz = real(const_express(&a));
	   }
	   else
	       sz = 0;
	   set_start = TRUE;
    }

    if (!END_OF_COMMAND && equals(c_token, "nohead")) {
	   c_token++;
           head = 0;
    }

    if (!END_OF_COMMAND && equals(c_token, "head")) {
	   c_token++;
           head = 1;
    }

    if (!END_OF_COMMAND)
	 int_error("extraneous or out-of-order arguments in set arrow", c_token);

    /* OK! add arrow */
    if (first_arrow != NULL) { /* skip to last arrow */
	   for (this_arrow = first_arrow; this_arrow != NULL ; 
		   prev_arrow = this_arrow, this_arrow = this_arrow->next)
		/* is this the arrow we want? */
		if (tag <= this_arrow->tag)
		  break;
    }
    if (this_arrow != NULL && tag == this_arrow->tag) {
	   /* changing the arrow */
	   if (set_start) {
		  this_arrow->sx = sx;
		  this_arrow->sy = sy;
		  this_arrow->sz = sz;
	   }
	   if (set_end) {
		  this_arrow->ex = ex;
		  this_arrow->ey = ey;
		  this_arrow->ez = ez;
	   }
	   this_arrow->head = head;
    } else {
	   /* adding the arrow */
	   new_arrow = (struct arrow_def *) 
		alloc ( (unsigned int) sizeof(struct arrow_def), "arrow");
	   if (prev_arrow != NULL)
		prev_arrow->next = new_arrow; /* add it to end of list */
	   else 
		first_arrow = new_arrow; /* make it start of list */
	   new_arrow->tag = tag;
	   new_arrow->next = this_arrow;
	   new_arrow->sx = sx;
	   new_arrow->sy = sy;
	   new_arrow->sz = sz;
	   new_arrow->ex = ex;
	   new_arrow->ey = ey;
	   new_arrow->ez = ez;
	   new_arrow->head = head;
    }
}

/* process 'set noarrow' command */
/* set noarrow {tag} */
static void
set_noarrow()
{
    struct value a;
    struct arrow_def *this_arrow;
    struct arrow_def *prev_arrow; 
    int tag;

    if (END_OF_COMMAND) {
	   /* delete all arrows */
	   while (first_arrow != NULL)
		delete_arrow((struct arrow_def *)NULL,first_arrow);
    }
    else {
	   /* get tag */
	   tag = (int)real(const_express(&a));
	   if (!END_OF_COMMAND)
		int_error("extraneous arguments to set noarrow", c_token);
	   for (this_arrow = first_arrow, prev_arrow = NULL;
		   this_arrow != NULL;
		   prev_arrow = this_arrow, this_arrow = this_arrow->next) {
		  if (this_arrow->tag == tag) {
			 delete_arrow(prev_arrow,this_arrow);
			 return;		/* exit, our job is done */
		  }
	   }
	   int_error("arrow not found", c_token);
    }
}

/* assign a new arrow tag */
/* arrows are kept sorted by tag number, so this is easy */
static int				/* the lowest unassigned tag number */
assign_arrow_tag()
{
    struct arrow_def *this_arrow;
    int last = 0;			/* previous tag value */

    for (this_arrow = first_arrow; this_arrow != NULL;
	    this_arrow = this_arrow->next)
	 if (this_arrow->tag == last+1)
	   last++;
	 else
	   break;

    return (last+1);
}

/* delete arrow from linked list started by first_arrow.
 * called with pointers to the previous arrow (prev) and the 
 * arrow to delete (this).
 * If there is no previous arrow (the arrow to delete is
 * first_arrow) then call with prev = NULL.
 */
static void
delete_arrow(prev,this)
	struct arrow_def *prev, *this;
{
    if (this!=NULL)	{		/* there really is something to delete */
	   if (prev!=NULL)		/* there is a previous arrow */
		prev->next = this->next; 
	   else				/* this = first_arrow so change first_arrow */
		first_arrow = this->next;
	   free((char *)this);
    }
}


enum PLOT_STYLE			/* not static; used by command.c */
get_style()
{
register enum PLOT_STYLE ps;

	c_token++;
	if (almost_equals(c_token,"l$ines"))
		ps = LINES;
	else if (almost_equals(c_token,"i$mpulses"))
		ps = IMPULSES;
	else if (almost_equals(c_token,"p$oints"))
		ps = POINTS;
	else if (almost_equals(c_token,"linesp$oints"))
		ps = LINESPOINTS;
	else if (almost_equals(c_token,"d$ots"))
		ps = DOTS;
	else if (almost_equals(c_token,"e$rrorbars"))
		ps = ERRORBARS;
	else
		int_error("expecting 'lines', 'points', 'linespoints', 'dots', 'impulses', or 'errorbars'",c_token);
	c_token++;
	return(ps);
}

/* For set [xy]tics... command*/
static void
load_tics(tdef)
	struct ticdef *tdef;	/* change this ticdef */
{
    if (equals(c_token,"(")) { /* set : TIC_USER */
	   c_token++;
	   load_tic_user(tdef);
    } else {				/* series : TIC_SERIES */
	   load_tic_series(tdef);
    }
}

/* load TIC_USER definition */
/* (tic[,tic]...)
 * where tic is ["string"] value
 * Left paren is already scanned off before entry.
 */
static void
load_tic_user(tdef)
	struct ticdef *tdef;
{
    struct ticmark *list = NULL; /* start of list */
    struct ticmark *last = NULL; /* end of list */
    struct ticmark *tic = NULL; /* new ticmark */
    char temp_string[MAX_LINE_LEN];
    struct value a;

    while (!END_OF_COMMAND) {
	   /* parse a new ticmark */
	   tic = (struct ticmark *)alloc(sizeof(struct ticmark), (char *)NULL);
	   if (tic == (struct ticmark *)NULL) {
		  free_marklist(list);
		  int_error("out of memory for tic mark", c_token);
	   }

	   /* has a string with it? */
	   if (isstring(c_token)) {
		  quote_str(temp_string,c_token);
		  tic->label = alloc((unsigned int)strlen(temp_string)+1, "tic label");
		  (void) strcpy(tic->label, temp_string);
		  c_token++;
	   } else
		tic->label = NULL;

	   /* in any case get the value */
	   tic->position = real(const_express(&a));
	   tic->next = NULL;

	   /* append to list */
	   if (list == NULL)
		last = list = tic;	/* new list */
	   else {				/* append to list */
		  last->next = tic;
		  last = tic;
	   }

	   /* expect "," or ")" here */
	   if (!END_OF_COMMAND && equals(c_token, ","))
		c_token++;		/* loop again */
	   else
		break;			/* hopefully ")" */
    }
    
    if (END_OF_COMMAND || !equals(c_token, ")")) {
	   free_marklist(list);
	   int_error("expecting right parenthesis )", c_token);
    }
    c_token++;
    
    /* successful list */
    if (tdef->type == TIC_USER) {
	   /* remove old list */
		/* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
	   free_marklist(tdef->def.user);
	   tdef->def.user = NULL;
    }
    tdef->type = TIC_USER;
    tdef->def.user = list;
}

static void
free_marklist(list)
	struct ticmark *list;
{
    register struct ticmark *freeable;

    while (list != NULL) {
	   freeable = list;
	   list = list->next;
	   if (freeable->label != NULL)
		free( (char *)freeable->label );
	   free( (char *)freeable );
    }
}

/* load TIC_SERIES definition */
/* start,incr[,end] */
static void
load_tic_series(tdef)
	struct ticdef *tdef;
{
    double start, incr, end;
    struct value a;
    int incr_token;

    start = real(const_express(&a));
    if (!equals(c_token, ","))
	 int_error("expecting comma to separate start,incr", c_token);
    c_token++;

    incr_token = c_token;
    incr = real(const_express(&a));

    if (END_OF_COMMAND)
	 end = VERYLARGE;
    else {
	   if (!equals(c_token, ","))
		int_error("expecting comma to separate incr,end", c_token);
	   c_token++;

	   end = real(const_express(&a));
    }
    if (!END_OF_COMMAND)
	 int_error("tic series is defined by start,increment[,end]", 
			 c_token);
    
    if (start < end && incr <= 0)
	 int_error("increment must be positive", incr_token);
    if (start > end && incr >= 0)
	 int_error("increment must be negative", incr_token);
    if (start > end) {
	   /* put in order */
		double numtics;
		numtics = floor( (end*(1+SIGNIF) - start)/incr );
		end = start;
		start = end + numtics*incr;
		incr = -incr;
/*
	   double temp = start;
	   start = end;
	   end = temp;
	   incr = -incr;
 */
    }

    if (tdef->type == TIC_USER) {
	   /* remove old list */
		/* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
	   free_marklist(tdef->def.user);
	   tdef->def.user = NULL;
    }
    tdef->type = TIC_SERIES;
    tdef->def.series.start = start;
    tdef->def.series.incr = incr;
    tdef->def.series.end = end;
}

static void
load_offsets (a, b, c, d)
double *a,*b, *c, *d;
{
struct value t;

	*a = real (const_express(&t));  /* loff value */
	c_token++;
	if (equals(c_token,","))
		c_token++;
	if (END_OF_COMMAND) 
	    return;

	*b = real (const_express(&t));  /* roff value */
	c_token++;
	if (equals(c_token,","))
		c_token++;
	if (END_OF_COMMAND) 
	    return;

	*c = real (const_express(&t));  /* toff value */
	c_token++;
	if (equals(c_token,","))
		c_token++;
	if (END_OF_COMMAND) 
	    return;

	*d = real (const_express(&t));  /* boff value */
	c_token++;
}


BOOLEAN					/* TRUE if a or b were changed */
load_range(a,b)			/* also used by command.c */
double *a,*b;
{
struct value t;
BOOLEAN changed = FALSE;

	if (equals(c_token,"]"))
		return(FALSE);
	if (END_OF_COMMAND) {
	    int_error("starting range value or ':' or 'to' expected",c_token);
	} else if (!equals(c_token,"to") && !equals(c_token,":"))  {
		*a = real(const_express(&t));
		changed = TRUE;
	}	
	if (!equals(c_token,"to") && !equals(c_token,":"))
		int_error("':' or keyword 'to' expected",c_token);
	c_token++;
	if (!equals(c_token,"]")) {
		*b = real(const_express(&t));
		changed = TRUE;
	 }
     return(changed);
}



/******* The 'show' command *******/
void
show_command()
{
    c_token++;

    if (!show_one() && !show_two())
	int_error(
	"valid show options:  'action_table', 'all', 'angles', 'arrow', \n\
	'autoscale', 'border', 'clip', 'contour', 'data', 'dummy', 'format', \n\
	'function', 'grid', 'hidden', 'key', 'label', 'logscale', 'mapping', \n\
	'offsets', 'output', 'plot', 'parametric', 'polar', 'rrange', \n\
	'samples', 'isosamples', 'view', 'size', 'terminal', 'tics', \n\
	'ticslevel', 'time', 'title', 'trange', 'urange', 'vrange', \n\
	'variables', 'version', 'xlabel', 'xrange', 'xtics', 'xzeroaxis', \n\
	'ylabel', 'yrange', 'ytics', 'yzeroaxis', 'zlabel', 'zrange', \n\
	'ztics', 'zero', 'zeroaxis'", c_token);
	screen_ok = FALSE;
	(void) putc('\n',stderr);
}

/* return TRUE if a command match, FALSE if not */
static BOOLEAN
show_one()
{
	if (almost_equals(c_token,"ac$tion_table") ||
			 equals(c_token,"at") ) {
		c_token++; 
		show_at();
		c_token++;
	}
	else if (almost_equals(c_token,"ar$row")) {
	    struct value a;
	    int tag = 0;

	    c_token++;
	    if (!END_OF_COMMAND) {
		   tag = (int)real(const_express(&a));
		   if (tag <= 0)
			int_error("tag must be > zero", c_token);
	    }

	    (void) putc('\n',stderr);
	    show_arrow(tag);
	}
	else if (almost_equals(c_token,"au$toscale")) {
		(void) putc('\n',stderr);
		show_autoscale();
		c_token++;
	}
	else if (almost_equals(c_token,"bor$der")) {
		(void) putc('\n',stderr);
		show_border();
		c_token++;
	}
	else if (almost_equals(c_token,"c$lip")) {
		(void) putc('\n',stderr);
		show_clip();
		c_token++;
	}
	else if (almost_equals(c_token,"ma$pping")) {
		(void) putc('\n',stderr);
		show_mapping();
		c_token++;
	}
	else if (almost_equals(c_token,"co$ntour")) {
		(void) putc('\n',stderr);
		show_contour();
		c_token++;
	}
	else if (almost_equals(c_token,"d$ata")) {
		c_token++;
		if (!almost_equals(c_token,"s$tyle"))
			int_error("expecting keyword 'style'",c_token);
		(void) putc('\n',stderr);
		show_style("data",data_style);
		c_token++;
	}
	else if (almost_equals(c_token,"d$ummy")) {
	  	(void) fprintf(stderr,"\n\tdummy variables are \"%s\" and \"%s\"\n",
	    				dummy_var[0], dummy_var[1]);
		c_token++;
	}
	else if (almost_equals(c_token,"fo$rmat")) {
		show_format();
		c_token++;
	}
	else if (almost_equals(c_token,"f$unctions")) {
		c_token++;
		if (almost_equals(c_token,"s$tyle"))  {
			(void) putc('\n',stderr);
			show_style("functions",func_style);
			c_token++;
		}
		else
			show_functions();
	}
	else if (almost_equals(c_token,"lo$gscale")) {
		(void) putc('\n',stderr);
		show_logscale();
		c_token++;
	}
	else if (almost_equals(c_token,"of$fsets")) {
		(void) putc('\n',stderr);
		show_offsets();
		c_token++;
	}
	else if (almost_equals(c_token,"o$utput")) {
		(void) putc('\n',stderr);
		show_output();
		c_token++;
	}
	else if (almost_equals(c_token,"tit$le")) {
		(void) putc('\n',stderr);
		show_title();
		c_token++;
	}
	else if (almost_equals(c_token,"xl$abel")) {
		(void) putc('\n',stderr);
		show_xlabel();
		c_token++;
	}
	else if (almost_equals(c_token,"yl$abel")) {
		(void) putc('\n',stderr);
		show_ylabel();
		c_token++;
	}
	else if (almost_equals(c_token,"zl$abel")) {
		(void) putc('\n',stderr);
		show_zlabel();
		c_token++;
	}
	else if (almost_equals(c_token,"xzero$axis")) {
		(void) putc('\n',stderr);
		show_xzeroaxis();
		c_token++;
	}
	else if (almost_equals(c_token,"yzero$axis")) {
		(void) putc('\n',stderr);
		show_yzeroaxis();
		c_token++;
	}
	else if (almost_equals(c_token,"zeroa$xis")) {
		(void) putc('\n',stderr);
		show_xzeroaxis();
		show_yzeroaxis();
		c_token++;
	}
	else if (almost_equals(c_token,"la$bel")) {
	    struct value a;
	    int tag = 0;

	    c_token++;
	    if (!END_OF_COMMAND) {
		   tag = (int)real(const_express(&a));
		   if (tag <= 0)
			int_error("tag must be > zero", c_token);
	    }

	    (void) putc('\n',stderr);
	    show_label(tag);
	}
	else if (almost_equals(c_token,"g$rid")) {
		(void) putc('\n',stderr);
		show_grid();
		c_token++;
	}
	else if (almost_equals(c_token,"k$ey")) {
		(void) putc('\n',stderr);
		show_key();
		c_token++;
	}
	else
		return (FALSE);
	return TRUE;
}

/* return TRUE if a command match, FALSE if not */
static BOOLEAN
show_two()
{
	if (almost_equals(c_token,"p$lot")) {
		(void) putc('\n',stderr);
		show_plot();
		c_token++;
	}
	else if (almost_equals(c_token,"par$ametric")) {
		(void) putc('\n',stderr);
		show_parametric();
		c_token++;
	}
	else if (almost_equals(c_token,"pol$ar")) {
		(void) putc('\n',stderr);
		show_polar();
		c_token++;
	}
	else if (almost_equals(c_token,"an$gles")) {
		(void) putc('\n',stderr);
		show_angles();
		c_token++;
	}
	else if (almost_equals(c_token,"ti$cs")) {
		(void) putc('\n',stderr);
		show_tics(TRUE,TRUE,TRUE);
		c_token++;
	}
	else if (almost_equals(c_token,"tim$e")) {
		(void) putc('\n',stderr);
		show_time();
		c_token++;
	}
	else if (almost_equals(c_token,"su$rface")) {
		(void) putc('\n',stderr);
		show_surface();
		c_token++;
	}
	else if (almost_equals(c_token,"hi$dden3d")) {
		(void) putc('\n',stderr);
		show_hidden3d();
		c_token++;
	}
	else if (almost_equals(c_token,"xti$cs")) {
	    show_tics(TRUE,FALSE,FALSE);
	    c_token++;
	}
	else if (almost_equals(c_token,"yti$cs")) {
	    show_tics(FALSE,TRUE,FALSE);
	    c_token++;
	}
	else if (almost_equals(c_token,"zti$cs")) {
	    show_tics(FALSE,FALSE,TRUE);
	    c_token++;
	}
	else if (almost_equals(c_token,"sa$mples")) {
		(void) putc('\n',stderr);
		show_samples();
		c_token++;
	}
	else if (almost_equals(c_token,"isosa$mples")) {
		(void) putc('\n',stderr);
		show_isosamples();
		c_token++;
	}
	else if (almost_equals(c_token,"si$ze")) {
		(void) putc('\n',stderr);
		show_size();
		c_token++;
	}
	else if (almost_equals(c_token,"t$erminal")) {
		(void) putc('\n',stderr);
		show_term();
		c_token++;
	}
	else if (almost_equals(c_token,"rr$ange")) {
		(void) putc('\n',stderr);
		show_range('r',rmin,rmax);
		c_token++;
	}
	else if (almost_equals(c_token,"tr$ange")) {
		(void) putc('\n',stderr);
		show_range('t',tmin,tmax);
		c_token++;
	}
	else if (almost_equals(c_token,"ur$ange")) {
		(void) putc('\n',stderr);
		show_range('u',umin,umax);
		c_token++;
	}
	else if (almost_equals(c_token,"vi$ew")) {
		(void) putc('\n',stderr);
		show_view();
		c_token++;
	}
	else if (almost_equals(c_token,"vr$ange")) {
		(void) putc('\n',stderr);
		show_range('v',vmin,vmax);
		c_token++;
	}
	else if (almost_equals(c_token,"v$ariables")) {
		show_variables();
		c_token++;
	}
	else if (almost_equals(c_token,"ve$rsion")) {
		show_version();
		c_token++;
	}
	else if (almost_equals(c_token,"xr$ange")) {
		(void) putc('\n',stderr);
		show_range('x',xmin,xmax);
		c_token++;
	}
	else if (almost_equals(c_token,"yr$ange")) {
		(void) putc('\n',stderr);
		show_range('y',ymin,ymax);
		c_token++;
	}
	else if (almost_equals(c_token,"zr$ange")) {
		(void) putc('\n',stderr);
		show_range('z',zmin,zmax);
		c_token++;
	}
	else if (almost_equals(c_token,"z$ero")) {
		(void) putc('\n',stderr);
		show_zero();
		c_token++;
	}
	else if (almost_equals(c_token,"a$ll")) {
		c_token++;
		show_version();
		show_autoscale();
		show_border();
		show_clip();
		show_contour();
		show_mapping();
	  	(void) fprintf(stderr,"\tdummy variables are \"%s\" and \"%s\"\n",
	    				dummy_var[0], dummy_var[1]);
		show_format();
		show_style("data",data_style);
		show_style("functions",func_style);
		show_grid();
		show_label(0);
		show_arrow(0);
		show_key();
		show_logscale();
		show_offsets();
		show_output();
		show_parametric();
		show_polar();
		show_angles();
		show_samples();
		show_isosamples();
		show_view();
		show_surface();
		show_hidden3d();
		show_size();
		show_term();
		show_tics(TRUE,TRUE,TRUE);
		show_time();
		if (parametric)
			if (!is_3d_plot)
				show_range('t',tmin,tmax);
			else {
				show_range('u',umin,umax);
				show_range('v',vmin,vmax);
			}
		if (polar)
		  show_range('r',rmin,rmax);
		show_range('x',xmin,xmax);
		show_range('y',ymin,ymax);
		show_range('z',zmin,zmax);
		show_title();
		show_xlabel();
		show_ylabel();
		show_zlabel();
		show_zero();
		show_plot();
		show_variables();
		show_functions();
		c_token++;
	}
	else
		return (FALSE);
	return (TRUE);
}


/*********** support functions for 'show'  **********/
static void
show_style(name,style)
char name[];
enum PLOT_STYLE style;
{
	fprintf(stderr,"\t%s are plotted with ",name);
	switch (style) {
		case LINES: fprintf(stderr,"lines\n"); break;
		case POINTS: fprintf(stderr,"points\n"); break;
		case IMPULSES: fprintf(stderr,"impulses\n"); break;
		case LINESPOINTS: fprintf(stderr,"linespoints\n"); break;
		case DOTS: fprintf(stderr,"dots\n"); break;
		case ERRORBARS: fprintf(stderr,"errorbars\n"); break;
	}
}

static void
show_range(name,min,max)
char name;
double min,max;
{
	fprintf(stderr,"\t%crange is [%g : %g]\n",name,min,max);
}

static void
show_zero()
{
	fprintf(stderr,"\tzero is %g\n",zero);
}

static void
show_offsets()
{
	fprintf(stderr,"\toffsets are %g, %g, %g, %g\n",loff,roff,toff,boff);
}

static void
show_border()
{
	fprintf(stderr,"\tborder is %sdrawn\n", draw_border ? "" : "not ");
}

static void
show_output()
{
	fprintf(stderr,"\toutput is sent to %s\n",outstr);
}

static void
show_samples()
{
	fprintf(stderr,"\tsampling rate is %d\n",samples);
}

static void
show_isosamples()
{
	fprintf(stderr,"\tiso sampling rate is %d\n",iso_samples);
}

static void
show_surface()
{
	fprintf(stderr,"\tsurface is %sdrawn\n", draw_surface ? "" : "not ");
}

static void
show_hidden3d()
{
	fprintf(stderr,"\thidden surface is %s\n", hidden3d ? "removed" : "drawn");
}

static void
show_view()
{
	fprintf(stderr,"\tview is %g rot_x, %g rot_z, %g scale, %g scale_z\n",
		surface_rot_x, surface_rot_z, surface_scale, surface_zscale);
}

static void
show_size()
{
	fprintf(stderr,"\tsize is scaled by %g,%g\n",xsize,ysize);
}

static void
show_title()
{
	fprintf(stderr,"\ttitle is \"%s\", offset at %d, %d\n",
		title,title_xoffset,title_yoffset);
}

static void
show_xlabel()
{
	fprintf(stderr,"\txlabel is \"%s\", offset at %d, %d\n",
		xlabel,xlabel_xoffset,xlabel_yoffset);
}

static void
show_ylabel()
{
	fprintf(stderr,"\tylabel is \"%s\", offset at %d, %d\n",
		ylabel,ylabel_xoffset,ylabel_yoffset);
}
static void
show_zlabel()
{
	fprintf(stderr,"\tzlabel is \"%s\", offset at %d, %d\n",
		zlabel,zlabel_xoffset,zlabel_yoffset);
}

static void
show_xzeroaxis()
{
	fprintf(stderr,"\txzeroaxis is %s\n",(xzeroaxis)? "ON" : "OFF");
}

static void
show_yzeroaxis()
{
	fprintf(stderr,"\tyzeroaxis is %s\n",(yzeroaxis)? "ON" : "OFF");
}

static void
show_label(tag)
    int tag;				/* 0 means show all */
{
    struct text_label *this_label;
    BOOLEAN showed = FALSE;

    for (this_label = first_label; this_label != NULL;
	    this_label = this_label->next) {
	   if (tag == 0 || tag == this_label->tag) {
		  showed = TRUE;
		  fprintf(stderr,"\tlabel %d \"%s\" at %g,%g,%g ",
				this_label->tag, this_label->text, 
				this_label->x, this_label->y, this_label->z);
		  switch(this_label->pos) {
			 case LEFT : {
				fprintf(stderr,"left");
				break;
			 }
			 case CENTRE : {
				fprintf(stderr,"centre");
				break;
			 }
			 case RIGHT : {
				fprintf(stderr,"right");
				break;
			 }
		  }
		  fputc('\n',stderr);
	   }
    }
    if (tag > 0 && !showed)
	 int_error("label not found", c_token);
}

static void
show_arrow(tag)
    int tag;				/* 0 means show all */
{
    struct arrow_def *this_arrow;
    BOOLEAN showed = FALSE;

    for (this_arrow = first_arrow; this_arrow != NULL;
	    this_arrow = this_arrow->next) {
	   if (tag == 0 || tag == this_arrow->tag) {
		  showed = TRUE;
		  fprintf(stderr,"\tarrow %d from %g,%g,%g to %g,%g,%g%s\n",
				this_arrow->tag, 
				this_arrow->sx, this_arrow->sy, this_arrow->sz,
				this_arrow->ex, this_arrow->ey, this_arrow->ez,
				this_arrow->head ? "" : " (nohead)");
	   }
    }
    if (tag > 0 && !showed)
	 int_error("arrow not found", c_token);
}

static void
show_grid()
{
	fprintf(stderr,"\tgrid is %s\n",(grid)? "ON" : "OFF");
}

static void
show_key()
{
	switch (key) {
		case -1 : 
			fprintf(stderr,"\tkey is ON\n");
			break;
		case 0 :
			fprintf(stderr,"\tkey is OFF\n");
			break;
		case 1 :
			fprintf(stderr,"\tkey is at %g,%g,%g\n",key_x,key_y,key_z);
			break;
	}
}

static void
show_parametric()
{
	fprintf(stderr,"\tparametric is %s\n",(parametric)? "ON" : "OFF");
}

static void
show_polar()
{
	fprintf(stderr,"\tpolar is %s\n",(polar)? "ON" : "OFF");
}

static void
show_angles()
{
	fprintf(stderr,"\tAngles are in ");
	switch (angles_format) {
	    case ANGLES_RADIANS:
	        fprintf(stderr, "radians\n");
		break;
	    case ANGLES_DEGREES:
	        fprintf(stderr, "degrees\n");
		break;
	}
}


static void
show_tics(showx, showy, showz)
	BOOLEAN showx, showy, showz;
{
    fprintf(stderr,"\ttics are %s, ",(tic_in)? "IN" : "OUT");
    fprintf(stderr,"\tticslevel is %g\n",ticslevel);

    if (showx)
	 show_ticdef(xtics, 'x', &xticdef);
    if (showy)
	 show_ticdef(ytics, 'y', &yticdef);
    if (showz)
	 show_ticdef(ztics, 'z', &zticdef);
    screen_ok = FALSE;
}

/* called by show_tics */
static void
show_ticdef(tics, axis, tdef)
	BOOLEAN tics;			/* xtics ytics or ztics */
	char axis;			/* 'x' 'y' or 'z' */
	struct ticdef *tdef;	/* xticdef yticdef or zticdef */
{
    register struct ticmark *t;

    fprintf(stderr, "\t%c-axis tic labelling is ", axis);
    if (!tics) {
	   fprintf(stderr, "OFF\n");
	   return;
    }

    switch(tdef->type) {
	   case TIC_COMPUTED: {
		  fprintf(stderr, "computed automatically\n");
		  break;
	   }
	   case TIC_SERIES: {
		  if (tdef->def.series.end == VERYLARGE)
		    fprintf(stderr, "series from %g by %g\n", 
				  tdef->def.series.start, tdef->def.series.incr);
		  else
		    fprintf(stderr, "series from %g by %g until %g\n", 
				  tdef->def.series.start, tdef->def.series.incr, 
				  tdef->def.series.end);
		  break;
	   }
	   case TIC_USER: {
		  fprintf(stderr, "list (");
		  for (t = tdef->def.user; t != NULL; t=t->next) {
			 if (t->label)
			   fprintf(stderr, "\"%s\" ", t->label);
			 if (t->next)
			   fprintf(stderr, "%g, ", t->position);
			 else
			   fprintf(stderr, "%g", t->position);
		  }
		  fprintf(stderr, ")\n");
		  break;
	   }
	   default: {
		  int_error("unknown ticdef type in show_ticdef()", NO_CARET);
		  /* NOTREACHED */
	   }
    }
}

static void
show_time()
{
	fprintf(stderr,"\ttime is %s, offset at %d, %d\n",
		(timedate)? "ON" : "OFF",
		time_xoffset,time_yoffset);
}

static void
show_term()
{
	char *str;

	fprintf(stderr,"\tterminal type is %s %s\n",
		term_tbl[term].name, term_options);
}

static void
show_plot()
{
	fprintf(stderr,"\tlast plot command was: %s\n",replot_line);
}

static void
show_autoscale()
{
	fprintf(stderr,"\tautoscaling is ");
	if (parametric)
		if (is_3d_plot)
			fprintf(stderr,"\tt: %s, ",(autoscale_t)? "ON" : "OFF");
		else
			fprintf(stderr,"\tu: %s, v: %s, ",
						(autoscale_u)? "ON" : "OFF",
						(autoscale_v)? "ON" : "OFF");
	else fprintf(stderr,"\t");

	if (polar) fprintf(stderr,"r: %s, ",(autoscale_r)? "ON" : "OFF");
	fprintf(stderr,"x: %s, ",(autoscale_x)? "ON" : "OFF");
	fprintf(stderr,"y: %s, ",(autoscale_y)? "ON" : "OFF");
	fprintf(stderr,"z: %s\n",(autoscale_z)? "ON" : "OFF");
}

static void
show_clip()
{
	fprintf(stderr,"\tpoint clip is %s\n",(clip_points)? "ON" : "OFF");

	if (clip_lines1)
	  fprintf(stderr,
         "\tdrawing and clipping lines between inrange and outrange points\n");
	else
	  fprintf(stderr,
         "\tnot drawing lines between inrange and outrange points\n");

	if (clip_lines2)
	  fprintf(stderr,
         "\tdrawing and clipping lines between two outrange points\n");
	else
	  fprintf(stderr,
         "\tnot drawing lines between two outrange points\n");
}

static void
show_mapping()
{
	fprintf(stderr,"\tmapping for 3-d data is ");

	switch (mapping3d) {
		case MAP3D_CARTESIAN:
			fprintf(stderr,"cartesian\n");
			break;
		case MAP3D_SPHERICAL:
			fprintf(stderr,"spherical\n");
			break;
		case MAP3D_CYLINDRICAL:
			fprintf(stderr,"cylindrical\n");
			break;
	}
}

static void
show_contour()
{
	fprintf(stderr,"\tcontour for surfaces are %s",
		(draw_contour)? "drawn" : "not drawn\n");

	if (draw_contour) {
	        fprintf(stderr, " in %d levels on ", contour_levels);
		switch (draw_contour) {
			case CONTOUR_BASE:
				fprintf(stderr,"grid base\n");
				break;
			case CONTOUR_SRF:
				fprintf(stderr,"surface\n");
				break;
			case CONTOUR_BOTH:
				fprintf(stderr,"grid base and surface\n");
				break;
		}
		switch (contour_kind) {
			case CONTOUR_KIND_LINEAR:
				fprintf(stderr,"\t\tas linear segments\n");
				break;
			case CONTOUR_KIND_CUBIC_SPL:
				fprintf(stderr,"\t\tas cubic spline interpolation segments with %d pts\n",
					contour_pts);
				break;
			case CONTOUR_KIND_BSPLINE:
				fprintf(stderr,"\t\tas bspline approximation segments of order %d with %d pts\n",
					contour_order, contour_pts);
				break;
		}
	}
}

static void
show_format()
{
	fprintf(stderr, "\ttic format is x-axis: \"%s\", y-axis: \"%s\", z-axis: \"%s\"\n",
		xformat, yformat, zformat);
}

static void
show_logscale()
{
	char *p;

	if (log_x && log_y && log_z)
		fprintf(stderr,"\tlogscaling all x, y and z axes\n");
	else {
		p = (log_x && log_y)			  /* Look for pairs. */
			 ? "x and y"
			 :  (log_x && log_z)
			         ? "x and z"
			         :  (log_y && log_z)
					 ? "y and z"
					 : NULL;
		if (p != NULL)
			fprintf(stderr,"\tlogscaling both %s axes\n",p);
		else {
			if (log_x)
				fprintf(stderr,"\tlogscaling x axis\n");
			if (log_y)
				fprintf(stderr,"\tlogscaling y axis\n");
			if (log_z)
				fprintf(stderr,"\tlogscaling z axis\n");
			if (!(log_x || log_y || log_z))
				fprintf(stderr,"\tno logscaling\n");
		}
	}
}

static void
show_variables()
{
register struct udvt_entry *udv = first_udv;
int len;

	fprintf(stderr,"\n\tVariables:\n");
	while (udv) {
	     len = instring(udv->udv_name, ' ');
		fprintf(stderr,"\t%-*s ",len,udv->udv_name);
		if (udv->udv_undef)
			fputs("is undefined\n",stderr);
		else {
			fputs("= ",stderr);
			disp_value(stderr,&(udv->udv_value));
			(void) putc('\n',stderr);
		}
		udv = udv->next_udv;
	}
}

void				/* used by plot.c */
show_version()
{
extern char version[];
extern char patchlevel[];
extern char date[];
extern char bug_email[];
static char *authors[] = {"Thomas Williams","Colin Kelley"}; /* primary */
int x;
long time();

	x = time((long *)NULL) & 1;
	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,"\nCopyright(C) 1986, 1987, 1990, 1991, 1992  %s, %s\n",
		authors[x],authors[1-x]);
    fprintf(stderr, "\n\tSend bugs and comments to %s\n", bug_email);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/setshow.h version [fbad1c61be].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * $Id: setshow.h,v 3.26 92/03/24 22:34:15 woo Exp Locker: woo $
 *
 */

/* GNUPLOT - setshow.h */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

/*
 * global variables to hold status of 'set' options
 *
 */
extern BOOLEAN			autoscale_r;
extern BOOLEAN			autoscale_t;
extern BOOLEAN			autoscale_u;
extern BOOLEAN			autoscale_v;
extern BOOLEAN			autoscale_x;
extern BOOLEAN			autoscale_y;
extern BOOLEAN			autoscale_z;
extern BOOLEAN			autoscale_lt;
extern BOOLEAN			autoscale_lu;
extern BOOLEAN			autoscale_lv;
extern BOOLEAN			autoscale_lx;
extern BOOLEAN			autoscale_ly;
extern BOOLEAN			autoscale_lz;
extern BOOLEAN			clip_points;
extern BOOLEAN			clip_lines1;
extern BOOLEAN			clip_lines2;
extern BOOLEAN			draw_border;
extern BOOLEAN			draw_surface;
extern BOOLEAN			timedate;
extern char			dummy_var[MAX_NUM_VAR][MAX_ID_LEN+1];
extern char			xformat[];
extern char			yformat[];
extern char			zformat[];
extern enum PLOT_STYLE data_style, func_style;
extern BOOLEAN			grid;
extern int			key;
extern double			key_x, key_y, key_z; /* user specified position for key */
extern BOOLEAN			log_x, log_y, log_z;
extern FILE*			outfile;
extern char			outstr[];
extern BOOLEAN			parametric;
extern BOOLEAN			polar;
extern BOOLEAN			hidden3d;
extern int			angles_format;
extern int			mapping3d;
extern int			samples;
extern int			iso_samples;
extern float			xsize; /* scale factor for size */
extern float			ysize; /* scale factor for size */
extern float			zsize; /* scale factor for size */
extern float			surface_rot_z;
extern float			surface_rot_x;
extern float			surface_scale;
extern float			surface_zscale;
extern int			term; /* unknown term is 0 */
extern char			term_options[];
extern char			title[];
extern char			xlabel[];
extern char			ylabel[];
extern char			zlabel[];
extern int			time_xoffset;
extern int			time_yoffset;
extern int			title_xoffset;
extern int			title_yoffset;
extern int			xlabel_xoffset;
extern int			xlabel_yoffset;
extern int			ylabel_xoffset;
extern int			ylabel_yoffset;
extern int			zlabel_xoffset;
extern int			zlabel_yoffset;
extern double			rmin, rmax;
extern double			tmin, tmax, umin, umax, vmin, vmax;
extern double			xmin, xmax, ymin, ymax, zmin, zmax;
extern double			loff, roff, toff, boff;
extern int			draw_contour;
extern int			contour_pts;
extern int			contour_kind;
extern int			contour_order;
extern int			contour_levels;
extern double			zero; /* zero threshold, not 0! */

extern BOOLEAN xzeroaxis;
extern BOOLEAN yzeroaxis;

extern BOOLEAN xtics;
extern BOOLEAN ytics;
extern BOOLEAN ztics;

extern float ticslevel;

extern struct ticdef xticdef;
extern struct ticdef yticdef;
extern struct ticdef zticdef;

extern BOOLEAN			tic_in;

extern struct text_label *first_label;
extern struct arrow_def *first_arrow;

/* The set and show commands, in setshow.c */
extern void set_command();
extern void show_command();
/* and some accessible support functions */
extern enum PLOT_STYLE get_style();
extern BOOLEAN load_range();
extern void show_version();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































Deleted r34.1/plot/standard.c version [fd140f6ddd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
#ifndef lint
static char *RCSid = "$Id: standard.c,v 3.26 92/03/24 22:34:37 woo Exp Locker: woo $";
#endif

/* GNUPLOT - standard.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <math.h>
#include <stdio.h>
#include "plot.h"

#ifdef vms
#include <errno.h>
#else
extern int errno;
#endif /* vms */


extern struct value stack[STACK_DEPTH];
extern int s_p;
extern double zero;

struct value *pop(), *complex(), *integer();

double magnitude(), angle(), real(), imag();

/* The bessel function approximations here are from
 * "Computer Approximations"
 * by Hart, Cheney et al.
 * John Wiley & Sons, 1968
 */

/* There appears to be a mistake in Hart, Cheney et al. on page 149.
 * Where it list Qn(x)/x ~ P(z*z)/Q(z*z), z = 8/x, it should read
 *               Qn(x)/z ~ P(z*z)/Q(z*z), z = 8/x
 * In the functions below, Qn(x) is implementated using the later
 * equation.
 * These bessel functions are accurate to about 1e-13
 */

#define PI_ON_FOUR       0.78539816339744830961566084581987572
#define PI_ON_TWO        1.57079632679489661923131269163975144
#define THREE_PI_ON_FOUR 2.35619449019234492884698253745962716
#define TWO_ON_PI        0.63661977236758134307553505349005744

static double dzero = 0.0;

/* jzero for x in [0,8]
 * Index 5849, 19.22 digits precision
 */
static double pjzero[] = {
	 0.4933787251794133561816813446e+21,
	-0.11791576291076105360384408e+21,
	 0.6382059341072356562289432465e+19,
	-0.1367620353088171386865416609e+18,
	 0.1434354939140346111664316553e+16,
	-0.8085222034853793871199468171e+13,
	 0.2507158285536881945555156435e+11,
	-0.4050412371833132706360663322e+8,
	 0.2685786856980014981415848441e+5
};

static double qjzero[] = {
	0.4933787251794133562113278438e+21,
	0.5428918384092285160200195092e+19,
	0.3024635616709462698627330784e+17,
	0.1127756739679798507056031594e+15,
	0.3123043114941213172572469442e+12,
	0.669998767298223967181402866e+9,
	0.1114636098462985378182402543e+7,
	0.1363063652328970604442810507e+4,
	0.1e+1
};

/* pzero for x in [8,inf]
 * Index 6548, 18.16 digits precision
 */
static double ppzero[] = {
	0.2277909019730468430227002627e+5,
	0.4134538663958076579678016384e+5,
	0.2117052338086494432193395727e+5,
	0.348064864432492703474453111e+4,
	0.15376201909008354295771715e+3,
	0.889615484242104552360748e+0
};

static double qpzero[] = {
	0.2277909019730468431768423768e+5,
	0.4137041249551041663989198384e+5,
	0.2121535056188011573042256764e+5,
	0.350287351382356082073561423e+4,
	0.15711159858080893649068482e+3,
	0.1e+1
};

/* qzero for x in [8,inf]
 * Index 6948, 18.33 digits precision
 */
static double pqzero[] = {
	-0.8922660020080009409846916e+2,
	-0.18591953644342993800252169e+3,
	-0.11183429920482737611262123e+3,
	-0.2230026166621419847169915e+2,
	-0.124410267458356384591379e+1,
	-0.8803330304868075181663e-2,
};

static double qqzero[] = {
	0.571050241285120619052476459e+4,
	0.1195113154343461364695265329e+5,
	0.726427801692110188369134506e+4,
	0.148872312322837565816134698e+4,
	0.9059376959499312585881878e+2,
	0.1e+1
};


/* yzero for x in [0,8]
 * Index 6245, 18.78 digits precision
 */
static double pyzero[] = {
	-0.2750286678629109583701933175e+20,
	 0.6587473275719554925999402049e+20,
	-0.5247065581112764941297350814e+19,
	 0.1375624316399344078571335453e+18,
	-0.1648605817185729473122082537e+16,
	 0.1025520859686394284509167421e+14,
	-0.3436371222979040378171030138e+11,
	 0.5915213465686889654273830069e+8,
	-0.4137035497933148554125235152e+5
};

static double qyzero[] = {
	0.3726458838986165881989980739e+21,
	0.4192417043410839973904769661e+19,
	0.2392883043499781857439356652e+17,
	0.9162038034075185262489147968e+14,
	0.2613065755041081249568482092e+12,
	0.5795122640700729537380087915e+9,
	0.1001702641288906265666651753e+7,
	0.1282452772478993804176329391e+4,
	0.1e+1
};


/* jone for x in [0,8]
 * Index 6050, 20.98 digits precision
 */
static double pjone[] = {
	 0.581199354001606143928050809e+21,
	-0.6672106568924916298020941484e+20,
	 0.2316433580634002297931815435e+19,
	-0.3588817569910106050743641413e+17,
	 0.2908795263834775409737601689e+15,
	-0.1322983480332126453125473247e+13,
	 0.3413234182301700539091292655e+10,
	-0.4695753530642995859767162166e+7,
	 0.270112271089232341485679099e+4
};

static double qjone[] = {
	0.11623987080032122878585294e+22,
	0.1185770712190320999837113348e+20,
	0.6092061398917521746105196863e+17,
	0.2081661221307607351240184229e+15,
	0.5243710262167649715406728642e+12,
	0.1013863514358673989967045588e+10,
	0.1501793594998585505921097578e+7,
	0.1606931573481487801970916749e+4,
	0.1e+1
};


/* pone for x in [8,inf]
 * Index 6749, 18.11 digits precision
 */
static double ppone[] = {
	0.352246649133679798341724373e+5,
	0.62758845247161281269005675e+5,
	0.313539631109159574238669888e+5,
	0.49854832060594338434500455e+4,
	0.2111529182853962382105718e+3,
	0.12571716929145341558495e+1
};

static double qpone[] = {
	0.352246649133679798068390431e+5,
	0.626943469593560511888833731e+5,
	0.312404063819041039923015703e+5,
	0.4930396490181088979386097e+4,
	0.2030775189134759322293574e+3,
	0.1e+1
};

/* qone for x in [8,inf]
 * Index 7149, 18.28 digits precision
 */
static double pqone[] = {
	0.3511751914303552822533318e+3,
	0.7210391804904475039280863e+3,
	0.4259873011654442389886993e+3,
	0.831898957673850827325226e+2,
	0.45681716295512267064405e+1,
	0.3532840052740123642735e-1
};

static double qqone[] = {
	0.74917374171809127714519505e+4,
	0.154141773392650970499848051e+5,
	0.91522317015169922705904727e+4,
	0.18111867005523513506724158e+4,
	0.1038187585462133728776636e+3,
	0.1e+1
};


/* yone for x in [0,8]
 * Index 6444, 18.24 digits precision
 */
static double pyone[] = {
	-0.2923821961532962543101048748e+20,
	 0.7748520682186839645088094202e+19,
	-0.3441048063084114446185461344e+18,
	 0.5915160760490070618496315281e+16,
	-0.4863316942567175074828129117e+14,
	 0.2049696673745662182619800495e+12,
	-0.4289471968855248801821819588e+9,
	 0.3556924009830526056691325215e+6
};

static double qyone[] = {
	0.1491311511302920350174081355e+21,
	0.1818662841706134986885065935e+19,
	0.113163938269888452690508283e+17,
	0.4755173588888137713092774006e+14,
	0.1500221699156708987166369115e+12,
	0.3716660798621930285596927703e+9,
	0.726914730719888456980191315e+6,
	0.10726961437789255233221267e+4,
	0.1e+1
};


f_real()
{
struct value a;
	push( complex(&a,real(pop(&a)), 0.0) );
}

f_imag()
{
struct value a;
	push( complex(&a,imag(pop(&a)), 0.0) );
}

f_arg()
{
struct value a;
	push( complex(&a,angle(pop(&a)), 0.0) );
}

f_conjg()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,real(&a),-imag(&a) ));
}

f_sin()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,sin(real(&a))*cosh(imag(&a)), cos(real(&a))*sinh(imag(&a))) );
}

f_cos()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,cos(real(&a))*cosh(imag(&a)), -sin(real(&a))*sinh(imag(&a))));
}

f_tan()
{
struct value a;
register double den;
	(void) pop(&a);
	if (imag(&a) == 0.0)
		push( complex(&a,tan(real(&a)),0.0) );
	else {
		den = cos(2*real(&a))+cosh(2*imag(&a));
		if (den == 0.0) {
			undefined = TRUE;
			push( &a );
		}
		else
			push( complex(&a,sin(2*real(&a))/den, sinh(2*imag(&a))/den) );
	}
}

f_asin()
{
struct value a;
register double alpha, beta, x, y;
	(void) pop(&a);
	x = real(&a); y = imag(&a);
	if (y == 0.0) {
		if (fabs(x) > 1.0) {
			undefined = TRUE;
			push(complex(&a,0.0, 0.0));
		} else
			push( complex(&a,asin(x),0.0) );
	} else {
		beta  = sqrt((x + 1)*(x + 1) + y*y)/2 - sqrt((x - 1)*(x - 1) + y*y)/2;
		alpha = sqrt((x + 1)*(x + 1) + y*y)/2 + sqrt((x - 1)*(x - 1) + y*y)/2;
		push( complex(&a,asin(beta), log(alpha + sqrt(alpha*alpha-1))) );
	}
}

f_acos()
{
struct value a;
register double alpha, beta, x, y;
	(void) pop(&a);
	x = real(&a); y = imag(&a);
	if (y == 0.0) {
		if (fabs(x) > 1.0) {
			undefined = TRUE;
			push(complex(&a,0.0, 0.0));
		} else
			push( complex(&a,acos(x),0.0) );
	} else {
		alpha = sqrt((x + 1)*(x + 1) + y*y)/2 + sqrt((x - 1)*(x - 1) + y*y)/2;
		beta  = sqrt((x + 1)*(x + 1) + y*y)/2 - sqrt((x - 1)*(x - 1) + y*y)/2;
		push( complex(&a,acos(beta), log(alpha + sqrt(alpha*alpha-1))) );
	}
}

f_atan()
{
struct value a;
register double x, y, u, v, w, z;
	(void) pop(&a);
	x = real(&a); y = imag(&a);
	if (y == 0.0)
		push( complex(&a,atan(x), 0.0) );
	else if (x == 0.0 && fabs(y) == 1.0) {
		undefined = TRUE;
		push(complex(&a,0.0, 0.0));
	} else {
	        if (x >= 0) {
		        u = x;
			v = y;
		} else {
		        u = -x;
			v = -y;
		}
		
	        z = atan(2*u/(1-u*u-v*v));
		w = log((u*u+(v+1)*(v+1))/(u*u+(v-1)*(v-1)))/4;
		if (z < 0)
		        z = z + 2*PI_ON_TWO;
		if (x < 0) {
		        z = -z;
			w = -w;
		}
		push( complex(&a,0.5*z, w) );
	}
}

f_sinh()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,sinh(real(&a))*cos(imag(&a)), cosh(real(&a))*sin(imag(&a))) );
}

f_cosh()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,cosh(real(&a))*cos(imag(&a)), sinh(real(&a))*sin(imag(&a))) );
}

f_tanh()
{
struct value a;
register double den;
	(void) pop(&a);
	den = cosh(2*real(&a)) + cos(2*imag(&a));
	push( complex(&a,sinh(2*real(&a))/den, sin(2*imag(&a))/den) );
}

f_int()
{
struct value a;
	push( integer(&a,(int)real(pop(&a))) );
}


f_abs()
{
struct value a;
	(void) pop(&a);
	switch (a.type) {
		case INT:
			push( integer(&a,abs(a.v.int_val)) );			
			break;
		case CMPLX:
			push( complex(&a,magnitude(&a), 0.0) );
	}
}

f_sgn()
{
struct value a;
	(void) pop(&a);
	switch(a.type) {
		case INT:
			push( integer(&a,(a.v.int_val > 0) ? 1 : 
					(a.v.int_val < 0) ? -1 : 0) );
			break;
		case CMPLX:
			push( integer(&a,(a.v.cmplx_val.real > 0.0) ? 1 : 
					(a.v.cmplx_val.real < 0.0) ? -1 : 0) );
			break;
	}
}


f_sqrt()
{
struct value a;
register double mag, ang;
	(void) pop(&a);
	mag = sqrt(magnitude(&a));
	if (imag(&a) == 0.0 && real(&a) < 0.0)
		push( complex(&a,0.0,mag) );
	else
	{
		if ( (ang = angle(&a)) < 0.0)
			ang += 2*Pi;
		ang /= 2;
		push( complex(&a,mag*cos(ang), mag*sin(ang)) );
	}
}


f_exp()
{
struct value a;
register double mag, ang;
	(void) pop(&a);
	mag = exp(real(&a));
	ang = imag(&a);
	push( complex(&a,mag*cos(ang), mag*sin(ang)) );
}


f_log10()
{
struct value a;
register double l10;;
	(void) pop(&a);
	l10 = log(10.0);	/***** replace with a constant! ******/
	push( complex(&a,log(magnitude(&a))/l10, angle(&a)/l10) );
}


f_log()
{
struct value a;
	(void) pop(&a);
	push( complex(&a,log(magnitude(&a)), angle(&a)) );
}


f_floor()
{
struct value a;

	(void) pop(&a);
	switch (a.type) {
		case INT:
			push( integer(&a,(int)floor((double)a.v.int_val)));			
			break;
		case CMPLX:
			push( integer(&a,(int)floor(a.v.cmplx_val.real)));
	}
}


f_ceil()
{
struct value a;

	(void) pop(&a);
	switch (a.type) {
		case INT:
			push( integer(&a,(int)ceil((double)a.v.int_val)));			
			break;
		case CMPLX:
			push( integer(&a,(int)ceil(a.v.cmplx_val.real)));
	}
}

#ifdef GAMMA

f_gamma()
{
extern int signgam;
register double y;
struct value a;

	y = GAMMA(real(pop(&a)));
	if (y > 88.0) {
		undefined = TRUE;
		push( integer(&a,0) );
	}
	else
		push( complex(&a,signgam * exp(y),0.0) );
}

#endif /* GAMMA */


/* bessel function approximations */
double jzero(x)
double x;
{
double p, q, x2;
int n;

	x2 = x * x;
	p = pjzero[8];
	q = qjzero[8];
	for (n=7; n>=0; n--) {
		p = p*x2 + pjzero[n];
		q = q*x2 + qjzero[n];
	}
	return(p/q);
}

double pzero(x)
double x;
{
double p, q, z, z2;
int n;

	z = 8.0 / x;
	z2 = z * z;
	p = ppzero[5];
	q = qpzero[5];
	for (n=4; n>=0; n--) {
		p = p*z2 + ppzero[n];
		q = q*z2 + qpzero[n];
	}
	return(p/q);
}

double qzero(x)
double x;
{
double p, q, z, z2;
int n;

	z = 8.0 / x;
	z2 = z * z;
	p = pqzero[5];
	q = qqzero[5];
	for (n=4; n>=0; n--) {
		p = p*z2 + pqzero[n];
		q = q*z2 + qqzero[n];
	}
	return(p/q);
}

double yzero(x)
double x;
{
double p, q, x2;
int n;

	x2 = x * x;
	p = pyzero[8];
	q = qyzero[8];
	for (n=7; n>=0; n--) {
		p = p*x2 + pyzero[n];
		q = q*x2 + qyzero[n];
	}
	return(p/q);
}

double rj0(x)
double x;
{
	if ( x <= 0.0 )
		x = -x;
	if ( x < 8.0 )
		return(jzero(x));
	else
		return( sqrt(TWO_ON_PI/x) *
			(pzero(x)*cos(x-PI_ON_FOUR) - 8.0/x*qzero(x)*sin(x-PI_ON_FOUR)) );

}

double ry0(x)
double x;
{
	if ( x < 0.0 )
		return(dzero/dzero); /* error */
	if ( x < 8.0 )
		return( yzero(x) + TWO_ON_PI*rj0(x)*log(x) );
	else
		return( sqrt(TWO_ON_PI/x) *
			(pzero(x)*sin(x-PI_ON_FOUR) + 
			(8.0/x)*qzero(x)*cos(x-PI_ON_FOUR)) );

}


double jone(x)
double x;
{
double p, q, x2;
int n;

	x2 = x * x;
	p = pjone[8];
	q = qjone[8];
	for (n=7; n>=0; n--) {
		p = p*x2 + pjone[n];
		q = q*x2 + qjone[n];
	}
	return(p/q);
}

double pone(x)
double x;
{
double p, q, z, z2;
int n;

	z = 8.0 / x;
	z2 = z * z;
	p = ppone[5];
	q = qpone[5];
	for (n=4; n>=0; n--) {
		p = p*z2 + ppone[n];
		q = q*z2 + qpone[n];
	}
	return(p/q);
}

double qone(x)
double x;
{
double p, q, z, z2;
int n;

	z = 8.0 / x;
	z2 = z * z;
	p = pqone[5];
	q = qqone[5];
	for (n=4; n>=0; n--) {
		p = p*z2 + pqone[n];
		q = q*z2 + qqone[n];
	}
	return(p/q);
}

double yone(x)
double x;
{
double p, q, x2;
int n;

	x2 = x * x;
	p = 0.0;
	q = qyone[8];
	for (n=7; n>=0; n--) {
		p = p*x2 + pyone[n];
		q = q*x2 + qyone[n];
	}
	return(p/q);
}

double rj1(x)
double x;
{
double v,w;
	v = x;
	if ( x < 0.0 )
		x = -x;
	if ( x < 8.0 )
		return(v*jone(x));
	else {
		w = sqrt(TWO_ON_PI/x) *
			(pone(x)*cos(x-THREE_PI_ON_FOUR) - 
			   8.0/x*qone(x)*sin(x-THREE_PI_ON_FOUR)) ;
		if (v < 0.0)
			w = -w;
		return( w );
	}
}

double ry1(x)
double x;
{
	if ( x <= 0.0 )
		return(dzero/dzero); /* error */
	if ( x < 8.0 )
		return( x*yone(x) + TWO_ON_PI*(rj1(x)*log(x) - 1.0/x) );
	else
		return( sqrt(TWO_ON_PI/x) *
			(pone(x)*sin(x-THREE_PI_ON_FOUR) + 
			(8.0/x)*qone(x)*cos(x-THREE_PI_ON_FOUR)) );
}


f_besj0()	
{
struct value a;
double x;
	(void) pop(&a);
	if (imag(&a) > zero)
		int_error("can only do bessel functions of reals",NO_CARET);
	push( complex(&a,rj0(real(&a)),0.0) );
}


f_besj1()	
{
struct value a;
double x;
	(void) pop(&a);
	if (imag(&a) > zero)
		int_error("can only do bessel functions of reals",NO_CARET);
	push( complex(&a,rj1(real(&a)),0.0) );
}


f_besy0()	
{
struct value a;
double x;
	(void) pop(&a);
	if (imag(&a) > zero)
		int_error("can only do bessel functions of reals",NO_CARET);
	if (real(&a) > 0.0)
		push( complex(&a,ry0(real(&a)),0.0) );
	else {
		push( complex(&a,0.0,0.0) );
		undefined = TRUE ;
	}
}


f_besy1()	
{
struct value a;
double x;
	(void) pop(&a);
	if (imag(&a) > zero)
		int_error("can only do bessel functions of reals",NO_CARET);
	if (real(&a) > 0.0)
		push( complex(&a,ry1(real(&a)),0.0) );
	else {
		push( complex(&a,0.0,0.0) );
		undefined = TRUE ;
	}
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term.c version [6d293458cf].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
#ifndef lint
static char *RCSid = "$Id: term.c,v 3.26 92/03/24 22:34:41 woo Exp Locker: woo $";
#endif

/* GNUPLOT - term.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <stdio.h>
#include "plot.h"
#include "setshow.h"
#include "term.h"
#include "bitmap.h"
#ifdef NEXT
#include <stdlib.h>
#include "EpsViewer.h"
#endif /* NEXT */

/* for use by all drivers */
#define sign(x) ((x) >= 0 ? 1 : -1)
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

BOOLEAN term_init;			/* true if terminal has been initialized */

extern FILE *outfile;
extern char outstr[];
extern BOOLEAN term_init;
extern int term;
extern float xsize, ysize;

extern char input_line[];
extern struct lexical_unit token[];
extern int num_tokens, c_token;
extern struct value *const_express();

extern BOOLEAN interactive;

/*
 * instead of <strings.h>
 */
extern char *strcpy();
extern int strlen(), strcmp(), strncmp();
#ifndef AMIGA_AC_5
extern double sqrt();
#endif

char *getenv();

#ifdef __TURBOC__
char *turboc_init();
#endif
#ifdef PC
void reopen_binary();
#endif
#ifdef vms
char *vms_init();
void vms_reset();
void term_mode_tek();
void term_mode_native();
void term_pasthru();
void term_nopasthru();
void reopen_binary();
void fflush_binary();
#endif

/* This is needed because the unixplot library only writes to stdout. */
#ifdef UNIXPLOT
FILE save_stdout;
#endif
int unixplot=0;

#define NICE_LINE		0
#define POINT_TYPES		6


do_point(x,y,number)
int x,y;
int number;
{
register int htic,vtic;
register struct termentry *t = &term_tbl[term];

     if (number < 0) {		/* do dot */
	    (*t->move)(x,y);
	    (*t->vector)(x,y);
	    return;
	}

	number %= POINT_TYPES;
	htic = (t->h_tic/2);	/* should be in term_tbl[] in later version */
	vtic = (t->v_tic/2);	

	switch(number) {
		case 0: /* do diamond */ 
				(*t->move)(x-htic,y);
				(*t->vector)(x,y-vtic);
				(*t->vector)(x+htic,y);
				(*t->vector)(x,y+vtic);
				(*t->vector)(x-htic,y);
				(*t->move)(x,y);
				(*t->vector)(x,y);
				break;
		case 1: /* do plus */ 
				(*t->move)(x-htic,y);
				(*t->vector)(x-htic,y);
				(*t->vector)(x+htic,y);
				(*t->move)(x,y-vtic);
				(*t->vector)(x,y-vtic);
				(*t->vector)(x,y+vtic);
				break;
		case 2: /* do box */ 
				(*t->move)(x-htic,y-vtic);
				(*t->vector)(x-htic,y-vtic);
				(*t->vector)(x+htic,y-vtic);
				(*t->vector)(x+htic,y+vtic);
				(*t->vector)(x-htic,y+vtic);
				(*t->vector)(x-htic,y-vtic);
				(*t->move)(x,y);
				(*t->vector)(x,y);
				break;
		case 3: /* do X */ 
				(*t->move)(x-htic,y-vtic);
				(*t->vector)(x-htic,y-vtic);
				(*t->vector)(x+htic,y+vtic);
				(*t->move)(x-htic,y+vtic);
				(*t->vector)(x-htic,y+vtic);
				(*t->vector)(x+htic,y-vtic);
				break;
		case 4: /* do triangle */ 
				(*t->move)(x,y+(4*vtic/3));
				(*t->vector)(x-(4*htic/3),y-(2*vtic/3));
				(*t->vector)(x+(4*htic/3),y-(2*vtic/3));
				(*t->vector)(x,y+(4*vtic/3));
				(*t->move)(x,y);
				(*t->vector)(x,y);
				break;
		case 5: /* do star */ 
				(*t->move)(x-htic,y);
				(*t->vector)(x-htic,y);
				(*t->vector)(x+htic,y);
				(*t->move)(x,y-vtic);
				(*t->vector)(x,y-vtic);
				(*t->vector)(x,y+vtic);
				(*t->move)(x-htic,y-vtic);
				(*t->vector)(x-htic,y-vtic);
				(*t->vector)(x+htic,y+vtic);
				(*t->move)(x-htic,y+vtic);
				(*t->vector)(x-htic,y+vtic);
				(*t->vector)(x+htic,y-vtic);
				break;
	}
}


/*
 * general point routine
 */
line_and_point(x,y,number)
int x,y,number;
{
	/* temporary(?) kludge to allow terminals with bad linetypes 
		to make nice marks */

	(*term_tbl[term].linetype)(NICE_LINE);
	do_point(x,y,number);
}

/* 
 * general arrow routine
 */
#define ROOT2 (1.41421)		/* sqrt of 2 */

do_arrow(sx, sy, ex, ey, head)
	int sx,sy;			/* start point */
	int ex, ey;			/* end point (point of arrowhead) */
	BOOLEAN head;
{
    register struct termentry *t = &term_tbl[term];
    int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */

    /* draw the line for the arrow. That's easy. */
    (*t->move)(sx, sy);
    (*t->vector)(ex, ey);

    if (head) {
    /* now draw the arrow head. */
    /* we put the arrowhead marks at 45 degrees to line */
       if (sx == ex) {
	   /* vertical line, special case */
	      int delta = ((float)len / ROOT2 + 0.5);
	      if (sy < ey)
		      delta = -delta;	/* up arrow goes the other way */
	      (*t->move)(ex - delta, ey + delta);
	      (*t->vector)(ex,ey);
	      (*t->vector)(ex + delta, ey + delta);
       } else {
	      int dx = sx - ex;
	      int dy = sy - ey;
	      double coeff = len / sqrt(2.0*((double)dx*(double)dx 
				   + (double)dy*(double)dy));
	      int x,y;			/* one endpoint */

	      x = (int)( ex + (dx + dy) * coeff );
	      y = (int)( ey + (dy - dx) * coeff );
	      (*t->move)(x,y);
	      (*t->vector)(ex,ey);

	      x = (int)( ex + (dx - dy) * coeff );
	      y = (int)( ey + (dy + dx) * coeff );
	      (*t->vector)(x,y);
       }
    }
}

#ifdef DUMB                    /* paper or glass dumb terminal */
#include "term/dumb.trm"
#endif


#ifdef PC			/* all PC types */
#include "term/pc.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
   the others to compile.
*/
#ifdef BITGRAPH
# ifndef TEK
#  define TEK
# endif
#endif

#ifdef SELENAR
# ifndef TEK
#  define TEK
# endif
#endif

#ifdef KERMIT
# ifndef TEK
#  define TEK
# endif
#endif

#ifdef LN03P
# ifndef TEK
#  define TEK
# endif
#endif

#ifdef VTTEK
# ifndef TEK
#  define TEK
# endif
#endif

#ifdef T410X		/* Tektronix 4106, 4107, 4109 and 420x terminals */
#include "term/t410x.trm"
#endif

#ifdef TEK			/* all TEK types, TEK, BBN, SELANAR, KERMIT, VTTEK */
#include "term/tek.trm"
#endif

#ifdef EPSONP	/* bit map types, EPSON, NEC, PROPRINTER, STAR Color */
#include "term/epson.trm"
#endif

#ifdef HPLJII		/* HP LaserJet II */
#include "term/hpljii.trm"
#endif

#ifdef HPLJIII /* HP LaserJet III in HPGL mode */
#  ifndef HPGL
#    define HPGL
#  endif
#endif

#ifdef FIG				/* Fig 1.4FS Interactive graphics program */
#include "term/fig.trm"
#include "term/bigfig.trm"
#endif
  
#ifdef GPR              /* Apollo Graphics Primitive Resource (fixed-size window) */
#include "term/gpr.trm"
#endif /* GPR */

#ifdef APOLLO           /* Apollo Graphics Primitive Resource (resizable window) */
#include "term/apollo.trm"
#endif /* APOLLO */

#ifdef IMAGEN		/* IMAGEN printer */
#include "term/imagen.trm"
#endif

#ifdef EEPIC		/* EEPIC (LATEX) type */
#include "term/eepic.trm"
# ifndef LATEX
#  define LATEX
# endif
#endif

#ifdef EMTEX		/* EMTEX (LATEX for PC) type */
# ifndef LATEX
#  define LATEX
# endif
#endif

#ifdef LATEX		/* LATEX type */
#include "term/latex.trm"
#endif

#ifdef PBM		/* PBMPLUS portable bitmap */
#include "term/pbm.trm"
#endif

#ifdef POSTSCRIPT	/* POSTSCRIPT type */
#include "term/post.trm"
#endif

#ifdef PRESCRIBE	/* PRESCRIBE type */
#include "term/kyo.trm"
#endif

#ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
#include "term/unixpc.trm"
#endif /* UNIXPC */

#ifdef AED
#include "term/aed.trm"
#endif /* AED */

#ifdef AIFM
#include "term/ai.trm"
#endif /* AIFM */

#ifdef CGI
#include "term/cgi.trm"
#endif /* CGI */

#ifdef HP2648
/* also works for HP2647 */
#include "term/hp2648.trm"
#endif /* HP2648 */

#ifdef HP26
#include "term/hp26.trm"
#endif /* HP26 */

#ifdef HP75
#ifndef HPGL
#define HPGL
#endif
#endif

/* HPGL - includes HP75 and HPLJIII in HPGL mode */
#ifdef HPGL
#include "term/hpgl.trm"
#endif /* HPGL */

/* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ 
	and Russell Lang, rjl@monu1.cc.monash.oz */
#ifdef DXY800A
#include "term/dxy.trm"
#endif /* DXY800A */

#ifdef IRIS4D
#include "term/iris4d.trm"
#endif /* IRIS4D */

#ifdef NEXT
#include "term/next.trm"
#endif /* NEXT */

#ifdef QMS
#include "term/qms.trm"
#endif /* QMS */

#ifdef REGIS
#include "term/regis.trm"
#endif /* REGIS */

#ifdef SUN
#include "term/sun.trm"
#endif /* SUN */

#ifdef VWS
#include "term/vws.trm"
#endif /* VWS */

#ifdef V384
#include "term/v384.trm"
#endif /* V384 */

#ifdef UNIXPLOT
#include "term/unixplot.trm"
#endif /* UNIXPLOT */

#ifdef X11
#include "term/x11.trm"
#endif /* X11 */

#ifdef DXF
#include "term/dxf.trm"
#endif /* DXF */
  
#ifdef AMIGASCREEN
#include "term/amiga.trm"
#endif /* AMIGASCREEN */


/* Dummy functions for unavailable features */

/* change angle of text.  0 is horizontal left to right.
* 1 is vertical bottom to top (90 deg rotate)  
*/
static int null_text_angle()
{
return FALSE ;	/* can't be done */
}

/* change justification of text.  
 * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
 */
static int null_justify_text()
{
return FALSE ;	/* can't be done */
}


/* Change scale of plot.
 * Parameters are x,y scaling factors for this plot.
 * Some terminals (eg latex) need to do scaling themselves.
 */
static int null_scale()
{
return FALSE ;	/* can't be done */
}

static int do_scale()
{
return TRUE ;	/* can be done */
}

options_null()
{
	term_options[0] = '\0';	/* we have no options */
}

static UNKNOWN_null()
{
}

/*
 * term_tbl[] contains an entry for each terminal.  "unknown" must be the
 *   first, since term is initialized to 0.
 */
struct termentry term_tbl[] = {
    {"unknown", "Unknown terminal type - not a plotting device",
	  100, 100, 1, 1,
	  1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
	  UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
	  UNKNOWN_null, UNKNOWN_null, null_text_angle, 
	  null_justify_text, UNKNOWN_null, UNKNOWN_null}

    ,{"table", "Dump ASCII table of X Y [Z] values to output",
	  100, 100, 1, 1,
	  1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
	  UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
	  UNKNOWN_null, UNKNOWN_null, null_text_angle, 
	  null_justify_text, UNKNOWN_null, UNKNOWN_null}

#ifdef AMIGASCREEN
    ,{"amiga", "Amiga Custom Screen",
	   AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, 
	   AMIGA_VTIC, AMIGA_HTIC, options_null, AMIGA_init, AMIGA_reset, 
	   AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector,
	   AMIGA_linetype, AMIGA_put_text, null_text_angle, 
	   AMIGA_justify_text, do_point, do_arrow}
#endif

#ifdef DUMB
    ,{"dumb", "printer or glass dumb terminal",
         DUMB_XMAX, DUMB_YMAX, 1, 1,
         1, 1, DUMB_options, DUMB_init, DUMB_reset,
         DUMB_text, null_scale, DUMB_graphics, DUMB_move, DUMB_vector,
         DUMB_linetype, DUMB_put_text, null_text_angle,
         null_justify_text, DUMB_point, DUMB_arrow}
#endif

#ifdef PC
#ifdef __TURBOC__

    ,{"egalib", "IBM PC/Clone with EGA graphics board",
	   EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
	   EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
	   EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
	   EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle, 
	   EGALIB_justify_text, do_point, do_arrow}

    ,{"vgalib", "IBM PC/Clone with VGA graphics board",
	   VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
	   VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
	   VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
	   VGA_linetype, VGA_put_text, VGA_text_angle, 
	   VGA_justify_text, do_point, do_arrow}

    ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
	   VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
	   VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
	   VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
	   VGAMONO_linetype, VGA_put_text, VGA_text_angle, 
	   VGA_justify_text, line_and_point, do_arrow}

    ,{"svga", "IBM PC/Clone with Super VGA graphics board",
	   SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
	   SVGA_VTIC, SVGA_HTIC, options_null, SVGA_init, SVGA_reset,
	   SVGA_text, null_scale, SVGA_graphics, SVGA_move, SVGA_vector,
	   SVGA_linetype, SVGA_put_text, SVGA_text_angle, 
	   SVGA_justify_text, do_point, do_arrow}

    ,{"mcga", "IBM PC/Clone with MCGA graphics board",
	   MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
	   MCGA_VTIC, MCGA_HTIC, options_null, MCGA_init, MCGA_reset,
	   MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
	   MCGA_linetype, MCGA_put_text, MCGA_text_angle, 
	   MCGA_justify_text, line_and_point, do_arrow}

    ,{"cga", "IBM PC/Clone with CGA graphics board",
	   CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
	   CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
	   CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
	   CGA_linetype, CGA_put_text, MCGA_text_angle, 
	   CGA_justify_text, line_and_point, do_arrow}

    ,{"hercules", "IBM PC/Clone with Hercules graphics board",
	   HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
	   HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
	   HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
	   HERC_linetype, HERC_put_text, MCGA_text_angle, 
	   HERC_justify_text, line_and_point, do_arrow}
#ifdef ATT6300
    ,{"att", "IBM PC/Clone with AT&T 6300 graphics board",
	   ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
	   ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
	   ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
	   ATT_linetype, ATT_put_text, ATT_text_angle, 
	   ATT_justify_text, line_and_point, do_arrow}
#endif
#else					/* TURBO */

    ,{"cga", "IBM PC/Clone with CGA graphics board",
	   CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
	   CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
	   CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
	   CGA_linetype, CGA_put_text, CGA_text_angle, 
	   null_justify_text, line_and_point, do_arrow}

    ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
	   EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
	   EGA_VTIC, EGA_HTIC, options_null, EGA_init, EGA_reset,
	   EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
	   EGA_linetype, EGA_put_text, EGA_text_angle, 
	   null_justify_text, do_point, do_arrow}

    ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
	   VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
	   VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
	   VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
	   VGA_linetype, VGA_put_text, VGA_text_angle, 
	   null_justify_text, do_point, do_arrow}

#ifdef EGALIB
    ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
	   EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
	   EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
	   EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
	   EGALIB_linetype, EGALIB_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef HERCULES
    ,{"hercules", "IBM PC/Clone with Hercules graphics board",
	   HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
	   HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
	   HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
	   HERC_linetype, HERC_put_text, HERC_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif					/* HERCULES */

#ifdef ATT6300
    ,{"att", "AT&T PC/6300 graphics",
	   ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
	   ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
	   ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
	   ATT_linetype, ATT_put_text, ATT_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef CORONA
    ,{"corona325", "Corona graphics ???",
	   COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
	   COR_VTIC, COR_HTIC, options_null, COR_init, COR_reset,
	   COR_text, null_scale, COR_graphics, COR_move, COR_vector,
	   COR_linetype, COR_put_text, COR_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif					/* CORONA */
#endif					/* TURBO */
#endif					/* PC */

#ifdef AED
    ,{"aed512", "AED 512 Terminal",
	   AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
	   AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
	   AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
	   AED_linetype, AED_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
    ,{"aed767", "AED 767 Terminal",
	   AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
	   AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
	   AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
	   AED_linetype, AED_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef AIFM
    ,{"aifm", "Adobe Illustrator 3.0 Format",
	   AI_XMAX, AI_YMAX, AI_VCHAR, AI_HCHAR, 
	   AI_VTIC, AI_HTIC, AI_options, AI_init, AI_reset, 
	   AI_text, null_scale, AI_graphics, AI_move, AI_vector, 
	   AI_linetype, AI_put_text, AI_text_angle, 
	   AI_justify_text, do_point, do_arrow}
#endif

#ifdef APOLLO
   	,{"apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing",
	   0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */
	   APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset,
	   APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector,
	   APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle,
	   APOLLO_justify_text, line_and_point, do_arrow}
#endif

#ifdef GPR
   	,{"gpr", "Apollo Graphics Primitive Resource, fixed-size window",
	   GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR,
	   GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset,
	   GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector,
	   GPR_linetype, GPR_put_text, GPR_text_angle,
	   GPR_justify_text, line_and_point, do_arrow}
#endif

#ifdef BITGRAPH
    ,{"bitgraph", "BBN Bitgraph Terminal",
	   BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, 
	   BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, 
	   BG_text, null_scale, BG_graphics, BG_move, BG_vector,
	   BG_linetype, BG_put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef CGI
    ,{"cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
	   CGI_XMAX, CGI_YMAX, 0, 0, 
	   CGI_VTIC, 0, options_null, CGI_init, CGI_reset, 
	   CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
	   CGI_linetype, CGI_put_text, CGI_text_angle, 
	   CGI_justify_text, CGI_point, do_arrow}

    ,{"hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
	   CGI_XMAX, CGI_YMAX, 0, 0, 
	   CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, 
	   CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
	   CGI_linetype, CGI_put_text, CGI_text_angle, 
	   CGI_justify_text, CGI_point, do_arrow}
#endif

#ifdef DXF
    ,{"dxf", "dxf-file for AutoCad (default size 120x80)",
       DXF_XMAX,DXF_YMAX,DXF_VCHAR, DXF_HCHAR,
       DXF_VTIC, DXF_HTIC, options_null,DXF_init, DXF_reset,
       DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector,
       DXF_linetype, DXF_put_text, DXF_text_angle,
       DXF_justify_text, do_point, do_arrow}
#endif

#ifdef DXY800A
    ,{"dxy800a", "Roland DXY800A plotter",
	   DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
	   DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset,
	   DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
	   DXY_linetype, DXY_put_text, DXY_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef EEPIC
    ,{"eepic", "EEPIC -- extended LaTeX picture environment",
	   EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, 
	   EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, 
	   EEPIC_text, EEPIC_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, 
	   EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, 
	   EEPIC_justify_text, EEPIC_point, EEPIC_arrow}
#endif

#ifdef EMTEX
   
    ,{"emtex", "LATEX picture environment with emTeX specials",
	   LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
	   LATEX_VTIC, LATEX_HTIC, options_null, EMTEX_init, EMTEX_reset, 
	   EMTEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
	   LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
	   LATEX_justify_text, LATEX_point, LATEX_arrow}
#endif

#ifdef EPS60
    ,{"epson_60dpi", "Epson-style 60-dot per inch printers",
	   EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
	   EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
	   EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
	   EPSONlinetype, EPSONput_text, EPSON_text_angle,
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef EPSONP
    ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
	   EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, 
	   EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, 
	   EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, 
	   EPSONlinetype, EPSONput_text, EPSON_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef FIG
    ,{"fig", "FIG graphics language: SunView or X graphics editor",
	   FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR, 
	   FIG_VTIC, FIG_HTIC, options_null, FIG_init, FIG_reset, 
	   FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector, 
	   FIG_linetype, FIG_put_text, FIG_text_angle, 
	   FIG_justify_text, do_point, FIG_arrow}
    ,{"bfig", "FIG graphics language: SunView or X graphics editor. Large Graph",
	   BFIG_XMAX, BFIG_YMAX, BFIG_VCHAR, BFIG_HCHAR, 
	   BFIG_VTIC, BFIG_HTIC, options_null, FIG_init, FIG_reset, 
	   FIG_text, null_scale, FIG_graphics, FIG_move, BFIG_vector, 
	   FIG_linetype, BFIG_put_text, FIG_text_angle, 
	   FIG_justify_text, do_point, BFIG_arrow}
#endif

#ifdef HP26
    ,{"hp2623A", "HP2623A and maybe others",
	   HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
	   HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
	   HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
	   HP26_linetype, HP26_put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef HP2648
    ,{"hp2648", "HP2648 and HP2647",
	   HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, 
	   HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, 
	   HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, 
	   HP2648linetype, HP2648put_text, HP2648_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef HP75
    ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
	   HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
	   HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
	   HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
	   HP75_linetype, HPGL_put_text, HPGL_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef HPGL
    ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
	   HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
	   HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
	   HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
	   HPGL_linetype, HPGL_put_text, HPGL_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef HPLJII
    ,{"hpljii", "HP Laserjet series II, [75 100 150 300]",
       HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
       HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
       HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
       HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
       HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
       do_arrow}
    ,{"hpdj", "HP DeskJet 500, [75 100 150 300]",
       HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
       HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
       HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
       HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
       HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
       do_arrow}
#endif

#ifdef HPLJIII
    ,{"pcl5_port", "HP laserjet iii (using HPGL plot vectors), portrait mode",
	PCL_YMAX, PCL_XMAX, PCL_VCHAR, PCL_HCHAR,
	PCL_VTIC, PCL_HTIC, options_null, PCL_PORT_init, PCL_reset,
	PCL_text, null_scale, PCL_graphics, HPGL_move, HPGL_vector,
	HPGL_linetype, PCL_put_text, HPGL_text_angle,
	null_justify_text, do_point, do_arrow}
     ,{"pcl5_land", "HP laserjet iii (using HPGL plot vectors), landscape mode",
	PCL_XMAX, PCL_YMAX, PCL_VCHAR, PCL_HCHAR,
	PCL_VTIC, PCL_HTIC, options_null, PCL_LAND_init, PCL_reset,
	PCL_text, null_scale, PCL_graphics, HPGL_move, HPGL_vector,
	HPGL_linetype, PCL_put_text, HPGL_text_angle,
	null_justify_text, do_point, do_arrow}
#endif

#ifdef IMAGEN
    ,{"imagen", "Imagen laser printer",
	   IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, 
	   IMAGEN_VTIC, IMAGEN_HTIC, options_null, IMAGEN_init, IMAGEN_reset, 
	   IMAGEN_text, null_scale, IMAGEN_graphics, IMAGEN_move, 
	   IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
	   IMAGEN_justify_text, line_and_point, do_arrow}
#endif

#ifdef IRIS4D
    ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
	   IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
	   IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
	   IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
	   IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef KERMIT
    ,{"kc_tek40xx", "Kermit-MS tek40xx terminal emulator - color",
	   TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
	   TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
	   KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
	   KTEK40Clinetype, TEK40put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
    ,{"km_tek40xx", "Kermit-MS tek40xx terminal emulator - monochrome",
	   TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
	   TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
	   TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
	   KTEK40Mlinetype, TEK40put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef LATEX
    ,{"latex", "LaTeX picture environment",
	   LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
	   LATEX_VTIC, LATEX_HTIC, options_null, LATEX_init, LATEX_reset, 
	   LATEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
	   LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
	   LATEX_justify_text, LATEX_point, LATEX_arrow}
#endif

#ifdef LN03P
     ,{"ln03", "LN03-plus laser printer in tektronix mode",
	TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
	TEK40VTIC, TEK40HTIC, options_null, LN03Pinit, LN03Preset,
	TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
	TEK40linetype, TEK40put_text, null_text_angle,
	null_justify_text, line_and_point, do_arrow}
#endif

#ifdef NEC
    ,{"nec_cp6m", "NEC printer CP6, Epson LQ-800 Monochrome",
	   NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
	   NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
	   NECtext, null_scale, NECMgraphics, NECmove, NECvector, 
	   NECMlinetype, NECput_text, NEC_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
    ,{"nec_cp6c", "NEC printer CP6 Color",
	   NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
	   NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
	   NECtext, null_scale, NECCgraphics, NECmove, NECvector, 
	   NECClinetype, NECput_text, NEC_text_angle, 
	   null_justify_text, do_point, do_arrow}
    ,{"nec_cp6d", "NEC printer CP6, Epson LQ-800 Draft monochrome",
	   NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
	   NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
	   NECdraft_text, null_scale, NECMgraphics, NECmove, NECvector, 
	   NECMlinetype, NECput_text, NEC_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef NEXT
    ,{"next", "NeXTstep window system",
	   NEXT_XMAX, NEXT_YMAX, NEXT_VCHAR, NEXT_HCHAR, 
	   NEXT_VTIC, NEXT_HTIC, NEXT_options, NEXT_init, NEXT_reset, 
	   NEXT_text, do_scale, NEXT_graphics, NEXT_move, NEXT_vector, 
	   NEXT_linetype, NEXT_put_text, NEXT_text_angle, 
	   NEXT_justify_text, NEXT_point, do_arrow}
#endif /* The postscript driver with NXImage displaying the postscript on screen */

#ifdef PBM
    ,{"pbm", "Portable bitmap",
       PBM_XMAX, PBM_YMAX, PBM_VCHAR,
       PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
       PBMinit, PBMreset, PBMtext, null_scale,
       PBMgraphics, PBMmove, PBMvector, PBMlinetype,
       PBMput_text, PBMtext_angle, null_justify_text, line_and_point,
       do_arrow}
    ,{"pgm", "Portable graymap",
       PBM_XMAX, PBM_YMAX, PBM_VCHAR,
       PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
       PBMinit, PBMreset, PGMtext, null_scale,
       PGMgraphics, PBMmove, PBMvector, PGMlinetype,
       PBMput_text, PBMtext_angle, null_justify_text, do_point,
       do_arrow}
    ,{"ppm", "Portable pixmap (color)",
       PBM_XMAX, PBM_YMAX, PBM_VCHAR,
       PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
       PBMinit, PBMreset, PPMtext, null_scale,
       PPMgraphics, PBMmove, PBMvector, PPMlinetype,
       PBMput_text, PBMtext_angle, null_justify_text, do_point,
       do_arrow}
#endif

#ifdef POSTSCRIPT
    ,{"postscript", "PostScript graphics language [mode \042fontname\042 font_size]",
	   PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, 
	   PS_VTIC, PS_HTIC, PS_options, PS_init, PS_reset, 
	   PS_text, null_scale, PS_graphics, PS_move, PS_vector, 
	   PS_linetype, PS_put_text, PS_text_angle, 
	   PS_justify_text, PS_point, do_arrow}
#endif

#ifdef PRESCRIBE
    ,{"prescribe", "Prescribe - for the Kyocera Laser Printer",
	PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, 
	PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, 
	PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
	PRE_linetype, PRE_put_text, null_text_angle, 
	PRE_justify_text, line_and_point, do_arrow}
    ,{"kyo", "Kyocera Laser Printer with Courier font",
	PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, 
	PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, 
	PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
	PRE_linetype, PRE_put_text, null_text_angle, 
	PRE_justify_text, line_and_point, do_arrow}
#endif /* PRESCRIBE */

#ifdef QMS
    ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
	   QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, 
	   QMS_VTIC, QMS_HTIC, options_null, QMS_init,QMS_reset, 
	   QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
	   QMS_linetype,QMS_put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef REGIS
    ,{"regis", "REGIS graphics language",
	   REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, 
	   REGISVTIC, REGISHTIC, options_null, REGISinit, REGISreset, 
	   REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
	   REGISlinetype, REGISput_text, REGIStext_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif


#ifdef SELANAR
    ,{"selanar", "Selanar",
	   TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
	   TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, 
	   SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, 
	   TEK40linetype, TEK40put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef STARC
    ,{"starc", "Star Color Printer",
	   STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, 
	   STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, 
	   STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, 
	   STARClinetype, STARCput_text, STARC_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef SUN
    ,{"sun", "SunView window system",
	   SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, 
	   SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, 
	   SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
	   SUN_linetype, SUN_put_text, null_text_angle, 
	   SUN_justify_text, line_and_point, do_arrow}
#endif

#ifdef VWS
    ,{"VWS", "VAX Windowing System (UIS)",
           VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
           VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
           VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
           VWS_linetype, VWS_put_text, VWS_text_angle,
           VWS_justify_text, do_point, do_arrow}
#endif

#ifdef TANDY60
    ,{"tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
	   EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
	   EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
	   TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
	   EPSONlinetype, EPSONput_text, EPSON_text_angle,
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef T410X
    ,{"tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
	   T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
	   T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
	   T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
	   T410X_linetype, T410X_put_text, T410X_text_angle, 
	   null_justify_text, T410X_point, do_arrow}
#endif

#ifdef TEK
    ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
	   TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
	   TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, 
	   TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, 
	   TEK40linetype, TEK40put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef UNIXPLOT
    ,{"unixplot", "Unix plotting standard (see plot(1))",
	   UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, 
	   UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, 
	   UP_text, null_scale, UP_graphics, UP_move, UP_vector, 
	   UP_linetype, UP_put_text, null_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif
	
#ifdef UNIXPC
    ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
	   uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, 
	   uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, 
	   uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
	   uPC_linetype, uPC_put_text, uPC_text_angle, 
	   null_justify_text, line_and_point, do_arrow}
#endif

#ifdef V384
    ,{"vx384", "Vectrix 384 and Tandy color printer",
	   V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, 
	   V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, 
	   V384_text, null_scale, V384_graphics, V384_move, V384_vector, 
	   V384_linetype, V384_put_text, null_text_angle, 
	   null_justify_text, do_point, do_arrow}
#endif

#ifdef VTTEK
    ,{"vttek", "VT-like tek40xx terminal emulator",
       TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR,
       TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
       TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
       VTTEK40linetype, VTTEK40put_text, null_text_angle,
       null_justify_text, line_and_point, do_arrow}
#endif

#ifdef X11
    ,{"x11", "X11 Window System",
	   X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
	   X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
	   X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
	   X11_linetype, X11_put_text, null_text_angle, 
	   X11_justify_text, line_and_point, do_arrow}
    ,{"X11", "X11 Window System - multi-color points",
	   X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
	   X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
	   X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
	   X11_linetype, X11_put_text, null_text_angle, 
	   X11_justify_text, do_point, do_arrow}
#endif
};

#define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))


list_terms()
{
register int i;

	fprintf(stderr,"\nAvailable terminal types:\n");
	for (i = 0; i < TERMCOUNT; i++)
		fprintf(stderr,"  %15s  %s\n",
			   term_tbl[i].name, term_tbl[i].description);
	(void) putc('\n',stderr);
}


/* set_term: get terminal number from name on command line */
/* will change 'term' variable if successful */
int						/* term number */
set_term(c_token)
int c_token;
{
    register int t;
    char *input_name;

    if (!token[c_token].is_token)
	 int_error("terminal name expected",c_token);
    t = -1;
    input_name = input_line + token[c_token].start_index;
    t = change_term(input_name, token[c_token].length);
    if (t == -1)
	 int_error("unknown terminal type; type just 'set terminal' for a list",
			 c_token);
    if (t == -2)
	 int_error("ambiguous terminal name; type just 'set terminal' for a list",
			 c_token);

    /* otherwise the type was changed */

    return(t);
}

/* change_term: get terminal number from name and set terminal type */
/* returns -1 if unknown, -2 if ambiguous, >=0 is terminal number */
int
change_term(name, length)
	char *name;
	int length;
{
    int i, t = -1;

    for (i = 0; i < TERMCOUNT; i++) {
	   if (!strncmp(name,term_tbl[i].name,length)) {
		  if (t != -1)
		    return(-2);	/* ambiguous */
		  t = i;
	   }
    }

    if (t == -1)			/* unknown */
	 return(t);

    /* Success: set terminal type now */

    term = t;
    term_init = FALSE;
    name = term_tbl[term].name;

    /* Special handling for unixplot term type */
    if (!strncmp("unixplot",name,8)) {
	   UP_redirect (2);  /* Redirect actual stdout for unixplots */
    } else if (unixplot) {
	   UP_redirect (3);  /* Put stdout back together again. */
    }

    if (interactive)
	 fprintf(stderr, "Terminal type set to '%s'\n", name);

    return(t);
}

/*
   Routine to detect what terminal is being used (or do anything else
   that would be nice).  One anticipated (or allowed for) side effect
   is that the global ``term'' may be set. 
   The environment variable GNUTERM is checked first; if that does
   not exist, then the terminal hardware is checked, if possible, 
   and finally, we can check $TERM for some kinds of terminals.
*/
/* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
init_terminal()
{
    char *term_name = NULL;
    int t;
    char *term = NULL;		/* from TERM environment var */
#ifdef X11
    char *display = NULL;
#endif
    char *gnuterm = NULL;

    /* GNUTERM environment variable is primary */
    gnuterm = getenv("GNUTERM");
    if (gnuterm != (char *)NULL) {
	 term_name = gnuterm;
#ifdef __TURBOC__
         get_path();   /* So *_init() can find the BGI driver */
#endif
    }
    else {
#ifdef __TURBOC__
	   term_name = turboc_init();
	   term = (char *)NULL; /* shut up turbo C */
#endif
	   
#ifdef vms
	   term_name = vms_init();
#endif

#ifdef NEXT
	term = getenv("TERM");
	if (term_name == (char *)NULL
		&& term != (char *)NULL && strcmp(term,"next") == 0)
	      term_name = "next";
#endif /* NeXT */
	   
#ifdef SUN
	   term = getenv("TERM");	/* try $TERM */
	   if (term_name == (char *)NULL
		  && term != (char *)NULL && strcmp(term, "sun") == 0)
		term_name = "sun";
#endif /* sun */

#ifdef GPR
   if (gpr_isa_pad()) term_name = "gpr";       /* find out whether stdout is a DM pad. See term/gpr.trm */
#else
#ifdef APOLLO
   if (apollo_isa_pad()) term_name = "apollo"; /* find out whether stdout is a DM pad. See term/apollo.trm */
#endif /* APOLLO */
#endif /* GPR    */

#ifdef X11
	   term = getenv("TERM");	/* try $TERM */
	   if (term_name == (char *)NULL
		  && term != (char *)NULL && strcmp(term, "xterm") == 0)
		term_name = "x11";
	   display = getenv("DISPLAY");
	   if (term_name == (char *)NULL && display != (char *)NULL)
		term_name = "x11";
#endif /* x11 */

#ifdef AMIGASCREEN
	   term_name = "amiga";
#endif

#ifdef UNIXPC
           if (iswind() == 0) {
              term_name = "unixpc";
           }
#endif /* unixpc */

#ifdef CGI
	   if (getenv("CGIDISP") || getenv("CGIPRNT"))
	     term_name = "cgi";
#endif /*CGI */
    }

    /* We have a name, try to set term type */
    if (term_name != NULL && *term_name != '\0') {
	   t = change_term(term_name, strlen(term_name));
	   if (t == -1)
		fprintf(stderr, "Unknown terminal name '%s'\n", term_name);
	   else if (t == -2)
		fprintf(stderr, "Ambiguous terminal name '%s'\n", term_name);
	   else				/* successful */
		;
    }
}


#ifdef __TURBOC__
char *
turboc_init()
{
  int g_driver,g_mode;
  char far *c1,*c2;
  char *term_name = NULL;
  struct text_info tinfo;       /* So we can restore starting text mode. */

/* Some of this code including BGI drivers is copyright Borland Intl. */
	g_driver=DETECT;
	      get_path();
	gettextinfo(&tinfo);
        initgraph(&g_driver,&g_mode,path);
        c1=getdrivername();
        c2=getmodename(g_mode);
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
			case 1 : term_name = "cga";
					 break;
			case 2 : term_name = "mcga";
					 break;
			case 3 : 
			case 4 : term_name = "egalib";
					 break;
			case 7 : term_name = "hercules";
					 break;
			case 8 : term_name = "att";
					 break;
			case 9 : term_name = "vgalib";
					 break;
            }
        closegraph();
        textmode(tinfo.currmode);
	clrscr();
	fprintf(stderr,"\tTC Graphics, driver %s  mode %s\n",c1,c2);
  return(term_name);
}
#endif /* __TURBOC__ */

/*
	This is always defined so we don't have to have command.c know if it
	is there or not.
*/
#ifndef UNIXPLOT
UP_redirect(caller) int caller; 
{
	caller = caller;	/* to stop Turbo C complaining 
						 * about caller not being used */
}
#else
UP_redirect (caller)
int caller;
/*
	Unixplot can't really write to outfile--it wants to write to stdout.
	This is normally ok, but the original design of gnuplot gives us
	little choice.  Originally users of unixplot had to anticipate
	their needs and redirect all I/O to a file...  Not very gnuplot-like.

	caller:  1 - called from SET OUTPUT "FOO.OUT"
			 2 - called from SET TERM UNIXPLOT
			 3 - called from SET TERM other
			 4 - called from SET OUTPUT
*/
{
	switch (caller) {
	case 1:
	/* Don't save, just replace stdout w/outfile (save was already done). */
		if (unixplot)
			*(stdout) = *(outfile);  /* Copy FILE structure */
	break;
	case 2:
		if (!unixplot) {
			fflush(stdout);
			save_stdout = *(stdout);
			*(stdout) = *(outfile);  /* Copy FILE structure */
			unixplot = 1;
		}
	break;
	case 3:
	/* New terminal in use--put stdout back to original. */
		closepl();
		fflush(stdout);
		*(stdout) = save_stdout;  /* Copy FILE structure */
		unixplot = 0;
	break;
	case 4:
	/*  User really wants to go to normal output... */
		if (unixplot) {
			fflush(stdout);
			*(stdout) = save_stdout;  /* Copy FILE structure */
		}
	break;
	}
}
#endif


/* test terminal by drawing border and text */
/* called from command test */
test_term()
{
	register struct termentry *t = &term_tbl[term];
	char *str;
	int x,y, xl,yl, i;
	unsigned int xmax, ymax;
	char label[MAX_ID_LEN];
	int scaling;

	if (!term_init) {
	   (*t->init)();
	   term_init = TRUE;
	}
	screen_ok = FALSE;
	scaling = (*t->scale)(xsize, ysize);
	xmax = (unsigned int)(t->xmax * (scaling ? 1 : xsize));
	ymax = (unsigned int)(t->ymax * (scaling ? 1 : ysize));
	(*t->graphics)();
	/* border linetype */
	(*t->linetype)(-2);
	(*t->move)(0,0);
	(*t->vector)(xmax-1,0);
	(*t->vector)(xmax-1,ymax-1);
	(*t->vector)(0,ymax-1);
	(*t->vector)(0,0);
	(void) (*t->justify_text)(LEFT);
	(*t->put_text)(t->h_char*5,ymax-t->v_char*3,"Terminal Test");
	/* axis linetype */
	(*t->linetype)(-1);
	(*t->move)(xmax/2,0);
	(*t->vector)(xmax/2,ymax-1);
	(*t->move)(0,ymax/2);
	(*t->vector)(xmax-1,ymax/2);
	/* test width and height of characters */
	(*t->linetype)(-2);
	(*t->move)(  xmax/2-t->h_char*10,ymax/2+t->v_char/2);
	(*t->vector)(xmax/2+t->h_char*10,ymax/2+t->v_char/2);
	(*t->vector)(xmax/2+t->h_char*10,ymax/2-t->v_char/2);
	(*t->vector)(xmax/2-t->h_char*10,ymax/2-t->v_char/2);
	(*t->vector)(xmax/2-t->h_char*10,ymax/2+t->v_char/2);
	(*t->put_text)(xmax/2-t->h_char*10,ymax/2,
		"12345678901234567890");
	/* test justification */
	(void) (*t->justify_text)(LEFT);
	(*t->put_text)(xmax/2,ymax/2+t->v_char*6,"left justified");
	str = "centre+d text";
	if ((*t->justify_text)(CENTRE))
		(*t->put_text)(xmax/2,
				ymax/2+t->v_char*5,str);
	else
		(*t->put_text)(xmax/2-strlen(str)*t->h_char/2,
				ymax/2+t->v_char*5,str);
	str = "right justified";
	if ((*t->justify_text)(RIGHT))
		(*t->put_text)(xmax/2,
				ymax/2+t->v_char*4,str);
	else
		(*t->put_text)(xmax/2-strlen(str)*t->h_char,
				ymax/2+t->v_char*4,str);
	/* test text angle */
	str = "rotated ce+ntred text";
	if ((*t->text_angle)(1)) {
		if ((*t->justify_text)(CENTRE))
			(*t->put_text)(t->v_char,
				ymax/2,str);
		else
			(*t->put_text)(t->v_char,
				ymax/2-strlen(str)*t->h_char/2,str);
	}
	else {
	    (void) (*t->justify_text)(LEFT);
	    (*t->put_text)(t->h_char*2,ymax/2-t->v_char*2,"Can't rotate text");
	}
	(void) (*t->justify_text)(LEFT);
	(void) (*t->text_angle)(0);
	/* test tic size */
	(*t->move)(xmax/2+t->h_tic*2,0);
	(*t->vector)(xmax/2+t->h_tic*2,t->v_tic);
	(*t->move)(xmax/2,t->v_tic*2);
	(*t->vector)(xmax/2+t->h_tic,t->v_tic*2);
	(*t->put_text)(xmax/2+t->h_tic*2,t->v_tic*2+t->v_char/2,"test tics");
	/* test line and point types */
	x = xmax - t->h_char*4 - t->h_tic*4;
	y = ymax - t->v_char;
	for ( i = -2; y > t->v_char; i++ ) {
		(*t->linetype)(i);
		(void) sprintf(label,"%d",i);
		if ((*t->justify_text)(RIGHT))
			(*t->put_text)(x,y,label);
		else
			(*t->put_text)(x-strlen(label)*t->h_char,y,label);
		(*t->move)(x+t->h_char,y);
		(*t->vector)(x+t->h_char*4,y);
		if ( i >= -1 )
			(*t->point)(x+t->h_char*4+t->h_tic*2,y,i);
		y -= t->v_char;
	}
	/* test some arrows */
	(*t->linetype)(0);
	x = xmax/4;
	y = ymax/4;
	xl = t->h_tic*5;
	yl = t->v_tic*5;
	(*t->arrow)(x,y,x+xl,y,TRUE);
	(*t->arrow)(x,y,x+xl/2,y+yl,TRUE);
	(*t->arrow)(x,y,x,y+yl,TRUE);
	(*t->arrow)(x,y,x-xl/2,y+yl,FALSE);
	(*t->arrow)(x,y,x-xl,y,TRUE);
	(*t->arrow)(x,y,x-xl,y-yl,TRUE);
	(*t->arrow)(x,y,x,y-yl,TRUE);
	(*t->arrow)(x,y,x+xl,y-yl,TRUE);
	/* and back into text mode */
	(*t->text)();
}


#ifdef PC
/* 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 
   with binary mode. */
void
reopen_binary()
{
char filename[MAX_ID_LEN+1];

	if (strcmp(outstr,"STDOUT")) {
		(void) fclose(outfile);
		(void) strcpy(filename,outstr+1);	/* remove quotes */
		filename[strlen(filename)-1] = '\0';
		if ( (outfile = fopen(filename,"wb")) == (FILE *)NULL ) {
			if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
				os_error("cannot reopen file with binary type; output unknown",
					NO_CARET);
			} 
			else {
	os_error("cannot reopen file with binary type; output reset to ascii", 
					NO_CARET);
			}
		}
	}
}
#endif

#ifdef vms
/* these are needed to modify terminal characteristics */
#include <descrip.h>
#include <iodef.h>
#include <ttdef.h>
#include <tt2def.h>
#include <dcdef.h>
#include <ssdef.h>
#include <stat.h>
#include <fab.h>
static unsigned short   chan;
static int  old_char_buf[3], cur_char_buf[3];
$DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");

char *vms_init()
/*
 * Determine if we have a regis terminal
 * and save terminal characteristics
*/
{
   /* Save terminal characteristics in old_char_buf and
   initialise cur_char_buf to current settings. */
   int i;
   sys$assign(&sysoutput_desc,&chan,0,0);
   sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
   for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
   sys$dassgn(chan);

   /* Test if terminal is regis */
   if ((cur_char_buf[2] & TT2$M_REGIS) == TT2$M_REGIS) return("regis");
   return(NULL);
}

void
vms_reset()
/* set terminal to original state */
{
   int i;
   sys$assign(&sysoutput_desc,&chan,0,0);
   sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
   for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
   sys$dassgn(chan);
}

void
term_mode_tek()
/* set terminal mode to tektronix */
{
   long status;
   if (outfile != stdout) return; /* don't modify if not stdout */
   sys$assign(&sysoutput_desc,&chan,0,0);
   cur_char_buf[0] = 0x004A0000 | DC$_TERM | (TT$_TEK401X<<8);
   cur_char_buf[1] = (cur_char_buf[1] & 0x00FFFFFF) | 0x18000000;

   cur_char_buf[1] &= ~TT$M_CRFILL;
   cur_char_buf[1] &= ~TT$M_ESCAPE;
   cur_char_buf[1] &= ~TT$M_HALFDUP;
   cur_char_buf[1] &= ~TT$M_LFFILL;
   cur_char_buf[1] &= ~TT$M_MECHFORM;
   cur_char_buf[1] &= ~TT$M_NOBRDCST;
   cur_char_buf[1] &= ~TT$M_NOECHO;
   cur_char_buf[1] &= ~TT$M_READSYNC;
   cur_char_buf[1] &= ~TT$M_REMOTE;
   cur_char_buf[1] |= TT$M_LOWER;
   cur_char_buf[1] |= TT$M_TTSYNC;
   cur_char_buf[1] |= TT$M_WRAP;
   cur_char_buf[1] &= ~TT$M_EIGHTBIT;
   cur_char_buf[1] &= ~TT$M_MECHTAB;
   cur_char_buf[1] &= ~TT$M_SCOPE;
   cur_char_buf[1] |= TT$M_HOSTSYNC;

   cur_char_buf[2] &= ~TT2$M_APP_KEYPAD;
   cur_char_buf[2] &= ~TT2$M_BLOCK;
   cur_char_buf[2] &= ~TT2$M_DECCRT3;
   cur_char_buf[2] &= ~TT2$M_LOCALECHO;
   cur_char_buf[2] &= ~TT2$M_PASTHRU;
   cur_char_buf[2] &= ~TT2$M_REGIS;
   cur_char_buf[2] &= ~TT2$M_SIXEL;
   cur_char_buf[2] |= TT2$M_BRDCSTMBX;
   cur_char_buf[2] |= TT2$M_EDITING;
   cur_char_buf[2] |= TT2$M_INSERT;
   cur_char_buf[2] |= TT2$M_PRINTER;
   cur_char_buf[2] &= ~TT2$M_ANSICRT;
   cur_char_buf[2] &= ~TT2$M_AVO;
   cur_char_buf[2] &= ~TT2$M_DECCRT;
   cur_char_buf[2] &= ~TT2$M_DECCRT2;
   cur_char_buf[2] &= ~TT2$M_DRCS;
   cur_char_buf[2] &= ~TT2$M_EDIT;
   cur_char_buf[2] |= TT2$M_FALLBACK;

   status = sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
   if (status == SS$_BADPARAM) {
      /* terminal fallback utility not installed on system */
      cur_char_buf[2] &= ~TT2$M_FALLBACK;
      sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
   }
   else {
      if (status != SS$_NORMAL)
         lib$signal(status,0,0);
   }
   sys$dassgn(chan);
}

void
term_mode_native()
/* set terminal mode back to native */
{
   int i;
   if (outfile != stdout) return; /* don't modify if not stdout */
   sys$assign(&sysoutput_desc,&chan,0,0);
   sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
   for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
   sys$dassgn(chan);
}

void
term_pasthru()
/* set terminal mode pasthru */
{
   if (outfile != stdout) return; /* don't modify if not stdout */
   sys$assign(&sysoutput_desc,&chan,0,0);
   cur_char_buf[2] |= TT2$M_PASTHRU;
   sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
   sys$dassgn(chan);
}

void
term_nopasthru()
/* set terminal mode nopasthru */
{
   if (outfile != stdout) return; /* don't modify if not stdout */
   sys$assign(&sysoutput_desc,&chan,0,0);
   cur_char_buf[2] &= ~TT2$M_PASTHRU;
   sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
   sys$dassgn(chan);
}

void
reopen_binary()
/* close the file outfile outfile and reopen it with binary type
   if not already done or outfile == stdout */
{
   stat_t stat_buf;
   char filename[MAX_ID_LEN+1];
   if (outfile != stdout) { /* don't modify if not stdout */
      if (!fstat(fileno(outfile),&stat_buf)) {
         if (stat_buf.st_fab_rfm != FAB$C_FIX) {
            /* modify only if not already done */
            (void) fclose(outfile);
            (void) strcpy(filename,outstr+1);   /* remove quotes */
            filename[strlen(filename)-1] = '\0';
            (void) delete(filename);
            if ((outfile = fopen(filename,"wb","rfm=fix","bls=512","mrs=512"))
                == (FILE *)NULL ) {
               if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
                 os_error("cannot reopen file with binary type; output unknown",
                           NO_CARET);
               }
               else {
          os_error("cannot reopen file with binary type; output reset to ascii",
                           NO_CARET);
               }
            }
         }
      }
      else{
         os_error("cannot reopen file with binary type; output remains ascii",
                  NO_CARET);
      }
   }
}

void
fflush_binary()
{
   typedef short int INT16;     /* signed 16-bit integers */
   register INT16 k;            /* loop index */
   if (outfile != stdout) {
       /* Stupid VMS fflush() raises error and loses last data block
          unless it is full for a fixed-length record binary file.
          Pad it here with NULL characters. */
       for (k = (INT16)((*outfile)->_cnt); k > 0; --k)
          putc('\0',outfile);
       fflush(outfile);
   }
}
#endif
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term.h version [5f83094932].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * $Id: term.h,v 3.26 92/03/24 22:34:17 woo Exp Locker: woo $
 *
 */

/* GNUPLOT - term.h */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

/*
 * 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 */
#ifndef MSDOS

#ifdef AMIGA_LC_5_1
#define AMIGASCREEN	/* Amiga custom screen */

#else /* AMIGA_LC_5_1 */

#ifdef AMIGA_AC_5
#define AMIGASCREEN	/* Amiga custom screen */
#endif
#define AED		/* AED 512 and AED 767 */
#define AIFM		/* Adobe Illustrator Format */
#define BITGRAPH	/* BBN BitGraph */
/* #define CGI		/* SCO CGI */
/* #define IRIS4D	/* IRIS4D series computer */
#define KERMIT		/* MS-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 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 */

#endif /* AMIGA_LC_5_1 */

#ifndef AMIGA_LC_5_1

#define DXY800A		/* Roland DXY800A plotter */

#define HP2648		/* HP2648, HP2647 */
#define HP26		/* HP2623A and maybe others */
#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) */

#else /* AMIGA_LC_5_1 */
#define FIG 	  	/* Fig graphics language */

#endif /* AMIGA_LC_5_1 */

#define NEC		/* NEC CP6 pinwriter printer */
#define STARC		/* Star Color Printer */
#define TANDY60		/* Tandy DMP-130 series 60-dot per inch graphics */
#define V384		/* Vectrix 384 and tandy color printer */

#endif /* MSDOS */

/* These terminals can be used on any system */
#define DUMB

#define HPGL		/* HP7475, HP7220 plotters, and (hopefully) lots of others */

#define PBM		/* PBMPLUS portable bitmap */
#define POSTSCRIPT	/* Postscript */

/* #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 EPS60		/* Epson-style 60-dot per inch printers */
#define EPSONP		/* Epson LX-800, Star NL-10, NX-1000 and lots of others */
#define HPLJII		/* HP LaserJet II */
#define HPLJIII		/* HP LaserJet III */
#define LATEX		/* LATEX picture environment */

/* 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 */

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































Deleted r34.1/plot/term.h.original version [b9c9ebaa89].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* GNUPLOT - term.h */
/*
 * Copyright (C) 1986, 1987, 1990, 1991   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.
 * 
 * Send your comments or suggestions to 
 *  pixar!info-gnuplot@sun.com.
 * This is a mailing list; to join it send a note to 
 *  pixar!info-gnuplot-request@sun.com.  
 * Send bug reports to
 *  pixar!bug-gnuplot@sun.com.
 */

/*
 * 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 */
#ifndef MSDOS

#ifdef AMIGA_LC_5_1
#define AMIGASCREEN	/* Amiga custom screen */

#else /* AMIGA_LC_5_1 */

#ifdef AMIGA_AC_5
#define AMIGASCREEN	/* Amiga custom screen */
#endif
#define AED		/* AED 512 and AED 767 */
#define BITGRAPH	/* BBN BitGraph */
/* #define CGI		/* SCO CGI */
/* #define IRIS4D	/* IRIS4D series computer */
#define KERMIT		/* MS-Kermit Tektronix 4010 emulator */
#define FIG 	  	/* Fig graphics language */
#define REGIS		/* ReGis graphics (vt125, vt220, vt240, Gigis...) */
#define SELANAR		/* Selanar */
/* #define SUN		/* Sun Microsystems Workstation */
#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 */

#endif /* AMIGA_LC_5_1 */

#define DXY800A		/* Roland DXY800A plotter */

#define HP2648		/* HP2648, HP2647 */
#define HP26		/* HP2623A and maybe others */
#define HP75		/* HP7580, and probably other HPs */
#define IMAGEN  	/* Imagen laser printers (300dpi) (requires -Iterm also) */

#define NEC		/* NEC CP6 pinwriter printer */
#define PRESCRIBE	/* Kyocera Laser printer */
#define QMS		/* QMS/QUIC laserprinter (Talaris 1200 and others) */
#define STARC		/* Star Color Printer */
#define TANDY60		/* Tandy DMP-130 series 60-dot per inch graphics */
#define V384		/* Vectrix 384 and tandy color printer */

#endif /* MSDOS */

/* These terminals can be used on any system */
#define DUMB

#define HPGL		/* HP7475, HP7220 plotters, and (hopefully) lots of others */

#define POSTSCRIPT	/* Postscript */

/* #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 EPS60		/* Epson-style 60-dot per inch printers */
#define EPSONP		/* Epson LX-800, Star NL-10, NX-1000 and lots of others */
#define HPLJII		/* HP LaserJet II */
#define LATEX		/* LATEX picture environment */

/* 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 */

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































Deleted r34.1/plot/term/README version [3c4dd357a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
DOCUMENTATION FOR GNUPLOT TERMINAL DRIVER WRITERS
By Russell Lang 1/90

Information on each terminal device driver is contained in term.c and
the term/*.trm files.  Each driver is contained in a .trm file and is 
#include'd into term.c.  Each driver has a set of initialisers in 
term.c for term_tbl[], an array of struct termentry.

Here is the definition of the struct termentry from plot.h:

struct termentry {
	char *name;
	char *description;
	unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
	FUNC_PTR options,init,reset,text,scale,graphics,move,vector,linetype,
		put_text,text_angle,justify_text,point,arrow;
};

Here's a brief description of each variable:

The char *name is a pointer to a string containing the name
of the terminal.  This name is used by the 'set terminal' and 
'show terminal' commands.  
The name must be unique and must not be confused with an abbreviation 
of another name.  For example if the name "postscript" exists, it is not
possible to have another name "postscript2".
Keep the name under 15 characters.

The char *description is a pointer to a string containing a
description of the terminal, which is displayed in response
to the 'set terminal' command.  
Keep the description under 60 characters.

xmax is the maximum number of points in the x direction.  
The range of points used by gnuplot is 0 to xmax-1.

ymax is the maximum number of points in the y direction.  
The range of points used by gnuplot is 0 to ymax-1.

v_char is the height of characters, in the same units as xmax and ymax.
The border for labelling at the top and bottom of the plot is 
calculated using v_char.  
v_char is used as the vertical line spacing for characters.

h_char is the width of characters, in the same units as xmax and ymax.
The border for labelling at the left and right of the plot is 
calculated using h_char.  
If the _justify_text function returns FALSE, h_char is used to justify 
text right or centre.  If characters are not fixed width, then the 
_justify_text function must correctly justify the text.

v_tic is the vertical size of tics along the x axis, 
in the same units as ymax.

h_tic is the horizontal size of tics along the y axis, 
in the same units as xmax.


Here's a brief description of what each term.c function does:

_options()  Called when terminal type is selected.  
This procedure should parse options on the command line.  A list of the 
currently selected options should be stored in term_options[] in a form 
suitable for use with the set term command.  term_options[] is used by 
the save command.  Use options_null() if no options are available. 

_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...

_reset()  Called when gnuplot is exited, the output device changed or
the terminal type changed.  This procedure should reset the device, 
possibly flushing a buffer somewhere or generating a form feed.

_scale(xs,ys) Called just before _graphics(). This takes the x and y
scaling factors as information. If the terminal would like to do its
own scaling, it returns TRUE. Otherwise, it can ignore the information
and return FALSE: do_plot will do the scaling for you. null_scale is
provided to do just this, so most drivers can ignore this function
entirely. The Latex driver is currently the only one providing its own
scaling.

_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 immediately 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.

_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.

_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 0 or greater.  
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 and upwards are used for plots 0 and upwards.
If _linetype() is called with lt greater than the available line types, 
it should map it to one of the available line types.
Most drivers provide 9 different linetypes (lt is 0 to 8).

_put_text(x,y,str)  Called to display text at the (x,y) position, 
while in graphics mode.   The text should be vertically (with respect 
to the text) justified about (x,y).  The text is rotated according 
to _text_angle and then horizontally (with respect to the text)
justified according to _justify_text.

_text_angle(ang)  Called to rotate the text angle when placing the y label.
If ang = 0 then text is horizontal.  If ang = 1 then text is vertically
upwards.  Returns TRUE if text can be rotated, FALSE otherwise.

_justify_text(mode)  Called to justify text left, right or centre.
If mode = LEFT then text placed by _put_text is flushed left against (x,y).
If mode = CENTRE then centre of text is at (x,y).  
If mode = RIGHT then text is placed flushed right against (x,y).
Returns TRUE if text can be justified
Returns FALSE otherwise and then _put_text assumes text is flushed left;
justification of text is then performed by calculating the text width
using strlen(text) * h_char.

_point(x,y,point)  Called to place a point at position (x,y).
point is -1 or an integer from 0 upwards.  
6 point types (numbered 0 to 5) are normally provided.  
Point type -1 is a dot.
If point is more than the available point types then it should 
be mapped back to one of the available points.
Two _point() functions called do_point() and line_and_point() are 
provided in term.c and should be suitable for most drivers.  
do_point() draws the points in the current line type.
If your driver uses dotted line types (generally because it is
monochrome), you should use line_and_point() which changes to 
line type 0 before drawing the point.  line type 0 should be solid.

_arrow(sx,sy,ex,ey,head)  Called to draw an arrrow from (sx,sy) to (ex,ey).
A head is drawn on the arrow if head = TRUE.
An _arrow() function called do_arrow() is provided in term.c which will
draw arrows using the _move() and _vector() functions.  
Drivers should use do_arrow unless it causes problems.

The following should illustrate the order in which calls to these
routines are made:

  _init()
    _scale(xs,ys)
    _graphics()
      _linetype(lt)
      _move(x,y)
      _vector(x,y)
	  _point(x,y,point)
      _text_angle(angle)
      _justify(mode)
      _put_text(x,y,text)
      _arrow(sx,sy,ex,ey)
    _text()
    _graphics()
      .
      .
    _text()
  _reset()


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































Deleted r34.1/plot/term/aed.trm version [12dc069e45].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * $Id: aed.trm,v 3.26 92/03/24 22:34:46 woo Exp Locker: woo $
 */

/* GNUPLOT - aed.trm */
/*
 * Copyright (C) 1990, 1991, 1992
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   AED terminals
 *
 * AUTHORS
 *     Colin Kelley, Thomas Williams, Russell Lang
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define AED_XMAX 768
#define AED_YMAX 575

#define AED_XLAST (AED_XMAX - 1)
#define AED_YLAST (AED_YMAX - 1)

#define AED_VCHAR	13
#define AED_HCHAR	8
#define AED_VTIC	8
#define AED_HTIC	7

/* slightly different for AED 512 */
#define AED5_XMAX 512
#define AED5_XLAST (AED5_XMAX - 1)

AED_init()
{
	fprintf(outfile,
	"\033SEN3DDDN.SEC.7.SCT.0.1.80.80.90.SBC.0.AAV2.MOV.0.9.CHR.0.FFD");
/*   2            3     4                5     7    6       1
	1. Clear Screen
	2. Set Encoding
	3. Set Default Color
	4. Set Backround Color Table Entry
	5. Set Backround Color
	6. Move to Bottom Lefthand Corner
	7. Anti-Alias Vectors
*/
}


AED_graphics()
{
	fprintf(outfile,"\033FFD\033");
}


AED_text()
{
	fprintf(outfile,"\033MOV.0.9.SEC.7.XXX");
}



AED_linetype(linetype)
int linetype;
{
static int color[2+9] = { 7, 1, 6, 2, 3, 5, 1, 6, 2, 3, 5 };
static int type[2+9] = { 85, 85, 255, 255, 255, 255, 255, 85, 85, 85, 85 };

	if (linetype >= 10)
		linetype %= 10;
	fprintf(outfile,"\033SLS%d.255.",type[linetype+2]);
	fprintf(outfile,"\033SEC%d.",color[linetype+2]);
}



AED_move(x,y)
int x,y;
{
	fprintf(outfile,"\033MOV%d.%d.",x,y);
}


AED_vector(x,y)
int x,y;
{
	fprintf(outfile,"\033DVA%d.%d.",x,y);
}


AED_put_text(x,y,str)
int x,y;
char str[];
{
	AED_move(x,y - AED_VCHAR/2 + 2);
	fprintf(outfile,"\033XXX%s\033",str);
}


#define hxt (AED_HTIC/2)
#define hyt (AED_VTIC/2)

AED_reset()
{
	fprintf(outfile,"\033SCT0.1.0.0.0.SBC.0.FFD");
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































Deleted r34.1/plot/term/ai.trm version [4d9a4fc980].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*
 * $Id: ai.trm,v 3.26 92/03/24 22:35:00 woo Exp Locker: woo $
 */

/* GNUPLOT - ai.trm */
/*
 * Copyright (C) 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *     aifm
 *
 * AUTHORS
 *  Ray Ghanbari
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 * The 'aifm' driver produces files editable by Adobe Illustrator 3.0
 * To change font to Courier and font size to 20pts use 
 * 'set term aifm "Courier" 20'.
 * To switch to color output use
 * 'set term aifm color'.
 */


/* AIFM driver by Ray Ghanbari, ray@mtl.mit.edu, 
 *	based on PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */

char ai_font[MAX_ID_LEN+1] = "Times-Roman" ; /* name of font */
int ai_fontsize = 14;					 /* size of font in pts */
BOOLEAN ai_color = FALSE;
BOOLEAN ai_stroke = FALSE;
int ai_page=0;			/* page count */
int ai_path_count=0; 	/* count of lines in path */
int ai_ang=0;			/* text angle */
enum JUSTIFY ai_justify=LEFT;	/* text is flush left */


#define AI_XOFF	50	/* page offset in pts */
#define AI_YOFF	50

#define AI_XMAX 5000
#define AI_YMAX 3500

#define AI_XLAST (AI_XMAX - 1)
#define AI_YLAST (AI_YMAX - 1)

#define AI_VTIC (AI_YMAX/80)
#define AI_HTIC (AI_YMAX/80)

#define AI_SC (10.0)				/* scale is 1pt = 10 units */
#define AI_LW (0.5*AI_SC)		/* linewidth = 0.5 pts */

#define AI_VCHAR (14*AI_SC)		/* default is 14 point characters */
#define AI_HCHAR (14*AI_SC*6/10)


AI_options()
{
	extern struct value *const_express();
	extern double real();

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"d$efault")) {
			ai_color=FALSE;
			strcpy(ai_font,"Times-Roman");
			ai_fontsize = 14;
			c_token++;
		}
	}

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"m$onochrome")) {
			ai_color=FALSE;
			c_token++;
		}
		else if (almost_equals(c_token,"c$olor")) {
			ai_color=TRUE;
			c_token++;
		}
	}

	if (!END_OF_COMMAND && isstring(c_token)) {
		quote_str(ai_font,c_token);
		c_token++;
	}

	if (!END_OF_COMMAND) {
		/* We have font size specified */
		struct value a;
		ai_fontsize = (int)real(const_express(&a));
		c_token++;
		term_tbl[term].v_char = (unsigned int)(ai_fontsize*AI_SC);
		term_tbl[term].h_char = (unsigned int)(ai_fontsize*AI_SC*6/10);
	}

	sprintf(term_options,"%s \"%s\" %d",
		ai_color ? "color" : "monochrome",ai_font,ai_fontsize);
}


AI_init()
{
struct termentry *t = &term_tbl[term];
int i;
	ai_page = 0;
	fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-1.2\n");
	fprintf(outfile,"%%%%BoundingBox: %d %d %d %d\n", AI_XOFF,AI_YOFF,
		(int)((AI_XMAX)/AI_SC+0.5+AI_XOFF), 
		(int)((AI_YMAX)/AI_SC+0.5+AI_YOFF) );
	fprintf(outfile,"%%%%Template:\n");
	fprintf(outfile,"%%%%EndComments\n");
	fprintf(outfile,"%%%%EndProlog\n");
}


AI_graphics()
{
struct termentry *t = &term_tbl[term];
	ai_page++;
/*	fprintf(outfile,"%%%%Page: %d %d\n",ai_page,ai_page);*/
	fprintf(outfile,"0 G\n");
	fprintf(outfile,"1 j\n");
	fprintf(outfile,"1 J\n");
	fprintf(outfile,"u\n");
	ai_path_count = 0;
	ai_stroke = FALSE;
}


AI_text()
{
	if (ai_stroke) {
		fprintf(outfile,"S\n");
		ai_stroke = FALSE;
	}
	fprintf(outfile,"U\n");
	ai_path_count = 0;
}


AI_reset()
{
	fprintf(outfile,"%%%%Trailer\n");
/*	fprintf(outfile,"%%%%Pages: %d\n",ai_page);*/
}


AI_linetype(linetype)
int linetype;
{
	if (ai_stroke) {
		fprintf(outfile,"S\n");
		ai_stroke = FALSE;
	}
	switch(linetype) {
		case -2 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC*2.0);
				if (ai_color) {
					fprintf(outfile,"0 0 0 1 K\n");
				}
				else {				
					fprintf(outfile,"[] 0 d\n");
				}
				break;
				
		case -1 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC/2.0);
				if (ai_color) {
					fprintf(outfile,"0 0 0 1 K\n");
				}
				else {				
					fprintf(outfile,"[1 2] 0 d\n");
				}
				break;
				
		case 0 :  fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"1 0 1 0 K\n");
				}
				else {				
					fprintf(outfile,"[] 0 d\n");
				}
				break;
				
		case 1 :  fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"1 1 0 0 K\n");
				}
				else {				
					fprintf(outfile,"[4 2] 0 d\n");
				}
				break;
				
		case 2 :  fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0 1 1 0 K\n");
				}
				else {				
					fprintf(outfile,"[2 3] 0 d\n");
				}
				break;
				
		case 3 :  fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0 1 0 0 K\n");
				}
				else {				
					fprintf(outfile,"[1 1.5] 0 d\n");
				}
				break;
				
		case 4 :  fprintf(outfile,"%f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"1 0 0 0 K\n");
				}
				else {				
					fprintf(outfile,"[5 2 1 2] 0 d\n");
				}
				break;
				
		case 5 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0 0 1 0 K\n");
				}
				else {				
					fprintf(outfile,"[4 3 1 3] 0 d\n");
				}
				break;
				
		case 6 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0 0 0 1 K\n");
				}
				else {				
					fprintf(outfile,"[2 2 2 4] 0 d\n");
				}
				break;
				
		case 7 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0 0.7 1 0 K\n");
				}
				else {				
					fprintf(outfile,"[2 2 2 2 2 4] 0 d\n");
				}
				break;
				
		case 8 : fprintf(outfile,"%.2f w\n",AI_LW/AI_SC);
				if (ai_color) {
					fprintf(outfile,"0.5 0.5 0.5 0 K\n");
				}
				else {				
					fprintf(outfile,"[2 2 2 2 2 2 2 4] 0 d\n");
				}
				break;
		}
				
	ai_path_count = 0;
}


AI_move(x,y)
unsigned int x,y;
{
	if (ai_stroke) fprintf(outfile,"S\n");
	fprintf(outfile,"%.2f %.2f m\n", x/AI_SC, y/AI_SC);
	ai_path_count += 1;
	ai_stroke = TRUE;
}


AI_vector(x,y)
unsigned int x,y;
{
	fprintf(outfile,"%.2f %.2f l\n", x/AI_SC, y/AI_SC);
	ai_path_count += 1;
	ai_stroke = TRUE;
	if (ai_path_count >= 400) {
		fprintf(outfile,"S\n%.2f %.2f m\n",x/AI_SC,y/AI_SC);
		ai_path_count = 0;
	}
}


AI_put_text(x,y,str)
unsigned int x, y;
char *str;
{
char ch;
	if (ai_stroke) {
		fprintf(outfile,"S\n");
		ai_stroke = FALSE;
	}
	switch(ai_justify) {
		case LEFT :   fprintf(outfile,"/_%s %d 0 0 0 z\n",ai_font,ai_fontsize);
			break;
		case CENTRE : fprintf(outfile,"/_%s %d 0 0 1 z\n",ai_font,ai_fontsize);
			break;
		case RIGHT :  fprintf(outfile,"/_%s %d 0 0 2 z\n",ai_font,ai_fontsize);
			break;
	}
	if (ai_ang==0) {
		fprintf(outfile,"[ 1 0 0 1 %.2f %.2f] e\n",
			x/AI_SC,y/AI_SC - ai_fontsize/3.0);
	}
	else {
		fprintf(outfile,"[ 0 1 -1 0 %.2f %.2f] e\n",
			x/AI_SC - ai_fontsize/3.0,y/AI_SC);
	}
		
	putc('(',outfile);
	ch = *str++;
	while(ch!='\0') {
		if ( (ch=='(') || (ch==')') || (ch=='\\') )
			putc('\\',outfile);
		putc(ch,outfile);
		ch = *str++;
	}
	fprintf(outfile,") t\nT\n");
	ai_path_count = 0;
}

int AI_text_angle(ang)
int ang;
{
	ai_ang=ang;
	return TRUE;
}

int AI_justify_text(mode)
enum JUSTIFY mode;
{
	ai_justify=mode;
	return TRUE;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/amiga.trm version [2a39f5430c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
 * $Id: amiga.trm,v 3.26 92/03/24 22:34:45 woo Exp Locker: woo $
 */

/* GNUPLOT - amiga.trm */
/*
 * Copyright (C) 1991, 1992
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   Amiga Custom Screen
 *
 * AUTHORS
 *   Carsten Steger
 * 
 *   Pat R. Empleo      Slightly modified for Aztec C v5.2a (beta); sort of
 *   08/27/91           supports overscan; for large WB 2.0 virtual screens,
 *                      we limit the plot size so we don't have to scroll
 *                      around (not fun).
 *
 *   Carsten Steger     Modified to support Kickstart 2.0.
 *   09/11/91           Opens a text overscan screen when used with WB 2.0.
 *                      Discerns between NTSC and PAL Amigas when used with
 *                      WB 1.3 and lower.
 *
 *   Pat R. Empleo      Defined some 2.0 stuff in order to get Aztec C to
 *   09/20/91           work with Carsten's new code (see above).  When
 *                      KS/WB 2.0 support gets implemented in Aztec C, this
 *                      kludge will get deleted! 
 *                      (Aztec C release 5.2 beta)
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#ifdef AMIGA_AC_5
#include <intuition/intuitionbase.h>
#include <intuition/screens.h>
#include <graphics/text.h>
#include <graphics/gfxbase.h>
#else
/* You will have to use the Kickstart 2.0 header files for this to compile */
#include <exec/types.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/diskfont.h>
#endif

extern char *getenv(),*strchr();

#define AMIGA_XMAX 640
#define AMIGA_YMAX 512

#define AMIGA_VCHAR (12)
#define AMIGA_HCHAR (8)
#define AMIGA_VTIC (AMIGA_YMAX/80)
#define AMIGA_HTIC (AMIGA_XMAX/80)
/* The origin is in the upper left hand corner, so we have to translate */
/* and flip the coordinates: */
#define AMIGA_VTF(y) (AMIGA_ymax-1-(y))


struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *DiskfontBase;
static struct TextAttr AMIGA_Font = {
  "topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT
};
static struct TextFont *AMIGA_TextFont;
static struct NewScreen AMIGA_NewScreen = {
  0,0,AMIGA_XMAX,AMIGA_YMAX,4,15,0,HIRES|LACE,
  CUSTOMSCREEN|SCREENBEHIND|SCREENQUIET,NULL,NULL,NULL,NULL
};
static struct Screen *AMIGA_Screen;
static UWORD AMIGA_Colors [] = {
  0x000,0xfff,0xbbb,0x0f0,0xf00,0x00f,0x3ca,0xf0f,
  0x94d,0x0ff,0x82f,0xff0,0x0af,0xc5e,0xfa2,0xf44
};
static int AMIGA_slinetype;
static enum JUSTIFY AMIGA_justify = LEFT;
static unsigned int AMIGA_ymax,AMIGA_xmax; 
static WORD AMIGA_cwd,AMIGA_cht,AMIGA_bsl,AMIGA_vadj;
static struct TagItem AMIGA_ScrTagList[] = {
  {SA_Overscan,OSCAN_TEXT},{TAG_DONE,0}
};


AMIGA_reset()
{
  if (AMIGA_TextFont != NULL) CloseFont(AMIGA_TextFont);
  if (DiskfontBase != NULL) CloseLibrary(DiskfontBase);
  if (AMIGA_Screen != NULL) CloseScreen(AMIGA_Screen);
  if (IntuitionBase != NULL) CloseLibrary(IntuitionBase);
  if (GfxBase != NULL) CloseLibrary(GfxBase);
  AMIGA_TextFont = NULL;
  DiskfontBase = NULL;
  AMIGA_Screen = NULL;
  IntuitionBase = NULL;
  GfxBase = NULL;
}


AMIGA_init()
{
  static char fontname[80],*gnufont,*search;
  static int fsize;
  static char *test_str =
    " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
  static WORD test_len,test_pxl;


#ifdef AMIGA_LC_5_1
  /* Install exit trap in case of abnormal termination (see below). */
  int AMIGA_exit();
  if (!onexit(&AMIGA_exit)) {
    fprintf(stderr,"Couldn't set exit trap\n");
    exit(20);
  }
#endif
  GfxBase = OpenLibrary("graphics.library",0);
  if (GfxBase == NULL) {
    fprintf(stderr,"No Graphics-Library\n");
    AMIGA_reset();
    exit(20);
  }
  IntuitionBase = OpenLibrary("intuition.library",0);
  if (IntuitionBase == NULL) {
    fprintf(stderr,"No Intuition-Library\n");
    AMIGA_reset();
    exit(20);
  }
  if (IntuitionBase->LibNode.lib_Version <= 34) {
    /* We compute the vertical resolution for those poor NTSC-souls   :-)   */
    if (GfxBase->DisplayFlags & PAL) AMIGA_ymax = 512;
    else AMIGA_ymax = 400;
    AMIGA_xmax = 640;
    AMIGA_NewScreen.Width = AMIGA_xmax;
    AMIGA_NewScreen.Height = AMIGA_ymax;
    AMIGA_Screen = OpenScreen(&AMIGA_NewScreen);
    if (AMIGA_Screen == NULL) {
      fprintf(stderr,"No Screen\n");
      AMIGA_reset();
      exit(20);
    }
  } else {
    /* Kickstart 2.0 support */
    AMIGA_NewScreen.Width = STDSCREENWIDTH;
    AMIGA_NewScreen.Height = STDSCREENHEIGHT;
    AMIGA_Screen = OpenScreenTagList(&AMIGA_NewScreen,AMIGA_ScrTagList);
    if (AMIGA_Screen == NULL) {
      fprintf(stderr,"No Screen\n");
      AMIGA_reset();
      exit(20);
    }
    AMIGA_xmax = AMIGA_Screen->Width;
    AMIGA_ymax = AMIGA_Screen->Height;
  }
  term_tbl[term].xmax = AMIGA_xmax;
  term_tbl[term].ymax = AMIGA_ymax;
  gnufont = getenv("GNUFONT");
  if (gnufont != NULL ) {
    search = strchr(gnufont,'/');
    if (search != NULL) {
      *search++ = '\0';
      strncpy(fontname,gnufont,74);
      strcat(fontname,".font");
      sscanf(search,"%d",&fsize);
      /* Avoid opening "diskfont.library" if a built-in font is desired */
      if ((strcmp("topaz.font",fontname) == 0) &&
        ((fsize == TOPAZ_EIGHTY) || (fsize == TOPAZ_SIXTY))) {
        AMIGA_Font.ta_Name = fontname;
        AMIGA_Font.ta_YSize = fsize;
        AMIGA_Font.ta_Style = FS_NORMAL;
        AMIGA_Font.ta_Flags = FPF_ROMFONT;
        AMIGA_TextFont = OpenFont(&AMIGA_Font);
        if (AMIGA_TextFont != NULL) 
          SetFont(&AMIGA_Screen->RastPort,AMIGA_TextFont);
      } else {
        DiskfontBase = OpenLibrary("diskfont.library",0);
        if (DiskfontBase != NULL) {
          AMIGA_Font.ta_Name = fontname;
          AMIGA_Font.ta_YSize = fsize;
          AMIGA_Font.ta_Style = FS_NORMAL;
          AMIGA_Font.ta_Flags = FPF_ROMFONT|FPF_DISKFONT;
          AMIGA_TextFont = OpenDiskFont(&AMIGA_Font);
          if (AMIGA_TextFont != NULL)
            SetFont(&AMIGA_Screen->RastPort,AMIGA_TextFont);
        }
      }
    }
  }
  /* Width of characters: This works better for proportional fonts than */
  /* AMIGA_Screen->RastPort.TxWidth + AMIGA_Screen->RastPort.TxSpacing */
  test_len = strlen(test_str);
  test_pxl = TextLength(&AMIGA_Screen->RastPort,test_str,test_len);
  AMIGA_cwd = test_pxl / test_len;
  AMIGA_cht = AMIGA_Screen->RastPort.TxHeight; /* Height of characters */
  AMIGA_bsl = AMIGA_Screen->RastPort.TxBaseline; /* Reference line */
  /* Amount by which characters have to be shifted upwards to be */
  /* vertically justified: */
  AMIGA_vadj = AMIGA_bsl / 2;
  term_tbl[term].v_char = AMIGA_cht + 4; /* So lines won't be too close */
  term_tbl[term].h_char = AMIGA_cwd;
  LoadRGB4(&AMIGA_Screen->ViewPort,AMIGA_Colors,16);
  RemakeDisplay();
  AMIGA_slinetype = 1;
  SetAPen(&AMIGA_Screen->RastPort,AMIGA_slinetype);
  SetDrMd(&AMIGA_Screen->RastPort,JAM1);
}


AMIGA_text()
{
  char c;

  c = getc(stdin); /* This is extremely ugly... Yuk !!!!   >:-(   */
  ungetc(c,stdin); /* Maybe someone else will find a better solution */
  ScreenToBack(AMIGA_Screen);
}


AMIGA_graphics()
{
  SetRast(&AMIGA_Screen->RastPort,0);
  SetAPen(&AMIGA_Screen->RastPort,AMIGA_slinetype);
  ScreenToFront(AMIGA_Screen);
}


AMIGA_move(x,y)
unsigned int x,y;
{
  if ((x>=AMIGA_xmax) || (y>=AMIGA_ymax)) return;
  Move(&AMIGA_Screen->RastPort,x,AMIGA_VTF(y));
}


AMIGA_vector(x,y)
unsigned int x,y;
{
  if ((x>=AMIGA_xmax) || (y>=AMIGA_ymax)) return;
  Draw(&AMIGA_Screen->RastPort,x,AMIGA_VTF(y));
}


AMIGA_linetype(linetype)
int linetype;
{
  if (linetype >= 13) linetype %= 13;
  AMIGA_slinetype = linetype+3;
  SetAPen(&AMIGA_Screen->RastPort,AMIGA_slinetype);
}


AMIGA_put_text(x,y,str)
unsigned int x,y;
char *str;
{
  LONG len,tx_len;
  WORD xmin,xmax,ymin,ymax;

  len = strlen(str);
  tx_len = TextLength(&AMIGA_Screen->RastPort,str,len);
  switch (AMIGA_justify) {
    case LEFT:
      xmin = x;
      xmax = x + tx_len;
      break;
    case CENTRE:
      xmin = x - tx_len / 2;
      xmax = x + tx_len - tx_len / 2; /* aviod roundoff errors ! */
      break;
    case RIGHT:
      xmin = x - tx_len;
      xmax = x;
      break;
  }
  ymin = AMIGA_VTF(y) - AMIGA_vadj;
  ymax = ymin + AMIGA_cht;
  /* Check if character-string lies completely within the screen: */
  if ((xmax >= AMIGA_xmax) || (ymin < 0) || (ymax >= AMIGA_ymax)) return;
  Move(&AMIGA_Screen->RastPort,xmin,ymin+AMIGA_bsl);
  Text(&AMIGA_Screen->RastPort,str,len);
}


int AMIGA_justify_text(mode)
enum JUSTIFY mode;
{
  AMIGA_justify = mode;
  return TRUE;
}


/* This function is mainly included if the program terminates abnormally */
/* and the screen and libraries are still open. It closes down all opened */
/* libraries and screens. This happens e.g. when loading "bivariat.demo" */
/* and the stack is smaller than 70000 bytes. */
#ifdef AMIGA_LC_5_1
int AMIGA_exit(rc)
int rc;
{
  AMIGA_reset();
  return rc;
}
#endif
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/apollo.trm version [00abcc74e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/*
 * $Id: apollo.trm,v 3.26 92/03/24 22:34:58 woo Exp Locker: woo $
 */

/* GNUPLOT - apollo.trm */
/*
    Apollo terminal driver for GNUplot.

    Open a pad for the graphics, and use GPR routines.  For additional
    speed, we do the graphics to a separate bitmap, and the blt the
    entire bitmap to the display.  When the user specifies an output
    file name, however, we draw directly to the screen, so the graphics
    are written to the file correctly.  Thus, the user can save the
    graphics in a file, to be viewed later.  If we try the bitmap
    trick, it looks funny.

    Ray Lischner (uunet!mntgfx!lisch)
    4 October 1989	file created for GNUplot 1.1
    26 March 1990	updated for GNUplot 2.0
    30 October 1991	fixed minor problem in apollo_tic_sizes
*/

#include <apollo/base.h>
#include <apollo/error.h>
#include <apollo/pad.h>
#include <apollo/gpr.h>

/* default tick sizes for small windows */
#define APOLLO_VTIC	 6
#define APOLLO_HTIC	 6	

/* issue an error message, using additional text "s" */
#define apollo_error(s)	error_$print_name(status, (s), strlen(s))

/* if "status" indicates an error, then issue an error message */
#define apollo_check(s)	if (status.all != status_$ok) apollo_error(s)

static ios_$id_t stream = -1;           /* the stream for the pad */
static gpr_$bitmap_desc_t screen_desc;  /* the screen's bitmap */
static gpr_$bitmap_desc_t bitmap_desc;  /* the graphics bitmap */
static gpr_$attribute_desc_t attr;      /* attribute block for saved bitmap */
static short draw_width;                /* default GPR draw width */
static name_$long_pname_t font_name;    /* font path name */
static int APOLLO_XMAX, APOLLO_YMAX;    /* window size */
static boolean use_bitmap;              /* use a separate bitmap? */

/* return whether stdout is a DM pad */
apollo_isa_pad()
{
    status_$t status;
    pad_$isa(1, &status);
    return (status.all == status_$ok);
}

/*
    Find out what the default font is for the pad, and save the
    character height and width information.

    Note that we must save the font file name because we need
    to reload the font file everytime the window changes size.
*/
static void apollo_font_info(struct termentry* tbl, char* fname)
{
    short fwidth, fheight, flen;
    status_$t status;

    /* get the font size & update the termentry table */
    pad_$inq_font(stream, &fwidth, &fheight, fname, name_$long_pnamlen_max,
		  &flen, &status);
    apollo_check("inq_font");
    fname[flen] = '\0';

    tbl->v_char = fheight;
    tbl->h_char = fwidth;
}

/*
    Initialize all the GPR stuff.  To save time, we draw into a separate
    bitmap, and then blt it onto the screen all at once.  This results
    in 5-10 times speed-up in the graphics, with only a little
    complication.  Most of the complication is right here, making sure
    we allocate the right bitmaps, etc., in the right order.  The rest
    is in APOLLO_text(), where we actually BLT the bitmap onto the screen.
    Everything else is the same.

    The bitmaps have the same size as the window.  If the window changes
    size, then the bitmaps retain the same size, so the user sees part
    of the plot or a lot of space around the plot.  Drawing a new plot,
    or replotting the previous one causes APOLLO_graphics() to see if
    the window has changed size, in which case the GPR is terminated,
    and this routine is called again.  Thus, make sure any changes
    preserve this ability.  Anything that should only be done once
    to the pad should be handled by APOLLO_init().

    By the way, we save the current draw width, to be used later
    for drawing extra wide lines.  This way we don't need to know
    anything about the current output device characteristics;
    we can just draw the default width, or twice the default width, etc.
*/
static void apollo_gpr_init(struct termentry* tbl, pad_$window_desc_t* window)
{
    gpr_$offset_t size;
    short fontid;
    status_$t status;

    size.x_size = APOLLO_XMAX = tbl->xmax = window->width;
    size.y_size = APOLLO_YMAX = tbl->ymax = window->height;

    /* now initialize GPR */
    gpr_$init(gpr_$frame, stream, size, 1, &screen_desc, &status);
    apollo_check("gpr_$init");

    if (use_bitmap)
    {
	/* allocate the bitmap and its attribute block */
	gpr_$allocate_attribute_block(&attr, &status);
	apollo_check("allocate_attribute_block");

	gpr_$allocate_bitmap(size, 1, attr, &bitmap_desc, &status);
	apollo_check("allocate_bitmap");

	gpr_$set_bitmap(bitmap_desc, &status);
	apollo_check("set_bitmap");
    }

    /* set the font file */
    gpr_$load_font_file(font_name, strlen(font_name), &fontid, &status);
    apollo_check(font_name);

    gpr_$set_text_font(fontid, &status);
    apollo_check("set_text_font");

    gpr_$inq_draw_width(&draw_width, &status);
    apollo_check("inq_draw_width");
}

/*
    Determine the tick sizes to be used for labelling borders.
    By default, we use 1/50 of the window size, which looks nice to me.
    If this makes the ticks too small, however, we use a minimum
    size, to make sure they are visible.  The minimum size was also
    determined experimentally.

    Feel free to changes the sizes to something you feel looks better.

    This routine must be called after apollo_gpr_init(), because we
    need to know the window size, as stored in the termentry table.
*/
static void apollo_tic_sizes(struct termentry* tbl)
{
    /* base the tick size on the window size */
    tbl->v_tic = tbl->ymax / 50;
    if (tbl->v_tic < APOLLO_VTIC)
	tbl->v_tic = APOLLO_VTIC;
    tbl->h_tic = tbl->xmax / 50;
    if (tbl->h_tic < APOLLO_HTIC)
	tbl->h_tic = APOLLO_HTIC;
}

/*
    Terminate the GPR.  This is called whenever the window size
    changes, and we need to reinitialize the GPR.  I assume that
    calling gpr_$terminate() also deallocates the bitmaps and
    attribute blocks because deallocating the screen's bitmap
    causes terminate() to think GPR has already been terminated.

    Since this can be called many times, make sure nothing
    drastic is done here, like closing the stream to the pad.
    The only actions should be those that will be reinitialized
    by apollo_gpr_init().
*/
static void apollo_gpr_terminate()
{
    status_$t status;

    gpr_$terminate(false, &status);
    apollo_check("terminate");
}

/*
    Initialize the graphics.  This is called once, so we do things
    here that should be done exactly once, such as opening the window.
    I like to give windows names, so it is obvious what the window's
    contents are, but this causes a transcript to be kept in a file
    whose name is the window's name.  This might be nice in some
    circumstances, but to me it is a nuisance, so the file is
    deleted immediately.  The name is unlikely to appear normally,
    so there should be little interference with users' normal files.
    If the user has explicitly set the output file, however, then
    we use that name, and do not delete the file.  Thus, the
    user can get a metafile of the plot.  We can tell if the
    output file has been set because outstr is "STDOUT".  Otherwise,
    outstr is the filename, in single quotes.  We need to strip
    the quotes to make the file name.

    The DM defaults are used for window sizes and positions.  If
    the user doesn't like it, he or she can change is and issue
    a replot command (assuming a plot has already been generated).

    Note, also, that we must call pad_$set_scale() or else
    pad_$inq_windows() returns scaled values, which is not what
    we want.  Setting the scale to one (1) turns off the scaling,
    so we get real pixel sizes.

    Finally, we get the name and size of the default font.  The
    name is kept, as explained earlier.  Then we can initialize
    the GPR stuff.

    Note that there is a way that APOLLO_init() gets called more
    than once.  If the user issues the "set terminal apollo" command
    more than once, then this is called, so we need to make sure
    that we do not keep creating windows.

    An alternative strategy would be to interpret multiple "set term
    apollo"s to mean create multiple windows.  The user could only
    access the most recent window because GNUplot has no concept of
    multiple terminals.  The user would, in fact, have no way of
    removing old windows because they are still active.  We could try
    catching keyboard events to see if the user presses EXIT, but I do
    not want to start getting into that mess.  If the user really
    wants this kind of functionality, then he or she can run gnuplot
    multiple times.  I think that is a lot cleaner, don't you?
*/
APOLLO_init()
{
    /* only initialize once */
    if (stream == -1)
    {
	extern char outstr[];
	struct termentry* tbl;
	pad_$window_desc_t window;
	name_$long_name_t wname;
	short wnum;			/* junk needed by pad_$inq_windows() */
	boolean unlink_wname;
	status_$t status;

	tbl = &term_tbl[term];

	/* make the window name unique, with "gnuplot" in the label */
	if (strcmp(outstr, "STDOUT") == 0)
	{
	    sprintf(wname, "gnuplot-%d", getpid());
	    unlink_wname = true;
	}
	else
	{
	    /* strip the single quotes around the file name */
	    strcpy(wname, outstr + 1);
	    wname[strlen(wname) - 1] = '\0';
	    unlink_wname = false;
	}

	use_bitmap = unlink_wname;

	/* use the default window position and size */
	window.top = window.left = window.width = window.height = 0;
	pad_$create_window(wname, strlen(wname), pad_$transcript, 1, window,
			   &stream, &status);
	apollo_check("create_window");

	/* if this is not the user's name, then delete the file */
	if (unlink_wname)
	    unlink(wname);

	/* remove all scaling, to revert to pixel units, not char. units */
	pad_$set_scale(stream, 1, 1, &status);
	apollo_check("set_scale");

	/* get rid of the window when the program exits */
	pad_$set_auto_close(stream, 1, true, &status);
	apollo_check("set_auto_close");

	/* now determine the window size & update the termentry table */
	pad_$inq_windows(stream, &window, 1, &wnum, &status);
	apollo_check("inq_windows");

	/* the order of the next three calls is important */
	apollo_font_info(tbl, font_name);
	apollo_gpr_init(tbl, &window);
	apollo_tic_sizes(tbl);
    }
}

/*
    Prepare for graphics output.  Since this is what the user wants to
    do when preparing a new plot, this is a meaningful time to see if
    the window has changed size.  Thus, we avoid mucking about with
    asynchronous traps, and we avoid the bigger problem of dealing
    with a half-finished plot when the window changes size.

    Simply put, get the current window size, and if it has changed,
    then get rid of the old bitmaps, etc., and allocate new ones at
    the new size.  We also need to update the termentry table.
    If the window stays the same size, then just clear it.
*/
static void apollo_redo_window(pad_$window_desc_t* window)
{
    struct termentry* tbl = &term_tbl[term];
    status_$t status;

    /* the order of the following calls is important */
    apollo_gpr_terminate();
    apollo_gpr_init(tbl, window);
    apollo_tic_sizes(tbl);
}

APOLLO_graphics()
{
    pad_$window_desc_t window;
    short wnum;
    status_$t status;

    pad_$inq_windows(stream, &window, 1, &wnum, &status);
    apollo_check("inq_windows");

    if (window.width != APOLLO_XMAX || window.height != APOLLO_YMAX)
	apollo_redo_window(&window);
    else
    {
	gpr_$clear(0, &status);
	apollo_check("clear");
    }
}

/* set a line type:
   -2 heavy, solid	(border)
   -1 heavy, dotted	(axis)
   0  solid		(normal)
   1  dots		(other curves)
   2  short dash
   3  long dash
   4  dash dot

   Apparently, GPUplot draws a lot of short line segments, and each
   one starts a new pattern.  This makes the patterns somewhat useless,
   but one can still tell the difference between solid, dotted, and
   dashed lines.  The utility of fancier styles is limited, however.

   On a color workstation, we should use different colors, but I
   don't have one.
*/

/*
    To draw different line styles on an Apollo, we use two different
    parameters.  One is a line thickness, which is just an integral
    multiple of the default line thickness.  The second is a 16-bit
    pattern that is repeated.  We could use fancier patterns, since
    GPR supports up to 64-bits, but, as I explained earlier, this
    really does not buy us anything.

    I used patterns that do not start with all bits on because
    GNUplot seems to use lots of short line segments to draw
    a curve, and this might make a very curvey plot seem like
    a solid line, regardless of pattern.  I don't want to start
    with too many zeros, however, or else the curve might not
    appear at all!  All the patterns, therefore, start with one
    bit on.  The rest of the bits determine the true pattern.

    By examining graphics.c, we see that linetype -2 is used exclusively
    for the border, -1 for the axes, and the non-negative integers for
    the curves.  We use heavy lines for the border and axes, and normal
    width lines for the curves.

    Since C arrays start at zero, make sure all the offsets are correct,
    so that it is easy to access the array with -2...n linetypes.
*/

typedef struct {
    short width;
    short pattern;
} APOLLO_LINE;

static APOLLO_LINE apollo_lines[] = {
    { 2, ~0 },		/* heavy, solid */
    { 2, 0x6666 },	/* heavy, dotted */
    { 1, ~0 },		/* normal */
    { 1, 0xAAAA },	/* dotted */
    { 1, 0xC3C3 },	/* short dash */
    { 1, 0xE01F },	/* long dash */
    { 1, 0x87F8 },	/* dash dot */
    { 1, 0x6666 },	/* big dots */
};

#define BITS_PER_LINETYPE	16

/* apollo_line(-2) is the border style, etc. */
#define apollo_line(x)		apollo_lines[(x)+2]
#define apollo_pattern(x)	&apollo_line(x).pattern
#define apollo_width(x)		apollo_line(x).width

#define APOLLO_MIN_LINE		(-2)
#define APOLLO_MAX_LINE		(sizeof(apollo_lines)/sizeof(*apollo_lines)-2)

/* set the line style */
APOLLO_linetype(ltype)
int ltype;
{
    status_$t status;

    if (ltype < APOLLO_MIN_LINE)
	ltype = APOLLO_MIN_LINE;
    if (ltype >= APOLLO_MAX_LINE)
	ltype %= APOLLO_MAX_LINE;

    gpr_$set_line_pattern(1, apollo_pattern(ltype), BITS_PER_LINETYPE, &status);
    apollo_check("set_line_pattern");

    gpr_$set_draw_width(draw_width * apollo_width(ltype), &status);
    apollo_check("set_draw_width");
}

/* issue an error message that includes an (x, y) coordinate */
static void apollo_xy_error(char* s, int x, int y, status_$t status)
{
    char buffer[128];

    sprintf(buffer, "%s(%d, %d)", s, x, y);
    apollo_error(buffer);
}

#define apollo_xy_check(s)	\
    if (status.all != status_$ok) apollo_xy_error((s), x, y, status)

/*
    Note that GNUplot and GPR have reversed ideas of where the Y origin is.
    This means subtracting the Y coordinate from Y max.
*/
#define plot_to_gpr(y)		(APOLLO_YMAX - (y))

/* move to a new position */
APOLLO_move(unsigned int x, unsigned int y)
{
    status_$t status;

    gpr_$move((gpr_$coordinate_t) x, plot_to_gpr(y), &status);
    apollo_xy_check("move");
}

/* draw a line to a new position */
APOLLO_vector(unsigned int x, unsigned int y)
{
    status_$t status;

    gpr_$line((gpr_$coordinate_t) x, plot_to_gpr(y), &status);
    apollo_xy_check("line");
}

/*
    On terminals, this switches to text mode.  The real meaning,
    however, is that the graphics are finished.  This means we can
    now display the saved bitmap.
*/
APOLLO_text()
{
    if (use_bitmap)
    {
	static gpr_$position_t pos;		/* always zero */
	gpr_$window_t window;
	status_$t status;

	/* bitblt the entire bitmap to the entire window */
	window.window_base.x_coord = 0;
	window.window_base.y_coord = 0;
	window.window_size.x_size = APOLLO_XMAX;
	window.window_size.y_size = APOLLO_YMAX;

	gpr_$set_bitmap(screen_desc, &status);
	apollo_check("set_bitmap(screen_desc)");

	gpr_$pixel_blt(bitmap_desc, window, pos, &status);
	apollo_check("bitblt");

	gpr_$set_bitmap(bitmap_desc, &status);
	apollo_check("set_bitmap(bitmap_desc)");
    }
}

APOLLO_text_angle(ang)
int ang;
{
    status_$t status;

    gpr_$set_text_path(ang ? gpr_$up : gpr_$right, &status);
    apollo_check("set_text_path");
    return TRUE;
}

static enum JUSTIFY apollo_text_mode;

APOLLO_justify_text(mode)
enum JUSTIFY mode;
{
    apollo_text_mode = mode;
    return TRUE;
}

/*
    Write "str" right justified on row "row".  A row is assumed to
    have whatever height the current text has.  Make sure the
    text does not cover the tick marks.
*/
APOLLO_put_text(x, y, str)
unsigned int x, y;
char str[];
{
    gpr_$offset_t size;
    status_$t status;

    gpr_$inq_text_extent(str, strlen(str), &size, &status);
    apollo_check("inq_text_extent");

    y -= size.y_size / 2;	/* center around "y" */
    switch (apollo_text_mode)
    {
    case LEFT:
	break;
    case CENTRE:
	x -= size.x_size / 2;
	break;
    case RIGHT:
	x -= size.x_size;
	break;
    }
    APOLLO_move(x, y);

    gpr_$text(str, strlen(str), &status);
    apollo_check("put_text");
}

/* reset the graphics state and terminate */
APOLLO_reset()
{
    if (stream != -1)
    {
	apollo_gpr_terminate();
	stream = -1;
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/bigfig.trm version [9cfef9368f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * $Id: bigfig.trm,v 3.26 92/03/24 22:35:50 woo Exp Locker: woo $
 */

/* GNUPLOT - fig.trm */
/*
 * Copyright (C) 1990, 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Fig graphics language
 *
 * AUTHORS
 *  Micah Beck, David Kotz
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 */
 
/*
 * Original for Fig code output by Micah Beck, 1989
 * Department of Computer Science, Cornell University
 * Updated by David Kotz for gnuplot 2.0
 * More efficient output by Ian Dall
 * Increased size of plot by Ian Dall
 */
 
#define BFIG_HTIC       (7*FIG_RES/80)
#define BFIG_VTIC       (7*FIG_RES/80)
#define BFIG_HCHAR      (9*FIG_RES/80)
#define BFIG_FONT_S     (16)
#define BFIG_VCHAR      ((BFIG_FONT_S)*FIG_RES/80)  /* height in pixels of font
        */
 
#define BFIG_ARROW_WIDTH BFIG_HTIC
#define BFIG_ARROW_HEIGHT BFIG_HTIC
 
 
 
/* 7 inches wide by 5 inches high */
#define BFIG_XMAX (8 * FIG_RES)
#define BFIG_YMAX (5 * FIG_RES)
 
#define BFIG_XOFF (FIG_RES/2)
#define BFIG_YOFF (FIG_RES/2)
 
 
BFIG_vector(ux,uy)
     unsigned int ux,uy;
{
  int x=ux, y=uy;
 
  if (FIG_polyvec_stat != FIG_poly_part)
    {
      fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f  %d %d\n",
              O_POLYLINE, T_POLYLINE,
              FIG_type, 1, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_spacing,
              0, 0);
      fprintf(outfile, "%d %d",
              BFIG_XOFF + FIG_posx, BFIG_YMAX + BFIG_YOFF - FIG_posy);
      FIG_poly_vec_cnt = 1;
      FIG_polyvec_stat = FIG_poly_part;
    }
  fprintf(outfile, " %d %d",
          BFIG_XOFF +  x, BFIG_YMAX + BFIG_YOFF-y);
  FIG_poly_vec_cnt++;
  if (FIG_poly_vec_cnt > 50)
    FIG_poly_clean(FIG_polyvec_stat);
 
  FIG_posx = x;
  FIG_posy = y;
}
 
 
 
 
BFIG_arrow(sx, sy, ex, ey, head)
        int sx, sy;     /* start coord */
        int ex, ey;     /* end coord */
	BOOLEAN head;
{
	FIG_poly_clean(FIG_polyvec_stat);
        fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f  %d %d\n",
                O_POLYLINE, T_POLYLINE,
                FIG_type, 1, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_spacing,
                head ? 1 : 0, 0);
        /* arrow line */
	if ( head )
		fprintf(outfile, "%d %d %.3f %.3f %.3f\n",
                	0, 0, 1.0,
			(double)BFIG_ARROW_WIDTH, (double)BFIG_ARROW_HEIGHT);
        fprintf(outfile, "%d %d %d %d 9999 9999\n",
                BFIG_XOFF + sx, BFIG_YOFF + BFIG_YMAX - sy,
		BFIG_XOFF + ex, BFIG_YOFF + BFIG_YMAX - ey);
 
        FIG_posx = ex;
        FIG_posy = ey;
}
 
BFIG_put_text(x, y, str)
        int x, y;
        char *str;
{
  if (strlen(str) == 0) return;
  FIG_poly_clean(FIG_polyvec_stat);
    y = y - BFIG_VCHAR/2;               /* assuming vertical center justified */
 
    fprintf(outfile, "%d %d %d %d %d %d %d %6.3f %d %d %d %d %d %s\01\n",
                  O_TEXT, FIG_justify,
                  FIG_ROMAN_FONT, BFIG_FONT_S, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_angle,
                  1, BFIG_VCHAR, BFIG_HCHAR*strlen(str), BFIG_XOFF + x,
        BFIG_YMAX + BFIG_YOFF-y, str);
}
 
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































Deleted r34.1/plot/term/cgi.trm version [8e80dc423e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * $Id: cgi.trm,v 3.26 92/03/24 22:34:47 woo Exp Locker: woo $
 */

/* GNUPLOT - cgi.trm */
/*
 * Copyright (C) 1990, 1991, 1992 Ronald Florence
 *
 * Permission is hereby granted for unlimited non-commercial
 * use of this code, on condition that the copyright
 * notices are left intact and any modifications to the source
 * code are noted as such.  No warranty of any kind is implied
 * or granted for this material.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports SCO CGI drivers
 *
 * AUTHOR
 *   Ronald Florence <ron@mlfarm.com>
 */

#ifdef VGA_MONO
static short rgb[16][3] = {
  0,    0,      0,      /* Black        */
  1000,	1000,	1000,	/* White	*/
  800,	800,	0,	/* Red		*/
  0,	600,	0,	/* Green	*/
  0,	800,	800,	/* Blue		*/
  1000,	1000,	400,	/* Yellow	*/
  0,	600,	600,	/* Cyan		*/
  600,	600,	600,	/* Magenta	*/
  800,	800,	0,	/* Brown	*/
  600,	600,	600,	/* Lt. Grey	*/
  400,	600,	400,	/* Dark Grey	*/
  400,	600,	1000,	/* Lt. Blue	*/
  400,	1000,	400,	/* Lt Green	*/
  400,	1000,	1000,	/* Lt Cyan	*/
  1000,	600,	400,	/* Lt Red	*/
  600,	600,	1000	/* Lt Magenta	*/
};
#endif

#define CGI_XMAX	32767
#define CGI_YMAX	32767
#define CGI_VTIC	(CGI_YMAX / 75)
#define CGI_HTIC	term_tbl[term].h_tic
#define CGI_VCHAR	term_tbl[term].v_char
#define CGI_HCHAR	term_tbl[term].h_char
#define CRT		(gout[45] == 0)
#define CGICOLORS	gout[13]
#define CGILINES	gout[6]
#define CGIROTATES	gout[36]
#define CGITEXTALIGN	gout[48]

static short gout[66];
static short cgidev;
static short vect[4];
static short gin[19] = {
 0,	/* default aspect ratio */
 1,	/* solid line */
 1,	/* line color */
 1,	/* marker type . */
 1,	/* marker color */
 1,	/* graphics text font */
 1,	/* graphics text color */
 0,	/* fill interior style */
 0,	/* fill style index */
 1,	/* fill color index */
 1 	/* prompt for paper changes */
 };

char	*cgidriver, *getenv();


CGI_init()
{
  if (getenv(cgidriver = "CGIDISP") == NULL)
    HCGI_init();
}


HCGI_init()
{
  if (getenv(cgidriver = "CGIPRNT") == NULL)
    int_error("no CGI driver", NO_CARET);
}


CGI_graphics()
{
  int	i, aspect;
  char *s;
  short font_cap[9];
  char	err_str[80];

  if ( (s=getenv("ASPECT")) != NULL && (aspect=atoi(s)) >= 0 && aspect <= 3 )
    gin[0] = aspect;
  for (i = 0; cgidriver[i]; i++) 
    gin[11+i] = cgidriver[i];
  gin[18] = ' ';

  if (v_opnwk(gin, &cgidev, gout) < 0) 
    {
      sprintf(err_str, "CGI error %d opening %s", -vq_error(), cgidriver);
      int_error(err_str, NO_CARET);
    }
  vqt_representation(cgidev, 9, font_cap);
  CGI_VCHAR = font_cap[8] * 3 / 2;
  CGI_HCHAR = font_cap[7];
  CGI_HTIC = CGI_VTIC * ((double) gout[1] / (double) gout[4]) / 
			((double) gout[0] / (double) gout[3]);
#ifdef VGA_MONO
  if (CGICOLORS > 2)
    vsc_table(cgidev, 0, CGICOLORS, rgb);
#endif
}


CGI_text()
{
  if (CRT)  
    {
      short ptin[2];
      char  strin[2];
      
      ptin[0] = 0;
      ptin[1] = 0;
      vrq_string(cgidev, 1, 0, ptin, strin);
    }
  v_clswk(cgidev);
}


CGI_reset()
{
}


CGI_move(x, y)
     int x, y;
{
  vect[0] = x;
  vect[1] = y;
}

CGI_vector(x, y)
     int x, y;
{
  vect[2] = x;
  vect[3] = y;
  v_pline(cgidev, 2, vect);
  vect[0] = x;
  vect[1] = y;
}


CGI_linetype(linetype)
     int linetype;
{
  short lcolor;

  if (CGICOLORS > 2) 
    {
      lcolor = (linetype + 2) % CGICOLORS + 1;
      vsl_color(cgidev, lcolor);
      vsm_color(cgidev, lcolor);
    }
  vsl_type(cgidev, (linetype < 1) ? 1 : (linetype % CGILINES) + 1);
}


CGI_put_text(x, y, str)
int x, y;
char *str;
{
  v_gtext(cgidev, (short) x, (short) y, str);
}


CGI_text_angle(ang)
int	ang;
{
  if (!CGIROTATES)
    return FALSE;
				/* angles are 1/10 degree ccw */
  vst_rotation(cgidev, (ang) ? 900 : 0);
  return TRUE;
}


CGI_justify_text(mode)
enum JUSTIFY mode;
{
  short hor_in, hor_out, vert_out;

  if (!CGITEXTALIGN)
    return FALSE;

  switch (mode)
    {
    case LEFT:   hor_in = 0; break;
    case CENTRE: hor_in = 1; break;
    case RIGHT:  hor_in = 2; break;
    }
  vst_alignment(cgidev, hor_in, 1, &hor_out, &vert_out); 
  return TRUE;
}


#define POINT_TYPES 6

CGI_point(x,y,num)
     int x, y, num;
{
  short  point[2];
  static short cgimarker[POINT_TYPES] = {1, 2, 6, 4, 5, 3};
			              /* .  +  <> [] X  * */
  if (num < 0)
    {
      CGI_move(x, y);
      CGI_vector(x, y);
    }
  else
    {
      vsm_type(cgidev, cgimarker[num % POINT_TYPES]);
      point[0] = x;
      point[1] = y;
      v_pmarker(cgidev, 1, point);
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































Deleted r34.1/plot/term/dumb.trm version [5c226a3119].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
 * $Id: dumb.trm,v 3.26 92/03/24 22:34:48 woo Exp Locker: woo $
 */

/* GNUPLOT - dumb.trm */
/*
 * Copyright (C) 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   DUMB terminals
 *
 * AUTHORS
 *   Francois Pinard, 91-04-03
 *           INTERNET: pinard@iro.umontreal.ca
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 */

#define DUMB_AXIS_CONST '\1'
#define DUMB_BORDER_CONST '\2'

#define DUMB_XMAX 79
#define DUMB_YMAX 24

static char *dumb_matrix = NULL;      /* matrix of characters */
static char *dumb_priority = NULL;    /* matrix of priority at each position */
static char dumb_pen;                 /* current character used to draw */
static int dumb_x;                    /* current X position */
static int dumb_y;                    /* current Y position */
static int dumb_xmax = DUMB_XMAX;
static int dumb_ymax = DUMB_YMAX;

#define DUMB_PIXEL(x,y) dumb_matrix[dumb_xmax*(y)+(x)]


dumb_set_pixel(x,y,v,p)
int x,y,v,p;
{
  if (p > dumb_priority[dumb_xmax*y+x])
    {
      dumb_matrix[dumb_xmax*y+x] = v;
      dumb_priority[dumb_xmax*y+x] = p;
    }
}


DUMB_options()
{
  int x,y;
  struct value a;
  extern struct value *const_express();
  extern double real();

  if (!END_OF_COMMAND) {
    x = (int) real(const_express(&a));
    if (!END_OF_COMMAND) {
      y = (int) real(const_express(&a));
      dumb_xmax = term_tbl[term].xmax = x;
      dumb_ymax = term_tbl[term].ymax = y;
    }
  }

  sprintf(term_options, "%d %d",dumb_xmax,dumb_ymax);
}


DUMB_init()
{
  if (dumb_matrix)
    free(dumb_matrix);

  dumb_matrix = alloc (dumb_xmax * dumb_ymax * 2, "dumb terminal");

  dumb_priority = dumb_matrix + dumb_xmax * dumb_ymax;
}


char *
DUMB_str_state()
{
   static char str[80];

   sprintf( str, "%d %d", dumb_xmax, dumb_ymax );

   return str;
}


DUMB_graphics ()
{
  int i;
  char *pm = dumb_matrix, *pp = dumb_priority;

  for ( i = dumb_xmax * dumb_ymax; i > 0; i-- ) {
    *pm++ = ' ';
    *pp++ = 0;
  }
}


DUMB_text ()
{
  int x, y, l;

  putc ('\f', outfile);
  for (y = dumb_ymax - 1; y >= 0; y--)
    {
      for (l = dumb_xmax; l > 0 && DUMB_PIXEL (l - 1, y) == ' '; l--)
       ;
      for (x = 0; x < l; x++)
       putc (DUMB_PIXEL (x, y), outfile);
      if (y > 0)
       putc ('\n', outfile);
    }
  fflush (outfile);
}


DUMB_reset()
{
  free (dumb_matrix);
  dumb_matrix = NULL;
}


DUMB_linetype(linetype)
int linetype;
{
  static char pen_type[7] = {'*', '#', '$', '%', '@', '&', '='};

  if (linetype == -2)
    dumb_pen = DUMB_BORDER_CONST;
  else if (linetype == -1)
    dumb_pen = DUMB_AXIS_CONST;
  else
    {
      linetype = linetype % 7;
      dumb_pen = pen_type[linetype];
    }
}


DUMB_move(x, y)
int x, y;
{
  dumb_x = x;
  dumb_y = y;
}


DUMB_point(x,y,point)
int x,y,point;
{
  dumb_set_pixel (x, y, point == -1 ? '.' : point % 26 + 'A', 4);
}


DUMB_vector(x,y)
int x,y;
{
  char pen, pen1;
  int priority;
  int delta;

  if (abs (y - dumb_y) > abs (x - dumb_x))
    {
      switch (dumb_pen)
       {
       case DUMB_AXIS_CONST:
         pen = ':';
         pen1 = '+';
         priority = 1;
         break;

       case DUMB_BORDER_CONST:
         pen = '|';
         pen1 = '+';
         priority = 2;
         break;

       default:
         pen = dumb_pen;
         pen1 = dumb_pen;
         priority = 3;
         break;
       }
      dumb_set_pixel (dumb_x, dumb_y, pen1, priority);
      for (delta = 1; delta < abs (y - dumb_y); delta++)
       dumb_set_pixel (dumb_x
                       + (int) ((double) (x - dumb_x) * delta / abs(y - dumb_y)
                                + 0.5),
                       dumb_y + delta * sign (y - dumb_y),
                       pen, priority);
      dumb_set_pixel (x, y, pen1, priority);
    }
  else if (abs (x - dumb_x) > abs (y - dumb_y))
    {
      switch (dumb_pen)
       {
       case DUMB_AXIS_CONST:
         pen = '.';
         pen1 = '+';
         priority = 1;
         break;

       case DUMB_BORDER_CONST:
         pen = '-';
         pen1 = '+';
         priority = 2;
         break;

       default:
         pen = dumb_pen;
         pen1 = dumb_pen;
         priority = 3;
         break;
       }
      dumb_set_pixel (dumb_x, dumb_y, pen1, priority);
      for (delta = 1; delta < abs (x - dumb_x); delta++)
       dumb_set_pixel (dumb_x + delta * sign (x - dumb_x),
                       dumb_y +
                       (int) ((double) (y - dumb_y) * delta / abs(x - dumb_x)
                              + 0.5),
                       pen, priority);
      dumb_set_pixel (x, y, pen1, priority);
    }
  else
    {
      switch (dumb_pen)
       {
       case DUMB_AXIS_CONST:	/* zero length axis */
         pen = '+';
         priority = 1;
         break;

       case DUMB_BORDER_CONST:	/* zero length border */
         pen = '+';
         priority = 2;
         break;

       default:
         pen = dumb_pen;
         priority = 3;
         break;
       }
      for (delta = 0; delta <= abs (x - dumb_x); delta++)
	dumb_set_pixel (dumb_x + delta * sign (x - dumb_x),
			dumb_y + delta * sign (y - dumb_y),
			pen, priority);
    }
  dumb_x = x;
  dumb_y = y;
}


DUMB_put_text(x,y,str)
int x, y;
char *str;
{
  int length;
  int delta;

  length = strlen(str);
  if (x + length > dumb_xmax)
    x = max (0, dumb_xmax - length);

  for (; x < dumb_xmax && *str; x++, str++)
    dumb_set_pixel (x, y, *str, 5);
}


DUMB_arrow (sx,sy,ex,ey)
int sx,sy,ex,ey;
{
  char saved_pen;
  char saved_x;
  char saved_y;

  saved_pen = dumb_pen;
  saved_x = dumb_x;
  saved_y = dumb_y;

  dumb_pen = '>';
  dumb_x = sx;
  dumb_y = sy;
  DUMB_vector (ex,ey);

  dumb_pen = saved_pen;
  dumb_x = saved_x;
  dumb_y = saved_y;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/dxf.trm version [5124258d93].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * $Id: dxf.trm,v 3.26 92/03/24 22:34:49 woo Exp Locker: woo $
 */

/* GNUPLOT - dxf.trm */
/*
 * Copyright (C) 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   AutoCad (Release 10.x) dxf file format (import with AutoCad dxfin command)
 *
 *
 * AUTHOR
 *   Florian Hiss  (fhis1231@w204zrz.zrz.tu-berlin.de)
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
*/

#define DXF_UNIT 60.0
#define LINEWIDTH 0.0351  /* default line width is 1 pt */

/* 120 (autocad units) wide by 80 (autocad units) high (default)
   use the GNUPLOT 'set size' command to change the defaults */
#define DXF_XMAX (120.0 * DXF_UNIT)
#define DXF_YMAX (80.0 * DXF_UNIT)
#define DXF_HTIC (0.01 * DXF_XMAX)  /* 1.0 percent */
#define DXF_VTIC (0.01 * DXF_YMAX)  /* 1.0 percent */
#define DXF_HCHAR (0.014 * DXF_XMAX) /* 1.4 percent */
#define DXF_VCHAR (0.026 * DXF_YMAX) /* 2.6 percent */
#define DXF_TEXTHEIGHT (0.7 * DXF_VCHAR) /* actual text height */
#define DXF_TEXTWIDTH (0.7 * DXF_HCHAR) /* actual text width,
 only a guess, we don't know the width of a character of given height
 of the AutoCad STANDARD text font, so change it if you like */
#define DXF_LINE_TYPES 7 /* number of line types we support. see below  */
#define MAX_LAYER 7  /* number of layers used for the drawing. see below */
#define LT_SCALE 1  /* line type scaling */

static unsigned int DXF_posx;
static unsigned int DXF_posy;
static unsigned int dxf_linetype; /* linetype is mapped to a layer. see below. */
enum JUSTIFY dxf_justify = LEFT;
static float dxf_angle = 0.0; /* either 0 (horizontal) or 90.0 (vertical) */

/* text style used in the entire drawing */
static char *text_style = "STANDARD";
/* text always resides on layer 0 */
#define TEXT_LAYER 0
/* each linetype resides on its own layer. each layer has its own color.
   this avoids difficulties that AutoCad has with proper scaling of
   the linetypes.
   change the colors according to your needs */
static char *layer_name[] = {"0","1","2","3","4","5","6"};
/* the colours are white, red, yellow, green, cyan, blue, magenta.
   change them according to your needs.
   when using a black and white plotting device the colours map to different
   line thicknesses. see description of AutoCad print / plot command */
static char *layer_colour[] = {"7","1","2","3","4","5","6"};
/* support line types AutoCad has to offer by default. */
static char *layer_lines[] = {"CONTINUOUS","DASHED","HIDDEN","CENTER","PHANTOM",
			    "DOT","DASHDOT"};

static BOOLEAN vector_was_last = FALSE;

DXF_init()
{
	DXF_posx = DXF_posy = 0;
	dxf_linetype = 0;
	dxf_angle = 0.0;
	vector_was_last = FALSE;
}

DXF_graphics()
{
	register struct termentry *t = &term_tbl[term];
	int i;

	fprintf(outfile,"999\n");
	fprintf(outfile,"%% GNUPLOT: dxf file for AutoCad\n");
	fprintf(outfile,"  0\nSECTION\n  2\nHEADER\n");
	fprintf(outfile,"  9\n$EXTMIN\n");
	fprintf(outfile," 10\n0.000\n 20\n0.000\n");
	fprintf(outfile,"  9\n$EXTMAX\n");
	fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
	fprintf(outfile,"  9\n$LIMMIN\n");
	fprintf(outfile," 10\n0.000\n 20\n0.000\n");
	fprintf(outfile,"  9\n$LIMMAX\n");
	fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
	fprintf(outfile,"  9\n$TEXTSTYLE\n  7\n%s\n",text_style);
	fprintf(outfile,"  9\n$TEXTSIZE\n 40\n%-6.3f\n",DXF_TEXTHEIGHT/DXF_UNIT);
	fprintf(outfile,"  9\n$PLINEWID\n 40\n%-6.4f\n",LINEWIDTH);
	fprintf(outfile,"  9\n$LTSCALE\n  40\n%-6.3f\n",LT_SCALE);
	fprintf(outfile,"  9\n$COORDS\n 70\n  1\n");
	fprintf(outfile,"  9\n$CELTYPE\n 6\nBYLAYER\n"); /* entity line type name */
	fprintf(outfile,"  9\n$CLAYER\n  8\n0\n"); /* current layer */
	fprintf(outfile,"  9\n$CECOLOR\n 62\n   %s\n",layer_colour[0]);
	fprintf(outfile,"  9\n$MENU\n  1\nacad\n");
	fprintf(outfile,"  0\nENDSEC\n");
	fprintf(outfile,"  0\nSECTION\n  2\nTABLES\n");
	/* the linetype table */
	fprintf(outfile,"0\nTABLE\n  2\nLTYPE\n 70\n    %d\n",DXF_LINE_TYPES);
	fprintf(outfile,"0\nLTYPE\n  2\nCONTINUOUS\n 70\n    64\n");
	fprintf(outfile,"  3\nSolid line\n 72\n    65\n 73\n      0\n 40\n0.0\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nDASHED\n 70\n    64\n");
	fprintf(outfile,"  3\n__ __ __ __ __ __ __ __ __ __ __ __ __ __ __\n");
	fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.75\n 49\n0.5\n 49\n-0.25\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nHIDDEN\n 70\n    64\n");
	fprintf(outfile,"  3\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n");
	fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.375\n 49\n0.25\n 49\n-0.125\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nCENTER\n 70\n    64\n");
	fprintf(outfile,"  3\n____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____\n");
	fprintf(outfile," 72\n    65\n 73\n     4\n 40\n2.0\n 49\n1.25\n 49\n-0.25\n");
	fprintf(outfile," 49\n0.25\n 49\n-0.25\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nPHANTOM\n 70\n    64\n");
	fprintf(outfile,"  3\n_____ _ _ _____ _ _ _____ _ _ _____ _ _ ____\n");
	fprintf(outfile," 72\n    65\n 73\n     6\n 40\n2.5\n 49\n1.25\n");
	fprintf(outfile," 49\n-0.25\n 49\n0.25\n 49\n-0.25\n 49\n0.25\n 49\n-0.25\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nDOT\n 70\n    64\n");
	fprintf(outfile,"  3\n...............................................\n");
	fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.25\n 49\n0.0\n 49\n-0.25\n");
	fprintf(outfile,"  0\nLTYPE\n  2\nDASHDOT\n 70\n    64\n");
	fprintf(outfile,"  3\n__ . __ . __ . __ . __ . __ . __ . __ . __ . __\n");
	fprintf(outfile," 72\n    65\n 73\n     4\n 40\n1.0\n 49\n0.5\n 49\n-0.25\n");
	fprintf(outfile," 49\n0.0\n 49\n-0.25\n");
	fprintf(outfile,"  0\nENDTAB\n");
	/* the layer table */
	fprintf(outfile,"  0\nTABLE\n  2\nLAYER\n 70\n   %-d\n",MAX_LAYER);
	for (i = 1; i <= MAX_LAYER; i++)
		fprintf(outfile,"  0\nLAYER\n  2\n%s\n 70\n   64\n62\n   %s\n  6\n%s\n",
			layer_name[i-1],layer_colour[i-1],layer_lines[i-1]);
	fprintf(outfile,"  0\nENDTAB\n0\nENDSEC\n");
	/* no blocks for insertion */
	fprintf(outfile,"  0\nSECTION\n  2\nBLOCKS\n  0\nENDSEC\n");
	/* start the entity section */
	fprintf(outfile,"  0\nSECTION\n");
	fprintf(outfile,"  2\nENTITIES\n");
}

DXF_text()
{
	if (vector_was_last) fprintf(outfile,"  0\nSEQEND\n");
	fprintf(outfile,"  0\nENDSEC\n  0\nEOF\n");
}

DXF_linetype(linetype)
	int linetype;
{
	linetype = abs(linetype);
	linetype = linetype%DXF_LINE_TYPES;
	dxf_linetype = linetype;
}

DXF_move(x, y)
	unsigned int x, y;
{
	DXF_posx = x;
	DXF_posy = y;
	if (vector_was_last) fprintf(outfile,"  0\nSEQEND\n");
	vector_was_last = FALSE;
	fprintf(outfile,"  0\nPOLYLINE\n  8\n%s\n 66\n   1\n",layer_name[dxf_linetype]);
	fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
	fprintf(outfile,"  0\nVERTEX\n  8\n%s\n",layer_name[dxf_linetype]);
	fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
	fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
}

DXF_vector(ux, uy)
	unsigned int ux, uy;
{
	DXF_posx = ux;
	DXF_posy = uy;
	vector_was_last = TRUE;
	fprintf(outfile,"  0\nVERTEX\n  8\n%s\n",layer_name[dxf_linetype]);
	fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
	fprintf(outfile,"  10\n%-6.3f\n  20\n%-6.3f\n  30\n0.000\n",
					DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
}

DXF_put_text(x, y, str)
	int x, y;
	char str[];
{
	int stl;
	float xleftpos, yleftpos, xrightpos,yrightpos;
	/* ignore empty strings */
	if (str[0] == '\0') return;

	stl = 0; while (str[stl] != '\0') ++stl; /* get string length */

	if (vector_was_last) fprintf(outfile,"  0\nSEQEND\n");
	vector_was_last = FALSE;
	fprintf(outfile,"  0\nTEXT\n  8\n%s\n",layer_name[TEXT_LAYER]);
	if (dxf_angle != 90.0)
	{
	   switch (dxf_justify)
	   {
	   	case LEFT  : xleftpos = (float) x;
			     yleftpos = (float)(y-DXF_VCHAR/4.0);
			     xrightpos = (float)(x+stl*DXF_TEXTWIDTH);
			     yrightpos = yleftpos; break;
	   	case RIGHT : xleftpos = (float)(x-stl*DXF_TEXTWIDTH);
			     yleftpos = (float)(y-DXF_VCHAR/4.0);
			     xrightpos = (float) x;
			     yrightpos = yleftpos; break;
		case CENTRE: xleftpos = (float)(x-stl*DXF_TEXTWIDTH/2.0);
			     yleftpos = (float)(y-DXF_VCHAR/4.0);
			     xrightpos = (float) x;  /* center point */
			     yrightpos = yleftpos;
			     break;
	    }
	}
	else
	{
	    switch (dxf_justify)
	    {
	   	case LEFT  : xleftpos = (float)(x+DXF_VCHAR/4.0);
			     yleftpos = (float) y;
			     xrightpos = xleftpos;
			     yrightpos = (float)(y+stl*DXF_TEXTWIDTH); break;
	   	case RIGHT : xleftpos = (float)(x+DXF_VCHAR/4.0);
			     yleftpos = (float)(y-stl*DXF_HCHAR);
			     xrightpos = xleftpos;
			     yrightpos = (float) y; break;
		case CENTRE: xleftpos = (float)(x+DXF_VCHAR/4.0);
			     yleftpos = (float)(y-stl*DXF_TEXTWIDTH/2.0);
			     xrightpos = xleftpos;
			     yrightpos = (float) y;  /* center point */
			     break;
	    }
	}
	fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",
				xleftpos/DXF_UNIT,yleftpos/DXF_UNIT);
	fprintf(outfile," 40\n%-6.3f\n  1\n%s\n 50\n%-6.3f\n",
			DXF_TEXTHEIGHT/DXF_UNIT,str,dxf_angle);
	fprintf(outfile,"  7\n%s\n",text_style);
	if (dxf_justify != LEFT)
	{
		fprintf(outfile," 72\n%d\n",dxf_justify);
		fprintf(outfile," 11\n%-6.3f\n 21\n%-6.3f\n 31\n0.000\n",
				xrightpos/DXF_UNIT,yrightpos/DXF_UNIT);
	}
}

DXF_text_angle(angle)
	int angle;
{
	dxf_angle = 0.0;
	if (angle == 1) dxf_angle = 90.0;
	return(TRUE);
}

DXF_justify_text(mode)
	enum JUSTIFY mode;
{
	dxf_justify = mode;
	return(TRUE);
}

DXF_reset()
{
	DXF_posx = DXF_posy = 0;
}


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/dxy.trm version [099041c0a7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * $Id: dxy.trm,v 3.26 92/03/24 22:34:50 woo Exp Locker: woo $
 */

/* GNUPLOT - dxy.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Roland DXY800A plotter 
 *
 * AUTHORS
 *  Martin Yii, eln557h@monu3.OZ
 *  Further modified Jan 1990 by Russell Lang, rjl@monu1.cc.monash.oz
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define DXY_XMAX 2470
#define DXY_YMAX 1700

#define DXY_XLAST (DXY_XMAX - 1)
#define DXY_YLAST (DXY_XMAX - 1)

#define DXY_VCHAR	(56)	/* double actual height of characters */
#define DXY_HCHAR	(28)	/* actual width including spacing */
#define DXY_VTIC	(28)		
#define DXY_HTIC	(28)		

int dxy_angle = 0;

DXY_init()
{
/*
	No initialisation sequences for DXY 800A
*/
}


DXY_graphics()
{
	/* HOME, Character size 3 */
	fprintf(outfile,"H\nS3\n");
}


DXY_text()
{
/*
	No sequences needed
*/
}


DXY_linetype(linetype)
int linetype;
{
    /* select pen */
	fprintf(outfile,"J%d\n",(linetype+2)%8+1);
	switch(linetype) {
	   case -1 :  /* use dotted line for axis */
	   	    fprintf(outfile,"L1\nB50\n");
			break;
	   default :  /* use solid line for all others */
			fprintf(outfile,"L0\n");
	    		break;
   	}
}


DXY_move(x,y)
int x,y;
{
	fprintf(outfile,"M%d,%d\n",x,y);
}


DXY_vector(x,y)
int x,y;
{
	fprintf(outfile,"D%d,%d\n",x,y);
}


DXY_put_text(x,y,str)
int x, y;
char *str;
{
	if (dxy_angle == 1 ) 
		/* vertical */
		DXY_move(x + DXY_VCHAR/4,y);
	else
		/* horiz */
		DXY_move(x,y - DXY_VCHAR/4);
	fprintf(outfile,"P%s\n",str);
}


int DXY_text_angle(ang)
int ang;
{
	dxy_angle = ang;
	fprintf(outfile,"Q%d\n",ang);
	return TRUE;
}


DXY_reset()
{
	/* Home pen */
	fprintf(outfile,"H\n");
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































Deleted r34.1/plot/term/eepic.trm version [79f3efcbf8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
 * $Id: eepic.trm,v 3.26 92/03/24 22:34:51 woo Exp Locker: woo $
 */

/* GNUPLOT - eepic.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   The EEPIC macros for LaTeX. 
 *
 * AUTHORS
 *   David Kotz
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */
/*
 *  This file contains the eepic terminal driver, intended for use with the 
 *  eepic.sty macro package for LaTeX. This is an alternative to the 
 *  latex driver. You need eepic.sty, epic.sty, and a printer driver that
 *  supports the tpic \specials.
 *
 * Although dotted and dashed lines are possible with EEPIC, and are
 * tempting, they do not work well for high-sample-rate curves, mushing
 * the dashes all together into a solid line. For now anyway, the EEPIC
 * driver will have only solid lines. Anyone got a solution?
 *
 * LATEX must also be defined.
 */

#define EEPIC_PTS_PER_INCH (72.27)
#define DOTS_PER_INCH (300)	/* resolution of printer we expect to use */
#define EEPIC_UNIT (EEPIC_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */

/* 5 inches wide by 3 inches high (default) */
#define EEPIC_XMAX (5*DOTS_PER_INCH)  /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*5.0) */
#define EEPIC_YMAX (3*DOTS_PER_INCH)  /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*3.0) */

#define EEPIC_HTIC (5*DOTS_PER_INCH/72)		/* (5./EEPIC_UNIT) */
#define EEPIC_VTIC (5*DOTS_PER_INCH/72)		/* (5./EEPIC_UNIT) */
#define EEPIC_HCHAR (DOTS_PER_INCH*53/10/72)	/* (5.3/EEPIC_UNIT) */
#define EEPIC_VCHAR (DOTS_PER_INCH*11/72)	/* (11./EEPIC_UNIT) */

static unsigned int EEPIC_posx;
static unsigned int EEPIC_posy;
enum JUSTIFY eepic_justify=LEFT;
static int eepic_angle=0;

/* for DOTS point style */
#define EEPIC_TINY_DOT "\\rule{.1pt}{.1pt}"

/* POINTS */
#define EEPIC_POINT_TYPES 12	/* we supply more point types */
static char *EEPIC_points[] = {
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
    "\\makebox(0,0){$+$}",
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}",
    "\\makebox(0,0){$\\times$}",
    "\\makebox(0,0){$\\triangle$}",
    "\\makebox(0,0){$\\star$}",
    "\\circle{12}", "\\circle{18}", "\\circle{24}",
    "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
};

/* LINES */
#define EEPIC_NUMLINES 5		/* number of linetypes below */
static char *EEPIC_lines[] = {
    "\\thicklines \\path",			/* -2 border */
    "\\thinlines \\drawline[-50]",		/* -1 axes */
    "\\thinlines \\path",			/*  0 solid thin  */
    "\\thicklines \\path",			/*  1 solid thick */
    "\\Thicklines \\path",			/*  2 solid Thick */
};
/* These are other possibilities
    "\\thinlines \\dottedline{30}",
    "\\thinlines \\drawline[-30]",	
    "\\thinlines \\dottedline{60}",
    "\\thinlines \\drawline[-60]",	
    "\\thinlines \\dashline[-10]{20}[6]"
*/
static int EEPIC_type;		/* current line type */
static BOOLEAN EEPIC_inline = FALSE; /* are we in the middle of a line */
static void EEPIC_endline();	/* terminate any line in progress */
static int EEPIC_linecount = 0; /* number of points in line so far */
#define EEPIC_LINEMAX 50		/* max value for linecount */

/* ARROWS */
/* we use the same code as for LATEX */
static void best_latex_arrow(); /* figure out the best arrow */

EEPIC_init()
{
    EEPIC_posx = EEPIC_posy = 0;
    EEPIC_linetype(-1);
    fprintf(outfile, "%% GNUPLOT: LaTeX picture using EEPIC macros\n");
    fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", EEPIC_UNIT);
}


EEPIC_scale(xs, ys)
	double xs, ys;			/* scaling factors */
{
    register struct termentry *t = &term_tbl[term];

    /* we change the table for use in graphics.c and EEPIC_graphics */
    t->xmax = (unsigned int)(EEPIC_XMAX * xs);
    t->ymax = (unsigned int)(EEPIC_YMAX * ys);

    return(TRUE);
}

EEPIC_graphics()
{
    register struct termentry *t = &term_tbl[term];

    fprintf(outfile, "\\begin{picture}(%d,%d)(0,0)\n", t->xmax, t->ymax);
    fprintf(outfile, "\\tenrm\n");
}


EEPIC_text()
{
    EEPIC_endline();
    fprintf(outfile, "\\end{picture}\n");
}


EEPIC_linetype(linetype)
	int linetype;
{
    EEPIC_endline();

    if (linetype >= EEPIC_NUMLINES-2)
	 linetype %= (EEPIC_NUMLINES-2);

    EEPIC_type = linetype;
}



EEPIC_move(x,y)
	unsigned int x,y;
{
    EEPIC_endline();

    EEPIC_posx = x;
    EEPIC_posy = y;
}


EEPIC_point(x,y, number)		/* version of line_and_point */
	unsigned int x,y;
	int number;				/* type of point */
{
    EEPIC_move(x,y);
    
    /* Print the character defined by 'number'; number < 0 means 
	  to use a dot, otherwise one of the defined points. */
    fprintf(outfile, "\\put(%d,%d){%s}\n", x, y, 
		  (number < 0 ? EEPIC_TINY_DOT
		   : EEPIC_points[number % EEPIC_POINT_TYPES]));
}


EEPIC_vector(ux,uy)
	unsigned int ux,uy;
{
    if (!EEPIC_inline) {
	   EEPIC_inline = TRUE;

	   /* Start a new line. This depends on line type */
	   fprintf(outfile, "%s(%u,%u)", 
			 EEPIC_lines[EEPIC_type+2], 
			 EEPIC_posx, EEPIC_posy);
	   EEPIC_linecount = 1;
    } else {
	   /* Even though we are in middle of a path, 
	    * we may want to start a new path command. 
	    * If they are too long then latex will choke.
	    */
	   if (EEPIC_linecount++ >= EEPIC_LINEMAX) {
		  fprintf(outfile, "\n");
		  fprintf(outfile, "%s(%u,%u)", 
				EEPIC_lines[EEPIC_type+2], 
				EEPIC_posx, EEPIC_posy);
		  EEPIC_linecount = 1;
	   }
    }
    fprintf(outfile, "(%u,%u)", ux,uy);
    EEPIC_posx = ux;
    EEPIC_posy = uy;
}

static void
EEPIC_endline()
{
    if (EEPIC_inline) {
	   fprintf(outfile, "\n");
	   EEPIC_inline = FALSE;
    }
}


EEPIC_arrow(sx,sy, ex,ey, head)
	int sx,sy, ex,ey;
	BOOLEAN head;
{
    best_latex_arrow(sx,sy, ex,ey, 2, head); /* call latex routine */

    EEPIC_posx = ex;
    EEPIC_posy = ey;
}


EEPIC_put_text(x, y, str)
	int x,y;				/* reference point of string */
	char str[];			/* the text */
{
    EEPIC_endline();

    fprintf(outfile, "\\put(%d,%d)",x,y);
    switch(eepic_angle) {  
 	   case 0: {
		  switch(eepic_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{%s}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0){%s}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[r]{%s}}\n", str);
				break;
			 }
		  }
		  break;
	   }
	   case 1: {			/* put text in a short stack */
		  switch(eepic_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
				break;
			 }
		  }
		  break;
	   }	
    }
}



int EEPIC_justify_text(mode)
	enum JUSTIFY mode;
{
    eepic_justify = mode;
    return (TRUE);
}

int EEPIC_text_angle(angle)
	int angle;
{
    /* we can't really write text vertically, but this will 
	  put the ylabel centred at the left of the plot, and
	  then we'll make a \shortstack */
    eepic_angle = angle;
    return (TRUE);
}

EEPIC_reset()
{
    EEPIC_endline();
    EEPIC_posx = EEPIC_posy = 0;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/epson.trm version [78cae9dc1e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/*
 * $Id: epson.trm,v 3.26 92/03/24 22:34:52 woo Exp Locker: woo $
 */

/* GNUPLOT - epson.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  epson_lx800, nec_cp6c, nec_cp6d, nec_cp6b, starc,
 *  epson_60dpi, tandy_60dpi
 *
 * AUTHORS
 *  Russell Lang
 *  William Wilson
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/* The following epson lx800 driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* EPSON_init changes outfile to binary mode on PC's */

#ifdef EPSONP

#define EPSONXMAX	512 
#define EPSONYMAX	384

#define EPSONXLAST (EPSONXMAX - 1)
#define EPSONYLAST (EPSONYMAX - 1)

#define EPSONVCHAR		FNT5X9_VCHAR  	
#define EPSONHCHAR		FNT5X9_HCHAR		
#define EPSONVTIC		6
#define EPSONHTIC		6

EPSONinit()
{
#ifdef PC
	reopen_binary();
#endif
#ifdef vms
	reopen_binary();
#endif
}


EPSONgraphics()
{
	b_charsize(FNT5X9);
	b_makebitmap((unsigned int)(EPSONXMAX*xsize),
	             (unsigned int)(EPSONYMAX*ysize),1);
}


EPSONtext()
{
	epson_dump();
	b_freebitmap();
}


#define EPSONlinetype b_setlinetype
#define EPSONmove b_move
#define EPSONvector b_vector
#define EPSONput_text b_put_text
#define EPSON_text_angle b_text_angle

EPSONreset()
{
#ifdef vms
	fflush_binary();
#endif
}


/* output file must be binary mode for epson_dump */
epson_dump()
{
  register unsigned int x;
  int j;
	for (j=(b_ysize/8)-1; j>=0; j--) {
		/* select plotter graphics mode (square pixels) */
		fprintf(outfile,"\033J\030");	/* line feed 8/72" = 8 dots */
		fprintf(outfile,"\r\033*\005");
		(void) fputc((char)(b_xsize%256),outfile);
		(void) fputc((char)(b_xsize/256),outfile);
		for (x=0; x<b_xsize; x++) {
			(void) fputc( (char)(*((*b_p)[j]+x)), outfile );
		}
	}
#ifdef PC
	fprintf(stderr,"Print using: COPY /B\n");
#endif
}

#endif /* EPSONP */


/* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* NECinit changes outfile to binary mode for PC's */

/* Add a Monochrome NEC printer (for faster speed and line types) jdc */

#ifdef NEC

#define NECXMAX	400 
#define NECYMAX	320

#define NECXLAST (NECXMAX - 1)
#define NECYLAST (NECYMAX - 1)

#define NECVCHAR		FNT5X9_VCHAR  	
#define NECHCHAR		FNT5X9_HCHAR		
#define NECVTIC		6
#define NECHTIC		6

/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
static unsigned int neccolor[] = {1,8,4,2,10,12,6,14};
static unsigned int necpcolor[]= {0,2,1,4};

NECinit()
{
#ifdef PC
	reopen_binary();
#endif
#ifdef vms
	reopen_binary();
#endif
}


/* Monochrome only NEC CP6 printer (set term nec_cp6m or nec_cp6d). */
/* will probably work with NEC P6 printer */
NECMgraphics()
{
	b_charsize(FNT5X9);
	b_makebitmap((unsigned int)(NECXMAX*xsize),
	             (unsigned int)(NECYMAX*ysize),1);
}

/* Color ribbon in NEC CP6 printer (set term nec_cp6c) */
NECCgraphics()
{
	b_charsize(FNT5X9);
	b_makebitmap((unsigned int)(NECXMAX*xsize),
	             (unsigned int)(NECYMAX*ysize),4);
}


NECdraft_text()
{
	nec_draft_dump();
	b_freebitmap();
}

NECtext()
{
	nec_dump();
	b_freebitmap();
}

NECClinetype(linetype)
int linetype;
{
	if (linetype>=6)
		linetype %= 6;
	b_setvalue(neccolor[linetype+2]);
}

#define NECMlinetype b_setlinetype
#define NECmove b_move
#define NECvector b_vector
#define NECput_text b_put_text
#define NEC_text_angle b_text_angle

	
NECreset()
{
#ifdef vms
	fflush_binary();
#endif
}


/* output file must be binary mode for nec_dump */
nec_dump()
{
unsigned int x;
unsigned int plane,offset;
int j;
unsigned int column8;
unsigned long column24;
char column3, column2, column1;
	fprintf(outfile,"\033P\033l\005");  /* 10cpi, left margin 5 char */
	for (j=(b_ysize/8)-1;j>=0;j--) {
			fprintf(outfile,"\033J\030");  /* 24/180" line feed */
			for (plane=0; plane<b_planes; plane++) {
				offset=plane*b_psize;
				if (b_planes>1) {
				    /* select colour for plane */
				    fprintf(outfile,"\033r");
				    (void) fputc((char)necpcolor[plane],outfile);
				}
				/* select plotter graphics mode (square pixels) */
				fprintf(outfile,"\r\033*\047");
				(void) fputc((char)((b_xsize*3)%256),outfile);
				(void) fputc((char)((b_xsize*3)/256),outfile);
				for (x=0; x<b_xsize; x++) {
					column8= (unsigned int)(*((*b_p)[j+offset]+x));
					column24=0;
					if (column8&0x01) column24|=(long)0x000007;
					if (column8&0x02) column24|=(long)0x000038;
					if (column8&0x04) column24|=(long)0x0001c0;
					if (column8&0x08) column24|=(long)0x000e00;
					if (column8&0x10) column24|=(long)0x007000;
					if (column8&0x20) column24|=(long)0x038000;
					if (column8&0x40) column24|=(long)0x1c0000;
					if (column8&0x80) column24|=(long)0xe00000;
					column1 = (char) ( column24      & (long)0xff);
					column2 = (char) ((column24>>8)  & (long)0xff);
					column3 = (char) ((column24>>16) & (long)0xff);
					(void) fputc(column3,outfile);
					(void) fputc(column2,outfile);
					(void) fputc(column1,outfile);
					(void) fputc(column3,outfile);
					(void) fputc(column2,outfile);
					(void) fputc(column1,outfile);
					(void) fputc(column3,outfile);
					(void) fputc(column2,outfile);
					(void) fputc(column1,outfile);
				}
			}
	}
	fprintf(outfile,"\r\033l");
	(void) fputc('\0',outfile);				/* set left margin to 0 */
	if (b_planes > 1) {
		fprintf(outfile,"\033r");
		(void) fputc('\0',outfile);				/* set color to black */
	}
#ifdef PC
	fprintf(stderr,"Print using: COPY /B\n");
#endif
#ifdef vms
	fflush_binary();
#endif
}

/* output file must be binary mode for nec_dump */
nec_draft_dump()
{
unsigned int x;
unsigned int plane,offset;
int j;
	fprintf(outfile,"\033P\033l\005\r");  /* 10cpi, left margin 5 char */
	for (j=(b_ysize/8)-1;j>=0;j--) {
			fprintf(outfile,"\033J\030");  /* 24/180" line feed */
			for (plane=0; plane<b_planes; plane++) {
				offset=plane*b_psize;
				if (b_planes>1) {
				    /* select colour for plane */
				    fprintf(outfile,"\033r");
				    (void) fputc((char)necpcolor[plane],outfile);
				}
				/* select plotter graphics mode (square pixels) */
				fprintf(outfile,"\r\033*");
				(void) fputc('\0',outfile);
				(void) fputc((char)(b_xsize%256),outfile);
				(void) fputc((char)(b_xsize/256),outfile);
				for (x=0; x<b_xsize; x++) {
					(void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
				}
			}
	}
	fprintf(outfile,"\r\033l");
	(void) fputc('\0',outfile);				/* set left margin to 0 */
	if (b_planes > 1) {
		fprintf(outfile,"\033r");
		(void) fputc('\0',outfile);				/* set color to black */
	}
#ifdef PC
	fprintf(stderr,"Print using: COPY /B\n");
#endif
}

#endif /* NEC */

#ifdef STARC
/* The following Star color driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* STARC_init changes outfile to binary mode on PC's */

#define STARCXMAX	512 
#define STARCYMAX	384

#define STARCXLAST (STARCXMAX - 1)
#define STARCYLAST (STARCYMAX - 1)

#define STARCVCHAR		FNT5X9_VCHAR  	
#define STARCHCHAR		FNT5X9_HCHAR		
#define STARCVTIC		6
#define STARCHTIC		6

/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
static unsigned int STARCcolor[] = {1,8,4,2,10,12,6,14};
static unsigned int STARCpcolor[]= {0,2,1,4};

STARCinit()
{
#ifdef PC
	reopen_binary();
#endif
#ifdef vms
	reopen_binary();
#endif
}


STARCgraphics()
{
	b_charsize(FNT5X9);
	b_makebitmap((unsigned int)(STARCXMAX*xsize),
	             (unsigned int)(STARCYMAX*ysize),4);
}


STARCtext()
{
	STARC_dump();
	b_freebitmap();
}

STARClinetype(linetype)
int linetype;
{
	if (linetype>=6)
		linetype %= 6;
	b_setvalue(STARCcolor[linetype+2]);
}


#define STARCmove b_move
#define STARCvector b_vector
#define STARCput_text b_put_text
#define STARC_text_angle b_text_angle

STARCreset()
{
#ifdef vms
	fflush_binary();
#endif
}


/* output file must be binary mode for STARC_dump */
STARC_dump()
{
unsigned int x;
unsigned int plane,offset;
int j;
	for (j=(b_ysize/8)-1;j>=0;j--) {
		fprintf(outfile,"\033J\030");	/* line feed 8/72" = 8 dots */
		for (plane=0; plane<b_planes; plane++) {
			offset=plane*b_psize;
			if (b_planes>1) {
				/* select colour for plane */
				fprintf(outfile,"\033r");
				(void) fputc((char)STARCpcolor[plane],outfile);
			}
			/* select plotter graphics mode (square pixels) */
			fprintf(outfile,"\r\033*\005");
			(void) fputc((char)(b_xsize%256),outfile);
			(void) fputc((char)(b_xsize/256),outfile);
			for (x=0; x<b_xsize; x++) {
				(void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
			}
		}
	}
	if (b_planes > 1) {
		fprintf(outfile,"\033r");
		(void) fputc('\0',outfile);				/* set color to black */
	}
#ifdef PC
	fprintf(stderr,"Print using: COPY /B\n");
#endif
}

#endif /* STARC */


#ifdef EPS60

/* make the total dimensions 8 inches by 5 inches */
#define EPS60XMAX	480
#define EPS60YMAX	360

#define EPS60XLAST (EPS60XMAX - 1)
#define EPS60YLAST (EPS60YMAX - 1)

EPS60graphics()
{
	b_charsize(FNT5X9);
	b_makebitmap((unsigned int)(EPS60XMAX*xsize),
	             (unsigned int)(EPS60YMAX*ysize),1);
}


EPS60text()
{
	eps60_dump();
	b_freebitmap();
}



/* output file must be binary mode for eps60_dump */
eps60_dump()
{
  register unsigned int x;
  int j;
	fprintf(outfile,"\033%c\030",'3'); /* set line spacing 24/216" = 8 dots */
	for (j=(b_ysize/8)-1; j>=0; j--) {
		/* select printer graphics mode 'K' */
		fprintf(outfile,"\r\n\033K");
		(void) fputc((char)(b_xsize%256),outfile);
		(void) fputc((char)(b_xsize/256),outfile);
		for (x=0; x<b_xsize; x++) {
			(void) fputc( (char)(*((*b_p)[j]+x)), outfile );
		}
	}
	fprintf(outfile,"\033%c\044\r\n",'3'); /* set line spacing 36/216" = 1/6" */
#ifdef PC
	fprintf(stderr,"Print using: COPY /B\n");
#endif
}

#endif /* EPS60 */

#ifdef TANDY60

/* The only difference between TANDY60 and EPS60 is the inclusion
   of codes to swap the Tandy printer into IBM mode and back
   into Tandy mode.  For a Tandy already in IBM mode, use EPS60. */


TANDY60text()
{
#ifdef PC
	fprintf(stderr, "Inserting Tandy/IBM mode conversion codes\n");
#endif
	/* Switch to IBM mode, and leave 3 inches above the plot so as
	   to get rough vertical centring on the page.  Perform the
	   centring by setting 1" line feeds and issuing 3 of them. */
	fprintf(outfile, "\033!\033%c%c\n\n\n", '3',216);
	eps60_dump();
	b_freebitmap();
	/* A form feed must be sent before switching back to Tandy mode,
	   or else the form setting will be messed up. */
	fprintf(outfile, "\f\033!");
}


#endif  /* TANDY60 */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/fig.trm version [3a30c91e71].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * $Id: fig.trm,v 3.26 92/03/24 22:34:53 woo Exp Locker: woo $
 */

/* GNUPLOT - fig.trm */
/*
 * Copyright (C) 1990, 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Fig graphics language
 *
 * AUTHORS
 *  Micah Beck, David Kotz
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 */

#ifdef MSDOS
#define long int
#endif /* MSDOS */

/*
 * Original for Fig code output by Micah Beck, 1989
 * Department of Computer Science, Cornell University
 * Updated by David Kotz for gnuplot 2.0
 * More efficient output Ian by Dall
 */
#include "object.h"                     /* from the TransFig distribution */
#define FIG_DEFAULT (-1)
#define FIG_ROMAN_FONT (0)
 
#ifndef FIG_RES
/* Must be 80 for the Fig editor, but may be increased if used
 * only by TransFig filters.
 * Represents resolution per inch.
 */
#define FIG_RES         80
#endif
 
#define FIG_COORD_SYS   2
 
#define FIG_MAGIC       "#FIG 1.4-TFX"
#define FIG_HTIC        (5*FIG_RES/80)
#define FIG_VTIC        (5*FIG_RES/80)
#define FIG_FONT_S      FIG_DEFAULT
#define FIG_HCHAR       (6*FIG_RES/80) /* Change if FIG_FONT_S is changed */
#define FIG_VCHAR       (12*FIG_RES/80) /* Change if FIG_FONT_S is changed */
#define FIG_ARROW_WIDTH FIG_HTIC
#define FIG_ARROW_HEIGHT FIG_HTIC
 
static long FIG_xbase = FIG_RES/2;
static long FIG_ybase = FIG_RES/2;
 
static long FIG_posx;
static long FIG_posy;
static int FIG_poly_vec_cnt;
enum FIG_poly_stat {FIG_poly_new, FIG_poly_part};
static enum FIG_poly_stat FIG_polyvec_stat;
/* 5 inches wide by 3 inches high */
#define FIG_XMAX (5 * FIG_RES)
#define FIG_YMAX (3 * FIG_RES)
 
#define FIG_XOFF (FIG_RES/4)
#define FIG_YOFF (FIG_RES/4)
 
static int FIG_type;            /* negative types use real lines */
static float FIG_spacing;       /* length of dash or dot spacing */
static int FIG_justify;         /* Fig justification T_*_JUSTIFIED */
static float FIG_angle;         /* Fig text angle 0=horiz, Pi/2=vert */
 
#define FIG_POINT_TYPES POINT_TYPES /* we use the same points */
 
static
  FIG_poly_clean(stat)
enum FIG_poly_stat stat;
{
  if(stat == FIG_poly_part)
        fprintf(outfile, " 9999 9999\n");
  FIG_polyvec_stat = FIG_poly_new;
}
 
FIG_init()
{
    FIG_posx = FIG_posy = 0;
    FIG_polyvec_stat = FIG_poly_new;
    FIG_linetype(-1);
    FIG_justify_text(LEFT);
    FIG_text_angle(0);
 
    fprintf(outfile, "%s\n", FIG_MAGIC);
    fprintf(outfile, "%d %d\n", FIG_RES, FIG_COORD_SYS);
}
 
 
FIG_graphics()
{
    FIG_posx = FIG_posy = 0;
    FIG_polyvec_stat = FIG_poly_new;
    /* there is no way to have separate pictures in a FIG file */
}
 
 
FIG_text()
{
    /* there is no way to have separate pictures in a FIG file */
    FIG_poly_clean(FIG_polyvec_stat);
    FIG_posx = FIG_posy = 0;
    fflush(outfile);
}
 
 
/* Line types for FIG work like this:
 *  -2 : solid (border)
 *  -1 : dashed 4 (axes)
 *   0 : solid (first curve)
 *   1 : dotted 3
 *   2 : dashed 3
 *   3 : dotted 6
 *   4 : dashed 6
 *   ... ...
 */
 
FIG_linetype(linetype)
        int linetype;                   /* expect linetype >= -2 */
{
    int last_FIG_type = FIG_type;
    int last_FIG_spacing = FIG_spacing;
    switch (linetype) {
           case 0:
           case -2: {
                  FIG_type = 0; /* solid line */
                  FIG_spacing = 0.0;
                  break;
           }
           case -1: {
                  FIG_type = 1; /* dashed */
                  FIG_spacing = 4.0; /* dash length */
                  break;
           }
           default: {
                  linetype = abs(linetype); /* shouldn't be negative anyway */
                  /* now linetype >= 1 */
                  FIG_type = linetype % 2 + 1; /* dotted, dashed, ... */
                  FIG_spacing = (linetype+1) / 2 * 3;
                  break;
           }
    }
    if (FIG_type != last_FIG_type || FIG_spacing != last_FIG_spacing)
      FIG_poly_clean(FIG_polyvec_stat);
}
 
FIG_move(x,y)
        unsigned int x,y;
{
    int last_FIG_posx = FIG_posx;
    int last_FIG_posy = FIG_posy;
    FIG_posx = x;
    FIG_posy = y;
    if (FIG_posx != last_FIG_posx || FIG_posy != last_FIG_posy)
          FIG_poly_clean(FIG_polyvec_stat);
}
 
 
FIG_vector(ux,uy)
     unsigned int ux,uy;
{
  int x=ux, y=uy;
 
  if (FIG_polyvec_stat != FIG_poly_part)
    {
      fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f  %d %d\n",
              O_POLYLINE, T_POLYLINE,
              FIG_type, 1, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_spacing,
              0, 0);
      fprintf(outfile, "%d %d",
              FIG_XOFF + FIG_posx, FIG_YMAX + FIG_YOFF - FIG_posy);
      FIG_poly_vec_cnt = 1;
      FIG_polyvec_stat = FIG_poly_part;
    }
  fprintf(outfile, " %d %d",
          FIG_XOFF +  x, FIG_YMAX + FIG_YOFF-y);
  FIG_poly_vec_cnt++;
  if (FIG_poly_vec_cnt > 50)
    FIG_poly_clean(FIG_polyvec_stat);
 
  FIG_posx = x;
  FIG_posy = y;
}
 
 
FIG_arrow(sx, sy, ex, ey, head)
        int sx, sy;     /* start coord */
        int ex, ey;     /* end coord */
	BOOLEAN head;
{
	FIG_poly_clean(FIG_polyvec_stat);
        fprintf(outfile, "%d %d %d %d %d %d %d %d %6.3f  %d %d\n",
                O_POLYLINE, T_POLYLINE,
                FIG_type, 1, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_spacing,
                head ? 1 : 0, 0);
        /* arrow line */
	if ( head )
	        fprintf(outfile, "%d %d %.3f %.3f %.3f\n",
        	        0, 0, 1.0,
			(double)FIG_ARROW_WIDTH, (double)FIG_ARROW_HEIGHT);
        fprintf(outfile, "%d %d %d %d 9999 9999\n",
                FIG_XOFF + sx, FIG_YOFF + FIG_YMAX - sy,
		FIG_XOFF + ex, FIG_YOFF + FIG_YMAX - ey);
 
        FIG_posx = ex;
        FIG_posy = ey;
}
 
 
FIG_put_text(x, y, str)
        int x, y;
        char *str;
{
  if (strlen(str) == 0) return;
  FIG_poly_clean(FIG_polyvec_stat);
    y = y - FIG_VCHAR/2;                /* assuming vertical center justified */
 
    fprintf(outfile, "%d %d %d %d %d %d %d %6.3f %d %d %d %d %d %s\01\n",
                  O_TEXT, FIG_justify,
                  FIG_ROMAN_FONT, FIG_FONT_S, FIG_DEFAULT, FIG_DEFAULT, FIG_DEFAULT, FIG_angle,
                  FIG_DEFAULT, FIG_VCHAR, FIG_HCHAR*strlen(str), FIG_XOFF + x,
        FIG_YMAX + FIG_YOFF-y, str);
}
 
int FIG_justify_text(mode)
        enum JUSTIFY mode;
{
    switch(mode) {
           case LEFT: FIG_justify = T_LEFT_JUSTIFIED; break;
           case CENTRE: FIG_justify = T_CENTER_JUSTIFIED; break;
           case RIGHT: FIG_justify = T_RIGHT_JUSTIFIED; break;
           /* shouldn't happen */
           default: FIG_justify = T_LEFT_JUSTIFIED; break;
    }
    return (TRUE);
}
 
int FIG_text_angle(angle)
        int angle;
{
    if (angle)
         FIG_angle = Pi / 2.0;  /* vertical is pi/2 radians */
    else
         FIG_angle = 0.0;               /* horizontal */
    return (TRUE);
}
 
FIG_reset()
{
    FIG_poly_clean(FIG_polyvec_stat);
    FIG_posx = FIG_posy = 0;
    fflush(outfile);
}

#ifdef MSDOS
#undef long
#endif /* MSDOS */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/gpr.trm version [0e450c02b1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/*
 * $Id: gpr.trm,v 3.26 92/03/24 22:35:00 woo Exp Locker: woo $
 */

/* GNUPLOT - gpr.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   APOLLO's GPR windowing system
 *
 * AUTHORS
 *  Michael Aramini
 *  Roque D Oliveira , oliveria@caen.engin.umich.edu
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */
#include <apollo/base.h>
#include <apollo/error.h>
#include <apollo/gpr.h>
#include <apollo/pad.h>
/* landscape window */
/*
#define GPR_XMAX 720
#define GPR_YMAX 450
*/
/* portrait window */
#define GPR_XMAX 585
#define GPR_YMAX 735

#define GPR_XLAST (GPR_XMAX - 1)
#define GPR_YLAST (GPR_YMAX - 1)

#define GPR_VCHAR 19
#define GPR_HCHAR 10
#define GPR_VTIC (GPR_YMAX/80)
#define GPR_HTIC (GPR_XMAX/80)

gpr_$direction_t  gpr_path=gpr_$right;
int               gpr_ang=0;            /* text angle, 0=horizontal, 1=vertical */
enum JUSTIFY      gpr_justify=LEFT;     /* text is flush left */

static status_$t  status;
unsigned int      DEBUG    = 0;         /* set it to 1 when debugging program */


static void check(messagex)
char *messagex;
{
  if (status.all = status_$ok)
  {
    error_$print(status);
    printf("Error occurred while %s.\n", messagex);
  }
}

/* return whether stdout is a DM pad . Called by term.c */
gpr_isa_pad()
{
    pad_$isa(1, &status);
    return (status.all == status_$ok);
}


GPR_init()
{
  gpr_$offset_t dm_bitmap_size;
  gpr_$bitmap_desc_t dm_bitmap_desc;
  pad_$window_desc_t window;
  short font_id;
  stream_$id_t stream_id;
  static gpr_$rgb_plane_t  hi_plane;
  static gpr_$disp_char_t  display_characteristics;
  static float             screen_size_r_width,screen_size_r_height ;
  static short int         disp_len = sizeof(gpr_$disp_char_t);
  static short int         disp_len_returned;


  /* open a pad to do graphics in */
  window.top    = 0;
  window.left   = 0;
  window.width  = GPR_XMAX + 10; /* 10 accounts for width of window border */
  window.height = GPR_YMAX + 35; /* 35 accounts for height of window border */
  pad_$create_window("",(short)0,pad_$transcript,(short)1,window,&stream_id,&status);
  check("pad_$create_window");

/*  pad_$set_full_window(stream_id,(short) 1,&window, &status); */
/*  pad_$set_border (stream_id,(short) 1, true, &status); */
  pad_$set_scale (stream_id,(short) 1,(short) 1, &status);
  pad_$set_auto_close(stream_id, (short) 1, true, &status );

  gpr_$inq_disp_characteristics(gpr_$direct,stream_id,disp_len,&display_characteristics,&disp_len_returned,&status);
  check("in gpr_$inq_display_characteristics");
  screen_size_r_width    = (float) display_characteristics.x_window_size;    /*x_window_size in pixels */
  screen_size_r_height   = (float) display_characteristics.y_window_size;    /*y_window_size in pixels */
  hi_plane  = display_characteristics.n_planes - 1;  
  if(DEBUG) printf("width=%f height=%f \n",screen_size_r_width,screen_size_r_height);

  dm_bitmap_size.x_size = 1280;
  dm_bitmap_size.y_size = 1024;
  gpr_$init(gpr_$direct,stream_id,dm_bitmap_size,hi_plane,&dm_bitmap_desc,&status); 
  check("in gpr_$init");
/*
  gpr_$set_obscured_opt(gpr_$pop_if_obs, &status); 
  check("in gpr_$set_obscured_opt");
*/
  gpr_$set_auto_refresh(true, &status); 
  check("in gpr_$set_auto_refresh");

  /* load a font and make it current */
  gpr_$load_font_file("f7x13", 5, &font_id, &status);
  check("in gpr_$load_font_file");
  gpr_$set_text_font(font_id, &status);
  check("in gpr_$set_text_font");

  /* set up color values */
  gpr_$set_draw_value((gpr_$pixel_value_t)7, &status);  /* white */
  check("in gpr_set_draw_value");
  gpr_$set_text_background_value((gpr_$pixel_value_t)(-1), &status); /* trans */
  check("in gpr_$set_text_background_value");
  gpr_$set_text_value((gpr_$pixel_value_t)7, &status);  /* white */
  check("in gpr_$set_text_value");
}


GPR_graphics()
{
  gpr_$coordinate_t locx,locy,marker_size;

  (void) gpr_$acquire_display(&status);
  check("in gpr_$acquire display");
  gpr_$clear((gpr_$pixel_value_t)0, &status);  /* black */
  check("in gpr_$clear");

  if(DEBUG) 
   {
    marker_size = (short) 10;  

    locx = (short) 5;
    locy = (short) 5;
    gpr_$set_draw_value((gpr_$pixel_value_t)2, &status);  /* white */
    gpr_$move( (locx - marker_size/2) ,locy,&status);
    gpr_$line( (locx + marker_size/2) ,locy,&status);
    gpr_$move( locx, (locy + marker_size/2),&status);
    gpr_$line( locx, (locy - marker_size/2),&status);
    
    locx = (short) (GPR_XMAX -1 - 5);
    locy = (short) 5;
    gpr_$set_draw_value((gpr_$pixel_value_t)3, &status);  /* white */
    gpr_$move( (locx - marker_size/2) ,locy,&status);
    gpr_$line( (locx + marker_size/2) ,locy,&status);
    gpr_$move( locx, (locy + marker_size/2),&status);
    gpr_$line( locx, (locy - marker_size/2),&status);
    
    locx = (short) 5;
    locy = (short) (GPR_YMAX -1 - 5);
    gpr_$set_draw_value((gpr_$pixel_value_t)4, &status);  /* white */
    gpr_$move( (locx - marker_size/2) ,locy,&status);
    gpr_$line( (locx + marker_size/2) ,locy,&status);
    gpr_$move( locx, (locy + marker_size/2),&status);
    gpr_$line( locx, (locy - marker_size/2),&status);
    
    locx = (short) (GPR_XMAX -1 - 5);
    locy = (short) (GPR_YMAX -1 - 5);
    gpr_$set_draw_value((gpr_$pixel_value_t)5, &status);  /* white */
    gpr_$move( (locx - marker_size/2) ,locy,&status);
    gpr_$line( (locx + marker_size/2) ,locy,&status);
    gpr_$move( locx, (locy + marker_size/2),&status);
    gpr_$line( locx, (locy - marker_size/2),&status);
    
    gpr_$set_draw_value((gpr_$pixel_value_t)7, &status);  /* white */
    check("in gpr_$set_draw_value");
   } /* end if(DEBUG) */

}


GPR_text()
{
  gpr_$release_display(&status);
  check("gpr_$release_display");
}


GPRold_linetype(linetype)
int linetype;
{
  static gpr_$line_pattern_t patterns[2+5] = {
      { 0xFFFF },   /* solid              1111111111111111 */
      { 0x3FFF },   /* very long dashed   0011111111111111 */
      { 0xFFFF },   /* solid              1111111111111111 */
      { 0x5555 },   /* dotted             0101010101010101 */
      { 0x3333 },   /* short dashed       0011001100110011 */
      { 0xB5AD },   /* dot short-dashed   1011010110101101 */
      { 0x3FFF }    /* very long dashed   0011111111111111 */
                                             };
  if (linetype >= 5) linetype %= 5;
  gpr_$set_line_pattern((short)1, patterns[linetype+2], (short)16, &status);
  check("in gpr_$set_line_pattern");
}

GPR_linetype(linetype)
int linetype;
{
  static gpr_$line_pattern_t patterns[2+7] = {
      { 0xFFFF },   /* solid              1111111111111111 */
      { 0x1111 },   /* long-spaced dotted 0001000100010001 */
      { 0xFFFF },   /* solid              1111111111111111 */
      { 0x5555 },   /* dotted             0101010101010101 */
      { 0x3333 },   /* short  dashed      0011001100110011 */
      { 0x7777 },   /* medium dashed      0111011101110111 */
      { 0x3F3F },   /* long   dashed      0011111100111111 */
      { 0x0F0F },   /* long-spaced dashed 0000111100001111 */
      { 0x5F5F }    /* dot dashed         0101111101011111 */
                                             };
  if (linetype >= 7) linetype %= 7;
  gpr_$set_line_pattern((short)1, patterns[linetype+2], (short)16, &status);
  check("in gpr_$set_line_pattern");

/*
  gpr_$set_draw_value((gpr_$pixel_value_t)(linetype + 1), &status);
  check("in gpr_$set_draw_value");
*/
}


GPR_move(x, y)
unsigned int x, y;
{
  gpr_$move((short)x, (short)(GPR_YMAX -1 - y), &status);
  check("in gpr_$move");
}


GPR_vector(x, y)
unsigned int x, y;
{
  gpr_$line((short)x, (short)(GPR_YMAX -1 - y), &status);
  check("in gpr_$line");
}


GPR_put_text(x,y,str)
unsigned int x,y;        /* reference point of string */
char str[];              /* the text */
{
  gpr_$coordinate_t xgpr,ygpr;
  gpr_$offset_t     str_size_in_pixels;
  short int         str_len;     

  gpr_$coordinate_t locx,locy,marker_size;

  if(DEBUG) 
   {
    locx = (short) x;
    locy = (short) (GPR_YMAX -1 - y);
    marker_size = (short) 20;  
    gpr_$set_draw_value((gpr_$pixel_value_t)1, &status);  /* white */
    gpr_$move( (locx - marker_size/2) ,locy,&status);
    gpr_$line( (locx + marker_size/2) ,locy,&status);
    gpr_$move( locx, (locy + marker_size/2),&status);
    gpr_$line( locx, (locy - marker_size/2),&status);
    gpr_$set_draw_value((gpr_$pixel_value_t)7, &status);  /* white */
   }

  xgpr = (short) x;
  ygpr = (short) (GPR_YMAX -1 - y); 
  gpr_$set_text_path(gpr_path, &status); 
  check("gpr_$set_text_path");

  str_len = (short) strlen(str);
  gpr_$inq_text_extent(str,str_len,&str_size_in_pixels,&status); /* Calculate how much space (in pixels) the string requires */    
  check("in gpr_$inq_text_extent");

  switch (gpr_justify) 
   {
    case LEFT :
        {
         switch (gpr_path) 
          {
           case gpr_$up :           /* vertical */
               {
                if(DEBUG) printf("LEFT and up , str=%s\n",str);
                break;
               }
           case gpr_$right :        /* horizontal */
               {
                ygpr = ygpr + str_size_in_pixels.y_size/2;
                if(DEBUG) printf("LEFT and right, str=%s \n",str);
                break;
               }
          }
         break;
        }

    case CENTRE :
        {  
         switch (gpr_path) 
          {
           case gpr_$up :           /* vertical */
               {
                xgpr = xgpr + str_size_in_pixels.x_size/2;
                ygpr = ygpr + str_size_in_pixels.y_size/2;
                if(DEBUG) printf("CENTRE and up, str=%s \n",str);
                break;
               }
           case gpr_$right :        /* horizontal */
               {
                xgpr = xgpr - str_size_in_pixels.x_size/2;
                ygpr = ygpr + str_size_in_pixels.y_size/2;
                if(DEBUG) printf("CENTRE and right, str=%s \n",str);
                break;
               }
          }
         break;
        }
    case RIGHT :
        {
         switch (gpr_path) 
          {
           case gpr_$up :           /* vertical */
               {
                ygpr = ygpr + str_size_in_pixels.y_size;
                if(DEBUG) printf("RIGHT and up, str=%s \n",str);
                break;
               }
           case gpr_$right :        /* horizontal */
               {
                xgpr = xgpr - str_size_in_pixels.x_size;
                ygpr = ygpr + str_size_in_pixels.y_size/2;
                if(DEBUG) printf("RIGHT and right, str=%s \n",str);
                break;
               }
          }
         break;
        }
   }

  gpr_$move(xgpr,ygpr,&status);
  check("in gpr_$move");
  gpr_$text(str, str_len, &status);
  check("in gpr_$text");
}

int GPR_text_angle(ang)
int ang;
{   
    if (gpr_ang != ang)
      {
        gpr_ang  = ang;
        gpr_path = (gpr_ang == 1 ? gpr_$up : gpr_$right);
      }
    return (TRUE);
}

int GPR_justify_text(mode)
enum JUSTIFY mode;
{
    gpr_justify = mode;
    return (TRUE);
}

GPR_reset()
{
  gpr_$terminate(false, &status);
  check("in gpr_$terminate");
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/hp26.trm version [06b115db00].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * $Id: hp26.trm,v 3.26 92/03/24 22:34:55 woo Exp Locker: woo $
 */

/* GNUPLOT - hp26.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  HP2623A 
 *
 * AUTHORS
 *   hplvlch!ch (Chuck Heller) 
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */


#define HP26_XMAX 512
#define HP26_YMAX 390

#define HP26_XLAST (HP26_XMAX - 1)
#define HP26_YLAST (HP26_XMAX - 1)

/* Assume a character size of 1, or a 7 x 10 grid. */
#define HP26_VCHAR	10
#define HP26_HCHAR	7
#define HP26_VTIC	(HP26_YMAX/70)		
#define HP26_HTIC	(HP26_XMAX/75)		

HP26_init()
{
	/*	The HP2623A needs no initialization. */
}


HP26_graphics()
{
	/*	Clear and enable the display */

	fputs("\033*daZ\033*dcZ",outfile);
}


HP26_text()
{
	fputs("\033*dT",outfile);	/* back to text mode */
}


HP26_linetype(linetype)
int linetype;
{
#define	SOLID	1
#define LINE4	4
#define LINE5	5
#define LINE6	6
#define LINE8	8
#define	DOTS	7
#define LINE9	9
#define LINE10	10

static int map[2+9] = {	SOLID,	/* border */
						SOLID,	/* axes */
						DOTS,	/* plot 0 */
						LINE4,	/* plot 1 */
						LINE5,	/* plot 2 */
						LINE6,	/* plot 3 */
						LINE8,	/* plot 4 */
						LINE9,	/* plot 5 */
						LINE10,	/* plot 6 */
						SOLID,	/* plot 7 */
						SOLID	/* plot 8 */ };

	if (linetype >= 9)
		linetype %= 9;
	fprintf(outfile,"\033*m%dB",map[linetype + 2]);
}


HP26_move(x,y)
int x,y;
{
	fprintf(outfile,"\033*pa%d,%dZ",x,y);
}


HP26_vector(x,y)
int x,y;
{
	fprintf(outfile,"\033*pb%d,%dZ",x,y);
}


HP26_put_text(x,y,str)
int x, y;
char *str;
{
	HP26_move(x,y + HP26_VCHAR/2);
	fputs("\033*dS",outfile);
	fprintf(outfile,"\033*m3Q\033*l%s\n",str);
	fputs("\033*dT",outfile);
}



HP26_reset()
{
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































Deleted r34.1/plot/term/hp2648.trm version [7440504418].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * $Id: hp2648.trm,v 3.26 92/03/24 22:34:55 woo Exp Locker: woo $
 */

/* GNUPLOT -  hp2648.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  HP2648 and HP2647
 *
 * AUTHORS
 *  Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define HP2648XMAX 720             
#define HP2648YMAX 360

#define HP2648XLAST (HP2648XMAX - 1)
#define HP2648YLAST (HP2648YMAX - 1)

#define HP2648VCHAR		12  	
#define HP2648HCHAR		7		
#define HP2648VTIC		8
#define HP2648HTIC		8


HP2648init()
{
	fprintf(outfile,"\033*m1m1n136,1cZ");
/*                   1     2 3     4
	1. mode
	2. textsize=1
	3. textangle=1
        4. define line type 2 to be *   *   *   * etc.
*/
}


HP2648graphics()
{
	fprintf(outfile,"\033*dacZ");
/*                   1     23
	1. mode
	2. clear grahics screen
	3. graphics video on
*/
}


HP2648text()
{
}


HP2648linetype(linetype)
int linetype;
{
	static int hpline[] = {1,7,1,4,5,6,8,9,10,7,2};
	fprintf(outfile,"\033*m%dbZ",hpline[(linetype+2)%11]);
}


HP2648move(x,y)
int x,y;
{
	fprintf(outfile,"\033*paf%d,%dZ",x,y);
    /*               1     23     4
	1	plot mode
	2	"pen up"
	3	goto absolute x,y
	4	end command
	*/
}


HP2648vector(x,y)
int x,y;
{
	fprintf(outfile,"\033*pbf%d,%dZ",x,y);
    /*                     1 
	1	"pen down"
	*/
}


HP2648put_text(x,y,str)
int x, y;
char *str;
{
	HP2648move(x,y-HP2648VCHAR/2 + 1);
	fprintf(outfile,"\033*l%s\n",str);
}


int HP2648_text_angle(ang)
int ang;
{
	fprintf(outfile,"\033*m%dnZ\n",ang+1);
	return TRUE;
}
	
HP2648reset()
{
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































Deleted r34.1/plot/term/hpgl.trm version [7f77f27bc1].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * $Id: hpgl.trm,v 3.26 92/03/24 22:34:56 woo Exp Locker: woo $
 */

/* GNUPLOT - hpgl.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  hpgl, hp7580b, HP Laserjet III
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams, Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define HPGL_XMAX 15200
#define HPGL_YMAX 10000

#define PCL_XMAX 10000
#define PCL_YMAX  7500

#define HPGL_XLAST (HPGL_XMAX - 1)
#define HPGL_YLAST (HPGL_XMAX - 1)

/* HPGL_VCHAR, HPGL_HCHAR  are not used */
#define HPGL_VCHAR	(HPGL_YMAX/100*32/10) /* 3.2% */
#define HPGL_HCHAR	(HPGL_XMAX/100*12/10) /* 1.2% */
#define HPGL_VTIC	(HPGL_YMAX/70)		
#define HPGL_HTIC	(HPGL_YMAX/70)		

#define PCL_VCHAR	(PCL_YMAX/100*32/10) /* 3.2% */
#define PCL_HCHAR	(PCL_XMAX/100*12/10) /* 1.2% */
#define PCL_VTIC	(PCL_YMAX/70)		
#define PCL_HTIC	(PCL_YMAX/70)		

int HPGL_ang = 0;

HPGL_init()
{
	fputs("\033.Y\n",outfile);
/*	       1
	1. enable eavesdropping
*/
}

PCL_PORT_init()
{
  	fputs("\033E\033&l1X\033&l0O\033&2A\033%0B;PW0.15\n",outfile);
/*           1      2       3       4     5     6
	1. reset the printer
	2. one copy
	3. portrait orientation
	4. use letter paper
	5. enter HP-GL/2 with old pen position
	6. Pen Width
*/
}

PCL_LAND_init()
{
	fputs("\033E\033&l1X\033&l1O\033%0B;PW0.15\n",outfile);
/*
                 1      2       3       4     5
	1. reset the printer
	2. one copy
	3. landscape orientation
	4. enter HP-GL/2 with old pen position
	5. Pen Width
*/
}


PCL_graphics()
{
	fprintf(outfile,
	"\033%0B\nIN;\nSC0,%d,0,%d;\nSR%f,%f;\n",
		PCL_XMAX,PCL_YMAX,
		((double)(PCL_HCHAR)*200/3/PCL_XMAX),
		((double)(PCL_VCHAR)*100/2/PCL_YMAX) );
/*	 0         1    2             3 
	0. enter HPGL/2 mode
	1. reset to power-up defaults
	2. set SCaling
	3. set character size
*/
	HPGL_ang = 0;
}

HPGL_graphics()
{
	fprintf(outfile,
	"IN;\nSC0,%d,0,%d;\nSR%f,%f;\n",
		HPGL_XMAX,HPGL_YMAX,
		((double)(HPGL_HCHAR)*200/3/HPGL_XMAX),
		((double)(HPGL_VCHAR)*100/2/HPGL_YMAX) );
/*	 1    2             3 
	1. reset to power-up defaults
	2. set SCaling
	3. set character size
*/
	HPGL_ang = 0;
}


PCL_text()
{
	fputs("PU;\nSP0;\n\033.Z\0",outfile);
/*	       1    2     3
	1. pen up
	2. park pen
	3. disable eavesdropping
*/
	fputs("\n\033%1A\n\033&l0H\0",outfile);
/*	           1    2      3
	1. enter PCL
	2. eject page
	3. reset printer
*/
}

HPGL_text()
{
	fputs("PU;\nSP0;\n\033.Z\0",outfile);
/*	       1    2     3
	1. pen up
	2. park pen
	3. disable eavesdropping
*/
}


HPGL_linetype(linetype)
int linetype;
{
/* allow for 6 pens */
	fprintf(outfile,"PU;\nSP%d;\n",(linetype+2)%6+1); 
}


HP75_linetype(linetype)
int linetype;
{
/* allow for 4 pens */
	fprintf(outfile,"PU;\nSP%d;\n",(linetype+2)%4+1); 
}


/* some early HPGL plotters (e.g. HP7220C) require the
 * Pen Up/Down and Pen (move) Absolute commands to be separate
 */
HPGL_move(x,y)
int x,y;
{
	fprintf(outfile,"PU;PA%d,%d;\n",x,y);
}


HPGL_vector(x,y)
int x,y;
{
	fprintf(outfile,"PD;PA%d,%d;\n",x,y);
}


HPGL_put_text(x,y,str)
int x, y;
char *str;
{
	if (HPGL_ang == 1)
		HPGL_move(x + HPGL_VCHAR/4,y);
	else
		HPGL_move(x,y - HPGL_VCHAR/4);
	fprintf(outfile,"LB%s\003\n",str);
}

PCL_put_text(x,y,str)
int x, y;
char *str;
{
        if (HPGL_ang == 1)
                HPGL_move(x + PCL_VCHAR/4,y);
        else
                HPGL_move(x,y - PCL_VCHAR/4);
        fprintf(outfile,"LB%s\003\n",str);
}


int HPGL_text_angle(ang)
int ang;
{
	HPGL_ang = ang;
	if (ang == 1)
		/* vertical */
		fprintf(outfile,"DI0,1;\n");
	else
		/* horizontal */
		fprintf(outfile,"DI1,0;\n");
	return TRUE;
}

HPGL_reset()
{
       fprintf(outfile,"PG;\n");
       /*  This HPGL command is ignored in HPGL/2 */
}


PCL_reset()
{
	fputs("\033%0A\033&l0H\033E\n",outfile);
/*         PCL mode   eject reset  */
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































Deleted r34.1/plot/term/hpljii.trm version [b9efe0f3a5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
 * $Id: hpljii.trm,v 3.26 92/03/24 22:34:57 woo Exp Locker: woo $
 */

/* GNUPLOT - hpljii.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  hpljii, hpdj
 *
 * AUTHORS
 *  John Engels
 *  Russell Lang
 *  Maurice Castro
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/* The following HP laserjet series II driver uses generic bit mapped graphics
   routines from bitmap.c to build up a bit map in memory.  The driver
   interchanges colomns and lines in order to access entire lines
   easily and returns the lines to get bits in the right order :
   (x,y) -> (y,XMAX-1-x). */
/* This interchange is done by calling b_makebitmap() with reversed 
   xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
   will then perform the interchange before each pixel is plotted */
/* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
   of Jyrki Yli-Nokari */

#ifdef HPLJII

/* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
   75ppi.  (Pixel size = 1, 2, 3, 4 dots) */

#define HPLJII_DPP (hplj_dpp)   /* dots per pixel */
#define HPLJII_PPI (300/HPLJII_DPP) /* pixel per inch */
/* make XMAX and YMAX a multiple of 8 */
#define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
#define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))

#define HPLJII_VCHAR (HPLJII_PPI/6) /* Courier font with 6 lines per inch */
#define HPLJII_HCHAR (HPLJII_PPI/10) /* Courier font with 10 caracters
                                        per inch */

/* default values for term_tbl */
#define HPLJII_75PPI_XMAX (1920/4)
#define HPLJII_75PPI_YMAX (1920/4)
#define HPLJII_75PPI_HCHAR (1920/4/6)
#define HPLJII_75PPI_VCHAR (1920/4/10)
#define HPLJII_75PPI_VTIC 5
#define HPLJII_75PPI_HTIC 5


#define HPLJII_PUSH_CURSOR fprintf(outfile,"\033&f0S") /* Save current
                  cursor position */
#define HPLJII_POP_CURSOR fprintf(outfile,"\033&f1S") /* Restore
                  cursor position */
#define HPLJII_COURIER fprintf(outfile,"\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D")
         /* be sure to use courier font with 6lpi and 10cpi */

static int hplj_dpp=4;
/* bm_pattern not appropriate for 300ppi graphics */
static unsigned int b_300ppi_pattern[] = {0xffff, 0x1111,
        0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff};

HPLJIIoptions()
{
char opt[4];

#define HPDJERROR "expecting dots per inch size 75, 100, 150 or 300"
	if (!END_OF_COMMAND) {
		if (token[c_token].length>3)
			int_error(HPDJERROR,c_token);

		/* almost_equals() won't accept numbers - use strcmp() instead */
		capture(opt,c_token,c_token);
		if (!strcmp(opt,"75")) {
   			hplj_dpp = 4;
		}
		else if (!strcmp(opt,"100")) {
   			hplj_dpp = 3;
		}
		else if (!strcmp(opt,"150")) {
   			hplj_dpp = 2;
		}
		else if (!strcmp(opt,"300")) {
   			hplj_dpp = 1;
		} else {
			int_error(HPDJERROR,c_token);
		}
		c_token++;
	}

	term_tbl[term].xmax = HPLJII_XMAX;
	term_tbl[term].ymax = HPLJII_YMAX;
	switch(hplj_dpp) {
		case 1:
			strcpy(term_options,"300");
			term_tbl[term].v_tic = 15;
			term_tbl[term].h_tic = 15;
			break;
		case 2:
			strcpy(term_options,"150");
			term_tbl[term].v_tic = 8;
			term_tbl[term].h_tic = 8;
			break;
		case 3:
			strcpy(term_options,"100");
			term_tbl[term].v_tic = 6;
			term_tbl[term].h_tic = 6;
			break;
		case 4:
			strcpy(term_options,"75");
			term_tbl[term].v_tic = 5;
			term_tbl[term].h_tic = 5;
			break;
	}
}


HPLJIIinit()
{
#ifdef vms
   reopen_binary();
#endif /* vms */
#ifdef PC
   reopen_binary();
#endif /* PC */
}


HPLJIIgraphics()
{
   term_tbl[term].v_char = HPLJII_VCHAR;
   term_tbl[term].h_char = HPLJII_HCHAR;
   HPLJII_COURIER;
   HPLJII_PUSH_CURSOR;
   /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
      setting b_rastermode to TRUE */
   b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
   b_rastermode = TRUE;
}


/* HPLJIItext by rjl - no compression */
HPLJIItext()
{
  register int x,j,row;

   fprintf(outfile,"\033*t%dR", HPLJII_PPI);
   HPLJII_POP_CURSOR;
   fprintf(outfile, "\033*r1A");

   /* dump bitmap in raster mode */
   for (x = b_xsize-1; x >= 0; x--) {
      row = (b_ysize/8)-1;
      fprintf(outfile, "\033*b0m%dW", b_ysize/8);
      for (j = row; j >= 0; j--) {
         (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
      }
   }
   fprintf(outfile, "\033*rB");

   b_freebitmap();

#ifndef vms  /* most vms spoolers add a formfeed character */
   fprintf(outfile,"\f");
#endif /* not vms */
}



HPLJIIlinetype(linetype)
int linetype;
{

   if (hplj_dpp == 1) {
      if (linetype>=7)
          linetype %= 7;
      /* b_pattern not appropriate for 300ppi graphics */
      b_linemask = b_300ppi_pattern[linetype+2];
      b_maskcount=0;
   }
   else {
      b_setlinetype(linetype);
   }
}

#define HPLJIImove b_move
#define HPLJIIvector b_vector
#define HPLJIItext_angle b_text_angle

HPLJIIput_text(x,y,str)
unsigned int x, y;
char *str;
{
   switch (b_angle) {
      case 0:
         y -= HPLJII_VCHAR/5;
         HPLJII_POP_CURSOR;
         HPLJII_PUSH_CURSOR;
         /* (0,0) is the upper left point of the paper */
         fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
                                         ,  (HPLJII_YMAX-y-1)*HPLJII_DPP );
         fputs(str, outfile);
/*       for (; *str; ++str, x += HPLJII_HCHAR)
            HPLJIIputc (x, y, *str, b_angle);*/
         break;
      case 1:
         y += (HPLJII_HCHAR-2*HPLJII_VCHAR)/2;
         y += (HPLJII_VCHAR+HPLJII_HCHAR)*strlen(str)/2;
         for (; *str; ++str, y -= HPLJII_VCHAR)
            HPLJIIputc (x, y, *str, b_angle);
         break;
   }
}

HPLJIIputc(x,y,c,angle)
unsigned int x,y;
int angle;
char c;
{
   HPLJII_POP_CURSOR;
   HPLJII_PUSH_CURSOR;
   /* (0,0) is the upper left point of the paper */
   fprintf(outfile, "\033*p%+dx%+dY", x*HPLJII_DPP
                                   ,  (HPLJII_YMAX-y-1)*HPLJII_DPP );
   fputc(c, outfile);
}


HPLJIIreset()
{
#ifdef vms
   fflush_binary();
#endif /* vms */
}


/* HP DeskJet routines */
HPDJgraphics()
{
	switch(hplj_dpp) {
		case 1:
			b_charsize(FNT13X25);
			term_tbl[term].v_char = FNT13X25_VCHAR;
			term_tbl[term].h_char = FNT13X25_HCHAR;
			break;
		case 2:
			b_charsize(FNT13X25);
			term_tbl[term].v_char = FNT13X25_VCHAR;
			term_tbl[term].h_char = FNT13X25_HCHAR;
			break;
		case 3:
			b_charsize(FNT9X17);
			term_tbl[term].v_char = FNT9X17_VCHAR;
			term_tbl[term].h_char = FNT9X17_HCHAR;
			break;
		case 4:
			b_charsize(FNT5X9);
			term_tbl[term].v_char = FNT5X9_VCHAR;
			term_tbl[term].h_char = FNT5X9_HCHAR;
			break;
	}
	/* rotate plot -90 degrees by reversing XMAX and YMAX and by 
	setting b_rastermode to TRUE */
	b_makebitmap(HPLJII_YMAX,HPLJII_XMAX,1);
	b_rastermode = TRUE;
}


/* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
   hopefully compatible with other HP Deskjet printers */
HPDJtext()
{
  register int x,j,row;

   fprintf(outfile,"\033*b0M");
   fprintf(outfile,"\033*t%dR", HPLJII_PPI);
   fprintf(outfile, "\033*r0A");

   /* dump bitmap in raster mode */
   for (x = b_xsize-1; x >= 0; x--) {
      row = (b_ysize/8)-1;
      fprintf(outfile, "\033*b%dW", b_ysize/8);
      for (j = row; j >= 0; j--) {
         (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
      }
   }
   fprintf(outfile, "\033*rbC");

   b_freebitmap();

#ifndef vms  /* most vms spoolers add a formfeed character */
   fprintf(outfile,"\f");
#endif /* not vms */
}

#define HPDJtext_angle b_text_angle
#define HPDJput_text b_put_text

#endif /* HPLJII */

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/imagen.trm version [ca09b97cd9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/*
 * $Id: imagen.trm,v 3.26 92/03/24 22:35:33 woo Exp Locker: woo $
 */

/* GNUPLOT - imagen.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   Imagen laser printers
 *
 * AUTHORS
 *   Paul E. McKenney, David Kotz
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/*
 * Original for direct Imagen output (but retaining many of the
 * LaTeX extensions) by Paul E. McKenney, 1989.
 * Further modified by David Kotz to fit into gnuplot 2.0.
 * Information Science and Technology Division, SRI International,
 * 333 Ravenswood Ave, Menlo Park, CA 94025.
 * Mail to mckenney@sri.com.
 */

#include "impcodes.h"

#define IMAGEN_PTS_PER_INCH (300)

#define IMAGEN_XMAX (IMAGEN_PTS_PER_INCH * 10) /* 10.0 inches */
#define IMAGEN_YMAX (IMAGEN_PTS_PER_INCH * 75 / 10) /* 7.5 inches */

#define IMAGEN_FONTSIZE 12

#define IMAGEN_HTIC (20)
#define IMAGEN_VTIC (20)
#define IMAGEN_VCHAR (IMAGEN_FONTSIZE*5)
#define IMAGEN_HCHAR (IMAGEN_VCHAR/2)

static int IMAGEN_orgx;		/* absolute-pixel-ORIgin of graph.	*/
static int IMAGEN_orgy;
static int IMAGEN_posx;		/* current drawing position (lines).	*/
static int IMAGEN_posy;
static int IMAGEN_inplot;
static int IMAGEN_xmax;		/* width of graph in pixels.		*/
static int IMAGEN_ymax;		/* height of graph in pixels.		*/
static int IMAGEN_hchar;		/* Height of CHAR in current font.	*/
static int IMAGEN_wchar;		/* Width of CHAR in current font.	*/
static int IMAGEN_blofs;		/* BaseLine OFfSet from bounding box.	*/
static int IMAGEN_angle = -1;	/* 0 for horizontal text, 1 for vertical */
static enum JUSTIFY IMAGEN_justify = LEFT; /* left/center/right */

static IMAGEN_seq_pos;		/* position in sequence */

static void IMAGEN_putwd();
static void IMAGEN_createfamily();
static void IMAGEN_setfont();
static void IMAGEN_setpos();
static char *IMAGEN_cvts();

IMAGEN_init()
{
    char font[10];			/* font name */

    IMAGEN_posx = IMAGEN_posy = 0;

    IMAGEN_orgx = (11.0 * IMAGEN_PTS_PER_INCH - IMAGEN_XMAX) / 2;
    IMAGEN_orgy = (8.5 * IMAGEN_PTS_PER_INCH - IMAGEN_YMAX)/ 2;

    fputs("@document(language impress)", outfile);

    putc(imP_SET_HV_SYSTEM, outfile);
    putc((3<<3)|5, outfile);

    sprintf(font, "cour%02d", IMAGEN_FONTSIZE);
    IMAGEN_createfamily(font, IMAGEN_FONTSIZE);
    IMAGEN_setfont(IMAGEN_FONTSIZE);

    IMAGEN_text_angle(0);

    putc(imP_SET_ABS_H, outfile);
    IMAGEN_putwd(0);
    putc(imP_SET_ABS_V, outfile);
    IMAGEN_putwd(0);

    IMAGEN_linetype(-1);
}

IMAGEN_graphics()
{
    static BOOLEAN first = TRUE;

    if (!first)
	 putc(imP_ENDPAGE, outfile);
    first = FALSE;

    IMAGEN_move(0, 0);
}

IMAGEN_text()
{
}


IMAGEN_linetype(linetype)
int linetype;
{
    static int lastlinetype = -10;

    if (linetype < 0)
	 linetype = -linetype;
    else
	 linetype *= 2;

    if (lastlinetype == linetype)
	 return;

    lastlinetype = linetype;	/* now >= 0 */

    putc(imP_SET_PEN, outfile);
    putc(linetype, outfile);
}


IMAGEN_move(x,y)
	unsigned int x,y;
{
    IMAGEN_posx = x;
    IMAGEN_posy = y;
}

IMAGEN_vector(ux,uy)
	unsigned int ux,uy;
{
    /* Create path. */

    putc(imP_CREATE_PATH, outfile);
    IMAGEN_putwd(2);
    IMAGEN_putwd(IMAGEN_posx + IMAGEN_orgx);
    IMAGEN_putwd(IMAGEN_posy + IMAGEN_orgy);
    IMAGEN_putwd(ux + IMAGEN_orgx);
    IMAGEN_putwd(uy + IMAGEN_orgy);

    /* Draw path with black pen. */

    putc(imP_DRAW_PATH, outfile);
    putc(15, outfile);

    /* Set current position to end of line. */

    IMAGEN_move(ux, uy);
}

static void
IMAGEN_setpos(ux, uy)
	int ux,uy;
{
    /* Set x and y position (for text), also set beginning-of-line. */

    putc(imP_SET_ABS_H, outfile);
    IMAGEN_putwd(ux + IMAGEN_orgx);
    putc(imP_SET_ABS_V, outfile);
    IMAGEN_putwd(uy + IMAGEN_orgy);
    putc(imP_SET_BOL, outfile);
    if (IMAGEN_angle == 1)
	 IMAGEN_putwd(uy + IMAGEN_orgx); /* vertical */
    else
	 IMAGEN_putwd(ux + IMAGEN_orgx); /* horizontal */
}

IMAGEN_text_angle(angle)
	int angle;
{
    if (IMAGEN_angle != angle) {
	   IMAGEN_angle = angle;	/* record for later use */
	   putc(imP_SET_ADV_DIRS, outfile);
	   putc(angle == 0 ? 0 : 7, outfile); /* 0=>horiz : 7=>vert */
    }

    return(TRUE);
}

IMAGEN_justify_text(mode)
	enum JUSTIFY mode;
{
    IMAGEN_justify = mode;
    return(TRUE);
}

static char *
IMAGEN_cvts(str, width, height)
	char		*str;
	int		*width;
	int		*height;
{
    char		*cp1;
    char		*cp2;
    static char	*buf = NULL;
    int		h;
    int		maxw;
    int		w;

    /* Free up old buffer, if there is one, get a new one.  Since	*/
    /* all transformations shorten the string, get a buffer that is	*/
    /* the same size as the input string.				*/

    if (buf != NULL)
	 (void) free(buf);
    buf = (char *) alloc(strlen(str), "converted label string");

    /* Do the transformations. */

    cp1 = str;
    cp2 = buf;
    h = 1;
    maxw = 0;
    w = 0;
    while (strlen(cp1) > 0) {
	   switch (*cp1) {
		  case ' ' :		/* Space character. */
		    *cp2++ = imP_SP;
		    w++;
		    break;
		    
		    case  '\\' :	/* Escape sequence. */
			 if (*++cp1 == '\\') {
				/* Begin new line. */
				h++;
				if (w > maxw)
				  maxw = w;
				w = 0;
				*cp2++ = imP_CRLF;
				break;
			 }
		    
		    /* Fall through to just copy next char out.	*/
		    
		    default :
			 *cp2++ = *cp1;
		    w++;
		    break;
		}
	   cp1++;
    }
    
    *cp2 = '\0';
    if (w > maxw)
	 maxw = w;
    
    if (height != NULL)
	 *height = IMAGEN_angle ?
	   IMAGEN_wchar * maxw :
		IMAGEN_hchar * h;
    if (width != NULL)
	 *width = IMAGEN_angle ?
	   IMAGEN_hchar * h :
		IMAGEN_wchar * maxw;
    return (buf);
}

IMAGEN_put_text(x, y, str)
	int x,y;				/* reference point of string */
	char str[];			/* the text */
{
    char *cvstr;
    int height;
    int width;
    
    cvstr = IMAGEN_cvts(str, &width, &height);

    switch (IMAGEN_justify) {
	   case LEFT: break;
	   case CENTRE: x -= width/2; break;
	   case RIGHT: x -= width; break;
    }

    if (IMAGEN_angle) {		/* vertical */
	   x += IMAGEN_hchar;
	   y -= height/2;
    } else				/* horizontal */
	 y += height/2 - IMAGEN_hchar;

    IMAGEN_setpos(x, y + IMAGEN_blofs);
    fputs(cvstr, outfile);
}


IMAGEN_reset()
{
    putc(imP_EOF, outfile);
}

static void
IMAGEN_putwd(w)
{
	putc(w>>8, outfile);
	putc(w, outfile);
}

static void
IMAGEN_createfamily(c, sz)
	char		*c;
	int		sz;
{
    putc(imP_CREATE_FAMILY_TABLE, outfile);
    putc(sz, outfile);
    putc(1, outfile);
    putc(0, outfile);
    fputs(c, outfile);
    putc(0, outfile);
}

static void
IMAGEN_setfont(sz) 
    int sz;
{
    IMAGEN_hchar = sz * 5;
    IMAGEN_wchar = IMAGEN_hchar / 2;
    IMAGEN_blofs = IMAGEN_hchar / 3;
    putc(imP_SET_FAMILY, outfile);
    putc(sz, outfile);
    putc(imP_SET_SP, outfile);
    IMAGEN_putwd(IMAGEN_wchar);
    putc(imP_SET_IL, outfile);
    IMAGEN_putwd(IMAGEN_hchar);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/impcodes.h version [ec265e66cc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * $Id: impcodes.h,v 3.26 92/03/24 22:35:32 woo Exp Locker: woo $
 */

/*
 * Copyright (c) 1985 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)imPcodes.h	5.1 (Berkeley) 9/21/85
 */

#define	imP_SP	128
#define	imP_SP1	129
#define	imP_OLD_MMOVE	130
#define	imP_MPLUS	131
#define	imP_MMINUS	132
#define	imP_MMOVE	133
#define	imP_SMOVE	134

#define	imP_SET_ABS_H	135
#define	imP_SET_REL_H	136
#define	imP_SET_ABS_V	137
#define	imP_SET_REL_V	138

#define	imP_SRULE	192
#define	imP_BRULE	193

#define	imP_SET_HPOS	195
#define	imP_SET_VPOS	196
#define	imP_CRLF	197
#define	imP_SGLY	198
#define	imP_BGLY	199
#define	imP_DELG	200
#define	imP_DELC	201
#define	imP_DELF	202

#define	imP_SET_HV_SYSTEM	205
#define	imP_SET_ADV_DIRS	206
#define	imP_SET_FAMILY	207
#define	imP_SET_IL	208
#define	imP_SET_BOL	209
#define	imP_SET_SP	210
#define	imP_PUSH	211
#define	imP_POP	212
#define	imP_PAGE	213
#define	imP_SET_PUSH_MASK	214
#define	imP_ENDPAGE	219

#define	imP_CREATE_FAMILY_TABLE	221
#define	imP_CREATE_MAP	222

#define	imP_CREATE_PATH	230
#define	imP_SET_TEXTURE	231
#define	imP_SET_PEN	232
#define	imP_FILL_PATH	233
#define	imP_DRAW_PATH	234
#define	imP_BITMAP	235
#define	imP_SET_MAGN	236

#define	imP_EOF	255


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted r34.1/plot/term/iris4d.trm version [864bcb98fe].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 * $Id: iris4d.trm,v 3.26 92/03/24 22:35:35 woo Exp Locker: woo $
 */

/* GNUPLOT - iris4d.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   IRIS terminals
 *
 * AUTHORS
 *   John H. Merritt 
 *           (Applied Research Corporation) 7/1/89
 *           INTERNET: merritt@iris613.gsfc.nasa.gov
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#include <gl.h>

#define IRIS4DRC    ".gnuplot_iris4d"

#define IRIS4D_XMAX 1024
#define IRIS4D_YMAX 1024

#define IRIS4D_XLAST (IRIS4D_XMAX - 1)
#define IRIS4D_YLAST (IRIS4D_YMAX - 1)

#define IRIS4D_VCHAR (IRIS4D_YMAX/30)
#define IRIS4D_HCHAR (IRIS4D_XMAX/72)
#define IRIS4D_VTIC (IRIS4D_YMAX/80)
#define IRIS4D_HTIC (IRIS4D_XMAX/80)

static short colors24bits[][3] =
{
    { 85,  85,  85  },  /* 0. BACK GROUND ( DARKGRAY ) */
    { 0,   0,   0   },  /* 1. BLACK */
    { 170, 0,   170 },  /* 2. MAGENTA */
    { 85,  255, 255 },  /* 3. LIGHTCYAN */
    { 170, 0,   0   },  /* 4. RED */
    { 0,   170, 0   },  /* 5. GREEN */
    { 255, 85,  255 },  /* 6. LIGHTMAGENTA */
    { 255, 255, 85  },  /* 7. YELLOW */
    { 255, 85,  85  },  /* 8. LIGHTRED */
    { 85,  255, 85  },  /* 9. LIGHTGREEN */
    { 0,   170, 170 },  /* 10. CYAN */
    { 170, 170, 0   },  /* 11. BROWN */
};
#define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))

static iris24bits = FALSE;

#define IRIS4D_BACKGROUND	0
#define IRIS4D_BLACK		1
#define IRIS4D_MAGENTA		2
#define IRIS4D_LIGHTCYAN	3
#define IRIS4D_RED		4
#define IRIS4D_GREEN		5
#define IRIS4D_LIGHTMAGENTA	6
#define IRIS4D_YELLOW		7
#define IRIS4D_LIGHTRED		8
#define IRIS4D_LIGHTGREEN	9
#define IRIS4D_CYAN		10
#define IRIS4D_BROWN		11

IRIS4D_options()
{
  int i = 0;
  struct value a;
  extern struct value *const_express();
  extern double real();

  if (!END_OF_COMMAND) {
    i = (int) real(const_express(&a));
  }

  iris24bits = (i == 24);

  sprintf(term_options, "%s",iris24bits ? "24" : "8");
}

IRIS4D_init()
{
  int i;
  char homedirfile[80], line[80];
  FILE *f;

  foreground();
  winopen("Gnuplot");
  if (iris24bits)
  {
    RGBmode();
    gconfig();
  }

  strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
  if ((f = fopen(IRIS4DRC, "r")) != NULL ||
      (f = fopen(homedirfile, "r")) != NULL) {
    int c1, c2, c3;
    for (i = 0; i < COLOR24_SIZE; i++) {
      if (fgets(line, 79, f) == NULL ||
	  sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
	int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
      colors24bits[i][0] = c1;
      colors24bits[i][1] = c2;
      colors24bits[i][2] = c3;
    }
      
    fclose(f);
  }
  deflinestyle(1, 0x3FFF); /* long dash */
  deflinestyle(2, 0x5555); /* dotted */
  deflinestyle(3, 0x3333); /* short dash */
  deflinestyle(4, 0xB5AD); /* dotdashed */
  deflinestyle(5, 0x0F0F); /* dashed */
  deflinestyle(6, 0xBBBB); /* dotdashed */
  deflinestyle(7, 0x3F3F); /* mid-long dash */
  deflinestyle(8, 0x7777); /* mid-long dash */

  return;
}

IRIS4D_graphics()
{
  reshapeviewport();
  ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
  if (iris24bits)
    RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
	     colors24bits[IRIS4D_BACKGROUND][1],
	     colors24bits[IRIS4D_BACKGROUND][2]);
  else
    color(WHITE);

  clear();
  
  return;
}

IRIS4D_text()
{
  return; /* enter text from another window!!! */
}

IRIS4D_linetype(linetype)
int linetype;
{
  static int pen_color_24[11] =
    {
      IRIS4D_BLACK,		/* reserved for border and numbers */
      IRIS4D_MAGENTA,		/* reserved for axis traces */
      IRIS4D_LIGHTCYAN,
      IRIS4D_RED,
      IRIS4D_GREEN,
      IRIS4D_LIGHTMAGENTA,
      IRIS4D_YELLOW,
      IRIS4D_LIGHTRED,
      IRIS4D_LIGHTGREEN,
      IRIS4D_CYAN,
      IRIS4D_BROWN,
    };
  static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};

  if (iris24bits)
  {
    int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];

    RGBcolor(colors24bits[pencolor][0],
	     colors24bits[pencolor][1],
	     colors24bits[pencolor][2]);
    /* Make all lines solid (linestyle 0) upto to the ninth. If more than
     * 9 colors are needed, start to use the different line styles (1 to 8).
     */
    setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
  }
  else
  {
    linetype = linetype % 8;
    color((Colorindex) pen_color[linetype]);
    setlinestyle(linetype);
  }
  return;
}

IRIS4D_move(x, y)
unsigned int x, y;
{
  move2i(x, y);
  return;
}

IRIS4D_cmove(x, y)
unsigned int x, y;
{
  cmov2i(x, y);
  return;
}

IRIS4D_vector(x, y)
unsigned x, y;
{
  draw2i(x, y);
  return;
}


IRIS4D_put_text(x,y,str)
int x, y;
char *str;
{
  IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
  charstr(str);
  return;
}


IRIS4D_reset()
{
  return;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































Deleted r34.1/plot/term/kyo.trm version [4569a884e7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * $Id: kyo.trm,v 3.26 92/03/24 22:35:36 woo Exp Locker: woo $
 */

/* Prescribe (KYOCERA) driver - Michael Waldor */
/* Modified for gnuplot 2.0 sk@sun4 24-Apr-1990 13:23 */
#ifdef PRESCRIBE

#define PRE_XMAX 2567
#define PRE_YMAX 1815	/* X:Y = sqrt(2) */

#define PRE_XLAST (PRE_XMAX - 1)
#define PRE_YLAST (PRE_YMAX - 1)

#define PRE_VCHAR (PRE_YMAX/30)
#define PRE_HCHAR 33	/* about 9 chars per inch */
#define PRE_HTIC (PRE_XMAX/80)
#define PRE_VTIC PRE_HTIC

/* for Courier font: */
#define KYO_VCHAR (14*(300/72))	/* 12 pt + 2 pt baselineskip */
#define KYO_HCHAR (300/10)	/*  10 chars per inch */

enum JUSTIFY pre_justify=LEFT;	/* text is flush left */

PRE_init()
{
  (void) fprintf(outfile,"!R! RES;\n") ;
  /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
  /* SPO: landscape format */
  /* STM, SLM set top, left margin*/
  /* Font: bold Helvetica (proportional font) */
  (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
  (void) fprintf(outfile,"FTMD 15; FONT 29; SCPI 9;\n") ;
}

KYO_init()
{
  (void) fprintf(outfile,"!R! RES;\n") ;
  /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
  /* SPO: landscape format */
  /* STM, SLM set top, left margin */
  /* Font: Courier (fixed width font) */
  (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
  (void) fprintf(outfile,"FTMD 15; FONT 17; SCPI 10;\n") ;
}

PRE_graphics()
{
}

PRE_text()			/* eject page after each plot */
{
  (void) fprintf(outfile,"PAGE;\n") ; 
}

PRE_linetype(linetype)
int linetype ;
{
  /* actually choose pendiameter */
  if (linetype < 0) linetype = -linetype;
  else linetype = 3;
  (void) fprintf(outfile,"SPD %d;\n", linetype) ;
}
 
PRE_move(x,y)
unsigned int x,y ;
{
  (void) fprintf(outfile,"MAP %1d,%1d;\n",x,PRE_YMAX-y) ;
}
 
PRE_vector(x,y)
unsigned int x,y ;
{
  (void) fprintf(outfile,"DAP %1d, %1d;\n",x,PRE_YMAX-y) ;
}
 
PRE_put_text(x, y, str)
unsigned int x,y ;
char *str;
{
  PRE_move(x,y);
  switch(pre_justify){
  case RIGHT:
    (void) fprintf(outfile,"RTXT \"%s\", B;\n",str) ;
    break;
  default:
    (void) fprintf(outfile,"TEXT \"%s\", B;\n",str) ;
  }
}
 
int PRE_justify_text(mode)
enum JUSTIFY mode;
{
  pre_justify=mode;
  switch(pre_justify){
  case LEFT:
  case RIGHT:
    return(TRUE);
  default:
    return(FALSE);
  }
  
}

PRE_reset()
{
  (void) fprintf(outfile,"PAGE; RES; EXIT;\n");
}

#endif /* PRESCRIBE */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































Deleted r34.1/plot/term/latex.trm version [bb91a8f450].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*
 * $Id: latex.trm,v 3.26 92/03/24 22:35:37 woo Exp Locker: woo $
 */

/* GNUPLOT - latex.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   LaTeX pictures (latex).
 *   LaTeX pictures with emTeX specials (emtex). 
 *
 * AUTHORS
 *   David Kotz, Russell Lang
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/* modified to optimize use of \rule for long lines */

/* the following LATEX driver has been modified by 
   Russell Lang, eln272v@monu1.cc.monash.oz from the
   GnuTeX 1.3 driver by David Kotz, David.Kotz@Dartmouth.edu.
   Since then it has been further extended by David Kotz.
   EmTeX driver by Russell Lang. */


#define LATEX_PTS_PER_INCH (72.27)
#define DOTS_PER_INCH (300)	/* resolution of printer we expect to use */
#define LATEX_UNIT (LATEX_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */

/* 5 inches wide by 3 inches high (default) */
#define LATEX_XMAX (5*DOTS_PER_INCH)  /* (LATEX_PTS_PER_INCH/LATEX_UNIT*5.0) */
#define LATEX_YMAX (3*DOTS_PER_INCH)  /* (LATEX_PTS_PER_INCH/LATEX_UNIT*3.0) */

#define LATEX_HTIC (5*DOTS_PER_INCH/72)		/* (5./LATEX_UNIT) */
#define LATEX_VTIC (5*DOTS_PER_INCH/72)		/* (5./LATEX_UNIT) */
#define LATEX_HCHAR (DOTS_PER_INCH*53/10/72)	/* (5.3/LATEX_UNIT) */
#define LATEX_VCHAR (DOTS_PER_INCH*11/72)	/* (11./LATEX_UNIT) */

static int LATEX_posx;
static int LATEX_posy;
static enum JUSTIFY latex_justify=LEFT;
static int latex_angle=0;

/* Default line-drawing character */
/* the definition of plotpoint varies with linetype */
#define LATEX_DOT "\\usebox{\\plotpoint}"
#define LATEX_TINY_DOT "\\rule{.1pt}{.1pt}" /* for dots plot style */

/* POINTS */
#define LATEX_POINT_TYPES 12	/* we supply more point types */
static char *LATEX_points[] = {
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
    "\\makebox(0,0){$+$}",
    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}",
    "\\makebox(0,0){$\\times$}",
    "\\makebox(0,0){$\\triangle$}",
    "\\makebox(0,0){$\\star$}",
    "\\circle{12}", "\\circle{18}", "\\circle{24}",
    "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
};

/* LINES */
static float LATEX_size = 0;	/* current thick of line in points */
static float LATEX_dotspace = 0; /* current dotspace of line in points */
#define LATEX_LINE_TYPES 6	/* number of line types below */
#define LATEX_THIN_LINE 0	/* the thinnest solid line type */
static struct {
    float size;			/* size of dot, or thick of line in points */
    float dotspace;			/* inter-dot space in points; 0 for lines */
} LATEX_lines[] = {
    {.35, 0.0},				/* thin solid line */
    {.7, 0.0},				/* thick solid line */
    {1.0, 0.0},				/* Thick solid line */
    {.5, 5.0},				/* dotted line */
    {.5, 9.0},				/* widely dotted line */
    {.5, 13.0}				/* really widely dotted line */
};
/* for drawing dotted and solid lines */
static void LATEX_dot_line();
static void LATEX_solid_line();
static void LATEX_rule();
static void LATEX_flushdot();
#define LATEX_flushrule() LATEX_rule(2, 0.,0.,0.,0.) /* flush old rule */
static BOOLEAN LATEX_moved = TRUE;	/* pen is up after move */
static float LATEX_dotsize;	/* size of LATEX_DOT in units */
static BOOLEAN LATEX_needsdot = FALSE;/* does dotted line need termination? */

#ifdef EMTEX
BOOLEAN emtex=FALSE; /* not currently using emtex */
static void EMTEX_solid_line();
#endif

/* ARROWS */
/* the set of non-vertical/non-horizontal LaTeX vector slopes */
/* except negatives - they are handled specially */
static struct vslope {
    int dx, dy;
} LATEX_slopes[] = {
    {1,1}, {1,2}, {1,3}, {1,4},
    {2,1}, {2,3},
    {3,1}, {3,2}, {3,4},
    {4,1}, {4,3},
    {0,0}					/* terminator */
};
static void best_latex_arrow(); /* figure out the best arrow */

LATEX_init()
{
#ifdef EMTEX
    emtex = FALSE;
#endif
    LATEX_posx = LATEX_posy = 0;
    fprintf(outfile, "%% GNUPLOT: LaTeX picture\n");
    fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
    fprintf(outfile, 
		  "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
    LATEX_linetype(-1);
	LATEX_size =0;
}


LATEX_scale(xs, ys)
	double xs, ys;			/* scaling factors */
{
    register struct termentry *t = &term_tbl[term];

    /* we change the table for use in graphics.c and LATEX_graphics */
    t->xmax = (unsigned int)(LATEX_XMAX * xs);
    t->ymax = (unsigned int)(LATEX_YMAX * ys);

    return(TRUE);
}

LATEX_graphics()
{
    register struct termentry *t = &term_tbl[term];

    fprintf(outfile, "\\begin{picture}(%d,%d)(0,0)\n", t->xmax, t->ymax);
    fprintf(outfile, "\\tenrm\n");
}


LATEX_text()
{
    LATEX_flushrule();
    LATEX_flushdot();
    fprintf(outfile, "\\end{picture}\n");
    LATEX_posx = LATEX_posy = 0; /* current position */
    LATEX_moved = TRUE;	/* pen is up after move */
}

LATEX_linetype(linetype)
	int linetype;
{
    float size;

    if (linetype >= LATEX_LINE_TYPES)
	 linetype %= LATEX_LINE_TYPES;

#ifdef EMTEX
    if (!emtex)
#endif
    LATEX_flushrule();
    LATEX_flushdot();

    /* Find the new desired line thickness. */
    /* negative linetypes (for axes) use a thin line */
    /* only relevant for drawing axes/border in 3d */
    size = (linetype >= 0 ? LATEX_lines[linetype].size 
		  : LATEX_lines[LATEX_THIN_LINE].size);

    /* If different from current size, redefine \plotpoint */
    if (size != LATEX_size) {
	   fprintf(outfile, 
			 "\\sbox{\\plotpoint}{\\rule[%.3fpt]{%.3fpt}{%.3fpt}}%%\n",
			 -size/2, size, size);
#ifdef EMTEX
        if (emtex)         /* change line width */
		fprintf(outfile, "\\special{em:linewidth %.1fpt}%%\n", size);
#endif
    }
    
    LATEX_size = size;
    LATEX_dotsize = size / LATEX_UNIT;
    LATEX_dotspace = (linetype >= 0) ? LATEX_lines[linetype].dotspace : 0;
    LATEX_moved = TRUE;			/* reset */
}

LATEX_move(x,y)
	unsigned int x,y;
{
    LATEX_flushdot();

    LATEX_posx = x;
    LATEX_posy = y;
    LATEX_moved = TRUE;			/* reset */
}


LATEX_point(x,y, number)		/* version of line_and_point */
	unsigned int x,y;
	int number;				/* type of point */
{
    LATEX_move(x,y);
    
    /* Print the character defined by 'number'; number < 0 means 
	  to use a dot, otherwise one of the defined points. */
    fprintf(outfile, "\\put(%d,%d){%s}\n", x, y, 
		  (number < 0 ? LATEX_TINY_DOT
		   : LATEX_points[number % LATEX_POINT_TYPES]));
}


LATEX_vector(ux,uy)
	unsigned int ux,uy;
{
    if (LATEX_dotspace == 0.0) {
	   /* solid line */
#ifdef EMTEX
	   if (emtex)
		EMTEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
	   else
#endif
		LATEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
    } else
	 /* dotted line */
	 LATEX_dot_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);

    LATEX_posx = ux;
    LATEX_posy = uy;
}

static void
LATEX_solid_line(x1,x2, y1,y2)
	int x1,x2, y1,y2;
{
    float slope;
    int inc;
    float next;
    float x,y;
    int code;				/* possibly combine with previous rule */

    /* we draw a solid line using the current line thickness (size) */
    /* we do it with lots of \\rules */

    if (x1 == x2 && y1 == y2) { /* zero-length line - just a dot */
	   if (LATEX_moved) {
		  LATEX_flushrule();
		  /* plot a dot */
		  fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
	   }
    } else {
	   code = (LATEX_moved ? 0 : 1); /* no combine after move */
	   if (x1 == x2)		/* vertical line - special case */
		LATEX_rule(code, (double)x1, (double)y1,
			   LATEX_dotsize, (double)y2-y1);
	   else if (y1 == y2)	/* horizontal line - special case */
		LATEX_rule(code, (double)x1, (double)y1, (double)x2-x1,
			   LATEX_dotsize);
	   else {
		  slope = ((float)y2-y1)/((float)x2-x1);
		  if (abs(slope) <= 1.0) {
			 /* longer than high */
			 inc = sign(y2-y1);
			 for (x = x1, y = y1; (y2-y)*inc >= 0; y += inc) {
				next = inc/slope + x;
				if ((x2>x1 && next > x2) || (x2<x1 && next < x2)) {
				    LATEX_rule(code, x,y, x2-x, LATEX_dotsize);
				    break;
				} else {
				    LATEX_rule(code, x,y, next-x, LATEX_dotsize);
				    x = next;
				}
				code = 0;
			 }
		  } else {
			 /* higher than long */
			 inc = sign(x2-x1);
			 for (x = x1, y = y1; (x2-x)*inc >= 0; x += inc) {
				next = inc*slope + y;
				if ((y2>y1 && next > y2) || (y2<y1 && next < y2)) {
				    LATEX_rule(code, x,y, LATEX_dotsize, y2-y);
				    break;
				} else {
				    LATEX_rule(code, x,y, LATEX_dotsize, next-y);
				    y = next;
				}
				code = 0;
			 }
		  }
	   }
    }
    LATEX_moved = FALSE;
}

/* Draw a \rule. Width or height may be negative; we can correct.
 * The rule is never output immediately. The previous rule is output
 * as-is if code is 0, and the previous rule is
 * combined with the current rule (if possible) if code is 1.
 * The previous rule is output, and the new one ignored, if code is 2.
 */
static void
LATEX_rule(code, x,y, width, height)
	int code;				/* how do we treat this rule? */
	double x, y;
	double width;
	double height;
{  
    static float lastx, lasty;
    static float lastw, lasth;
    static BOOLEAN valid = FALSE; /* is 'last' data valid? */
    BOOLEAN combine = (code == 1);
    BOOLEAN flush = (code == 2);

    if (!flush)
	 if (width == 0 || height == 0)
	   return;			/* ignore this rule */

    if (valid && combine) {
	   /* try to combine new rule with old rule */
	   if ((int)lastx == (int)x && lastw == width) { /* vertical rule */
		  if (lasth * height >= 0) { /* same sign */
			 lasth += height;
			 return;
		  }
	   } else if ((int)lasty == (int)y && lasth == height){ /* horiz rule */
		  if (lastw * width >= 0) { /* same sign */
			 lastw += width;
			 return;
		  }
	   }
	   /* oh well, output last and remember the new one */
    }

    if (valid) {
	   /* output the rule */
	   if (lastw < 0) {
		  lastx += lastw;
		  lastw = -lastw;
	   }
	   if (lasth < 0) {
		  lasty += lasth;
		  lasth = -lasth;
	   }

	   /* if very small use canned dot */
	   if (lastw < LATEX_dotsize || lasth < LATEX_dotsize)
		fprintf(outfile, "\\put(%d,%d){%s}\n",	   
			   (int)lastx, (int)lasty, LATEX_DOT);
	   else
		fprintf(outfile, "\\put(%d,%d){\\rule[%.3fpt]{%.3fpt}{%.3fpt}}\n",
			   (int)lastx, (int)lasty, -LATEX_dotsize*LATEX_UNIT/2,
			   lastw*LATEX_UNIT, lasth*LATEX_UNIT);
    }
    
    if (flush) {
	   valid = FALSE;
    } else {
	   lastx = x; lasty = y;
	   lastw = width; lasth = height;
	   valid = TRUE;
    }
}

static void
LATEX_dot_line(x1,x2, y1,y2)
	int x1,x2, y1,y2;
{
    static float LATEX_left;	/* fraction of space left after last dot */
#ifndef AMIGA_AC_5
    extern double sqrt();
#endif
    /* we draw a dotted line using the current dot spacing */

    if (LATEX_moved)
	 LATEX_left = 1.0;		/* reset after a move */

    /* zero-length line? */
    if (x1 == x2 && y1 == y2) {
	   if (LATEX_moved)
		/* plot a dot */
		fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
    } else {
	   float dotspace = LATEX_dotspace / LATEX_UNIT;
	   float x,y;			/* current position */
	   float xinc, yinc;	/* increments */
	   float slope;		/* slope of line */
	   float lastx = -1;	/* last x point plotted */
	   float lasty = -1;	/* last y point plotted */

	   /* first, figure out increments for x and y */
	   if (x2 == x1) {
		  xinc = 0.0;
		  yinc = (y2-y1>0)?dotspace:-dotspace;
	   } else {
		  slope = ((float)y2-y1)/((float)x2-x1);
		  xinc = dotspace / sqrt(1 + slope*slope) * sign(x2-x1);
		  yinc = slope * xinc;
	   }
	   
	   /* now draw the dotted line */
	   /* we take into account where we last placed a dot */
	   for (x=x1 + xinc*(1-LATEX_left), y=y1 + yinc*(1-LATEX_left);
		   (x2-x)*xinc >= 0 && (y2-y)*yinc >= 0; /* same sign or zero */
		   lastx = x, x += xinc, 
		   lasty = y, y += yinc)
		fprintf(outfile, "\\put(%d,%d){%s}\n", (int)x, (int)y, LATEX_DOT);

	   /* how much is left over, as a fraction of dotspace? */
	   if (xinc != 0.0)			/* xinc must be nonzero */
		if (lastx >= 0)
		  LATEX_left = abs(x2 - lastx) / abs(xinc);
		else
		  LATEX_left += abs(x2-x1) / abs(xinc);
	   else
		if (lasty >= 0)
		  LATEX_left = abs(y2 - lasty) / abs(yinc);
		else
		  LATEX_left += abs(y2-y1) / abs(yinc);
    }

    LATEX_needsdot = (LATEX_left > 0);

    LATEX_moved = FALSE;
}

static void
LATEX_flushdot()
{
    if (LATEX_needsdot) 
	 fprintf(outfile, "\\put(%d,%d){%s}\n", 
		    LATEX_posx, LATEX_posy, LATEX_DOT);
    LATEX_needsdot = FALSE;
}

LATEX_arrow(sx,sy, ex,ey, head)
	int sx,sy, ex,ey;
	BOOLEAN head;
{
    best_latex_arrow(sx,sy, ex,ey, 1, head);

    LATEX_posx = ex;
    LATEX_posy = ey;
}

static void best_latex_arrow(sx,sy, ex,ey, who, head)
	int sx,sy, ex,ey;		/* start and end points */
	int who;				/* 1=LATEX, 2=EEPIC */
	BOOLEAN head;
{
    int dx = ex - sx;
    int dy = ey - sy;
    int x, y;				/* points near sx,sy */
    float m;				/* slope of line */
    float arrowslope;		/* slope of arrow */
    float minerror = 0;		/* best-case error */
    struct vslope *slope;	/* one of the slopes */
    struct vslope *bestslope;	/* the slope with min error */
    BOOLEAN horiz;			/* was it the horiz line that was best? */

    /* We try to draw a real arrow (ie, \vector). If we can't get
	* a slope that is close, we draw a bent arrow.
	*/

    if (dx == 0) {
	   /* vertical arrow */
	   fprintf(outfile, "\\put(%d,%d){\\%s(0,%d){%d}}\n",
			 sx, sy, head ? "vector":"line", 
			 sign(ey-sy), abs(ey-sy));
    } else if (dy == 0) {
	   /* horizontal arrow */
	   fprintf(outfile, "\\put(%d,%d){\\%s(%d,0){%d}}\n",
			 sx, sy, head ? "vector":"line",
			 sign(ex-sx), abs(ex-sx));
    } else {
	   /* Slanted arrow. We'll give it a try.
	    * we try to find the closest-slope arrowhead.
	    */
	   bestslope = NULL;
	   minerror = 0; /* to shut up turbo C */
	   m = abs((float)dy/dx); /* the slope we want */
	   for (slope = LATEX_slopes; slope->dx != 0.0; slope++) {
		  /* find the slope of the arrow */
		  arrowslope = (float) slope->dy / slope->dx;
		  if (bestslope == NULL || abs(m-arrowslope) < minerror) {
			 minerror = abs(m-arrowslope);
			 bestslope = slope;
		  }
	   }

	   /* now we have the best slope arrow */
	   /* maybe it's exactly the right slope! */
	   if (minerror == 0.0)	/* unlikely but possible */
		fprintf(outfile, "\\put(%d,%d){\\%s(%d,%d){%d}}\n",
			   sx, sy, head ? "vector" : "line",
			   bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy),
			   abs(ex-sx));
	   else {
		  /* we draw the line the usual way, with thin lines */
#ifdef EMTEX
		  if (emtex) {
			 LATEX_linetype(LATEX_THIN_LINE);
			 EMTEX_solid_line(sx,ex,sy,ey);
		  } else 
#endif
			if (who == 1) {
			   LATEX_linetype(LATEX_THIN_LINE);
			   LATEX_solid_line(sx,ex,sy,ey);
			}
#ifdef EEPIC
			else {
			   EEPIC_move(sx,sy);
			   EEPIC_vector(ex,ey);
			}
#endif /* EEPIC */
		  /* and then draw an arrowhead (a short vector) there */
			if (head)
		  		fprintf(outfile, "\\put(%d,%d){\\vector(%d,%d){0}}\n",
				ex, ey, 
				bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy));
	   }
    }
}


LATEX_put_text(x, y, str)
	int x,y;				/* reference point of string */
	char str[];			/* the text */
{
    /* ignore empty strings */
    if (str[0] == '\0')
	 return;

    fprintf(outfile, "\\put(%d,%d)",x,y);
    switch(latex_angle) {  
 	   case 0: {
		  switch(latex_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{%s}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0){%s}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[r]{%s}}\n", str);
				break;
			 }
		  }
		  break;
	   }
	   case 1: {			/* put text in a short stack */
		  switch(latex_justify) {
			 case LEFT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case CENTRE: {
				fprintf(outfile,
					   "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
				break;
			 }
			 case RIGHT: {
				fprintf(outfile,
					   "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
				break;
			 }
		  }
		  break;
	   }	
    }
}



int LATEX_justify_text(mode)
	enum JUSTIFY mode;
{
    latex_justify = mode;
    return (TRUE);
}

int LATEX_text_angle(angle)
	int angle;
{
    /* we can't really write text vertically, but this will 
	  put the ylabel centred at the left of the plot, and
	  then we'll make a \shortstack */
    latex_angle = angle;
    return (TRUE);
}

LATEX_reset()
{
    LATEX_posx = LATEX_posy = 0; /* current position */
    LATEX_moved = TRUE;	/* pen is up after move */
}


#ifdef EMTEX

EMTEX_init()
{
    emtex=TRUE;
    LATEX_posx = LATEX_posy = 0;
    fprintf(outfile, "%% GNUPLOT: LaTeX picture with emtex specials\n");
    fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
    fprintf(outfile, 
		  "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
    LATEX_linetype(-1);
}


EMTEX_reset()
{
    emtex=FALSE;
    LATEX_posx = LATEX_posy = 0;
}


EMTEX_text()
{
    fprintf(outfile, "\\end{picture}\n");
}


static void
EMTEX_solid_line(x1,x2, y1,y2)
	int x1,x2, y1,y2;
{
    /* emtex special solid line */
	if (LATEX_moved)
		fprintf(outfile, "\\put(%d,%d){\\special{em:moveto}}\n", x1, y1);
	if ( (x1!=x2) || (y1!=y2) )
		fprintf(outfile, "\\put(%d,%d){\\special{em:lineto}}\n", x2, y2);
    LATEX_posx = x2;
    LATEX_posy = y2;
    LATEX_moved = FALSE;
}


#endif /* EMTEX */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/next.trm version [9f1b7abe2c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/*
 * $Id$
 *
 * $Log$
 */

/* GNUPLOT - next.trm */
/*
 * Copyright (C) 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *     next
 *
 * AUTHORS
 *  Nick Strobel from Russell Lang's post.trm
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 * The 'postscript' driver produces landscape output 10" wide and 7" high.  
 * To get a smaller epsf output use 'set size 0.5,0.5', 
 * 'set term postscript portrait', make only one plot per file
 * and change the first line of the postscript file from
 * '%!PS-Adobe-2.0' to '%!PS-Adobe-2.0 EPSF-2.0'
 * To change font to Times-Roman and font size to 20pts use 
 * 'set term postscript "Times-Roman" 20'.
 */


/* NeXT driver by Nick Strobel, strobel@phast.phys.washington.edu */
#import <math.h>
#import <dpsclient/dpsclient.h>
#import <dpsclient/dpsNeXT.h>
#import <stdlib.h>
#import "../EpsViewer.h"

DPSContext d;
static void window_create(float width, float height);
float width,height;	
float xsize_orig,ysize_orig;  

char next_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
int next_fontsize = 14;					 /* size of font in pts */
BOOLEAN next_portrait = FALSE;				 /* vertical page */
BOOLEAN next_color = FALSE;
BOOLEAN init_called = FALSE;
BOOLEAN initframe_called = FALSE;

int next_page=0;			/* page count */
int next_path_count=0; 	/* count of lines in path */
int next_ang=0;			/* text angle */
enum JUSTIFY next_justify=LEFT;	/* text is flush left */

char *NEXT_header[] = {
"/vpt2 vpt 2 mul def\n",
"/hpt2 hpt 2 mul def\n",
/* flush left show */
"/Lshow { currentpoint stroke moveto\n",
"  0 vshift rmoveto show } def\n", 
/* flush right show */
"/Rshow { currentpoint stroke moveto\n",
"  dup stringwidth pop neg vshift rmoveto show } def\n", 
/* centred show */
"/Cshow { currentpoint stroke moveto\n",
"  dup stringwidth pop -2 div vshift rmoveto show } def\n", 
/* Dash or Color Line */
"/DL { Color {setrgbcolor [] 0 setdash pop}\n",
" {pop pop pop 0 setdash} ifelse } def\n",
/* Border Lines */
"/BL { stroke gnulinewidth 2 mul setlinewidth } def\n",
/* Axes Lines */
"/AL { stroke gnulinewidth 2 div setlinewidth } def\n",
/* Plot Lines */
"/PL { stroke gnulinewidth setlinewidth } def\n",
/* Line Types */
"/LTb { BL [] 0 0 0 DL } def\n", /* border */
"/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */
"/LT0 { PL [] 0 1 0 DL } def\n",
"/LT1 { PL [4 dl 2 dl] 0 0 1 DL } def\n",
"/LT2 { PL [2 dl 3 dl] 1 0 0 DL } def\n",
"/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n",
"/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n",
"/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n",
"/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n",
"/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n",
"/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n",
"/M {moveto} def\n",
"/L {lineto} def\n",
"/P { stroke [] 0 setdash\n", /* Point */
"  currentlinewidth 2 div sub moveto\n",
"  0 currentlinewidth rlineto  stroke } def\n",
"/D { stroke [] 0 setdash  2 copy  vpt add moveto\n", /* Diamond */
"  hpt neg vpt neg rlineto  hpt vpt neg rlineto\n",
"  hpt vpt rlineto  hpt neg vpt rlineto  closepath  stroke\n",
"  P  } def\n",
"/A { stroke [] 0 setdash  vpt sub moveto  0 vpt2 rlineto\n", /* Plus (Add) */
"  currentpoint stroke moveto\n",
"  hpt neg vpt neg rmoveto  hpt2 0 rlineto stroke\n",
"  } def\n",
"/B { stroke [] 0 setdash  2 copy  exch hpt sub exch vpt add moveto\n", /* Box */
"  0 vpt2 neg rlineto  hpt2 0 rlineto  0 vpt2 rlineto\n",
"  hpt2 neg 0 rlineto  closepath  stroke\n",
"  P  } def\n",
"/C { stroke [] 0 setdash  exch hpt sub exch vpt add moveto\n", /* Cross */
"  hpt2 vpt2 neg rlineto  currentpoint  stroke  moveto\n",
"  hpt2 neg 0 rmoveto  hpt2 vpt2 rlineto stroke  } def\n",
"/T { stroke [] 0 setdash  2 copy  vpt 1.12 mul add moveto\n", /* Triangle */
"  hpt neg vpt -1.62 mul rlineto\n",
"  hpt 2 mul 0 rlineto\n",
"  hpt neg vpt 1.62 mul rlineto  closepath  stroke\n",
"  P  } def\n",
"/S { 2 copy A C} def\n", /* Star */
NULL
};

#define NEXT_XOFF	50	/* page offset in pts */
#define NEXT_YOFF	50

#define NEXT_XMAX 7200
#define NEXT_YMAX 5040

#define NEXT_XLAST (NEXT_XMAX - 1)
#define NEXT_YLAST (NEXT_YMAX - 1)

#define NEXT_VTIC (NEXT_YMAX/80)
#define NEXT_HTIC (NEXT_YMAX/80)

#define NEXT_SC (10)				/* scale is 1pt = 10 units */
#define	NEXT_LW (0.5*NEXT_SC)		/* linewidth = 0.5 pts */

#define NEXT_VCHAR (14*NEXT_SC)		/* default is 14 point characters */
#define NEXT_HCHAR (14*NEXT_SC*6/10)

NEXT_options()
{
	extern struct value *const_express();
	extern double real();

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"p$ortrait")) {
			next_portrait=TRUE;
			c_token++;
		}
		else if (almost_equals(c_token,"l$andscape")) {
			next_portrait=FALSE;
			c_token++;
		}
		else if (almost_equals(c_token,"d$efault")) {
			next_portrait=FALSE;
			next_color=FALSE;
			strcpy(next_font,"Courier");
			next_fontsize = 14;
			c_token++;
		}
	}

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"m$onochrome")) {
			next_color=FALSE;
			c_token++;
		}
		else if (almost_equals(c_token,"c$olor")) {
			next_color=TRUE;
			c_token++;
		}
	}

	if (!END_OF_COMMAND && isstring(c_token)) {
		quote_str(next_font,c_token);
		c_token++;
	}

	if (!END_OF_COMMAND) {
		/* We have font size specified */
		struct value a;
		next_fontsize = (int)real(const_express(&a));
		c_token++;
		term_tbl[term].v_char = (unsigned int)(next_fontsize*NEXT_SC);
		term_tbl[term].h_char = (unsigned int)(next_fontsize*NEXT_SC*6/10);
	}

	sprintf(term_options,"%s %s \"%s\" %d",
		next_portrait ? "portrait" : "landscape",
		next_color ? "color" : "monochrome",next_font,next_fontsize);
}


NEXT_init()
{
struct termentry *t = &term_tbl[term];
int i;
float llx,lly,urx,ury;
/* I commented out the postscript comment fields because they are not really 
*  needed (even the bounding box). However, if you'd like to send all the
*  postscript to the context d, they're still there for you
*/

		llx=NEXT_XOFF;
		lly=NEXT_YOFF;

	if(!initframe_called) {
		if(!next_portrait){
			urx=(xsize*(NEXT_XMAX)/NEXT_SC+0.5+NEXT_XOFF);
			ury=(ysize*(NEXT_YMAX)/NEXT_SC+0.5+NEXT_YOFF);
		} else {
			urx=(ysize*(NEXT_YMAX)/NEXT_SC+0.5+NEXT_XOFF);
			ury=(xsize*(NEXT_XMAX)/NEXT_SC+0.5+NEXT_YOFF);
		}
		  width=urx-llx;	
		  height=ury-lly;
		  xsize_orig=xsize;
		  ysize_orig=ysize;	
		  window_create(width,height);
	   	  d=DPSGetCurrentContext();
	   DPSPrintf(d,"/showpage {initgraphics} bind def\n");
  	}
		DPSPrintf(d,"1 setgray\n");
		DPSPrintf(d,"0 1 %g %g rectfill\n",rint(width),rint(height));
		DPSPrintf(d,"0 setgray\n");
		DPSPrintf(d,"0 1 %g %g rectstroke\n",rint(width),rint(height));
//       	DPSPrintf(d,"/_the_saved_vm_ save def\n");
		DPSPrintf(d,"%g %g translate\n",-llx,-lly); /* KEEP this IN! */

//		DPSPrintf(d,"%%!PS-ADOBE-2.0 EPSF-2.0\n");
//		DPSPrintf(d,"%%%%Creator: gnuplot\n");
//		DPSPrintf(d,"%%%%DocumentFonts: %s\n", next_font);
//		DPSPrintf(d,"%%%%BoundingBox: %d %d ", NEXT_XOFF,NEXT_YOFF);
//		if (!next_portrait)
//			DPSPrintf(d,"%d %d\n",(int)width, (int)height);
//		else 
//			DPSPrintf(d,"%d %d\n",(int)width, (int)height);
//		DPSPrintf(d,"%%%%Pages: (atend)\n");
//		DPSPrintf(d,"%%%%EndComments\n");
		DPSPrintf(d,"/gnudict 40 dict def\ngnudict begin\n");
		DPSPrintf(d,"/Color %s def\n",next_color ? "true" : "false");
		DPSPrintf(d,"/gnulinewidth %.3f def\n",NEXT_LW);
		DPSPrintf(d,"/vshift %d def\n", (int)(t->v_char)/(-3));
		DPSPrintf(d,"/dl {%d mul} def\n",NEXT_SC); /* dash length */
		DPSPrintf(d,"/hpt %.1f def\n",NEXT_HTIC/2.0);
		DPSPrintf(d,"/vpt %.1f def\n",NEXT_VTIC/2.0);
		for ( i=0; NEXT_header[i] != NULL; i++)
			DPSPrintf(d,"%s",NEXT_header[i]);
		DPSPrintf(d,"end\n");
//		DPSPrintf(d,"%%%%EndProlog\n");
		init_called=TRUE;
}

static void window_create(float width, float height)
{
	initframe_called=TRUE;
	
	NXApp=[EpsViewer new];
	[NXApp windowCreate:width Height:height];
}

NEXT_graphics()
{
struct termentry *t = &term_tbl[term];
	next_page++;
	if(!init_called)
		NEXT_init();	/* set up the frame properly */
	init_called=FALSE;
//	DPSPrintf(d,"%%%%Page: %d %d\n",next_page,next_page);
	DPSPrintf(d,"gnudict begin\n");
	DPSPrintf(d,"gsave\n");
	DPSPrintf(d,"%d %d translate\n",NEXT_XOFF,NEXT_YOFF);
	if (!next_portrait) {
/* keep plot entirely in the window */
		if(xsize>xsize_orig)
			xsize=xsize_orig;
		if(ysize>ysize_orig)
			ysize=ysize_orig;
	    DPSPrintf(d,"%.3f %.3f scale\n", xsize/NEXT_SC, ysize/NEXT_SC);
	}
	else {
		if(xsize>xsize_orig)
			xsize=xsize_orig;
		if(ysize>ysize_orig)
			ysize=ysize_orig;
	    DPSPrintf(d,"%.3f %.3f scale\n", ysize/NEXT_SC, xsize/NEXT_SC);
	    DPSPrintf(d,"90 rotate\n0 %d translate\n", -NEXT_YMAX);
	}
	DPSPrintf(d,"0 setgray\n");
	DPSPrintf(d,"/%s findfont %d ", next_font, (t->v_char) );
	DPSPrintf(d,"scalefont setfont\n");
	DPSPrintf(d,"newpath\n");
	next_path_count = 0;	
}


NEXT_text()
{
	next_path_count = 0;
	DPSPrintf(d,"stroke\ngrestore\nend\nshowpage\n");
//	DPSPrintf(d,"\ngrestoreall _the_saved_vm_ restore\n");
		
	DPSFlushContext(d);
	
	
}


NEXT_reset()
{	
	DPSPrintf(d,"currentwindow termwindow\n");
	DPSPrintf(d,"nulldevice\n");

	DPSFlushContext(d);
	initframe_called=FALSE;
}


NEXT_linetype(linetype)
int linetype;
{
char *line = "ba012345678"; 
	DPSPrintf(d,"LT%c\n", line[(linetype%9)+2]);
	next_path_count = 0;
}


NEXT_move(x,y)
unsigned int x,y;
{
	DPSPrintf(d,"%d %d M\n", x, y);
	next_path_count += 1;
}


NEXT_vector(x,y)
unsigned int x,y;
{
	DPSPrintf(d,"%d %d L\n", x, y);
	next_path_count += 1;
	if (next_path_count >= 400) {
		DPSPrintf(d,"currentpoint stroke moveto\n");
		next_path_count = 0;
	}
}


NEXT_put_text(x,y,str)
unsigned int x, y;
char *str;
{
char ch;
	NEXT_move(x,y);
	if (next_ang != 0)
		DPSPrintf(d,"currentpoint gsave translate %d rotate 0 0 moveto\n"
			,next_ang*90);
/*	NXPutc(psStream,'(');			*/
	DPSPrintf(d,"%c",'(');
	ch = *str++;
	while(ch!='\0') {
		if ( (ch=='(') || (ch==')') || (ch=='\\') )
/*			NXPutc(psStream,'\\');
		NXPutc(psStream,ch);			*/
			DPSPrintf(d,"%c",'\\');
		DPSPrintf(d,"%c",ch);
		ch = *str++;
	}
	switch(next_justify) {
		case LEFT : DPSPrintf(d,") Lshow\n");
			break;
		case CENTRE : DPSPrintf(d,") Cshow\n");
			break;
		case RIGHT : DPSPrintf(d,") Rshow\n");
			break;
	}
	if (next_ang != 0)
		DPSPrintf(d,"grestore\n");
	next_path_count = 0;
}

int NEXT_text_angle(ang)
int ang;
{
	next_ang=ang;
	return TRUE;
}

int NEXT_justify_text(mode)
enum JUSTIFY mode;
{
	next_justify=mode;
	return TRUE;
}

/* postscript point routines */
NEXT_point(x,y,number)
int x,y;
int number;
{
char *point = "PDABCTS";
	number %= POINT_TYPES;
 	if (number < -1)
		number = -1;		/* negative types are all 'dot' */
	DPSPrintf(d,"%d %d %c\n", x, y, point[number+1]);
	next_path_count = 0;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/object.h version [53209437ff].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
 * $Id: object.h,v 3.26 92/03/24 22:35:34 woo Exp Locker: woo $
 */

/* 
 *	FIG : Facility for Interactive Generation of figures
 *
 *	(c) copy right 1985 by Supoj Sutanthavibul (supoj@sally.utexas.edu)
 *      January 1985.
 *	1st revision : Aug 1985.
 *	2nd revision : Feb 1988.
 *
 *	%W%	%G%
*/
#define					DEFAULT			-1

typedef		struct f_pattern {
			int			w, h;
			int			*p;
			}
		F_pattern;

typedef		struct f_pen {
			int			x, y;
			int			*p;
			}
		F_pen;

typedef		struct f_point {
			int			x, y;
			struct f_point		*next;
			}
		F_point;

typedef		struct f_pos {
			int			x, y;
			}
		F_pos;

typedef		struct f_arrow {
			int			type;
			int			style;
			float			thickness;
			float			wid;
			float			ht;
			}
		F_arrow;

typedef		struct f_ellipse {
			int			type;
#define					T_ELLIPSE_BY_RAD	1
#define					T_ELLIPSE_BY_DIA	2
#define					T_CIRCLE_BY_RAD		3
#define					T_CIRCLE_BY_DIA		4
			int			style;
			int			thickness;
			int			color;
#define					BLACK			0
			int			depth;
			int			direction;
			float			style_val;
			float			angle;
			struct f_pen		*pen;
			struct f_pattern	*area_fill;
#define		       			UNFILLED	(F_pattern *)0
#define		       			BLACK_FILL	(F_pattern *)1
#define		       			DARK_GRAY_FILL	(F_pattern *)2
#define		       			MED_GRAY_FILL	(F_pattern *)3
#define		       			LIGHT_GRAY_FILL	(F_pattern *)4
#define		       			WHITE_FILL	(F_pattern *)4
			struct f_pos		center;
			struct f_pos		radiuses;
			struct f_pos		start;
			struct f_pos		end;
			struct f_ellipse	*next;
			}
		F_ellipse;

typedef		struct f_arc {
			int			type;
#define					T_3_POINTS_ARC		1
			int			style;
			int			thickness;
			int			color;
			int			depth;
			struct f_pen		*pen;
			struct f_pattern	*area_fill;
			float			style_val;
			int			direction;
			struct f_arrow		*for_arrow;
			struct f_arrow		*back_arrow;
			struct {float x, y;}	center;
			struct f_pos		point[3];
			struct f_arc		*next;
			}
		F_arc;

typedef		struct f_line {
			int			type;
#define					T_POLYLINE	1
#define					T_BOX		2
#define					T_POLYGON	3
			int			style;
			int			thickness;
			int			color;
			int			depth;
			float			style_val;
			struct f_pen		*pen;
			struct f_pattern	*area_fill;
			struct f_arrow		*for_arrow;
			struct f_arrow		*back_arrow;
			struct f_point		*points;
			struct f_line		*next;
			}
		F_line;

typedef		struct f_text {
			int			type;
#define					T_LEFT_JUSTIFIED	0
#define					T_CENTER_JUSTIFIED	1
#define					T_RIGHT_JUSTIFIED	2
			int			font;
#define					DEFAULT_FONT		0
#define					ROMAN_FONT		1
#define					BOLD_FONT		2
#define					ITALIC_FONT		3
#define					MODERN_FONT		4
#define					TYPEWRITER_FONT		5
			int			size;	/* point size */
			int			color;
			int			depth;
			float			angle;	/* in radian */
			int			style;
#define					PLAIN		1
#define					ITALIC		2
#define					BOLD		4
#define					OUTLINE		8
#define					SHADOW		16
			int			height;	/* pixels */
			int			length;	/* pixels */
			int			base_x;
			int			base_y;
			struct f_pen		*pen;
			char			*cstring;
			struct f_text		*next;
			}
		F_text;

typedef		struct f_control {
			float			lx, ly, rx, ry;
			struct f_control	*next;
			}
		F_control;

#define		int_spline(s)		(s->type & 0x2)
#define		normal_spline(s)	(!(s->type & 0x2))
#define		closed_spline(s)	(s->type & 0x1)
#define		open_spline(s)		(!(s->type & 0x1))

typedef		struct f_spline {
			int			type;
#define					T_OPEN_NORMAL		0
#define					T_CLOSED_NORMAL		1
#define					T_OPEN_INTERPOLATED	2
#define					T_CLOSED_INTERPOLATED	3
			int			style;
			int			thickness;
			int			color;
			int			depth;
			float			style_val;
			struct f_pen		*pen;
			struct f_pattern	*area_fill;
			struct f_arrow		*for_arrow;
			struct f_arrow		*back_arrow;
			/*
			For T_OPEN_NORMAL and T_CLOSED_NORMAL points
			are control points while they are knots for
			T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
			whose control points are stored in controls.
			*/
			struct f_point		*points;
			struct f_control	*controls;
			struct f_spline		*next;
			}
		F_spline;

typedef		struct f_compound {
			struct f_pos		nwcorner;
			struct f_pos		secorner;
			struct f_line		*lines;
			struct f_ellipse	*ellipses;
			struct f_spline		*splines;
			struct f_text		*texts;
			struct f_arc		*arcs;
			struct f_compound	*compounds;
			struct f_compound	*next;
			}
		F_compound;

#define		ARROW_SIZE		sizeof(struct f_arrow)
#define		POINT_SIZE		sizeof(struct f_point)
#define		CONTROL_SIZE		sizeof(struct f_control)
#define		ELLOBJ_SIZE		sizeof(struct f_ellipse)
#define		ARCOBJ_SIZE		sizeof(struct f_arc)
#define		LINOBJ_SIZE		sizeof(struct f_line)
#define		TEXOBJ_SIZE		sizeof(struct f_text)
#define		SPLOBJ_SIZE		sizeof(struct f_spline)
#define		COMOBJ_SIZE		sizeof(struct f_compound)

/**********************  object codes  **********************/

#define		O_ELLIPSE		1
#define		O_POLYLINE		2
#define		O_SPLINE		3
#define		O_TEXT			4
#define		O_ARC			5
#define		O_COMPOUND		6
#define		O_END_COMPOUND		-O_COMPOUND
#define		O_ALL_OBJECT		99

/************  object styles (except for f_text)  ************/

#define		SOLID_LINE		0
#define		DASH_LINE		1
#define		DOTTED_LINE		2

#define		CLOSED_PATH		0
#define		OPEN_PATH		1
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































Deleted r34.1/plot/term/pbm.trm version [69699986bd].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
 * $Id: pbm.trm,v 3.24 1992/02/29 16:23:41 woo Exp woo $
 *
 * $Log: pbm.trm,v $
 * Revision 3.24  1992/02/29  16:23:41  woo
 * gnuplot3.2, beta 4
 *
 * Revision 3.23  1992/02/21  20:18:16  woo
 * gnuplot3.2, beta 3
 *
 */

/* GNUPLOT - pbm.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  pbm, pgm, ppm
 *
 * AUTHORS
 *  Russell Lang
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/* The following pbmplus drivers use the generic bit mapped graphics
   routines from bitmap.c to build up a bit map in memory.  The driver
   interchanges colomns and lines in order to access entire lines
   easily and returns the lines to get bits in the right order :
   (x,y) -> (y,XMAX-1-x). */
/* This interchange is done by calling b_makebitmap() with reversed 
   xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
   will then perform the interchange before each pixel is plotted */
/* See Jef Poskanzer's excellent PBMplus package for more details of
   the Portable BitMap format and for programs to convert PBM files  
   to other bitmap formats. */

#ifdef PBM

/* make XMAX and YMAX a multiple of 8 */
#define PBM_XMAX (640)
#define PBM_YMAX (480)
#define PBM_VCHAR (FNT5X9_VCHAR)
#define PBM_HCHAR (FNT5X9_VCHAR)
#define PBM_VTIC FNT5X9_HBITS
#define PBM_HTIC FNT5X9_HBITS

static int pbm_font=1;	/* small font */
/* 7=black, 0=white */
static int pgm_gray[]={7,1,6,5,4,3,2,1,7};  /* grays  */
/* bit3=!intensify, bit2=!red, bit1=!green, bit0=!blue */
static int ppm_color[]={15,8,3,5,6,4,2,1,11,13,14}; /* colors */

PBMoptions()
{
	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"s$mall"))
			pbm_font=1;
		else if (almost_equals(c_token,"m$edium"))
			pbm_font=2;
		else if (almost_equals(c_token,"l$arge"))
			pbm_font=3;
		else
			int_error("expecting: small, medium, large",c_token);
		c_token++;
	}
}


PBMinit()
{
#ifdef vms
   reopen_binary();
#endif /* vms */
#ifdef PC
   reopen_binary();
#endif /* PC */
}


PBMreset()
{
#ifdef vms
   fflush_binary();
#endif /* vms */
}


PBMsetfont()
{
	switch(pbm_font) {
		case 1:
			b_charsize(FNT5X9);
			term_tbl[term].v_char = FNT5X9_VCHAR;
			term_tbl[term].h_char = FNT5X9_HCHAR;
			term_tbl[term].v_tic = FNT5X9_HBITS;
			term_tbl[term].h_tic = FNT5X9_HBITS;
			break;
		case 2:
			b_charsize(FNT9X17);
			term_tbl[term].v_char = FNT9X17_VCHAR;
			term_tbl[term].h_char = FNT9X17_HCHAR;
			term_tbl[term].v_tic = FNT9X17_HBITS;
			term_tbl[term].h_tic = FNT9X17_HBITS;
			break;
		case 3:
			b_charsize(FNT13X25);
			term_tbl[term].v_char = FNT13X25_VCHAR;
			term_tbl[term].h_char = FNT13X25_HCHAR;
			term_tbl[term].v_tic = FNT13X25_HBITS;
			term_tbl[term].h_tic = FNT13X25_HBITS;
			break;
	}
}


PBMgraphics()
{
	PBMsetfont();
	/* rotate plot -90 degrees by reversing XMAX and YMAX and by 
	setting b_rastermode to TRUE */
	b_makebitmap((unsigned int)(PBM_YMAX*ysize),
                     (unsigned int)(PBM_XMAX*xsize),1);
	b_rastermode = TRUE;
}


PBMtext()
{
  register int x,j,row;

   fprintf(outfile,"P4\n");
   fprintf(outfile,"%u %u\n", b_ysize, b_xsize);

   /* dump bitmap in raster mode */
   for (x = b_xsize-1; x >= 0; x--) {
      row = (b_ysize/8)-1;
      for (j = row; j >= 0; j--) {
         (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
      }
   }

   b_freebitmap();
}

#define PBMlinetype b_setlinetype
#define PBMmove b_move
#define PBMvector b_vector
#define PBMtext_angle b_text_angle
#define PBMtext_angle b_text_angle
#define PBMput_text b_put_text

/* PGM functions */
PGMgraphics()
{
	PBMsetfont();
	/* rotate plot -90 degrees by reversing XMAX and YMAX and by 
	setting b_rastermode to TRUE */
	b_makebitmap((unsigned int)(PBM_YMAX*ysize),
                     (unsigned int)(PBM_XMAX*xsize),3);
	b_rastermode = TRUE;
        b_setlinetype(0); /* solid lines */
}


PGMtext()
{
  register int x,j,row;
  register int i,value;
  int mask, plane1, plane2, plane3;

   fprintf(outfile,"P5\n");
   fprintf(outfile,"%u %u\n", b_ysize, b_xsize);
   fprintf(outfile,"%u\n",7);

   /* dump bitmap in raster mode */
   for (x = b_xsize-1; x >= 0; x--) {
      row = (b_ysize/8)-1;
      for (j = row; j >= 0; j--) {
         mask = 0x80;
         plane1=(*((*b_p)[j]+x));
         plane2=(*((*b_p)[j+b_psize]+x));
         plane3=(*((*b_p)[j+b_psize+b_psize]+x));
         for (i=0; i<8; i++) {
            value=7;
            if (plane1 & mask)  value-=1;
            if (plane2 & mask)  value-=2;
            if (plane3 & mask)  value-=4;
            (void) fputc( (char)(value), outfile );
            mask>>=1;
         }
      }
   }

   b_freebitmap();
}


PGMlinetype(linetype)
int linetype;
{
    if (linetype>=7)
        linetype %= 7;
    b_setvalue(pgm_gray[linetype+2]);
}


/* PPM functions */
PPMgraphics()
{
	PBMsetfont();
	/* rotate plot -90 degrees by reversing XMAX and YMAX and by 
	setting b_rastermode to TRUE */
	b_makebitmap((unsigned int)(PBM_YMAX*ysize),
                     (unsigned int)(PBM_XMAX*xsize),4);
	b_rastermode = TRUE;
        b_setlinetype(0); /* solid lines */
}



PPMtext()
{
  register int x,j,row;
  register int i;
  int mask, plane1, plane2, plane3, plane4;
  int red, green, blue;

   fprintf(outfile,"P6\n");
   fprintf(outfile,"%u %u\n", b_ysize, b_xsize);
   fprintf(outfile,"%u\n",3);

   /* dump bitmap in raster mode */
   for (x = b_xsize-1; x >= 0; x--) {
      row = (b_ysize/8)-1;
      for (j = row; j >= 0; j--) {
         mask = 0x80;
         plane1=(*((*b_p)[j]+x));
         plane2=(*((*b_p)[j+b_psize]+x));
         plane3=(*((*b_p)[j+b_psize+b_psize]+x));
         plane4=(*((*b_p)[j+b_psize+b_psize+b_psize]+x));
         for (i=0; i<8; i++) {
            red = (plane3 & mask) ? 1 : 3;
            green = (plane2 & mask) ? 1 : 3;
            blue = (plane1 & mask) ? 1 : 3;
            if (plane4 & mask) {
               red--; green--; blue--;
            }
            (void) fputc( (char)(red), outfile );
            (void) fputc( (char)(green), outfile );
            (void) fputc( (char)(blue), outfile );
            mask>>=1;
         }
      }
   }

   b_freebitmap();
}


PPMlinetype(linetype)
int linetype;
{
    if (linetype>=9)
        linetype %= 9;
    b_setvalue(ppm_color[linetype+2]);
}

#endif /* PBM */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/pc.trm version [5fea2e6d8f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
/*
 * $Id: pc.trm,v 3.26 92/03/24 22:35:39 woo Exp Locker: woo $
 */

/* GNUPLOT - pc.trm */
/*
 * Copyright (C) 1990, 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Under Microsoft C
 *      cga, egabios, egalib, vgabios, hercules, corona325, att
 *  Under Turboc C
 *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 */

#ifdef __TURBOC__
#include <graphics.h>
#include <conio.h>
#include <dos.h>
  int g_driver, g_mode, g_error;
  char far *path;
  char *pathp, path_s[128];

/* instead of string.h */
extern char *strrchr();

get_path()
{
   path=(char far *) getenv("BGI");
   if (path==NULL) {
      (void) strcpy(path_s,_argv[0]);
      pathp=strrchr(path_s,'\\');
      *pathp=0x00;
      path=path_s;
   }
}

static struct text_info tinfo;       /* So we can restore starting text mode. */
#endif


static char near buf[80];	/* kludge since EGA.LIB is compiled SMALL */

static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};

static int graphics_on = FALSE;
int startx, starty;

int pc_angle;
#define PC_VCHAR FNT5X9_VCHAR
#define PC_HCHAR FNT5X9_HCHAR

pause()		/* press any key to continue... */
{
	(void) getch();
}


PC_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
#ifdef __TURBOC__
	restorecrtmode();
        textmode(tinfo.currmode);
	clrscr();
#else
	Vmode(3);
#endif
}

PC_reset()
{
#ifdef __TURBOC__
	closegraph();
        textmode(tinfo.currmode);
	clrscr();
#endif
}


#ifndef __TURBOC__

PC_putc(x,y,c,angle,line_func)
unsigned int x,y;
char c;
int angle;
FUNC_PTR line_func;
{
int i,j,k;
unsigned int pixelon;
	i = (int)(c) - 32;
	for (j=0; j<FNT5X9_VBITS; j++) {
		for (k=0; k<FNT5X9_HBITS; k++) {
			pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
			if (pixelon) {
				switch(angle) {
					case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
							break;
					case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
							break;
				}
			}
		}
	}
}


int PC_text_angle(ang)
int ang;
{
	pc_angle=ang;
	return TRUE;
}


#define CGA_XMAX 640
#define CGA_YMAX 200

#define CGA_XLAST (CGA_XMAX - 1)
#define CGA_YLAST (CGA_YMAX - 1)

#define CGA_VCHAR PC_VCHAR
#define CGA_HCHAR PC_HCHAR
#define CGA_VTIC 4
#define CGA_HTIC 6

int line_cga;

CGA_init()
{
	PC_color(1);		/* monochrome */
}

CGA_graphics()
{
	graphics_on = TRUE;
	Vmode(6);
}

#define CGA_text PC_text

CGA_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	line_cga=linetype;
	PC_mask(pattern[linetype+2]);
}

CGA_move(x,y)
{
	startx = x;
	starty = y;
}


CGA_vector(x,y)
{
	PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
	startx = x;
	starty = y;
}


CGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
int line;
	line= line_cga; 	/* disable the dotted lines temporarily */
	PC_mask(pattern[0]);
	switch(pc_angle) {
		case 0 : y -= CGA_VCHAR/2;
				break;
		case 1 : x += CGA_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
		switch(pc_angle) {
			case 0 : x+=CGA_HCHAR ;
					break;
			case 1 : y+=CGA_HCHAR ;
					break;
		}
	}
	PC_mask(pattern[line]);  /* enable dotted lines */
}


#define CGA_text_angle PC_text_angle

#define CGA_reset PC_reset


#define EGA_XMAX 640
#define EGA_YMAX 350

#define EGA_XLAST (EGA_XMAX - 1)
#define EGA_YLAST (EGA_YMAX - 1)

#define EGA_VCHAR PC_VCHAR
#define EGA_HCHAR PC_HCHAR
#define EGA_VTIC 4
#define EGA_HTIC 5

static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};

static int *egacolor;


EGA_init()
{
	PC_mask(0xffff);
	egacolor = ega256color;		/* should be smarter */
}

EGA_graphics()
{
	graphics_on = TRUE;
	Vmode(16);
}

#define EGA_text PC_text

EGA_linetype(linetype)
{
	if (linetype >= 13)
		linetype %= 13;
	PC_color(egacolor[linetype+2]);
}

EGA_move(x,y)
{
	startx = x;
	starty = y;
}

EGA_vector(x,y)
{
	PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
	startx = x;
	starty = y;
}


EGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
	switch(pc_angle) {
		case 0 : y -= EGA_VCHAR/2;
				break;
		case 1 : x += EGA_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
		switch(pc_angle) {
			case 0 : x+=EGA_HCHAR ;
					break;
			case 1 : y+=EGA_HCHAR ;
					break;
		}
	}
}


#define EGA_text_angle PC_text_angle

#define EGA_reset PC_reset



/* The following VGA routines are hacked from the above EGA routines
   They worked on two VGA cards.
   Russell Lang, eln272v@monu1.cc.monash.oz */
#define VGA_XMAX 640
#define VGA_YMAX 480

#define VGA_XLAST (VGA_XMAX - 1)
#define VGA_YLAST (VGA_YMAX - 1)

#define VGA_VCHAR PC_VCHAR
#define VGA_HCHAR PC_HCHAR
#define VGA_VTIC 5
#define VGA_HTIC 5

static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};

static int *vgacolor;


VGA_init()
{
	PC_mask(0xffff);
	vgacolor = vga256color;		/* should be smarter */
}

VGA_graphics()
{
	graphics_on = TRUE;
	Vmode(18);
}

#define VGA_text PC_text

VGA_linetype(linetype)
{
	if (linetype >= 13)
		linetype %= 13;
	PC_color(vgacolor[linetype+2]);
}

VGA_move(x,y)
{
	startx = x;
	starty = y;
}

VGA_vector(x,y)
{
	PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
	startx = x;
	starty = y;
}


VGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
	switch(pc_angle) {
		case 0 : y -= VGA_VCHAR/2;
				break;
		case 1 : x += VGA_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
		switch(pc_angle) {
			case 0 : x+=VGA_HCHAR ;
					break;
			case 1 : y+=VGA_HCHAR ;
					break;
		}
	}
}


#define VGA_text_angle PC_text_angle

#define VGA_reset PC_reset



#ifdef EGALIB

#define EGALIB_XMAX 640
#define EGALIB_YMAX 350

#define EGALIB_XLAST (EGA_XMAX - 1)
#define EGALIB_YLAST (EGA_YMAX - 1)

#define EGALIB_VCHAR 14
#define EGALIB_HCHAR 8
#define EGALIB_VTIC 4
#define EGALIB_HTIC 5

#include "mcega.h"

EGALIB_init()
{
	GPPARMS();
	if (GDTYPE != 5) {
		term = 0;
		int_error("color EGA board not found",NO_CARET);
	}
	egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
}

EGALIB_graphics()
{
	graphics_on = TRUE;
	GPINIT();
}

EGALIB_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	GPTERM();
}

EGALIB_linetype(linetype)
{
	if (linetype >= 13)
		linetype %= 13;
	GPCOLOR(egacolor[linetype+2]);
}

EGALIB_move(x,y)
{
	GPMOVE(x,GDMAXROW-y);
}


EGALIB_vector(x,y)
{
	GPLINE(x,GDMAXROW-y);
}


EGALIB_put_text(x,y,str)
int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	GotoXY((int)(x/EGALIB_HCHAR),
		   (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
	gprintf(buf);
}


#define EGALIB_reset PC_reset

#endif /* EGALIB */


#ifdef HERCULES

#define HERC_XMAX 720
#define HERC_YMAX 348

#define HERC_XLAST (HERC_XMAX - 1)
#define HERC_YLAST (HERC_YMAX - 1)

#define HERC_VCHAR PC_VCHAR
#define HERC_HCHAR PC_HCHAR
#define HERC_VTIC 4
#define HERC_HTIC 5

int line_herc;

HERC_init()
{
	H_init();
}

HERC_graphics()
{
	HVmode(1);
	graphics_on = TRUE;
}

HERC_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	HVmode(0);
}

HERC_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	H_mask(pattern[linetype+2]);
	line_herc = linetype;
}

HERC_move(x,y)
{
	if (x < 0)
		startx = 0;
	else if (x > HERC_XLAST)
		startx = HERC_XLAST;
	else
		startx = x;

	if (y < 0)
		starty = 0;
	else if (y > HERC_YLAST)
		starty = HERC_YLAST;
	else
		starty = y;
}

HERC_vector(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > HERC_XLAST)
		x = HERC_XLAST;
	if (y < 0)
		y = 0;
	else if (y > HERC_YLAST)
		y = HERC_YLAST;

	H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
	startx = x;
	starty = y;
}


HERC_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
int line;
	line= line_herc; 	/* disable the dotted lines temporarily */
	H_mask(pattern[0]);
	switch(pc_angle) {
		case 0 : y -= HERC_VCHAR/2;
				break;
		case 1 : x += HERC_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
		switch(pc_angle) {
			case 0 : x+=HERC_HCHAR ;
					break;
			case 1 : y+=HERC_HCHAR ;
					break;
		}
	}
	H_mask(pattern[line]);  /* enable dotted lines */
}


#define HERC_text_angle PC_text_angle

#define HERC_reset PC_reset


#endif /* HERCULES */


/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
   ATT 6300 driver */ 


#ifdef ATT6300

#define ATT_XMAX 640
#define ATT_YMAX 400

#define ATT_XLAST (ATT_XMAX - 1)
#define ATT_YLAST (ATT_YMAX - 1)

#define ATT_VCHAR PC_VCHAR
#define ATT_HCHAR PC_HCHAR
#define ATT_VTIC 4
#define ATT_HTIC 5

#define ATT_init CGA_init

ATT_graphics()
{
	graphics_on = TRUE;
	Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
}

#define ATT_text CGA_text

#define ATT_linetype CGA_linetype

#define ATT_move CGA_move

ATT_vector(x,y)
{
	PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
	startx = x;
	starty = y;
}


ATT_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
int line;
	line= line_cga; 	/* disable the dotted lines temporarily */
	PC_mask(pattern[0]);
	switch(pc_angle) {
		case 0 : y -= ATT_VCHAR/2;
				break;
		case 1 : x += ATT_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
		switch(pc_angle) {
			case 0 : x+=ATT_HCHAR ;
					break;
			case 1 : y+=ATT_HCHAR ;
					break;
		}
	}
	PC_mask(pattern[line]);  /* enable dotted lines */
}


#define ATT_text_angle PC_text_angle

#define ATT_reset CGA_reset

#endif  /* ATT6300 */


#ifdef CORONA

#define COR_XMAX 640
#define COR_YMAX 325

#define COR_XLAST (COR_XMAX - 1)
#define COR_YLAST (COR_YMAX - 1)

#define COR_VCHAR PC_VCHAR
#define COR_HCHAR PC_HCHAR
#define COR_VTIC 4
#define COR_HTIC 5

int line_cor;

static int corscreen;		/* screen number, 0 - 7 */

COR_init()
{
register char *p;
	if (!(p = getenv("CORSCREEN")))
		int_error("must run CORPLOT for Corona graphics",NO_CARET);
	corscreen = *p - '0';
}

COR_graphics()
{
	graphics_on = TRUE;
	Vmode(3);				/* clear text screen */
	grinit(corscreen);
	grandtx();
}

COR_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	grreset();
	txonly();
	Vmode(3);
}

COR_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	line_cor = linetype;
	Cor_mask(pattern[linetype+2]);
}

COR_move(x,y)
{
	if (x < 0)
		startx = 0;
	else if (x > COR_XLAST)
		startx = COR_XLAST;
	else
		startx = x;

	if (y < 0)
		starty = 0;
	else if (y > COR_YLAST)
		starty = COR_YLAST;
	else
		starty = y;
}

COR_vector(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > COR_XLAST)
		x = COR_XLAST;
	if (y < 0)
		y = 0;
	else if (y > COR_YLAST)
		y = COR_YLAST;

	Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
	startx = x;
	starty = y;
}


COR_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
int line;
	line= line_cor; 	/* disable the dotted lines temporarily */
	Cor_mask(pattern[0]);
	switch(pc_angle) {
		case 0 : y -= COR_VCHAR/2;
				break;
		case 1 : x += COR_VCHAR/2;
				break;
	}
	for (i=0;str[i];i++) {
		PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
		switch(pc_angle) {
			case 0 : x+=COR_HCHAR ;
					break;
			case 1 : y+=COR_HCHAR ;
					break;
		}
	}
	COR_mask(pattern[line]);  /* enable dotted lines */
}


#define COR_text_angle PC_text_angle

#define COR_reset PC_reset

#endif /* CORONA */


#else /* ifndef __TURBOC__ */
/* all of the Turbo C routines for the different graphics devices go here */

#define VGA_XMAX 640
#define VGA_YMAX 480

#define VGA_XLAST (VGA_XMAX - 1)
#define VGA_YLAST (VGA_YMAX - 1)

#define VGA_VCHAR 10
#define VGA_HCHAR 8
#define VGA_VTIC 4
#define VGA_HTIC 5

#define SVGA_XMAX 640
#define SVGA_YMAX 480

#define SVGA_VCHAR 10
#define SVGA_HCHAR 8
#define SVGA_VTIC 4
#define SVGA_HTIC 5

static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
static int *vgacolor;

static int svga_xmax = SVGA_XMAX,
	   svga_ymax = SVGA_YMAX,
	   svga_xlast = 639,
	   svga_ylast = 479;

#define VGA_reset EGALIB_reset
#define VGA_text EGALIB_text
#define VGA_move EGALIB_move
#define VGA_vector EGALIB_vector
#define VGA_text_angle PC_text_angle
#define VGA_justify_text PC_justify_text

#define SVGA_reset EGALIB_reset
#define SVGA_text EGALIB_text
#define SVGA_move EGALIB_move
#define SVGA_vector EGALIB_vector
#define SVGA_text_angle PC_text_angle
#define SVGA_justify_text PC_justify_text
#define SVGA_linetype VGA_linetype

int PC_text_angle(ang)
int ang;
{
	int size = svga_ymax > 600 ? 2 : 1;

	pc_angle = ang;

	switch (ang) {
		case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,size);
			break;
		case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,size);
			break;
	}
	return TRUE;
}

int PC_justify_text(mode)
enum JUSTIFY mode;
{
	switch(mode) {
		case LEFT :
			settextjustify(LEFT_TEXT,CENTER_TEXT);
			break;
		case CENTRE :
			settextjustify(CENTER_TEXT,CENTER_TEXT);
			break;
		case RIGHT:
			settextjustify(RIGHT_TEXT,CENTER_TEXT);
			break;
	}
	return TRUE;
}

VGA_init()
{
	g_driver=VGA;
	g_mode=2;
	gettextinfo(&tinfo);
        initgraph(&g_driver,&g_mode,path);
        if(g_driver!=9){
          term=0;
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }

/*          int_error("color VGA board not found",NO_CARET);*/
        }
        if(g_driver==VGA) vgacolor=vga256color;
}

VGA_graphics()
{       g_driver=VGA;
	g_mode=2;
	graphics_on = TRUE;
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	VGA_justify_text(LEFT);
}

VGA_linetype(linetype)
{
	if (linetype >= 13)
		linetype %= 13;
	setcolor(vgacolor[linetype+2]);
}

VGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,VGA_YLAST-y,buf);
}


VGAMONO_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	setlinestyle(4,pattern[linetype+2],1);
}

static int huge detect_svga(void)
{
    return g_mode;
}

SVGA_init()
{
	char *p, name[128], *SVGA = getenv( "SVGA" );

	if (SVGA == NULL)
		int_error("'SVGA' driver environment variable is not set",
			  NO_CARET);

	strcpy(name, SVGA);
	if ((p = strrchr(name, '.')) == NULL ||
	    sscanf(&p[1], "%d", &g_mode) != 1)
		int_error("'SVGA' envvar should be of the form 'name.mode'",
			  NO_CARET);

	*p = 0;

	installuserdriver(name, detect_svga);
	gettextinfo(&tinfo);
	g_driver = 0;
        initgraph(&g_driver,&g_mode,path);
        if(g_driver<0){
          term=0;
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }

        }
	else
	    vgacolor=vga256color;

	/* Get the screen size: */
	svga_xmax = term_tbl[term].xmax = getmaxx() + 1;
        svga_ymax = term_tbl[term].ymax = getmaxy() + 1;
	svga_xlast = svga_xmax-1;
	svga_ylast = svga_ymax-1;

	if (svga_ymax > 600) {		       /* Double the tic/font sizes. */
		term_tbl[term].h_char = SVGA_HCHAR * 2;
		term_tbl[term].v_char = SVGA_VCHAR * 2;
		term_tbl[term].h_tic = SVGA_HTIC * 2;
		term_tbl[term].v_tic = SVGA_VTIC * 2;
		settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
 	}
	else
		settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
}

SVGA_graphics()
{
	graphics_on = TRUE;
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	VGA_justify_text(LEFT);

        svga_ymax = getmaxy() + 1;
	if (svga_ymax > 600)		       /* Double the tic/font sizes. */
		settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
	else
		settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
}

SVGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,svga_ylast-y,buf);
}

#define MCGA_XMAX 640
#define MCGA_YMAX 480

#define MCGA_XLAST (MCGA_XMAX - 1)
#define MCGA_YLAST (MCGA_YMAX - 1)

#define MCGA_VCHAR 10
#define MCGA_HCHAR 8
#define MCGA_VTIC 4
#define MCGA_HTIC 5

static int *MCGAcolor;

#define MCGA_reset EGALIB_reset
#define MCGA_text EGALIB_text
#define MCGA_move EGALIB_move
#define MCGA_vector EGALIB_vector
#define MCGA_text_angle PC_text_angle
#define MCGA_justify_text PC_justify_text

MCGA_init()
{
	g_driver=MCGA;
	g_mode=5;
	gettextinfo(&tinfo);
        initgraph(&g_driver,&g_mode,path);
        if(g_driver!=2){
          term=0;
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }
        }
}

MCGA_graphics()
{
	graphics_on = TRUE;
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	MCGA_justify_text(LEFT);
}


MCGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,MCGA_YLAST-y,buf);
}


MCGA_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	setlinestyle(4,pattern[linetype+2],1);
}


#define EGALIB_XMAX 640
#define EGALIB_YMAX 350

#define EGALIB_XLAST (EGALIB_XMAX - 1)
#define EGALIB_YLAST (EGALIB_YMAX - 1)

#define EGALIB_VCHAR 10
#define EGALIB_HCHAR 8
#define EGALIB_VTIC 4
#define EGALIB_HTIC 5

static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};

static int *egacolor;

#define EGALIB_text_angle PC_text_angle
#define EGALIB_justify_text PC_justify_text

EGALIB_init()
{
	g_driver=EGA;
	g_mode=1;
	gettextinfo(&tinfo);
        initgraph(&g_driver,&g_mode,path);
        if(g_driver<3 || g_driver>4){
          term=0;
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }

/*          int_error("color EGA board not found",NO_CARET);*/
        }
        if(g_driver==EGA) egacolor=ega256color;
        if(g_driver==EGA64) egacolor=ega64color;
}

EGALIB_graphics()
{
	graphics_on = TRUE;
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	EGALIB_justify_text(LEFT);
}

EGALIB_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	restorecrtmode();
        textmode(tinfo.currmode);
	clrscr();
	svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
}

EGALIB_linetype(linetype)
{
	if (linetype >= 13)
		linetype %= 13;
	setcolor(egacolor[linetype+2]);
}

EGALIB_move(x,y)
{
        moveto(x,getmaxy()-y);
}


EGALIB_vector(x,y)
{
	lineto(x,getmaxy()-y);
}


EGALIB_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,EGALIB_YLAST-y,buf);
}


EGALIB_reset()
{
  	closegraph();
        textmode(tinfo.currmode);
	clrscr();
	svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
}


#define CGA_XMAX 640
#define CGA_YMAX 200

#define CGA_XLAST (CGA_XMAX - 1)
#define CGA_YLAST (CGA_YMAX - 1)

#define CGA_VCHAR 10
#define CGA_HCHAR 8
#define CGA_VTIC 4
#define CGA_HTIC 6

#define CGA_text_angle PC_text_angle
#define CGA_justify_text PC_justify_text
#define CGA_reset PC_reset

CGA_init()
{
	g_driver=CGA;
	g_mode=4;
	gettextinfo(&tinfo);
	initgraph(&g_driver,&g_mode,path);
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }
/*	PC_color(1);		 monochrome */

}

CGA_graphics()
{
	graphics_on = TRUE;
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	CGA_justify_text(LEFT);
	/*	Vmode(6);*/
}

#define CGA_text PC_text

CGA_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	setlinestyle(4,pattern[linetype+2],1);
}

CGA_move(x,y)
{
	moveto(x,getmaxy()-y);
}


CGA_vector(x,y)
{
	lineto(x,getmaxy()-y);
}

CGA_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,CGA_YLAST-y,buf);
}



#define HERC_XMAX 720
#define HERC_YMAX 348

#define HERC_XLAST (HERC_XMAX - 1)
#define HERC_YLAST (HERC_YMAX - 1)

#define HERC_VCHAR 10
#define HERC_HCHAR 8
#define HERC_VTIC 4
#define HERC_HTIC 5

#define HERC_text_angle PC_text_angle
#define HERC_justify_text PC_justify_text
#define HERC_reset PC_reset

HERC_init()
{
	g_driver=HERCMONO;
	g_mode=0;
	gettextinfo(&tinfo);
  	initgraph(&g_driver,&g_mode,path);
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }
}

HERC_graphics()
{
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	HERC_justify_text(LEFT);
	graphics_on = TRUE;
}

HERC_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	restorecrtmode();
        textmode(tinfo.currmode);
	clrscr();
}

HERC_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	setlinestyle(4,pattern[linetype+2],1);
}

HERC_move(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > HERC_XLAST)
		x = HERC_XLAST;

	if (y < 0)
		y = 0;
	else if (y > HERC_YLAST)
		y = HERC_YLAST;
	moveto(x,getmaxy()-y);
}

HERC_vector(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > HERC_XLAST)
		x = HERC_XLAST;
	if (y < 0)
		y = 0;
	else if (y > HERC_YLAST)
		y = HERC_YLAST;

	lineto(x,getmaxy()-y);
}


HERC_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,HERC_YLAST-y,buf);
}


#ifdef ATT6300
/* this driver added by rjl@monu1.cc.monash.edu.au */

#define ATT_XMAX 640
#define ATT_YMAX 400

#define ATT_XLAST (ATT_XMAX - 1)
#define ATT_YLAST (ATT_YMAX - 1)

#define ATT_VCHAR PC_VCHAR
#define ATT_HCHAR PC_HCHAR
#define ATT_VTIC 4
#define ATT_HTIC 5

#define ATT_text_angle PC_text_angle
#define ATT_justify_text PC_justify_text
#define ATT_reset PC_reset

ATT_init()
{
	g_driver=ATT400;
	g_mode=5;
	gettextinfo(&tinfo);
  	initgraph(&g_driver,&g_mode,path);
          switch (g_driver){
            case -2: fprintf(stderr,"Graphics card not detected.\n");
                     break;
            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
                     break;
            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
                     break;
            case -5: fprintf(stderr,"Insufficient memory to load ",
                             "graphics driver.");
                     break;
            }
}

ATT_graphics()
{
	gettextinfo(&tinfo);
	setgraphmode(getgraphmode());
	ATT_justify_text(LEFT);
	graphics_on = TRUE;
}

ATT_text()
{
	if (graphics_on) {
		graphics_on = FALSE;
		pause();
	}
	restorecrtmode();
        textmode(tinfo.currmode);
	clrscr();
}

ATT_linetype(linetype)
{
	if (linetype >= 5)
		linetype %= 5;
	setlinestyle(4,pattern[linetype+2],1);
}

ATT_move(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > ATT_XLAST)
		x = ATT_XLAST;

	if (y < 0)
		y = 0;
	else if (y > ATT_YLAST)
		y = ATT_YLAST;
	moveto(x,getmaxy()-y);
}

ATT_vector(x,y)
{
	if (x < 0)
		x = 0;
	else if (x > ATT_XLAST)
		x = ATT_XLAST;
	if (y < 0)
		y = 0;
	else if (y > ATT_YLAST)
		y = ATT_YLAST;

	lineto(x,getmaxy()-y);
}


ATT_put_text(x,y,str)
unsigned int x, y;
char *str;
{
	strcpy((char far *)buf,str);
	outtextxy(x,ATT_YLAST-y,buf);
}
#endif /* ifdef ATT6300 */

#endif /* ifndef __TURBOC__ */

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/post.trm version [a9637a861f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/*
 * $Id: post.trm,v 3.26 92/03/24 22:35:40 woo Exp Locker: woo $
 */

/* GNUPLOT - post.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *     postscript
 *
 * AUTHORS
 *  Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 * The 'postscript' driver produces landscape output 10" wide and 7" high.  
 * To change font to Times-Roman and font size to 20pts use 
 * 'set term postscript "Times-Roman" 20'.
 * To get a smaller (5" x 3.5") eps output use 'set term post eps'
 * and make only one plot per file.  Font size for eps will be half
 * the specified size.
 */


/* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */

char ps_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
int ps_fontsize = 14;					 /* size of font in pts */
BOOLEAN ps_portrait = FALSE;				 /* vertical page */
BOOLEAN ps_color = FALSE;
BOOLEAN ps_eps = FALSE;	/* Is this for an eps file? */
			/* Added by Robert Davis <davis@ecn.purdue.edu> */
int ps_page=0;			/* page count */
int ps_path_count=0; 	/* count of lines in path */
int ps_ang=0;			/* text angle */
enum JUSTIFY ps_justify=LEFT;	/* text is flush left */

char *PS_header[] = {
"/vpt2 vpt 2 mul def\n",
"/hpt2 hpt 2 mul def\n",
/* flush left show */
"/Lshow { currentpoint stroke moveto\n",
"  0 vshift rmoveto show } def\n", 
/* flush right show */
"/Rshow { currentpoint stroke moveto\n",
"  dup stringwidth pop neg vshift rmoveto show } def\n", 
/* centred show */
"/Cshow { currentpoint stroke moveto\n",
"  dup stringwidth pop -2 div vshift rmoveto show } def\n", 
/* Dash or Color Line */
"/DL { Color {setrgbcolor [] 0 setdash pop}\n",
" {pop pop pop 0 setdash} ifelse } def\n",
/* Border Lines */
"/BL { stroke gnulinewidth 2 mul setlinewidth } def\n",
/* Axes Lines */
"/AL { stroke gnulinewidth 2 div setlinewidth } def\n",
/* Plot Lines */
"/PL { stroke gnulinewidth setlinewidth } def\n",
/* Line Types */
"/LTb { BL [] 0 0 0 DL } def\n", /* border */
"/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */
"/LT0 { PL [] 0 1 0 DL } def\n",
"/LT1 { PL [4 dl 2 dl] 0 0 1 DL } def\n",
"/LT2 { PL [2 dl 3 dl] 1 0 0 DL } def\n",
"/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n",
"/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n",
"/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n",
"/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n",
"/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n",
"/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n",
"/M {moveto} def\n",
"/L {lineto} def\n",
"/P { stroke [] 0 setdash\n", /* Point */
"  currentlinewidth 2 div sub moveto\n",
"  0 currentlinewidth rlineto  stroke } def\n",
"/D { stroke [] 0 setdash  2 copy  vpt add moveto\n", /* Diamond */
"  hpt neg vpt neg rlineto  hpt vpt neg rlineto\n",
"  hpt vpt rlineto  hpt neg vpt rlineto  closepath  stroke\n",
"  P  } def\n",
"/A { stroke [] 0 setdash  vpt sub moveto  0 vpt2 rlineto\n", /* Plus (Add) */
"  currentpoint stroke moveto\n",
"  hpt neg vpt neg rmoveto  hpt2 0 rlineto stroke\n",
"  } def\n",
"/B { stroke [] 0 setdash  2 copy  exch hpt sub exch vpt add moveto\n", /* Box */
"  0 vpt2 neg rlineto  hpt2 0 rlineto  0 vpt2 rlineto\n",
"  hpt2 neg 0 rlineto  closepath  stroke\n",
"  P  } def\n",
"/C { stroke [] 0 setdash  exch hpt sub exch vpt add moveto\n", /* Cross */
"  hpt2 vpt2 neg rlineto  currentpoint  stroke  moveto\n",
"  hpt2 neg 0 rmoveto  hpt2 vpt2 rlineto stroke  } def\n",
"/T { stroke [] 0 setdash  2 copy  vpt 1.12 mul add moveto\n", /* Triangle */
"  hpt neg vpt -1.62 mul rlineto\n",
"  hpt 2 mul 0 rlineto\n",
"  hpt neg vpt 1.62 mul rlineto  closepath  stroke\n",
"  P  } def\n",
"/S { 2 copy A C} def\n", /* Star */
NULL
};

#define PS_XOFF	50	/* page offset in pts */
#define PS_YOFF	50

#define PS_XMAX 7200
#define PS_YMAX 5040

#define PS_XLAST (PS_XMAX - 1)
#define PS_YLAST (PS_YMAX - 1)

#define PS_VTIC (PS_YMAX/80)
#define PS_HTIC (PS_YMAX/80)

#define PS_SC (10)				/* scale is 1pt = 10 units */
#define	PS_LW (0.5*PS_SC)		/* linewidth = 0.5 pts */

#define PS_VCHAR (14*PS_SC)		/* default is 14 point characters */
#define PS_HCHAR (14*PS_SC*6/10)


PS_options()
{
	extern struct value *const_express();
	extern double real();

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"p$ortrait")) {
			ps_portrait=TRUE;
 			ps_eps=FALSE;
			c_token++;
		}
		else if (almost_equals(c_token,"l$andscape")) {
			ps_portrait=FALSE;
 			ps_eps=FALSE;
			c_token++;
		}
 		else if (almost_equals(c_token,"e$psf")) {
 			ps_portrait=TRUE;
 			ps_eps = TRUE;
 			c_token++;
 		}
		else if (almost_equals(c_token,"d$efault")) {
			ps_portrait=FALSE;
 			ps_eps=FALSE;
			ps_color=FALSE;
			strcpy(ps_font,"Courier");
			ps_fontsize = 14;
			term_tbl[term].v_char = (unsigned int)(ps_fontsize*PS_SC);
			term_tbl[term].h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
			c_token++;
		}
	}

	if (!END_OF_COMMAND) {
		if (almost_equals(c_token,"m$onochrome")) {
			ps_color=FALSE;
			c_token++;
		}
		else if (almost_equals(c_token,"c$olor")) {
			ps_color=TRUE;
			c_token++;
		}
	}

	if (!END_OF_COMMAND && isstring(c_token)) {
		quote_str(ps_font,c_token);
		c_token++;
	}

	if (!END_OF_COMMAND) {
		/* We have font size specified */
		struct value a;
		ps_fontsize = (int)real(const_express(&a));
		term_tbl[term].v_char = (unsigned int)(ps_fontsize*PS_SC);
		term_tbl[term].h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
	}

	sprintf(term_options,"%s %s \"%s\" %d",
		ps_eps ? "eps" : (ps_portrait ? "portrait" : "landscape"),
		ps_color ? "color" : "monochrome",ps_font,ps_fontsize);
}


PS_init()
{
struct termentry *t = &term_tbl[term];
int i;
	ps_page = 0;
	if (!ps_eps)
		fprintf(outfile,"%%!PS-Adobe-2.0\n");
	else
		fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-2.0\n");
	fprintf(outfile,"%%%%Creator: gnuplot\n");
	fprintf(outfile,"%%%%DocumentFonts: %s\n", ps_font);
	fprintf(outfile,"%%%%BoundingBox: %d %d ", PS_XOFF,PS_YOFF);
	if (ps_portrait)
		fprintf(outfile,"%d %d\n", 
			(int)(xsize*(ps_eps ? 0.5 : 1.0)*(PS_XMAX)/PS_SC+0.5+PS_XOFF), 
			(int)(ysize*(ps_eps ? 0.5 : 1.0)*(PS_YMAX)/PS_SC+0.5+PS_YOFF) );
	else 
		fprintf(outfile,"%d %d\n", 
			(int)(ysize*(ps_eps ? 0.5 : 1.0)*(PS_YMAX)/PS_SC+0.5+PS_XOFF), 
			(int)(xsize*(ps_eps ? 0.5 : 1.0)*(PS_XMAX)/PS_SC+0.5+PS_YOFF) );
	if (!ps_eps)
		fprintf(outfile,"%%%%Pages: (atend)\n");
	fprintf(outfile,"%%%%EndComments\n");
	fprintf(outfile,"/gnudict 40 dict def\ngnudict begin\n");
	fprintf(outfile,"/Color %s def\n",ps_color ? "true" : "false");
	fprintf(outfile,"/gnulinewidth %.3f def\n",PS_LW);
	fprintf(outfile,"/vshift %d def\n", (int)(t->v_char)/(-3));
	fprintf(outfile,"/dl {%d mul} def\n",PS_SC); /* dash length */
	fprintf(outfile,"/hpt %.1f def\n",PS_HTIC/2.0);
	fprintf(outfile,"/vpt %.1f def\n",PS_VTIC/2.0);
	for ( i=0; PS_header[i] != NULL; i++)
		fprintf(outfile,"%s",PS_header[i]);
	fprintf(outfile,"end\n");
	fprintf(outfile,"%%%%EndProlog\n");
}


PS_graphics()
{
struct termentry *t = &term_tbl[term];
	ps_page++;
	if (!ps_eps)
		fprintf(outfile,"%%%%Page: %d %d\n",ps_page,ps_page);
	fprintf(outfile,"gnudict begin\n");
	fprintf(outfile,"gsave\n");
	fprintf(outfile,"%d %d translate\n",PS_XOFF,PS_YOFF);
	fprintf(outfile,"%.3f %.3f scale\n", (ps_eps ? 0.5 : 1.0)/PS_SC,
	                                     (ps_eps ? 0.5 : 1.0)/PS_SC);
	if (!ps_portrait) {
	    fprintf(outfile,"90 rotate\n0 %d translate\n", (int)(-PS_YMAX*ysize));
	}
	fprintf(outfile,"0 setgray\n");
	fprintf(outfile,"/%s findfont %d ",ps_font, (t->v_char) );
	fprintf(outfile,"scalefont setfont\n");
	fprintf(outfile,"newpath\n");
	ps_path_count = 0;
}


PS_text()
{
	ps_path_count = 0;
	fprintf(outfile,"stroke\ngrestore\nend\nshowpage\n");
}


PS_reset()
{
	fprintf(outfile,"%%%%Trailer\n");
	if (!ps_eps)
		fprintf(outfile,"%%%%Pages: %d\n",ps_page);
}


PS_linetype(linetype)
int linetype;
{
char *line = "ba012345678"; 
	fprintf(outfile,"LT%c\n", line[(linetype%9)+2]);
	ps_path_count = 0;
}


PS_move(x,y)
unsigned int x,y;
{
	fprintf(outfile,"%d %d M\n", x, y);
	ps_path_count += 1;
}


PS_vector(x,y)
unsigned int x,y;
{
	fprintf(outfile,"%d %d L\n", x, y);
	ps_path_count += 1;
	if (ps_path_count >= 400) {
		fprintf(outfile,"currentpoint stroke moveto\n");
		ps_path_count = 0;
	}
}


PS_put_text(x,y,str)
unsigned int x, y;
char *str;
{
char ch;
	PS_move(x,y);
	if (ps_ang != 0)
		fprintf(outfile,"currentpoint gsave translate %d rotate 0 0 moveto\n"
			,ps_ang*90);
	putc('(',outfile);
	ch = *str++;
	while(ch!='\0') {
		if ( (ch=='(') || (ch==')') || (ch=='\\') )
			putc('\\',outfile);
		putc(ch,outfile);
		ch = *str++;
	}
	switch(ps_justify) {
		case LEFT : fprintf(outfile,") Lshow\n");
			break;
		case CENTRE : fprintf(outfile,") Cshow\n");
			break;
		case RIGHT : fprintf(outfile,") Rshow\n");
			break;
	}
	if (ps_ang != 0)
		fprintf(outfile,"grestore\n");
	ps_path_count = 0;
}

int PS_text_angle(ang)
int ang;
{
	ps_ang=ang;
	return TRUE;
}

int PS_justify_text(mode)
enum JUSTIFY mode;
{
	ps_justify=mode;
	return TRUE;
}

/* postscript point routines */
PS_point(x,y,number)
int x,y;
int number;
{
char *point = "PDABCTS";
	number %= POINT_TYPES;
 	if (number < -1)
		number = -1;		/* negative types are all 'dot' */
	fprintf(outfile,"%d %d %c\n", x, y, point[number+1]);
	ps_path_count = 0;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/qms.trm version [f376908d5b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * $Id: qms.trm,v 3.26 92/03/24 22:35:41 woo Exp Locker: woo $
 */

/* GNUPLOT - qms.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  QMS laser printers
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams, Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define QMS_XMAX 9000
#define QMS_YMAX 6000

#define QMS_XLAST (QMS_XMAX - 1)
#define QMS_YLAST (QMS_YMAX - 1)

#define QMS_VCHAR		120
#define QMS_HCHAR		70
#define QMS_VTIC		70
#define QMS_HTIC		70

int qms_line = 0;	/* to remember current line type */

QMS_init()
{
/* This was just ^IOL, but at Rutgers at least we need some more stuff */
  fprintf(outfile,"^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n");
/*                 ^ QUIC on    ^set defaults  ^ set botttom,top,left margins
                          ^landscape         ^free format   */
/* set defaults are: implicit decimal point, units in inches, 
   numbers left justified, units in 1/1000 inch, do not ignore spaces */
/* margins are in 1/1000 inch units */
}


QMS_graphics()
{
	fprintf(outfile,"^IGV\n");
/*	                 ^enter graphics vector mode */
}



QMS_text()
{
/* added ^-, because ^, after an ^I command doesn't actually print a page */
/* Did anybody try this code out?  [uhh...-cdk] */
	fprintf(outfile,"^IGE\n^-^,");
/*	                 ^exit graphics vector mode
	                       ^pass terminator
	                         ^print page  */
}


QMS_linetype(linetype)
int linetype;
{
static int width[2+9] = {7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7};
static int type[2+9] =  {0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3};
/*
 * I don't know about Villanova, but on our printer, using ^V without
 * previously setting up a pattern crashes the microcode.
 * [nope, doesn't crash here. -cdk]
 * [it generates a controller error here on dotted lines. - rjl]
 */
/* Code to define patterns added by rjl
 * According to the manual it should work - but it doesn't
 */
	qms_line = linetype;
	if (linetype >= 9)
		linetype %= 9;
	fprintf(outfile,"^PW%02d\n",width[linetype+2]); 
/*	                 ^width in dots */
	switch (type[linetype+2]) {
		case 1 :	/* short dash */
			fprintf(outfile,"^PV102025^G\n^V1\n");
/* ^PV = define pattern vector, 1 = pattern number,
   02 = number of pen downs and ups, 025 = .025" length of ups/downs */
			break;
		case 2 :	/* medium dash */
			fprintf(outfile,"^PV202050^G\n^V2\n");
			break;
		case 3 :	/* long dash */
			fprintf(outfile,"^PV302100^G\n^V3\n");
			break;
		default:
		case 0 :
			fprintf(outfile,"^V0\n");
			break;
	}
}


QMS_move(x,y)
int x,y;
{
	fprintf(outfile,"^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
/*	                 ^pen up vector*/
}


QMS_vector(x2,y2)
int x2,y2;
{
	fprintf(outfile,"^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
/*	                 ^pen down vector*/
}


QMS_put_text(x,y,str)
unsigned int x,y;
char str[];
{
char ch;
	QMS_move(x,y + QMS_VCHAR/3);
	fputs("^IGE\n",outfile);
	ch = *str++;
	while(ch!='\0') {
		if (ch=='^')
			putc('^',outfile);
		putc(ch,outfile);
		ch = *str++;
	}
	fputs("\n^IGV\n",outfile);
	QMS_linetype(qms_line); /* restore line type */
}


QMS_reset()
{
	fprintf(outfile,"^PN^-\n");
/*	                 ^QUIC off*/
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































Deleted r34.1/plot/term/regis.trm version [caae2fb3a9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * $Id: regis.trm,v 3.26 92/03/24 22:35:42 woo Exp Locker: woo $
 */

/* GNUPLOT - regis.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  REGIS devices
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#define REGISXMAX 800             
#define REGISYMAX 440

#define REGISXLAST (REGISXMAX - 1)
#define REGISYLAST (REGISYMAX - 1)

#define REGISVCHAR		20  	
#define REGISHCHAR		9
#define REGISVTIC		8
#define REGISHTIC		6

int REGISang = 0;

REGISinit()
{
	fprintf(outfile,"\033[r\033[24;1H");
/*                   1     2
	1. reset scrolling region
	2. locate cursor on bottom line
*/
}


/* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
REGISgraphics()
{
	fprintf(outfile,"\033[2J\033P1pS(C0)S(E)");
/*                   1      2      3	4   5
	1. clear screen
	2. enter ReGIS graphics
	3. turn off graphics diamond cursor
	4. clear graphics screen
*/
	(void) REGIStext_angle(0); /* select text size and angle */ 
}


REGIStext()
{
	fprintf(outfile,"\033\\\033[24;1H");
/*	                   1    2
	1. Leave ReGIS graphics mode
 	2. locate cursor on last line of screen
*/
}


REGISlinetype(linetype)
int     linetype;
{
      /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
static int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
static int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};

	if (linetype >= 9)
		linetype %= 9;
	fprintf(outfile, "W(I%d)", in_map[linetype + 2]);
	fprintf(outfile, "W(P%d)", lt_map[linetype + 2]);
}


REGISmove(x,y)
int x,y;
{
	fprintf(outfile,"P[%d,%d]",x,REGISYLAST-y,x,REGISYLAST-y);
}


REGISvector(x,y)
int x,y;
{
	fprintf(outfile,"v[]v[%d,%d]",x,REGISYLAST - y);
/* the initial v[] is needed to get the first pixel plotted */
}


/* put_text and text_angle by rjl */
REGISput_text(x,y,str)
int x, y;
char *str;
{
	if (REGISang==1)
		REGISmove(x-REGISVCHAR/2-1,y);
	else
		REGISmove(x,y+REGISVCHAR/2-1);
	(void) putc('T',outfile); (void) putc('\'',outfile);
	while (*str) {
		(void) putc(*str,outfile);
		if (*str == '\'')
			(void) putc('\'',outfile);	/* send out another one */
		str++;
	}
	(void) putc('\'',outfile);
}


int REGIStext_angle(ang)
int ang;
{
	REGISang = ang;
	if (ang == 1)
		fputs("T(D90,S1)",outfile);
	else
		fputs("T(D0,S1)",outfile);
	return TRUE;
}


REGISreset()
{
	fprintf(outfile,"\033[2J\033[24;1H");
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































Deleted r34.1/plot/term/sun.trm version [ddaeab5ae8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
 * $Id: sun.trm,v 3.26 92/03/24 22:35:43 woo Exp Locker: woo $
 */

/* GNUPLOT - sun.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   SUNview windowing system
 *
 * AUTHORS
 *  Maurice Castro
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#include <suntool/sunview.h>
#include <suntool/canvas.h>
#include <suntool/scrollbar.h>
#include <suntool/panel.h>
#include <pixrect/pixrect_hs.h>

#define SUN_XMAX 600
#define SUN_YMAX 512

#define SUN_VCHAR (12)		/* default, will be changed */
#define SUN_HCHAR (8)		/* default, will be changed */
#define SUN_VTIC (SUN_YMAX/80)
#define SUN_HTIC (SUN_XMAX/80)
#define MARGIN 5
#define MINWIN 128

static Frame frame;
static Canvas canvas;
static Pixwin *pw;
static struct pixfont *sun_font = NULL;

static enum JUSTIFY sun_justify=LEFT;

static Notify_value local_notice_destroy();

extern Notify_error notify_dispatch();
  
/* dotted line generator */
unsigned int sun_value = 1;	/* this can be used for colour */
unsigned int sun_line_mask = 0xffff;	/* 16 bit mask for dotted lines */
static unsigned int sun_pattern[] = {0xffff, 0x1111,
	0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
int sun_mask_count = 0;
unsigned int sun_lastx, sun_lasty;	/* last pixel set - used by sun_line */


SUN_init()
{
  struct termentry *t = &term_tbl[term];
  struct pr_subregion bound;

  frame = window_create(NULL, FRAME, 
            FRAME_LABEL,               "Gnuplot",
            0);
  notify_interpose_destroy_func(frame,local_notice_destroy);
  canvas = window_create(frame, CANVAS,
            CANVAS_AUTO_EXPAND,        TRUE,
            CANVAS_AUTO_SHRINK,        TRUE,
            CANVAS_MARGIN,             MARGIN,
            0);
  notify_do_dispatch();
  pw = canvas_pixwin(canvas);
  window_set(frame, WIN_SHOW, TRUE, 0);

  /* figure out font and rough size */
  sun_font = pf_default();
  pf_textbound(&bound, 1, sun_font, "M");
  t->v_char = bound.size.y;
  t->h_char = bound.size.x;

  return;
}

SUN_graphics()
{
  term_tbl[term].xmax = (int) window_get(canvas,CANVAS_WIDTH);
  term_tbl[term].ymax = (int) window_get(canvas,CANVAS_HEIGHT);
  pw_writebackground(pw,0,0,term_tbl[term].xmax, term_tbl[term].ymax, PIX_SRC );
  notify_dispatch();
  /* do not let the user make the window too small */
  if ((term_tbl[term].xmax)<MINWIN)
  {
      window_set(frame,
            WIN_WIDTH,                MINWIN+2*MARGIN+24,
            0);
      notify_dispatch();
      SUN_graphics();
      }
  if ((term_tbl[term].ymax) <MINWIN)
  {
      window_set(frame,
            WIN_HEIGHT,               MINWIN+2*MARGIN+24,
            0);
      notify_dispatch();
      SUN_graphics();
      }
  notify_dispatch();
  return;
}

SUN_text()
{
  notify_dispatch();
  return; /* enter text from another window!!! */
}

SUN_linetype(linetype)
int linetype;
{
	if (linetype>=7)
		linetype %= 7;
	sun_line_mask = sun_pattern[linetype+2];
	sun_mask_count=0;
}


SUN_move(x, y)
unsigned int x, y;
{
  sun_lastx = x;
  sun_lasty = y;
  notify_dispatch();
  return;
}

SUN_vector(x, y)
unsigned int x, y;
{
  if ( (x>=term_tbl[term].xmax) || (y>=term_tbl[term].ymax) )
	return;
  sun_line(sun_lastx,x,sun_lasty,y);
  canvas_pixwin(canvas);
  notify_dispatch();
  return;
}


SUN_put_text(x,y,str)
unsigned int x, y;
char *str;
{
  struct pr_subregion bound;

  if ( (x>=term_tbl[term].xmax) || (y>=term_tbl[term].ymax) )
	return;

  pf_textbound(&bound, strlen(str), sun_font, str);
  y = term_tbl[term].ymax-1-y + bound.size.y/3; /* vertical centering */

  switch(sun_justify) {
	 case LEFT:   break;
	 case CENTRE: x -= bound.size.x/2; break;
	 case RIGHT:  x -= bound.size.x; break;
  }
  pw_text(pw, x,y, PIX_SRC | PIX_DST, 0, str); 
  canvas_pixwin(canvas);
  notify_dispatch();
  return;
}
 

int SUN_justify_text(mode)
	enum JUSTIFY mode;
{
    sun_justify = mode;
    return (TRUE);
}
  
  


SUN_reset()
{
  
  term_tbl[term].xmax = SUN_XMAX;
  term_tbl[term].ymax = SUN_YMAX;
  window_set(frame, WIN_SHOW, FALSE, 0);
  return;
}



sun_setmaskpixel(x,y,value)
unsigned int x,y,value;
{
	/* dotted line generator */
	if ((sun_line_mask>>sun_mask_count)&(unsigned int)(1)) {
		pw_put(pw,x,term_tbl[term].ymax-1-y,sun_value);
	}
	sun_mask_count= (sun_mask_count+1) % 16;
	sun_lastx= x;  /* last pixel set with mask */
	sun_lasty= y;
}




sun_line(x1,x2,y1,y2)
unsigned int x1,x2,y1,y2;
{
int runcount;
int dx,dy;
int xinc,yinc;
unsigned int xplot,yplot;

	runcount=0;
	dx = abs((int)(x1)-(int)(x2));
	if (x2>x1)  xinc=  1;
	if (x2==x1) xinc=  0;
	if (x2<x1)  xinc= -1;
	dy = abs((int)(y1)-(int)(y2));
	if (y2>y1)  yinc=  1;
	if (y2==y1) yinc=  0;
	if (y2<y1)  yinc= -1;
	xplot=x1;
	yplot=y1;
	if (dx>dy) {
		/* iterate x */
		if ( (sun_line_mask==0xffff) ||
			((xplot!=sun_lastx) && (yplot!=sun_lasty)) )
			sun_setmaskpixel(xplot,yplot,sun_value);
		while (xplot!=x2) { 
			xplot+=xinc;
			runcount+=dy;
			if (runcount>=(dx-runcount)) {
				yplot+=yinc;
				runcount-=dx;
			}
			sun_setmaskpixel(xplot,yplot,sun_value);
		} 
	} else {
		/* iterate y */
		if ( (sun_line_mask==0xffff) ||
			((xplot!=sun_lastx) && (yplot!=sun_lasty)) )
			sun_setmaskpixel(xplot,yplot,sun_value);
		while (yplot!=y2) {
			yplot+=yinc;
			runcount+=dx;
			if (runcount>=(dy-runcount)) {
				xplot+=xinc;
				runcount-=dy;
			}
			sun_setmaskpixel(xplot,yplot,sun_value);
		} 
	}
}


static Notify_value local_notice_destroy(frame, status)
   Frame frame;
   Destroy_status status;
{
   if (status != DESTROY_CHECKING)
   {
      SUN_reset();
      term_init = FALSE;
      }
   return(NOTIFY_DONE);
   }

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/t410x.trm version [b41fea5b21].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
 * $Id: t410x.trm,v 3.26 92/03/24 22:35:44 woo Exp Locker: woo $
 */

/* GNUPLOT - t410x.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports: Tektronix 410x and 420x series terminals
 *
 * AUTHORS
 *   Colin Kelley, Thomas Williams
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/* Tektronix 410X and 420X driver written by Cary D. Renzema.
 * email address: caryr@vice.ico.tek.com
 *
 * I've tested this driver on the following terminals: 4106, 4107A, 4109
 * and 4207.  It should work, without editing, on other terminals in the
 * 410x and 420x families.  It will probably need to be changed to work
 * on a 4105 (screen size and character rotation are two guesses).  This
 * file can also be used as a start for a 411x driver.
 *
 * Cary R.
 * April 5, 1990
 */

#ifdef T410X

#define T410XXMAX 4095
#define T410XYMAX 3131

#define T410XVCHAR	71
#define T410XHCHAR	51
#define T410XVTIC	36
#define T410XHTIC	36	

static int T410X_angle=0;

T410X_init()
{
	(void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
	(void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
/*
	 1. set tek mode
	 2. set character path to 0 (characters placed equal to rotation)
	 3. set character size to 59 height
	 4. set character precision to string
	 5. set character text index to 1
	 6. set character write mode to overstrike
	 7. clear the view
	 8. clear the segments
	 9. clear the dialog buffer
	10. set ansi mode
*/
	(void) fflush(outfile);
}


T410X_reset()
{
	(void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
/*
	1. set tek mode
	2. clear the dialog buffer
	3. set ansi mode
*/
	(void) fflush(outfile);
}


T410X_graphics()
{
	(void) fprintf(outfile, "\033%%!0\033\014\033LV0");
/*
	1. set tek mode
	2. clear the screen
	3. set dialog area invisible
*/
	(void) fflush(outfile);
}

T410X_text()
{
	(void) fprintf(outfile, "\033LV1\033%%!1");
/*
	1. set dialog area visible
	2. set ansi mode
*/
	(void) fflush(outfile);
}


T410X_move(x, y)
unsigned int x, y;
{
	(void) fprintf(outfile, "\033LF");
	(void) T410X_encode_x_y(x, y);
	(void) fflush(outfile);
}


T410X_vector(x, y)
unsigned int x, y;
{
	(void) fprintf(outfile, "\033LG");
	(void) T410X_encode_x_y(x, y);
	(void) fflush(outfile);
}


T410X_point(x, y, number)
unsigned int x, y;
int number;
{
	(void) fprintf(outfile, "\033MM");
	(void) T410X_encode_int(max(number, 0)%11);
	(void) fprintf(outfile, "\033LH");
	(void) T410X_encode_x_y(x, y);
	(void) fflush(outfile);
}


T410X_linetype(linetype)
int linetype;
{
	switch (linetype) {
		case -1:
			(void) fprintf(outfile, "\033ML5");
			break;
		case -2:
			(void) fprintf(outfile, "\033ML?");
			break;
		default:
			(void) fprintf(outfile, "\033ML");
			(void) T410X_encode_int(linetype%14+2);
			break;
	}
	(void) fprintf(outfile, "\033MV");
	(void) T410X_encode_int(max(linetype, 0)%8);
	(void) fflush(outfile);
}


T410X_put_text(x, y, str)
unsigned int x, y;
char str[];
{
	extern int T410X_angle;

	if (T410X_angle == 0) {
		(void) T410X_move(x, y-T410XVCHAR/2+6);
		(void) fprintf(outfile, "\033MR00");
	} else {
		(void) T410X_move(x+T410XHCHAR/2-6, y);
		(void) fprintf(outfile, "\033MRE:0");
	}
	(void) fprintf(outfile, "\033LT");
	(void) T410X_encode_int(strlen(str));
	(void) fputs(str, outfile);
	(void) fflush(outfile);
}

T410X_text_angle(ang)
int ang;
{
	extern int T410X_angle;

	T410X_angle = ang;
	return(TRUE);
}

/* These last two routines are based on fortran code found in the
 * 4106/4107/4109/CX PROGRAMMERS manual.
 */

T410X_encode_x_y(x, y)
unsigned int x, y;
{
	static char chix=0, chiy=0, cloy=0, ceb=0;

	register unsigned int hix, lox, hiy, loy, eb, lx, ly;

	lx = (x <= T410XXMAX) ? x : T410XXMAX;
	ly = (y <= T410XYMAX) ? y : T410XYMAX;

	hix = lx/128 + 32;
	lox = (lx/4)%32 + 64;
	hiy = ly/128 + 32;
	loy = (ly/4)%32 + 96;
	eb = (ly%4)*4 + lx%4 + 96;

	if (chiy != hiy) (void) putc(hiy, outfile);
	if (ceb != eb) (void) putc(eb, outfile);
	if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
	if (chix != hix) (void) putc(hix, outfile);
	(void) putc(lox, outfile);

	chix = hix;
	chiy = hiy;
	cloy = loy;
	ceb = eb;
}


T410X_encode_int(number)
int number;
{
	register unsigned int mag, hi1, hi2, lo;

	mag = abs(number);

	hi1 = mag/1024 + 64;
	hi2 = (mag/16)%64 + 64;
	lo = mag%16 + 32;

	if (number >= 0) lo += 16;

	if (hi1 != 64) (void) putc(hi1, outfile);
	if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
	(void) putc(lo, outfile);

}


#endif /* T410X */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































Deleted r34.1/plot/term/tek.trm version [9455a721f9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/*
 * $Id: tek.trm,v 3.26 92/03/24 22:35:45 woo Exp Locker: woo $
 */

/* GNUPLOT - tek.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  tek40xx, bitgraph, kermit_color_tek40xx, kermit_mono_tek40xx, selanar
 *  ln03plus
 *
 * AUTHORS
 *   Colin Kelley, Thomas Williams, Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

#ifdef TEK

#define TEK40XMAX 1024
#define TEK40YMAX 780

#define TEK40XLAST (TEK40XMAX - 1)
#define TEK40YLAST (TEK40YMAX - 1)

#define TEK40VCHAR		25
#define TEK40HCHAR		14
#define TEK40VTIC		11
#define TEK40HTIC		11	

#define HX 0x20		/* bit pattern to OR over 5-bit data */
#define HY 0x20
#define LX 0x40
#define LY 0x60

#define LOWER5 31
#define UPPER5 (31<<5)


TEK40init()
{
}


TEK40graphics()
{
#ifdef vms
	term_pasthru();
#endif /* vms */
	fprintf(outfile,"\033\014");
/*                   1
	1. clear screen
*/
	(void) fflush(outfile);
	sleep(1);  
	/* sleep 1 second to allow screen time to clear on real 
	   tektronix terminals */
}

TEK40text()
{
	TEK40move(0,12);
	fprintf(outfile,"\037");
/*                   1
	1. into alphanumerics
*/
#ifdef vms
	term_nopasthru();
#endif /* vms */
}


TEK40linetype(linetype)
int linetype;
{
}

TEK40move(x,y)
unsigned int x,y;
{
	(void) putc('\035', outfile);	/* into graphics */
	TEK40vector(x,y);
}


TEK40vector(x,y)
unsigned int x,y;
{
	(void) putc((HY | (y & UPPER5)>>5), outfile);
	(void) putc((LY | (y & LOWER5)), outfile);
	(void) putc((HX | (x & UPPER5)>>5), outfile);
	(void) putc((LX | (x & LOWER5)), outfile);
}


TEK40put_text(x,y,str)
unsigned int x,y;
char str[];
{
	TEK40move(x,y-11);
	fprintf(outfile,"\037%s\n",str);
}


TEK40reset()
{
}

#endif /* TEK */



/* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */

#ifdef BITGRAPH

#define BG_XMAX			 	768 /* width of plot area */
#define BG_YMAX			 	768 /* height of plot area */
#define BG_SCREEN_HEIGHT	1024 /* full screen height */

#define BG_XLAST	 (BG_XMAX - 1)
#define BG_YLAST	 (BG_YMAX - 1)

#define BG_VCHAR	16
#define BG_HCHAR	 9
#define BG_VTIC		 8
#define BG_HTIC		 8	


#define BG_init TEK40init

#define BG_graphics TEK40graphics


#define BG_linetype TEK40linetype

#define BG_move TEK40move

#define BG_vector TEK40vector


BG_text()
{
	BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR);
	fprintf(outfile,"\037");
/*                   1
	1. into alphanumerics
*/
}


BG_put_text(x,y,str)
unsigned int x,y;
char str[];
{
	BG_move(x,y-11);
	fprintf(outfile,"\037%s\n",str);
}


#define BG_reset TEK40reset

#endif /* BITGRAPH */


/* Color and Monochrome specials for the MS-Kermit Tektronix Emulator
   by Russell Lang,  eln272v@monu1.cc.monash.oz  */

#ifdef KERMIT

#define KTEK40HCHAR		13

KTEK40graphics()
{
#ifdef vms
        term_mode_tek();
	term_pasthru();
#endif /* vms */
	fprintf(outfile,"\033\014");
/*                   1
	1. clear screen
*/
	/* kermit tektronix emulation doesn't need to wait */
}

KTEK40Ctext()
{
	TEK40text();
	KTEK40Clinetype(0);  /* change to green */
#ifdef vms
	term_nopasthru();
#endif /* vms */
}

/* special color linetypes for MS-DOS Kermit v2.31 tektronix emulator */
/*	0 = normal, 1 = bright 
	foreground color (30-37) = 30 + colors
		where colors are   1=red, 2=green, 4=blue */
static char *kermit_color[15]= {"\033[0;37m","\033[1;30m",
		"\033[0;32m","\033[0;36m","\033[0;31m","\033[0;35m",
		"\033[1;34m","\033[1;33m","\033[1;31m","\033[1;37m",
		"\033[1;35m","\033[1;32m","\033[1;36m","\033[0;34m",
		"\033[0;33m"};

KTEK40Clinetype(linetype)
int linetype;
{
	if (linetype >= 13)
		linetype %= 13;
	fprintf(outfile,"%s",kermit_color[linetype+2]);
}


/* linetypes for MS-DOS Kermit v2.30 tektronix emulator */
/* `=solid, a=fine dots, b=short dashes, c=dash dot, 
   d=long dash dot, e=dash dot dot */
static char *kerm_linetype = "`a`abcde" ;

KTEK40Mlinetype(linetype)
int linetype;
{
	if (linetype >= 6)
		linetype %= 6;
	fprintf(outfile,"\033%c",kerm_linetype[linetype+2]);
}

KTEK40reset()
{
	fprintf(outfile,"\030\n");  /* turn off Tek emulation */
#ifdef vms
	term_mode_native();
#endif /* vms */
}

#endif /* KERMIT */


/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
   Selanar driver */

#ifdef SELANAR

SEL_init()
{
	fprintf(outfile,"\033\062");
/*					1
	1. set to ansi mode
*/
}


SEL_graphics()
{
	fprintf(outfile,"\033[H\033[J\033\061\033\014");
/*                   1           2       3
	1. clear ANSI screen
	2. set to TEK mode
	3. clear screen
*/
}


SEL_text()
{
	TEK40move(0,12);
	fprintf(outfile,"\033\062");
/*                   1
	1. into ANSI mode
*/
}

SEL_reset()
{
	fprintf(outfile,"\033\061\033\012\033\062\033[H\033[J");
/*                   1        2       3      4
1       set tek mode
2       clear screen
3       set ansi mode
4       clear screen
*/
}
#endif /* SELANAR */

#ifdef VTTEK

VTTEK40init()
{
        fprintf(outfile,"\033[?38h");
        fflush(outfile);
        sleep(1);
        /* sleep 1 second to allow screen time to clear on some terminals */
#ifdef vms
        term_mode_tek();
#endif /* vms */
}

VTTEK40reset()
{
        fprintf(outfile,"\033[?38l");
        fflush(outfile);
        sleep(1);
        /* sleep 1 second to allow screen time to clear on some terminals */
#ifdef vms
        term_mode_native();
#endif /* vms */
}

/* linetypes for VT-type terminals in tektronix emulator mode */
/* `=solid, a=fine dots, b=short dashes, c=dash dot,
   d=long dash dot, h=bold solid, i=bold fine dots, j=bold short dashes,
   k=bold dash dot, l=bold long dash dot */
static char *vt_linetype = "`a`abcdhijkl" ;
static int last_vt_linetype = 0;
VTTEK40linetype(linetype)
int linetype;
{
        if (linetype >= 10)
                linetype %= 10;
        fprintf(outfile,"\033%c",vt_linetype[linetype+2]);
        last_vt_linetype = linetype;
}

VTTEK40put_text(x,y,str)
unsigned int x,y;
char str[];
{
        int linetype;
        linetype = last_vt_linetype;
        VTTEK40linetype(0);
        TEK40put_text(x,y,str);
        VTTEK40linetype(linetype);
}

#endif /* VTTEK */

#ifdef LN03P

LN03Pinit()
{
	fprintf(outfile,"\033[?38h");
}

LN03Preset()
{
	fprintf(outfile,"\033[?38l");
}
#endif /* LN03P */
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/unixpc.trm version [4f356c962a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/*
 * $Id: unixpc.trm,v 3.26 92/03/24 22:35:46 woo Exp Locker: woo $
 */

/* GNUPLOT - unixpc.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Unix PC's (ATT 3b1)
 *
 * AUTHORS
 *    John Campbell
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/*
>From: John Campbell (...!arizona!naucse!jdc)

I originally ported gnuplot to the ATT 3b1 (ATT7300) on 12/4/88, and then
added the minimal code needed to bring it up to 2.0 level on 1/28/90.  The 
3b1, as I view it, is a 720x300 bitmapped, monochrome display (often people 
don't use the top 12 scan lines and thus the effective size is 720x288).  I 
tried to maximize the size of the graph area, by using these top 12 lines 
(normally reserved) and set up a signal handler to restore them upon exit, 
abort, etc.

Line styles were "fudged" (they do not know the aspect ratio).  The same
line style may look different depending upon the slope of the curve.  Due to
this only 4 line styles were implemented.  While more line types are possible,
the current styles were chosen as distinguishable.

The 3b1 has 4 "special" rows at the bottom that I could not use in graphics
mode.  It has been suggested that we use these lines for command prompting.
Others have requested that we have a graphics window and a command window.
My experience with gnuplot only includes relatively dumb graphics devices--
hence gnuplot "looks and feels" normal to me the way I implemented it.
I welcome either of these changes from someone else, however.
*/

#include <sys/window.h>   /* Started with tam.h--too much trouble. */
#include <sys/signal.h>
#include <errno.h>

#define uPC_HIGH_BIT    (0x8000)

typedef unsigned short Scr_type;
typedef unsigned char Scr_kluge;

#define uPC_XMAX 720
#define uPC_YMAX 300

#define uPC_XSIZE       45 /* Short ints. */
#define uPC_YSIZE uPC_YMAX

Scr_type uPC_display[uPC_YSIZE][uPC_XSIZE];
int uPC_width = 2*uPC_XSIZE;
int uPC_sx=0, uPC_sy=0;
int uPC_cur_linetype=0;
int uPC_angle = 0;
unsigned short uPC_raster_count=0;
static Scr_type lookup[] = {
      0x0001, 0x0002, 0x0004, 0x0008,
      0x0010, 0x0020, 0x0040, 0x0080,
      0x0100, 0x0200, 0x0400, 0x0800,
      0x1000, 0x2000, 0x4000, 0x8000,
   };

#define uPC_XLAST (uPC_XMAX - 1)
#define uPC_YLAST (uPC_YMAX - 1)

#define uPC_VCHAR FNT5X9_VCHAR
#define uPC_HCHAR FNT5X9_HCHAR
#define uPC_VTIC  uPC_VCHAR/2  /* Was 8  */
#define uPC_HTIC  uPC_HCHAR    /* Was 12 */

extern errno, sys_nerr;
extern char *sys_errlist[];

static struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 0,
                           0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};

#define IfErrOut(e1,e2,s1,s2) if (e1 e2) {\
fprintf(stderr, "%s:: %s %s\n", sys_errlist[errno], s1, s2);\
uPC_fixwind(0);\
exit(-1);}

uPC_init()
{
/* This routine will ioctl to change 0 size */
   int i;
   struct uwdata uw;
   int uPC_fixwind();
   short gw;

/* Check that we are on the bitmapped window. */
   if (iswind() != 0) {
      fprintf (stderr, "Sorry--must run from the bitmapped terminal\n");
      exit(-1);
   }
   for (i=1; i<=16; i++) {
      if (i != SIGINT && i != SIGFPE)  /* Two are caught in plot.c */
         signal (i, uPC_fixwind);
   }

/* Increase the screen size */
   uw.uw_x = 0;
   uw.uw_y = 0;   /* Leave room for top status line. */
   uw.uw_width = uPC_XMAX;      /* 720 */
   uw.uw_height = uPC_YMAX;     /* 288 normal--we clobber 12 (top row)*/
   uw.uw_uflags = 1;         /* Creates with no border */

   IfErrOut (ioctl(1, WIOCSETD, &uw), <0, "ioctl failed on", "WIOCSETD");
}


uPC_graphics()
{
/* This routine will clear the uPC_display buffer and window. */
   register Scr_type *j;
   register int i;

   j = (Scr_type *)uPC_display;
   i = uPC_YSIZE*uPC_XSIZE + 1;

   while (--i)
      *j++ = 0;
/*
   Position the cursor to the bottom of the screen so when we come back to
   text mode we are just below the graph.
*/
   printf ("\033[25;1H");

   uPC_ur.ur_dstop = DSTSRC;   /* replace (clear screen). */
   IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
      "ioctl failed", "WIOCRASTOP");
   uPC_ur.ur_dstop = DSTOR;   /* Or in (show text) */
}


uPC_text()
{
/* This routine will flush the display. */

   IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
      "ioctl failed", "WIOCRASTOP");
}


uPC_linetype(linetype)
int linetype;
{
/* This routine records the current linetype. */
   if (uPC_cur_linetype != linetype) {
      uPC_raster_count = 0;
      uPC_cur_linetype = linetype;
   }
}


uPC_move(x,y)
unsigned int x,y;
{
/* This routine just records x and y in uPC_sx, uPC_sy */
   uPC_sx = x;
   uPC_sy = y;
}


/* Was just (*(a)|=(b)) */
#define uPC_PLOT(a,b)   (uPC_cur_linetype != 0 ? uPC_plot_word (a,b) :\
                                (*(a)|=(b)))

uPC_plot_word(a,b)
Scr_type *a, b;
/*
   Weak attempt to make line styles.  The real problem is the aspect
   ratio.  This routine is called only when a bit is to be turned on in
   a horizontal word.  A better line style routine would know something
   about the slope of the line around the current point (in order to
   change weighting).

   This yields 3 working linetypes plus a usable axis line type.
*/
{
/* Various line types */
   switch (uPC_cur_linetype) {
   case -1:
   /* Distinguish between horizontal and vertical axis. */
      if (uPC_sx > uPC_XMAX/8 && uPC_sx < 7*uPC_XMAX/8) {
      /* Fuzzy tolerance because we don't know exactly where the y axis is */
         if (++uPC_raster_count % 2 == 0) *(a) |= b;
      }
      else {
      /* Due to aspect ratio, take every other y pixel and every third x. */
         *(a) |= (b & 0x9999);
      }
   break;
   case 1:
   case 5:
   /* Make a |    |----|    |----| type of line. */
      if ((1<<uPC_raster_count) & 0xF0F0) *(a) |= b;
      if (++uPC_raster_count > 15) uPC_raster_count = 0;
   break;
   case 2:
   case 6:
   /* Make a |----|----|----|--- |    | type of line. */
      if ((1<<uPC_raster_count) & 0x0EFFF) *(a) |= b;
      if (++uPC_raster_count > 19) uPC_raster_count = 0;
   break;
   case 3:
   case 7:
   /* Make a | -  | -  | -  | -  | type of line. */
      if ((1<<uPC_raster_count) & 0x4444) *(a) |= b;
      if (++uPC_raster_count > 15) uPC_raster_count = 0;
   break;
   case 4:
   case 8:
   default:
      *(a) |= b;
   break;
   }
}

uPC_vector(x,y)
unsigned int x,y;
{
/* This routine calls line with x,y */
   int x1 = uPC_sx, y1=uPC_sy, x2 = x, y2 = y;
   register int  c, e, dx, dy, width;
   register Scr_type mask, *a;

/* Record new sx, sy for next call to the vector routine. */
   uPC_sx = x2;
   uPC_sy = y2;

   a = &uPC_display[(uPC_YSIZE - 1) - y1][x1 >> 4];
   mask = lookup[x1 & 0x0f];
   width = uPC_width;

   if ((dx = x2 - x1) > 0) {
      if ((dy = y2 - y1) > 0) {
         if (dx > dy) {         /* dx > 0, dy > 0, dx > dy */
            dy <<= 1;
            e = dy - dx;
            c = dx + 2;
            dx <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  (Scr_kluge *)a -= width;
                  e -= dx;
               }
               if (mask & uPC_HIGH_BIT) {
                  mask = 1;
                  a++;
               } else
                  mask <<= 1;
               e += dy;
            }
         } else {            /* dx > 0, dy > 0, dx <= dy */
            dx <<= 1;
            e = dx - dy;
            c = dy + 2;
            dy <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  if (mask & uPC_HIGH_BIT) {
                     mask = 1;
                     a++;
                  } else
                     mask <<= 1;
                  e -= dy;
               }
               (Scr_kluge *)a -= width;
               e += dx;
            }
         }
      } else {
         dy = -dy;
         if (dx > dy) {         /* dx > 0, dy <= 0, dx > dy */
            dy <<= 1;
            e = dy - dx;
            c = dx + 2;
            dx <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  (Scr_kluge *)a += width;
                  e -= dx;
               }
               if (mask & uPC_HIGH_BIT) {
                  mask = 1;
                  a++;
               } else
                  mask <<= 1;
               e += dy;
            }
         } else {            /* dx > 0, dy <= 0, dx <= dy */
            dx <<= 1;
            e = dx - dy;
            c = dy + 2;
            dy <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  if (mask & uPC_HIGH_BIT) {
                     mask = 1;
                     a++;
                  } else
                     mask <<= 1;
                  e -= dy;
               }
               (Scr_kluge *)a += width;
               e += dx;
            }
         }
      }
   } else {
      dx = -dx;
      if ((dy = y2 - y1) > 0) {
         if (dx > dy) {         /* dx <= 0, dy > 0, dx > dy */
            dy <<= 1;
            e = dy - dx;
            c = dx + 2;
            dx <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  (Scr_kluge *)a -= width;
                  e -= dx;
               }
               if (mask & 1) {
                  mask = uPC_HIGH_BIT;
                  a--;
               } else
                  mask >>= 1;
               e += dy;
            }
         } else {            /* dx <= 0, dy > 0, dx <= dy */
            dx <<= 1;
            e = dx - dy;
            c = dy + 2;
            dy <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  if (mask & 1) {
                     mask = uPC_HIGH_BIT;
                     a--;
                  } else
                     mask >>= 1;
                  e -= dy;
               }
               (Scr_kluge *)a -= width;
               e += dx;
            }
         }
      } else {
         dy = -dy;
         if (dx > dy) {         /* dx <= 0, dy <= 0, dx > dy */
            dy <<= 1;
            e = dy - dx;
            c = dx + 2;
            dx <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  (Scr_kluge *)a += width;
                  e -= dx;
               }
               if (mask & 1) {
                  mask = uPC_HIGH_BIT;
                  a--;
               } else
                  mask >>= 1;
               e += dy;
            }
         } else {            /* dx <= 0, dy <= 0, dx <= dy */
            dx <<= 1;
            e = dx - dy;
            c = dy + 2;
            dy <<= 1;

            while (--c) {
               uPC_PLOT(a, mask);
               if (e >= 0) {
                  if (mask & 1) {
                     mask = uPC_HIGH_BIT;
                     a--;
                  } else
                     mask >>= 1;
                  e -= dy;
               }
               (Scr_kluge *)a += width;
               e += dx;
            }
         }
      }
   }
}


#ifdef uPC_NOT_USED
/* Added by Russell Lang, eln272v@monu1.cc.monash.oz
   This placement to the nearest character cell worked, and I'm leaving
   it here so the calculations involved won't be lost!  (jdc)
*/
uPC_put_text(x,y,str)
unsigned int x,y;
char str[];
{
/* This routine puts the text at the cursor location nearest
   to (x,y).  Obviously the exact postion would look better */

/* Just use the ANSI escape sequence CUP (iswind said that was ok!) */
   printf ("\033[%d;%dH%s\033[25;1H", (int)(24-(y-uPC_VCHAR/2)*25/uPC_YMAX), 
				(int)(x*80/uPC_XMAX), str); 
   fflush (stdout);
}
#endif


uPC_put_text(x,y,str)
unsigned int x,y;
char str[];
{
   if (uPC_angle == 1)
      x += uPC_VCHAR/2;
   else
      y -= uPC_VCHAR/2;

   switch (uPC_angle) {
      case 0:
         for (; *str; ++str, x += uPC_HCHAR)
            uPC_putc (x, y, *str, uPC_angle);
      break;
      case 1:
         for (; *str; ++str, y += uPC_HCHAR)
            uPC_putc (x, y, *str, uPC_angle);
      break;
   }
}


uPC_putc (x, y, c, angle)
unsigned int x, y;
int c, angle;
/*
   Put a character at an x,y location in the bit map (using the fnt5x9
   array.  This is mostly just copied from the bitmap.c driver.
*/
{
   int i, j, k;
   register Scr_type mask, *a;
   char_row fc;
   unsigned int pixelon;

   i = c - ' ';
   for (j=0; j<FNT5X9_VBITS; j++) {
      fc = fnt5x9[i][j];
      for (k=0; k<FNT5X9_HBITS; k++) {
         pixelon = ((unsigned int)(fc))>>k & 1;
         if (pixelon) {
            switch (angle) {
            case 0:
               mask = lookup[x+k+1 & 0x0f];
               a = &uPC_display[(uPC_YSIZE - 1) - (y+j)][(x+k+1) >> 4];
            break;
            case 1:
               mask = lookup[x-j & 0x0f];
               a = &uPC_display[(uPC_YSIZE - 1) - (y+k+1)][(x-j) >> 4];
            break;
            }
            *(a) |= (mask);  /* see uPC_PLOT macro */
         }
      }
   }
}


uPC_text_angle (ang)
int ang;
{
   uPC_angle = ang;
   return TRUE;
}


uPC_reset()
{
/* Reset window to normal size. */
   uPC_fixwind (0);
}



uPC_fixwind(signo)
int signo;
{
   static struct uwdata wreset = { 0, 12, 720, 288, 0x1};
   struct utdata ut;

/* Reset the window to the right size. */
   ioctl(1, WIOCSETD, &wreset);   /* 0, not wncur here! */

/* Scroll the screen once. (avoids typing over the same line) */
   fprintf (stderr, "\n");

   if (signo) {
      if (signo == SIGILL || signo == SIGTRAP || signo == SIGPWR)
         signal (signo, SIG_DFL);
      kill (0,signo);  /* Redo the signal (as if we never trapped it). */
   }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/unixplot.trm version [a0c2f9e471].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * $Id: unixplot.trm,v 3.26 92/03/24 22:35:47 woo Exp Locker: woo $
 */

/* GNUPLOT -- unixplot.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Unix plot(5) graphics language
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams, Russell Lang
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/*
Unixplot library writes to stdout.  A fix was put in place by
..!arizona!naucse!jdc to let set term and set output redirect
stdout.  All other terminals write to outfile.
*/

#define UP_XMAX 4096
#define UP_YMAX 4096

#define UP_XLAST (UP_XMAX - 1)
#define UP_YLAST (UP_YMAX - 1)

#define UP_VCHAR (UP_YMAX/30)	/* just a guess--no way to know this! */
#define UP_HCHAR (UP_XMAX/60)	/* just a guess--no way to know this! */
#define UP_VTIC (UP_YMAX/80)
#define UP_HTIC (UP_XMAX/80)

UP_init()
{
	openpl();
	space(0, 0, UP_XMAX, UP_YMAX);
}


UP_graphics()
{
	erase();
}


UP_text()
{
}


UP_linetype(linetype)
int linetype;
{
static char *lt[2+5] = {"solid", "longdashed", "solid", "dotted","shortdashed",
	"dotdashed", "longdashed"};

	if (linetype >= 5)
		linetype %= 5;
	linemod(lt[linetype+2]);
}


UP_move(x,y)
unsigned int x,y;
{
	move(x,y);
}


UP_vector(x,y)
unsigned int x,y;
{
	cont(x,y);
}


UP_put_text(x,y,str)
unsigned int x,y;
char str[];
{
	UP_move(x+UP_HCHAR/2,y+UP_VCHAR/5);
	label(str);
}

UP_reset()
{
	closepl();
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































Deleted r34.1/plot/term/v384.trm version [b5461696ea].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * $Id: v384.trm,v 3.26 92/03/24 22:35:48 woo Exp Locker: woo $
 */

/* GNUPLOT - v384.trm */
/*
 * Copyright (C) 1990, 1991, 1992   
 *
 * 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.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  Vectrix 384 - works with tandy color printer as well
 *
 * AUTHORS
 *   roland@moncskermit.OZ (Roland Yap) 
 * 
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 * 
 */

/*
 *	Vectrix 384 driver - works with tandy color printer as well
 *  in reverse printing 8 color mode.
 *  This doesn't work on Vectrix 128 because it redefines the
 *  color table. It can be hacked to work on the 128 by changing
 *  the colours but then it will probably not print best. The color
 *  table is purposely designed so that it will print well
 *
 */

#define V384_XMAX 630
#define V384_YMAX 480

#define V384_XLAST (V384_XMAX - 1)
#define V384_YLAST (V384_YMAX - 1)

#define V384_VCHAR	12
#define V384_HCHAR	7
#define V384_VTIC	8
#define V384_HTIC	7


V384_init()
{
	fprintf(outfile,"%c%c  G0   \n",27,18);
	fprintf(outfile,"Q 0 8\n");
	fprintf(outfile,"0 0 0\n");
	fprintf(outfile,"255 0 0\n");
	fprintf(outfile,"0 255 0\n");
	fprintf(outfile,"0 0 255\n");
	fprintf(outfile,"0 255 255\n");
	fprintf(outfile,"255 0 255\n");
	fprintf(outfile,"255 255 0\n");
	fprintf(outfile,"255 255 255\n");
}


V384_graphics()
{
	fprintf(outfile,"%c%c E0 RE N 65535\n",27,18);
}


V384_text()
{
	fprintf(outfile,"%c%c\n",27,17);
}


V384_linetype(linetype)
int linetype;
{
static int color[]= {
		1 /* red */,
		2 /* green */,
		3 /* blue */,
		4 /* cyan */,
		5 /* magenta */,
		6 /* yellow */, /* not a good color so not in use at the moment */
		7 /* white */
	};
		
	if (linetype < 0)
		linetype=6;
	else
		linetype %= 5;
	fprintf(outfile,"C %d\n",color[linetype]);
}


V384_move(x,y)
unsigned int x,y;
{
	fprintf(outfile,"M %d %d\n",x+20,y);
}


V384_vector(x,y)
unsigned int x,y;
{
	fprintf(outfile,"L %d %d\n",x+20,y);
}


V384_put_text (x, y, str)
unsigned int x, y;
char str[];
{
	V384_move (x, y + V384_VCHAR/2);
	fprintf (outfile, "$%s\n", str);
}


V384_reset()
{
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































Deleted r34.1/plot/term/vws.trm version [ad0a91e324].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
 * $Id: vws.trm,v 3.26 92/03/24 22:35:51 woo Exp Locker: woo $
 */

/* GNUPLOT - vws.trm */
/*
 * Copyright (C) 1990, 1991, 1992
 *
 * 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.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   IRIS terminals
 *
 * AUTHORS
 *   Walter Speth
 *           BITNET: SPETH@DBNPIB5
 *
 * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
 *
 */
 
#define VWS_XMAX   1024
#define VWS_YMAX   780
#define VWS_VCHAR  25
#define VWS_HCHAR  15
#define VWS_VTIC   10
#define VWS_HTIC   10
 
#include stdio
/*
#include math
#include ssdef
*/
#include descrip
 
#include <uisentry.h>
#include <uisusrdef.h>
 
 
#define DEFAULT_ATTR 0
#define OVER_ATTR 1
#define ERAS_ATTR 2
#define BIS_ATTR 3
#define COLOR_ATTR 4
#define TEXT_ATTR 5
#define LINE_ATTR 6
#define BACK_ATTR 7
 
 
float current_x, current_y;
 
 
int vd_id, wd_id;
int vcm_id;
 
static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION");
static $DESCRIPTOR(vd_title, "gnuplot");
 
static float x0, y0, xsiz, ysiz,
             wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new,
             wc_xmin, wc_ymin, wc_xmax, wc_ymax,
             vd_width, vd_height;
 
VWS_resize_ast()
{ uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz,
                     &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
  replotrequest();
}
/****************************************************************************/
VWS_init()
 
 
{
  int i;
  int cattr;
  $DESCRIPTOR(a_font,"DTABER0003WK00PG0001UZZZZ02A000");
 
  vd_width  = 14;
  vd_height = 10; /* aspect sqrt(2) as DIN A paper */
 
  wc_xmin = 0.0;
  wc_ymin = 0.0;
  wc_xmax = (float) VWS_XMAX;
  wc_ymax = (float) VWS_YMAX;
 
  vcm_id = uis$create_color_map(&8);
 
  vd_id = uis$create_display(&wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
                             &vd_width, &vd_height, &vcm_id);
 
  uis$set_color(&vd_id, &0, &.5, &.5, &.5);
  uis$set_color(&vd_id, &1, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &2, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &3, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &4, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &5, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &6, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &7, &0.0, &0.0, &0.0);
 
/*
  uis$set_color(&vd_id, &2, &.2, &.2, &.2);
  uis$set_color(&vd_id, &3, &.3, &.3, &.3);
  uis$set_color(&vd_id, &4, &.4, &.4, &.4);
  uis$set_color(&vd_id, &5, &.5, &.5, &.5);
  uis$set_color(&vd_id, &6, &.6, &.6, &.6);
  uis$set_color(&vd_id, &7, &.7, &.7, &.7);
 
/* perhaps better for color terms (which I do not have)
  uis$set_color(&vd_id, &0, &0.0, &0.0, &0.0);
  uis$set_color(&vd_id, &1, &0.9, &0.0, &0.0);
  uis$set_color(&vd_id, &2, &0.0, &0.9, &0.0);
  uis$set_color(&vd_id, &3, &0.9, &0.9, &0.0);
  uis$set_color(&vd_id, &4, &0.0, &0.0, &0.9);
  uis$set_color(&vd_id, &5, &0.9, &0.0, &0.9);
  uis$set_color(&vd_id, &6, &0.0, &0.9, &0.9);
  uis$set_color(&vd_id, &7, &0.9, &0.9, &0.9);
/*
*/
  uis$disable_display_list(&vd_id);
 
  wd_id = uis$create_window(&vd_id, &ws_devname, &vd_title,
                            &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
                            &vd_width, &vd_height);
 
  uis$set_resize_ast(&vd_id, &wd_id, &VWS_resize_ast, &0,
                     &x0, &y0, &xsiz, &ysiz,
                     &wc_xmin_new, &wc_ymin_new, &wc_xmax_new, &wc_ymax_new);
 
  uis$set_writing_mode(&vd_id, &DEFAULT_ATTR, &OVER_ATTR, &UIS$C_MODE_OVER);
  uis$set_writing_mode(&vd_id, &DEFAULT_ATTR, &ERAS_ATTR, &UIS$C_MODE_ERAS);
  uis$set_writing_mode(&vd_id, &DEFAULT_ATTR, &BIS_ATTR, &UIS$C_MODE_BIS);
/*
  for (i=0; i<8; i++) {
    cattr = COLOR_ATTR+i;
    uis$set_writing_index(&vd_id, &COPY_ATTR, &cattr, &i);
    }
*/
  uis$set_background_index(&vd_id, &DEFAULT_ATTR, &BACK_ATTR, &0);
  uis$set_writing_mode(&vd_id, &DEFAULT_ATTR, &TEXT_ATTR, &UIS$C_MODE_OVER);
  uis$set_font(&vd_id,&TEXT_ATTR,&TEXT_ATTR,&a_font);
  uis$set_char_size(&vd_id,&TEXT_ATTR,&TEXT_ATTR,&0,
                    &(float)VWS_HCHAR,&(float)VWS_VCHAR);
  uis$set_line_style(&vd_id,&LINE_ATTR,&LINE_ATTR,&0xFFFFFFFF);
}
 
/****************************************************************************/
 
VWS_reset()
{
  uis$delete_display(&vd_id);
}
/****************************************************************************/
VWS_scale(xs,ys)
int xs,ys;
{
        return FALSE;
}
/****************************************************************************/
VWS_graphics()
{
    uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
}
/****************************************************************************/
VWS_text()
{
}
/****************************************************************************/
VWS_move(x,y)
int x,y;
{
  current_x= (float)(x);
  current_y= (float)(y);
}
/****************************************************************************/
VWS_vector(x,y)
int x,y;
{ int col;
  float fx,fy;
  fx=(float) x;
  fy=(float) y;
 
      uis$line(&vd_id, &LINE_ATTR,
               &current_x, &current_y, &fx, &fy);
      VWS_move (x,y);
}
/****************************************************************************/
VWS_linetype(lt)
int lt;
{
long int lstyle[9]={    0xffffffff,
                        0Xff00ff00,
                        0xffffff00,
                        0xffff0000,
                        0xf0f0f0f0,
                        0Xfff0fff0,
                        0xf000f000,
                        0xa5a5a5af,
                        0xf00f00f0 };
 
  switch(lt) {
case -1: uis$set_line_style(&vd_id,&LINE_ATTR,&LINE_ATTR,&0xFFFFFFFF);
         uis$set_line_width(&vd_id,&LINE_ATTR,&LINE_ATTR,&1.5);
         break;
case -2: uis$set_line_style(&vd_id,&LINE_ATTR,&LINE_ATTR,&0xFFFFFFFF);
         uis$set_line_width(&vd_id,&LINE_ATTR,&LINE_ATTR,&2.0);
         break;
/*
default:  uis$set_line_style(&vd_id,&LINE_ATTR,&LINE_ATTR,&lstyle[lt % 8]);
          makes part of curve disappear on my workstation
*/
default:  uis$set_line_style(&vd_id,&LINE_ATTR,&LINE_ATTR,&0xFFFFFFFF);
         uis$set_line_width(&vd_id,&LINE_ATTR,&LINE_ATTR,&1.0);
}
}
 
/****************************************************************************/
static int justify_mode =CENTRE,up;;
 
VWS_put_text(x,y,str)
int x,y; char* str;
{
  float fx,fy, thih, twid;
 
 
/* uis$text parameter is descriptor string not character string */
 
  struct dsc$descriptor_s textline = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,""};
 
 
  textline.dsc$a_pointer = str;
  textline.dsc$w_length = strlen(textline.dsc$a_pointer);
  uis$measure_text(&vd_id,&TEXT_ATTR,&textline,&twid,&thih);
  fx=(float)x;
  fy=(float)y;
 
  switch (justify_mode) {
  case LEFT : fy+=thih/2.;
              break;
  case RIGHT : fy+=thih/2.;
               fx-=twid;
              break;
 
  case CENTRE : fy+=thih/2.;
               fx-=twid/2;
              break;
  };
 
  uis$text(&vd_id,&TEXT_ATTR,&textline,&fx,&fy);
     /* write to Example Viewport window */
 
 
}
/****************************************************************************/
VWS_text_angle(ang)
int ang;
{
  float degrees;
  degrees=90.*(up=ang);
  uis$set_text_slope (&vd_id, &TEXT_ATTR, &TEXT_ATTR, &degrees);
return TRUE;
}
/****************************************************************************/
VWS_justify_text(mode)
int mode;
{ justify_mode=mode;
return TRUE;
}
/****************************************************************************/
VWS_point(x,y,point)
int x,y,point;
{
do_point(x,y,point);
}
/****************************************************************************/
VWS_arrow(sx,sy,ex,ey)
int sx,sy,ex,ey;
{
do_arrow(sx,sy,ex,ey);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/term/x11.trm version [bb7f5d3b9c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * $Id: x11.trm,v 3.26 92/03/24 22:35:49 woo Exp Locker: woo $
 */

/*
 *    x11.trm  --- inboard terminal driver for X11
 */

#define X11_XMAX 4096
#define X11_YMAX 4096

/* approximations for typical font/screen sizes */
#define X11_VCHAR (X11_YMAX/25) 
#define X11_HCHAR (X11_XMAX/100) 
#define X11_VTIC (X11_YMAX/100)
#define X11_HTIC (X11_XMAX/150)

#define X11_nopts 25
char X11_opts[X11_nopts][20] = {
   "-mono", "-gray", "-clear",
   "-iconic", "-rv", "-reverse", "+rv", "-synchronous", 
   "-display", "-geometry", "-bg", "-background", "-bd", "-bordercolor", "-bw",
   "-borderwidth", "-fg", "-foreground", "-fn", "-font", "-name", 
   "-selectionTimeout", "-title", "-xnllanguage", "-xrm" 
   };
int X11_optarg[X11_nopts] = { 
   0, 0, 0,
   0, 0, 0, 0, 0,
   1, 1, 1, 1, 1, 1, 1,
   1, 1, 1, 1, 1, 1, 
   1, 1, 1, 1
   };

FILE *X11_ipc; 
char X11_command[1024]= "gnuplot_x11";

/*   X11_args - scan gnuplot command line for standard X Toolkit options */

X11_args(argc, argv) int argc; char *argv[]; {
   int nx11 = 0, n;

   while(++argv, --argc > 0) {
      for (n=0; n<X11_nopts; n++) {
	 if (!strcmp(*argv, X11_opts[n])) {
	    strcat(X11_command, " ");
	    strcat(X11_command, *argv); 
	    if (X11_optarg[n]) {
	       if (--argc <= 0) return(nx11);
	       strcat(X11_command, " \"");
	       strcat(X11_command, *++argv); 
	       strcat(X11_command, "\"");
	       nx11++;
	       }
	    nx11++; break;
	    }
	 }
      if (n == X11_nopts) break; 
      }
   return(nx11);
   }

#ifndef CRIPPLED_SELECT
/*-----------------------------------------------------------------------------
 *   use pipe IPC on most platforms
 *---------------------------------------------------------------------------*/
FILE *popen();

X11_init() { X11_ipc = popen(X11_command, "w"); }

X11_graphics() { fprintf(X11_ipc, "G\n"); }

X11_text() { 
   fprintf(X11_ipc, "E\n"); fflush(X11_ipc);
#ifdef ULTRIX_KLUDGE
   fprintf(X11_ipc, "E\n"); fflush(X11_ipc);
#endif
   }

X11_reset() { fprintf(X11_ipc, "R\n"); fflush(X11_ipc); pclose(X11_ipc); }

#else   /* CRIPPLED_SELECT */
/*-----------------------------------------------------------------------------
 *   use file IPC on the others
 *---------------------------------------------------------------------------*/

char X11_tmp[32], X11_tmp0[32], X11_shutdown[32];
int X11_pid;

X11_init() { 
   if (!(X11_pid = fork())) {
      execl("/bin/sh", "sh", "-c", X11_command, NULL);
      _exit(1);
      }
   sprintf(X11_tmp, "/tmp/Gnuplot_%d", X11_pid);
   sprintf(X11_tmp0, "%s-", X11_tmp);
   sprintf(X11_shutdown,  "echo R >%s",X11_tmp);
   }

X11_graphics() { 
   X11_ipc = fopen(X11_tmp0, "w"); 
   if (!X11_ipc) { perror(X11_tmp0); system(X11_shutdown); exit(1); }
   fprintf(X11_ipc, "G\n"); 
   }

X11_text() { 
   fprintf(X11_ipc, "E\n"); 
#ifdef ULTRIX_KLUDGE
   fprintf(X11_ipc, "E\n");
#endif
   fclose(X11_ipc);
   rename(X11_tmp0, X11_tmp);
   }

X11_reset() { system(X11_shutdown); }

#endif  /* CRIPPLED_SELECT */ /*---------------------------------------------*/

X11_move(x,y) unsigned int x,y; { fprintf(X11_ipc, "M%04d%04d\n", x, y); }

X11_vector(x,y) unsigned int x,y; { fprintf(X11_ipc, "V%04d%04d\n", x, y); }

X11_linetype(lt) int lt; { fprintf(X11_ipc, "L%04d\n", lt); }

X11_put_text(x,y,str) unsigned int x,y; char str[]; {
   fprintf(X11_ipc, "T%04d%04d%s\n", x, y, str);
   }
X11_justify_text(mode) enum JUSTIFY mode; {
   fprintf(X11_ipc, "J%04d\n", mode);
   return(TRUE);
   }
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































Deleted r34.1/plot/util.c version [bcd74112fa].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#ifndef lint
static char *RCSid = "$Id: util.c,v 3.26 92/03/24 22:34:43 woo Exp Locker: woo $";
#endif

/* GNUPLOT - util.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

#include <ctype.h>
#include <setjmp.h>
#include <stdio.h>
#include <errno.h>
#include "plot.h"

BOOLEAN screen_ok;
	/* TRUE if command just typed; becomes FALSE whenever we
		send some other output to screen.  If FALSE, the command line
		will be echoed to the screen before the ^ error message. */

#ifndef vms
#ifndef __ZTC__
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
#endif
#endif /* vms */

extern char input_line[];
extern struct lexical_unit token[];
extern jmp_buf env;	/* from plot.c */
extern int inline_num;		/* from command.c */
extern BOOLEAN interactive;	/* from plot.c */
extern char *infile_name;	/* from plot.c */

extern char *strchr();

#ifndef AMIGA_AC_5
extern double sqrt(), atan2();
#endif

/*
 * chr_in_str() compares the characters in the string of token number t_num
 * with c, and returns TRUE if a match was found.
 */
chr_in_str(t_num, c)
int t_num;
char c;
{
register int i;

	if (!token[t_num].is_token)
		return(FALSE);				/* must be a value--can't be equal */
	for (i = 0; i < token[t_num].length; i++) {
		if (input_line[token[t_num].start_index+i] == c)
			return(TRUE);
		}
	return FALSE;
}


/*
 * equals() compares string value of token number t_num with str[], and
 *   returns TRUE if they are identical.
 */
equals(t_num, str)
int t_num;
char *str;
{
register int i;

	if (!token[t_num].is_token)
		return(FALSE);				/* must be a value--can't be equal */
	for (i = 0; i < token[t_num].length; i++) {
		if (input_line[token[t_num].start_index+i] != str[i])
			return(FALSE);
		}
	/* now return TRUE if at end of str[], FALSE if not */
	return(str[i] == '\0');
}



/*
 * almost_equals() compares string value of token number t_num with str[], and
 *   returns TRUE if they are identical up to the first $ in str[].
 */
almost_equals(t_num, str)
int t_num;
char *str;
{
register int i;
register int after = 0;
register start = token[t_num].start_index;
register length = token[t_num].length;

	if (!token[t_num].is_token)
		return(FALSE);				/* must be a value--can't be equal */
	for (i = 0; i < length + after; i++) {
		if (str[i] != input_line[start + i]) {
			if (str[i] != '$')
				return(FALSE);
			else {
				after = 1;
				start--;	/* back up token ptr */
				}
			}
		}

	/* i now beyond end of token string */

	return(after || str[i] == '$' || str[i] == '\0');
}



isstring(t_num)
int t_num;
{
	
	return(token[t_num].is_token &&
		   (input_line[token[t_num].start_index] == '\'' ||
		   input_line[token[t_num].start_index] == '\"'));
}


isnumber(t_num)
int t_num;
{
	return(!token[t_num].is_token);
}


isletter(t_num)
int t_num;
{
	return(token[t_num].is_token &&
			((isalpha(input_line[token[t_num].start_index]))||
			 (input_line[token[t_num].start_index] == '_')));
}


/*
 * is_definition() returns TRUE if the next tokens are of the form
 *   identifier =
 *		-or-
 *   identifier ( identifer ) =
 */
is_definition(t_num)
int t_num;
{
	return (isletter(t_num) &&
			(equals(t_num+1,"=") ||			/* variable */
			(equals(t_num+1,"(") &&		/* function */
			 isletter(t_num+2)   &&
			 equals(t_num+3,")") &&
			 equals(t_num+4,"=") ) ||
			(equals(t_num+1,"(") &&		/* function with */
			 isletter(t_num+2)   &&		/* two variables */
			 equals(t_num+3,",") &&
			 isletter(t_num+4)   &&
			 equals(t_num+5,")") &&
			 equals(t_num+6,"=") )
		));
}



/*
 * copy_str() copies the string in token number t_num into str, appending
 *   a null.  No more than MAX_ID_LEN chars are copied.
 */
copy_str(str, t_num)
char str[];
int t_num;
{
register int i = 0;
register int start = token[t_num].start_index;
register int count;

	if ((count = token[t_num].length) > MAX_ID_LEN)
		count = MAX_ID_LEN;
	do {
		str[i++] = input_line[start++];
		} while (i != count);
	str[i] = '\0';
}


/*
 * quote_str() does the same thing as copy_str, except it ignores the
 *   quotes at both ends.  This seems redundant, but is done for
 *   efficency.
 */
quote_str(str, t_num)
char str[];
int t_num;
{
register int i = 0;
register int start = token[t_num].start_index + 1;
register int count;

	if ((count = token[t_num].length - 2) > MAX_ID_LEN)
		count = MAX_ID_LEN;
	if (count>0) {
		do {
			str[i++] = input_line[start++];
			} while (i != count);
	}
	str[i] = '\0';
}


/*
 * quotel_str() does the same thing as quote_str, except it uses
 * MAX_LINE_LEN instead of MAX_ID_LEN. 
 */ 
quotel_str(str, t_num) 
char str[]; 
int t_num; 
{
register int i = 0;
register int start = token[t_num].start_index + 1;
register int count;

	if ((count = token[t_num].length - 2) > MAX_LINE_LEN)
		count = MAX_LINE_LEN;
	if (count>0) {
		do {
			str[i++] = input_line[start++];
			} while (i != count);
	}
	str[i] = '\0';
}


/*
 *	capture() copies into str[] the part of input_line[] which lies between
 *	the begining of token[start] and end of token[end].
 */
capture(str,start,end)
char str[];
int start,end;
{
register int i,e;

	e = token[end].start_index + token[end].length;
	for (i = token[start].start_index; i < e && input_line[i] != '\0'; i++)
		*str++ = input_line[i];
	*str = '\0';
}


/*
 *	m_capture() is similar to capture(), but it mallocs storage for the
 *  string.
 */
m_capture(str,start,end)
char **str;
int start,end;
{
register int i,e;
register char *s;

	if (*str)		/* previous pointer to malloc'd memory there */
		free(*str);
	e = token[end].start_index + token[end].length;
	*str = alloc((unsigned int)(e - token[start].start_index + 1), "string");
     s = *str;
     for (i = token[start].start_index; i < e && input_line[i] != '\0'; i++)
	  *s++ = input_line[i];
     *s = '\0';
}


/*
 *	m_quote_capture() is similar to m_capture(), but it removes
	quotes from either end if the string.
 */
m_quote_capture(str,start,end)
char **str;
int start,end;
{
register int i,e;
register char *s;

	if (*str)		/* previous pointer to malloc'd memory there */
		free(*str);
	e = token[end].start_index + token[end].length-1;
	*str = alloc((unsigned int)(e - token[start].start_index + 1), "string");
     s = *str;
    for (i = token[start].start_index + 1; i < e && input_line[i] != '\0'; i++)
	 *s++ = input_line[i];
    *s = '\0';
}


convert(val_ptr, t_num)
struct value *val_ptr;
int t_num;
{
	*val_ptr = token[t_num].l_val;
}

static char *num_to_str(r)
double r;
{
	static i = 0;
	static char s[4][20];
	int j = i++;

	if ( i > 3 ) i = 0;

	sprintf( s[j], "%g", r );
	if ( strchr( s[j], '.' ) == NULL &&
	     strchr( s[j], 'e' ) == NULL &&
	     strchr( s[j], 'E' ) == NULL )
		strcat( s[j], ".0" );

	return s[j];
} 

disp_value(fp,val)
FILE *fp;
struct value *val;
{
	switch(val->type) {
		case INT:
			fprintf(fp,"%d",val->v.int_val);
			break;
		case CMPLX:
			if (val->v.cmplx_val.imag != 0.0 )
				fprintf(fp,"{%s, %s}",
					num_to_str(val->v.cmplx_val.real),
					num_to_str(val->v.cmplx_val.imag));
			else
				fprintf(fp,"%s",
					num_to_str(val->v.cmplx_val.real));
			break;
		default:
			int_error("unknown type in disp_value()",NO_CARET);
	}
}


double
real(val)		/* returns the real part of val */
struct value *val;
{
	switch(val->type) {
		case INT:
			return((double) val->v.int_val);
		case CMPLX:
			return(val->v.cmplx_val.real);
	}
	int_error("unknown type in real()",NO_CARET);
	/* NOTREACHED */
	return((double)0.0);
}


double
imag(val)		/* returns the imag part of val */
struct value *val;
{
	switch(val->type) {
		case INT:
			return(0.0);
		case CMPLX:
			return(val->v.cmplx_val.imag);
	}
	int_error("unknown type in imag()",NO_CARET);
	/* NOTREACHED */
	return((double)0.0);
}



double
magnitude(val)		/* returns the magnitude of val */
struct value *val;
{
	switch(val->type) {
		case INT:
			return((double) abs(val->v.int_val));
		case CMPLX:
			return(sqrt(val->v.cmplx_val.real*
				    val->v.cmplx_val.real +
				    val->v.cmplx_val.imag*
				    val->v.cmplx_val.imag));
	}
	int_error("unknown type in magnitude()",NO_CARET);
	/* NOTREACHED */
	return((double)0.0);
}



double
angle(val)		/* returns the angle of val */
struct value *val;
{
	switch(val->type) {
		case INT:
			return((val->v.int_val > 0) ? 0.0 : Pi);
		case CMPLX:
			if (val->v.cmplx_val.imag == 0.0) {
				if (val->v.cmplx_val.real >= 0.0)
					return(0.0);
				else
					return(Pi);
			}
			return(atan2(val->v.cmplx_val.imag,
				     val->v.cmplx_val.real));
	}
	int_error("unknown type in angle()",NO_CARET);
	/* NOTREACHED */
	return((double)0.0);
}


struct value *
complex(a,realpart,imagpart)
struct value *a;
double realpart, imagpart;
{
	a->type = CMPLX;
	a->v.cmplx_val.real = realpart;
	a->v.cmplx_val.imag = imagpart;
	return(a);
}


struct value *
integer(a,i)
struct value *a;
int i;
{
	a->type = INT;
	a->v.int_val = i;
	return(a);
}



os_error(str,t_num)
char str[];
int t_num;
{
#ifdef vms
static status[2] = {1, 0};		/* 1 is count of error msgs */
#endif

register int i;

	/* reprint line if screen has been written to */

	if (t_num != NO_CARET) {		/* put caret under error */
		if (!screen_ok)
			fprintf(stderr,"\n%s%s\n", PROMPT, input_line);

		for (i = 0; i < sizeof(PROMPT) - 1; i++)
			(void) putc(' ',stderr);
		for (i = 0; i < token[t_num].start_index; i++) {
			(void) putc((input_line[i] == '\t') ? '\t' : ' ',stderr);
			}
		(void) putc('^',stderr);
		(void) putc('\n',stderr);
	}

	for (i = 0; i < sizeof(PROMPT) - 1; i++)
		(void) putc(' ',stderr);
	fprintf(stderr,"%s\n",str);

	for (i = 0; i < sizeof(PROMPT) - 1; i++)
		(void) putc(' ',stderr);
     if (!interactive)
	  if (infile_name != NULL)
	    fprintf(stderr,"\"%s\", line %d: ", infile_name, inline_num);
	  else
	    fprintf(stderr,"line %d: ", inline_num);


#ifdef vms
	status[1] = vaxc$errno;
	sys$putmsg(status);
	(void) putc('\n',stderr);
#else
#ifdef __ZTC__
	fprintf(stderr,"error number %d\n\n",errno);
#else
	if (errno >= sys_nerr)
		fprintf(stderr, "unknown errno %d\n\n", errno);
	else
		fprintf(stderr,"(%s)\n\n",sys_errlist[errno]);
#endif
#endif

	longjmp(env, TRUE);	/* bail out to command line */
}


int_error(str,t_num)
char str[];
int t_num;
{
register int i;

	/* reprint line if screen has been written to */

	if (t_num != NO_CARET) {		/* put caret under error */
		if (!screen_ok)
			fprintf(stderr,"\n%s%s\n", PROMPT, input_line);

		for (i = 0; i < sizeof(PROMPT) - 1; i++)
			(void) putc(' ',stderr);
		for (i = 0; i < token[t_num].start_index; i++) {
			(void) putc((input_line[i] == '\t') ? '\t' : ' ',stderr);
			}
		(void) putc('^',stderr);
		(void) putc('\n',stderr);
	}

	for (i = 0; i < sizeof(PROMPT) - 1; i++)
		(void) putc(' ',stderr);
     if (!interactive)
	  if (infile_name != NULL)
	    fprintf(stderr,"\"%s\", line %d: ", infile_name, inline_num);
	  else
	    fprintf(stderr,"line %d: ", inline_num);
     fprintf(stderr,"%s\n\n", str);

	longjmp(env, TRUE);	/* bail out to command line */
}

/* Lower-case the given string (DFK) */
/* Done in place. */
void
lower_case(s)
     char *s;
{
  register char *p = s;

  while (*p != '\0') {
    if (isupper(*p))
	 *p = tolower(*p);
    p++;
  }
}

/* Squash spaces in the given string (DFK) */
/* That is, reduce all multiple white-space chars to single spaces */
/* Done in place. */
void
squash_spaces(s)
     char *s;
{
  register char *r = s;		/* reading point */
  register char *w = s;		/* writing point */
  BOOLEAN space = FALSE;		/* TRUE if we've already copied a space */

  for (w = r = s; *r != '\0'; r++) {
	 if (isspace(*r)) {
		/* white space; only copy if we haven't just copied a space */
		if (!space) {
		    space = TRUE;
		    *w++ = ' ';
		}				/* else ignore multiple spaces */
	 } else {
		/* non-space character; copy it and clear flag */
		*w++ = *r;
		space = FALSE;
	 }
  }
  *w = '\0';				/* null terminate string */
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted r34.1/plot/version.c version [818439da89].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef lint
static char *RCSid = "$Id: version.c,v 3.26 92/03/24 22:34:44 woo Exp Locker: woo $";
#endif

/* GNUPLOT - version.c */
/*
 * Copyright (C) 1986, 1987, 1990, 1991, 1992   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.
 * 
 * Send your comments or suggestions to 
 *  info-gnuplot@ames.arc.nasa.gov.
 * This is a mailing list; to join it send a note to 
 *  info-gnuplot-request@ames.arc.nasa.gov.  
 * Send bug reports to
 *  bug-gnuplot@ames.arc.nasa.gov.
 */

char version[] = "3.2 ";
char patchlevel[] = "2, Mar 24 92";
char date[] = "Sat Mar 24 21:08:47 PST 1992";

/* override in Makefile */
#ifndef CONTACT
# define CONTACT "bug-gnuplot@ames.arc.nasa.gov"
#endif
char bug_email[] = CONTACT;
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































Deleted r36/cslsrc/r36.inf version [e1efcbad6d].

more than 10,000 changes

Deleted r37/lisp/csl/util/r37.inf version [781d017ff5].

more than 10,000 changes


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]