home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / sc / patch04b < prev    next >
Encoding:
Text File  |  1992-05-23  |  43.4 KB  |  1,840 lines

  1. Newsgroups: comp.sources.misc
  2. From: prslnk!buhrt@iuvax.cs.indiana.edu (Jeff Buhrt)
  3. Subject:  v30i021:  sc - The SC Spreadsheet, Patch04b/2
  4. Message-ID: <1992May24.043856.23893@sparky.imd.sterling.com>
  5. X-Md4-Signature: cb39943d64c124c3cee8d440da2893b1
  6. Date: Sun, 24 May 1992 04:38:56 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: prslnk!buhrt@iuvax.cs.indiana.edu (Jeff Buhrt)
  10. Posting-number: Volume 30, Issue 21
  11. Archive-name: sc/patch04b
  12. Environment: UNIX, VMS, MS-DOS
  13. Patch-To: sc: Volume 20, Issue 35-41
  14.  
  15. *** ../619/interp.c    Mon Mar 16 10:09:40 1992
  16. --- interp.c    Fri May  8 12:31:27 1992
  17. ***************
  18. *** 7,13 ****
  19.    *
  20.    *              More mods Robert Bond, 12/86
  21.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  22. !  *        $Revision: 6.19 $
  23.    */
  24.   
  25.   #define DEBUGDTS 1        /* REMOVE ME */
  26. --- 7,13 ----
  27.    *
  28.    *              More mods Robert Bond, 12/86
  29.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  30. !  *        $Revision: 6.21 $
  31.    */
  32.   
  33.   #define DEBUGDTS 1        /* REMOVE ME */
  34. ***************
  35. *** 53,66 ****
  36.   #endif
  37.   
  38.   #ifdef SIGVOID
  39. !     void quit();
  40.   #else
  41. !     int quit();
  42.   #endif
  43.   
  44. - /* Suffixes for engineering notation THA 9/19/88 */
  45. - extern char engmult[];
  46.   /* Use this structure to save the the last 'g' command */
  47.   struct go_save {
  48.       int g_type;
  49. --- 53,63 ----
  50.   #endif
  51.   
  52.   #ifdef SIGVOID
  53. !     void doquit();
  54.   #else
  55. !     int doquit();
  56.   #endif
  57.   
  58.   /* Use this structure to save the the last 'g' command */
  59.   struct go_save {
  60.       int g_type;
  61. ***************
  62. *** 113,119 ****
  63. --- 110,118 ----
  64.   double    rint();
  65.   int    cellerror = CELLOK;    /* is there an error in this cell */
  66.   
  67. + #ifndef PI
  68.   #define PI (double)3.14159265358979323846
  69. + #endif
  70.   #define dtr(x) ((x)*(PI/(double)180.0))
  71.   #define rtd(x) ((x)*(180.0/(double)PI))
  72.   
  73. ***************
  74. *** 189,195 ****
  75.       }
  76.   
  77.       if (p && p->label) {
  78. !     pr = xmalloc((unsigned)(strlen(p->label)+1));
  79.       (void) strcpy(pr, p->label);
  80.       if (p->cellerror)
  81.           cellerror = CELLINVALID;
  82. --- 188,194 ----
  83.       }
  84.   
  85.       if (p && p->label) {
  86. !     pr = scxmalloc((unsigned)(strlen(p->label)+1));
  87.       (void) strcpy(pr, p->label);
  88.       if (p->cellerror)
  89.           cellerror = CELLINVALID;
  90. ***************
  91. *** 293,299 ****
  92.       }
  93.       if ( p && p->flags&is_valid)
  94.           ret = p->v;
  95. !     xfree(s);
  96.       }
  97.       return ret;
  98.   }
  99. --- 292,298 ----
  100.       }
  101.       if ( p && p->flags&is_valid)
  102.           ret = p->v;
  103. !     scxfree(s);
  104.       }
  105.       return ret;
  106.   }
  107. ***************
  108. *** 598,604 ****
  109.       return((double)0);
  110.   
  111.       (void)strtof(s, &v);
  112. !     xfree(s);
  113.       return(v);
  114.   }
  115.   
  116. --- 597,603 ----
  117.       return((double)0);
  118.   
  119.       (void)strtof(s, &v);
  120. !     scxfree(s);
  121.       return(v);
  122.   }
  123.   
  124. ***************
  125. *** 619,628 ****
  126.       v = 0.0;
  127.   
  128.       if (s1)
  129. !         xfree(s1);
  130.   
  131.       if (s2)
  132. !         xfree(s2);
  133.   
  134.       return(v);
  135.   }
  136. --- 618,627 ----
  137.       v = 0.0;
  138.   
  139.       if (s1)
  140. !         scxfree(s1);
  141.   
  142.       if (s2)
  143. !         scxfree(s2);
  144.   
  145.       return(v);
  146.   }
  147. ***************
  148. *** 630,637 ****
  149.   
  150.   /*
  151.    * Given a string representing a column name and a value which is a column
  152. !  * number, return a pointer to the selected cell's entry, if any, else 0.  Use
  153. !  * only the integer part of the column number.  Always free the string.
  154.    */
  155.   
  156.   struct ent *
  157. --- 629,636 ----
  158.   
  159.   /*
  160.    * Given a string representing a column name and a value which is a column
  161. !  * number, return a pointer to the selected cell's entry, if any, else NULL.
  162. !  * Use only the integer part of the column number.  Always free the string.
  163.    */
  164.   
  165.   struct ent *
  166. ***************
  167. *** 655,664 ****
  168.        && (col < maxcols))            /* in range */
  169.       {
  170.       p = *ATBL(tbl, row, col);
  171. !     if (p->cellerror)
  172.           cellerror = CELLINVALID;
  173.       }
  174. !     xfree (colstr);
  175.       return (p);
  176.   }
  177.   
  178. --- 654,663 ----
  179.        && (col < maxcols))            /* in range */
  180.       {
  181.       p = *ATBL(tbl, row, col);
  182. !     if ((p != NULL) && p->cellerror)
  183.           cellerror = CELLINVALID;
  184.       }
  185. !     scxfree (colstr);
  186.       return (p);
  187.   }
  188.   
  189. ***************
  190. *** 897,902 ****
  191. --- 896,902 ----
  192.       case NVAL:      return (donval(seval(e->e.o.left),eval(e->e.o.right)));
  193.       case MYROW:    return ((double) gmyrow);
  194.       case MYCOL:    return ((double) gmycol);
  195. +     case NUMITER:    return ((double) repct);
  196.       default:    error ("Illegal numeric expression");
  197.               exprerr = 1;
  198.       }
  199. ***************
  200. *** 955,961 ****
  201.   
  202.   /* 
  203.    * Rules for string functions:
  204. !  * Take string arguments which they xfree.
  205.    * All returned strings are assumed to be xalloced.
  206.    */
  207.   
  208. --- 955,961 ----
  209.   
  210.   /* 
  211.    * Rules for string functions:
  212. !  * Take string arguments which they scxfree.
  213.    * All returned strings are assumed to be xalloced.
  214.    */
  215.   
  216. ***************
  217. *** 970,982 ****
  218.       return((char *)0);
  219.       arg1 = s1 ? s1 : "";
  220.       arg2 = s2 ? s2 : "";
  221. !     p = xmalloc((unsigned)(strlen(arg1)+strlen(arg2)+1));
  222.       (void) strcpy(p, arg1);
  223.       (void) strcat(p, arg2);
  224.       if (s1)
  225. !         xfree(s1);
  226.       if (s2)
  227. !         xfree(s2);
  228.       return(p);
  229.   }
  230.   
  231. --- 970,982 ----
  232.       return((char *)0);
  233.       arg1 = s1 ? s1 : "";
  234.       arg2 = s2 ? s2 : "";
  235. !     p = scxmalloc((unsigned)(strlen(arg1)+strlen(arg2)+1));
  236.       (void) strcpy(p, arg1);
  237.       (void) strcat(p, arg2);
  238.       if (s1)
  239. !         scxfree(s1);
  240.       if (s2)
  241. !         scxfree(s2);
  242.       return(p);
  243.   }
  244.   
  245. ***************
  246. *** 989,995 ****
  247.   
  248.       tp = ctime(&tloc);
  249.       tp[24] = '\0';
  250. !     p = xmalloc((unsigned)25);
  251.       (void) strcpy(p, tp);
  252.       return(p);
  253.   }
  254. --- 989,995 ----
  255.   
  256.       tp = ctime(&tloc);
  257.       tp[24] = '\0';
  258. !     p = scxmalloc((unsigned)25);
  259.       (void) strcpy(p, tp);
  260.       return(p);
  261.   }
  262. ***************
  263. *** 1006,1014 ****
  264.       if (!fmtstr)
  265.       return((char *)0);
  266.       (void) sprintf(buff, fmtstr, v);
  267. !     p = xmalloc((unsigned)(strlen(buff)+1));
  268.       (void) strcpy(p, buff);
  269. !     xfree(fmtstr);
  270.       return(p);
  271.   }
  272.   
  273. --- 1006,1014 ----
  274.       if (!fmtstr)
  275.       return((char *)0);
  276.       (void) sprintf(buff, fmtstr, v);
  277. !     p = scxmalloc((unsigned)(strlen(buff)+1));
  278.       (void) strcpy(p, buff);
  279. !     scxfree(fmtstr);
  280.       return(p);
  281.   }
  282.   
  283. ***************
  284. *** 1032,1039 ****
  285.       error("Warning: External functions unavailable on VMS");
  286.       cellerror = CELLERROR;    /* not sure if this should be a cellerror */
  287.       if (command)
  288. !     xfree(command);
  289. !     return (strcpy (xmalloc((unsigned) 1), "\0"));
  290.   }
  291.   
  292.   #else /* VMS */
  293. --- 1032,1039 ----
  294.       error("Warning: External functions unavailable on VMS");
  295.       cellerror = CELLERROR;    /* not sure if this should be a cellerror */
  296.       if (command)
  297. !     scxfree(command);
  298. !     return (strcpy (scxmalloc((unsigned) 1), "\0"));
  299.   }
  300.   
  301.   #else /* VMS */
  302. ***************
  303. *** 1053,1069 ****
  304.           ((prevstr == NULL) || (*prevstr == '\0')) ?
  305.               "null" : "previous");
  306.   
  307. !     if (command) xfree (command);
  308.       } else {
  309.       if ((! command) || (! *command)) {
  310.           error ("Warning: external function given null command name");
  311.           cellerror = CELLERROR;
  312. !         if (command) xfree (command);
  313.       } else {
  314.           FILE *pp;
  315.   
  316.           (void) sprintf (buff, "%s %g", command, value); /* build cmd line */
  317. !         xfree (command);
  318.   
  319.           error ("Running external function...");
  320.           (void) refresh();
  321. --- 1053,1069 ----
  322.           ((prevstr == NULL) || (*prevstr == '\0')) ?
  323.               "null" : "previous");
  324.   
  325. !     if (command) scxfree (command);
  326.       } else {
  327.       if ((! command) || (! *command)) {
  328.           error ("Warning: external function given null command name");
  329.           cellerror = CELLERROR;
  330. !         if (command) scxfree (command);
  331.       } else {
  332.           FILE *pp;
  333.   
  334.           (void) sprintf (buff, "%s %g", command, value); /* build cmd line */
  335. !         scxfree (command);
  336.   
  337.           error ("Running external function...");
  338.           (void) refresh();
  339. ***************
  340. *** 1086,1092 ****
  341.   
  342.               if (strlen(buff) + 1 > prevlen)
  343.               {    prevlen = strlen(buff) + 40;
  344. !             prevstr = xrealloc(prevstr, prevlen);
  345.               }
  346.               (void) strcpy (prevstr, buff);
  347.                /* save alloc'd copy */
  348. --- 1086,1092 ----
  349.   
  350.               if (strlen(buff) + 1 > prevlen)
  351.               {    prevlen = strlen(buff) + 40;
  352. !             prevstr = scxrealloc(prevstr, prevlen);
  353.               }
  354.               (void) strcpy (prevstr, buff);
  355.                /* save alloc'd copy */
  356. ***************
  357. *** 1097,1105 ****
  358.       } /* else */
  359.       } /* else */
  360.       if (prevstr)
  361. !     return (strcpy (xmalloc ((unsigned) (strlen (prevstr) + 1)), prevstr));
  362.       else
  363. !     return (strcpy(xmalloc((unsigned)1), ""));
  364.   }
  365.   
  366.   #endif /* VMS */
  367. --- 1097,1105 ----
  368.       } /* else */
  369.       } /* else */
  370.       if (prevstr)
  371. !     return (strcpy (scxmalloc ((unsigned) (strlen (prevstr) + 1)), prevstr));
  372.       else
  373. !     return (strcpy(scxmalloc((unsigned)1), ""));
  374.   }
  375.   
  376.   #endif /* VMS */
  377. ***************
  378. *** 1121,1127 ****
  379.       char *llabel;
  380.   
  381.       llabel = (ep = getent (colstr, rowdoub)) ? (ep -> label) : "";
  382. !     return (strcpy (xmalloc ((unsigned) (strlen (llabel) + 1)), llabel));
  383.   }
  384.   
  385.   
  386. --- 1121,1127 ----
  387.       char *llabel;
  388.   
  389.       llabel = (ep = getent (colstr, rowdoub)) ? (ep -> label) : "";
  390. !     return (strcpy (scxmalloc ((unsigned) (strlen (llabel) + 1)), llabel));
  391.   }
  392.   
  393.   
  394. ***************
  395. *** 1145,1161 ****
  396.       v2 =  strlen (s) - 1;        /* to end   */
  397.   
  398.       if (v1 < 0 || v1 > v2) {        /* out of range, return null string */
  399. !     xfree(s);
  400. !     p = xmalloc((unsigned)1);
  401.       p[0] = '\0';
  402.       return(p);
  403.       }
  404. !     s2 = p = xmalloc((unsigned)(v2-v1+2));
  405.       s1 = &s[v1];
  406.       for(; v1 <= v2; s1++, s2++, v1++)
  407.       *s2 = *s1;
  408.       *s2 = '\0';
  409. !     xfree(s);
  410.       return(p);
  411.   }
  412.   
  413. --- 1145,1161 ----
  414.       v2 =  strlen (s) - 1;        /* to end   */
  415.   
  416.       if (v1 < 0 || v1 > v2) {        /* out of range, return null string */
  417. !     scxfree(s);
  418. !     p = scxmalloc((unsigned)1);
  419.       p[0] = '\0';
  420.       return(p);
  421.       }
  422. !     s2 = p = scxmalloc((unsigned)(v2-v1+2));
  423.       s1 = &s[v1];
  424.       for(; v1 <= v2; s1++, s2++, v1++)
  425.       *s2 = *s1;
  426.       *s2 = '\0';
  427. !     scxfree(s);
  428.       return(p);
  429.   }
  430.   
  431. ***************
  432. *** 1233,1239 ****
  433.   
  434.       if (se == (struct enode *)0) return (char *)0;
  435.       switch (se->op) {
  436. !     case O_SCONST: p = xmalloc((unsigned)(strlen(se->e.s)+1));
  437.                (void) strcpy(p, se->e.s);
  438.                return(p);
  439.       case O_VAR:    {
  440. --- 1233,1239 ----
  441.   
  442.       if (se == (struct enode *)0) return (char *)0;
  443.       switch (se->op) {
  444. !     case O_SCONST: p = scxmalloc((unsigned)(strlen(se->e.s)+1));
  445.                (void) strcpy(p, se->e.s);
  446.                return(p);
  447.       case O_VAR:    {
  448. ***************
  449. *** 1242,1248 ****
  450.   
  451.               if (!ep->label)
  452.                   return((char *)0);
  453. !             p = xmalloc((unsigned)(strlen(ep->label)+1));
  454.               (void) strcpy(p, ep->label);
  455.               return(p);
  456.                }
  457. --- 1242,1248 ----
  458.   
  459.               if (!ep->label)
  460.                   return((char *)0);
  461. !             p = scxmalloc((unsigned)(strlen(ep->label)+1));
  462.               (void) strcpy(p, ep->label);
  463.               return(p);
  464.                }
  465. ***************
  466. *** 1273,1280 ****
  467.       case SUBSTR: return(dosubstr(seval(se->e.o.left),
  468.                   (int)eval(se->e.o.right->e.o.left) - 1,
  469.                   (int)eval(se->e.o.right->e.o.right) - 1));
  470. !     case COLTOA: return(strcpy(xmalloc((unsigned)10),
  471. !                    coltoa(eval(se->e.o.right)+1)));
  472.       default:
  473.                error ("Illegal string expression");
  474.                exprerr = 1;
  475. --- 1273,1280 ----
  476.       case SUBSTR: return(dosubstr(seval(se->e.o.left),
  477.                   (int)eval(se->e.o.right->e.o.left) - 1,
  478.                   (int)eval(se->e.o.right->e.o.right) - 1));
  479. !     case COLTOA: return(strcpy(scxmalloc((unsigned)10),
  480. !                    coltoa((int)eval(se->e.o.right)+1)));
  481.       default:
  482.                error ("Illegal string expression");
  483.                exprerr = 1;
  484. ***************
  485. *** 1293,1298 ****
  486. --- 1293,1300 ----
  487.    */
  488.   
  489.   int propagation = 10;    /* max number of times to try calculation */
  490. + int repct = 1;        /* Make repct a global variable so that the 
  491. +                 function @numiter can access it */
  492.   
  493.   void
  494.   setiterations(i)
  495. ***************
  496. *** 1307,1314 ****
  497.   
  498.   void
  499.   EvalAll () {
  500. !      int lastcnt, repct = 1;
  501.     
  502.        (void) signal(SIGFPE, eval_fpe);
  503.   
  504.        while ((lastcnt = RealEvalAll()) && (++repct <= propagation));
  505. --- 1309,1317 ----
  506.   
  507.   void
  508.   EvalAll () {
  509. !      int lastcnt;
  510.     
  511. +      repct = 1;
  512.        (void) signal(SIGFPE, eval_fpe);
  513.   
  514.        while ((lastcnt = RealEvalAll()) && (++repct <= propagation));
  515. ***************
  516. *** 1315,1321 ****
  517.        if((propagation>1)&& (lastcnt >0 ))
  518.            error("Still changing after %d iterations",propagation-1);
  519.   
  520. !     (void) signal(SIGFPE, quit);
  521.   }
  522.   
  523.   /*
  524. --- 1318,1324 ----
  525.        if((propagation>1)&& (lastcnt >0 ))
  526.            error("Still changing after %d iterations",propagation-1);
  527.   
  528. !     (void) signal(SIGFPE, doquit);
  529.   }
  530.   
  531.   /*
  532. ***************
  533. *** 1369,1375 ****
  534.           changed++;
  535.           }
  536.           if(p->label)
  537. !         xfree(p->label);
  538.           p->label = v;
  539.       } else {
  540.           double v;
  541. --- 1372,1378 ----
  542.           changed++;
  543.           }
  544.           if(p->label)
  545. !         scxfree(p->label);
  546.           p->label = v;
  547.       } else {
  548.           double v;
  549. ***************
  550. *** 1403,1409 ****
  551.       freeenodes = p->e.o.left;
  552.       }
  553.       else
  554. !     p = (struct enode *) xmalloc ((unsigned)sizeof (struct enode));
  555.       p->op = op;
  556.       p->e.o.left = a1;
  557.       p->e.o.right = a2;
  558. --- 1406,1412 ----
  559.       freeenodes = p->e.o.left;
  560.       }
  561.       else
  562. !     p = (struct enode *) scxmalloc ((unsigned)sizeof (struct enode));
  563.       p->op = op;
  564.       p->e.o.left = a1;
  565.       p->e.o.right = a2;
  566. ***************
  567. *** 1421,1427 ****
  568.       freeenodes = p->e.o.left;
  569.       }
  570.       else
  571. !     p = (struct enode *) xmalloc ((unsigned)sizeof (struct enode));
  572.       p->op = op;
  573.       p->e.v = a1;
  574.       return p;
  575. --- 1424,1430 ----
  576.       freeenodes = p->e.o.left;
  577.       }
  578.       else
  579. !     p = (struct enode *) scxmalloc ((unsigned)sizeof (struct enode));
  580.       p->op = op;
  581.       p->e.v = a1;
  582.       return p;
  583. ***************
  584. *** 1438,1444 ****
  585.       freeenodes = p->e.o.left;
  586.       }
  587.       else
  588. !     p = (struct enode *) xmalloc ((unsigned)sizeof (struct enode));
  589.       p->op = op;
  590.       p->e.r = a1;
  591.       return p;
  592. --- 1441,1447 ----
  593.       freeenodes = p->e.o.left;
  594.       }
  595.       else
  596. !     p = (struct enode *) scxmalloc ((unsigned)sizeof (struct enode));
  597.       p->op = op;
  598.       p->e.r = a1;
  599.       return p;
  600. ***************
  601. *** 1455,1461 ****
  602.       freeenodes = p->e.o.left;
  603.       }
  604.       else
  605. !     p = (struct enode *) xmalloc ((unsigned)sizeof (struct enode));
  606.       p->op = op;
  607.       p->e.k = a1;
  608.       return p;
  609. --- 1458,1464 ----
  610.       freeenodes = p->e.o.left;
  611.       }
  612.       else
  613. !     p = (struct enode *) scxmalloc ((unsigned)sizeof (struct enode));
  614.       p->op = op;
  615.       p->e.k = a1;
  616.       return p;
  617. ***************
  618. *** 1472,1478 ****
  619.       freeenodes = p->e.o.left;
  620.       }
  621.       else
  622. !     p = (struct enode *) xmalloc ((unsigned)sizeof(struct enode));
  623.       p->op = O_SCONST;
  624.       p->e.s = s;
  625.       return(p);
  626. --- 1475,1481 ----
  627.       freeenodes = p->e.o.left;
  628.       }
  629.       else
  630. !     p = (struct enode *) scxmalloc ((unsigned)sizeof(struct enode));
  631.       p->op = O_SCONST;
  632.       p->e.s = s;
  633.       return(p);
  634. ***************
  635. *** 1564,1570 ****
  636.   g_free()
  637.   {
  638.       switch (gs.g_type) {
  639. !     case G_STR: xfree(gs.g_s); break;
  640.       default: break;
  641.       }
  642.       gs.g_type = G_NONE;
  643. --- 1567,1573 ----
  644.   g_free()
  645.   {
  646.       switch (gs.g_type) {
  647. !     case G_STR: scxfree(gs.g_s); break;
  648.       default: break;
  649.       }
  650.       gs.g_type = G_NONE;
  651. ***************
  652. *** 1675,1681 ****
  653.   
  654.   #if defined(RE_COMP)
  655.       if ((tmp = re_comp(s)) != (char *)0) {
  656. !     xfree(s);
  657.       error(tmp);
  658.       return;
  659.       }
  660. --- 1678,1684 ----
  661.   
  662.   #if defined(RE_COMP)
  663.       if ((tmp = re_comp(s)) != (char *)0) {
  664. !     scxfree(s);
  665.       error(tmp);
  666.       return;
  667.       }
  668. ***************
  669. *** 1682,1688 ****
  670.   #endif
  671.   #if defined(REGCMP)
  672.       if ((tmp = regcmp(s, (char *)0)) == (char *)0) {
  673. !     xfree(s);
  674.       cellerror = CELLERROR;
  675.       error("Invalid search string");
  676.       return;
  677. --- 1685,1691 ----
  678.   #endif
  679.   #if defined(REGCMP)
  680.       if ((tmp = regcmp(s, (char *)0)) == (char *)0) {
  681. !     scxfree(s);
  682.       cellerror = CELLERROR;
  683.       error("Invalid search string");
  684.       return;
  685. ***************
  686. *** 1870,1876 ****
  687.           FullUpdate++;
  688.           v->cellerror = cellerror;
  689.       }
  690. !     (void) signal(SIGFPE, quit);
  691.       if (exprerr) {
  692.           efree(e);
  693.           return;
  694. --- 1873,1879 ----
  695.           FullUpdate++;
  696.           v->cellerror = cellerror;
  697.       }
  698. !     (void) signal(SIGFPE, doquit);
  699.       if (exprerr) {
  700.           efree(e);
  701.           return;
  702. ***************
  703. *** 1931,1937 ****
  704.       FullUpdate++;
  705.       v->cellerror = cellerror;
  706.       }
  707. !     (void) signal(SIGFPE, quit);
  708.       if (exprerr) {
  709.       efree(se);
  710.       return;
  711. --- 1934,1940 ----
  712.       FullUpdate++;
  713.       v->cellerror = cellerror;
  714.       }
  715. !     (void) signal(SIGFPE, doquit);
  716.       if (exprerr) {
  717.       efree(se);
  718.       return;
  719. ***************
  720. *** 1939,1945 ****
  721.       if (constant(se)) {
  722.       label(v, p, flushdir);
  723.       if (p)
  724. !         xfree(p);
  725.       efree(se);
  726.       if (v->flags & is_strexpr) {
  727.               efree(v->expr);
  728. --- 1942,1948 ----
  729.       if (constant(se)) {
  730.       label(v, p, flushdir);
  731.       if (p)
  732. !         scxfree(p);
  733.       efree(se);
  734.       if (v->flags & is_strexpr) {
  735.               efree(v->expr);
  736. ***************
  737. *** 1992,2001 ****
  738.           continue;
  739.           }
  740.           if (n->format)
  741. !         xfree(n->format);
  742.           n->format = 0;
  743.           if (s && *s != '\0')
  744. !         n->format = strcpy(xmalloc((unsigned)(strlen(s)+1)), s);
  745.           n->flags |= is_changed;
  746.          }
  747.   }
  748. --- 1995,2004 ----
  749.           continue;
  750.           }
  751.           if (n->format)
  752. !         scxfree(n->format);
  753.           n->format = 0;
  754.           if (s && *s != '\0')
  755. !         n->format = strcpy(scxmalloc((unsigned)(strlen(s)+1)), s);
  756.           n->flags |= is_changed;
  757.          }
  758.   }
  759. ***************
  760. *** 2034,2040 ****
  761.       }
  762.       }
  763.       FullUpdate++;
  764. !     col_hidden[arg] = 1;
  765.   }
  766.   
  767.   void
  768. --- 2037,2043 ----
  769.       }
  770.       }
  771.       FullUpdate++;
  772. !     col_hidden[arg] = TRUE;
  773.   }
  774.   
  775.   void
  776. ***************
  777. *** 2049,2055 ****
  778.       efree(v->expr);
  779.       v->expr = (struct enode *)0;
  780.       if (v->format)
  781. !     xfree(v->format);
  782.       v->format = (char *)0;
  783.       v->flags |= (is_changed);
  784.       v->flags &=  (is_valid);
  785. --- 2052,2058 ----
  786.       efree(v->expr);
  787.       v->expr = (struct enode *)0;
  788.       if (v->format)
  789. !     scxfree(v->format);
  790.       v->format = (char *)0;
  791.       v->flags |= (is_changed);
  792.       v->flags &=  (is_valid);
  793. ***************
  794. *** 2079,2084 ****
  795. --- 2082,2088 ----
  796.            && e -> op != NOW
  797.            && e -> op != MYROW
  798.            && e -> op != MYCOL
  799. +          && e -> op != NUMITER
  800.       )
  801.       );
  802.   }
  803. ***************
  804. *** 2094,2100 ****
  805.           efree(e->e.o.right);
  806.       }
  807.       if (e->op == O_SCONST && e->e.s)
  808. !         xfree(e->e.s);
  809.       e->e.o.left = freeenodes;
  810.       freeenodes = e;
  811.       }
  812. --- 2098,2104 ----
  813.           efree(e->e.o.right);
  814.       }
  815.       if (e->op == O_SCONST && e->e.s)
  816. !         scxfree(e->e.s);
  817.       e->e.o.left = freeenodes;
  818.       freeenodes = e;
  819.       }
  820. ***************
  821. *** 2115,2123 ****
  822.           v = tv, flushdir = -1;
  823.           else flushdir = -1;
  824.       }
  825. !     if (v->label) xfree((char *)(v->label));
  826.       if (s && s[0]) {
  827. !         v->label = xmalloc ((unsigned)(strlen(s)+1));
  828.           (void) strcpy (v->label, s);
  829.       } else
  830.           v->label = (char *)0;
  831. --- 2119,2127 ----
  832.           v = tv, flushdir = -1;
  833.           else flushdir = -1;
  834.       }
  835. !     if (v->label) scxfree((char *)(v->label));
  836.       if (s && s[0]) {
  837. !         v->label = scxmalloc ((unsigned)(strlen(s)+1));
  838.           (void) strcpy (v->label, s);
  839.       } else
  840.           v->label = (char *)0;
  841. ***************
  842. *** 2288,2293 ****
  843. --- 2292,2300 ----
  844.               linelim--;
  845.               break;
  846.       case COLTOA:    one_arg( "@coltoa(", e); break;
  847. +     case NUMITER:    for ( s = "@numiter"; line[linelim++] = *s++;);
  848. +                         linelim--;
  849. +                         break;
  850.       default:    decompile (e->e.o.left, mypriority);
  851.               line[linelim++] = e->op;
  852.               decompile (e->e.o.right, mypriority+1);
  853. *** ../619/lex.c    Mon Mar 16 10:09:42 1992
  854. --- lex.c    Fri May  8 12:31:28 1992
  855. ***************
  856. *** 7,13 ****
  857.    *
  858.    *              More mods Robert Bond, 12/86
  859.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  860. !  *        $Revision: 6.19 $
  861.    *
  862.    */
  863.   
  864. --- 7,13 ----
  865.    *
  866.    *              More mods Robert Bond, 12/86
  867.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  868. !  *        $Revision: 6.21 $
  869.    *
  870.    */
  871.   
  872. ***************
  873. *** 216,222 ****
  874.           ptr = p+1;    /* "string" or "string\"quoted\"" */
  875.           while(*ptr && ((*ptr != '"') || (*(ptr-1) == '\\')))
  876.           ptr++;
  877. !         ptr = xmalloc((unsigned)(ptr-p));
  878.       yylval.sval = ptr;
  879.       p += 1;
  880.       while (*p && ((*p != '"') || (*(p-1) == '\\')))
  881. --- 216,222 ----
  882.           ptr = p+1;    /* "string" or "string\"quoted\"" */
  883.           while(*ptr && ((*ptr != '"') || (*(ptr-1) == '\\')))
  884.           ptr++;
  885. !         ptr = scxmalloc((unsigned)(ptr-p));
  886.       yylval.sval = ptr;
  887.       p += 1;
  888.       while (*p && ((*p != '"') || (*(p-1) == '\\')))
  889. ***************
  890. *** 411,416 ****
  891. --- 411,417 ----
  892.       km[1].k_str = tgetstr("kr", &p); km[1].k_val = ctl('f');
  893.       km[2].k_str = tgetstr("ku", &p); km[2].k_val = ctl('p');
  894.       km[3].k_str = tgetstr("kd", &p); km[3].k_val = ctl('n');
  895.       ktmp = tgetstr("ks",&p);
  896.       if (ktmp)  {
  897.       (void) strcpy(ks_buf, ktmp);
  898. ***************
  899. *** 597,602 ****
  900. --- 598,615 ----
  901.   #ifdef KEY_HOME
  902.       case KEY_HOME:    break;
  903.   #endif
  904. + #ifdef KEY_DC
  905. +     case KEY_DC:    c = 'x'; break;
  906. + #endif
  907. + #ifdef KEY_FIND
  908. +     case KEY_FIND:  c = 'g'; break;
  909. + #endif
  910. + #ifdef KEY_HELP
  911. +     case KEY_HELP:  c = '?'; break;
  912. + #endif
  913. + #ifdef KEY_SELECT
  914. +     case KEY_SELECT:c = 'm'; break;
  915. + #endif
  916.   #ifdef KEY_C1
  917.   /* This stuff works for a wyse wy75 in ANSI mode under 5.3.  Good luck. */
  918.   /* It is supposed to map the curses keypad back to the numeric equiv. */
  919. ***************
  920. *** 613,619 ****
  921.       case KEY_C3:    c = '.'; break;
  922.       case KEY_ENTER: c = ctl('m'); break;
  923.   #endif
  924. !     default:   c = toascii(c); 
  925.       break;
  926.       }
  927.       return (c);
  928. --- 626,632 ----
  929.       case KEY_C3:    c = '.'; break;
  930.       case KEY_ENTER: c = ctl('m'); break;
  931.   #endif
  932. !     default:        c = toascii(c); 
  933.       break;
  934.       }
  935.       return (c);
  936. *** ../619/psc.c    Mon Mar 16 10:09:42 1992
  937. --- psc.c    Fri May  8 12:31:29 1992
  938. ***************
  939. *** 17,23 ****
  940.    *  Author: Robert Bond
  941.    *  Adjustments: Jeff Buhrt and Eric Putz
  942.    */
  943. ! char *rev = "$Revision: 6.19 $";
  944.   
  945.   #include <ctype.h>
  946.   #include <stdio.h>
  947. --- 17,23 ----
  948.    *  Author: Robert Bond
  949.    *  Adjustments: Jeff Buhrt and Eric Putz
  950.    */
  951. ! char *rev = "$Revision: 6.21 $";
  952.   
  953.   #include <ctype.h>
  954.   #include <stdio.h>
  955. *** ../619/range.c    Mon Mar 16 10:09:43 1992
  956. --- range.c    Fri May  8 12:31:29 1992
  957. ***************
  958. *** 4,10 ****
  959.    *
  960.    *              Robert Bond, 4/87
  961.    *
  962. !  *        $Revision: 6.19 $
  963.    */
  964.   
  965.   #include <sys/types.h>
  966. --- 4,10 ----
  967.    *
  968.    *              Robert Bond, 4/87
  969.    *
  970. !  *        $Revision: 6.21 $
  971.    */
  972.   
  973.   #include <sys/types.h>
  974. ***************
  975. *** 59,71 ****
  976.   
  977.       if (find_range(name, strlen(name), (struct ent *)0, (struct ent *)0)) {
  978.       error("Error: range name already defined");
  979. !     xfree(name);
  980.       return;
  981.       }
  982.   
  983.       if (strlen(name) <= 2) {
  984.       error("Invalid range name - too short");
  985. !     xfree(name);
  986.       return;
  987.       }
  988.   
  989. --- 59,71 ----
  990.   
  991.       if (find_range(name, strlen(name), (struct ent *)0, (struct ent *)0)) {
  992.       error("Error: range name already defined");
  993. !     scxfree(name);
  994.       return;
  995.       }
  996.   
  997.       if (strlen(name) <= 2) {
  998.       error("Invalid range name - too short");
  999. !     scxfree(name);
  1000.       return;
  1001.       }
  1002.   
  1003. ***************
  1004. *** 73,79 ****
  1005.       if (!((isalpha(*p) && (len<=2)) ||
  1006.           ((isdigit(*p) || isalpha(*p) || (*p == '_')) && (len>2)))) {
  1007.           error("Invalid range name - illegal combination");
  1008. !         xfree(name);
  1009.           return;
  1010.       }
  1011.    
  1012. --- 73,79 ----
  1013.       if (!((isalpha(*p) && (len<=2)) ||
  1014.           ((isdigit(*p) || isalpha(*p) || (*p == '_')) && (len>2)))) {
  1015.           error("Invalid range name - illegal combination");
  1016. !         scxfree(name);
  1017.           return;
  1018.       }
  1019.    
  1020. ***************
  1021. *** 83,89 ****
  1022.           label(rcp, name, 0);
  1023.       }
  1024.   
  1025. !     r = (struct range *)xmalloc((unsigned)sizeof(struct range));
  1026.       r->r_name = name;
  1027.       r->r_left = left;
  1028.       r->r_right = right;
  1029. --- 83,89 ----
  1030.           label(rcp, name, 0);
  1031.       }
  1032.   
  1033. !     r = (struct range *)scxmalloc((unsigned)sizeof(struct range));
  1034.       r->r_name = name;
  1035.       r->r_left = left;
  1036.       r->r_right = right;
  1037. ***************
  1038. *** 119,126 ****
  1039.           r->r_prev->r_next = r->r_next;
  1040.       else
  1041.       rng_base = r->r_next;
  1042. !     xfree((char *)(r->r_name));
  1043. !     xfree((char *)r);
  1044.   }
  1045.   
  1046.   void
  1047. --- 119,126 ----
  1048.           r->r_prev->r_next = r->r_next;
  1049.       else
  1050.       rng_base = r->r_next;
  1051. !     scxfree((char *)(r->r_name));
  1052. !     scxfree((char *)r);
  1053.   }
  1054.   
  1055.   void
  1056. ***************
  1057. *** 134,141 ****
  1058.   
  1059.       while (r) {
  1060.       nextr = r->r_next;
  1061. !     xfree((char *)(r->r_name));
  1062. !     xfree((char *)r);
  1063.       r = nextr;
  1064.       }
  1065.   }
  1066. --- 134,141 ----
  1067.   
  1068.       while (r) {
  1069.       nextr = r->r_next;
  1070. !     scxfree((char *)(r->r_name));
  1071. !     scxfree((char *)r);
  1072.       r = nextr;
  1073.       }
  1074.   }
  1075. *** ../619/sc.c    Mon Mar 16 10:09:44 1992
  1076. --- sc.c    Fri May  8 12:31:31 1992
  1077. ***************
  1078. *** 8,14 ****
  1079.    *              More mods Robert Bond, 12/86
  1080.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1081.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1082. !  *        $Revision: 6.19 $
  1083.    *
  1084.    */
  1085.   
  1086. --- 8,14 ----
  1087.    *              More mods Robert Bond, 12/86
  1088.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1089.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1090. !  *        $Revision: 6.21 $
  1091.    *
  1092.    */
  1093.   
  1094. ***************
  1095. *** 126,132 ****
  1096.           freeents = freeents->next;
  1097.       }
  1098.       else
  1099. !         *pp = (struct ent *) xmalloc((unsigned)sizeof(struct ent));
  1100.       if (row>maxrow) maxrow = row;
  1101.       if (col>maxcol) maxcol = col;
  1102.       (*pp)->label = (char *)0;
  1103. --- 126,132 ----
  1104.           freeents = freeents->next;
  1105.       }
  1106.       else
  1107. !         *pp = (struct ent *) scxmalloc((unsigned)sizeof(struct ent));
  1108.       if (row>maxrow) maxrow = row;
  1109.       if (col>maxcol) maxcol = col;
  1110.       (*pp)->label = (char *)0;
  1111. ***************
  1112. *** 224,231 ****
  1113.       argc--;
  1114.           switch (argv[0][1]) {
  1115.           case 'x':
  1116. ! #if defined(VMS) || defined(MSDOS)
  1117. !             (void) fprintf(stderr, "Crypt not available for VMS or MS-DOS\n");
  1118.               exit(1);
  1119.   #else 
  1120.               Crypt = 1;
  1121. --- 224,231 ----
  1122.       argc--;
  1123.           switch (argv[0][1]) {
  1124.           case 'x':
  1125. ! #if defined(VMS) || defined(MSDOS) || !defined(CRYPT_PATH)
  1126. !             (void) fprintf(stderr, "Crypt not available\n");
  1127.               exit(1);
  1128.   #else 
  1129.               Crypt = 1;
  1130. ***************
  1131. *** 343,349 ****
  1132.   #if    pyr
  1133.          if ( iscntrl(c) || (c >= 011 && c <= 015) )    /* iscntrl broken in OSx4.1 */
  1134.   #else
  1135. !        if ( iscntrl(c) || (c == 020 ) )    /* iscntrl broken in OSx4.1 */
  1136.   #endif
  1137.           switch (c) {
  1138.   #ifdef SIGTSTP
  1139. --- 343,349 ----
  1140.   #if    pyr
  1141.          if ( iscntrl(c) || (c >= 011 && c <= 015) )    /* iscntrl broken in OSx4.1 */
  1142.   #else
  1143. !        if (isascii(c) && (iscntrl(c) || (c == 020)) )    /* iscntrl broken in OSx4.1 */
  1144.   #endif
  1145.           switch (c) {
  1146.   #ifdef SIGTSTP
  1147. ***************
  1148. *** 509,516 ****
  1149. --- 509,521 ----
  1150.               break;    /* ignore flow control */
  1151.   
  1152.           case ctl('t'):
  1153. + #if !defined(VMS) && !defined(MSDOS) && defined(CRYPT_PATH)
  1154.               error(
  1155.   "Toggle: a:auto,c:cell,e:ext funcs,n:numeric,t:top,x:encrypt,$:pre-scale,<MORE>");
  1156. + #else                 /* no encryption available */
  1157. +             error(
  1158. + "Toggle: a:auto,c:cell,e:ext funcs,n:numeric,t:top,$:pre-scale,<MORE>");
  1159. + #endif
  1160.               (void) refresh();
  1161.   
  1162.               switch (nmgetch()) {
  1163. ***************
  1164. *** 536,543 ****
  1165. --- 541,552 ----
  1166.                       showcell ? "en" : "dis");
  1167.                   break;
  1168.               case 'x': case 'X':
  1169. + #if defined(VMS) || defined(MSDOS) || !defined(CRYPT_PATH)
  1170. +                 error ("Encryption not available.");
  1171. + #else 
  1172.                   Crypt = (! Crypt);
  1173.                   error ("Encryption %sabled.", Crypt? "en" : "dis");
  1174. + #endif
  1175.                   break;
  1176.               case 'l': case 'L':
  1177.                   autolabel = (! autolabel);
  1178. ***************
  1179. *** 609,620 ****
  1180.               static    unsigned    templen = 0;
  1181.               int templim;
  1182.   
  1183. !             /* xrealloc will xmalloc if needed */
  1184.               if (strlen(line)+1 > templen)
  1185.               {    templen = strlen(line)+40;
  1186.   
  1187. !                 temp = xrealloc(temp, templen);
  1188. !                 temp1= xrealloc(temp1, templen);
  1189.               }
  1190.               strcpy(temp, line);
  1191.               templim = linelim;
  1192. --- 618,629 ----
  1193.               static    unsigned    templen = 0;
  1194.               int templim;
  1195.   
  1196. !             /* scxrealloc will scxmalloc if needed */
  1197.               if (strlen(line)+1 > templen)
  1198.               {    templen = strlen(line)+40;
  1199.   
  1200. !                 temp = scxrealloc(temp, templen);
  1201. !                 temp1= scxrealloc(temp1, templen);
  1202.               }
  1203.               strcpy(temp, line);
  1204.               templim = linelim;
  1205. ***************
  1206. *** 641,647 ****
  1207.               break;
  1208.   
  1209.           } /* End of the control char switch stmt */
  1210. !     else if (isdigit(c) && ((numeric && edistate >= 0) ||
  1211.               (!numeric && (linelim < 0 || edistate >= 0)))) {
  1212.           /* we got a leading number */
  1213.           if (edistate != 0) {
  1214. --- 650,656 ----
  1215.               break;
  1216.   
  1217.           } /* End of the control char switch stmt */
  1218. !     else if (isascii(c) && isdigit(c) && ((numeric && edistate >= 0) ||
  1219.               (!numeric && (linelim < 0 || edistate >= 0)))) {
  1220.           /* we got a leading number */
  1221.           if (edistate != 0) {
  1222. ***************
  1223. *** 1121,1137 ****
  1224.               break;
  1225.           case 'W':
  1226.               (void) sprintf (line, "write [\"dest\" range] \"");
  1227.               linelim = strlen (line);
  1228.               insert_mode();
  1229.               break;
  1230.           case 'S':    /* set options */
  1231.               (void) sprintf (line, "set ");
  1232. !             error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex),<MORE>");
  1233.               linelim = strlen (line);
  1234.               insert_mode();
  1235.               break;
  1236.           case 'T':    /* tbl output */
  1237.               (void) sprintf (line, "tbl [\"dest\" range] \"");
  1238.               linelim = strlen (line);
  1239.               insert_mode();
  1240.               break;
  1241. --- 1130,1158 ----
  1242.               break;
  1243.           case 'W':
  1244.               (void) sprintf (line, "write [\"dest\" range] \"");
  1245. +             if (*curfile)
  1246. +                        error ("Default file is \"%s.asc\"",curfile);
  1247.               linelim = strlen (line);
  1248.               insert_mode();
  1249.               break;
  1250.           case 'S':    /* set options */
  1251.               (void) sprintf (line, "set ");
  1252. !             error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex|frame),<MORE>");
  1253.               linelim = strlen (line);
  1254.               insert_mode();
  1255.               break;
  1256.           case 'T':    /* tbl output */
  1257.               (void) sprintf (line, "tbl [\"dest\" range] \"");
  1258. +             if (*curfile && tbl_style == 0)
  1259. +                        error ("Default file is \"%s.cln\"",curfile);
  1260. +                     else if (*curfile && tbl_style == TBL)
  1261. +                        error ("Default file is \"%s.tbl\"",curfile);
  1262. +                     else if (*curfile && tbl_style == LATEX)
  1263. +                        error ("Default file is \"%s.lat\"",curfile);
  1264. +                     else if (*curfile && tbl_style == SLATEX)
  1265. +                        error ("Default file is \"%s.stx\"",curfile);
  1266. +                     else if (*curfile && tbl_style == TEX)
  1267. +                        error ("Default file is \"%s.tex\"",curfile);
  1268.               linelim = strlen (line);
  1269.               insert_mode();
  1270.               break;
  1271. ***************
  1272. *** 1293,1299 ****
  1273.   signals()
  1274.   {
  1275.   #ifdef SIGVOID
  1276. !     void quit();
  1277.       void time_out();
  1278.       void dump_me();
  1279.   #ifdef    SIGWINCH
  1280. --- 1314,1320 ----
  1281.   signals()
  1282.   {
  1283.   #ifdef SIGVOID
  1284. !     void doquit();
  1285.       void time_out();
  1286.       void dump_me();
  1287.   #ifdef    SIGWINCH
  1288. ***************
  1289. *** 1300,1306 ****
  1290.       void winchg();
  1291.   #endif
  1292.   #else
  1293. !     int quit();
  1294.       int time_out();
  1295.       int dump_me();
  1296.   #ifdef    SIGWINCH
  1297. --- 1321,1327 ----
  1298.       void winchg();
  1299.   #endif
  1300.   #else
  1301. !     int doquit();
  1302.       int time_out();
  1303.       int dump_me();
  1304.   #ifdef    SIGWINCH
  1305. ***************
  1306. *** 1311,1322 ****
  1307.       (void) signal(SIGINT, SIG_IGN);
  1308.   #if !defined(MSDOS)
  1309.       (void) signal(SIGQUIT, dump_me);
  1310. !     (void) signal(SIGPIPE, quit);
  1311.       (void) signal(SIGALRM, time_out);
  1312. !     (void) signal(SIGBUS, quit);
  1313.   #endif
  1314. !     (void) signal(SIGTERM, quit);
  1315. !     (void) signal(SIGFPE, quit);
  1316.   #ifdef    SIGWINCH
  1317.       (void) signal(SIGWINCH, winchg);
  1318.   #endif
  1319. --- 1332,1343 ----
  1320.       (void) signal(SIGINT, SIG_IGN);
  1321.   #if !defined(MSDOS)
  1322.       (void) signal(SIGQUIT, dump_me);
  1323. !     (void) signal(SIGPIPE, doquit);
  1324.       (void) signal(SIGALRM, time_out);
  1325. !     (void) signal(SIGBUS, doquit);
  1326.   #endif
  1327. !     (void) signal(SIGTERM, doquit);
  1328. !     (void) signal(SIGFPE, doquit);
  1329.   #ifdef    SIGWINCH
  1330.       (void) signal(SIGWINCH, winchg);
  1331.   #endif
  1332. ***************
  1333. *** 1339,1345 ****
  1334.   #else
  1335.   int
  1336.   #endif
  1337. ! quit()
  1338.   {
  1339.       diesave();
  1340.       stopdisp();
  1341. --- 1360,1366 ----
  1342.   #else
  1343.   int
  1344.   #endif
  1345. ! doquit()
  1346.   {
  1347.       diesave();
  1348.       stopdisp();
  1349. *** ../619/sc.h    Mon Mar 16 10:09:44 1992
  1350. --- sc.h    Fri May  8 12:31:32 1992
  1351. ***************
  1352. *** 6,12 ****
  1353.    *            University of Maryland
  1354.    *        R. Bond  12/86
  1355.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1356. !  *        $Revision: 6.19 $
  1357.    *
  1358.    */
  1359.   
  1360. --- 6,12 ----
  1361.    *            University of Maryland
  1362.    *        R. Bond  12/86
  1363.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1364. !  *        $Revision: 6.21 $
  1365.    *
  1366.    */
  1367.   
  1368. ***************
  1369. *** 129,134 ****
  1370. --- 129,135 ----
  1371.   struct enode {
  1372.       int op;
  1373.       union {
  1374. +     int gram_match;         /* some compilers (hp9000ipc) need this */
  1375.       double k;        /* constant # */
  1376.       struct ent_ptr v;    /* ref. another cell */
  1377.       struct range_s r;    /* op is on a range */
  1378. ***************
  1379. *** 205,210 ****
  1380. --- 206,212 ----
  1381.   #define UPPER OP_BASE + 55
  1382.   #define LOWER OP_BASE + 56
  1383.   #define CAPITAL OP_BASE + 57
  1384. + #define NUMITER    OP_BASE + 58
  1385.   
  1386.   /* flag values */
  1387.   #define is_valid     0001
  1388. ***************
  1389. *** 233,238 ****
  1390. --- 235,241 ----
  1391.   #define    LATEX    2        /* 'LaTeX' */
  1392.   #define    TEX    3        /* 'TeX' */
  1393.   #define    SLATEX    4        /* 'SLaTeX' (Scandinavian LaTeX) */
  1394. + #define    FRAME    5        /* tblprint style output for FrameMaker */
  1395.   
  1396.   /* Types for etype() */
  1397.   #define NUM    1
  1398. ***************
  1399. *** 269,278 ****
  1400.   extern    char *coltoa();
  1401.   extern    char *findhome();
  1402.   extern    char *r_name();
  1403.   extern    char *strrchr();
  1404.   extern    char *v_name();
  1405. - extern    char *xmalloc();
  1406. - extern    char *xrealloc();
  1407.   extern    int any_locked_cells();
  1408.   extern    int are_ranges();
  1409.   extern    int atocol();
  1410. --- 272,281 ----
  1411.   extern    char *coltoa();
  1412.   extern    char *findhome();
  1413.   extern    char *r_name();
  1414. + extern    char *scxmalloc();
  1415. + extern    char *scxrealloc();
  1416.   extern    char *strrchr();
  1417.   extern    char *v_name();
  1418.   extern    int any_locked_cells();
  1419.   extern    int are_ranges();
  1420.   extern    int atocol();
  1421. ***************
  1422. *** 357,362 ****
  1423. --- 360,366 ----
  1424.   extern    void readfile();
  1425.   extern    void resetkbd();
  1426.   extern    void rowshow_op();
  1427. + extern    void scxfree();
  1428.   extern    void setauto();
  1429.   extern    void setiterations();
  1430.   extern    void setorder();
  1431. ***************
  1432. *** 376,382 ****
  1433.   extern    void write_fd();
  1434.   extern    void write_line();
  1435.   extern    void write_range();
  1436. - extern    void xfree();
  1437.   extern    void yyerror();
  1438.   #ifdef DOBACKUPS
  1439.   extern    int backup_file();
  1440. --- 380,385 ----
  1441. ***************
  1442. *** 383,393 ****
  1443. --- 386,399 ----
  1444.   #endif
  1445.   
  1446.   extern    int modflg;
  1447. + #if !defined(VMS) && !defined(MSDOS) && defined(CRYPT_PATH)
  1448.   extern    int Crypt;
  1449. + #endif
  1450.   extern    char *mdir;
  1451.   extern    double prescale;
  1452.   extern    int extfunc;
  1453.   extern    int propagation;
  1454. + extern    int repct;
  1455.   extern    int calc_order;
  1456.   extern    int autocalc;
  1457.   extern    int autolabel;
  1458. ***************
  1459. *** 415,418 ****
  1460. --- 421,426 ----
  1461.   #if defined(BSD42) || defined(BSD43) && !defined(ultrix)
  1462.   #define    memcpy(dest, source, len)    bcopy(source, dest, (unsigned int)len);
  1463.   #define    memset(dest, zero, len)        bzero((dest), (unsigned int)(len));
  1464. + #else
  1465. + #include <memory.h>
  1466.   #endif
  1467. *** ../619/screen.c    Mon Mar 16 10:09:45 1992
  1468. --- screen.c    Fri May  8 12:31:33 1992
  1469. ***************
  1470. *** 8,14 ****
  1471.    *              More mods Robert Bond, 12/86
  1472.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1473.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1474. !  *        $Revision: 6.19 $
  1475.    *
  1476.    */
  1477.   
  1478. --- 8,14 ----
  1479.    *              More mods Robert Bond, 12/86
  1480.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1481.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1482. !  *        $Revision: 6.21 $
  1483.    *
  1484.    */
  1485.   
  1486. ***************
  1487. *** 543,550 ****
  1488.       initkbd();
  1489.       scrollok(stdscr, 1);
  1490.   
  1491. ! #ifndef IDLOKBAD
  1492. ! # ifdef SYSV3
  1493.       /*
  1494.        * turn hardware insert/delete on, if possible.
  1495.        * turn on scrolling for systems with SYSVr3.{1,2} (SYSVr3.0 has this set
  1496. --- 543,550 ----
  1497.       initkbd();
  1498.       scrollok(stdscr, 1);
  1499.   
  1500. ! #if defined(SYSV3) && !defined(NOIDLOK)
  1501. ! # ifndef IDLOKBAD
  1502.       /*
  1503.        * turn hardware insert/delete on, if possible.
  1504.        * turn on scrolling for systems with SYSVr3.{1,2} (SYSVr3.0 has this set
  1505. ***************
  1506. *** 551,558 ****
  1507.        * as the default)
  1508.        */
  1509.        idlok(stdscr,TRUE);
  1510. ! # endif
  1511. ! #else    /*
  1512.        * This seems to fix (with an empty spreadsheet):
  1513.        *    a) Redrawing the bottom half of the screen when you
  1514.        *        move between row 9 <-> 10
  1515. --- 551,557 ----
  1516.        * as the default)
  1517.        */
  1518.        idlok(stdscr,TRUE);
  1519. ! # else    /*
  1520.        * This seems to fix (with an empty spreadsheet):
  1521.        *    a) Redrawing the bottom half of the screen when you
  1522.        *        move between row 9 <-> 10
  1523. ***************
  1524. *** 566,571 ****
  1525. --- 565,571 ----
  1526.        *     noticing the rows become 2, 3, 40, 41, 42... (etc).
  1527.        */
  1528.        idlok(stdscr,FALSE);
  1529. + # endif
  1530.   #endif
  1531.   
  1532.       FullUpdate++;
  1533. *** ../619/version.c    Mon Mar 16 10:09:45 1992
  1534. --- version.c    Fri May  8 12:31:33 1992
  1535. ***************
  1536. *** 4,7 ****
  1537.    * The part after the first colon, except the last char, appears on the screen.
  1538.    */
  1539.   
  1540. ! char *rev = "$Revision: 6.19 $";
  1541. --- 4,7 ----
  1542.    * The part after the first colon, except the last char, appears on the screen.
  1543.    */
  1544.   
  1545. ! char *rev = "$Revision: 6.21 $";
  1546. *** ../619/vi.c    Mon Mar 16 10:09:46 1992
  1547. --- vi.c    Fri May  8 12:31:34 1992
  1548. ***************
  1549. *** 1,7 ****
  1550.   /*    SC    A Spreadsheet Calculator
  1551.    *
  1552.    *    One line vi emulation
  1553. !  *    $Revision: 6.19 $
  1554.    */
  1555.   
  1556.   #include <sys/types.h>
  1557. --- 1,7 ----
  1558.   /*    SC    A Spreadsheet Calculator
  1559.    *
  1560.    *    One line vi emulation
  1561. !  *    $Revision: 6.21 $
  1562.    */
  1563.   
  1564.   #include <sys/types.h>
  1565. ***************
  1566. *** 104,109 ****
  1567. --- 104,110 ----
  1568.       case 'R':    replace_mode();            break;
  1569.       case 'X':    u_save(c); back_space();    break;
  1570.       case 'a':    u_save(c); append_line();    break;
  1571. +     case 'A':    u_save(c);last_col();append_line();    break;
  1572.       case 'b':    linelim = back_word();        break;
  1573.       case 'c':    u_save(c); change_cmd();    break;
  1574.       case 'd':    u_save(c); delete_cmd();    break;
  1575. ***************
  1576. *** 251,257 ****
  1577.       if (strlen(line)+1 > undolen)
  1578.       {    undolen = strlen(line)+40;
  1579.   
  1580. !     undo_line = xrealloc(undo_line, undolen);
  1581.       }
  1582.       (void) strcpy(undo_line, line);
  1583.   
  1584. --- 252,258 ----
  1585.       if (strlen(line)+1 > undolen)
  1586.       {    undolen = strlen(line)+40;
  1587.   
  1588. !     undo_line = scxrealloc(undo_line, undolen);
  1589.       }
  1590.       (void) strcpy(undo_line, line);
  1591.   
  1592. ***************
  1593. *** 278,284 ****
  1594.   
  1595.       if (strlen(line)+1 > templen)
  1596.       {    templen = strlen(line)+40;
  1597. !     tempc = xrealloc(tempc, templen);
  1598.       }
  1599.   
  1600.       strcpy(tempc, line);
  1601. --- 279,285 ----
  1602.   
  1603.       if (strlen(line)+1 > templen)
  1604.       {    templen = strlen(line)+40;
  1605. !     tempc = scxrealloc(tempc, templen);
  1606.       }
  1607.   
  1608.       strcpy(tempc, line);
  1609. ***************
  1610. *** 595,601 ****
  1611.   
  1612.       if (history[lasthist].len < strlen(line)+1)
  1613.       {    history[lasthist].len = strlen(line)+40;
  1614. !     history[lasthist].histline = xrealloc(history[lasthist].histline,
  1615.                             history[lasthist].len);
  1616.       }
  1617.       (void) strcpy(history[lasthist].histline, line);
  1618. --- 596,602 ----
  1619.   
  1620.       if (history[lasthist].len < strlen(line)+1)
  1621.       {    history[lasthist].len = strlen(line)+40;
  1622. !     history[lasthist].histline = scxrealloc(history[lasthist].histline,
  1623.                             history[lasthist].len);
  1624.       }
  1625.       (void) strcpy(history[lasthist].histline, line);
  1626. ***************
  1627. *** 636,642 ****
  1628.   
  1629.       if (strlen(line)+1 > lastsrchlen)
  1630.       {    lastsrchlen = strlen(line)+40;
  1631. !     last_search = xrealloc(last_search, lastsrchlen);
  1632.       }
  1633.       (void)strcpy(last_search, line+1);
  1634.       search_again();
  1635. --- 637,643 ----
  1636.   
  1637.       if (strlen(line)+1 > lastsrchlen)
  1638.       {    lastsrchlen = strlen(line)+40;
  1639. !     last_search = scxrealloc(last_search, lastsrchlen);
  1640.       }
  1641.       (void)strcpy(last_search, line+1);
  1642.       search_again();
  1643. *** ../619/vmtbl.c    Mon Mar 16 10:09:47 1992
  1644. --- vmtbl.c    Fri May  8 12:31:35 1992
  1645. ***************
  1646. *** 8,14 ****
  1647.    *              More mods Robert Bond, 12/86
  1648.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1649.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1650. !  *        $Revision: 6.19 $
  1651.    *
  1652.    */
  1653.   #ifdef PSC
  1654. --- 8,14 ----
  1655.    *              More mods Robert Bond, 12/86
  1656.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1657.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1658. !  *        $Revision: 6.21 $
  1659.    *
  1660.    */
  1661.   #ifdef PSC
  1662. ***************
  1663. *** 54,62 ****
  1664.   }
  1665.   #endif /* !PSC */
  1666.       
  1667. ! /* xrealloc will just xmalloc if oldptr is == NULL */
  1668.   #define GROWALLOC(newptr, oldptr, nelem, type, msg) \
  1669. !     newptr = (type *)xrealloc((char *)oldptr, \
  1670.                        (unsigned)(nelem*sizeof(type))); \
  1671.       if (newptr == (type *)NULL) \
  1672.       {   error(msg); \
  1673. --- 54,62 ----
  1674.   }
  1675.   #endif /* !PSC */
  1676.       
  1677. ! /* scxrealloc will just scxmalloc if oldptr is == NULL */
  1678.   #define GROWALLOC(newptr, oldptr, nelem, type, msg) \
  1679. !     newptr = (type *)scxrealloc((char *)oldptr, \
  1680.                        (unsigned)(nelem*sizeof(type))); \
  1681.       if (newptr == (type *)NULL) \
  1682.       {   error(msg); \
  1683. ***************
  1684. *** 177,183 ****
  1685.           /* [re]alloc the space for each row */
  1686.           for (i = 0; i < maxrows; i++)
  1687.           {
  1688. !             if ((tbl[i] = (struct ent **)xrealloc((char *)tbl[i],
  1689.               (unsigned)(newcols * sizeof(struct ent **)))) == (struct ent **)0)
  1690.               {    error(nowider);
  1691.                   return(FALSE);
  1692. --- 177,183 ----
  1693.           /* [re]alloc the space for each row */
  1694.           for (i = 0; i < maxrows; i++)
  1695.           {
  1696. !             if ((tbl[i] = (struct ent **)scxrealloc((char *)tbl[i],
  1697.               (unsigned)(newcols * sizeof(struct ent **)))) == (struct ent **)0)
  1698.               {    error(nowider);
  1699.                   return(FALSE);
  1700. ***************
  1701. *** 195,201 ****
  1702.   
  1703.       /* fill in the bottom of the table */
  1704.       for (; i < newrows; i++)
  1705. !     {    if ((tbl[i] = (struct ent **)xmalloc((unsigned)(newcols *
  1706.                   sizeof(struct ent **)))) == (struct ent **)0)
  1707.           {    error(nowider);
  1708.               return(FALSE);
  1709. --- 195,201 ----
  1710.   
  1711.       /* fill in the bottom of the table */
  1712.       for (; i < newrows; i++)
  1713. !     {    if ((tbl[i] = (struct ent **)scxmalloc((unsigned)(newcols *
  1714.                   sizeof(struct ent **)))) == (struct ent **)0)
  1715.           {    error(nowider);
  1716.               return(FALSE);
  1717. *** ../619/xmalloc.c    Mon Mar 16 10:09:47 1992
  1718. --- xmalloc.c    Fri May  8 12:31:35 1992
  1719. ***************
  1720. *** 1,6 ****
  1721.   /*
  1722.    * A safer saner malloc, for careless programmers
  1723. !  * $Revision: 6.19 $
  1724.    */
  1725.   
  1726.   #include <stdio.h>
  1727. --- 1,6 ----
  1728.   /*
  1729.    * A safer saner malloc, for careless programmers
  1730. !  * $Revision: 6.21 $
  1731.    */
  1732.   
  1733.   #include <stdio.h>
  1734. ***************
  1735. *** 17,32 ****
  1736.   extern void exit();
  1737.   #endif
  1738.   
  1739. ! #define    MAGIC    (double)1234567890.1234456789
  1740.   
  1741.   char *
  1742. ! xmalloc(n)
  1743.   unsigned n;
  1744.   {
  1745.       register char *ptr;
  1746.   
  1747.       if ((ptr = malloc(n + sizeof(double))) == NULL)
  1748. !         fatal("xmalloc: no memory");
  1749.       *((double *) ptr) = MAGIC;        /* magic number */
  1750.       return(ptr + sizeof(double));
  1751.   }
  1752. --- 17,32 ----
  1753.   extern void exit();
  1754.   #endif
  1755.   
  1756. ! #define    MAGIC    (double)1234567890.12344
  1757.   
  1758.   char *
  1759. ! scxmalloc(n)
  1760.   unsigned n;
  1761.   {
  1762.       register char *ptr;
  1763.   
  1764.       if ((ptr = malloc(n + sizeof(double))) == NULL)
  1765. !         fatal("scxmalloc: no memory");
  1766.       *((double *) ptr) = MAGIC;        /* magic number */
  1767.       return(ptr + sizeof(double));
  1768.   }
  1769. ***************
  1770. *** 33,64 ****
  1771.   
  1772.   /* we make sure realloc will do a malloc if needed */
  1773.   char *
  1774. ! xrealloc(ptr, n)
  1775.   char    *ptr;
  1776.   unsigned n;
  1777.   {
  1778.       if (ptr == NULL)
  1779. !         return(xmalloc(n));
  1780.   
  1781.       ptr -= sizeof(double);
  1782.       if (*((double *) ptr) != MAGIC)
  1783. !         fatal("xrealloc: storage not xmalloc'ed");
  1784.   
  1785.       if ((ptr = realloc(ptr, n + sizeof(double))) == NULL)
  1786. !         fatal("xmalloc: no memory");
  1787.       *((double *) ptr) = MAGIC;        /* magic number */
  1788.       return(ptr + sizeof(double));
  1789.   }
  1790.   
  1791.   void
  1792. ! xfree(p)
  1793.   char *p;
  1794.   {
  1795.       if (p == NULL)
  1796. !         fatal("xfree: NULL");
  1797.       p -= sizeof(double);
  1798.       if (*((double *) p) != MAGIC)
  1799. !         fatal("xfree: storage not malloc'ed");
  1800.       free(p);
  1801.   }
  1802.   
  1803. --- 33,64 ----
  1804.   
  1805.   /* we make sure realloc will do a malloc if needed */
  1806.   char *
  1807. ! scxrealloc(ptr, n)
  1808.   char    *ptr;
  1809.   unsigned n;
  1810.   {
  1811.       if (ptr == NULL)
  1812. !         return(scxmalloc(n));
  1813.   
  1814.       ptr -= sizeof(double);
  1815.       if (*((double *) ptr) != MAGIC)
  1816. !         fatal("scxrealloc: storage not scxmalloc'ed");
  1817.   
  1818.       if ((ptr = realloc(ptr, n + sizeof(double))) == NULL)
  1819. !         fatal("scxmalloc: no memory");
  1820.       *((double *) ptr) = MAGIC;        /* magic number */
  1821.       return(ptr + sizeof(double));
  1822.   }
  1823.   
  1824.   void
  1825. ! scxfree(p)
  1826.   char *p;
  1827.   {
  1828.       if (p == NULL)
  1829. !         fatal("scxfree: NULL");
  1830.       p -= sizeof(double);
  1831.       if (*((double *) p) != MAGIC)
  1832. !         fatal("scxfree: storage not malloc'ed");
  1833.       free(p);
  1834.   }
  1835.   
  1836.  
  1837. exit 0 # Just in case...
  1838.