home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / gnuplot2 / patch03 / patch1b
Encoding:
Text File  |  1990-10-05  |  62.5 KB  |  2,592 lines

  1. *** ./graphics.c    Tue Mar 27 09:01:22 1990
  2. --- ../patch1/graphics.c    Mon Sep 10 09:57:37 1990
  3. ***************
  4. *** 60,66
  5.   static int xleft, xright, ybot, ytop;
  6.   
  7.   /* Boundary and scale factors, in user coordinates */
  8. ! static double xmin, xmax, ymin, ymax;
  9.   static double xscale, yscale;
  10.   
  11.   /* And the functions to map from user to terminal coordinates */
  12.  
  13. --- 60,69 -----
  14.   static int xleft, xright, ybot, ytop;
  15.   
  16.   /* Boundary and scale factors, in user coordinates */
  17. ! /* x_min, x_max, y_min, y_max are local to this file and
  18. !  * are not the same as variables of the same names in other files
  19. !  */
  20. ! static double x_min, x_max, y_min, y_max;
  21.   static double xscale, yscale;
  22.   
  23.   /* And the functions to map from user to terminal coordinates */
  24. ***************
  25. *** 64,71
  26.   static double xscale, yscale;
  27.   
  28.   /* And the functions to map from user to terminal coordinates */
  29. ! #define map_x(x) (int)(xleft+(x-xmin)*xscale+0.5) /* maps floating point x to screen */ 
  30. ! #define map_y(y) (int)(ybot+(y-ymin)*yscale+0.5)    /* same for y */
  31.   
  32.   /* (DFK) Watch for cancellation error near zero on axes labels */
  33.   #define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  34.  
  35. --- 67,74 -----
  36.   static double xscale, yscale;
  37.   
  38.   /* And the functions to map from user to terminal coordinates */
  39. ! #define map_x(x) (int)(xleft+(x-x_min)*xscale+0.5) /* maps floating point x to screen */ 
  40. ! #define map_y(y) (int)(ybot+(y-y_min)*yscale+0.5)    /* same for y */
  41.   
  42.   /* (DFK) Watch for cancellation error near zero on axes labels */
  43.   #define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  44. ***************
  45. *** 108,115
  46.             int_error(errbuf, NO_CARET);
  47.          } else
  48.           return(log10(coord));
  49. -     } else {
  50. -        return(coord);
  51.       }
  52.       return((double)NULL); /* shut lint up */
  53.   }
  54.  
  55. --- 111,116 -----
  56.             int_error(errbuf, NO_CARET);
  57.          } else
  58.           return(log10(coord));
  59.       }
  60.       return(coord);
  61.   }
  62. ***************
  63. *** 111,117
  64.       } else {
  65.          return(coord);
  66.       }
  67. !     return((double)NULL); /* shut lint up */
  68.   }
  69.   
  70.   /* borders of plotting area */
  71.  
  72. --- 112,118 -----
  73.          } else
  74.           return(log10(coord));
  75.       }
  76. !     return(coord);
  77.   }
  78.   
  79.   /* borders of plotting area */
  80. ***************
  81. *** 187,196
  82.   
  83.   /* store these in variables global to this file */
  84.   /* otherwise, we have to pass them around a lot */
  85. !      xmin = min_x;
  86. !      xmax = max_x; 
  87. !      ymin = min_y;
  88. !      ymax = max_y;
  89.   
  90.       if (polar) {
  91.           /* will possibly change xmin, xmax, ymin, ymax */
  92.  
  93. --- 188,197 -----
  94.   
  95.   /* store these in variables global to this file */
  96.   /* otherwise, we have to pass them around a lot */
  97. !      x_min = min_x;
  98. !      x_max = max_x; 
  99. !      y_min = min_y;
  100. !      y_max = max_y;
  101.   
  102.       if (polar) {
  103.           /* will possibly change x_min, x_max, y_min, y_max */
  104. ***************
  105. *** 193,199
  106.        ymax = max_y;
  107.   
  108.       if (polar) {
  109. !         /* will possibly change xmin, xmax, ymin, ymax */
  110.           polar_xform(plots,pcount);
  111.       }
  112.   
  113.  
  114. --- 194,200 -----
  115.        y_max = max_y;
  116.   
  117.       if (polar) {
  118. !         /* will possibly change x_min, x_max, y_min, y_max */
  119.           polar_xform(plots,pcount);
  120.       }
  121.   
  122. ***************
  123. *** 197,203
  124.           polar_xform(plots,pcount);
  125.       }
  126.   
  127. !     if (ymin == VERYLARGE || ymax == -VERYLARGE)
  128.           int_error("all points undefined!", NO_CARET);
  129.   
  130.       if (xmin == VERYLARGE || xmax == -VERYLARGE)
  131.  
  132. --- 198,204 -----
  133.           polar_xform(plots,pcount);
  134.       }
  135.   
  136. !     if (y_min == VERYLARGE || y_max == -VERYLARGE)
  137.           int_error("all points undefined!", NO_CARET);
  138.   
  139.       if (x_min == VERYLARGE || x_max == -VERYLARGE)
  140. ***************
  141. *** 200,206
  142.       if (ymin == VERYLARGE || ymax == -VERYLARGE)
  143.           int_error("all points undefined!", NO_CARET);
  144.   
  145. !     if (xmin == VERYLARGE || xmax == -VERYLARGE)
  146.           int_error("all points undefined!", NO_CARET);
  147.   
  148.   /*    Apply the desired viewport offsets. */
  149.  
  150. --- 201,207 -----
  151.       if (y_min == VERYLARGE || y_max == -VERYLARGE)
  152.           int_error("all points undefined!", NO_CARET);
  153.   
  154. !     if (x_min == VERYLARGE || x_max == -VERYLARGE)
  155.           int_error("all points undefined!", NO_CARET);
  156.   
  157.   /*    Apply the desired viewport offsets. */
  158. ***************
  159. *** 204,212
  160.           int_error("all points undefined!", NO_CARET);
  161.   
  162.   /*    Apply the desired viewport offsets. */
  163. !      if (ymin < ymax) {
  164. !         ymin -= boff;
  165. !         ymax += toff;
  166.       } else {
  167.           ymax -= boff;
  168.           ymin += toff;
  169.  
  170. --- 205,213 -----
  171.           int_error("all points undefined!", NO_CARET);
  172.   
  173.   /*    Apply the desired viewport offsets. */
  174. !      if (y_min < y_max) {
  175. !         y_min -= boff;
  176. !         y_max += toff;
  177.       } else {
  178.           y_max -= boff;
  179.           y_min += toff;
  180. ***************
  181. *** 208,215
  182.           ymin -= boff;
  183.           ymax += toff;
  184.       } else {
  185. !         ymax -= boff;
  186. !         ymin += toff;
  187.       }
  188.        if (xmin < xmax) {
  189.           xmin -= loff;
  190.  
  191. --- 209,216 -----
  192.           y_min -= boff;
  193.           y_max += toff;
  194.       } else {
  195. !         y_max -= boff;
  196. !         y_min += toff;
  197.       }
  198.        if (x_min < x_max) {
  199.           x_min -= loff;
  200. ***************
  201. *** 211,219
  202.           ymax -= boff;
  203.           ymin += toff;
  204.       }
  205. !      if (xmin < xmax) {
  206. !         xmin -= loff;
  207. !         xmax += roff;
  208.       } else {
  209.           xmax -= loff;
  210.           xmin += roff;
  211.  
  212. --- 212,220 -----
  213.           y_max -= boff;
  214.           y_min += toff;
  215.       }
  216. !      if (x_min < x_max) {
  217. !         x_min -= loff;
  218. !         x_max += roff;
  219.       } else {
  220.           x_max -= loff;
  221.           x_min += roff;
  222. ***************
  223. *** 215,222
  224.           xmin -= loff;
  225.           xmax += roff;
  226.       } else {
  227. !         xmax -= loff;
  228. !         xmin += roff;
  229.       }
  230.   
  231.   /* SETUP RANGES, SCALES AND TIC PLACES */
  232.  
  233. --- 216,223 -----
  234.           x_min -= loff;
  235.           x_max += roff;
  236.       } else {
  237. !         x_max -= loff;
  238. !         x_min += roff;
  239.       }
  240.   
  241.   /* SETUP RANGES, SCALES AND TIC PLACES */
  242. ***************
  243. *** 221,227
  244.   
  245.   /* SETUP RANGES, SCALES AND TIC PLACES */
  246.       if (ytics && yticdef.type == TIC_COMPUTED) {
  247. !        ytic = make_tics(ymin,ymax,log_y);
  248.       
  249.          if (autoscale_ly) {
  250.             if (ymin < ymax) {
  251.  
  252. --- 222,228 -----
  253.   
  254.   /* SETUP RANGES, SCALES AND TIC PLACES */
  255.       if (ytics && yticdef.type == TIC_COMPUTED) {
  256. !        ytic = make_tics(y_min,y_max,log_y);
  257.       
  258.          if (autoscale_ly) {
  259.             if (y_min < y_max) {
  260. ***************
  261. *** 224,232
  262.          ytic = make_tics(ymin,ymax,log_y);
  263.       
  264.          if (autoscale_ly) {
  265. !           if (ymin < ymax) {
  266. !              ymin = ytic * floor(ymin/ytic);       
  267. !              ymax = ytic * ceil(ymax/ytic);
  268.             }
  269.             else {            /* reverse axis */
  270.                ymin = ytic * ceil(ymin/ytic);       
  271.  
  272. --- 225,233 -----
  273.          ytic = make_tics(y_min,y_max,log_y);
  274.       
  275.          if (autoscale_ly) {
  276. !           if (y_min < y_max) {
  277. !              y_min = ytic * floor(y_min/ytic);       
  278. !              y_max = ytic * ceil(y_max/ytic);
  279.             }
  280.             else {            /* reverse axis */
  281.                y_min = ytic * ceil(y_min/ytic);       
  282. ***************
  283. *** 229,236
  284.                ymax = ytic * ceil(ymax/ytic);
  285.             }
  286.             else {            /* reverse axis */
  287. !              ymin = ytic * ceil(ymin/ytic);       
  288. !              ymax = ytic * floor(ymax/ytic);
  289.             }
  290.          }
  291.       }
  292.  
  293. --- 230,237 -----
  294.                y_max = ytic * ceil(y_max/ytic);
  295.             }
  296.             else {            /* reverse axis */
  297. !              y_min = ytic * ceil(y_min/ytic);       
  298. !              y_max = ytic * floor(y_max/ytic);
  299.             }
  300.          }
  301.       }
  302. ***************
  303. *** 236,242
  304.       }
  305.   
  306.       if (xtics && xticdef.type == TIC_COMPUTED) {
  307. !        xtic = make_tics(xmin,xmax,log_x);
  308.          
  309.          if (autoscale_lx) {
  310.             if (xmin < xmax) {
  311.  
  312. --- 237,243 -----
  313.       }
  314.   
  315.       if (xtics && xticdef.type == TIC_COMPUTED) {
  316. !        xtic = make_tics(x_min,x_max,log_x);
  317.          
  318.          if (autoscale_lx) {
  319.             if (x_min < x_max) {
  320. ***************
  321. *** 239,247
  322.          xtic = make_tics(xmin,xmax,log_x);
  323.          
  324.          if (autoscale_lx) {
  325. !           if (xmin < xmax) {
  326. !              xmin = xtic * floor(xmin/xtic);    
  327. !              xmax = xtic * ceil(xmax/xtic);
  328.             } else {
  329.                xmin = xtic * ceil(xmin/xtic);
  330.                xmax = xtic * floor(xmax/xtic);    
  331.  
  332. --- 240,248 -----
  333.          xtic = make_tics(x_min,x_max,log_x);
  334.          
  335.          if (autoscale_lx) {
  336. !           if (x_min < x_max) {
  337. !              x_min = xtic * floor(x_min/xtic);    
  338. !              x_max = xtic * ceil(x_max/xtic);
  339.             } else {
  340.                x_min = xtic * ceil(x_min/xtic);
  341.                x_max = xtic * floor(x_max/xtic);    
  342. ***************
  343. *** 243,250
  344.                xmin = xtic * floor(xmin/xtic);    
  345.                xmax = xtic * ceil(xmax/xtic);
  346.             } else {
  347. !              xmin = xtic * ceil(xmin/xtic);
  348. !              xmax = xtic * floor(xmax/xtic);    
  349.             }
  350.          }
  351.       }
  352.  
  353. --- 244,251 -----
  354.                x_min = xtic * floor(x_min/xtic);    
  355.                x_max = xtic * ceil(x_max/xtic);
  356.             } else {
  357. !              x_min = xtic * ceil(x_min/xtic);
  358. !              x_max = xtic * floor(x_max/xtic);    
  359.             }
  360.          }
  361.       }
  362. ***************
  363. *** 249,259
  364.          }
  365.       }
  366.   
  367. ! /*    This used be xmax == xmin, but that caused an infinite loop once. */
  368. !     if (fabs(xmax - xmin) < zero)
  369. !         int_error("xmin should not equal xmax!",NO_CARET);
  370. !     if (fabs(ymax - ymin) < zero)
  371. !         int_error("ymin should not equal ymax!",NO_CARET);
  372.   
  373.   /* INITIALIZE TERMINAL */
  374.       if (!term_init) {
  375.  
  376. --- 250,260 -----
  377.          }
  378.       }
  379.   
  380. ! /*    This used be x_max == x_min, but that caused an infinite loop once. */
  381. !     if (fabs(x_max - x_min) < zero)
  382. !         int_error("x_min should not equal x_max!",NO_CARET);
  383. !     if (fabs(y_max - y_min) < zero)
  384. !         int_error("y_min should not equal y_max!",NO_CARET);
  385.   
  386.   /* INITIALIZE TERMINAL */
  387.       if (!term_init) {
  388. ***************
  389. *** 268,275
  390.        boundary(scaling);
  391.   
  392.   /* SCALE FACTORS */
  393. !     yscale = (ytop - ybot)/(ymax - ymin);
  394. !     xscale = (xright - xleft)/(xmax - xmin);
  395.       
  396.   /* DRAW AXES */
  397.       (*t->linetype)(-1);    /* axis line type */
  398.  
  399. --- 269,276 -----
  400.        boundary(scaling);
  401.   
  402.   /* SCALE FACTORS */
  403. !     yscale = (ytop - ybot)/(y_max - y_min);
  404. !     xscale = (xright - xleft)/(x_max - x_min);
  405.       
  406.   /* DRAW AXES */
  407.       (*t->linetype)(-1);    /* axis line type */
  408. ***************
  409. *** 297,304
  410.        if (ytics) {
  411.           switch (yticdef.type) {
  412.              case TIC_COMPUTED: {
  413. !                if (ymin < ymax)
  414. !                 draw_ytics(ytic * floor(ymin/ytic),
  415.                           ytic,
  416.                           ytic * ceil(ymax/ytic));
  417.                 else
  418.  
  419. --- 298,305 -----
  420.        if (ytics) {
  421.           switch (yticdef.type) {
  422.              case TIC_COMPUTED: {
  423. !                if (y_min < y_max)
  424. !                 draw_ytics(ytic * floor(y_min/ytic),
  425.                           ytic,
  426.                           ytic * ceil(y_max/ytic));
  427.                 else
  428. ***************
  429. *** 300,306
  430.                  if (ymin < ymax)
  431.                   draw_ytics(ytic * floor(ymin/ytic),
  432.                           ytic,
  433. !                         ytic * ceil(ymax/ytic));
  434.                 else
  435.                   draw_ytics(ytic * floor(ymax/ytic),
  436.                           ytic,
  437.  
  438. --- 301,307 -----
  439.                  if (y_min < y_max)
  440.                   draw_ytics(ytic * floor(y_min/ytic),
  441.                           ytic,
  442. !                         ytic * ceil(y_max/ytic));
  443.                 else
  444.                   draw_ytics(ytic * floor(y_max/ytic),
  445.                           ytic,
  446. ***************
  447. *** 302,308
  448.                           ytic,
  449.                           ytic * ceil(ymax/ytic));
  450.                 else
  451. !                 draw_ytics(ytic * floor(ymax/ytic),
  452.                           ytic,
  453.                           ytic * ceil(ymin/ytic));
  454.   
  455.  
  456. --- 303,309 -----
  457.                           ytic,
  458.                           ytic * ceil(y_max/ytic));
  459.                 else
  460. !                 draw_ytics(ytic * floor(y_max/ytic),
  461.                           ytic,
  462.                           ytic * ceil(y_min/ytic));
  463.   
  464. ***************
  465. *** 304,310
  466.                 else
  467.                   draw_ytics(ytic * floor(ymax/ytic),
  468.                           ytic,
  469. !                         ytic * ceil(ymin/ytic));
  470.   
  471.                 break;
  472.              }
  473.  
  474. --- 305,311 -----
  475.                 else
  476.                   draw_ytics(ytic * floor(y_max/ytic),
  477.                           ytic,
  478. !                         ytic * ceil(y_min/ytic));
  479.   
  480.                 break;
  481.              }
  482. ***************
  483. *** 309,317
  484.                 break;
  485.              }
  486.              case TIC_SERIES: {
  487. !               draw_ytics(yticdef.def.series.start, 
  488. !                       yticdef.def.series.incr, 
  489. !                       yticdef.def.series.end);
  490.                 break;
  491.              }
  492.              case TIC_USER: {
  493.  
  494. --- 310,318 -----
  495.                 break;
  496.              }
  497.              case TIC_SERIES: {
  498. !               draw_series_ytics(yticdef.def.series.start, 
  499. !                             yticdef.def.series.incr, 
  500. !                             yticdef.def.series.end);
  501.                 break;
  502.              }
  503.              case TIC_USER: {
  504. ***************
  505. *** 315,321
  506.                 break;
  507.              }
  508.              case TIC_USER: {
  509. !               draw_user_ytics(yticdef.def.user);
  510.                 break;
  511.              }
  512.              default: {
  513.  
  514. --- 316,322 -----
  515.                 break;
  516.              }
  517.              case TIC_USER: {
  518. !               draw_set_ytics(yticdef.def.user);
  519.                 break;
  520.              }
  521.              default: {
  522. ***************
  523. *** 331,338
  524.        if (xtics) {
  525.           switch (xticdef.type) {
  526.              case TIC_COMPUTED: {
  527. !                if (xmin < xmax)
  528. !                 draw_xtics(xtic * floor(xmin/xtic),
  529.                           xtic,
  530.                           xtic * ceil(xmax/xtic));
  531.                 else
  532.  
  533. --- 332,339 -----
  534.        if (xtics) {
  535.           switch (xticdef.type) {
  536.              case TIC_COMPUTED: {
  537. !                if (x_min < x_max)
  538. !                 draw_xtics(xtic * floor(x_min/xtic),
  539.                           xtic,
  540.                           xtic * ceil(x_max/xtic));
  541.                 else
  542. ***************
  543. *** 334,340
  544.                  if (xmin < xmax)
  545.                   draw_xtics(xtic * floor(xmin/xtic),
  546.                           xtic,
  547. !                         xtic * ceil(xmax/xtic));
  548.                 else
  549.                   draw_xtics(xtic * floor(xmax/xtic),
  550.                           xtic,
  551.  
  552. --- 335,341 -----
  553.                  if (x_min < x_max)
  554.                   draw_xtics(xtic * floor(x_min/xtic),
  555.                           xtic,
  556. !                         xtic * ceil(x_max/xtic));
  557.                 else
  558.                   draw_xtics(xtic * floor(x_max/xtic),
  559.                           xtic,
  560. ***************
  561. *** 336,342
  562.                           xtic,
  563.                           xtic * ceil(xmax/xtic));
  564.                 else
  565. !                 draw_xtics(xtic * floor(xmax/xtic),
  566.                           xtic,
  567.                           xtic * ceil(xmin/xtic));
  568.   
  569.  
  570. --- 337,343 -----
  571.                           xtic,
  572.                           xtic * ceil(x_max/xtic));
  573.                 else
  574. !                 draw_xtics(xtic * floor(x_max/xtic),
  575.                           xtic,
  576.                           xtic * ceil(x_min/xtic));
  577.   
  578. ***************
  579. *** 338,344
  580.                 else
  581.                   draw_xtics(xtic * floor(xmax/xtic),
  582.                           xtic,
  583. !                         xtic * ceil(xmin/xtic));
  584.   
  585.                 break;
  586.              }
  587.  
  588. --- 339,345 -----
  589.                 else
  590.                   draw_xtics(xtic * floor(x_max/xtic),
  591.                           xtic,
  592. !                         xtic * ceil(x_min/xtic));
  593.   
  594.                 break;
  595.              }
  596. ***************
  597. *** 343,351
  598.                 break;
  599.              }
  600.              case TIC_SERIES: {
  601. !               draw_xtics(xticdef.def.series.start, 
  602. !                       xticdef.def.series.incr, 
  603. !                       xticdef.def.series.end);
  604.                 break;
  605.              }
  606.              case TIC_USER: {
  607.  
  608. --- 344,352 -----
  609.                 break;
  610.              }
  611.              case TIC_SERIES: {
  612. !               draw_series_xtics(xticdef.def.series.start, 
  613. !                             xticdef.def.series.incr, 
  614. !                             xticdef.def.series.end);
  615.                 break;
  616.              }
  617.              case TIC_USER: {
  618. ***************
  619. *** 349,355
  620.                 break;
  621.              }
  622.              case TIC_USER: {
  623. !               draw_user_xtics(xticdef.def.user);
  624.                 break;
  625.              }
  626.              default: {
  627.  
  628. --- 350,356 -----
  629.                 break;
  630.              }
  631.              case TIC_USER: {
  632. !               draw_set_xtics(xticdef.def.user);
  633.                 break;
  634.              }
  635.              default: {
  636. ***************
  637. *** 551,557
  638.                break;
  639.             }
  640.             case OUTRANGE: {
  641. !              if (!inrange(plot->points[i].x, xmin,xmax))
  642.                  continue;
  643.                x = map_x(plot->points[i].x);
  644.                if ((ymin < ymax 
  645.  
  646. --- 552,558 -----
  647.                break;
  648.             }
  649.             case OUTRANGE: {
  650. !              if (!inrange(plot->points[i].x, x_min,x_max))
  651.                  continue;
  652.                x = map_x(plot->points[i].x);
  653.                if ((y_min < y_max 
  654. ***************
  655. *** 554,569
  656.                if (!inrange(plot->points[i].x, xmin,xmax))
  657.                  continue;
  658.                x = map_x(plot->points[i].x);
  659. !              if ((ymin < ymax 
  660. !                  && plot->points[i].y < ymin)
  661. !                 || (ymax < ymin 
  662. !                     && plot->points[i].y > ymin))
  663. !                y = map_y(ymin);
  664. !              if ((ymin < ymax 
  665. !                  && plot->points[i].y > ymax)
  666. !                 || (ymax<ymin 
  667. !                     && plot->points[i].y < ymax))
  668. !                y = map_y(ymax);
  669.                break;
  670.             }
  671.             default:        /* just a safety */
  672.  
  673. --- 555,570 -----
  674.                if (!inrange(plot->points[i].x, x_min,x_max))
  675.                  continue;
  676.                x = map_x(plot->points[i].x);
  677. !              if ((y_min < y_max 
  678. !                  && plot->points[i].y < y_min)
  679. !                 || (y_max < y_min 
  680. !                     && plot->points[i].y > y_min))
  681. !                y = map_y(y_min);
  682. !              if ((y_min < y_max 
  683. !                  && plot->points[i].y > y_max)
  684. !                 || (y_max<y_min 
  685. !                     && plot->points[i].y < y_max))
  686. !                y = map_y(y_max);
  687.                break;
  688.             }
  689.             default:        /* just a safety */
  690. ***************
  691. *** 699,705
  692.       int i;                /* line segment from point i-1 to point i */
  693.       double *ex, *ey;        /* the point where it crosses an edge */
  694.   {
  695. !     /* global xmin, xmax, ymin, xmax */
  696.       double ax = points[i-1].x;
  697.       double ay = points[i-1].y;
  698.       double bx = points[i].x;
  699.  
  700. --- 700,706 -----
  701.       int i;                /* line segment from point i-1 to point i */
  702.       double *ex, *ey;        /* the point where it crosses an edge */
  703.   {
  704. !     /* global x_min, x_max, y_min, x_max */
  705.       double ax = points[i-1].x;
  706.       double ay = points[i-1].y;
  707.       double bx = points[i].x;
  708. ***************
  709. *** 708,714
  710.   
  711.       if (by == ay) {
  712.          /* horizontal line */
  713. !        /* assume inrange(by, ymin, ymax) */
  714.          *ey = by;        /* == ay */
  715.   
  716.          if (inrange(xmax, ax, bx))
  717.  
  718. --- 709,715 -----
  719.   
  720.       if (by == ay) {
  721.          /* horizontal line */
  722. !        /* assume inrange(by, y_min, y_max) */
  723.          *ey = by;        /* == ay */
  724.   
  725.          if (inrange(x_max, ax, bx))
  726. ***************
  727. *** 711,720
  728.          /* assume inrange(by, ymin, ymax) */
  729.          *ey = by;        /* == ay */
  730.   
  731. !        if (inrange(xmax, ax, bx))
  732. !         *ex = xmax;
  733. !        else if (inrange(xmin, ax, bx))
  734. !         *ex = xmin;
  735.          else {
  736.           (*term_tbl[term].text)();
  737.           (void) fflush(outfile);
  738.  
  739. --- 712,721 -----
  740.          /* assume inrange(by, y_min, y_max) */
  741.          *ey = by;        /* == ay */
  742.   
  743. !        if (inrange(x_max, ax, bx))
  744. !         *ex = x_max;
  745. !        else if (inrange(x_min, ax, bx))
  746. !         *ex = x_min;
  747.          else {
  748.           (*term_tbl[term].text)();
  749.           (void) fflush(outfile);
  750. ***************
  751. *** 723,729
  752.          return;
  753.       } else if (bx == ax) {
  754.          /* vertical line */
  755. !        /* assume inrange(bx, xmin, xmax) */
  756.          *ex = bx;        /* == ax */
  757.   
  758.          if (inrange(ymax, ay, by))
  759.  
  760. --- 724,730 -----
  761.          return;
  762.       } else if (bx == ax) {
  763.          /* vertical line */
  764. !        /* assume inrange(bx, x_min, x_max) */
  765.          *ex = bx;        /* == ax */
  766.   
  767.          if (inrange(y_max, ay, by))
  768. ***************
  769. *** 726,735
  770.          /* assume inrange(bx, xmin, xmax) */
  771.          *ex = bx;        /* == ax */
  772.   
  773. !        if (inrange(ymax, ay, by))
  774. !         *ey = ymax;
  775. !        else if (inrange(ymin, ay, by))
  776. !         *ey = ymin;
  777.          else {
  778.           (*term_tbl[term].text)();
  779.           (void) fflush(outfile);
  780.  
  781. --- 727,736 -----
  782.          /* assume inrange(bx, x_min, x_max) */
  783.          *ex = bx;        /* == ax */
  784.   
  785. !        if (inrange(y_max, ay, by))
  786. !         *ey = y_max;
  787. !        else if (inrange(y_min, ay, by))
  788. !         *ey = y_min;
  789.          else {
  790.           (*term_tbl[term].text)();
  791.           (void) fflush(outfile);
  792. ***************
  793. *** 740,749
  794.   
  795.       /* slanted line of some kind */
  796.   
  797. !     /* does it intersect ymin edge */
  798. !     if (inrange(ymin, ay, by) && ymin != ay && ymin != by) {
  799. !        x = ax + (ymin-ay) * ((bx-ax) / (by-ay));
  800. !        if (inrange(x, xmin, xmax)) {
  801.             *ex = x;
  802.             *ey = ymin;
  803.             return;            /* yes */
  804.  
  805. --- 741,750 -----
  806.   
  807.       /* slanted line of some kind */
  808.   
  809. !     /* does it intersect y_min edge */
  810. !     if (inrange(y_min, ay, by) && y_min != ay && y_min != by) {
  811. !        x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  812. !        if (inrange(x, x_min, x_max)) {
  813.             *ex = x;
  814.             *ey = y_min;
  815.             return;            /* yes */
  816. ***************
  817. *** 745,751
  818.          x = ax + (ymin-ay) * ((bx-ax) / (by-ay));
  819.          if (inrange(x, xmin, xmax)) {
  820.             *ex = x;
  821. !           *ey = ymin;
  822.             return;            /* yes */
  823.          }
  824.       }
  825.  
  826. --- 746,752 -----
  827.          x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  828.          if (inrange(x, x_min, x_max)) {
  829.             *ex = x;
  830. !           *ey = y_min;
  831.             return;            /* yes */
  832.          }
  833.       }
  834. ***************
  835. *** 750,759
  836.          }
  837.       }
  838.       
  839. !     /* does it intersect ymax edge */
  840. !     if (inrange(ymax, ay, by) && ymax != ay && ymax != by) {
  841. !        x = ax + (ymax-ay) * ((bx-ax) / (by-ay));
  842. !        if (inrange(x, xmin, xmax)) {
  843.             *ex = x;
  844.             *ey = ymax;
  845.             return;            /* yes */
  846.  
  847. --- 751,760 -----
  848.          }
  849.       }
  850.       
  851. !     /* does it intersect y_max edge */
  852. !     if (inrange(y_max, ay, by) && y_max != ay && y_max != by) {
  853. !        x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  854. !        if (inrange(x, x_min, x_max)) {
  855.             *ex = x;
  856.             *ey = y_max;
  857.             return;            /* yes */
  858. ***************
  859. *** 755,761
  860.          x = ax + (ymax-ay) * ((bx-ax) / (by-ay));
  861.          if (inrange(x, xmin, xmax)) {
  862.             *ex = x;
  863. !           *ey = ymax;
  864.             return;            /* yes */
  865.          }
  866.       }
  867.  
  868. --- 756,762 -----
  869.          x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  870.          if (inrange(x, x_min, x_max)) {
  871.             *ex = x;
  872. !           *ey = y_max;
  873.             return;            /* yes */
  874.          }
  875.       }
  876. ***************
  877. *** 760,770
  878.          }
  879.       }
  880.   
  881. !     /* does it intersect xmin edge */
  882. !     if (inrange(xmin, ax, bx) && xmin != ax && xmin != bx) {
  883. !        y = ay + (xmin-ax) * ((by-ay) / (bx-ax));
  884. !        if (inrange(y, ymin, ymax)) {
  885. !           *ex = xmin;
  886.             *ey = y;
  887.             return;
  888.          }
  889.  
  890. --- 761,771 -----
  891.          }
  892.       }
  893.   
  894. !     /* does it intersect x_min edge */
  895. !     if (inrange(x_min, ax, bx) && x_min != ax && x_min != bx) {
  896. !        y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
  897. !        if (inrange(y, y_min, y_max)) {
  898. !           *ex = x_min;
  899.             *ey = y;
  900.             return;
  901.          }
  902. ***************
  903. *** 770,780
  904.          }
  905.       }
  906.   
  907. !     /* does it intersect xmax edge */
  908. !     if (inrange(xmax, ax, bx) && xmax != ax && xmax != bx) {
  909. !        y = ay + (xmax-ax) * ((by-ay) / (bx-ax));
  910. !        if (inrange(y, ymin, ymax)) {
  911. !           *ex = xmax;
  912.             *ey = y;
  913.             return;
  914.          }
  915.  
  916. --- 771,781 -----
  917.          }
  918.       }
  919.   
  920. !     /* does it intersect x_max edge */
  921. !     if (inrange(x_max, ax, bx) && x_max != ax && x_max != bx) {
  922. !        y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
  923. !        if (inrange(y, y_min, y_max)) {
  924. !           *ex = x_max;
  925.             *ey = y;
  926.             return;
  927.          }
  928. ***************
  929. *** 791,797
  930.       */
  931.       if (ax == -VERYLARGE) {
  932.          if (ay != -VERYLARGE) {
  933. !           *ex = min(xmin, xmax);
  934.             *ey = by;
  935.             return;
  936.          }
  937.  
  938. --- 792,798 -----
  939.       */
  940.       if (ax == -VERYLARGE) {
  941.          if (ay != -VERYLARGE) {
  942. !           *ex = min(x_min, x_max);
  943.             *ey = by;
  944.             return;
  945.          }
  946. ***************
  947. *** 797,803
  948.          }
  949.       } else if (bx == -VERYLARGE) {
  950.          if (by != -VERYLARGE) {
  951. !           *ex = min(xmin, xmax);
  952.             *ey = ay;
  953.             return;
  954.          }
  955.  
  956. --- 798,804 -----
  957.          }
  958.       } else if (bx == -VERYLARGE) {
  959.          if (by != -VERYLARGE) {
  960. !           *ex = min(x_min, x_max);
  961.             *ey = ay;
  962.             return;
  963.          }
  964. ***************
  965. *** 804,810
  966.       } else if (ay == -VERYLARGE) {
  967.          /* note we know ax != -VERYLARGE */
  968.          *ex = bx;
  969. !        *ey = min(ymin, ymax);
  970.          return;
  971.       } else if (by == -VERYLARGE) {
  972.          /* note we know bx != -VERYLARGE */
  973.  
  974. --- 805,811 -----
  975.       } else if (ay == -VERYLARGE) {
  976.          /* note we know ax != -VERYLARGE */
  977.          *ex = bx;
  978. !        *ey = min(y_min, y_max);
  979.          return;
  980.       } else if (by == -VERYLARGE) {
  981.          /* note we know bx != -VERYLARGE */
  982. ***************
  983. *** 809,815
  984.       } else if (by == -VERYLARGE) {
  985.          /* note we know bx != -VERYLARGE */
  986.          *ex = ax;
  987. !        *ey = min(ymin, ymax);
  988.          return;
  989.       }
  990.   
  991.  
  992. --- 810,816 -----
  993.       } else if (by == -VERYLARGE) {
  994.          /* note we know bx != -VERYLARGE */
  995.          *ex = ax;
  996. !        *ey = min(y_min, y_max);
  997.          return;
  998.       }
  999.   
  1000. ***************
  1001. *** 846,852
  1002.       int i;                /* line segment from point i-1 to point i */
  1003.       double *lx, *ly;        /* lx[2], ly[2]: points where it crosses edges */
  1004.   {
  1005. !     /* global xmin, xmax, ymin, xmax */
  1006.       double ax = points[i-1].x;
  1007.       double ay = points[i-1].y;
  1008.       double bx = points[i].x;
  1009.  
  1010. --- 847,853 -----
  1011.       int i;                /* line segment from point i-1 to point i */
  1012.       double *lx, *ly;        /* lx[2], ly[2]: points where it crosses edges */
  1013.   {
  1014. !     /* global x_min, x_max, y_min, x_max */
  1015.       double ax = points[i-1].x;
  1016.       double ay = points[i-1].y;
  1017.       double bx = points[i].x;
  1018. ***************
  1019. *** 856,865
  1020.   
  1021.       if (by == ay) {
  1022.          /* horizontal line */
  1023. !        /* y coord must be in range, and line must span both xmin and xmax */
  1024. !        /* note that spanning xmin implies spanning xmax */
  1025. !        if (inrange(by, ymin, ymax) && inrange(xmin, ax, bx)) {
  1026. !           *lx++ = xmin;
  1027.             *ly++ = by;
  1028.             *lx++ = xmax;
  1029.             *ly++ = by;
  1030.  
  1031. --- 857,866 -----
  1032.   
  1033.       if (by == ay) {
  1034.          /* horizontal line */
  1035. !        /* y coord must be in range, and line must span both x_min and x_max */
  1036. !        /* note that spanning x_min implies spanning x_max */
  1037. !        if (inrange(by, y_min, y_max) && inrange(x_min, ax, bx)) {
  1038. !           *lx++ = x_min;
  1039.             *ly++ = by;
  1040.             *lx++ = x_max;
  1041.             *ly++ = by;
  1042. ***************
  1043. *** 861,867
  1044.          if (inrange(by, ymin, ymax) && inrange(xmin, ax, bx)) {
  1045.             *lx++ = xmin;
  1046.             *ly++ = by;
  1047. !           *lx++ = xmax;
  1048.             *ly++ = by;
  1049.             return(TRUE);
  1050.          } else
  1051.  
  1052. --- 862,868 -----
  1053.          if (inrange(by, y_min, y_max) && inrange(x_min, ax, bx)) {
  1054.             *lx++ = x_min;
  1055.             *ly++ = by;
  1056. !           *lx++ = x_max;
  1057.             *ly++ = by;
  1058.             return(TRUE);
  1059.          } else
  1060. ***************
  1061. *** 868,876
  1062.           return(FALSE);
  1063.       } else if (bx == ax) {
  1064.          /* vertical line */
  1065. !        /* x coord must be in range, and line must span both ymin and ymax */
  1066. !        /* note that spanning ymin implies spanning ymax */
  1067. !        if (inrange(bx, xmin, xmax) && inrange(ymin, ay, by)) {
  1068.             *lx++ = bx;
  1069.             *ly++ = ymin;
  1070.             *lx++ = bx;
  1071.  
  1072. --- 869,877 -----
  1073.           return(FALSE);
  1074.       } else if (bx == ax) {
  1075.          /* vertical line */
  1076. !        /* x coord must be in range, and line must span both y_min and y_max */
  1077. !        /* note that spanning y_min implies spanning y_max */
  1078. !        if (inrange(bx, x_min, x_max) && inrange(y_min, ay, by)) {
  1079.             *lx++ = bx;
  1080.             *ly++ = y_min;
  1081.             *lx++ = bx;
  1082. ***************
  1083. *** 872,878
  1084.          /* note that spanning ymin implies spanning ymax */
  1085.          if (inrange(bx, xmin, xmax) && inrange(ymin, ay, by)) {
  1086.             *lx++ = bx;
  1087. !           *ly++ = ymin;
  1088.             *lx++ = bx;
  1089.             *ly++ = ymax;
  1090.             return(TRUE);
  1091.  
  1092. --- 873,879 -----
  1093.          /* note that spanning y_min implies spanning y_max */
  1094.          if (inrange(bx, x_min, x_max) && inrange(y_min, ay, by)) {
  1095.             *lx++ = bx;
  1096. !           *ly++ = y_min;
  1097.             *lx++ = bx;
  1098.             *ly++ = y_max;
  1099.             return(TRUE);
  1100. ***************
  1101. *** 874,880
  1102.             *lx++ = bx;
  1103.             *ly++ = ymin;
  1104.             *lx++ = bx;
  1105. !           *ly++ = ymax;
  1106.             return(TRUE);
  1107.          } else
  1108.           return(FALSE);
  1109.  
  1110. --- 875,881 -----
  1111.             *lx++ = bx;
  1112.             *ly++ = y_min;
  1113.             *lx++ = bx;
  1114. !           *ly++ = y_max;
  1115.             return(TRUE);
  1116.          } else
  1117.           return(FALSE);
  1118. ***************
  1119. *** 883,892
  1120.       /* slanted line of some kind */
  1121.       /* there can be only zero or two intersections below */
  1122.   
  1123. !     /* does it intersect ymin edge */
  1124. !     if (inrange(ymin, ay, by)) {
  1125. !        x = ax + (ymin-ay) * ((bx-ax) / (by-ay));
  1126. !        if (inrange(x, xmin, xmax)) {
  1127.             *lx++ = x;
  1128.             *ly++ = ymin;
  1129.             intersect = TRUE;
  1130.  
  1131. --- 884,893 -----
  1132.       /* slanted line of some kind */
  1133.       /* there can be only zero or two intersections below */
  1134.   
  1135. !     /* does it intersect y_min edge */
  1136. !     if (inrange(y_min, ay, by)) {
  1137. !        x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  1138. !        if (inrange(x, x_min, x_max)) {
  1139.             *lx++ = x;
  1140.             *ly++ = y_min;
  1141.             intersect = TRUE;
  1142. ***************
  1143. *** 888,894
  1144.          x = ax + (ymin-ay) * ((bx-ax) / (by-ay));
  1145.          if (inrange(x, xmin, xmax)) {
  1146.             *lx++ = x;
  1147. !           *ly++ = ymin;
  1148.             intersect = TRUE;
  1149.          }
  1150.       }
  1151.  
  1152. --- 889,895 -----
  1153.          x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  1154.          if (inrange(x, x_min, x_max)) {
  1155.             *lx++ = x;
  1156. !           *ly++ = y_min;
  1157.             intersect = TRUE;
  1158.          }
  1159.       }
  1160. ***************
  1161. *** 893,902
  1162.          }
  1163.       }
  1164.       
  1165. !     /* does it intersect ymax edge */
  1166. !     if (inrange(ymax, ay, by)) {
  1167. !        x = ax + (ymax-ay) * ((bx-ax) / (by-ay));
  1168. !        if (inrange(x, xmin, xmax)) {
  1169.             *lx++ = x;
  1170.             *ly++ = ymax;
  1171.             intersect = TRUE;
  1172.  
  1173. --- 894,903 -----
  1174.          }
  1175.       }
  1176.       
  1177. !     /* does it intersect y_max edge */
  1178. !     if (inrange(y_max, ay, by)) {
  1179. !        x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  1180. !        if (inrange(x, x_min, x_max)) {
  1181.             *lx++ = x;
  1182.             *ly++ = y_max;
  1183.             intersect = TRUE;
  1184. ***************
  1185. *** 898,904
  1186.          x = ax + (ymax-ay) * ((bx-ax) / (by-ay));
  1187.          if (inrange(x, xmin, xmax)) {
  1188.             *lx++ = x;
  1189. !           *ly++ = ymax;
  1190.             intersect = TRUE;
  1191.          }
  1192.       }
  1193.  
  1194. --- 899,905 -----
  1195.          x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  1196.          if (inrange(x, x_min, x_max)) {
  1197.             *lx++ = x;
  1198. !           *ly++ = y_max;
  1199.             intersect = TRUE;
  1200.          }
  1201.       }
  1202. ***************
  1203. *** 903,913
  1204.          }
  1205.       }
  1206.   
  1207. !     /* does it intersect xmin edge */
  1208. !     if (inrange(xmin, ax, bx)) {
  1209. !        y = ay + (xmin-ax) * ((by-ay) / (bx-ax));
  1210. !        if (inrange(y, ymin, ymax)) {
  1211. !           *lx++ = xmin;
  1212.             *ly++ = y;
  1213.             intersect = TRUE;
  1214.          }
  1215.  
  1216. --- 904,914 -----
  1217.          }
  1218.       }
  1219.   
  1220. !     /* does it intersect x_min edge */
  1221. !     if (inrange(x_min, ax, bx)) {
  1222. !        y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
  1223. !        if (inrange(y, y_min, y_max)) {
  1224. !           *lx++ = x_min;
  1225.             *ly++ = y;
  1226.             intersect = TRUE;
  1227.          }
  1228. ***************
  1229. *** 913,923
  1230.          }
  1231.       }
  1232.   
  1233. !     /* does it intersect xmax edge */
  1234. !     if (inrange(xmax, ax, bx)) {
  1235. !        y = ay + (xmax-ax) * ((by-ay) / (bx-ax));
  1236. !        if (inrange(y, ymin, ymax)) {
  1237. !           *lx++ = xmax;
  1238.             *ly++ = y;
  1239.             intersect = TRUE;
  1240.          }
  1241.  
  1242. --- 914,924 -----
  1243.          }
  1244.       }
  1245.   
  1246. !     /* does it intersect x_max edge */
  1247. !     if (inrange(x_max, ax, bx)) {
  1248. !        y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
  1249. !        if (inrange(y, y_min, y_max)) {
  1250. !           *lx++ = x_max;
  1251.             *ly++ = y;
  1252.             intersect = TRUE;
  1253.          }
  1254. ***************
  1255. *** 935,942
  1256.       */
  1257.       if (ax == -VERYLARGE) {
  1258.          if (ay != -VERYLARGE
  1259. !           && inrange(by, ymin, ymax) && inrange(xmax, ax, bx)) {
  1260. !           *lx++ = xmin;
  1261.             *ly = by;
  1262.             *lx++ = xmax;
  1263.             *ly = by;
  1264.  
  1265. --- 936,943 -----
  1266.       */
  1267.       if (ax == -VERYLARGE) {
  1268.          if (ay != -VERYLARGE
  1269. !           && inrange(by, y_min, y_max) && inrange(x_max, ax, bx)) {
  1270. !           *lx++ = x_min;
  1271.             *ly = by;
  1272.             *lx++ = x_max;
  1273.             *ly = by;
  1274. ***************
  1275. *** 938,944
  1276.             && inrange(by, ymin, ymax) && inrange(xmax, ax, bx)) {
  1277.             *lx++ = xmin;
  1278.             *ly = by;
  1279. !           *lx++ = xmax;
  1280.             *ly = by;
  1281.             intersect = TRUE;
  1282.          }
  1283.  
  1284. --- 939,945 -----
  1285.             && inrange(by, y_min, y_max) && inrange(x_max, ax, bx)) {
  1286.             *lx++ = x_min;
  1287.             *ly = by;
  1288. !           *lx++ = x_max;
  1289.             *ly = by;
  1290.             intersect = TRUE;
  1291.          }
  1292. ***************
  1293. *** 944,951
  1294.          }
  1295.       } else if (bx == -VERYLARGE) {
  1296.          if (by != -VERYLARGE
  1297. !           && inrange(ay, ymin, ymax) && inrange(xmax, ax, bx)) {
  1298. !           *lx++ = xmin;
  1299.             *ly = ay;
  1300.             *lx++ = xmax;
  1301.             *ly = ay;
  1302.  
  1303. --- 945,952 -----
  1304.          }
  1305.       } else if (bx == -VERYLARGE) {
  1306.          if (by != -VERYLARGE
  1307. !           && inrange(ay, y_min, y_max) && inrange(x_max, ax, bx)) {
  1308. !           *lx++ = x_min;
  1309.             *ly = ay;
  1310.             *lx++ = x_max;
  1311.             *ly = ay;
  1312. ***************
  1313. *** 947,953
  1314.             && inrange(ay, ymin, ymax) && inrange(xmax, ax, bx)) {
  1315.             *lx++ = xmin;
  1316.             *ly = ay;
  1317. !           *lx++ = xmax;
  1318.             *ly = ay;
  1319.             intersect = TRUE;
  1320.          }
  1321.  
  1322. --- 948,954 -----
  1323.             && inrange(ay, y_min, y_max) && inrange(x_max, ax, bx)) {
  1324.             *lx++ = x_min;
  1325.             *ly = ay;
  1326. !           *lx++ = x_max;
  1327.             *ly = ay;
  1328.             intersect = TRUE;
  1329.          }
  1330. ***************
  1331. *** 953,959
  1332.          }
  1333.       } else if (ay == -VERYLARGE) {
  1334.          /* note we know ax != -VERYLARGE */
  1335. !        if (inrange(bx, xmin, xmax) && inrange(ymax, ay, by)) {
  1336.             *lx++ = bx;
  1337.             *ly = ymin;
  1338.             *lx++ = bx;
  1339.  
  1340. --- 954,960 -----
  1341.          }
  1342.       } else if (ay == -VERYLARGE) {
  1343.          /* note we know ax != -VERYLARGE */
  1344. !        if (inrange(bx, x_min, x_max) && inrange(y_max, ay, by)) {
  1345.             *lx++ = bx;
  1346.             *ly = y_min;
  1347.             *lx++ = bx;
  1348. ***************
  1349. *** 955,961
  1350.          /* note we know ax != -VERYLARGE */
  1351.          if (inrange(bx, xmin, xmax) && inrange(ymax, ay, by)) {
  1352.             *lx++ = bx;
  1353. !           *ly = ymin;
  1354.             *lx++ = bx;
  1355.             *ly = ymax;
  1356.             intersect = TRUE;
  1357.  
  1358. --- 956,962 -----
  1359.          /* note we know ax != -VERYLARGE */
  1360.          if (inrange(bx, x_min, x_max) && inrange(y_max, ay, by)) {
  1361.             *lx++ = bx;
  1362. !           *ly = y_min;
  1363.             *lx++ = bx;
  1364.             *ly = y_max;
  1365.             intersect = TRUE;
  1366. ***************
  1367. *** 957,963
  1368.             *lx++ = bx;
  1369.             *ly = ymin;
  1370.             *lx++ = bx;
  1371. !           *ly = ymax;
  1372.             intersect = TRUE;
  1373.          }
  1374.       } else if (by == -VERYLARGE) {
  1375.  
  1376. --- 958,964 -----
  1377.             *lx++ = bx;
  1378.             *ly = y_min;
  1379.             *lx++ = bx;
  1380. !           *ly = y_max;
  1381.             intersect = TRUE;
  1382.          }
  1383.       } else if (by == -VERYLARGE) {
  1384. ***************
  1385. *** 962,968
  1386.          }
  1387.       } else if (by == -VERYLARGE) {
  1388.          /* note we know bx != -VERYLARGE */
  1389. !        if (inrange(ax, xmin, xmax) && inrange(ymax, ay, by)) {
  1390.             *lx++ = ax;
  1391.             *ly = ymin;
  1392.             *lx++ = ax;
  1393.  
  1394. --- 963,969 -----
  1395.          }
  1396.       } else if (by == -VERYLARGE) {
  1397.          /* note we know bx != -VERYLARGE */
  1398. !        if (inrange(ax, x_min, x_max) && inrange(y_max, ay, by)) {
  1399.             *lx++ = ax;
  1400.             *ly = y_min;
  1401.             *lx++ = ax;
  1402. ***************
  1403. *** 964,970
  1404.          /* note we know bx != -VERYLARGE */
  1405.          if (inrange(ax, xmin, xmax) && inrange(ymax, ay, by)) {
  1406.             *lx++ = ax;
  1407. !           *ly = ymin;
  1408.             *lx++ = ax;
  1409.             *ly = ymax;
  1410.             intersect = TRUE;
  1411.  
  1412. --- 965,971 -----
  1413.          /* note we know bx != -VERYLARGE */
  1414.          if (inrange(ax, x_min, x_max) && inrange(y_max, ay, by)) {
  1415.             *lx++ = ax;
  1416. !           *ly = y_min;
  1417.             *lx++ = ax;
  1418.             *ly = y_max;
  1419.             intersect = TRUE;
  1420. ***************
  1421. *** 966,972
  1422.             *lx++ = ax;
  1423.             *ly = ymin;
  1424.             *lx++ = ax;
  1425. !           *ly = ymax;
  1426.             intersect = TRUE;
  1427.          }
  1428.       }
  1429.  
  1430. --- 967,973 -----
  1431.             *lx++ = ax;
  1432.             *ly = y_min;
  1433.             *lx++ = ax;
  1434. !           *ly = y_max;
  1435.             intersect = TRUE;
  1436.          }
  1437.       }
  1438. ***************
  1439. *** 993,1002
  1440.       If not autoscaling, use the yrange for both x and y ranges.
  1441.   */
  1442.       if (autoscale_ly) {
  1443. !         xmin = VERYLARGE;
  1444. !         ymin = VERYLARGE;
  1445. !         xmax = -VERYLARGE;
  1446. !         ymax = -VERYLARGE;
  1447.           autoscale_lx = TRUE;
  1448.       } else {
  1449.           xmin = ymin;
  1450.  
  1451. --- 994,1003 -----
  1452.       If not autoscaling, use the yrange for both x and y ranges.
  1453.   */
  1454.       if (autoscale_ly) {
  1455. !         x_min = VERYLARGE;
  1456. !         y_min = VERYLARGE;
  1457. !         x_max = -VERYLARGE;
  1458. !         y_max = -VERYLARGE;
  1459.           autoscale_lx = TRUE;
  1460.       } else {
  1461.           x_min = y_min;
  1462. ***************
  1463. *** 999,1006
  1464.           ymax = -VERYLARGE;
  1465.           autoscale_lx = TRUE;
  1466.       } else {
  1467. !         xmin = ymin;
  1468. !         xmax = ymax;
  1469.       }
  1470.       
  1471.       this_plot = plots;
  1472.  
  1473. --- 1000,1007 -----
  1474.           y_max = -VERYLARGE;
  1475.           autoscale_lx = TRUE;
  1476.       } else {
  1477. !         x_min = y_min;
  1478. !         x_max = y_max;
  1479.       }
  1480.       
  1481.       this_plot = plots;
  1482. ***************
  1483. *** 1017,1026
  1484.                   pnts[i].x = x;
  1485.                   pnts[i].y = y;
  1486.                   if (autoscale_ly) {
  1487. !                     if (xmin > x) xmin = x;
  1488. !                     if (xmax < x) xmax = x;
  1489. !                     if (ymin > y) ymin = y;
  1490. !                     if (ymax < y) ymax = y;
  1491.                       pnts[i].type = INRANGE;
  1492.                   } else if(inrange(x, xmin, xmax) && inrange(y, ymin, ymax))
  1493.                     pnts[i].type = INRANGE;
  1494.  
  1495. --- 1018,1027 -----
  1496.                   pnts[i].x = x;
  1497.                   pnts[i].y = y;
  1498.                   if (autoscale_ly) {
  1499. !                     if (x_min > x) x_min = x;
  1500. !                     if (x_max < x) x_max = x;
  1501. !                     if (y_min > y) y_min = y;
  1502. !                     if (y_max < y) y_max = y;
  1503.                       pnts[i].type = INRANGE;
  1504.                   } else if(inrange(x, x_min, x_max) && inrange(y, y_min, y_max))
  1505.                     pnts[i].type = INRANGE;
  1506. ***************
  1507. *** 1022,1028
  1508.                       if (ymin > y) ymin = y;
  1509.                       if (ymax < y) ymax = y;
  1510.                       pnts[i].type = INRANGE;
  1511. !                 } else if(inrange(x, xmin, xmax) && inrange(y, ymin, ymax))
  1512.                     pnts[i].type = INRANGE;
  1513.                   else
  1514.                     pnts[i].type = OUTRANGE;
  1515.  
  1516. --- 1023,1029 -----
  1517.                       if (y_min > y) y_min = y;
  1518.                       if (y_max < y) y_max = y;
  1519.                       pnts[i].type = INRANGE;
  1520. !                 } else if(inrange(x, x_min, x_max) && inrange(y, y_min, y_max))
  1521.                     pnts[i].type = INRANGE;
  1522.                   else
  1523.                     pnts[i].type = OUTRANGE;
  1524. ***************
  1525. *** 1030,1036
  1526.           }    
  1527.       }
  1528.   
  1529. !     if (autoscale_lx && anydefined && fabs(xmax - xmin) < zero) {
  1530.           /* This happens at least for the plot of 1/cos(x) (vertical line). */
  1531.           fprintf(stderr, "Warning: empty x range [%g:%g], ", xmin,xmax);
  1532.           if (xmin == 0.0) {
  1533.  
  1534. --- 1031,1037 -----
  1535.           }    
  1536.       }
  1537.   
  1538. !     if (autoscale_lx && anydefined && fabs(x_max - x_min) < zero) {
  1539.           /* This happens at least for the plot of 1/cos(x) (vertical line). */
  1540.           fprintf(stderr, "Warning: empty x range [%g:%g], ", x_min,x_max);
  1541.           if (x_min == 0.0) {
  1542. ***************
  1543. *** 1032,1041
  1544.   
  1545.       if (autoscale_lx && anydefined && fabs(xmax - xmin) < zero) {
  1546.           /* This happens at least for the plot of 1/cos(x) (vertical line). */
  1547. !         fprintf(stderr, "Warning: empty x range [%g:%g], ", xmin,xmax);
  1548. !         if (xmin == 0.0) {
  1549. !            xmin = -1; 
  1550. !            xmax = 1;
  1551.           } else {
  1552.              xmin *= 0.9;
  1553.              xmax *= 1.1;
  1554.  
  1555. --- 1033,1042 -----
  1556.   
  1557.       if (autoscale_lx && anydefined && fabs(x_max - x_min) < zero) {
  1558.           /* This happens at least for the plot of 1/cos(x) (vertical line). */
  1559. !         fprintf(stderr, "Warning: empty x range [%g:%g], ", x_min,x_max);
  1560. !         if (x_min == 0.0) {
  1561. !            x_min = -1; 
  1562. !            x_max = 1;
  1563.           } else {
  1564.              x_min *= 0.9;
  1565.              x_max *= 1.1;
  1566. ***************
  1567. *** 1037,1044
  1568.              xmin = -1; 
  1569.              xmax = 1;
  1570.           } else {
  1571. !            xmin *= 0.9;
  1572. !            xmax *= 1.1;
  1573.           }
  1574.           fprintf(stderr, "adjusting to [%g:%g]\n", xmin,xmax);
  1575.       }
  1576.  
  1577. --- 1038,1045 -----
  1578.              x_min = -1; 
  1579.              x_max = 1;
  1580.           } else {
  1581. !            x_min *= 0.9;
  1582. !            x_max *= 1.1;
  1583.           }
  1584.           fprintf(stderr, "adjusting to [%g:%g]\n", x_min,x_max);
  1585.       }
  1586. ***************
  1587. *** 1040,1046
  1588.              xmin *= 0.9;
  1589.              xmax *= 1.1;
  1590.           }
  1591. !         fprintf(stderr, "adjusting to [%g:%g]\n", xmin,xmax);
  1592.       }
  1593.       if (autoscale_ly && anydefined && fabs(ymax - ymin) < zero) {
  1594.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1595.  
  1596. --- 1041,1047 -----
  1597.              x_min *= 0.9;
  1598.              x_max *= 1.1;
  1599.           }
  1600. !         fprintf(stderr, "adjusting to [%g:%g]\n", x_min,x_max);
  1601.       }
  1602.       if (autoscale_ly && anydefined && fabs(y_max - y_min) < zero) {
  1603.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1604. ***************
  1605. *** 1042,1048
  1606.           }
  1607.           fprintf(stderr, "adjusting to [%g:%g]\n", xmin,xmax);
  1608.       }
  1609. !     if (autoscale_ly && anydefined && fabs(ymax - ymin) < zero) {
  1610.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1611.           fprintf(stderr, "Warning: empty y range [%g:%g], ", ymin, ymax);
  1612.           if (ymin == 0.0) {
  1613.  
  1614. --- 1043,1049 -----
  1615.           }
  1616.           fprintf(stderr, "adjusting to [%g:%g]\n", x_min,x_max);
  1617.       }
  1618. !     if (autoscale_ly && anydefined && fabs(y_max - y_min) < zero) {
  1619.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1620.           fprintf(stderr, "Warning: empty y range [%g:%g], ", y_min, y_max);
  1621.           if (y_min == 0.0) {
  1622. ***************
  1623. *** 1044,1053
  1624.       }
  1625.       if (autoscale_ly && anydefined && fabs(ymax - ymin) < zero) {
  1626.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1627. !         fprintf(stderr, "Warning: empty y range [%g:%g], ", ymin, ymax);
  1628. !         if (ymin == 0.0) {
  1629. !            ymin = -1;
  1630. !            ymax = 1;
  1631.           } else {
  1632.              ymin *= 0.9;
  1633.              ymax *= 1.1;
  1634.  
  1635. --- 1045,1054 -----
  1636.       }
  1637.       if (autoscale_ly && anydefined && fabs(y_max - y_min) < zero) {
  1638.           /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  1639. !         fprintf(stderr, "Warning: empty y range [%g:%g], ", y_min, y_max);
  1640. !         if (y_min == 0.0) {
  1641. !            y_min = -1;
  1642. !            y_max = 1;
  1643.           } else {
  1644.              y_min *= 0.9;
  1645.              y_max *= 1.1;
  1646. ***************
  1647. *** 1049,1056
  1648.              ymin = -1;
  1649.              ymax = 1;
  1650.           } else {
  1651. !            ymin *= 0.9;
  1652. !            ymax *= 1.1;
  1653.           }
  1654.           fprintf(stderr, "adjusting to [%g:%g]\n", ymin, ymax);
  1655.       }
  1656.  
  1657. --- 1050,1057 -----
  1658.              y_min = -1;
  1659.              y_max = 1;
  1660.           } else {
  1661. !            y_min *= 0.9;
  1662. !            y_max *= 1.1;
  1663.           }
  1664.           fprintf(stderr, "adjusting to [%g:%g]\n", y_min, y_max);
  1665.       }
  1666. ***************
  1667. *** 1052,1058
  1668.              ymin *= 0.9;
  1669.              ymax *= 1.1;
  1670.           }
  1671. !         fprintf(stderr, "adjusting to [%g:%g]\n", ymin, ymax);
  1672.       }
  1673.   }
  1674.   
  1675.  
  1676. --- 1053,1059 -----
  1677.              y_min *= 0.9;
  1678.              y_max *= 1.1;
  1679.           }
  1680. !         fprintf(stderr, "adjusting to [%g:%g]\n", y_min, y_max);
  1681.       }
  1682.   }
  1683.   
  1684. ***************
  1685. *** 1067,1073
  1686.       double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1687.   
  1688.       if (end == VERYLARGE)            /* for user-def series */
  1689. !         end = max(ymin,ymax);
  1690.   
  1691.       /* limit to right side of plot */
  1692.       end = min(end, max(ymin,ymax));
  1693.  
  1694. --- 1068,1074 -----
  1695.       double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1696.   
  1697.       if (end == VERYLARGE)            /* for user-def series */
  1698. !         end = max(y_min,y_max);
  1699.   
  1700.       /* limit to right side of plot */
  1701.       end = min(end, max(y_min,y_max));
  1702. ***************
  1703. *** 1070,1076
  1704.           end = max(ymin,ymax);
  1705.   
  1706.       /* limit to right side of plot */
  1707. !     end = min(end, max(ymin,ymax));
  1708.   
  1709.       /* to allow for rounding errors */
  1710.       ticmin = min(ymin,ymax) - SIGNIF*incr;
  1711.  
  1712. --- 1071,1077 -----
  1713.           end = max(y_min,y_max);
  1714.   
  1715.       /* limit to right side of plot */
  1716. !     end = min(end, max(y_min,y_max));
  1717.   
  1718.       /* to allow for rounding errors */
  1719.       ticmin = min(y_min,y_max) - SIGNIF*incr;
  1720. ***************
  1721. *** 1073,1080
  1722.       end = min(end, max(ymin,ymax));
  1723.   
  1724.       /* to allow for rounding errors */
  1725. !     ticmin = min(ymin,ymax) - SIGNIF*incr;
  1726. !     ticmax = max(ymin,ymax) + SIGNIF*incr;
  1727.       end = end + SIGNIF*incr; 
  1728.   
  1729.       for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1730.  
  1731. --- 1074,1081 -----
  1732.       end = min(end, max(y_min,y_max));
  1733.   
  1734.       /* to allow for rounding errors */
  1735. !     ticmin = min(y_min,y_max) - SIGNIF*incr;
  1736. !     ticmax = max(y_min,y_max) + SIGNIF*incr;
  1737.       end = end + SIGNIF*incr; 
  1738.   
  1739.       for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1740. ***************
  1741. *** 1085,1091
  1742.               for (ltic = 2; ltic <= 9; ltic++) {
  1743.                   lticplace = ticplace+log10((double)ltic);
  1744.                   if ( inrange(lticplace,ticmin,ticmax) )
  1745. !                     ytick(lticplace, (char *)NULL, incr, 0.5);
  1746.               }
  1747.           }
  1748.       }
  1749.  
  1750. --- 1086,1092 -----
  1751.               for (ltic = 2; ltic <= 9; ltic++) {
  1752.                   lticplace = ticplace+log10((double)ltic);
  1753.                   if ( inrange(lticplace,ticmin,ticmax) )
  1754. !                     ytick(lticplace, "\0", incr, 0.5);
  1755.               }
  1756.           }
  1757.       }
  1758. ***************
  1759. *** 1091,1097
  1760.       }
  1761.   }
  1762.   
  1763.   /* DRAW_XTICS: draw a regular tic series, x axis */
  1764.   draw_xtics(start, incr, end)
  1765.           double start, incr, end; /* tic series definition */
  1766.  
  1767. --- 1092,1097 -----
  1768.       }
  1769.   }
  1770.   
  1771.   /* DRAW_XTICS: draw a regular tic series, x axis */
  1772.   draw_xtics(start, incr, end)
  1773.           double start, incr, end; /* tic series definition */
  1774. ***************
  1775. *** 1103,1109
  1776.       double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1777.   
  1778.       if (end == VERYLARGE)            /* for user-def series */
  1779. !         end = max(xmin,xmax);
  1780.   
  1781.       /* limit to right side of plot */
  1782.       end = min(end, max(xmin,xmax));
  1783.  
  1784. --- 1103,1109 -----
  1785.       double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1786.   
  1787.       if (end == VERYLARGE)            /* for user-def series */
  1788. !         end = max(x_min,x_max);
  1789.   
  1790.       /* limit to right side of plot */
  1791.       end = min(end, max(x_min,x_max));
  1792. ***************
  1793. *** 1106,1112
  1794.           end = max(xmin,xmax);
  1795.   
  1796.       /* limit to right side of plot */
  1797. !     end = min(end, max(xmin,xmax));
  1798.   
  1799.       /* to allow for rounding errors */
  1800.       ticmin = min(xmin,xmax) - SIGNIF*incr;
  1801.  
  1802. --- 1106,1112 -----
  1803.           end = max(x_min,x_max);
  1804.   
  1805.       /* limit to right side of plot */
  1806. !     end = min(end, max(x_min,x_max));
  1807.   
  1808.       /* to allow for rounding errors */
  1809.       ticmin = min(x_min,x_max) - SIGNIF*incr;
  1810. ***************
  1811. *** 1109,1116
  1812.       end = min(end, max(xmin,xmax));
  1813.   
  1814.       /* to allow for rounding errors */
  1815. !     ticmin = min(xmin,xmax) - SIGNIF*incr;
  1816. !     ticmax = max(xmin,xmax) + SIGNIF*incr;
  1817.       end = end + SIGNIF*incr; 
  1818.   
  1819.       for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1820.  
  1821. --- 1109,1116 -----
  1822.       end = min(end, max(x_min,x_max));
  1823.   
  1824.       /* to allow for rounding errors */
  1825. !     ticmin = min(x_min,x_max) - SIGNIF*incr;
  1826. !     ticmax = max(x_min,x_max) + SIGNIF*incr;
  1827.       end = end + SIGNIF*incr; 
  1828.   
  1829.       for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1830. ***************
  1831. *** 1121,1127
  1832.               for (ltic = 2; ltic <= 9; ltic++) {
  1833.                   lticplace = ticplace+log10((double)ltic);
  1834.                   if ( inrange(lticplace,ticmin,ticmax) )
  1835. !                     xtick(lticplace, (char *)NULL, incr, 0.5);
  1836.               }
  1837.           }
  1838.       }
  1839.  
  1840. --- 1121,1127 -----
  1841.               for (ltic = 2; ltic <= 9; ltic++) {
  1842.                   lticplace = ticplace+log10((double)ltic);
  1843.                   if ( inrange(lticplace,ticmin,ticmax) )
  1844. !                     xtick(lticplace, "\0", incr, 0.5);
  1845.               }
  1846.           }
  1847.       }
  1848. ***************
  1849. *** 1127,1134
  1850.       }
  1851.   }
  1852.   
  1853. ! /* DRAW_USER_YTICS: draw a user tic series, y axis */
  1854. ! draw_user_ytics(list)
  1855.       struct ticmark *list;    /* list of tic marks */
  1856.   {
  1857.       double ticplace;
  1858.  
  1859. --- 1127,1189 -----
  1860.       }
  1861.   }
  1862.   
  1863. ! /* DRAW_SERIES_YTICS: draw a user tic series, y axis */
  1864. ! draw_series_ytics(start, incr, end)
  1865. !         double start, incr, end; /* tic series definition */
  1866. !         /* assume start < end, incr > 0 */
  1867. ! {
  1868. !     double ticplace, place;
  1869. !     double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1870. !     double spacing = log_y ? log10(incr) : incr;
  1871. !     if (end == VERYLARGE)
  1872. !         end = max(CheckLog(log_y, y_min), CheckLog(log_y, y_max));
  1873. !     else
  1874. !       /* limit to right side of plot */
  1875. !       end = min(end, max(CheckLog(log_y, y_min), CheckLog(log_y, y_max)));
  1876. !     /* to allow for rounding errors */
  1877. !     ticmin = min(y_min,y_max) - SIGNIF*incr;
  1878. !     ticmax = max(y_min,y_max) + SIGNIF*incr;
  1879. !     end = end + SIGNIF*incr; 
  1880. !     for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1881. !         place = (log_y ? log10(ticplace) : ticplace);
  1882. !         if ( inrange(place,ticmin,ticmax) )
  1883. !          ytick(place, yformat, spacing, 1.0);
  1884. !     }
  1885. ! }
  1886. ! /* DRAW_SERIES_XTICS: draw a user tic series, x axis */
  1887. ! draw_series_xtics(start, incr, end)
  1888. !         double start, incr, end; /* tic series definition */
  1889. !         /* assume start < end, incr > 0 */
  1890. ! {
  1891. !     double ticplace, place;
  1892. !     double ticmin, ticmax;    /* for checking if tic is almost inrange */
  1893. !     double spacing = log_x ? log10(incr) : incr;
  1894. !     if (end == VERYLARGE)
  1895. !         end = max(CheckLog(log_x, x_min), CheckLog(log_x, x_max));
  1896. !     else
  1897. !       /* limit to right side of plot */
  1898. !       end = min(end, max(CheckLog(log_x, x_min), CheckLog(log_x, x_max)));
  1899. !     /* to allow for rounding errors */
  1900. !     ticmin = min(x_min,x_max) - SIGNIF*incr;
  1901. !     ticmax = max(x_min,x_max) + SIGNIF*incr;
  1902. !     end = end + SIGNIF*incr; 
  1903. !     for (ticplace = start; ticplace <= end; ticplace +=incr) {
  1904. !         place = (log_x ? log10(ticplace) : ticplace);
  1905. !         if ( inrange(place,ticmin,ticmax) )
  1906. !          xtick(place, xformat, spacing, 1.0);
  1907. !     }
  1908. ! }
  1909. ! /* DRAW_SET_YTICS: draw a user tic set, y axis */
  1910. ! draw_set_ytics(list)
  1911.       struct ticmark *list;    /* list of tic marks */
  1912.   {
  1913.       double ticplace;
  1914. ***************
  1915. *** 1132,1139
  1916.       struct ticmark *list;    /* list of tic marks */
  1917.   {
  1918.       double ticplace;
  1919. !     double incr = (ymax - ymin) / 10;
  1920. !     /* global xmin, xmax, xscale, ymin, ymax, yscale */
  1921.   
  1922.       while (list != NULL) {
  1923.          ticplace = list->position;
  1924.  
  1925. --- 1187,1194 -----
  1926.       struct ticmark *list;    /* list of tic marks */
  1927.   {
  1928.       double ticplace;
  1929. !     double incr = (y_max - y_min) / 10;
  1930. !     /* global x_min, x_max, xscale, y_min, y_max, yscale */
  1931.   
  1932.       while (list != NULL) {
  1933.          ticplace = (log_y ? log10(list->position) : list->position);
  1934. ***************
  1935. *** 1136,1145
  1936.       /* global xmin, xmax, xscale, ymin, ymax, yscale */
  1937.   
  1938.       while (list != NULL) {
  1939. !        ticplace = list->position;
  1940. !        if ( inrange(ticplace, ymin, ymax)         /* in range */
  1941. !           || NearlyEqual(ticplace, ymin, incr)    /* == ymin */
  1942. !           || NearlyEqual(ticplace, ymax, incr))    /* == ymax */
  1943.           ytick(ticplace, list->label, incr, 1.0);
  1944.   
  1945.          list = list->next;
  1946.  
  1947. --- 1191,1200 -----
  1948.       /* global x_min, x_max, xscale, y_min, y_max, yscale */
  1949.   
  1950.       while (list != NULL) {
  1951. !        ticplace = (log_y ? log10(list->position) : list->position);
  1952. !        if ( inrange(ticplace, y_min, y_max)         /* in range */
  1953. !           || NearlyEqual(ticplace, y_min, incr)    /* == y_min */
  1954. !           || NearlyEqual(ticplace, y_max, incr))    /* == y_max */
  1955.           ytick(ticplace, list->label, incr, 1.0);
  1956.   
  1957.          list = list->next;
  1958. ***************
  1959. *** 1146,1153
  1960.       }
  1961.   }
  1962.   
  1963. ! /* DRAW_USER_XTICS: draw a user tic series, x axis */
  1964. ! draw_user_xtics(list)
  1965.       struct ticmark *list;    /* list of tic marks */
  1966.   {
  1967.       double ticplace;
  1968.  
  1969. --- 1201,1208 -----
  1970.       }
  1971.   }
  1972.   
  1973. ! /* DRAW_SET_XTICS: draw a user tic set, x axis */
  1974. ! draw_set_xtics(list)
  1975.       struct ticmark *list;    /* list of tic marks */
  1976.   {
  1977.       double ticplace;
  1978. ***************
  1979. *** 1151,1158
  1980.       struct ticmark *list;    /* list of tic marks */
  1981.   {
  1982.       double ticplace;
  1983. !     double incr = (xmax - xmin) / 10;
  1984. !     /* global xmin, xmax, xscale, ymin, ymax, yscale */
  1985.   
  1986.       while (list != NULL) {
  1987.          ticplace = list->position;
  1988.  
  1989. --- 1206,1213 -----
  1990.       struct ticmark *list;    /* list of tic marks */
  1991.   {
  1992.       double ticplace;
  1993. !     double incr = (x_max - x_min) / 10;
  1994. !     /* global x_min, x_max, xscale, y_min, y_max, yscale */
  1995.   
  1996.       while (list != NULL) {
  1997.          ticplace = (log_x ? log10(list->position) : list->position);
  1998. ***************
  1999. *** 1155,1164
  2000.       /* global xmin, xmax, xscale, ymin, ymax, yscale */
  2001.   
  2002.       while (list != NULL) {
  2003. !        ticplace = list->position;
  2004. !        if ( inrange(ticplace, xmin, xmax)         /* in range */
  2005. !           || NearlyEqual(ticplace, xmin, incr)    /* == xmin */
  2006. !           || NearlyEqual(ticplace, xmax, incr))    /* == xmax */
  2007.           xtick(ticplace, list->label, incr, 1.0);
  2008.   
  2009.          list = list->next;
  2010.  
  2011. --- 1210,1219 -----
  2012.       /* global x_min, x_max, xscale, y_min, y_max, yscale */
  2013.   
  2014.       while (list != NULL) {
  2015. !        ticplace = (log_x ? log10(list->position) : list->position);
  2016. !        if ( inrange(ticplace, x_min, x_max)         /* in range */
  2017. !           || NearlyEqual(ticplace, x_min, incr)    /* == x_min */
  2018. !           || NearlyEqual(ticplace, x_max, incr))    /* == x_max */
  2019.           xtick(ticplace, list->label, incr, 1.0);
  2020.   
  2021.          list = list->next;
  2022. ***************
  2023. *** 1194,1209
  2024.       }
  2025.   
  2026.       /* label the ticmark */
  2027. !     if (text) {
  2028. !         (void) sprintf(ticlabel, text, CheckLog(log_y, place));
  2029. !         if ((*t->justify_text)(RIGHT)) {
  2030. !            (*t->put_text)(xleft-(t->h_char),
  2031. !                        map_y(place), ticlabel);
  2032. !         } else {
  2033. !            (*t->put_text)(xleft-(t->h_char)*(strlen(ticlabel)+1),
  2034. !                        map_y(place), ticlabel);
  2035. !         }
  2036. !     }
  2037.   }
  2038.   
  2039.   /* draw and label an x-axis ticmark */
  2040.  
  2041. --- 1249,1265 -----
  2042.       }
  2043.   
  2044.       /* label the ticmark */
  2045. !     if (text == NULL) 
  2046. !      text = yformat;
  2047. !     
  2048. !     (void) sprintf(ticlabel, text, CheckLog(log_y, place));
  2049. !     if ((*t->justify_text)(RIGHT)) {
  2050. !        (*t->put_text)(xleft-(t->h_char),
  2051. !                    map_y(place), ticlabel);
  2052. !     } else {
  2053. !        (*t->put_text)(xleft-(t->h_char)*(strlen(ticlabel)+1),
  2054. !                    map_y(place), ticlabel);
  2055. !     }
  2056.   }
  2057.   
  2058.   /* draw and label an x-axis ticmark */
  2059. ***************
  2060. *** 1233,1239
  2061.              (*t->move)(map_x(place), ybot);
  2062.              (*t->vector)(map_x(place), ybot - ticsize);
  2063.       }
  2064.       /* label the ticmark */
  2065.       if (text) {
  2066.          (void) sprintf(ticlabel, text, CheckLog(log_x, place));
  2067.  
  2068. --- 1289,1295 -----
  2069.              (*t->move)(map_x(place), ybot);
  2070.              (*t->vector)(map_x(place), ybot - ticsize);
  2071.       }
  2072. !     
  2073.       /* label the ticmark */
  2074.       if (text == NULL)
  2075.        text = xformat;
  2076. ***************
  2077. *** 1235,1248
  2078.       }
  2079.   
  2080.       /* label the ticmark */
  2081. !     if (text) {
  2082. !        (void) sprintf(ticlabel, text, CheckLog(log_x, place));
  2083. !        if ((*t->justify_text)(CENTRE)) {
  2084. !           (*t->put_text)(map_x(place),
  2085. !                       ybot-(t->v_char), ticlabel);
  2086. !        } else {
  2087. !           (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
  2088. !                       ybot-(t->v_char), ticlabel);
  2089. !        }
  2090.       }
  2091.   }
  2092.  
  2093. --- 1291,1305 -----
  2094.       }
  2095.       
  2096.       /* label the ticmark */
  2097. !     if (text == NULL)
  2098. !      text = xformat;
  2099. !     (void) sprintf(ticlabel, text, CheckLog(log_x, place));
  2100. !     if ((*t->justify_text)(CENTRE)) {
  2101. !        (*t->put_text)(map_x(place),
  2102. !                    ybot-(t->v_char), ticlabel);
  2103. !     } else {
  2104. !        (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
  2105. !                    ybot-(t->v_char), ticlabel);
  2106.       }
  2107.   }
  2108. diff -cr ./docs/gnuplot.1 ../patch/docs/gnuplot.1
  2109. *** ./docs/gnuplot.1    Tue Mar 27 08:59:42 1990
  2110. --- ../patch/docs/gnuplot.1    Thu Sep  6 09:59:07 1990
  2111. ***************
  2112. *** 1,5
  2113.   .\" dummy line
  2114. ! .TH GNUPLOT 1 "13 February 1990"
  2115.   .UC 4
  2116.   .SH NAME
  2117.   gnuplot \- an interactive plotting program
  2118.  
  2119. --- 1,5 -----
  2120.   .\" dummy line
  2121. ! .TH GNUPLOT 1 "31 August 1990"
  2122.   .UC 4
  2123.   .SH NAME
  2124.   gnuplot \- an interactive plotting program
  2125. ***************
  2126. *** 4,10
  2127.   .SH NAME
  2128.   gnuplot \- an interactive plotting program
  2129.   .SH SYNOPSIS
  2130. ! .B gnuplot  file ...
  2131.   .br
  2132.   .SH DESCRIPTION
  2133.   .I Gnuplot 
  2134.  
  2135. --- 4,11 -----
  2136.   .SH NAME
  2137.   gnuplot \- an interactive plotting program
  2138.   .SH SYNOPSIS
  2139. ! .B gnuplot
  2140. ! [ X11 options ] [file ...]
  2141.   .br
  2142.   .SH DESCRIPTION
  2143.   .I Gnuplot 
  2144. ***************
  2145. *** 38,43
  2146.   BBN BitGraph,
  2147.   Roland DXY800A,
  2148.   EEPIC,
  2149.   Epson LX-800,
  2150.   Fig, 
  2151.   HP2623,
  2152.  
  2153. --- 39,46 -----
  2154.   BBN BitGraph,
  2155.   Roland DXY800A,
  2156.   EEPIC,
  2157. + EmTeX,
  2158. + Epson 60dpi printers,
  2159.   Epson LX-800,
  2160.   Fig, 
  2161.   HP2623,
  2162. ***************
  2163. *** 54,59
  2164.   QMS QUIC,
  2165.   ReGis (VT125 and VT2xx),
  2166.   Selanar,
  2167.   Tek 401x,
  2168.   Vectrix 384,
  2169.   and unixplot.  
  2170.  
  2171. --- 57,64 -----
  2172.   QMS QUIC,
  2173.   ReGis (VT125 and VT2xx),
  2174.   Selanar,
  2175. + Star color printer,
  2176. + Tandy DMP-130 printer,
  2177.   Tek 401x,
  2178.   Tek 410x,
  2179.   Vectrix 384,
  2180. ***************
  2181. *** 55,60
  2182.   ReGis (VT125 and VT2xx),
  2183.   Selanar,
  2184.   Tek 401x,
  2185.   Vectrix 384,
  2186.   and unixplot.  
  2187.   The PC version compiled by Microsoft C
  2188.  
  2189. --- 60,66 -----
  2190.   Star color printer,
  2191.   Tandy DMP-130 printer,
  2192.   Tek 401x,
  2193. + Tek 410x,
  2194.   Vectrix 384,
  2195.   Unix PC (ATT 3b1 or ATT 7300)
  2196.   unixplot,  
  2197. ***************
  2198. *** 56,62
  2199.   Selanar,
  2200.   Tek 401x,
  2201.   Vectrix 384,
  2202. ! and unixplot.  
  2203.   The PC version compiled by Microsoft C
  2204.   supports IBM CGA, EGA, VGA, Hercules, ATT 6300,
  2205.   and Corona 325 graphics.  
  2206.  
  2207. --- 62,70 -----
  2208.   Tek 401x,
  2209.   Tek 410x,
  2210.   Vectrix 384,
  2211. ! Unix PC (ATT 3b1 or ATT 7300)
  2212. ! unixplot,  
  2213. ! and X11.
  2214.   The PC version compiled by Microsoft C
  2215.   supports IBM CGA, EGA, VGA, Hercules, ATT 6300,
  2216.   and Corona 325 graphics.  
  2217. ***************
  2218. *** 61,67
  2219.   supports IBM CGA, EGA, VGA, Hercules, ATT 6300,
  2220.   and Corona 325 graphics.  
  2221.   The PC version compiled by Turbo C
  2222. ! supports IBM CGA, EGA, MCGA, VGA and Hercules graphics.  
  2223.   Other devices can be added simply, but will require recompiling.
  2224.   .PP
  2225.   Shell escapes and command line substitution.
  2226.  
  2227. --- 69,75 -----
  2228.   supports IBM CGA, EGA, VGA, Hercules, ATT 6300,
  2229.   and Corona 325 graphics.  
  2230.   The PC version compiled by Turbo C
  2231. ! supports IBM CGA, EGA, MCGA, VGA, Hercules and ATT 6300 graphics.  
  2232.   Other devices can be added simply, but will require recompiling.
  2233.   .PP
  2234.   Shell escapes and command line substitution.
  2235. ***************
  2236. *** 73,78
  2237.   All computations performed in the complex domain.  Just the real part is
  2238.   plotted by default, but functions like imag() and abs() and arg() are
  2239.   available to override this.
  2240.   .SH AUTHORS
  2241.   Thomas Williams, Pixar Corporation, 
  2242.   .br
  2243.  
  2244. --- 81,123 -----
  2245.   All computations performed in the complex domain.  Just the real part is
  2246.   plotted by default, but functions like imag() and abs() and arg() are
  2247.   available to override this.
  2248. + .SH X11 OPTIONS
  2249. + .I Gnuplot 
  2250. + provides two terminal types (\fIx11\fP and \fIX11\fP) for use
  2251. + with X servers. The \fIX11\fP terminal type provides differing colors as well 
  2252. + as shapes for the \fIpoints\fP plotting style. The two types are otherwise 
  2253. + identical.  When used with either of these terminal types, \fIgnuplot\fP
  2254. + honors all the standard X Toolkit options and resources such as geometry, font,
  2255. + foreground and background. See the X(1) man page for a description of
  2256. + the options. For color or grayscale displays \fIgnuplot\fP also honors 
  2257. + the following resources (shown here with default values):
  2258. + .sp
  2259. + .B  "gnuplot*textColor: black"
  2260. + .br 
  2261. + .B  "gnuplot*borderColor: black"
  2262. + .br 
  2263. + .B  "gnuplot*axisColor: black"
  2264. + .br 
  2265. + .B  "gnuplot*line1Color: red"
  2266. + .br 
  2267. + .B  "gnuplot*line2Color: green"
  2268. + .br 
  2269. + .B  "gnuplot*line3Color: blue"
  2270. + .br 
  2271. + .B  "gnuplot*line4Color: magenta"
  2272. + .br 
  2273. + .B  "gnuplot*line5Color: cyan"
  2274. + .br 
  2275. + .B  "gnuplot*line6Color: sienna"
  2276. + .br 
  2277. + .B  "gnuplot*line7Color: orange"
  2278. + .br 
  2279. + .B  "gnuplot*line8Color: coral"
  2280. + .br 
  2281. + .PP
  2282. + The size or aspect ratio of a plot may be changed by resizing the
  2283. + .I gnuplot
  2284. + window.
  2285.   .SH AUTHORS
  2286.   Thomas Williams, Pixar Corporation, 
  2287.   .br
  2288. ***************
  2289. *** 87,92
  2290.   Further additions by David Kotz, Duke University, North Carolina, USA. 
  2291.   .br
  2292.   (dfk@cs.duke.edu)
  2293.   .SH BUGS
  2294.   The atan() function does not work correctly for complex arguments.
  2295.   .br
  2296.  
  2297. --- 132,139 -----
  2298.   Further additions by David Kotz, Duke University, North Carolina, USA. 
  2299.   .br
  2300.   (dfk@cs.duke.edu)
  2301. + .br
  2302. + X11 support by Ed Kubaitis, University of Illinois, USA.
  2303.   .SH BUGS
  2304.   The atan() function does not work correctly for complex arguments.
  2305.   .br
  2306. ***************
  2307. *** 90,95
  2308.   .SH BUGS
  2309.   The atan() function does not work correctly for complex arguments.
  2310.   .br
  2311.   See the 
  2312.   .I help bugs
  2313.   command in gnuplot.
  2314.  
  2315. --- 137,144 -----
  2316.   .SH BUGS
  2317.   The atan() function does not work correctly for complex arguments.
  2318.   .br
  2319. + The bessel functions do not work for complex arguments.
  2320. + .br
  2321.   See the 
  2322.   .I help bugs
  2323.   command in gnuplot.
  2324. ***************
  2325. *** 95,97
  2326.   command in gnuplot.
  2327.   .SH SEE ALSO
  2328.   See the printed manual or the on-line help for details on specific commands.
  2329.  
  2330. --- 144,148 -----
  2331.   command in gnuplot.
  2332.   .SH SEE ALSO
  2333.   See the printed manual or the on-line help for details on specific commands.
  2334. + .br
  2335. + X(1).
  2336. diff -cr ./docs/gnuplot.doc ../patch/docs/gnuplot.doc
  2337. *** ./docs/gnuplot.doc    Tue Mar 27 08:59:55 1990
  2338. --- ../patch/docs/gnuplot.doc    Wed Sep 12 17:36:14 1990
  2339. ***************
  2340. *** 21,26
  2341.    many commands.
  2342.   
  2343.    For help on any topic, type 'help' followed by the name of the topic.
  2344.   2 clear
  2345.   ?clear
  2346.    The `clear` command erases the current screen or output device as
  2347.  
  2348. --- 21,39 -----
  2349.    many commands.
  2350.   
  2351.    For help on any topic, type 'help' followed by the name of the topic.
  2352. + 2 cd
  2353. + ?cd
  2354. +  The `cd` command changes working directory.
  2355. +  
  2356. +  Syntax:
  2357. +          cd <directory-name>
  2358. +  
  2359. +  The directory name must be enclosed in quotes.
  2360. +  
  2361. +  Examples:
  2362. +  
  2363. +          cd 'subdir'
  2364. +          cd ".."
  2365.   2 clear
  2366.   ?clear
  2367.    The `clear` command erases the current screen or output device as
  2368. ***************
  2369. *** 30,36
  2370.   ?comments
  2371.    Comments are supported as follows: a # may appear in most places in a line
  2372.    and GNUPLOT will ignore the rest of the line. It will not have this
  2373. !  affect inside quotes, inside numbers (including complex numbers), inside
  2374.    command substitutions, etc. In short, it works anywhere it makes sense
  2375.    to work.
  2376.   2 environment
  2377.  
  2378. --- 43,49 -----
  2379.   ?comments
  2380.    Comments are supported as follows: a # may appear in most places in a line
  2381.    and GNUPLOT will ignore the rest of the line. It will not have this
  2382. !  effect inside quotes, inside numbers (including complex numbers), inside
  2383.    command substitutions, etc. In short, it works anywhere it makes sense
  2384.    to work.
  2385.   2 environment
  2386. ***************
  2387. *** 49,56
  2388.    On VMS, the symbol GNUPLOT$HELP should be defined as the name of 
  2389.    the help library for gnuplot.
  2390.    
  2391. !  On Unix, HOME is used as the name of a directory to search for a 
  2392. !  .gnuplot file if none is found in the current directory. 
  2393.    On MS-DOS, GNUPLOT is used.  On VMS, SYS$LOGIN: is used.  
  2394.    See help start-up.  
  2395.    
  2396.  
  2397. --- 62,69 -----
  2398.    On VMS, the symbol GNUPLOT$HELP should be defined as the name of 
  2399.    the help library for gnuplot.
  2400.    
  2401. !  On Unix, HOME is used as the name of a directory to search for 
  2402. !  a .gnuplot file if none is found in the current directory. 
  2403.    On MS-DOS, GNUPLOT is used.  On VMS, SYS$LOGIN: is used.  
  2404.    See help start-up.  
  2405.    
  2406. ***************
  2407. *** 653,658
  2408.            print <expression>
  2409.    
  2410.    See `expressions`.
  2411.   2 quit
  2412.   ?quit
  2413.    The `exit` and `quit` commands and your computer's END-OF-FILE
  2414.  
  2415. --- 666,677 -----
  2416.            print <expression>
  2417.    
  2418.    See `expressions`.
  2419. + 2 pwd
  2420. + ?pwd
  2421. +  The `pwd` command prints the name of the working directory to the screen.
  2422. +  
  2423. +  Syntax:
  2424. +          pwd
  2425.   2 quit
  2426.   ?quit
  2427.    The `exit` and `quit` commands and your computer's END-OF-FILE
  2428. ***************
  2429. *** 1400,1405
  2430.   ?bugs
  2431.    The atan() function does not work correctly for complex arguments.
  2432.    
  2433.    The most important known bug is actually in the stdio library for the
  2434.    Sun4 operating system (SunOS Sys4-3.2). The "%g" format for `printf`
  2435.    sometimes incorrectly prints numbers (e.g., 200000.0 as "2").  Thus,
  2436.  
  2437. --- 1419,1426 -----
  2438.   ?bugs
  2439.    The atan() function does not work correctly for complex arguments.
  2440.    
  2441. +  The bessel functions do not work for complex arguments.
  2442. +  
  2443.    The most important known bug is actually in the stdio library for the
  2444.    Sun4 operating system (SunOS Sys4-3.2). The "%g" format for `printf`
  2445.    sometimes incorrectly prints numbers (e.g., 200000.0 as "2").  Thus,
  2446. ***************
  2447. *** 1446,1448
  2448.    %g format than release 2.4, but not much.  Trailing decimal points are 
  2449.    now removed, but trailing zeros are still not removed from %g numbers 
  2450.    in exponential format.
  2451.  
  2452. --- 1467,1472 -----
  2453.    %g format than release 2.4, but not much.  Trailing decimal points are 
  2454.    now removed, but trailing zeros are still not removed from %g numbers 
  2455.    in exponential format.
  2456. +  
  2457. +  Please report any bugs you find to pixar!bug-gnuplot@sun.com or
  2458. +  pixar!bug-gnuplot@ucbvax.berkeley.edu.
  2459. Common subdirectories: ./docs/latextut and ../patch/docs/latextut
  2460. diff -cr ./docs/latextut/tutorial.tex ../patch/docs/latextut/tutorial.tex
  2461. *** ./docs/latextut/tutorial.tex    Tue Mar 27 09:00:42 1990
  2462. --- ../patch/docs/latextut/tutorial.tex    Tue Aug 28 16:17:28 1990
  2463. ***************
  2464. *** 57,62
  2465.   and may produce better-looking plots. See Section~\ref{s:eepic} for
  2466.   more information.
  2467.   
  2468.   \section{Using GNUPLOT for \LaTeX: a Tutorial}
  2469.   
  2470.   GNUPLOT is by nature an interactive program. Users making plots for
  2471.  
  2472. --- 57,68 -----
  2473.   and may produce better-looking plots. See Section~\ref{s:eepic} for
  2474.   more information.
  2475.   
  2476. + There is a small package of auxiliary files (makefiles and scripts)
  2477. + that I find useful for making \LaTeX\ plots with GNUPLOT. This is
  2478. + available for \verb+ftp+ as \verb+pub/gnuplot-latex.shar+ from
  2479. + \verb+cs.duke.edu+. I can mail copies (see the end of this paper for
  2480. + information).
  2481.   \section{Using GNUPLOT for \LaTeX: a Tutorial}
  2482.   
  2483.   GNUPLOT is by nature an interactive program. Users making plots for
  2484. ***************
  2485. *** 500,505
  2486.   may be changed.
  2487.   
  2488.   \section{Contact}
  2489. ! Please contact me at dfk@cs.duke.edu with any comments you may have.
  2490.   
  2491.   \end{document}
  2492.  
  2493. --- 506,515 -----
  2494.   may be changed.
  2495.   
  2496.   \section{Contact}
  2497. ! Please contact me at \verb+dfk@cs.duke.edu+ with any comments you may
  2498. ! have on GNUPLOT's \LaTeX\ driver. For general GNUPLOT questions, send
  2499. ! mail to the GNUPLOT mailing list
  2500. ! (\verb+pixar!info-gnuplot@ucbvax.berkeley.edu+). 
  2501.   
  2502.   \end{document}
  2503. diff -c ./translate/command.c ../patch/translate/command.c
  2504. *** ./translate/command.c    Tue Mar 27 09:03:58 1990
  2505. --- ../patch/translate/command.c    Tue Aug 28 16:07:33 1990
  2506. ***************
  2507. *** 983,989
  2508.       err_msg(message);
  2509.   
  2510.       if (point && line)
  2511. !      return(LINESPOINTS);
  2512.       if (point)
  2513.        return(POINTS);
  2514.       if (line)
  2515.  
  2516. --- 983,989 -----
  2517.       err_msg(message);
  2518.   
  2519.       if (point && line)
  2520. !      return((int)LINESPOINTS);
  2521.       if (point)
  2522.        return((int)POINTS);
  2523.       if (line)
  2524. ***************
  2525. *** 985,991
  2526.       if (point && line)
  2527.        return(LINESPOINTS);
  2528.       if (point)
  2529. !      return(POINTS);
  2530.       if (line)
  2531.        return(LINES);
  2532.   
  2533.  
  2534. --- 985,991 -----
  2535.       if (point && line)
  2536.        return((int)LINESPOINTS);
  2537.       if (point)
  2538. !      return((int)POINTS);
  2539.       if (line)
  2540.        return((int)LINES);
  2541.   
  2542. ***************
  2543. *** 987,993
  2544.       if (point)
  2545.        return(POINTS);
  2546.       if (line)
  2547. !      return(LINES);
  2548.   
  2549.       /* should not happen */
  2550.       err_msg("no standard style corresponds to this style");
  2551.  
  2552. --- 987,993 -----
  2553.       if (point)
  2554.        return((int)POINTS);
  2555.       if (line)
  2556. !      return((int)LINES);
  2557.   
  2558.       /* should not happen */
  2559.       err_msg("no standard style corresponds to this style");
  2560. ***************
  2561. *** 991,997
  2562.   
  2563.       /* should not happen */
  2564.       err_msg("no standard style corresponds to this style");
  2565. !     return(LINES);
  2566.   }
  2567.   
  2568.   
  2569.  
  2570. --- 991,997 -----
  2571.   
  2572.       /* should not happen */
  2573.       err_msg("no standard style corresponds to this style");
  2574. !     return((int)LINES);
  2575.   }
  2576.   
  2577.   
  2578.