home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume11 / gnuplot2 / part13 < prev    next >
Encoding:
Text File  |  1990-03-25  |  60.0 KB  |  2,614 lines

  1. Newsgroups: comp.sources.misc
  2. organization: Pixar -- Marin County, California
  3. subject: v11i078: Gnuplot 2.0 - 13 of 14
  4. From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 11, Issue 78
  8. Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
  9. Archive-name: gnuplot2/part13
  10.  
  11. This is gnuplot.sh13
  12.  
  13. --- CUT HERE ---
  14. #! /bin/sh
  15. echo x - translate/Makefile
  16. sed 's/^X//' >translate/Makefile <<'*-*-END-of-translate/Makefile-*-*'
  17. X#------------------------------------------------------------------
  18. X# Makefile for gnut2p
  19. X#   A translation program from Gnutex to GNUPLOT
  20. X#   David Kotz
  21. X#   Duke University
  22. X#   dfk@cs.duke.edu
  23. X#
  24. X# derived from gnutex
  25. X#
  26. X
  27. X# Define this for production version
  28. XCFLAGS=-O -s
  29. X# For the debugging version
  30. X#CFLAGS=-g
  31. X
  32. X# Your favorite tags program
  33. XTAGS=etags
  34. X#TAGS=ctags
  35. X
  36. XOBJS = plot.o scanner.o parse.o command.o eval.o \
  37. X    standard.o internal.o util.o misc.o 
  38. X
  39. XSRC = plot.h command.c eval.c internal.c misc.c \
  40. X    parse.c plot.c scanner.c standard.c util.c
  41. X
  42. Xgnut2p: $(OBJS)
  43. X    cc $(CFLAGS) $(OBJS) -o gnut2p -lm
  44. X
  45. X$(OBJS): plot.h
  46. X
  47. XTAGS: $(SRC)
  48. X    $(TAGS) $(SRC)
  49. X
  50. Xclean:
  51. X    rm -f *.o *~ core
  52. X
  53. Xspotless:
  54. X    rm -f *.o *~ core gnut2p TAGS
  55. X
  56. *-*-END-of-translate/Makefile-*-*
  57. echo x - translate/README
  58. sed 's/^X//' >translate/README <<'*-*-END-of-translate/README-*-*'
  59. Xgnut2p translator - David Kotz January 1990
  60. X
  61. XThis program converts gnutex files to gnuplot files.  It does its
  62. Xbest, but is not perfect. Most of gnutex will translate directly, some
  63. Xthings will translated easily (such as 'set size'), but some things
  64. Xcannot be translated (such as 'set style'). One thing this program
  65. Xdoes is to move plot commands down past the 'label' and 'key' commands
  66. X(which change into 'set label' and 'set key' commands). This may move
  67. Xit past other commands. If it moves past variable or function
  68. Xdefinitions, 'set' commands, or other commands which affect the plot
  69. Xcommand's execution, then the new version will be incorrect. I expect
  70. Xthis case to be rare; indeed, I generally expect the last lines in
  71. XGnuTeX input files used with LaTeX to consist of 'plot, label,' and
  72. X'key' commands.
  73. X
  74. XThe usage of this program is simple: 
  75. X
  76. X   gnut2p infile outfile
  77. X
  78. X'infile' is an existing GnuTeX file, and 'outfile' will be created as
  79. Xthe GNUPLOT equivalent. The errors, warnings, and explanatory comments
  80. Xappear on stderr. Any use of line continuation will be lost, and some
  81. Xinstances of the input style (eg, white space) may be changed.
  82. X
  83. XTo build this program, see the Makefile. It is fairly straightforward.
  84. *-*-END-of-translate/README-*-*
  85. echo x - translate/command.c
  86. sed 's/^X//' >translate/command.c <<'*-*-END-of-translate/command.c-*-*'
  87. X/*
  88. X *
  89. X *    gnutex/gnuplot translator  --  command.c
  90. X *
  91. X * By David Kotz, 1990.
  92. X * Department of Computer Science, Duke University, Durham, NC 27706.
  93. X * Mail to dfk@cs.duke.edu.
  94. X */
  95. X
  96. X#include <stdio.h>
  97. X#include <math.h>
  98. X#include "plot.h"
  99. X
  100. X#ifndef STDOUT
  101. X#define STDOUT 1
  102. X#endif
  103. X
  104. Xextern char *malloc();
  105. X
  106. X/*
  107. X * global variables to hold status of 'set' options
  108. X *
  109. X */
  110. XBOOLEAN            autoscale_x = TRUE;
  111. XBOOLEAN            autoscale_y = TRUE;
  112. XBOOLEAN            autoscale_lx = TRUE; /* local to this plot */
  113. XBOOLEAN            autoscale_ly = TRUE; /* local to this plot */
  114. Xenum PLOT_STYLE data_style    = POINTS,
  115. X                func_style    = LINES;
  116. XBOOLEAN            log_x        = FALSE,
  117. X                log_y        = FALSE;
  118. XFILE*            infile;
  119. XFILE*            outfile;
  120. Xchar            outstr[MAX_ID_LEN+1] = "STDOUT";
  121. Xint                samples        = SAMPLES;
  122. Xint                term        = 0;                /* unknown term is 0 */
  123. Xdouble            xmin        = -10,
  124. X                xmax        = 10,
  125. X                ymin        = -10,
  126. X                ymax        = 10;
  127. Xdouble            zero = ZERO;            /* zero threshold, not 0! */
  128. X
  129. XBOOLEAN xtics = TRUE;
  130. XBOOLEAN ytics = TRUE;
  131. X
  132. XBOOLEAN clipping = TRUE;
  133. X
  134. XBOOLEAN undefined;
  135. X
  136. Xchar title_string[MAX_LINE_LEN] = "";
  137. Xchar xlabel_string[MAX_LINE_LEN] = "";
  138. Xchar ylabel_string[MAX_LINE_LEN] = "";
  139. Xchar xformat[MAX_ID_LEN] = "";
  140. Xchar yformat[MAX_ID_LEN] = "";
  141. Xint y_skip_factor = 0;
  142. Xdouble plot_width = 4;        /* width  in inches, for latex */
  143. Xdouble plot_height = 3;        /* height in inches, for latex */
  144. X
  145. X/*
  146. X * instead of <strings.h>
  147. X */
  148. X
  149. Xchar *gets(),*getenv();
  150. Xchar *strcpy(),*strcat();
  151. X
  152. Xdouble magnitude(),angle(),real(),imag();
  153. Xstruct value *const_express(), *pop(), *complex();
  154. X
  155. X
  156. Xextern struct vt_entry vt[];
  157. Xextern struct st_entry st[];
  158. Xextern struct udft_entry udft[];
  159. X
  160. Xextern int inline;            /* line number of current input line */
  161. Xchar input_line[MAX_LINE_LEN],dummy_var[MAX_ID_LEN + 1];
  162. Xstruct at_type *curr_at;
  163. Xint c_token;
  164. Xint next_value = (int)NEXT_VALUE,next_function = 0,c_function = 0;
  165. Xint num_tokens;
  166. X
  167. Xstruct curve_points plot[MAX_PLOTS];
  168. Xint plot_count = 0;
  169. Xchar plot_ranges[MAX_LINE_LEN+1];
  170. XBOOLEAN pending_plot = FALSE;    /* TRUE if a plot command is pending output */
  171. Xint plot_line;                /* input line number of pending plot */
  172. XBOOLEAN key_on = TRUE;        /* will a key be displayed */
  173. XBOOLEAN plot_key = FALSE;    /* did we want a key for this plot? */
  174. XBOOLEAN label_on = FALSE;    /* will labels be displayed */
  175. XBOOLEAN arrow_on = FALSE;    /* will arrows be displayed */
  176. XBOOLEAN plot_label = FALSE;    /* do we want labels displayed? */
  177. XBOOLEAN plot_arrow = FALSE;    /* do we want arrows displayed? */
  178. XBOOLEAN plot_format = FALSE;    /* have we seen a set format? */
  179. X
  180. XBOOLEAN was_output;            /* was there any output from command? */
  181. X
  182. Xint inline = 0;            /* input line number */
  183. X
  184. Xcom_line()
  185. X{
  186. X    read_line();
  187. X
  188. X#ifdef vms
  189. X    if (input_line[0] == '!' || input_line[0] == '$')
  190. X     fprintf(outfile, "%s\n", input_line);
  191. X    else
  192. X      do_line();
  193. X#else /* vms */
  194. X    if (input_line[0] == '!')
  195. X     fprintf(outfile, "%s\n", input_line);
  196. X    else
  197. X      do_line();
  198. X#endif
  199. X
  200. X}
  201. X
  202. X/* Read a line of input; much simplified by the fact that infile is 
  203. X * never a terminal. Handles line continuation and EOF.
  204. X */
  205. Xread_line()
  206. X{
  207. X    int len, left;
  208. X    int start = 0;
  209. X    BOOLEAN more, stop;
  210. X    int last;
  211. X
  212. X    /* read one command */
  213. X    left = MAX_LINE_LEN;
  214. X    start = 0;
  215. X    more = TRUE;
  216. X    stop = FALSE;
  217. X
  218. X    while (more) {
  219. X       if (fgets(&(input_line[start]), left, infile) == NULL) {
  220. X          stop = TRUE;        /* EOF in file */
  221. X          input_line[start] = '\0';
  222. X          more = FALSE;    
  223. X       } else {
  224. X          inline++;
  225. X          len = strlen(input_line) - 1;
  226. X          if (input_line[len] == '\n') { /* remove any newline */
  227. X             input_line[len] = '\0';
  228. X             len--;
  229. X          } else if (len+1 >= left)
  230. X            int_error("Input line too long",NO_CARET);
  231. X                 
  232. X          if (input_line[len] == '\\') { /* line continuation */
  233. X             start = len;
  234. X             left -= len;
  235. X          } else
  236. X            more = FALSE;
  237. X       }
  238. X    }
  239. X
  240. X    if (stop && input_line[0] == '\0')
  241. X     done(0);
  242. X}
  243. X
  244. Xdo_line()
  245. X{
  246. X    extern int comment_pos;    /* from scanner */
  247. X    BOOLEAN nonempty;        /* TRUE if output was nonempty */
  248. X
  249. X    num_tokens = scanner(input_line);
  250. X    c_token = 0;
  251. X    nonempty = FALSE;
  252. X    while(c_token < num_tokens) {
  253. X       was_output = FALSE;
  254. X
  255. X       command();            /* parse the next command */
  256. X
  257. X       if (c_token < num_tokens) /* something after command */
  258. X        if (equals(c_token,";")) {
  259. X            c_token++;
  260. X            if (was_output)
  261. X             fprintf(outfile, "; ");
  262. X        } else
  263. X          int_error("';' expected",c_token);
  264. X       nonempty = was_output || nonempty;
  265. X    }
  266. X
  267. X    /* write out any comment */
  268. X    if (comment_pos >= 0) {
  269. X       if (nonempty)
  270. X        putc(' ', outfile);
  271. X       fputs(input_line+comment_pos, outfile);
  272. X       nonempty = TRUE;
  273. X    }
  274. X    if (nonempty || num_tokens == 0)
  275. X     putc('\n', outfile);
  276. X}
  277. X
  278. X
  279. Xcommand()
  280. X{
  281. X    int start_token = c_token;
  282. X
  283. X    if (is_definition(c_token)) {
  284. X       define();
  285. X       copy_command(start_token, c_token-1);
  286. X    }
  287. X    else if (almost_equals(c_token,"h$elp") || equals(c_token,"?")) {
  288. X       c_token++;
  289. X       while (!(END_OF_COMMAND))
  290. X        c_token++;
  291. X       err_msg("help command ignored (removed)");
  292. X    }
  293. X    else if (almost_equals(c_token,"pr$int")) {
  294. X       struct value a;
  295. X       c_token++;
  296. X       (void) const_express(&a);
  297. X       copy_command(start_token, c_token-1);
  298. X    }
  299. X    else if (almost_equals(c_token,"p$lot")) {
  300. X       if (pending_plot)
  301. X        write_plot();
  302. X       c_token++;
  303. X       plotrequest();
  304. X       pending_plot = TRUE;
  305. X       plot_line = inline;
  306. X       /* we defer output until eof or next plot command */
  307. X    }
  308. X    else if (almost_equals(c_token,"la$bel")) {
  309. X       c_token++;
  310. X       labelrequest();
  311. X    }
  312. X    else if (almost_equals(c_token,"k$ey")) {
  313. X       c_token++;
  314. X       keyrequest();
  315. X    }
  316. X    else if (almost_equals(c_token,"se$t")) {
  317. X       c_token++;
  318. X       if (almost_equals(c_token,"t$erminal")) {
  319. X          c_token++;
  320. X          if (!END_OF_COMMAND)
  321. X            c_token++;
  322. X          copy_command(start_token, c_token-1);
  323. X       }
  324. X       else if (almost_equals(c_token,"sa$mples")) {
  325. X          struct value a;
  326. X          c_token++;
  327. X          (void)magnitude(const_express(&a));
  328. X          copy_command(start_token, c_token-1);
  329. X       }
  330. X       else if (almost_equals(c_token,"o$utput")) {
  331. X          c_token++;
  332. X          if (!END_OF_COMMAND) { /* no file specified */
  333. X             if (!isstring(c_token)) 
  334. X               int_error("expecting filename",c_token);
  335. X             else
  336. X               c_token++;
  337. X          }
  338. X          copy_command(start_token, c_token-1);
  339. X       }
  340. X       else if (almost_equals(c_token,"a$utoscale")) {
  341. X          c_token++;
  342. X          if (END_OF_COMMAND) {
  343. X          } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  344. X             c_token++;
  345. X          } else if (equals(c_token, "x")) {
  346. X             c_token++;
  347. X          } else if (equals(c_token, "y")) {
  348. X             c_token++;
  349. X          } else
  350. X            int_error("expecting axes specification", c_token);
  351. X          copy_command(start_token, c_token-1);
  352. X       } 
  353. X       else if (almost_equals(c_token,"noa$utoscale")) {
  354. X          c_token++;
  355. X          if (END_OF_COMMAND) {
  356. X          } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  357. X             c_token++;
  358. X          } else if (equals(c_token, "x")) {
  359. X             c_token++;
  360. X          } else if (equals(c_token, "y")) {
  361. X             c_token++;
  362. X          } else
  363. X            int_error("expecting axes specification", c_token);
  364. X          copy_command(start_token, c_token-1);
  365. X       } 
  366. X       else if (almost_equals(c_token,"l$ogscale")) {
  367. X          c_token++;
  368. X          if (equals(c_token,"x")) {
  369. X             c_token++;
  370. X          } else if (equals(c_token,"y")) {
  371. X             c_token++;
  372. X          } else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  373. X             c_token++;
  374. X          } else
  375. X            int_error("expecting 'x', 'y', or 'xy'", c_token);
  376. X          copy_command(start_token, c_token-1);
  377. X       }
  378. X       else if (almost_equals(c_token,"nol$ogscale")) {
  379. X          copy_command(start_token, c_token++);
  380. X       }
  381. X       else if (almost_equals(c_token,"z$ero")) {
  382. X          struct value a;
  383. X          c_token++;
  384. X          (void) magnitude(const_express(&a)); 
  385. X          copy_command(start_token, c_token-1);
  386. X       }
  387. X       else if (almost_equals(c_token,"x$range")) {
  388. X          c_token++;
  389. X          if (!equals(c_token,"["))
  390. X            int_error("expecting '['",c_token);
  391. X          c_token++;
  392. X          load_range();
  393. X          if (!equals(c_token,"]"))
  394. X            int_error("expecting ']'",c_token);
  395. X          c_token++;
  396. X          copy_command(start_token, c_token-1);
  397. X       }
  398. X       else if (almost_equals(c_token,"y$range")) {
  399. X          c_token++;
  400. X          if (!equals(c_token,"["))
  401. X            int_error("expecting '['",c_token);
  402. X          c_token++;
  403. X          load_range();
  404. X          if (!equals(c_token,"]"))
  405. X            int_error("expecting ']'",c_token);
  406. X          c_token++;
  407. X          copy_command(start_token, c_token-1);
  408. X       }
  409. X       else if (almost_equals(c_token,"d$ata")) {
  410. X          c_token++;
  411. X          if (!almost_equals(c_token,"s$tyle")) 
  412. X            int_error("expecting keyword 'style'",c_token);
  413. X          c_token++;
  414. X          if (END_OF_COMMAND)
  415. X            int_error("expecting style name", c_token);
  416. X          c_token++;
  417. X          copy_command(start_token, c_token-1);
  418. X       }
  419. X       else if (almost_equals(c_token,"f$unction")) {
  420. X          c_token++;
  421. X          if (!almost_equals(c_token,"s$tyle")) 
  422. X            int_error("expecting keyword 'style'",c_token);
  423. X          c_token++;
  424. X          if (END_OF_COMMAND)
  425. X            int_error("expecting style name", c_token);
  426. X          c_token++;
  427. X          copy_command(start_token, c_token-1);
  428. X       }
  429. X       else if (almost_equals(c_token,"st$yle")) {
  430. X          c_token++;
  431. X          add_style();
  432. X          err_msg("'set style' command obsolete (removed)");
  433. X       }
  434. X       else if (almost_equals(c_token,"xl$abel")) {
  435. X          c_token++;
  436. X          if (!isstring(c_token)) 
  437. X            int_error("expecting x label string",c_token);
  438. X          c_token++;
  439. X          copy_command(start_token, c_token-1);
  440. X       }
  441. X       else if (almost_equals(c_token,"xt$ics")) {
  442. X          copy_command(start_token, c_token++);
  443. X       } 
  444. X       else if (almost_equals(c_token,"noxt$ics")) {
  445. X          copy_command(start_token, c_token++);
  446. X       } 
  447. X       else if (almost_equals(c_token,"yl$abel")) {
  448. X          c_token++;
  449. X          if (!isstring(c_token)) {
  450. X             int_error("expecting y label string",c_token);
  451. X          } else {
  452. X             c_token++;
  453. X             if (!END_OF_COMMAND) { /* skip factor specified */
  454. X                err_msg("ignoring skip factor on ylabel");
  455. X                copy_command(start_token, c_token-1);
  456. X                c_token++;
  457. X             } else
  458. X               copy_command(start_token, c_token-1);
  459. X          }
  460. X       }
  461. X       else if (almost_equals(c_token,"yt$ics")) {
  462. X          copy_command(start_token, c_token++);
  463. X       } 
  464. X       else if (almost_equals(c_token,"noyt$ics")) {
  465. X          copy_command(start_token, c_token++);
  466. X       } 
  467. X       else if (almost_equals(c_token,"fo$rmat")) {
  468. X          c_token++;
  469. X          if (equals(c_token,"x")) {
  470. X             c_token++;
  471. X          } else if (equals(c_token,"y")) {
  472. X             c_token++;
  473. X          } else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  474. X             c_token++;
  475. X          } else if (isstring(c_token)) {
  476. X          } else
  477. X            int_error("expecting 'x', 'y', or 'xy'",c_token);
  478. X          if (!isstring(c_token))
  479. X            int_error("expecting format string",c_token);
  480. X          c_token++;
  481. X          copy_command(start_token, c_token-1);
  482. X          plot_format = TRUE;
  483. X       }
  484. X       else if (almost_equals(c_token,"ti$tle")) {
  485. X          c_token++;
  486. X          if (!isstring(c_token)) 
  487. X            int_error("expecting title string",c_token);
  488. X          c_token++;
  489. X          copy_command(start_token, c_token-1);
  490. X       }
  491. X       else if (almost_equals(c_token,"si$ze")) {
  492. X          struct value a;
  493. X          c_token++;
  494. X          plot_width = magnitude(const_express(&a));
  495. X          if (!equals(c_token, ","))
  496. X            int_error("expecting comma between width and height", c_token);
  497. X          c_token++;        /* comma */
  498. X          plot_height = magnitude(const_express(&a));
  499. X          err_msg("'set size' command translated");
  500. X          fprintf(outfile, "set size %.3g, %.3g", 
  501. X                (plot_width + 1.096)/5., /* adjust for margins too */
  502. X                (plot_height + 0.616)/3.);
  503. X          was_output = TRUE;
  504. X       }
  505. X       else if (almost_equals(c_token,"cl$ip")) {
  506. X          c_token++;
  507. X          fprintf(outfile, "set clip points");
  508. X          was_output = TRUE;
  509. X       } 
  510. X       else if (almost_equals(c_token,"nocl$ip")) {
  511. X          c_token++;
  512. X          fprintf(outfile, "set noclip points");
  513. X          was_output = TRUE;
  514. X       } 
  515. X       else
  516. X        int_error("unknown set option (try 'help set')",c_token);
  517. X    }
  518. X    else if (almost_equals(c_token,"sh$ow")) {
  519. X       if (almost_equals(++c_token,"f$unctions")) {
  520. X          c_token++;
  521. X          if (almost_equals(c_token,"s$tyle")) 
  522. X            c_token++;
  523. X          copy_command(start_token, c_token-1);
  524. X       }
  525. X       else if (almost_equals(c_token,"v$ariables")) {
  526. X          copy_command(start_token, c_token++);
  527. X       }
  528. X       else if (almost_equals(c_token,"ac$tion_table") ||
  529. X              equals(c_token,"at") ) {
  530. X          c_token++;
  531. X          show_at();
  532. X          copy_command(start_token, c_token-1);
  533. X       } 
  534. X       else if (almost_equals(c_token,"d$ata")) {
  535. X          c_token++;
  536. X          if (!almost_equals(c_token,"s$tyle")) 
  537. X            int_error("expecting keyword 'style'",c_token);
  538. X          c_token++;
  539. X          copy_command(start_token, c_token-1);
  540. X       }
  541. X       else if (almost_equals(c_token,"x$range")) {
  542. X          copy_command(start_token, c_token++);
  543. X       } 
  544. X       else if (almost_equals(c_token,"y$range")) {
  545. X          copy_command(start_token, c_token++);
  546. X       } 
  547. X       else if (almost_equals(c_token,"z$ero")) {
  548. X          copy_command(start_token, c_token++);
  549. X       }
  550. X       else if (almost_equals(c_token,"sa$mples")) {
  551. X          copy_command(start_token, c_token++);
  552. X       }
  553. X       else if (almost_equals(c_token,"o$utput")) {
  554. X          copy_command(start_token, c_token++);
  555. X       }
  556. X       else if (almost_equals(c_token,"t$erminal")) {
  557. X          copy_command(start_token, c_token++);
  558. X       }
  559. X       else if (almost_equals(c_token,"au$toscale")) {
  560. X          copy_command(start_token, c_token++);
  561. X       }
  562. X       else if (almost_equals(c_token,"ve$rsion")) {
  563. X          copy_command(start_token, c_token++);
  564. X       } 
  565. X       else if (almost_equals(c_token,"l$ogscale")) {
  566. X          copy_command(start_token, c_token++);
  567. X       }
  568. X       else if (almost_equals(c_token,"cl$ipping")) {
  569. X          copy_command(start_token, c_token++);
  570. X       }
  571. X       else if (almost_equals(c_token,"xl$abel")) {
  572. X          copy_command(start_token, c_token++);
  573. X       }
  574. X       else if (almost_equals(c_token,"yl$abel")) {
  575. X          copy_command(start_token, c_token++);
  576. X       }
  577. X       else if (almost_equals(c_token,"fo$rmat")) {
  578. X          copy_command(start_token, c_token++);
  579. X       }
  580. X       else if (almost_equals(c_token,"ti$tle")) {
  581. X          copy_command(start_token, c_token++);
  582. X       }
  583. X       else if (almost_equals(c_token,"si$ze")) {
  584. X          copy_command(start_token, c_token++);
  585. X       }
  586. X       else if (almost_equals(c_token,"st$yle")) {
  587. X          c_token++;
  588. X          add_style();
  589. X          err_msg("'show style' command ignored (removed)");
  590. X       }
  591. X       else if (almost_equals(c_token,"a$ll")) {
  592. X          copy_command(start_token, c_token++);
  593. X       }
  594. X       else
  595. X        int_error("unknown show option (try 'help show')",c_token);
  596. X    }
  597. X    else if (almost_equals(c_token,"cl$ear")) {
  598. X       copy_command(start_token, c_token++);
  599. X    }
  600. X    else if (almost_equals(c_token,"she$ll")) {
  601. X       copy_command(start_token, c_token++);
  602. X    }
  603. X    else if (almost_equals(c_token,"sa$ve")) {
  604. X       c_token++;
  605. X       if (almost_equals(c_token,"f$unctions")
  606. X          || almost_equals(c_token,"v$ariables")) {
  607. X          c_token++;
  608. X          if (!isstring(c_token))
  609. X            int_error("expecting filename",c_token);
  610. X       } else if (!isstring(c_token)) {
  611. X          int_error("filename or keyword 'functions' or 'variables' expected",c_token);
  612. X       }
  613. X       c_token++;
  614. X       copy_command(start_token, c_token-1);
  615. X    }
  616. X    else if (almost_equals(c_token,"lo$ad")) {
  617. X       if (!isstring(++c_token))
  618. X        int_error("expecting filename",c_token);
  619. X       c_token++;
  620. X       copy_command(start_token, c_token-1);
  621. X    }
  622. X    else if (almost_equals(c_token,"ex$it") ||
  623. X           almost_equals(c_token,"q$uit")) {
  624. X       copy_command(start_token, c_token++);
  625. X       /* done(IO_SUCCESS); */
  626. X    }
  627. X    else if (equals(c_token,";")) { /* null statement */
  628. X       copy_command(start_token, c_token++);
  629. X    } else {
  630. X       int_error("invalid command",c_token);
  631. X    }
  632. X}
  633. X
  634. Xload_range()
  635. X{
  636. Xstruct value t;
  637. Xdouble a,b;
  638. X
  639. X    if (equals(c_token,"]"))
  640. X        return;
  641. X    if (END_OF_COMMAND) {
  642. X        int_error("starting range value or 'to' expected",c_token);
  643. X    } else if (!equals(c_token,"to") && !equals(c_token,":"))  {
  644. X        a = real(const_express(&t));
  645. X    }    
  646. X    if (!equals(c_token,"to") && !equals(c_token,":")) 
  647. X        int_error("Keyword 'to' or ':' expected",c_token);
  648. X    c_token++; 
  649. X    if (!equals(c_token,"]"))
  650. X        b = real(const_express(&t));
  651. X}
  652. X
  653. X
  654. Xplotrequest()
  655. X{
  656. X    int start_token = c_token;
  657. X
  658. X    if (equals(c_token,"[")) {
  659. X       c_token++;
  660. X       if (isletter(c_token)) {
  661. X          c_token++;
  662. X          if (equals(c_token,"="))
  663. X            c_token++;
  664. X          else
  665. X            int_error("'=' expected",c_token);
  666. X       }
  667. X       load_range();
  668. X       if (!equals(c_token,"]"))
  669. X        int_error("']' expected",c_token);
  670. X       c_token++;
  671. X    }
  672. X
  673. X    if (equals(c_token,"[")) { /* set optional y ranges */
  674. X       c_token++;
  675. X       load_range();
  676. X       if (!equals(c_token,"]"))
  677. X        int_error("']' expected",c_token);
  678. X       c_token++;
  679. X    }
  680. X
  681. X    capture(plot_ranges, start_token, c_token-1);
  682. X
  683. X    eval_plots();
  684. X}
  685. X
  686. X/* Parse the definition of a style and add to table */
  687. Xadd_style()
  688. X{
  689. X    register int i;
  690. X    int style = -1;                /* the new style number */
  691. X    struct value a;
  692. X    register struct st_entry *stp;    /* quick access to new entry */
  693. X    int null_definition = TRUE; /* watch out for missing definitions */
  694. X
  695. X    /* check if it's already in the table... */
  696. X
  697. X    style = -1;
  698. X    for (i = 0; i < next_value; i++) {
  699. X        if (equals(c_token,st[i].st_name))
  700. X            style = i;
  701. X    }
  702. X    /* Not found - assign a new one */
  703. X    if (style < 0)
  704. X     style = next_style;
  705. X    /* Found - redefine it */
  706. X    if (style <= FIXED_STYLES)
  707. X     int_error("cannot redefine this style", c_token);
  708. X    if (style == MAX_STYLES)
  709. X     int_error("user defined style space full",NO_CARET);
  710. X    else
  711. X     next_style++;
  712. X
  713. X    stp = &st[style];
  714. X
  715. X    /* Copy in the name of the style */
  716. X    copy_str(stp->st_name,c_token);
  717. X    stp->st_undef = TRUE;
  718. X    c_token++;
  719. X
  720. X    /* Point type */
  721. X    if(!isstring(c_token)) {
  722. X       *stp->st_point = '\0'; /* null point definition */
  723. X    } else {
  724. X       quote_str(stp->st_point, c_token);
  725. X       c_token++;
  726. X       null_definition = FALSE;
  727. X    }
  728. X
  729. X     /* Spacing */
  730. X    if(END_OF_COMMAND) {
  731. X       stp->st_spacing = 0;
  732. X       stp->st_length = 0;
  733. X    } else {
  734. X       /* read dot spacing */
  735. X       if (!isnumber(c_token)) {
  736. X          next_value--;
  737. X          int_error("expecting spacing (in points) for style", c_token);
  738. X       }
  739. X       convert(&a, c_token);
  740. X       stp->st_spacing = magnitude(&a);
  741. X       if (stp->st_spacing < 0.1) {
  742. X          next_value--;
  743. X          int_error("unreasonable spacing value", c_token);
  744. X       }
  745. X       c_token++;
  746. X
  747. X       /* build dot sequence */
  748. X       stp->st_length = 0;
  749. X       
  750. X       while(!(END_OF_COMMAND)) {
  751. X          if (!isstring(c_token))
  752. X            int_error("expecting a string defining a sequence style", c_token);
  753. X          quote_str(stp->st_seq[stp->st_length++], c_token);
  754. X          c_token++;
  755. X          if (stp->st_length >= MAX_STYLE_SEQ_LENGTH)
  756. X            int_error("style sequence too long", c_token);
  757. X       }
  758. X       null_definition = FALSE;
  759. X
  760. X       if (stp->st_length == 0)
  761. X        int_error("expecting dot sequence", c_token);
  762. X    }
  763. X
  764. X    if (null_definition)
  765. X     int_error("expecting definition of style", c_token);
  766. X
  767. X    c_token++;
  768. X}
  769. X
  770. X
  771. Xlabelrequest()
  772. X{
  773. X    struct value a;
  774. X    double x,y;            /* the point */
  775. X    char pos[MAX_ID_LEN+1];    /* optional argument */
  776. X    char text[MAX_ID_LEN+1];    /* text of the label */
  777. X    double length = 0;        /* length of arrow */
  778. X    int dx = 0, dy = 0;        /* slope of arrow */
  779. X
  780. X    /* x coordinate */
  781. X    const_express(&a);
  782. X    x = real(&a);
  783. X    if (log_x)        /* handle coords on logscale plot. PEM 01/17/89 */
  784. X    x = log10(x);
  785. X
  786. X    if (!equals(c_token, ","))
  787. X     int_error("comma expected", c_token);
  788. X    c_token++;
  789. X
  790. X    /* y coordinate */
  791. X    const_express(&a);
  792. X    y = real(&a);
  793. X    if (log_y)        /* handle coords on logscale plot. PEM 01/17/89 */
  794. X    y = log10(y);
  795. X
  796. X    /* text */
  797. X    if (isstring(c_token))
  798. X     quote_str(text, c_token++);
  799. X    else
  800. X     int_error("expecting text of the label", c_token);
  801. X
  802. X    /* optional pos */
  803. X    pos[0] = '\0';
  804. X    if (!(END_OF_COMMAND)) {
  805. X       copy_str(pos, c_token++);
  806. X       
  807. X       /* optional length for optional arrow  */
  808. X       if (!(END_OF_COMMAND)) {
  809. X          const_express(&a);
  810. X          length = real(&a);
  811. X
  812. X          if (!(END_OF_COMMAND)) {
  813. X             if (!equals(c_token, ","))
  814. X               int_error("comma expected", c_token);
  815. X             c_token++;
  816. X          
  817. X             const_express(&a);
  818. X             dx = (int) real(&a);
  819. X
  820. X             if (!equals(c_token, ","))
  821. X               int_error("comma expected", c_token);
  822. X             c_token++;
  823. X
  824. X             const_express(&a);
  825. X             dy = (int) real(&a);
  826. X          }
  827. X       }
  828. X    }
  829. X
  830. X    save_label(x,y, text, pos, length, dx, dy);
  831. X}
  832. X
  833. X/* translate the label  */
  834. Xsave_label(x,y, text, pos, length, dx, dy)
  835. X    double x,y;            /* the point */
  836. X    char text[MAX_ID_LEN+1];    /* text of the label */
  837. X    char pos[MAX_ID_LEN+1];    /* optional argument */
  838. X    double length;            /* length of arrow */
  839. X    int dx, dy;            /* slope of arrow */
  840. X{
  841. X    char *where = NULL;
  842. X    BOOLEAN adjust = FALSE;
  843. X    double ex, ey;
  844. X
  845. X    if (instring(pos, 'l'))
  846. X     where = "left";
  847. X    else if (instring(pos, 'r'))
  848. X     where = "right";
  849. X    else
  850. X     where = "center";
  851. X
  852. X    if (instring(pos, 't') || instring(pos, 'b'))
  853. X     adjust = TRUE;
  854. X
  855. X    fprintf(outfile, "set label \"%s\" at %g,%g %s\n", text, x, y, where);
  856. X
  857. X    if (length != 0) {
  858. X       /* arrow option. Compute destination */
  859. X       if (dx == 0 && dy == 0) {
  860. X          if (instring(pos, 'l'))
  861. X            dx = -1;
  862. X          else if (instring(pos, 'r')) 
  863. X            dx = 1;
  864. X          else
  865. X            dx = 0;
  866. X          if (instring(pos, 't'))
  867. X            dy = 1;
  868. X          else if (instring(pos, 'b')) 
  869. X            dy = -1;
  870. X          else
  871. X            dy = 0;
  872. X       }
  873. X       ex = x + (dx ? length : 0);
  874. X       ey = y + (dx ? ((float)dy/dx * length) : length);
  875. X
  876. X       fprintf(outfile, "set arrow from %g,%g to %g,%g\n", x, y, ex, ey);
  877. X       arrow_on = TRUE;
  878. X       plot_arrow = TRUE;
  879. X    }
  880. X
  881. X    label_on = TRUE;
  882. X    plot_label = TRUE;
  883. X    was_output = TRUE;
  884. X}
  885. X
  886. Xkeyrequest()
  887. X{
  888. X    struct value a;
  889. X    double x,y;            /* the point */
  890. X    int styles[MAX_KEYS+1];    /* the style for each plot */
  891. X    char *text[MAX_KEYS+1];    /* text of each key entry */
  892. X    int style;
  893. X    int curve = 0;            /* index of the entry */
  894. X
  895. X    /* x coordinate */
  896. X    const_express(&a);
  897. X    x = real(&a);
  898. X
  899. X    if (!equals(c_token, ","))
  900. X     int_error("comma expected", c_token);
  901. X    c_token++;
  902. X
  903. X    /* y coordinate */
  904. X    const_express(&a);
  905. X    y = real(&a);
  906. X
  907. X    do {                    /* scan the entries in the key */
  908. X       /* text */
  909. X       if (isstring(c_token)) {
  910. X          text[curve] = (char *) malloc(MAX_ID_LEN);
  911. X          quote_str(text[curve], c_token++);
  912. X       } else
  913. X        int_error("expecting text of the key entry", c_token);
  914. X       
  915. X       if (almost_equals(c_token, "w$ith"))
  916. X        c_token++;
  917. X       else
  918. X        int_error("expecting 'with' style for key entry", c_token);
  919. X
  920. X       for (style = 0; style < next_style; style++)
  921. X        if (equals(c_token, st[style].st_name))
  922. X          break;
  923. X       if (style == next_style)
  924. X        int_error("unknown plot style; type 'show style'", 
  925. X                c_token);
  926. X       else
  927. X        styles[curve] = style;
  928. X       c_token++;
  929. X
  930. X       if (!END_OF_COMMAND)
  931. X        if (!equals(c_token, ","))
  932. X          int_error("expecting ',' between key entries", c_token);
  933. X        else
  934. X          c_token++;
  935. X
  936. X       curve++;
  937. X       if (curve > MAX_KEYS)
  938. X        int_error("too many lines in the key", c_token);
  939. X    } while (!END_OF_COMMAND);
  940. X
  941. X    text[curve] = NULL;        /* acts as terminator */
  942. X
  943. X    save_key (x,y, styles, text);
  944. X
  945. X    for (curve--; curve >= 0; curve--)
  946. X     free(text[curve]);
  947. X}
  948. X
  949. Xsave_key (x,y, styles, text)
  950. X    double x,y;            /* the position of the key */
  951. X    int styles[MAX_KEYS+1];    /* the style for each plot */
  952. X    char *text[MAX_KEYS+1];    /* text of each key entry */
  953. X{
  954. X    int curve;                /* index of the entry */
  955. X
  956. X    for (curve = 0; text[curve] != NULL; curve++) {
  957. X       strcpy(plot[curve].title, text[curve]);
  958. X    }
  959. X    fprintf(outfile, "set key %g,%g", x,y);
  960. X    was_output = TRUE;
  961. X    key_on = TRUE;
  962. X    plot_key = TRUE;
  963. X
  964. X    err_msg("'key' command translated; position needs adjusting");
  965. X}
  966. X
  967. Xdefine()
  968. X{
  969. Xregister int value,start_token;  /* start_token is the 1st token in the    */
  970. X                                /* function definition.            */
  971. X
  972. X    if (equals(c_token+1,"(")) {
  973. X        /* function ! */
  974. X        start_token = c_token;
  975. X        copy_str(dummy_var, c_token + 2);
  976. X        c_token += 5; /* skip (, dummy, ) and = */
  977. X        value = c_function = user_defined(start_token);
  978. X        build_at(&(udft[value].at));
  979. X                /* define User Defined Function (parse.c)*/
  980. X        capture(udft[value].definition,start_token,c_token-1);
  981. X    }
  982. X    else {
  983. X        /* variable ! */
  984. X        c_token +=2;
  985. X        (void) const_express(&vt[value = add_value(c_token - 2) ].vt_value);
  986. X        vt[value].vt_undef = FALSE;
  987. X    }
  988. X}
  989. X
  990. X/* This parses the plot command after any range specifications. 
  991. X * We revert to one-pass parsing here. That's all we need.
  992. X */
  993. Xeval_plots()
  994. X{
  995. Xregister int plot_num, start_token;
  996. Xstruct value a;
  997. Xint style;
  998. X
  999. X    c_function = MAX_UDFS;        /* last udft[] entry used for plots */
  1000. X
  1001. X    plot_num = 0;
  1002. X
  1003. X    while (TRUE) {
  1004. X        if (END_OF_COMMAND)
  1005. X            int_error("function to plot expected",c_token);
  1006. X        if (plot_num == MAX_PLOTS)
  1007. X            int_error("maximum number of plots exceeded",NO_CARET);
  1008. X
  1009. X        start_token = c_token;
  1010. X
  1011. X        if (is_definition(c_token)) {
  1012. X            define();
  1013. X        } else {
  1014. X            if (isstring(c_token)) {            /* data file to plot */
  1015. X                plot[plot_num].plot_type = DATA;
  1016. X                style = (int)data_style;
  1017. X                c_token++; /* skip file name */
  1018. X            } 
  1019. X            else {                            /* function to plot */
  1020. X                plot[plot_num].plot_type = FUNC;
  1021. X                style = (int)func_style;
  1022. X                build_at(&udft[MAX_UDFS].at);
  1023. X                /* that's all */
  1024. X            }
  1025. X            capture(plot[plot_num].def,start_token,c_token-1);
  1026. X            plot[plot_num].title[0] = '\0';
  1027. X
  1028. X            if (almost_equals(c_token,"w$ith")) {
  1029. X                c_token++;
  1030. X                for (style = 0; style < next_style; style++)
  1031. X                  if (equals(c_token, st[style].st_name))
  1032. X                    break;
  1033. X                if (style == next_style)
  1034. X                  int_error("unknown plot style; type 'show style'", 
  1035. X                          c_token);
  1036. X                else
  1037. X                  c_token++;
  1038. X            }
  1039. X            plot[plot_num].plot_style = equiv_style(style);
  1040. X            plot_num++;
  1041. X        }
  1042. X
  1043. X        if (equals(c_token,",")) 
  1044. X            c_token++;
  1045. X        else  
  1046. X            break;
  1047. X    }
  1048. X
  1049. X    plot_count = plot_num;
  1050. X}
  1051. X
  1052. X/* return a standard style close to the given style */
  1053. Xint
  1054. Xequiv_style(style)
  1055. X    int style;            /* may be a user-def style */
  1056. X{
  1057. X    BOOLEAN line, point;
  1058. X    char message[MAX_LINE_LEN+1];
  1059. X
  1060. X    if (style <= FIXED_STYLES)
  1061. X     return(style);
  1062. X
  1063. X    point = (st[style].st_point[0] != '\0');
  1064. X    line = (st[style].st_length > 0);
  1065. X
  1066. X    sprintf(message,
  1067. X          "user-defined style %s replaced by similar standard style",
  1068. X          st[style].st_name);
  1069. X    err_msg(message);
  1070. X
  1071. X    if (point && line)
  1072. X     return(LINESPOINTS);
  1073. X    if (point)
  1074. X     return(POINTS);
  1075. X    if (line)
  1076. X     return(LINES);
  1077. X
  1078. X    /* should not happen */
  1079. X    err_msg("no standard style corresponds to this style");
  1080. X    return(LINES);
  1081. X}
  1082. X
  1083. X
  1084. X/* write out the plot command now that we know titles */
  1085. Xwrite_plot()
  1086. X{
  1087. X    int plot_num;
  1088. X
  1089. X    if (!plot_key && key_on) {
  1090. X       fprintf(outfile, "set nokey\n");
  1091. X       key_on = FALSE;
  1092. X    }
  1093. X
  1094. X    if (!plot_label && label_on) {
  1095. X       fprintf(outfile, "set nolabel\n");
  1096. X       label_on = FALSE;
  1097. X    }
  1098. X
  1099. X    if (!plot_arrow && arrow_on) {
  1100. X       fprintf(outfile, "set noarrow\n");
  1101. X       arrow_on = FALSE;
  1102. X    }
  1103. X
  1104. X    if (!plot_format) {
  1105. X       fprintf(outfile, "set format xy \"$%%g$\"\n");
  1106. X       plot_format = TRUE;
  1107. X    }
  1108. X
  1109. X    fprintf(outfile, "plot %s ", plot_ranges);
  1110. X
  1111. X    for (plot_num = 0; plot_num < plot_count; plot_num++) {
  1112. X       if (plot_num > 0)
  1113. X        fputs(", ", outfile);
  1114. X       fprintf(outfile, "%s", plot[plot_num].def);
  1115. X       if (plot[plot_num].title[0] != '\0')
  1116. X        fprintf(outfile, " title \"%s\"", plot[plot_num].title);
  1117. X
  1118. X       fprintf(outfile, " with %s", st[plot[plot_num].plot_style].st_name);
  1119. X    }
  1120. X
  1121. X    fprintf(outfile, "\n");
  1122. X    /* we don't set was_output since we have the newline already */
  1123. X
  1124. X    fprintf(stderr, 
  1125. X          "\n***%d: plot command moved, watch out for use of variables\n", 
  1126. X          plot_line);
  1127. X
  1128. X    pending_plot = FALSE;
  1129. X    plot_key = FALSE;
  1130. X    plot_label = FALSE;
  1131. X    plot_arrow = FALSE;
  1132. X}
  1133. X
  1134. X/* copy a command from input to output */
  1135. Xcopy_command(start, end)
  1136. X    int start, end;        /* inclusive token numbers */
  1137. X{
  1138. X    char command_line[MAX_LINE_LEN+1];
  1139. X
  1140. X    capture(command_line, start, end);
  1141. X    fputs(command_line, outfile);
  1142. X    was_output = TRUE;
  1143. X}
  1144. X
  1145. Xdone(status)
  1146. Xint status;
  1147. X{
  1148. X    if (pending_plot)
  1149. X     write_plot();
  1150. X
  1151. X    exit(status);
  1152. X}
  1153. *-*-END-of-translate/command.c-*-*
  1154. echo x - translate/eval.c
  1155. sed 's/^X//' >translate/eval.c <<'*-*-END-of-translate/eval.c-*-*'
  1156. X/*
  1157. X *
  1158. X *    G N U P L O T  --  eval.c
  1159. X *
  1160. X *  Copyright (C) 1986 Colin Kelley, Thomas Williams
  1161. X *
  1162. X *  You may use this code as you wish if credit is given and this message
  1163. X *  is retained.
  1164. X *
  1165. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  1166. X *  included in later releases.
  1167. X *
  1168. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  1169. X */
  1170. X
  1171. X#include <stdio.h>
  1172. X#include "plot.h"
  1173. X
  1174. Xextern int c_token,next_value,next_function;
  1175. Xextern struct udft_entry udft[];
  1176. Xextern struct ft_entry ft[];
  1177. Xextern struct vt_entry vt[];
  1178. Xextern struct at_type *curr_at;
  1179. Xextern struct lexical_unit token[];
  1180. X
  1181. Xstruct value *integer();
  1182. X
  1183. X
  1184. X
  1185. Xint add_value(t_num)
  1186. Xint t_num;
  1187. X{
  1188. Xregister int i;
  1189. X
  1190. X    /* check if it's already in the table... */
  1191. X
  1192. X    for (i = 0; i < next_value; i++) {
  1193. X        if (equals(t_num,vt[i].vt_name))
  1194. X            return(i);
  1195. X    }
  1196. X    if (next_value == MAX_VALUES)
  1197. X        int_error("user defined constant space full",NO_CARET);
  1198. X    copy_str(vt[next_value].vt_name,t_num);
  1199. X    vt[next_value].vt_value.type = INT;        /* not necessary, but safe! */
  1200. X    vt[next_value].vt_undef = TRUE;
  1201. X    return(next_value++);
  1202. X}
  1203. X
  1204. X
  1205. Xadd_action(sf_index,arg)
  1206. Xenum operators sf_index;
  1207. Xstruct value *arg;
  1208. X
  1209. X /* argument to pass to standard function indexed by sf_index */
  1210. X{
  1211. X
  1212. X    if ( curr_at->count >= MAX_AT_LEN ) 
  1213. X        int_error("action table overflow",NO_CARET);
  1214. X    curr_at->actions[curr_at->count].index = ((int)sf_index);
  1215. X    if (arg != (struct value *)0)
  1216. X        curr_at->actions[curr_at->count].arg = *arg;
  1217. X    curr_at->count++;
  1218. X}
  1219. X
  1220. X
  1221. Xint standard(t_num)  /* return standard function index or 0 */
  1222. X{
  1223. Xregister int i;
  1224. X    for (i = (int)SF_START; ft[i].ft_name != NULL; i++) {
  1225. X        if (equals(t_num,ft[i].ft_name))
  1226. X            return(i);
  1227. X    }
  1228. X    return(0);
  1229. X}
  1230. X
  1231. X
  1232. X
  1233. Xint user_defined(t_num)  /* find or add function and return index */
  1234. Xint t_num; /* index to token[] */
  1235. X{
  1236. Xregister int i;
  1237. X    for (i = 0; i < next_function; i++) {
  1238. X        if (equals(t_num,udft[i].udft_name))
  1239. X            return(i);
  1240. X    }
  1241. X    if (next_function == MAX_UDFS)
  1242. X        int_error("user defined function space full",t_num);
  1243. X    copy_str(udft[next_function].udft_name,t_num);
  1244. X    udft[next_function].definition[0] = '\0';
  1245. X    udft[next_function].at.count = 0;
  1246. X    (void) integer(&udft[next_function].dummy_value, 0);
  1247. X    return(next_function++);
  1248. X}
  1249. X
  1250. X
  1251. Xexecute_at(at_ptr)
  1252. Xstruct at_type *at_ptr;
  1253. X{
  1254. Xregister int i;
  1255. X    for (i = 0; i < at_ptr->count; i++) {
  1256. X        (*ft[at_ptr->actions[i].index].funct)(&(at_ptr->actions[i].arg));
  1257. X    }
  1258. X}
  1259. X
  1260. X/*
  1261. X
  1262. X 'ft' is a table containing C functions within this program. 
  1263. X
  1264. X An 'action_table' contains pointers to these functions and arguments to be
  1265. X passed to them. 
  1266. X
  1267. X at_ptr is a pointer to the action table which must be executed (evaluated)
  1268. X
  1269. X so the iterated line exectues the function indexed by the at_ptr and 
  1270. X passes the argument which is pointed to by the arg_ptr 
  1271. X
  1272. X*/
  1273. *-*-END-of-translate/eval.c-*-*
  1274. echo x - translate/gnut2p.1
  1275. sed 's/^X//' >translate/gnut2p.1 <<'*-*-END-of-translate/gnut2p.1-*-*'
  1276. X.TH GNUT2P 1
  1277. X.SH NAME
  1278. Xgnut2p \- translate GnuTeX input file to GNUPLOT input file
  1279. X.SH SYNOPSIS
  1280. X.B gnut2P
  1281. Xinfile outfile
  1282. X.SH DESCRIPTION
  1283. X.I gnut2p 
  1284. Xconverts an input file for the old gnutex(1) plotting program into an
  1285. Xinput file suitable for its successor, gnuplot(1) version 2.0.  This
  1286. Xprogram does its best, but is not perfect. Most of gnutex will
  1287. Xtranslate directly, some things will translated easily (such as \fBset
  1288. Xsize\fR), but some things cannot be translated (such as \fBset
  1289. Xstyle\fR). One thing this program does is to move plot commands down
  1290. Xpast the \fBlabel\fR and \fBkey\fR commands (which change into \fBset
  1291. Xlabel\fR and \fBset key\fR commands). This may move it past other
  1292. Xcommands.  If it moves past variable or function definitions,
  1293. X\fBset\fR commands, or other commands which affect the plot command's
  1294. Xexecution, then the new version will be incorrect. I expect this case
  1295. Xto be rare; indeed, I generally expect the last lines in GnuTeX input
  1296. Xfiles used with LaTeX to consist of \fBplot\fR, \fBlabel\fR, and
  1297. X\fBkey\fR commands.
  1298. X.PP 
  1299. XThe usage of this program is simple. 
  1300. X.I infile
  1301. Xis an existing GnuTeX file, and 
  1302. X.I outfile
  1303. Xwill be created as the GNUPLOT equivalent. The errors, warnings, and
  1304. Xexplanatory comments appear on stderr. Any use of line continuation
  1305. Xwill be lost, and some instances of the input style (eg, white space)
  1306. Xmay be changed.
  1307. X
  1308. X.SH SEE ALSO
  1309. Xgnuplot(1), gnutex(1)
  1310. X.br
  1311. XThe "GNUPLOT" 2.0 Manual
  1312. X.br
  1313. XThe "GnuTeX" 1.6 Manual and Tutorial
  1314. X.br
  1315. X"LaTeX and the GNUPLOT Plotting Program" (notes for former GnuTeX users).
  1316. X
  1317. X.SH AUTHOR
  1318. XDavid Kotz dfk@cs.duke.edu
  1319. *-*-END-of-translate/gnut2p.1-*-*
  1320. echo x - translate/internal.c
  1321. sed 's/^X//' >translate/internal.c <<'*-*-END-of-translate/internal.c-*-*'
  1322. X/*
  1323. X *
  1324. X *    G N U P L O T  --  internal.c
  1325. X *
  1326. X *  Copyright (C) 1986 Colin Kelley, Thomas Williams
  1327. X *
  1328. X *  You may use this code as you wish if credit is given and this message
  1329. X *  is retained.
  1330. X *
  1331. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  1332. X *  included in later releases.
  1333. X *
  1334. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  1335. X */
  1336. X
  1337. X#include <math.h>
  1338. X#include <stdio.h>
  1339. X#include "plot.h"
  1340. X
  1341. Xextern BOOLEAN undefined;
  1342. Xextern struct vt_entry vt[MAX_VALUES];
  1343. Xextern struct udft_entry udft[MAX_UDFS];
  1344. X
  1345. Xchar *strcpy();
  1346. X
  1347. Xstruct value *pop(), *complex(), *integer();
  1348. Xdouble magnitude(), angle(), real();
  1349. X
  1350. Xstruct value stack[STACK_DEPTH];
  1351. X
  1352. Xint s_p = -1;   /* stack pointer */
  1353. X
  1354. X#ifndef MSDOS /* suggested by "J.D. McDonald " <mcdonald@uxe.cso.uiuc.edu> */
  1355. X/*
  1356. X * System V and MSC 4.0 call this when they wants to print an error message.
  1357. X * Don't!
  1358. X */
  1359. Xmatherr()
  1360. X{
  1361. X    return (undefined = TRUE);        /* don't print error message */
  1362. X}
  1363. X#endif MSDOS
  1364. X
  1365. Xreset_stack()
  1366. X{
  1367. X    s_p = -1;
  1368. X}
  1369. X
  1370. X
  1371. Xcheck_stack()    /* make sure stack's empty */
  1372. X{
  1373. X    if (s_p != -1)
  1374. X        fprintf(stderr,"\nwarning:  internal error--stack not empty!\n");
  1375. X}
  1376. X
  1377. X
  1378. Xstruct value *pop(x)
  1379. Xstruct value *x;
  1380. X{
  1381. X    if (s_p  < 0 )
  1382. X        int_error("stack underflow",NO_CARET);
  1383. X    *x = stack[s_p--];
  1384. X    return(x);
  1385. X}
  1386. X
  1387. X#define ERR_VAR "undefined variable: "
  1388. X
  1389. Xf_push(x)
  1390. Xstruct value *x;        /* contains index of value to push; must be integer! */
  1391. X{
  1392. Xstatic char err_str[sizeof(ERR_VAR) + MAX_ID_LEN] = ERR_VAR;
  1393. Xregister int index;
  1394. X
  1395. X    if (x->type != INT)
  1396. X        int_error("internal error--non-int passed to f_push!",NO_CARET);
  1397. X    index = x->v.int_val;
  1398. X
  1399. X    if (vt[index].vt_undef) {     /* undefined */
  1400. X        (void) strcpy(&err_str[sizeof(ERR_VAR) - 1], vt[index].vt_name);
  1401. X        int_error(err_str,NO_CARET);
  1402. X    }
  1403. X    push(&vt[index].vt_value);
  1404. X}
  1405. X
  1406. X
  1407. Xf_pushc(x)
  1408. Xstruct value *x;
  1409. X{
  1410. X    if (s_p == STACK_DEPTH - 1)
  1411. X        int_error("stack overflow",NO_CARET);
  1412. X    stack[++s_p] = *x;
  1413. X}
  1414. X
  1415. X
  1416. Xf_pushd(x)
  1417. Xstruct value *x;
  1418. X{
  1419. X    f_pushc(&udft[x->v.int_val].dummy_value);
  1420. X}
  1421. X
  1422. X
  1423. X#define ERR_FUN "undefined function: "
  1424. X
  1425. Xf_call(f_index)  /* execute a udf */
  1426. Xstruct value *f_index;
  1427. X{
  1428. Xstatic char err_str[sizeof(ERR_FUN) + MAX_ID_LEN] = ERR_FUN;
  1429. X
  1430. X    if (udft[f_index->v.int_val].at.count == 0) { /* undefined */
  1431. X        (void) strcpy(&err_str[sizeof(ERR_FUN) - 1],
  1432. X                udft[f_index->v.int_val].udft_name);
  1433. X        int_error(err_str,NO_CARET);
  1434. X    }
  1435. X    (void) pop(&udft[f_index->v.int_val].dummy_value);
  1436. X
  1437. X    execute_at(&udft[f_index->v.int_val].at);
  1438. X}
  1439. X
  1440. X
  1441. Xstatic int_check(v)
  1442. Xstruct value *v;
  1443. X{
  1444. X    if (v->type != INT)
  1445. X        int_error("non-integer passed to boolean operator",NO_CARET);
  1446. X}
  1447. X
  1448. X
  1449. Xf_terniary()        /* code for (a) ? b : c */
  1450. X{
  1451. Xstruct value a, b, c;
  1452. X    (void) pop(&c);    (void) pop(&b);    int_check(pop(&a));
  1453. X    push((a.v.int_val) ? &b : &c);
  1454. X            /* I just had to use ? : here! */
  1455. X}
  1456. X
  1457. X
  1458. Xf_lnot()
  1459. X{
  1460. Xstruct value a;
  1461. X    int_check(pop(&a));
  1462. X    push(integer(&a,!a.v.int_val) );
  1463. X}
  1464. X
  1465. X
  1466. Xf_bnot()
  1467. X{
  1468. Xstruct value a;
  1469. X    int_check(pop(&a));
  1470. X    push( integer(&a,~a.v.int_val) );
  1471. X}
  1472. X
  1473. X
  1474. Xf_lor()
  1475. X{
  1476. Xstruct value a,b;
  1477. X    int_check(pop(&b));
  1478. X    int_check(pop(&a));
  1479. X    push( integer(&a,a.v.int_val || b.v.int_val) );
  1480. X}
  1481. X
  1482. X
  1483. Xf_land()
  1484. X{
  1485. Xstruct value a,b;
  1486. X    int_check(pop(&b));
  1487. X    int_check(pop(&a));
  1488. X    push( integer(&a,a.v.int_val && b.v.int_val) );
  1489. X}
  1490. X
  1491. X
  1492. Xf_bor()
  1493. X{
  1494. Xstruct value a,b;
  1495. X    int_check(pop(&b));
  1496. X    int_check(pop(&a));
  1497. X    push( integer(&a,a.v.int_val | b.v.int_val) );
  1498. X}
  1499. X
  1500. X
  1501. Xf_xor()
  1502. X{
  1503. Xstruct value a,b;
  1504. X    int_check(pop(&b));
  1505. X    int_check(pop(&a));
  1506. X    push( integer(&a,a.v.int_val ^ b.v.int_val) );
  1507. X}
  1508. X
  1509. X
  1510. Xf_band()
  1511. X{
  1512. Xstruct value a,b;
  1513. X    int_check(pop(&b));
  1514. X    int_check(pop(&a));
  1515. X    push( integer(&a,a.v.int_val & b.v.int_val) );
  1516. X}
  1517. X
  1518. X
  1519. Xf_uminus()
  1520. X{
  1521. Xstruct value a;
  1522. X    (void) pop(&a);
  1523. X    switch(a.type) {
  1524. X        case INT:
  1525. X            a.v.int_val = -a.v.int_val;
  1526. X            break;
  1527. X        case CMPLX:
  1528. X            a.v.cmplx_val.real =
  1529. X                -a.v.cmplx_val.real;
  1530. X            a.v.cmplx_val.imag =
  1531. X                -a.v.cmplx_val.imag;
  1532. X    }
  1533. X    push(&a);
  1534. X}
  1535. X
  1536. X
  1537. Xf_eq() /* note: floating point equality is rare because of roundoff error! */
  1538. X{
  1539. Xstruct value a, b;
  1540. X    register int result;
  1541. X    (void) pop(&b);
  1542. X    (void) pop(&a);
  1543. X    switch(a.type) {
  1544. X        case INT:
  1545. X            switch (b.type) {
  1546. X                case INT:
  1547. X                    result = (a.v.int_val ==
  1548. X                        b.v.int_val);
  1549. X                    break;
  1550. X                case CMPLX:
  1551. X                    result = (a.v.int_val ==
  1552. X                        b.v.cmplx_val.real &&
  1553. X                       b.v.cmplx_val.imag == 0.0);
  1554. X            }
  1555. X            break;
  1556. X        case CMPLX:
  1557. X            switch (b.type) {
  1558. X                case INT:
  1559. X                    result = (b.v.int_val == a.v.cmplx_val.real &&
  1560. X                       a.v.cmplx_val.imag == 0.0);
  1561. X                    break;
  1562. X                case CMPLX:
  1563. X                    result = (a.v.cmplx_val.real==
  1564. X                        b.v.cmplx_val.real &&
  1565. X                        a.v.cmplx_val.imag==
  1566. X                        b.v.cmplx_val.imag);
  1567. X            }
  1568. X    }
  1569. X    push(integer(&a,result));
  1570. X}
  1571. X
  1572. X
  1573. Xf_ne()
  1574. X{
  1575. Xstruct value a, b;
  1576. X    register int result;
  1577. X    (void) pop(&b);
  1578. X    (void) pop(&a);
  1579. X    switch(a.type) {
  1580. X        case INT:
  1581. X            switch (b.type) {
  1582. X                case INT:
  1583. X                    result = (a.v.int_val !=
  1584. X                        b.v.int_val);
  1585. X                    break;
  1586. X                case CMPLX:
  1587. X                    result = (a.v.int_val !=
  1588. X                        b.v.cmplx_val.real ||
  1589. X                       b.v.cmplx_val.imag != 0.0);
  1590. X            }
  1591. X            break;
  1592. X        case CMPLX:
  1593. X            switch (b.type) {
  1594. X                case INT:
  1595. X                    result = (b.v.int_val !=
  1596. X                        a.v.cmplx_val.real ||
  1597. X                       a.v.cmplx_val.imag != 0.0);
  1598. X                    break;
  1599. X                case CMPLX:
  1600. X                    result = (a.v.cmplx_val.real !=
  1601. X                        b.v.cmplx_val.real ||
  1602. X                        a.v.cmplx_val.imag !=
  1603. X                        b.v.cmplx_val.imag);
  1604. X            }
  1605. X    }
  1606. X    push(integer(&a,result));
  1607. X}
  1608. X
  1609. X
  1610. Xf_gt()
  1611. X{
  1612. Xstruct value a, b;
  1613. X    register int result;
  1614. X    (void) pop(&b);
  1615. X    (void) pop(&a);
  1616. X    switch(a.type) {
  1617. X        case INT:
  1618. X            switch (b.type) {
  1619. X                case INT:
  1620. X                    result = (a.v.int_val >
  1621. X                        b.v.int_val);
  1622. X                    break;
  1623. X                case CMPLX:
  1624. X                    result = (a.v.int_val >
  1625. X                        b.v.cmplx_val.real);
  1626. X            }
  1627. X            break;
  1628. X        case CMPLX:
  1629. X            switch (b.type) {
  1630. X                case INT:
  1631. X                    result = (a.v.cmplx_val.real >
  1632. X                        b.v.int_val);
  1633. X                    break;
  1634. X                case CMPLX:
  1635. X                    result = (a.v.cmplx_val.real >
  1636. X                        b.v.cmplx_val.real);
  1637. X            }
  1638. X    }
  1639. X    push(integer(&a,result));
  1640. X}
  1641. X
  1642. X
  1643. Xf_lt()
  1644. X{
  1645. Xstruct value a, b;
  1646. X    register int result;
  1647. X    (void) pop(&b);
  1648. X    (void) pop(&a);
  1649. X    switch(a.type) {
  1650. X        case INT:
  1651. X            switch (b.type) {
  1652. X                case INT:
  1653. X                    result = (a.v.int_val <
  1654. X                        b.v.int_val);
  1655. X                    break;
  1656. X                case CMPLX:
  1657. X                    result = (a.v.int_val <
  1658. X                        b.v.cmplx_val.real);
  1659. X            }
  1660. X            break;
  1661. X        case CMPLX:
  1662. X            switch (b.type) {
  1663. X                case INT:
  1664. X                    result = (a.v.cmplx_val.real <
  1665. X                        b.v.int_val);
  1666. X                    break;
  1667. X                case CMPLX:
  1668. X                    result = (a.v.cmplx_val.real <
  1669. X                        b.v.cmplx_val.real);
  1670. X            }
  1671. X    }
  1672. X    push(integer(&a,result));
  1673. X}
  1674. X
  1675. X
  1676. Xf_ge()
  1677. X{
  1678. Xstruct value a, b;
  1679. X    register int result;
  1680. X    (void) pop(&b);
  1681. X    (void) pop(&a);
  1682. X    switch(a.type) {
  1683. X        case INT:
  1684. X            switch (b.type) {
  1685. X                case INT:
  1686. X                    result = (a.v.int_val >=
  1687. X                        b.v.int_val);
  1688. X                    break;
  1689. X                case CMPLX:
  1690. X                    result = (a.v.int_val >=
  1691. X                        b.v.cmplx_val.real);
  1692. X            }
  1693. X            break;
  1694. X        case CMPLX:
  1695. X            switch (b.type) {
  1696. X                case INT:
  1697. X                    result = (a.v.cmplx_val.real >=
  1698. X                        b.v.int_val);
  1699. X                    break;
  1700. X                case CMPLX:
  1701. X                    result = (a.v.cmplx_val.real >=
  1702. X                        b.v.cmplx_val.real);
  1703. X            }
  1704. X    }
  1705. X    push(integer(&a,result));
  1706. X}
  1707. X
  1708. X
  1709. Xf_le()
  1710. X{
  1711. Xstruct value a, b;
  1712. X    register int result;
  1713. X    (void) pop(&b);
  1714. X    (void) pop(&a);
  1715. X    switch(a.type) {
  1716. X        case INT:
  1717. X            switch (b.type) {
  1718. X                case INT:
  1719. X                    result = (a.v.int_val <=
  1720. X                        b.v.int_val);
  1721. X                    break;
  1722. X                case CMPLX:
  1723. X                    result = (a.v.int_val <=
  1724. X                        b.v.cmplx_val.real);
  1725. X            }
  1726. X            break;
  1727. X        case CMPLX:
  1728. X            switch (b.type) {
  1729. X                case INT:
  1730. X                    result = (a.v.cmplx_val.real <=
  1731. X                        b.v.int_val);
  1732. X                    break;
  1733. X                case CMPLX:
  1734. X                    result = (a.v.cmplx_val.real <=
  1735. X                        b.v.cmplx_val.real);
  1736. X            }
  1737. X    }
  1738. X    push(integer(&a,result));
  1739. X}
  1740. X
  1741. X
  1742. Xf_plus()
  1743. X{
  1744. Xstruct value a, b, result;
  1745. X    (void) pop(&b);
  1746. X    (void) pop(&a);
  1747. X    switch(a.type) {
  1748. X        case INT:
  1749. X            switch (b.type) {
  1750. X                case INT:
  1751. X                    (void) integer(&result,a.v.int_val +
  1752. X                        b.v.int_val);
  1753. X                    break;
  1754. X                case CMPLX:
  1755. X                    (void) complex(&result,a.v.int_val +
  1756. X                        b.v.cmplx_val.real,
  1757. X                       b.v.cmplx_val.imag);
  1758. X            }
  1759. X            break;
  1760. X        case CMPLX:
  1761. X            switch (b.type) {
  1762. X                case INT:
  1763. X                    (void) complex(&result,b.v.int_val +
  1764. X                        a.v.cmplx_val.real,
  1765. X                       a.v.cmplx_val.imag);
  1766. X                    break;
  1767. X                case CMPLX:
  1768. X                    (void) complex(&result,a.v.cmplx_val.real+
  1769. X                        b.v.cmplx_val.real,
  1770. X                        a.v.cmplx_val.imag+
  1771. X                        b.v.cmplx_val.imag);
  1772. X            }
  1773. X    }
  1774. X    push(&result);
  1775. X}
  1776. X
  1777. X
  1778. Xf_minus()
  1779. X{
  1780. Xstruct value a, b, result;
  1781. X    (void) pop(&b);
  1782. X    (void) pop(&a);        /* now do a - b */
  1783. X    switch(a.type) {
  1784. X        case INT:
  1785. X            switch (b.type) {
  1786. X                case INT:
  1787. X                    (void) integer(&result,a.v.int_val -
  1788. X                        b.v.int_val);
  1789. X                    break;
  1790. X                case CMPLX:
  1791. X                    (void) complex(&result,a.v.int_val -
  1792. X                        b.v.cmplx_val.real,
  1793. X                       -b.v.cmplx_val.imag);
  1794. X            }
  1795. X            break;
  1796. X        case CMPLX:
  1797. X            switch (b.type) {
  1798. X                case INT:
  1799. X                    (void) complex(&result,a.v.cmplx_val.real -
  1800. X                        b.v.int_val,
  1801. X                        a.v.cmplx_val.imag);
  1802. X                    break;
  1803. X                case CMPLX:
  1804. X                    (void) complex(&result,a.v.cmplx_val.real-
  1805. X                        b.v.cmplx_val.real,
  1806. X                        a.v.cmplx_val.imag-
  1807. X                        b.v.cmplx_val.imag);
  1808. X            }
  1809. X    }
  1810. X    push(&result);
  1811. X}
  1812. X
  1813. X
  1814. Xf_mult()
  1815. X{
  1816. Xstruct value a, b, result;
  1817. X    (void) pop(&b);
  1818. X    (void) pop(&a);    /* now do a*b */
  1819. X
  1820. X    switch(a.type) {
  1821. X        case INT:
  1822. X            switch (b.type) {
  1823. X                case INT:
  1824. X                    (void) integer(&result,a.v.int_val *
  1825. X                        b.v.int_val);
  1826. X                    break;
  1827. X                case CMPLX:
  1828. X                    (void) complex(&result,a.v.int_val *
  1829. X                        b.v.cmplx_val.real,
  1830. X                        a.v.int_val *
  1831. X                        b.v.cmplx_val.imag);
  1832. X            }
  1833. X            break;
  1834. X        case CMPLX:
  1835. X            switch (b.type) {
  1836. X                case INT:
  1837. X                    (void) complex(&result,b.v.int_val *
  1838. X                        a.v.cmplx_val.real,
  1839. X                        b.v.int_val *
  1840. X                        a.v.cmplx_val.imag);
  1841. X                    break;
  1842. X                case CMPLX:
  1843. X                    (void) complex(&result,a.v.cmplx_val.real*
  1844. X                        b.v.cmplx_val.real-
  1845. X                        a.v.cmplx_val.imag*
  1846. X                        b.v.cmplx_val.imag,
  1847. X                        a.v.cmplx_val.real*
  1848. X                        b.v.cmplx_val.imag+
  1849. X                        a.v.cmplx_val.imag*
  1850. X                        b.v.cmplx_val.real);
  1851. X            }
  1852. X    }
  1853. X    push(&result);
  1854. X}
  1855. X
  1856. X
  1857. Xf_div()
  1858. X{
  1859. Xstruct value a, b, result;
  1860. Xregister double square;
  1861. X    (void) pop(&b);
  1862. X    (void) pop(&a);    /* now do a/b */
  1863. X
  1864. X    switch(a.type) {
  1865. X        case INT:
  1866. X            switch (b.type) {
  1867. X                case INT:
  1868. X                    if (b.v.int_val)
  1869. X                      (void) integer(&result,a.v.int_val /
  1870. X                        b.v.int_val);
  1871. X                    else {
  1872. X                      (void) integer(&result,0);
  1873. X                      undefined = TRUE;
  1874. X                    }
  1875. X                    break;
  1876. X                case CMPLX:
  1877. X                    square = b.v.cmplx_val.real*
  1878. X                        b.v.cmplx_val.real +
  1879. X                        b.v.cmplx_val.imag*
  1880. X                        b.v.cmplx_val.imag;
  1881. X                    if (square)
  1882. X                        (void) complex(&result,a.v.int_val*
  1883. X                        b.v.cmplx_val.real/square,
  1884. X                        -a.v.int_val*
  1885. X                        b.v.cmplx_val.imag/square);
  1886. X                    else {
  1887. X                        (void) complex(&result,0.0,0.0);
  1888. X                        undefined = TRUE;
  1889. X                    }
  1890. X            }
  1891. X            break;
  1892. X        case CMPLX:
  1893. X            switch (b.type) {
  1894. X                case INT:
  1895. X                    if (b.v.int_val)
  1896. X                      
  1897. X                      (void) complex(&result,a.v.cmplx_val.real/
  1898. X                        b.v.int_val,
  1899. X                        a.v.cmplx_val.imag/
  1900. X                        b.v.int_val);
  1901. X                    else {
  1902. X                        (void) complex(&result,0.0,0.0);
  1903. X                        undefined = TRUE;
  1904. X                    }
  1905. X                    break;
  1906. X                case CMPLX:
  1907. X                    square = b.v.cmplx_val.real*
  1908. X                        b.v.cmplx_val.real +
  1909. X                        b.v.cmplx_val.imag*
  1910. X                        b.v.cmplx_val.imag;
  1911. X                    if (square)
  1912. X                    (void) complex(&result,(a.v.cmplx_val.real*
  1913. X                        b.v.cmplx_val.real+
  1914. X                        a.v.cmplx_val.imag*
  1915. X                        b.v.cmplx_val.imag)/square,
  1916. X                        (a.v.cmplx_val.imag*
  1917. X                        b.v.cmplx_val.real-
  1918. X                        a.v.cmplx_val.real*
  1919. X                        b.v.cmplx_val.imag)/
  1920. X                            square);
  1921. X                    else {
  1922. X                        (void) complex(&result,0.0,0.0);
  1923. X                        undefined = TRUE;
  1924. X                    }
  1925. X            }
  1926. X    }
  1927. X    push(&result);
  1928. X}
  1929. X
  1930. X
  1931. Xf_mod()
  1932. X{
  1933. Xstruct value a, b;
  1934. X    (void) pop(&b);
  1935. X    (void) pop(&a);    /* now do a%b */
  1936. X
  1937. X    if (a.type != INT || b.type != INT)
  1938. X        int_error("can only mod ints",NO_CARET);
  1939. X    if (b.v.int_val)
  1940. X        push(integer(&a,a.v.int_val % b.v.int_val));
  1941. X    else {
  1942. X        push(integer(&a,0));
  1943. X        undefined = TRUE;
  1944. X    }
  1945. X}
  1946. X
  1947. X
  1948. Xf_power()
  1949. X{
  1950. Xstruct value a, b, result;
  1951. Xregister int i, t, count;
  1952. Xregister double mag, ang;
  1953. X    (void) pop(&b);
  1954. X    (void) pop(&a);    /* now find a**b */
  1955. X
  1956. X    switch(a.type) {
  1957. X        case INT:
  1958. X            switch (b.type) {
  1959. X                case INT:
  1960. X                    count = abs(b.v.int_val);
  1961. X                    t = 1;
  1962. X                    for(i=0; i < count; i++)
  1963. X                        t *= a.v.int_val;
  1964. X                    if (b.v.int_val >= 0)
  1965. X                        (void) integer(&result,t);
  1966. X                    else
  1967. X                        (void) complex(&result,1.0/t,0.0);
  1968. X                    break;
  1969. X                case CMPLX:
  1970. X                    mag =
  1971. X                      pow(magnitude(&a),fabs(b.v.cmplx_val.real));
  1972. X                    if (b.v.cmplx_val.real < 0.0)
  1973. X                        mag = 1.0/mag;
  1974. X                    ang = angle(&a)*b.v.cmplx_val.real+
  1975. X                      b.v.cmplx_val.imag;
  1976. X                    (void) complex(&result,mag*cos(ang),
  1977. X                        mag*sin(ang));
  1978. X            }
  1979. X            break;
  1980. X        case CMPLX:
  1981. X            switch (b.type) {
  1982. X                case INT:
  1983. X                    /* not so good, but...! */
  1984. X                    mag =
  1985. X                      pow(magnitude(&a),(double)abs(b.v.int_val));
  1986. X                    if (b.v.int_val < 0)
  1987. X                        mag = 1.0/mag;
  1988. X                    ang = angle(&a)*b.v.int_val;
  1989. X                    (void) complex(&result,mag*cos(ang),
  1990. X                        mag*sin(ang));
  1991. X                    break;
  1992. X                case CMPLX:
  1993. X                    mag =
  1994. X                      pow(magnitude(&a),fabs(b.v.cmplx_val.real));
  1995. X                    if (b.v.cmplx_val.real < 0.0)
  1996. X                      mag = 1.0/mag;
  1997. X                    ang = angle(&a)*b.v.cmplx_val.real+
  1998. X                      b.v.cmplx_val.imag;
  1999. X                    (void) complex(&result,mag*cos(ang),
  2000. X                        mag*sin(ang));
  2001. X            }
  2002. X    }
  2003. X    push(&result);
  2004. X}
  2005. *-*-END-of-translate/internal.c-*-*
  2006. echo x - translate/misc.c
  2007. sed 's/^X//' >translate/misc.c <<'*-*-END-of-translate/misc.c-*-*'
  2008. X/*
  2009. X *
  2010. X *    G N U P L O T  --  misc.c
  2011. X *
  2012. X *  Copyright (C) 1986 Thomas Williams, Colin Kelley
  2013. X *
  2014. X *  You may use this code as you wish if credit is given and this message
  2015. X *  is retained.
  2016. X *
  2017. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  2018. X *  included in later releases.
  2019. X *
  2020. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  2021. X */
  2022. X
  2023. X#include <stdio.h>
  2024. X#include "plot.h"
  2025. X
  2026. Xextern struct curve_points plot[];
  2027. Xextern int c_token,next_value,next_function;
  2028. Xextern struct udft_entry udft[];
  2029. Xextern struct at_type *curr_at;
  2030. Xextern struct ft_entry ft[];
  2031. Xextern struct vt_entry vt[];
  2032. X
  2033. X
  2034. Xshow_at(level)
  2035. Xint level;
  2036. X{
  2037. Xstruct at_type *at_address;
  2038. Xint i, j;
  2039. Xstruct value *arg;
  2040. X
  2041. X    at_address = curr_at;
  2042. X    for (i = 0; i < at_address->count; i++) {
  2043. X        for (j = 0; j < level; j++)
  2044. X            (void) putc(' ',stderr);    /* indent */
  2045. X
  2046. X            /* print name of action instruction */
  2047. X        fputs(ft[at_address->actions[i].index].ft_name,stderr);
  2048. X        arg = &(at_address->actions[i].arg);
  2049. X            /* now print optional argument */
  2050. X
  2051. X        switch(at_address->actions[i].index) {
  2052. X          case (int)PUSH:    fprintf(stderr," (%s)\n",
  2053. X                      vt[arg->v.int_val].vt_name);
  2054. X                    break;
  2055. X          case (int)PUSHC:    (void) putc('(',stderr);
  2056. X                    show_value(stderr,arg);
  2057. X                    fputs(")\n",stderr);
  2058. X                    break;
  2059. X          case (int)PUSHD:    fprintf(stderr," (%s dummy)\n",
  2060. X                      udft[arg->v.int_val].udft_name);
  2061. X                    break;
  2062. X          case (int)CALL:    fprintf(stderr," (%s)\n",
  2063. X                      udft[arg->v.int_val].udft_name);
  2064. X                    curr_at = &udft[arg->v.int_val].at;
  2065. X                    show_at(level+2); /* recurse! */
  2066. X                    curr_at = at_address;
  2067. X                    break;
  2068. X          default:
  2069. X                    (void) putc('\n',stderr);
  2070. X        }
  2071. X    }
  2072. X}
  2073. *-*-END-of-translate/misc.c-*-*
  2074. echo x - translate/parse.c
  2075. sed 's/^X//' >translate/parse.c <<'*-*-END-of-translate/parse.c-*-*'
  2076. X/*
  2077. X *
  2078. X *    G N U P L O T  --  parse.c
  2079. X *
  2080. X *  Copyright (C) 1986 Colin Kelley, Thomas Williams
  2081. X *
  2082. X *  You may use this code as you wish if credit is given and this message
  2083. X *  is retained.
  2084. X *
  2085. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  2086. X *  included in later releases.
  2087. X *
  2088. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  2089. X */
  2090. X
  2091. X#include <stdio.h>
  2092. X#include <setjmp.h>
  2093. X#include <signal.h>
  2094. X#include <errno.h>
  2095. X#include "plot.h"
  2096. X
  2097. Xextern BOOLEAN undefined;
  2098. X
  2099. X#ifndef vms
  2100. Xextern int errno;
  2101. X#endif
  2102. X
  2103. Xextern int next_function,c_function /* next available space in udft */;
  2104. Xextern int num_tokens,c_token;
  2105. Xextern struct lexical_unit token[];
  2106. Xextern char dummy_var[];
  2107. Xextern struct at_type *curr_at;
  2108. X
  2109. Xstruct value *pop(),*integer(),*complex();
  2110. X
  2111. Xstatic struct at_type temp_at;
  2112. Xstatic jmp_buf fpe_env;
  2113. X
  2114. X#define dummy (struct value *) 0
  2115. X
  2116. Xfpe()
  2117. X{
  2118. X    (void) signal(SIGFPE, fpe);
  2119. X    undefined = TRUE;
  2120. X    longjmp(fpe_env, TRUE);
  2121. X}
  2122. X
  2123. Xevaluate_at(at,valptr)
  2124. Xstruct at_type *at;
  2125. Xstruct value *valptr;
  2126. X{
  2127. X    undefined = FALSE;
  2128. X    errno = 0;
  2129. X    reset_stack();
  2130. X    if (setjmp(fpe_env))
  2131. X        return;                /* just bail out */
  2132. X    (void) signal(SIGFPE, fpe);    /* catch core dumps on FPEs */
  2133. X
  2134. X    execute_at(at);
  2135. X
  2136. X    (void) signal(SIGFPE, SIG_DFL);
  2137. X
  2138. X    if (errno == EDOM || errno == ERANGE) {
  2139. X        undefined = TRUE;
  2140. X    } else {
  2141. X        (void) pop(valptr);
  2142. X        check_stack();
  2143. X    }
  2144. X}
  2145. X
  2146. X
  2147. Xstruct value *
  2148. Xconst_express(valptr)
  2149. Xstruct value *valptr;
  2150. X{
  2151. Xregister int tkn = c_token;
  2152. X    if (END_OF_COMMAND)
  2153. X        int_error("constant expression required",c_token);
  2154. X    build_at(&temp_at);    /* make a temporary action table */
  2155. X    evaluate_at(&temp_at,valptr);    /* run it and send answer back */
  2156. X    if (undefined) {
  2157. X        int_error("undefined value",tkn);
  2158. X    }
  2159. X    return(valptr);
  2160. X}
  2161. X
  2162. X
  2163. Xbuild_at(at)    /* build full expressions */
  2164. Xstruct at_type *at;
  2165. X{
  2166. X    curr_at = at;        /* set global variable */
  2167. X    curr_at->count = 0;        /* reset action table !!! */
  2168. X    express();
  2169. X}
  2170. X
  2171. X
  2172. Xexpress()  /* full expressions */
  2173. X{
  2174. X    xterm();
  2175. X    xterms();
  2176. X}
  2177. X
  2178. Xxterm()  /* NEW!  ? : expressions */
  2179. X{
  2180. X    aterm();
  2181. X    aterms();
  2182. X}
  2183. X
  2184. X
  2185. Xaterm()
  2186. X{
  2187. X    bterm();
  2188. X    bterms();
  2189. X}
  2190. X
  2191. X
  2192. Xbterm()
  2193. X{
  2194. X    cterm();
  2195. X    cterms();
  2196. X}
  2197. X
  2198. X
  2199. Xcterm()
  2200. X{
  2201. X    dterm();
  2202. X    dterms();
  2203. X}
  2204. X
  2205. X
  2206. Xdterm()
  2207. X{    
  2208. X    eterm();
  2209. X    eterms();
  2210. X}
  2211. X
  2212. X
  2213. Xeterm()
  2214. X{
  2215. X    fterm();
  2216. X    fterms();
  2217. X}
  2218. X
  2219. X
  2220. Xfterm()
  2221. X{
  2222. X    gterm();
  2223. X    gterms();
  2224. X}
  2225. X
  2226. X
  2227. Xgterm()
  2228. X{
  2229. X    hterm();
  2230. X    hterms();
  2231. X}
  2232. X
  2233. X
  2234. Xhterm()
  2235. X{
  2236. X    unary(); /* - things */
  2237. X    iterms(); /* * / % */
  2238. X}
  2239. X
  2240. X
  2241. Xfactor()
  2242. X{
  2243. Xregister int value;
  2244. Xstruct value a, real_value;
  2245. X
  2246. X    if (equals(c_token,"(")) {
  2247. X        c_token++;
  2248. X        express();
  2249. X        if (!equals(c_token,")")) 
  2250. X            int_error("')' expected",c_token);
  2251. X        c_token++;
  2252. X    }
  2253. X    else if (isnumber(c_token)) {
  2254. X        convert(&real_value,c_token);
  2255. X        c_token++;
  2256. X        add_action(PUSHC, &real_value);
  2257. X    }
  2258. X    else if (isletter(c_token)) {
  2259. X        if ((c_token+1 < num_tokens)  && equals(c_token+1,"(")) {
  2260. X        value = standard(c_token);
  2261. X            if (value) {    /* it's a standard function */
  2262. X                c_token += 2;
  2263. X                express();
  2264. X                if (!equals(c_token,")"))
  2265. X                    int_error("')' expected",c_token);
  2266. X                c_token++;
  2267. X                add_action(value,dummy);
  2268. X            }
  2269. X            else {
  2270. X                value = user_defined(c_token);
  2271. X                c_token += 2;
  2272. X                express();
  2273. X                if (!equals(c_token,")")) 
  2274. X                    int_error("')' expected",c_token);
  2275. X                c_token++;
  2276. X                add_action(CALL,integer(&a,value));
  2277. X            }
  2278. X        }
  2279. X        else {
  2280. X            if (equals(c_token,dummy_var)) {
  2281. X                value = c_function;
  2282. X                c_token++;
  2283. X                add_action(PUSHD,integer(&a,value));
  2284. X            }
  2285. X            else {
  2286. X                value = add_value(c_token);
  2287. X                c_token++;
  2288. X                add_action(PUSH,integer(&a,value));
  2289. X            }
  2290. X        }
  2291. X    } /* end if letter */
  2292. X    else
  2293. X        int_error("invalid expression ",c_token);
  2294. X
  2295. X    /* add action code for ** operator */
  2296. X    if (equals(c_token,"**")) {
  2297. X            c_token++;
  2298. X            unary();
  2299. X            add_action(POWER,dummy);
  2300. X    }
  2301. X}
  2302. X
  2303. X
  2304. X
  2305. Xxterms()
  2306. X{  /* create action code for ? : expressions */
  2307. X
  2308. X    while (equals(c_token,"?")) {
  2309. X        c_token++;
  2310. X        express();
  2311. X        if (!equals(c_token,":")) 
  2312. X            int_error("expecting ':'",c_token);
  2313. X        c_token++;
  2314. X        express();
  2315. X        add_action(TERNIARY,dummy);
  2316. X    }
  2317. X}
  2318. X
  2319. X
  2320. Xaterms()
  2321. X{  /* create action codes for || operator */
  2322. X
  2323. X    while (equals(c_token,"||")) {
  2324. X        c_token++;
  2325. X        aterm();
  2326. X        add_action(LOR,dummy);
  2327. X    }
  2328. X}
  2329. X
  2330. X
  2331. Xbterms()
  2332. X{ /* create action code for && operator */
  2333. X
  2334. X    while (equals(c_token,"&&")) {
  2335. X        c_token++;
  2336. X        bterm();
  2337. X        add_action(LAND,dummy);
  2338. X    }
  2339. X}
  2340. X
  2341. X
  2342. Xcterms()
  2343. X{ /* create action code for | operator */
  2344. X
  2345. X    while (equals(c_token,"|")) {
  2346. X        c_token++;
  2347. X        cterm();
  2348. X        add_action(BOR,dummy);
  2349. X    }
  2350. X}
  2351. X
  2352. X
  2353. Xdterms()
  2354. X{ /* create action code for ^ operator */
  2355. X
  2356. X    while (equals(c_token,"^")) {
  2357. X        c_token++;
  2358. X        dterm();
  2359. X        add_action(XOR,dummy);
  2360. X    }
  2361. X}
  2362. X
  2363. X
  2364. Xeterms()
  2365. X{ /* create action code for & operator */
  2366. X
  2367. X    while (equals(c_token,"&")) {
  2368. X        c_token++;
  2369. X        eterm();
  2370. X        add_action(BAND,dummy);
  2371. X    }
  2372. X}
  2373. X
  2374. X
  2375. Xfterms()
  2376. X{ /* create action codes for == and != operators */
  2377. X
  2378. X    while (TRUE) {
  2379. X        if (equals(c_token,"==")) {
  2380. X            c_token++;
  2381. X            fterm();
  2382. X            add_action(EQ,dummy);
  2383. X        }
  2384. X        else if (equals(c_token,"!=")) {
  2385. X            c_token++;
  2386. X            fterm(); 
  2387. X            add_action(NE,dummy); 
  2388. X        }
  2389. X        else break;
  2390. X    }
  2391. X}
  2392. X
  2393. X
  2394. Xgterms()
  2395. X{ /* create action code for < > >= or <= operators */
  2396. X    
  2397. X    while (TRUE) {
  2398. X        /* I hate "else if" statements */
  2399. X        if (equals(c_token,">")) {
  2400. X            c_token++;
  2401. X            gterm();
  2402. X            add_action(GT,dummy);
  2403. X        }
  2404. X        else if (equals(c_token,"<")) {
  2405. X            c_token++;
  2406. X            gterm();
  2407. X            add_action(LT,dummy);
  2408. X        }        
  2409. X        else if (equals(c_token,">=")) {
  2410. X            c_token++;
  2411. X            gterm();
  2412. X            add_action(GE,dummy);
  2413. X        }
  2414. X        else if (equals(c_token,"<=")) {
  2415. X            c_token++;
  2416. X            gterm();
  2417. X            add_action(LE,dummy);
  2418. X        }
  2419. X        else break;
  2420. X    }
  2421. X
  2422. X}
  2423. X
  2424. X
  2425. X
  2426. Xhterms()
  2427. X{ /* create action codes for + and - operators */
  2428. X
  2429. X    while (TRUE) {
  2430. X            if (equals(c_token,"+")) {
  2431. X                c_token++;
  2432. X                hterm();
  2433. X                add_action(PLUS,dummy);
  2434. X            }
  2435. X            else if (equals(c_token,"-")) {
  2436. X                c_token++;
  2437. X                hterm();
  2438. X                add_action(MINUS,dummy);
  2439. X            }
  2440. X            else break;
  2441. X    }
  2442. X}
  2443. X
  2444. X
  2445. Xiterms()
  2446. X{ /* add action code for * / and % operators */
  2447. X
  2448. X    while (TRUE) {
  2449. X            if (equals(c_token,"*")) {
  2450. X                c_token++;
  2451. X                unary();
  2452. X                add_action(MULT,dummy);
  2453. X            }
  2454. X            else if (equals(c_token,"/")) {
  2455. X                c_token++;
  2456. X                unary();
  2457. X                add_action(DIV,dummy);
  2458. X            }
  2459. X            else if (equals(c_token,"%")) {
  2460. X                c_token++;
  2461. X                unary();
  2462. X                add_action(MOD,dummy);
  2463. X            }
  2464. X            else break;
  2465. X    }
  2466. X}
  2467. X
  2468. X
  2469. Xunary()
  2470. X{ /* add code for unary operators */
  2471. X    if (equals(c_token,"!")) {
  2472. X        c_token++;
  2473. X        unary();
  2474. X        add_action(LNOT,dummy);
  2475. X    }
  2476. X    else if (equals(c_token,"~")) {
  2477. X        c_token++;
  2478. X        unary();
  2479. X        add_action(BNOT,dummy);
  2480. X    }
  2481. X    else if (equals(c_token,"-")) {
  2482. X        c_token++;
  2483. X        unary();
  2484. X        add_action(UMINUS,dummy);
  2485. X    }
  2486. X    else 
  2487. X        factor();
  2488. X}
  2489. *-*-END-of-translate/parse.c-*-*
  2490. echo x - translate/plot.c
  2491. sed 's/^X//' >translate/plot.c <<'*-*-END-of-translate/plot.c-*-*'
  2492. X/*
  2493. X *
  2494. X *    gnutex/gnuplot translator  --  plot.c
  2495. X *
  2496. X * By David Kotz, 1990.
  2497. X * Department of Computer Science, Duke University, Durham, NC 27706.
  2498. X * Mail to dfk@cs.duke.edu.
  2499. X */
  2500. X
  2501. X#include <stdio.h>
  2502. X#include <setjmp.h>
  2503. X#include <signal.h>
  2504. X#include "plot.h"
  2505. X
  2506. Xextern FILE *infile;
  2507. Xextern FILE *outfile;
  2508. X
  2509. Xjmp_buf env;
  2510. X
  2511. Xstruct value stack[STACK_DEPTH];
  2512. X
  2513. Xstruct lexical_unit token[MAX_TOKENS];
  2514. X
  2515. Xstruct value *integer(),*complex();
  2516. X
  2517. Xextern f_push(),f_pushc(),f_pushd(),f_call(),f_terniary(),f_lnot(),f_bnot(),
  2518. X    f_uminus(),f_lor(),f_land(),f_bor(),f_xor(),f_band(),f_eq(),f_ne(),
  2519. X    f_gt(),f_lt(),f_ge(),f_le(),f_plus(),f_minus(),f_mult(),f_div(),
  2520. X    f_mod(),f_power();
  2521. X
  2522. Xextern f_real(),f_imag(),f_arg(),f_conjg(),f_sin(),f_cos(),f_tan(),f_asin(),
  2523. X    f_acos(),f_atan(),f_sinh(),f_cosh(),f_tanh(),f_int(),f_abs(),f_sgn(),
  2524. X    f_sqrt(),f_exp(),f_log10(),f_log(),f_besj0(),f_besj1(),f_besy0(),f_besy1(),
  2525. X    f_floor(),f_ceil();
  2526. X    
  2527. X
  2528. Xstruct ft_entry ft[] = {    /* built-in function table */
  2529. X
  2530. X/* internal functions: */
  2531. X    {"push", f_push},    {"pushc", f_pushc},    {"pushd", f_pushd},
  2532. X    {"call", f_call},    {"?:", f_terniary},    {"lnot", f_lnot},
  2533. X    {"bnot", f_bnot},    {"uminus", f_uminus},    {"lor", f_lor},
  2534. X    {"land", f_land},    {"bor", f_bor},        {"xor", f_xor},
  2535. X    {"band", f_band},    {"eq", f_eq},        {"ne", f_ne},
  2536. X    {"gt", f_gt},        {"lt", f_lt},        {"ge", f_ge},
  2537. X    {"le", f_le},        {"plus", f_plus},    {"minus", f_minus},
  2538. X    {"mult", f_mult},    {"div", f_div},        {"mod", f_mod},
  2539. X    {"power", f_power},
  2540. X
  2541. X/* standard functions: */
  2542. X    {"real", f_real},    {"imag", f_imag},    {"arg", f_arg},
  2543. X    {"conjg", f_conjg}, {"sin", f_sin},        {"cos", f_cos},
  2544. X    {"tan", f_tan},        {"asin", f_asin},    {"acos", f_acos},
  2545. X    {"atan", f_atan},    {"sinh", f_sinh},    {"cosh", f_cosh},
  2546. X    {"tanh", f_tanh},    {"int", f_int},        {"abs", f_abs},
  2547. X    {"sgn", f_sgn},        {"sqrt", f_sqrt},    {"exp", f_exp},
  2548. X    {"log10", f_log10},    {"log", f_log},        {"besj0", f_besj0},
  2549. X    {"besj1", f_besj1},    {"besy0", f_besy0},    {"besy1", f_besy1},
  2550. X    {"floor", f_floor},    {"ceil", f_ceil},     {NULL, NULL}
  2551. X};
  2552. X
  2553. Xstruct udft_entry udft[MAX_UDFS+1];
  2554. X
  2555. Xstruct vt_entry vt[MAX_VALUES] = {
  2556. X    {"pi"},            {"xmin"},        {"xmax"},
  2557. X    {"ymin"},         {"ymax"},        {"autoscale"}
  2558. X};
  2559. X
  2560. Xstruct st_entry st[MAX_STYLES] = {
  2561. X    /* include the fixed styles by default */
  2562. X    /* These must match the positions in enum PLOT_STYLE */
  2563. X    {"lines"},         {"points"},        {"impulses"},        {"linespoints"},
  2564. X    {"dots"}
  2565. X};
  2566. Xint next_style = FIXED_STYLES+1;
  2567. X
  2568. Xcatch()                    /* interrupts */
  2569. X{
  2570. X    (void) signal(SIGFPE, SIG_DFL);    /* turn off FPE trapping */
  2571. X    (void) fflush(outfile);
  2572. X    (void) putc('\n',stderr);
  2573. X    longjmp(env, TRUE);        /* return to prompt */
  2574. X}
  2575. X
  2576. X
  2577. Xmain(argc, argv)
  2578. X    int argc;
  2579. X    char **argv;
  2580. X{
  2581. X    setbuf(stderr,NULL);
  2582. X
  2583. X    if (argc == 3) {
  2584. X       infile = fopen(argv[1], "r");
  2585. X       if (infile == (FILE *)NULL) {
  2586. X          fprintf(stderr, "Cannot open '%s' for input\n", argv[1]);
  2587. X          exit(1);
  2588. X       }
  2589. X       outfile = fopen(argv[2], "w");
  2590. X       if (outfile == (FILE *)NULL) {
  2591. X          fprintf(stderr, "Cannot open '%s' for output\n", argv[2]);
  2592. X          exit(1);
  2593. X       }
  2594. X    } else {
  2595. X       fprintf(stderr, "usage: gnut2p infile outfile\n");
  2596. X       exit(2);
  2597. X    }
  2598. X
  2599. X    (void) complex(&vt[(int)C_PI].vt_value, Pi, 0.0);
  2600. X
  2601. X    setjmp(env);
  2602. X
  2603. X    /* setting to some of the old defaults */
  2604. X    fprintf(outfile, "set noclip one; set noclip two; set clip points\n");
  2605. X
  2606. X    while(TRUE)
  2607. X     com_line();
  2608. X}
  2609. *-*-END-of-translate/plot.c-*-*
  2610. exit
  2611.  
  2612.  
  2613.