home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-25 | 60.0 KB | 2,614 lines |
- Newsgroups: comp.sources.misc
- organization: Pixar -- Marin County, California
- subject: v11i078: Gnuplot 2.0 - 13 of 14
- From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 11, Issue 78
- Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Archive-name: gnuplot2/part13
-
- This is gnuplot.sh13
-
- --- CUT HERE ---
- #! /bin/sh
- echo x - translate/Makefile
- sed 's/^X//' >translate/Makefile <<'*-*-END-of-translate/Makefile-*-*'
- X#------------------------------------------------------------------
- X# Makefile for gnut2p
- X# A translation program from Gnutex to GNUPLOT
- X# David Kotz
- X# Duke University
- X# dfk@cs.duke.edu
- X#
- X# derived from gnutex
- X#
- X
- X# Define this for production version
- XCFLAGS=-O -s
- X# For the debugging version
- X#CFLAGS=-g
- X
- X# Your favorite tags program
- XTAGS=etags
- X#TAGS=ctags
- X
- XOBJS = plot.o scanner.o parse.o command.o eval.o \
- X standard.o internal.o util.o misc.o
- X
- XSRC = plot.h command.c eval.c internal.c misc.c \
- X parse.c plot.c scanner.c standard.c util.c
- X
- Xgnut2p: $(OBJS)
- X cc $(CFLAGS) $(OBJS) -o gnut2p -lm
- X
- X$(OBJS): plot.h
- X
- XTAGS: $(SRC)
- X $(TAGS) $(SRC)
- X
- Xclean:
- X rm -f *.o *~ core
- X
- Xspotless:
- X rm -f *.o *~ core gnut2p TAGS
- X
- *-*-END-of-translate/Makefile-*-*
- echo x - translate/README
- sed 's/^X//' >translate/README <<'*-*-END-of-translate/README-*-*'
- Xgnut2p translator - David Kotz January 1990
- X
- XThis program converts gnutex files to gnuplot files. It does its
- Xbest, but is not perfect. Most of gnutex will translate directly, some
- Xthings will translated easily (such as 'set size'), but some things
- Xcannot be translated (such as 'set style'). One thing this program
- Xdoes is to move plot commands down past the 'label' and 'key' commands
- X(which change into 'set label' and 'set key' commands). This may move
- Xit past other commands. If it moves past variable or function
- Xdefinitions, 'set' commands, or other commands which affect the plot
- Xcommand's execution, then the new version will be incorrect. I expect
- Xthis case to be rare; indeed, I generally expect the last lines in
- XGnuTeX input files used with LaTeX to consist of 'plot, label,' and
- X'key' commands.
- X
- XThe usage of this program is simple:
- X
- X gnut2p infile outfile
- X
- X'infile' is an existing GnuTeX file, and 'outfile' will be created as
- Xthe GNUPLOT equivalent. The errors, warnings, and explanatory comments
- Xappear on stderr. Any use of line continuation will be lost, and some
- Xinstances of the input style (eg, white space) may be changed.
- X
- XTo build this program, see the Makefile. It is fairly straightforward.
- *-*-END-of-translate/README-*-*
- echo x - translate/command.c
- sed 's/^X//' >translate/command.c <<'*-*-END-of-translate/command.c-*-*'
- X/*
- X *
- X * gnutex/gnuplot translator -- command.c
- X *
- X * By David Kotz, 1990.
- X * Department of Computer Science, Duke University, Durham, NC 27706.
- X * Mail to dfk@cs.duke.edu.
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include "plot.h"
- X
- X#ifndef STDOUT
- X#define STDOUT 1
- X#endif
- X
- Xextern char *malloc();
- X
- X/*
- X * global variables to hold status of 'set' options
- X *
- X */
- XBOOLEAN autoscale_x = TRUE;
- XBOOLEAN autoscale_y = TRUE;
- XBOOLEAN autoscale_lx = TRUE; /* local to this plot */
- XBOOLEAN autoscale_ly = TRUE; /* local to this plot */
- Xenum PLOT_STYLE data_style = POINTS,
- X func_style = LINES;
- XBOOLEAN log_x = FALSE,
- X log_y = FALSE;
- XFILE* infile;
- XFILE* outfile;
- Xchar outstr[MAX_ID_LEN+1] = "STDOUT";
- Xint samples = SAMPLES;
- Xint term = 0; /* unknown term is 0 */
- Xdouble xmin = -10,
- X xmax = 10,
- X ymin = -10,
- X ymax = 10;
- Xdouble zero = ZERO; /* zero threshold, not 0! */
- X
- XBOOLEAN xtics = TRUE;
- XBOOLEAN ytics = TRUE;
- X
- XBOOLEAN clipping = TRUE;
- X
- XBOOLEAN undefined;
- X
- Xchar title_string[MAX_LINE_LEN] = "";
- Xchar xlabel_string[MAX_LINE_LEN] = "";
- Xchar ylabel_string[MAX_LINE_LEN] = "";
- Xchar xformat[MAX_ID_LEN] = "";
- Xchar yformat[MAX_ID_LEN] = "";
- Xint y_skip_factor = 0;
- Xdouble plot_width = 4; /* width in inches, for latex */
- Xdouble plot_height = 3; /* height in inches, for latex */
- X
- X/*
- X * instead of <strings.h>
- X */
- X
- Xchar *gets(),*getenv();
- Xchar *strcpy(),*strcat();
- X
- Xdouble magnitude(),angle(),real(),imag();
- Xstruct value *const_express(), *pop(), *complex();
- X
- X
- Xextern struct vt_entry vt[];
- Xextern struct st_entry st[];
- Xextern struct udft_entry udft[];
- X
- Xextern int inline; /* line number of current input line */
- Xchar input_line[MAX_LINE_LEN],dummy_var[MAX_ID_LEN + 1];
- Xstruct at_type *curr_at;
- Xint c_token;
- Xint next_value = (int)NEXT_VALUE,next_function = 0,c_function = 0;
- Xint num_tokens;
- X
- Xstruct curve_points plot[MAX_PLOTS];
- Xint plot_count = 0;
- Xchar plot_ranges[MAX_LINE_LEN+1];
- XBOOLEAN pending_plot = FALSE; /* TRUE if a plot command is pending output */
- Xint plot_line; /* input line number of pending plot */
- XBOOLEAN key_on = TRUE; /* will a key be displayed */
- XBOOLEAN plot_key = FALSE; /* did we want a key for this plot? */
- XBOOLEAN label_on = FALSE; /* will labels be displayed */
- XBOOLEAN arrow_on = FALSE; /* will arrows be displayed */
- XBOOLEAN plot_label = FALSE; /* do we want labels displayed? */
- XBOOLEAN plot_arrow = FALSE; /* do we want arrows displayed? */
- XBOOLEAN plot_format = FALSE; /* have we seen a set format? */
- X
- XBOOLEAN was_output; /* was there any output from command? */
- X
- Xint inline = 0; /* input line number */
- X
- Xcom_line()
- X{
- X read_line();
- X
- X#ifdef vms
- X if (input_line[0] == '!' || input_line[0] == '$')
- X fprintf(outfile, "%s\n", input_line);
- X else
- X do_line();
- X#else /* vms */
- X if (input_line[0] == '!')
- X fprintf(outfile, "%s\n", input_line);
- X else
- X do_line();
- X#endif
- X
- X}
- X
- X/* Read a line of input; much simplified by the fact that infile is
- X * never a terminal. Handles line continuation and EOF.
- X */
- Xread_line()
- X{
- X int len, left;
- X int start = 0;
- X BOOLEAN more, stop;
- X int last;
- X
- X /* read one command */
- X left = MAX_LINE_LEN;
- X start = 0;
- X more = TRUE;
- X stop = FALSE;
- X
- X while (more) {
- X if (fgets(&(input_line[start]), left, infile) == NULL) {
- X stop = TRUE; /* EOF in file */
- X input_line[start] = '\0';
- X more = FALSE;
- X } else {
- X inline++;
- X len = strlen(input_line) - 1;
- X if (input_line[len] == '\n') { /* remove any newline */
- X input_line[len] = '\0';
- X len--;
- X } else if (len+1 >= left)
- X int_error("Input line too long",NO_CARET);
- X
- X if (input_line[len] == '\\') { /* line continuation */
- X start = len;
- X left -= len;
- X } else
- X more = FALSE;
- X }
- X }
- X
- X if (stop && input_line[0] == '\0')
- X done(0);
- X}
- X
- Xdo_line()
- X{
- X extern int comment_pos; /* from scanner */
- X BOOLEAN nonempty; /* TRUE if output was nonempty */
- X
- X num_tokens = scanner(input_line);
- X c_token = 0;
- X nonempty = FALSE;
- X while(c_token < num_tokens) {
- X was_output = FALSE;
- X
- X command(); /* parse the next command */
- X
- X if (c_token < num_tokens) /* something after command */
- X if (equals(c_token,";")) {
- X c_token++;
- X if (was_output)
- X fprintf(outfile, "; ");
- X } else
- X int_error("';' expected",c_token);
- X nonempty = was_output || nonempty;
- X }
- X
- X /* write out any comment */
- X if (comment_pos >= 0) {
- X if (nonempty)
- X putc(' ', outfile);
- X fputs(input_line+comment_pos, outfile);
- X nonempty = TRUE;
- X }
- X if (nonempty || num_tokens == 0)
- X putc('\n', outfile);
- X}
- X
- X
- Xcommand()
- X{
- X int start_token = c_token;
- X
- X if (is_definition(c_token)) {
- X define();
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"h$elp") || equals(c_token,"?")) {
- X c_token++;
- X while (!(END_OF_COMMAND))
- X c_token++;
- X err_msg("help command ignored (removed)");
- X }
- X else if (almost_equals(c_token,"pr$int")) {
- X struct value a;
- X c_token++;
- X (void) const_express(&a);
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"p$lot")) {
- X if (pending_plot)
- X write_plot();
- X c_token++;
- X plotrequest();
- X pending_plot = TRUE;
- X plot_line = inline;
- X /* we defer output until eof or next plot command */
- X }
- X else if (almost_equals(c_token,"la$bel")) {
- X c_token++;
- X labelrequest();
- X }
- X else if (almost_equals(c_token,"k$ey")) {
- X c_token++;
- X keyrequest();
- X }
- X else if (almost_equals(c_token,"se$t")) {
- X c_token++;
- X if (almost_equals(c_token,"t$erminal")) {
- X c_token++;
- X if (!END_OF_COMMAND)
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"sa$mples")) {
- X struct value a;
- X c_token++;
- X (void)magnitude(const_express(&a));
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"o$utput")) {
- X c_token++;
- X if (!END_OF_COMMAND) { /* no file specified */
- X if (!isstring(c_token))
- X int_error("expecting filename",c_token);
- X else
- X c_token++;
- X }
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"a$utoscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
- X c_token++;
- X } else if (equals(c_token, "x")) {
- X c_token++;
- X } else if (equals(c_token, "y")) {
- X c_token++;
- X } else
- X int_error("expecting axes specification", c_token);
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"noa$utoscale")) {
- X c_token++;
- X if (END_OF_COMMAND) {
- X } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
- X c_token++;
- X } else if (equals(c_token, "x")) {
- X c_token++;
- X } else if (equals(c_token, "y")) {
- X c_token++;
- X } else
- X int_error("expecting axes specification", c_token);
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"l$ogscale")) {
- X c_token++;
- X if (equals(c_token,"x")) {
- X c_token++;
- X } else if (equals(c_token,"y")) {
- X c_token++;
- X } else if (equals(c_token,"xy") || equals(c_token,"yx")) {
- X c_token++;
- X } else
- X int_error("expecting 'x', 'y', or 'xy'", c_token);
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"nol$ogscale")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"z$ero")) {
- X struct value a;
- X c_token++;
- X (void) magnitude(const_express(&a));
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"x$range")) {
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X load_range();
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"y$range")) {
- X c_token++;
- X if (!equals(c_token,"["))
- X int_error("expecting '['",c_token);
- X c_token++;
- X load_range();
- X if (!equals(c_token,"]"))
- X int_error("expecting ']'",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"d$ata")) {
- X c_token++;
- X if (!almost_equals(c_token,"s$tyle"))
- X int_error("expecting keyword 'style'",c_token);
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("expecting style name", c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"f$unction")) {
- X c_token++;
- X if (!almost_equals(c_token,"s$tyle"))
- X int_error("expecting keyword 'style'",c_token);
- X c_token++;
- X if (END_OF_COMMAND)
- X int_error("expecting style name", c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"st$yle")) {
- X c_token++;
- X add_style();
- X err_msg("'set style' command obsolete (removed)");
- X }
- X else if (almost_equals(c_token,"xl$abel")) {
- X c_token++;
- X if (!isstring(c_token))
- X int_error("expecting x label string",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"xt$ics")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"noxt$ics")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"yl$abel")) {
- X c_token++;
- X if (!isstring(c_token)) {
- X int_error("expecting y label string",c_token);
- X } else {
- X c_token++;
- X if (!END_OF_COMMAND) { /* skip factor specified */
- X err_msg("ignoring skip factor on ylabel");
- X copy_command(start_token, c_token-1);
- X c_token++;
- X } else
- X copy_command(start_token, c_token-1);
- X }
- X }
- X else if (almost_equals(c_token,"yt$ics")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"noyt$ics")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"fo$rmat")) {
- X c_token++;
- X if (equals(c_token,"x")) {
- X c_token++;
- X } else if (equals(c_token,"y")) {
- X c_token++;
- X } else if (equals(c_token,"xy") || equals(c_token,"yx")) {
- X c_token++;
- X } else if (isstring(c_token)) {
- X } else
- X int_error("expecting 'x', 'y', or 'xy'",c_token);
- X if (!isstring(c_token))
- X int_error("expecting format string",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X plot_format = TRUE;
- X }
- X else if (almost_equals(c_token,"ti$tle")) {
- X c_token++;
- X if (!isstring(c_token))
- X int_error("expecting title string",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"si$ze")) {
- X struct value a;
- X c_token++;
- X plot_width = magnitude(const_express(&a));
- X if (!equals(c_token, ","))
- X int_error("expecting comma between width and height", c_token);
- X c_token++; /* comma */
- X plot_height = magnitude(const_express(&a));
- X err_msg("'set size' command translated");
- X fprintf(outfile, "set size %.3g, %.3g",
- X (plot_width + 1.096)/5., /* adjust for margins too */
- X (plot_height + 0.616)/3.);
- X was_output = TRUE;
- X }
- X else if (almost_equals(c_token,"cl$ip")) {
- X c_token++;
- X fprintf(outfile, "set clip points");
- X was_output = TRUE;
- X }
- X else if (almost_equals(c_token,"nocl$ip")) {
- X c_token++;
- X fprintf(outfile, "set noclip points");
- X was_output = TRUE;
- X }
- X else
- X int_error("unknown set option (try 'help set')",c_token);
- X }
- X else if (almost_equals(c_token,"sh$ow")) {
- X if (almost_equals(++c_token,"f$unctions")) {
- X c_token++;
- X if (almost_equals(c_token,"s$tyle"))
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"v$ariables")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"ac$tion_table") ||
- X equals(c_token,"at") ) {
- X c_token++;
- X show_at();
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"d$ata")) {
- X c_token++;
- X if (!almost_equals(c_token,"s$tyle"))
- X int_error("expecting keyword 'style'",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"x$range")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"y$range")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"z$ero")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"sa$mples")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"o$utput")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"t$erminal")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"au$toscale")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"ve$rsion")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"l$ogscale")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"cl$ipping")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"xl$abel")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"yl$abel")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"fo$rmat")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"ti$tle")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"si$ze")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"st$yle")) {
- X c_token++;
- X add_style();
- X err_msg("'show style' command ignored (removed)");
- X }
- X else if (almost_equals(c_token,"a$ll")) {
- X copy_command(start_token, c_token++);
- X }
- X else
- X int_error("unknown show option (try 'help show')",c_token);
- X }
- X else if (almost_equals(c_token,"cl$ear")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"she$ll")) {
- X copy_command(start_token, c_token++);
- X }
- X else if (almost_equals(c_token,"sa$ve")) {
- X c_token++;
- X if (almost_equals(c_token,"f$unctions")
- X || almost_equals(c_token,"v$ariables")) {
- X c_token++;
- X if (!isstring(c_token))
- X int_error("expecting filename",c_token);
- X } else if (!isstring(c_token)) {
- X int_error("filename or keyword 'functions' or 'variables' expected",c_token);
- X }
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"lo$ad")) {
- X if (!isstring(++c_token))
- X int_error("expecting filename",c_token);
- X c_token++;
- X copy_command(start_token, c_token-1);
- X }
- X else if (almost_equals(c_token,"ex$it") ||
- X almost_equals(c_token,"q$uit")) {
- X copy_command(start_token, c_token++);
- X /* done(IO_SUCCESS); */
- X }
- X else if (equals(c_token,";")) { /* null statement */
- X copy_command(start_token, c_token++);
- X } else {
- X int_error("invalid command",c_token);
- X }
- X}
- X
- Xload_range()
- X{
- Xstruct value t;
- Xdouble a,b;
- X
- X if (equals(c_token,"]"))
- X return;
- X if (END_OF_COMMAND) {
- X int_error("starting range value or 'to' expected",c_token);
- X } else if (!equals(c_token,"to") && !equals(c_token,":")) {
- X a = real(const_express(&t));
- X }
- X if (!equals(c_token,"to") && !equals(c_token,":"))
- X int_error("Keyword 'to' or ':' expected",c_token);
- X c_token++;
- X if (!equals(c_token,"]"))
- X b = real(const_express(&t));
- X}
- X
- X
- Xplotrequest()
- X{
- X int start_token = c_token;
- X
- X if (equals(c_token,"[")) {
- X c_token++;
- X if (isletter(c_token)) {
- X c_token++;
- X if (equals(c_token,"="))
- X c_token++;
- X else
- X int_error("'=' expected",c_token);
- X }
- X load_range();
- X if (!equals(c_token,"]"))
- X int_error("']' expected",c_token);
- X c_token++;
- X }
- X
- X if (equals(c_token,"[")) { /* set optional y ranges */
- X c_token++;
- X load_range();
- X if (!equals(c_token,"]"))
- X int_error("']' expected",c_token);
- X c_token++;
- X }
- X
- X capture(plot_ranges, start_token, c_token-1);
- X
- X eval_plots();
- X}
- X
- X/* Parse the definition of a style and add to table */
- Xadd_style()
- X{
- X register int i;
- X int style = -1; /* the new style number */
- X struct value a;
- X register struct st_entry *stp; /* quick access to new entry */
- X int null_definition = TRUE; /* watch out for missing definitions */
- X
- X /* check if it's already in the table... */
- X
- X style = -1;
- X for (i = 0; i < next_value; i++) {
- X if (equals(c_token,st[i].st_name))
- X style = i;
- X }
- X /* Not found - assign a new one */
- X if (style < 0)
- X style = next_style;
- X /* Found - redefine it */
- X if (style <= FIXED_STYLES)
- X int_error("cannot redefine this style", c_token);
- X if (style == MAX_STYLES)
- X int_error("user defined style space full",NO_CARET);
- X else
- X next_style++;
- X
- X stp = &st[style];
- X
- X /* Copy in the name of the style */
- X copy_str(stp->st_name,c_token);
- X stp->st_undef = TRUE;
- X c_token++;
- X
- X /* Point type */
- X if(!isstring(c_token)) {
- X *stp->st_point = '\0'; /* null point definition */
- X } else {
- X quote_str(stp->st_point, c_token);
- X c_token++;
- X null_definition = FALSE;
- X }
- X
- X /* Spacing */
- X if(END_OF_COMMAND) {
- X stp->st_spacing = 0;
- X stp->st_length = 0;
- X } else {
- X /* read dot spacing */
- X if (!isnumber(c_token)) {
- X next_value--;
- X int_error("expecting spacing (in points) for style", c_token);
- X }
- X convert(&a, c_token);
- X stp->st_spacing = magnitude(&a);
- X if (stp->st_spacing < 0.1) {
- X next_value--;
- X int_error("unreasonable spacing value", c_token);
- X }
- X c_token++;
- X
- X /* build dot sequence */
- X stp->st_length = 0;
- X
- X while(!(END_OF_COMMAND)) {
- X if (!isstring(c_token))
- X int_error("expecting a string defining a sequence style", c_token);
- X quote_str(stp->st_seq[stp->st_length++], c_token);
- X c_token++;
- X if (stp->st_length >= MAX_STYLE_SEQ_LENGTH)
- X int_error("style sequence too long", c_token);
- X }
- X null_definition = FALSE;
- X
- X if (stp->st_length == 0)
- X int_error("expecting dot sequence", c_token);
- X }
- X
- X if (null_definition)
- X int_error("expecting definition of style", c_token);
- X
- X c_token++;
- X}
- X
- X
- Xlabelrequest()
- X{
- X struct value a;
- X double x,y; /* the point */
- X char pos[MAX_ID_LEN+1]; /* optional argument */
- X char text[MAX_ID_LEN+1]; /* text of the label */
- X double length = 0; /* length of arrow */
- X int dx = 0, dy = 0; /* slope of arrow */
- X
- X /* x coordinate */
- X const_express(&a);
- X x = real(&a);
- X if (log_x) /* handle coords on logscale plot. PEM 01/17/89 */
- X x = log10(x);
- X
- X if (!equals(c_token, ","))
- X int_error("comma expected", c_token);
- X c_token++;
- X
- X /* y coordinate */
- X const_express(&a);
- X y = real(&a);
- X if (log_y) /* handle coords on logscale plot. PEM 01/17/89 */
- X y = log10(y);
- X
- X /* text */
- X if (isstring(c_token))
- X quote_str(text, c_token++);
- X else
- X int_error("expecting text of the label", c_token);
- X
- X /* optional pos */
- X pos[0] = '\0';
- X if (!(END_OF_COMMAND)) {
- X copy_str(pos, c_token++);
- X
- X /* optional length for optional arrow */
- X if (!(END_OF_COMMAND)) {
- X const_express(&a);
- X length = real(&a);
- X
- X if (!(END_OF_COMMAND)) {
- X if (!equals(c_token, ","))
- X int_error("comma expected", c_token);
- X c_token++;
- X
- X const_express(&a);
- X dx = (int) real(&a);
- X
- X if (!equals(c_token, ","))
- X int_error("comma expected", c_token);
- X c_token++;
- X
- X const_express(&a);
- X dy = (int) real(&a);
- X }
- X }
- X }
- X
- X save_label(x,y, text, pos, length, dx, dy);
- X}
- X
- X/* translate the label */
- Xsave_label(x,y, text, pos, length, dx, dy)
- X double x,y; /* the point */
- X char text[MAX_ID_LEN+1]; /* text of the label */
- X char pos[MAX_ID_LEN+1]; /* optional argument */
- X double length; /* length of arrow */
- X int dx, dy; /* slope of arrow */
- X{
- X char *where = NULL;
- X BOOLEAN adjust = FALSE;
- X double ex, ey;
- X
- X if (instring(pos, 'l'))
- X where = "left";
- X else if (instring(pos, 'r'))
- X where = "right";
- X else
- X where = "center";
- X
- X if (instring(pos, 't') || instring(pos, 'b'))
- X adjust = TRUE;
- X
- X fprintf(outfile, "set label \"%s\" at %g,%g %s\n", text, x, y, where);
- X
- X if (length != 0) {
- X /* arrow option. Compute destination */
- X if (dx == 0 && dy == 0) {
- X if (instring(pos, 'l'))
- X dx = -1;
- X else if (instring(pos, 'r'))
- X dx = 1;
- X else
- X dx = 0;
- X if (instring(pos, 't'))
- X dy = 1;
- X else if (instring(pos, 'b'))
- X dy = -1;
- X else
- X dy = 0;
- X }
- X ex = x + (dx ? length : 0);
- X ey = y + (dx ? ((float)dy/dx * length) : length);
- X
- X fprintf(outfile, "set arrow from %g,%g to %g,%g\n", x, y, ex, ey);
- X arrow_on = TRUE;
- X plot_arrow = TRUE;
- X }
- X
- X label_on = TRUE;
- X plot_label = TRUE;
- X was_output = TRUE;
- X}
- X
- Xkeyrequest()
- X{
- X struct value a;
- X double x,y; /* the point */
- X int styles[MAX_KEYS+1]; /* the style for each plot */
- X char *text[MAX_KEYS+1]; /* text of each key entry */
- X int style;
- X int curve = 0; /* index of the entry */
- X
- X /* x coordinate */
- X const_express(&a);
- X x = real(&a);
- X
- X if (!equals(c_token, ","))
- X int_error("comma expected", c_token);
- X c_token++;
- X
- X /* y coordinate */
- X const_express(&a);
- X y = real(&a);
- X
- X do { /* scan the entries in the key */
- X /* text */
- X if (isstring(c_token)) {
- X text[curve] = (char *) malloc(MAX_ID_LEN);
- X quote_str(text[curve], c_token++);
- X } else
- X int_error("expecting text of the key entry", c_token);
- X
- X if (almost_equals(c_token, "w$ith"))
- X c_token++;
- X else
- X int_error("expecting 'with' style for key entry", c_token);
- X
- X for (style = 0; style < next_style; style++)
- X if (equals(c_token, st[style].st_name))
- X break;
- X if (style == next_style)
- X int_error("unknown plot style; type 'show style'",
- X c_token);
- X else
- X styles[curve] = style;
- X c_token++;
- X
- X if (!END_OF_COMMAND)
- X if (!equals(c_token, ","))
- X int_error("expecting ',' between key entries", c_token);
- X else
- X c_token++;
- X
- X curve++;
- X if (curve > MAX_KEYS)
- X int_error("too many lines in the key", c_token);
- X } while (!END_OF_COMMAND);
- X
- X text[curve] = NULL; /* acts as terminator */
- X
- X save_key (x,y, styles, text);
- X
- X for (curve--; curve >= 0; curve--)
- X free(text[curve]);
- X}
- X
- Xsave_key (x,y, styles, text)
- X double x,y; /* the position of the key */
- X int styles[MAX_KEYS+1]; /* the style for each plot */
- X char *text[MAX_KEYS+1]; /* text of each key entry */
- X{
- X int curve; /* index of the entry */
- X
- X for (curve = 0; text[curve] != NULL; curve++) {
- X strcpy(plot[curve].title, text[curve]);
- X }
- X fprintf(outfile, "set key %g,%g", x,y);
- X was_output = TRUE;
- X key_on = TRUE;
- X plot_key = TRUE;
- X
- X err_msg("'key' command translated; position needs adjusting");
- X}
- X
- Xdefine()
- X{
- Xregister int value,start_token; /* start_token is the 1st token in the */
- X /* function definition. */
- X
- X if (equals(c_token+1,"(")) {
- X /* function ! */
- X start_token = c_token;
- X copy_str(dummy_var, c_token + 2);
- X c_token += 5; /* skip (, dummy, ) and = */
- X value = c_function = user_defined(start_token);
- X build_at(&(udft[value].at));
- X /* define User Defined Function (parse.c)*/
- X capture(udft[value].definition,start_token,c_token-1);
- X }
- X else {
- X /* variable ! */
- X c_token +=2;
- X (void) const_express(&vt[value = add_value(c_token - 2) ].vt_value);
- X vt[value].vt_undef = FALSE;
- X }
- X}
- X
- X/* This parses the plot command after any range specifications.
- X * We revert to one-pass parsing here. That's all we need.
- X */
- Xeval_plots()
- X{
- Xregister int plot_num, start_token;
- Xstruct value a;
- Xint style;
- X
- X c_function = MAX_UDFS; /* last udft[] entry used for plots */
- X
- X plot_num = 0;
- X
- X while (TRUE) {
- X if (END_OF_COMMAND)
- X int_error("function to plot expected",c_token);
- X if (plot_num == MAX_PLOTS)
- X int_error("maximum number of plots exceeded",NO_CARET);
- X
- X start_token = c_token;
- X
- X if (is_definition(c_token)) {
- X define();
- X } else {
- X if (isstring(c_token)) { /* data file to plot */
- X plot[plot_num].plot_type = DATA;
- X style = (int)data_style;
- X c_token++; /* skip file name */
- X }
- X else { /* function to plot */
- X plot[plot_num].plot_type = FUNC;
- X style = (int)func_style;
- X build_at(&udft[MAX_UDFS].at);
- X /* that's all */
- X }
- X capture(plot[plot_num].def,start_token,c_token-1);
- X plot[plot_num].title[0] = '\0';
- X
- X if (almost_equals(c_token,"w$ith")) {
- X c_token++;
- X for (style = 0; style < next_style; style++)
- X if (equals(c_token, st[style].st_name))
- X break;
- X if (style == next_style)
- X int_error("unknown plot style; type 'show style'",
- X c_token);
- X else
- X c_token++;
- X }
- X plot[plot_num].plot_style = equiv_style(style);
- X plot_num++;
- X }
- X
- X if (equals(c_token,","))
- X c_token++;
- X else
- X break;
- X }
- X
- X plot_count = plot_num;
- X}
- X
- X/* return a standard style close to the given style */
- Xint
- Xequiv_style(style)
- X int style; /* may be a user-def style */
- X{
- X BOOLEAN line, point;
- X char message[MAX_LINE_LEN+1];
- X
- X if (style <= FIXED_STYLES)
- X return(style);
- X
- X point = (st[style].st_point[0] != '\0');
- X line = (st[style].st_length > 0);
- X
- X sprintf(message,
- X "user-defined style %s replaced by similar standard style",
- X st[style].st_name);
- X err_msg(message);
- X
- X if (point && line)
- X return(LINESPOINTS);
- X if (point)
- X return(POINTS);
- X if (line)
- X return(LINES);
- X
- X /* should not happen */
- X err_msg("no standard style corresponds to this style");
- X return(LINES);
- X}
- X
- X
- X/* write out the plot command now that we know titles */
- Xwrite_plot()
- X{
- X int plot_num;
- X
- X if (!plot_key && key_on) {
- X fprintf(outfile, "set nokey\n");
- X key_on = FALSE;
- X }
- X
- X if (!plot_label && label_on) {
- X fprintf(outfile, "set nolabel\n");
- X label_on = FALSE;
- X }
- X
- X if (!plot_arrow && arrow_on) {
- X fprintf(outfile, "set noarrow\n");
- X arrow_on = FALSE;
- X }
- X
- X if (!plot_format) {
- X fprintf(outfile, "set format xy \"$%%g$\"\n");
- X plot_format = TRUE;
- X }
- X
- X fprintf(outfile, "plot %s ", plot_ranges);
- X
- X for (plot_num = 0; plot_num < plot_count; plot_num++) {
- X if (plot_num > 0)
- X fputs(", ", outfile);
- X fprintf(outfile, "%s", plot[plot_num].def);
- X if (plot[plot_num].title[0] != '\0')
- X fprintf(outfile, " title \"%s\"", plot[plot_num].title);
- X
- X fprintf(outfile, " with %s", st[plot[plot_num].plot_style].st_name);
- X }
- X
- X fprintf(outfile, "\n");
- X /* we don't set was_output since we have the newline already */
- X
- X fprintf(stderr,
- X "\n***%d: plot command moved, watch out for use of variables\n",
- X plot_line);
- X
- X pending_plot = FALSE;
- X plot_key = FALSE;
- X plot_label = FALSE;
- X plot_arrow = FALSE;
- X}
- X
- X/* copy a command from input to output */
- Xcopy_command(start, end)
- X int start, end; /* inclusive token numbers */
- X{
- X char command_line[MAX_LINE_LEN+1];
- X
- X capture(command_line, start, end);
- X fputs(command_line, outfile);
- X was_output = TRUE;
- X}
- X
- Xdone(status)
- Xint status;
- X{
- X if (pending_plot)
- X write_plot();
- X
- X exit(status);
- X}
- *-*-END-of-translate/command.c-*-*
- echo x - translate/eval.c
- sed 's/^X//' >translate/eval.c <<'*-*-END-of-translate/eval.c-*-*'
- X/*
- X *
- X * G N U P L O T -- eval.c
- X *
- X * Copyright (C) 1986 Colin Kelley, Thomas Williams
- X *
- X * You may use this code as you wish if credit is given and this message
- X * is retained.
- X *
- X * Please e-mail any useful additions to vu-vlsi!plot so they may be
- X * included in later releases.
- X *
- X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi)
- X */
- X
- X#include <stdio.h>
- X#include "plot.h"
- X
- Xextern int c_token,next_value,next_function;
- Xextern struct udft_entry udft[];
- Xextern struct ft_entry ft[];
- Xextern struct vt_entry vt[];
- Xextern struct at_type *curr_at;
- Xextern struct lexical_unit token[];
- X
- Xstruct value *integer();
- X
- X
- X
- Xint add_value(t_num)
- Xint t_num;
- X{
- Xregister int i;
- X
- X /* check if it's already in the table... */
- X
- X for (i = 0; i < next_value; i++) {
- X if (equals(t_num,vt[i].vt_name))
- X return(i);
- X }
- X if (next_value == MAX_VALUES)
- X int_error("user defined constant space full",NO_CARET);
- X copy_str(vt[next_value].vt_name,t_num);
- X vt[next_value].vt_value.type = INT; /* not necessary, but safe! */
- X vt[next_value].vt_undef = TRUE;
- X return(next_value++);
- X}
- X
- X
- Xadd_action(sf_index,arg)
- Xenum operators sf_index;
- Xstruct value *arg;
- X
- X /* argument to pass to standard function indexed by sf_index */
- X{
- X
- X if ( curr_at->count >= MAX_AT_LEN )
- X int_error("action table overflow",NO_CARET);
- X curr_at->actions[curr_at->count].index = ((int)sf_index);
- X if (arg != (struct value *)0)
- X curr_at->actions[curr_at->count].arg = *arg;
- X curr_at->count++;
- X}
- X
- X
- Xint standard(t_num) /* return standard function index or 0 */
- X{
- Xregister int i;
- X for (i = (int)SF_START; ft[i].ft_name != NULL; i++) {
- X if (equals(t_num,ft[i].ft_name))
- X return(i);
- X }
- X return(0);
- X}
- X
- X
- X
- Xint user_defined(t_num) /* find or add function and return index */
- Xint t_num; /* index to token[] */
- X{
- Xregister int i;
- X for (i = 0; i < next_function; i++) {
- X if (equals(t_num,udft[i].udft_name))
- X return(i);
- X }
- X if (next_function == MAX_UDFS)
- X int_error("user defined function space full",t_num);
- X copy_str(udft[next_function].udft_name,t_num);
- X udft[next_function].definition[0] = '\0';
- X udft[next_function].at.count = 0;
- X (void) integer(&udft[next_function].dummy_value, 0);
- X return(next_function++);
- X}
- X
- X
- X
- Xexecute_at(at_ptr)
- Xstruct at_type *at_ptr;
- X{
- Xregister int i;
- X for (i = 0; i < at_ptr->count; i++) {
- X (*ft[at_ptr->actions[i].index].funct)(&(at_ptr->actions[i].arg));
- X }
- X}
- X
- X/*
- X
- X 'ft' is a table containing C functions within this program.
- X
- X An 'action_table' contains pointers to these functions and arguments to be
- X passed to them.
- X
- X at_ptr is a pointer to the action table which must be executed (evaluated)
- X
- X so the iterated line exectues the function indexed by the at_ptr and
- X passes the argument which is pointed to by the arg_ptr
- X
- X*/
- *-*-END-of-translate/eval.c-*-*
- echo x - translate/gnut2p.1
- sed 's/^X//' >translate/gnut2p.1 <<'*-*-END-of-translate/gnut2p.1-*-*'
- X.TH GNUT2P 1
- X.SH NAME
- Xgnut2p \- translate GnuTeX input file to GNUPLOT input file
- X.SH SYNOPSIS
- X.B gnut2P
- Xinfile outfile
- X.SH DESCRIPTION
- X.I gnut2p
- Xconverts an input file for the old gnutex(1) plotting program into an
- Xinput file suitable for its successor, gnuplot(1) version 2.0. This
- Xprogram does its best, but is not perfect. Most of gnutex will
- Xtranslate directly, some things will translated easily (such as \fBset
- Xsize\fR), but some things cannot be translated (such as \fBset
- Xstyle\fR). One thing this program does is to move plot commands down
- Xpast the \fBlabel\fR and \fBkey\fR commands (which change into \fBset
- Xlabel\fR and \fBset key\fR commands). This may move it past other
- Xcommands. If it moves past variable or function definitions,
- X\fBset\fR commands, or other commands which affect the plot command's
- Xexecution, then the new version will be incorrect. I expect this case
- Xto be rare; indeed, I generally expect the last lines in GnuTeX input
- Xfiles used with LaTeX to consist of \fBplot\fR, \fBlabel\fR, and
- X\fBkey\fR commands.
- X.PP
- XThe usage of this program is simple.
- X.I infile
- Xis an existing GnuTeX file, and
- X.I outfile
- Xwill be created as the GNUPLOT equivalent. The errors, warnings, and
- Xexplanatory comments appear on stderr. Any use of line continuation
- Xwill be lost, and some instances of the input style (eg, white space)
- Xmay be changed.
- X
- X.SH SEE ALSO
- Xgnuplot(1), gnutex(1)
- X.br
- XThe "GNUPLOT" 2.0 Manual
- X.br
- XThe "GnuTeX" 1.6 Manual and Tutorial
- X.br
- X"LaTeX and the GNUPLOT Plotting Program" (notes for former GnuTeX users).
- X
- X.SH AUTHOR
- XDavid Kotz dfk@cs.duke.edu
- *-*-END-of-translate/gnut2p.1-*-*
- echo x - translate/internal.c
- sed 's/^X//' >translate/internal.c <<'*-*-END-of-translate/internal.c-*-*'
- X/*
- X *
- X * G N U P L O T -- internal.c
- X *
- X * Copyright (C) 1986 Colin Kelley, Thomas Williams
- X *
- X * You may use this code as you wish if credit is given and this message
- X * is retained.
- X *
- X * Please e-mail any useful additions to vu-vlsi!plot so they may be
- X * included in later releases.
- X *
- X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi)
- X */
- X
- X#include <math.h>
- X#include <stdio.h>
- X#include "plot.h"
- X
- Xextern BOOLEAN undefined;
- Xextern struct vt_entry vt[MAX_VALUES];
- Xextern struct udft_entry udft[MAX_UDFS];
- X
- Xchar *strcpy();
- X
- Xstruct value *pop(), *complex(), *integer();
- Xdouble magnitude(), angle(), real();
- X
- Xstruct value stack[STACK_DEPTH];
- X
- Xint s_p = -1; /* stack pointer */
- X
- X#ifndef MSDOS /* suggested by "J.D. McDonald " <mcdonald@uxe.cso.uiuc.edu> */
- X/*
- X * System V and MSC 4.0 call this when they wants to print an error message.
- X * Don't!
- X */
- Xmatherr()
- X{
- X return (undefined = TRUE); /* don't print error message */
- X}
- X#endif MSDOS
- X
- Xreset_stack()
- X{
- X s_p = -1;
- X}
- X
- X
- Xcheck_stack() /* make sure stack's empty */
- X{
- X if (s_p != -1)
- X fprintf(stderr,"\nwarning: internal error--stack not empty!\n");
- X}
- X
- X
- Xstruct value *pop(x)
- Xstruct value *x;
- X{
- X if (s_p < 0 )
- X int_error("stack underflow",NO_CARET);
- X *x = stack[s_p--];
- X return(x);
- X}
- X
- X#define ERR_VAR "undefined variable: "
- X
- Xf_push(x)
- Xstruct value *x; /* contains index of value to push; must be integer! */
- X{
- Xstatic char err_str[sizeof(ERR_VAR) + MAX_ID_LEN] = ERR_VAR;
- Xregister int index;
- X
- X if (x->type != INT)
- X int_error("internal error--non-int passed to f_push!",NO_CARET);
- X index = x->v.int_val;
- X
- X if (vt[index].vt_undef) { /* undefined */
- X (void) strcpy(&err_str[sizeof(ERR_VAR) - 1], vt[index].vt_name);
- X int_error(err_str,NO_CARET);
- X }
- X push(&vt[index].vt_value);
- X}
- X
- X
- Xf_pushc(x)
- Xstruct value *x;
- X{
- X if (s_p == STACK_DEPTH - 1)
- X int_error("stack overflow",NO_CARET);
- X stack[++s_p] = *x;
- X}
- X
- X
- Xf_pushd(x)
- Xstruct value *x;
- X{
- X f_pushc(&udft[x->v.int_val].dummy_value);
- X}
- X
- X
- X#define ERR_FUN "undefined function: "
- X
- Xf_call(f_index) /* execute a udf */
- Xstruct value *f_index;
- X{
- Xstatic char err_str[sizeof(ERR_FUN) + MAX_ID_LEN] = ERR_FUN;
- X
- X if (udft[f_index->v.int_val].at.count == 0) { /* undefined */
- X (void) strcpy(&err_str[sizeof(ERR_FUN) - 1],
- X udft[f_index->v.int_val].udft_name);
- X int_error(err_str,NO_CARET);
- X }
- X (void) pop(&udft[f_index->v.int_val].dummy_value);
- X
- X execute_at(&udft[f_index->v.int_val].at);
- X}
- X
- X
- Xstatic int_check(v)
- Xstruct value *v;
- X{
- X if (v->type != INT)
- X int_error("non-integer passed to boolean operator",NO_CARET);
- X}
- X
- X
- Xf_terniary() /* code for (a) ? b : c */
- X{
- Xstruct value a, b, c;
- X (void) pop(&c); (void) pop(&b); int_check(pop(&a));
- X push((a.v.int_val) ? &b : &c);
- X /* I just had to use ? : here! */
- X}
- X
- X
- Xf_lnot()
- X{
- Xstruct value a;
- X int_check(pop(&a));
- X push(integer(&a,!a.v.int_val) );
- X}
- X
- X
- Xf_bnot()
- X{
- Xstruct value a;
- X int_check(pop(&a));
- X push( integer(&a,~a.v.int_val) );
- X}
- X
- X
- Xf_lor()
- X{
- Xstruct value a,b;
- X int_check(pop(&b));
- X int_check(pop(&a));
- X push( integer(&a,a.v.int_val || b.v.int_val) );
- X}
- X
- X
- Xf_land()
- X{
- Xstruct value a,b;
- X int_check(pop(&b));
- X int_check(pop(&a));
- X push( integer(&a,a.v.int_val && b.v.int_val) );
- X}
- X
- X
- Xf_bor()
- X{
- Xstruct value a,b;
- X int_check(pop(&b));
- X int_check(pop(&a));
- X push( integer(&a,a.v.int_val | b.v.int_val) );
- X}
- X
- X
- Xf_xor()
- X{
- Xstruct value a,b;
- X int_check(pop(&b));
- X int_check(pop(&a));
- X push( integer(&a,a.v.int_val ^ b.v.int_val) );
- X}
- X
- X
- Xf_band()
- X{
- Xstruct value a,b;
- X int_check(pop(&b));
- X int_check(pop(&a));
- X push( integer(&a,a.v.int_val & b.v.int_val) );
- X}
- X
- X
- Xf_uminus()
- X{
- Xstruct value a;
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X a.v.int_val = -a.v.int_val;
- X break;
- X case CMPLX:
- X a.v.cmplx_val.real =
- X -a.v.cmplx_val.real;
- X a.v.cmplx_val.imag =
- X -a.v.cmplx_val.imag;
- X }
- X push(&a);
- X}
- X
- X
- Xf_eq() /* note: floating point equality is rare because of roundoff error! */
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val ==
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val ==
- X b.v.cmplx_val.real &&
- X b.v.cmplx_val.imag == 0.0);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (b.v.int_val == a.v.cmplx_val.real &&
- X a.v.cmplx_val.imag == 0.0);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real==
- X b.v.cmplx_val.real &&
- X a.v.cmplx_val.imag==
- X b.v.cmplx_val.imag);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_ne()
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val !=
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val !=
- X b.v.cmplx_val.real ||
- X b.v.cmplx_val.imag != 0.0);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (b.v.int_val !=
- X a.v.cmplx_val.real ||
- X a.v.cmplx_val.imag != 0.0);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real !=
- X b.v.cmplx_val.real ||
- X a.v.cmplx_val.imag !=
- X b.v.cmplx_val.imag);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_gt()
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val >
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val >
- X b.v.cmplx_val.real);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (a.v.cmplx_val.real >
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real >
- X b.v.cmplx_val.real);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_lt()
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val <
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val <
- X b.v.cmplx_val.real);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (a.v.cmplx_val.real <
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real <
- X b.v.cmplx_val.real);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_ge()
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val >=
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val >=
- X b.v.cmplx_val.real);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (a.v.cmplx_val.real >=
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real >=
- X b.v.cmplx_val.real);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_le()
- X{
- Xstruct value a, b;
- X register int result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X result = (a.v.int_val <=
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.int_val <=
- X b.v.cmplx_val.real);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X result = (a.v.cmplx_val.real <=
- X b.v.int_val);
- X break;
- X case CMPLX:
- X result = (a.v.cmplx_val.real <=
- X b.v.cmplx_val.real);
- X }
- X }
- X push(integer(&a,result));
- X}
- X
- X
- Xf_plus()
- X{
- Xstruct value a, b, result;
- X (void) pop(&b);
- X (void) pop(&a);
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X (void) integer(&result,a.v.int_val +
- X b.v.int_val);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.int_val +
- X b.v.cmplx_val.real,
- X b.v.cmplx_val.imag);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X (void) complex(&result,b.v.int_val +
- X a.v.cmplx_val.real,
- X a.v.cmplx_val.imag);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.cmplx_val.real+
- X b.v.cmplx_val.real,
- X a.v.cmplx_val.imag+
- X b.v.cmplx_val.imag);
- X }
- X }
- X push(&result);
- X}
- X
- X
- Xf_minus()
- X{
- Xstruct value a, b, result;
- X (void) pop(&b);
- X (void) pop(&a); /* now do a - b */
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X (void) integer(&result,a.v.int_val -
- X b.v.int_val);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.int_val -
- X b.v.cmplx_val.real,
- X -b.v.cmplx_val.imag);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X (void) complex(&result,a.v.cmplx_val.real -
- X b.v.int_val,
- X a.v.cmplx_val.imag);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.cmplx_val.real-
- X b.v.cmplx_val.real,
- X a.v.cmplx_val.imag-
- X b.v.cmplx_val.imag);
- X }
- X }
- X push(&result);
- X}
- X
- X
- Xf_mult()
- X{
- Xstruct value a, b, result;
- X (void) pop(&b);
- X (void) pop(&a); /* now do a*b */
- X
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X (void) integer(&result,a.v.int_val *
- X b.v.int_val);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.int_val *
- X b.v.cmplx_val.real,
- X a.v.int_val *
- X b.v.cmplx_val.imag);
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X (void) complex(&result,b.v.int_val *
- X a.v.cmplx_val.real,
- X b.v.int_val *
- X a.v.cmplx_val.imag);
- X break;
- X case CMPLX:
- X (void) complex(&result,a.v.cmplx_val.real*
- X b.v.cmplx_val.real-
- X a.v.cmplx_val.imag*
- X b.v.cmplx_val.imag,
- X a.v.cmplx_val.real*
- X b.v.cmplx_val.imag+
- X a.v.cmplx_val.imag*
- X b.v.cmplx_val.real);
- X }
- X }
- X push(&result);
- X}
- X
- X
- Xf_div()
- X{
- Xstruct value a, b, result;
- Xregister double square;
- X (void) pop(&b);
- X (void) pop(&a); /* now do a/b */
- X
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X if (b.v.int_val)
- X (void) integer(&result,a.v.int_val /
- X b.v.int_val);
- X else {
- X (void) integer(&result,0);
- X undefined = TRUE;
- X }
- X break;
- X case CMPLX:
- X square = b.v.cmplx_val.real*
- X b.v.cmplx_val.real +
- X b.v.cmplx_val.imag*
- X b.v.cmplx_val.imag;
- X if (square)
- X (void) complex(&result,a.v.int_val*
- X b.v.cmplx_val.real/square,
- X -a.v.int_val*
- X b.v.cmplx_val.imag/square);
- X else {
- X (void) complex(&result,0.0,0.0);
- X undefined = TRUE;
- X }
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X if (b.v.int_val)
- X
- X (void) complex(&result,a.v.cmplx_val.real/
- X b.v.int_val,
- X a.v.cmplx_val.imag/
- X b.v.int_val);
- X else {
- X (void) complex(&result,0.0,0.0);
- X undefined = TRUE;
- X }
- X break;
- X case CMPLX:
- X square = b.v.cmplx_val.real*
- X b.v.cmplx_val.real +
- X b.v.cmplx_val.imag*
- X b.v.cmplx_val.imag;
- X if (square)
- X (void) complex(&result,(a.v.cmplx_val.real*
- X b.v.cmplx_val.real+
- X a.v.cmplx_val.imag*
- X b.v.cmplx_val.imag)/square,
- X (a.v.cmplx_val.imag*
- X b.v.cmplx_val.real-
- X a.v.cmplx_val.real*
- X b.v.cmplx_val.imag)/
- X square);
- X else {
- X (void) complex(&result,0.0,0.0);
- X undefined = TRUE;
- X }
- X }
- X }
- X push(&result);
- X}
- X
- X
- Xf_mod()
- X{
- Xstruct value a, b;
- X (void) pop(&b);
- X (void) pop(&a); /* now do a%b */
- X
- X if (a.type != INT || b.type != INT)
- X int_error("can only mod ints",NO_CARET);
- X if (b.v.int_val)
- X push(integer(&a,a.v.int_val % b.v.int_val));
- X else {
- X push(integer(&a,0));
- X undefined = TRUE;
- X }
- X}
- X
- X
- Xf_power()
- X{
- Xstruct value a, b, result;
- Xregister int i, t, count;
- Xregister double mag, ang;
- X (void) pop(&b);
- X (void) pop(&a); /* now find a**b */
- X
- X switch(a.type) {
- X case INT:
- X switch (b.type) {
- X case INT:
- X count = abs(b.v.int_val);
- X t = 1;
- X for(i=0; i < count; i++)
- X t *= a.v.int_val;
- X if (b.v.int_val >= 0)
- X (void) integer(&result,t);
- X else
- X (void) complex(&result,1.0/t,0.0);
- X break;
- X case CMPLX:
- X mag =
- X pow(magnitude(&a),fabs(b.v.cmplx_val.real));
- X if (b.v.cmplx_val.real < 0.0)
- X mag = 1.0/mag;
- X ang = angle(&a)*b.v.cmplx_val.real+
- X b.v.cmplx_val.imag;
- X (void) complex(&result,mag*cos(ang),
- X mag*sin(ang));
- X }
- X break;
- X case CMPLX:
- X switch (b.type) {
- X case INT:
- X /* not so good, but...! */
- X mag =
- X pow(magnitude(&a),(double)abs(b.v.int_val));
- X if (b.v.int_val < 0)
- X mag = 1.0/mag;
- X ang = angle(&a)*b.v.int_val;
- X (void) complex(&result,mag*cos(ang),
- X mag*sin(ang));
- X break;
- X case CMPLX:
- X mag =
- X pow(magnitude(&a),fabs(b.v.cmplx_val.real));
- X if (b.v.cmplx_val.real < 0.0)
- X mag = 1.0/mag;
- X ang = angle(&a)*b.v.cmplx_val.real+
- X b.v.cmplx_val.imag;
- X (void) complex(&result,mag*cos(ang),
- X mag*sin(ang));
- X }
- X }
- X push(&result);
- X}
- *-*-END-of-translate/internal.c-*-*
- echo x - translate/misc.c
- sed 's/^X//' >translate/misc.c <<'*-*-END-of-translate/misc.c-*-*'
- X/*
- X *
- X * G N U P L O T -- misc.c
- X *
- X * Copyright (C) 1986 Thomas Williams, Colin Kelley
- X *
- X * You may use this code as you wish if credit is given and this message
- X * is retained.
- X *
- X * Please e-mail any useful additions to vu-vlsi!plot so they may be
- X * included in later releases.
- X *
- X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi)
- X */
- X
- X#include <stdio.h>
- X#include "plot.h"
- X
- Xextern struct curve_points plot[];
- Xextern int c_token,next_value,next_function;
- Xextern struct udft_entry udft[];
- Xextern struct at_type *curr_at;
- Xextern struct ft_entry ft[];
- Xextern struct vt_entry vt[];
- X
- X
- Xshow_at(level)
- Xint level;
- X{
- Xstruct at_type *at_address;
- Xint i, j;
- Xstruct value *arg;
- X
- X at_address = curr_at;
- X for (i = 0; i < at_address->count; i++) {
- X for (j = 0; j < level; j++)
- X (void) putc(' ',stderr); /* indent */
- X
- X /* print name of action instruction */
- X fputs(ft[at_address->actions[i].index].ft_name,stderr);
- X arg = &(at_address->actions[i].arg);
- X /* now print optional argument */
- X
- X switch(at_address->actions[i].index) {
- X case (int)PUSH: fprintf(stderr," (%s)\n",
- X vt[arg->v.int_val].vt_name);
- X break;
- X case (int)PUSHC: (void) putc('(',stderr);
- X show_value(stderr,arg);
- X fputs(")\n",stderr);
- X break;
- X case (int)PUSHD: fprintf(stderr," (%s dummy)\n",
- X udft[arg->v.int_val].udft_name);
- X break;
- X case (int)CALL: fprintf(stderr," (%s)\n",
- X udft[arg->v.int_val].udft_name);
- X curr_at = &udft[arg->v.int_val].at;
- X show_at(level+2); /* recurse! */
- X curr_at = at_address;
- X break;
- X default:
- X (void) putc('\n',stderr);
- X }
- X }
- X}
- *-*-END-of-translate/misc.c-*-*
- echo x - translate/parse.c
- sed 's/^X//' >translate/parse.c <<'*-*-END-of-translate/parse.c-*-*'
- X/*
- X *
- X * G N U P L O T -- parse.c
- X *
- X * Copyright (C) 1986 Colin Kelley, Thomas Williams
- X *
- X * You may use this code as you wish if credit is given and this message
- X * is retained.
- X *
- X * Please e-mail any useful additions to vu-vlsi!plot so they may be
- X * included in later releases.
- X *
- X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi)
- X */
- X
- X#include <stdio.h>
- X#include <setjmp.h>
- X#include <signal.h>
- X#include <errno.h>
- X#include "plot.h"
- X
- Xextern BOOLEAN undefined;
- X
- X#ifndef vms
- Xextern int errno;
- X#endif
- X
- Xextern int next_function,c_function /* next available space in udft */;
- Xextern int num_tokens,c_token;
- Xextern struct lexical_unit token[];
- Xextern char dummy_var[];
- Xextern struct at_type *curr_at;
- X
- Xstruct value *pop(),*integer(),*complex();
- X
- Xstatic struct at_type temp_at;
- Xstatic jmp_buf fpe_env;
- X
- X#define dummy (struct value *) 0
- X
- Xfpe()
- X{
- X (void) signal(SIGFPE, fpe);
- X undefined = TRUE;
- X longjmp(fpe_env, TRUE);
- X}
- X
- Xevaluate_at(at,valptr)
- Xstruct at_type *at;
- Xstruct value *valptr;
- X{
- X undefined = FALSE;
- X errno = 0;
- X reset_stack();
- X if (setjmp(fpe_env))
- X return; /* just bail out */
- X (void) signal(SIGFPE, fpe); /* catch core dumps on FPEs */
- X
- X execute_at(at);
- X
- X (void) signal(SIGFPE, SIG_DFL);
- X
- X if (errno == EDOM || errno == ERANGE) {
- X undefined = TRUE;
- X } else {
- X (void) pop(valptr);
- X check_stack();
- X }
- X}
- X
- X
- Xstruct value *
- Xconst_express(valptr)
- Xstruct value *valptr;
- X{
- Xregister int tkn = c_token;
- X if (END_OF_COMMAND)
- X int_error("constant expression required",c_token);
- X build_at(&temp_at); /* make a temporary action table */
- X evaluate_at(&temp_at,valptr); /* run it and send answer back */
- X if (undefined) {
- X int_error("undefined value",tkn);
- X }
- X return(valptr);
- X}
- X
- X
- Xbuild_at(at) /* build full expressions */
- Xstruct at_type *at;
- X{
- X curr_at = at; /* set global variable */
- X curr_at->count = 0; /* reset action table !!! */
- X express();
- X}
- X
- X
- Xexpress() /* full expressions */
- X{
- X xterm();
- X xterms();
- X}
- X
- Xxterm() /* NEW! ? : expressions */
- X{
- X aterm();
- X aterms();
- X}
- X
- X
- Xaterm()
- X{
- X bterm();
- X bterms();
- X}
- X
- X
- Xbterm()
- X{
- X cterm();
- X cterms();
- X}
- X
- X
- Xcterm()
- X{
- X dterm();
- X dterms();
- X}
- X
- X
- Xdterm()
- X{
- X eterm();
- X eterms();
- X}
- X
- X
- Xeterm()
- X{
- X fterm();
- X fterms();
- X}
- X
- X
- Xfterm()
- X{
- X gterm();
- X gterms();
- X}
- X
- X
- Xgterm()
- X{
- X hterm();
- X hterms();
- X}
- X
- X
- Xhterm()
- X{
- X unary(); /* - things */
- X iterms(); /* * / % */
- X}
- X
- X
- Xfactor()
- X{
- Xregister int value;
- Xstruct value a, real_value;
- X
- X if (equals(c_token,"(")) {
- X c_token++;
- X express();
- X if (!equals(c_token,")"))
- X int_error("')' expected",c_token);
- X c_token++;
- X }
- X else if (isnumber(c_token)) {
- X convert(&real_value,c_token);
- X c_token++;
- X add_action(PUSHC, &real_value);
- X }
- X else if (isletter(c_token)) {
- X if ((c_token+1 < num_tokens) && equals(c_token+1,"(")) {
- X value = standard(c_token);
- X if (value) { /* it's a standard function */
- X c_token += 2;
- X express();
- X if (!equals(c_token,")"))
- X int_error("')' expected",c_token);
- X c_token++;
- X add_action(value,dummy);
- X }
- X else {
- X value = user_defined(c_token);
- X c_token += 2;
- X express();
- X if (!equals(c_token,")"))
- X int_error("')' expected",c_token);
- X c_token++;
- X add_action(CALL,integer(&a,value));
- X }
- X }
- X else {
- X if (equals(c_token,dummy_var)) {
- X value = c_function;
- X c_token++;
- X add_action(PUSHD,integer(&a,value));
- X }
- X else {
- X value = add_value(c_token);
- X c_token++;
- X add_action(PUSH,integer(&a,value));
- X }
- X }
- X } /* end if letter */
- X else
- X int_error("invalid expression ",c_token);
- X
- X /* add action code for ** operator */
- X if (equals(c_token,"**")) {
- X c_token++;
- X unary();
- X add_action(POWER,dummy);
- X }
- X}
- X
- X
- X
- Xxterms()
- X{ /* create action code for ? : expressions */
- X
- X while (equals(c_token,"?")) {
- X c_token++;
- X express();
- X if (!equals(c_token,":"))
- X int_error("expecting ':'",c_token);
- X c_token++;
- X express();
- X add_action(TERNIARY,dummy);
- X }
- X}
- X
- X
- Xaterms()
- X{ /* create action codes for || operator */
- X
- X while (equals(c_token,"||")) {
- X c_token++;
- X aterm();
- X add_action(LOR,dummy);
- X }
- X}
- X
- X
- Xbterms()
- X{ /* create action code for && operator */
- X
- X while (equals(c_token,"&&")) {
- X c_token++;
- X bterm();
- X add_action(LAND,dummy);
- X }
- X}
- X
- X
- Xcterms()
- X{ /* create action code for | operator */
- X
- X while (equals(c_token,"|")) {
- X c_token++;
- X cterm();
- X add_action(BOR,dummy);
- X }
- X}
- X
- X
- Xdterms()
- X{ /* create action code for ^ operator */
- X
- X while (equals(c_token,"^")) {
- X c_token++;
- X dterm();
- X add_action(XOR,dummy);
- X }
- X}
- X
- X
- Xeterms()
- X{ /* create action code for & operator */
- X
- X while (equals(c_token,"&")) {
- X c_token++;
- X eterm();
- X add_action(BAND,dummy);
- X }
- X}
- X
- X
- Xfterms()
- X{ /* create action codes for == and != operators */
- X
- X while (TRUE) {
- X if (equals(c_token,"==")) {
- X c_token++;
- X fterm();
- X add_action(EQ,dummy);
- X }
- X else if (equals(c_token,"!=")) {
- X c_token++;
- X fterm();
- X add_action(NE,dummy);
- X }
- X else break;
- X }
- X}
- X
- X
- Xgterms()
- X{ /* create action code for < > >= or <= operators */
- X
- X while (TRUE) {
- X /* I hate "else if" statements */
- X if (equals(c_token,">")) {
- X c_token++;
- X gterm();
- X add_action(GT,dummy);
- X }
- X else if (equals(c_token,"<")) {
- X c_token++;
- X gterm();
- X add_action(LT,dummy);
- X }
- X else if (equals(c_token,">=")) {
- X c_token++;
- X gterm();
- X add_action(GE,dummy);
- X }
- X else if (equals(c_token,"<=")) {
- X c_token++;
- X gterm();
- X add_action(LE,dummy);
- X }
- X else break;
- X }
- X
- X}
- X
- X
- X
- Xhterms()
- X{ /* create action codes for + and - operators */
- X
- X while (TRUE) {
- X if (equals(c_token,"+")) {
- X c_token++;
- X hterm();
- X add_action(PLUS,dummy);
- X }
- X else if (equals(c_token,"-")) {
- X c_token++;
- X hterm();
- X add_action(MINUS,dummy);
- X }
- X else break;
- X }
- X}
- X
- X
- Xiterms()
- X{ /* add action code for * / and % operators */
- X
- X while (TRUE) {
- X if (equals(c_token,"*")) {
- X c_token++;
- X unary();
- X add_action(MULT,dummy);
- X }
- X else if (equals(c_token,"/")) {
- X c_token++;
- X unary();
- X add_action(DIV,dummy);
- X }
- X else if (equals(c_token,"%")) {
- X c_token++;
- X unary();
- X add_action(MOD,dummy);
- X }
- X else break;
- X }
- X}
- X
- X
- Xunary()
- X{ /* add code for unary operators */
- X if (equals(c_token,"!")) {
- X c_token++;
- X unary();
- X add_action(LNOT,dummy);
- X }
- X else if (equals(c_token,"~")) {
- X c_token++;
- X unary();
- X add_action(BNOT,dummy);
- X }
- X else if (equals(c_token,"-")) {
- X c_token++;
- X unary();
- X add_action(UMINUS,dummy);
- X }
- X else
- X factor();
- X}
- *-*-END-of-translate/parse.c-*-*
- echo x - translate/plot.c
- sed 's/^X//' >translate/plot.c <<'*-*-END-of-translate/plot.c-*-*'
- X/*
- X *
- X * gnutex/gnuplot translator -- plot.c
- X *
- X * By David Kotz, 1990.
- X * Department of Computer Science, Duke University, Durham, NC 27706.
- X * Mail to dfk@cs.duke.edu.
- X */
- X
- X#include <stdio.h>
- X#include <setjmp.h>
- X#include <signal.h>
- X#include "plot.h"
- X
- Xextern FILE *infile;
- Xextern FILE *outfile;
- X
- Xjmp_buf env;
- X
- Xstruct value stack[STACK_DEPTH];
- X
- Xstruct lexical_unit token[MAX_TOKENS];
- X
- Xstruct value *integer(),*complex();
- X
- Xextern f_push(),f_pushc(),f_pushd(),f_call(),f_terniary(),f_lnot(),f_bnot(),
- X f_uminus(),f_lor(),f_land(),f_bor(),f_xor(),f_band(),f_eq(),f_ne(),
- X f_gt(),f_lt(),f_ge(),f_le(),f_plus(),f_minus(),f_mult(),f_div(),
- X f_mod(),f_power();
- X
- Xextern f_real(),f_imag(),f_arg(),f_conjg(),f_sin(),f_cos(),f_tan(),f_asin(),
- X f_acos(),f_atan(),f_sinh(),f_cosh(),f_tanh(),f_int(),f_abs(),f_sgn(),
- X f_sqrt(),f_exp(),f_log10(),f_log(),f_besj0(),f_besj1(),f_besy0(),f_besy1(),
- X f_floor(),f_ceil();
- X
- X
- Xstruct ft_entry ft[] = { /* built-in function table */
- X
- X/* internal functions: */
- X {"push", f_push}, {"pushc", f_pushc}, {"pushd", f_pushd},
- X {"call", f_call}, {"?:", f_terniary}, {"lnot", f_lnot},
- X {"bnot", f_bnot}, {"uminus", f_uminus}, {"lor", f_lor},
- X {"land", f_land}, {"bor", f_bor}, {"xor", f_xor},
- X {"band", f_band}, {"eq", f_eq}, {"ne", f_ne},
- X {"gt", f_gt}, {"lt", f_lt}, {"ge", f_ge},
- X {"le", f_le}, {"plus", f_plus}, {"minus", f_minus},
- X {"mult", f_mult}, {"div", f_div}, {"mod", f_mod},
- X {"power", f_power},
- X
- X/* standard functions: */
- X {"real", f_real}, {"imag", f_imag}, {"arg", f_arg},
- X {"conjg", f_conjg}, {"sin", f_sin}, {"cos", f_cos},
- X {"tan", f_tan}, {"asin", f_asin}, {"acos", f_acos},
- X {"atan", f_atan}, {"sinh", f_sinh}, {"cosh", f_cosh},
- X {"tanh", f_tanh}, {"int", f_int}, {"abs", f_abs},
- X {"sgn", f_sgn}, {"sqrt", f_sqrt}, {"exp", f_exp},
- X {"log10", f_log10}, {"log", f_log}, {"besj0", f_besj0},
- X {"besj1", f_besj1}, {"besy0", f_besy0}, {"besy1", f_besy1},
- X {"floor", f_floor}, {"ceil", f_ceil}, {NULL, NULL}
- X};
- X
- Xstruct udft_entry udft[MAX_UDFS+1];
- X
- Xstruct vt_entry vt[MAX_VALUES] = {
- X {"pi"}, {"xmin"}, {"xmax"},
- X {"ymin"}, {"ymax"}, {"autoscale"}
- X};
- X
- Xstruct st_entry st[MAX_STYLES] = {
- X /* include the fixed styles by default */
- X /* These must match the positions in enum PLOT_STYLE */
- X {"lines"}, {"points"}, {"impulses"}, {"linespoints"},
- X {"dots"}
- X};
- Xint next_style = FIXED_STYLES+1;
- X
- Xcatch() /* interrupts */
- X{
- X (void) signal(SIGFPE, SIG_DFL); /* turn off FPE trapping */
- X (void) fflush(outfile);
- X (void) putc('\n',stderr);
- X longjmp(env, TRUE); /* return to prompt */
- X}
- X
- X
- Xmain(argc, argv)
- X int argc;
- X char **argv;
- X{
- X setbuf(stderr,NULL);
- X
- X if (argc == 3) {
- X infile = fopen(argv[1], "r");
- X if (infile == (FILE *)NULL) {
- X fprintf(stderr, "Cannot open '%s' for input\n", argv[1]);
- X exit(1);
- X }
- X outfile = fopen(argv[2], "w");
- X if (outfile == (FILE *)NULL) {
- X fprintf(stderr, "Cannot open '%s' for output\n", argv[2]);
- X exit(1);
- X }
- X } else {
- X fprintf(stderr, "usage: gnut2p infile outfile\n");
- X exit(2);
- X }
- X
- X (void) complex(&vt[(int)C_PI].vt_value, Pi, 0.0);
- X
- X setjmp(env);
- X
- X /* setting to some of the old defaults */
- X fprintf(outfile, "set noclip one; set noclip two; set clip points\n");
- X
- X while(TRUE)
- X com_line();
- X}
- *-*-END-of-translate/plot.c-*-*
- exit
-
-
-