home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / sc / patch02 < prev    next >
Encoding:
Text File  |  1991-09-20  |  50.8 KB  |  1,818 lines

  1. Newsgroups: comp.sources.misc
  2. From: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
  3. Subject:  REPOST: v22i104:  sc - The SC Spreadsheet, Patch02
  4. Message-ID: <1991Sep20.143836.6133@sparky.imd.sterling.com>
  5. X-Md4-Signature: b30a94b2d9df7f39f935859849d5f57b
  6. Date: Fri, 20 Sep 1991 14:38:36 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
  10. Posting-number: Volume 22, Issue 104
  11. Archive-name: sc/patch02
  12. Environment: UNIX, VMS, MS-DOS
  13. Patch-To: sc: Volume 20, Issue 35-41
  14.  
  15. [ This is being reposted due to a propagation error. ]
  16.  
  17. REQUIRES patch01 be applied first, the new revision level will be: 6.18.
  18.  
  19. James found a potential NULL pointer in the last patch, I found another
  20. that has been around a while that might have caused problems on: Suns,
  21. VAX, CCI, and maybe IBM/370 type iron.
  22.  
  23. A few new, really nice features are listed below.
  24.  
  25.                         -Jeff Buhrt
  26.                     {sequent,uunet}!sawmill!prslnk!buhrt
  27.                     812-275-0750 work
  28.                     Proslink, Inc.
  29.  
  30. *** 6.17    1991/09/04 14:20:49
  31. --- CHANGES    1991/09/09 19:19:29
  32. ***************
  33. *** 1,3 ****
  34. --- 1,29 ----
  35. + CHANGES BETWEEN 6.18 and 6.17
  36. + James Dugal    
  37. +     - NULL pointer fix for is_locked
  38. + Kevin Pye
  39. +     - add a new mode suitable for entry of large amounts of data.
  40. +         moves to next cell on return, maxrow/col when to start
  41. +         entering in the next row/col. (see help screens B&C)
  42. +     COMMANDS ADDED: ^Tz, ^Tr, Srowlimit=?, Scollimit=?
  43. + David Fox - added a date format so that columns whose values are the number
  44. +     of seconds since 1/1/70 will be displayed as dates in the format
  45. +     dd-mmm-yy, and a modification to the grammar so data entered in the
  46. +     format dd_mm_yy will be converted into the number of seconds since
  47. +     1/1/70.
  48. +     COMMANDS ADDED: f # # 3
  49. + Teus Hagen
  50. +     - labels are centered strings
  51. +     - constant strings with '\' preceeding character will
  52. +       be wheeled over the column width
  53. +     - a restart of sc on an sc file will go to last used cel
  54. +     - added toupper, tolower and do proper word capitalization
  55. +     COMMANDS ADDED: @toupper(), @tolower(), @capital(), @pi, "\[String]
  56. + Jeff Buhrt
  57. +     - external functions null/previous message was backwards
  58. +     - cleaned up help.c by inserting a new screen
  59. +     - found a possible NULL pointer in screen.c
  60.   CHANGES BETWEEN 6.17 and 6.16
  61.   Ulf Noren
  62.       - added cell locking, disallowing input, to ranges of cells
  63. *** 6.17    1991/09/04 14:20:49
  64. --- README    1991/09/09 19:14:35
  65. ***************
  66. *** 1,7 ****
  67.   This is a much modified version of the public domain spread sheet sc,
  68.   posted several years ago by Mark Weiser as vc, originally by James Gosling.
  69.   
  70. ! CHANGES lists the changes since 6.1 to 6.17.
  71.   Current maintainer: {sequent, uunet}!sawmill!prslnk!buhrt (Jeff Buhrt)
  72.   
  73.   When you get it built, try "sc tutorial.sc" for a simple introduction
  74. --- 1,10 ----
  75.   This is a much modified version of the public domain spread sheet sc,
  76.   posted several years ago by Mark Weiser as vc, originally by James Gosling.
  77.   
  78. ! CHANGES lists the changes since 6.1 to 6.18.
  79. !     Sc6.16 was released to comp.sources.misc and two sets of patches
  80. !     bring Sc6.16->6.17->6.18.
  81.   Current maintainer: {sequent, uunet}!sawmill!prslnk!buhrt (Jeff Buhrt)
  82.   
  83.   When you get it built, try "sc tutorial.sc" for a simple introduction
  84. *** 6.17    1991/09/04 14:20:49
  85. --- sc.doc    1991/09/09 19:14:40
  86. ***************
  87. *** 15,21 ****
  88.   .\" - TPs use default indent except for function names, then 18.
  89.   .\" - Smallify uppercase strings.
  90.   .\" - Avoid passive voice and third person.
  91. ! .\" $Revision: 6.17 $
  92.   .\"
  93.   .TH PNAME\ #REVISION#\  1
  94.   .SH NAME
  95. --- 15,21 ----
  96.   .\" - TPs use default indent except for function names, then 18.
  97.   .\" - Smallify uppercase strings.
  98.   .\" - Avoid passive voice and third person.
  99. ! .\" $Revision: 6.18 $
  100.   .\"
  101.   .TH PNAME\ #REVISION#\  1
  102.   .SH NAME
  103. ***************
  104. *** 98,103 ****
  105. --- 98,113 ----
  106.   .I Put
  107.   commands (see below) to encrypt and decrypt data files.
  108.   .\" ----------
  109. + .TP
  110. + .B \-R
  111. + Start the program with automatic newline action set to increment the row
  112. + (see below).
  113. + .\" ----------
  114. + .TP
  115. + .B \-C
  116. + Start the program with automatic newline action set to increment the column
  117. + (see below).
  118. + .\" ----------
  119.   .PP
  120.   All of these options can be changed with the
  121.   .I ^T
  122. ***************
  123. *** 245,255 ****
  124.   the name and value of the current cell is displayed on the top line.
  125.   If there is an associated label string,
  126.   the first character of the string value
  127. ! is ``<'' for a leftstring or ``>'' for a rightstring (see below),
  128.   followed by "\fIstring\fP" for a constant string
  129.   or
  130.   .RI { expr }
  131.   for a string expression.
  132.   If the cell has a numeric value,
  133.   it follows as
  134.   .RI [ value ],
  135. --- 255,269 ----
  136.   the name and value of the current cell is displayed on the top line.
  137.   If there is an associated label string,
  138.   the first character of the string value
  139. ! is ``|'' for a centered string, ``<'' for a leftstring or ``>'' for a rightstring (see below),
  140.   followed by "\fIstring\fP" for a constant string
  141.   or
  142.   .RI { expr }
  143.   for a string expression.
  144. + A constant string may be preceeded with a backslash (`\\').
  145. + In this case the constant string will be used as a ``wheel''
  146. + to fill a column, e.g. "\\-" for a line in a column,
  147. + and "\\Yeh " for "Yeh Yeh Ye".
  148.   If the cell has a numeric value,
  149.   it follows as
  150.   .RI [ value ],
  151. ***************
  152. *** 270,275 ****
  153. --- 284,333 ----
  154.   (not expressions) which you enter are multipled by 0.01
  155.   so you don't have to keep typing the decimal point
  156.   if you enter lots of dollar figures.
  157. + .\" ----------
  158. + .TP
  159. + .B r
  160. + Newline action.
  161. + This option toggles between three cases.
  162. + The default is no action.
  163. + If this option is used once, after each command which is terminated
  164. + by a newline character is completed, the current cell will be moved
  165. + down one row.
  166. + If this option is used again, after each command which is terminated
  167. + by a newline character is completed, the current cell will be moved
  168. + right one column.
  169. + Another use of this option will restore the default action.
  170. + .\" ----------
  171. + .TP
  172. + .B z
  173. + Set newline action limits.
  174. + This option sets limits to the newline action option above.
  175. + When this option is invoked, the row and column of the current cell are
  176. + remembered.
  177. + If a later newline action would take the current cell to the right of
  178. + the remembered column, then the current cell is instead moved to the
  179. + first column of the next row.
  180. + If a newline action would take the current cell below the remembered row,
  181. + then the current cell is instead moved to the top row of the next column.
  182. + .PP
  183. + The quick numeric entry, newline action and set newline action limits options
  184. + can be combined to allow very quick entry of large amounts of data.
  185. + If all the data to be entered is in a single row or column then setting
  186. + the quick numeric entry and the appropriate newline action will allow
  187. + the numbers to be entered without any explicit commands to position the
  188. + current cell or enter a number.
  189. + .PP
  190. + If the data entry involves several entries in each row for many rows, then
  191. + setting the quick numeric entry option, setting the newline action to move
  192. + right after each entry and setting the newline action limits on the last
  193. + column on which data should be entered will allow the data to entered
  194. + quickly.
  195. + If necessary, columns which do not need data to be entered can be hidden with
  196. + the
  197. + .B z
  198. + command.
  199. + Similar arrangements can be made for entering several rows of data
  200. + in each column.
  201.   .RE
  202.   .\" ----------
  203.   \0 \" exactly one blank line (hard to get)
  204. ***************
  205. *** 354,359 ****
  206. --- 412,446 ----
  207.   default: round-to-even (banker's round), *.5 will round to the closest even
  208.   number; doing a 'set rndinfinity' will round *.5 up to the next integer
  209.   (rounding to infinity).
  210. + .TP
  211. + .BI craction =n
  212. + Set the newline action.
  213. + .I n
  214. + can be:
  215. + .B 0
  216. + (default) to give no action;
  217. + .B 1
  218. + to move down after each entry; or
  219. + .B 2
  220. + to move right after each entry.
  221. + .TP
  222. + .BI rowlimit =n
  223. + Set the remembered limit for the maximum row below which
  224. + the current cell will be moved to the top of the next column
  225. + if the newline action is set to move the current cell down.
  226. + .I n
  227. + can be
  228. + .B -1
  229. + (default) to disable this facility.
  230. + .TP
  231. + .BI collimit =n
  232. + Set the remembered limit for the maximum column to the right of which
  233. + the current cell will be moved to the left of the next row
  234. + if the newline action is set to move the current cell right.
  235. + .I n
  236. + can be
  237. + .B -1
  238. + (default) to disable this facility.
  239.   .RE
  240.   .\" ==========
  241.   .SS "Cursor Control Commands"
  242. ***************
  243. *** 540,545 ****
  244. --- 627,635 ----
  245.   .\" ----------
  246.   .IP \fB"\fP
  247.   .PD 0
  248. + Enter a label string into the current cell
  249. + to be centered in the column.
  250. + .\" ----------
  251.   .TP
  252.   .B >
  253.   Enter a label string into the current cell
  254. ***************
  255. *** 1052,1058 ****
  256.   the total width in characters of the column,
  257.   the number of digits to follow decimal points,
  258.   and the format type.  Format types are 0 for fixed point,
  259. ! 1 for scientific notation, and 2 for engineering notation.
  260.   Values are rounded off to the least significant digit displayed.
  261.   The total column width affects displays of strings as well as numbers.
  262.   A preceding count can be used to affect more than one column.
  263. --- 1142,1148 ----
  264.   the total width in characters of the column,
  265.   the number of digits to follow decimal points,
  266.   and the format type.  Format types are 0 for fixed point,
  267. ! 1 for scientific notation, 2 for engineering notation, and 3 for dates.
  268.   Values are rounded off to the least significant digit displayed.
  269.   The total column width affects displays of strings as well as numbers.
  270.   A preceding count can be used to affect more than one column.
  271. ***************
  272. *** 1798,1804 ****
  273.   and string functions.
  274.   Note that string expressions are only allowed
  275.   when entering a cell's label string, not its numeric part.
  276. ! Also note that string expression results may be left or right flushed,
  277.   according to the type of the cell's string label.
  278.   .\" ----------
  279.   .TP
  280. --- 1888,1894 ----
  281.   and string functions.
  282.   Note that string expressions are only allowed
  283.   when entering a cell's label string, not its numeric part.
  284. ! Also note that string expression results may be left or right flushed or centered,
  285.   according to the type of the cell's string label.
  286.   .\" ----------
  287.   .TP
  288. ***************
  289. *** 1874,1879 ****
  290. --- 1964,1981 ----
  291.   the result is the null string.
  292.   You can use this for simple table lookups.
  293.   Be sure the table doesn't move unexpectedly!
  294. + .\" ----------
  295. + .TP 18
  296. + .BR @upper (e)
  297. + and
  298. + .BR @lower (e)
  299. + will case the string expression to upper or lower.
  300. + .\" ----------
  301. + .TP 18
  302. + .BR @capital (e)
  303. + will convert the first letter of words in a string
  304. + into upper case and other letters to lower case
  305. + (the latter if all letters of the string are upper case).
  306.   .\" ----------
  307.   .TP 18
  308.   .BR @upper (e)
  309. *** 6.17    1991/09/04 14:20:49
  310. --- cmds.c    1991/09/09 19:14:46
  311. ***************
  312. *** 7,13 ****
  313.    *
  314.    *              More mods Robert Bond, 12/86
  315.    *
  316. !  *        $Revision: 6.17 $
  317.    */
  318.   
  319.   #include <sys/types.h>
  320. --- 7,13 ----
  321.    *
  322.    *              More mods Robert Bond, 12/86
  323.    *
  324. !  *        $Revision: 6.18 $
  325.    */
  326.   
  327.   #include <sys/types.h>
  328. ***************
  329. *** 189,195 ****
  330.       for (r = sr; r <= er; r++) {
  331.       for (c = sc; c <= ec; c++) {
  332.           p = *ATBL(tbl, r, c);
  333. !         if (p->flags&is_locked) {
  334.           error(" Cell %s%d is locked", coltoa(c), r);
  335.           continue;
  336.           }
  337. --- 189,195 ----
  338.       for (r = sr; r <= er; r++) {
  339.       for (c = sc; c <= ec; c++) {
  340.           p = *ATBL(tbl, r, c);
  341. !         if (p && p->flags&is_locked) {
  342.           error(" Cell %s%d is locked", coltoa(c), r);
  343.           continue;
  344.           }
  345. ***************
  346. *** 620,629 ****
  347.       error("Precision too large");
  348.       p = w;
  349.       }
  350. !     /* format statement may record format of an as yet unused column
  351. !      * which causes it to run off the end of fwidth and precision --
  352. !      * causing a bus error later
  353. !      */
  354.       checkbounds(&crows, &ccols);
  355.       if (ccols < c2) {
  356.       error("Format statement failed to create implied column %d", c2);
  357. --- 620,626 ----
  358.       error("Precision too large");
  359.       p = w;
  360.       }
  361.       checkbounds(&crows, &ccols);
  362.       if (ccols < c2) {
  363.       error("Format statement failed to create implied column %d", c2);
  364. ***************
  365. *** 650,656 ****
  366.          !extfunc &&
  367.          showcell &&
  368.          showtop &&
  369. !        tbl_style == 0
  370.         )
  371.           return;        /* No reason to do this */
  372.   
  373. --- 647,656 ----
  374.          !extfunc &&
  375.          showcell &&
  376.          showtop &&
  377. !        tbl_style == 0 &&
  378. !        craction == 0 &&
  379. !        rowlimit == -1 &&
  380. !        collimit == -1
  381.         )
  382.           return;        /* No reason to do this */
  383.   
  384. ***************
  385. *** 676,681 ****
  386. --- 676,687 ----
  387.                       tbl_style == LATEX ? "latex" :
  388.                       tbl_style == SLATEX ? "slatex" :
  389.                       tbl_style == TEX ? "tex" : "0" );
  390. +     if (craction)
  391. +     (void) fprintf(f, " craction = %d", craction);
  392. +     if (rowlimit >= 0)
  393. +     (void) fprintf(f, " rowlimit = %d", rowlimit);
  394. +     if (collimit >= 0)
  395. +     (void) fprintf(f, " collimit = %d", collimit);
  396.       (void) fprintf(f, "\n");
  397.   }
  398.   
  399. ***************
  400. *** 785,792 ****
  401.               register char *fp;
  402.               struct ent *nc;
  403.   
  404. !             /* Figure out if the label slops over to a blank field */
  405.               slen = strlen(s);
  406.               while (slen > fieldlen && nextcol <= cn &&
  407.                   !((nc = lookat(row,nextcol))->flags & is_valid) &&
  408.                   !(nc->label)) {
  409. --- 791,803 ----
  410.               register char *fp;
  411.               struct ent *nc;
  412.   
  413. !             /*
  414. !              * Figure out if the label slops over to a blank field. A
  415. !              * string started with backslah is defining repition char
  416. !              */
  417.               slen = strlen(s);
  418. +             if ( *s == '\\' && *(s+1)!= '\0' )
  419. +             slen = fwidth[col];
  420.               while (slen > fieldlen && nextcol <= cn &&
  421.                   !((nc = lookat(row,nextcol))->flags & is_valid) &&
  422.                   !(nc->label)) {
  423. ***************
  424. *** 812,823 ****
  425. --- 823,846 ----
  426.               /* Now justify and print */
  427.               start = (*pp)->flags & is_leftflush ? pline + c
  428.                       : pline + c + fieldlen - slen;
  429. +             if( (*pp)->flags & is_label )
  430. +             start = pline + (c + ((fwidth[col]>slen)?(fwidth[col]-slen)/2:0));
  431.               last = pline + c + fieldlen;
  432.               fp = plinelim < c ? pline + plinelim : pline + c;
  433.               while (fp < start)
  434.               *fp++ = ' ';
  435. +             if( *s == '\\' && *(s+1)!= '\0' ) {
  436. +             char *strt;
  437. +             strt = ++s;
  438. +             while(slen--) {
  439. +                 *fp++ = *s++; if( *s == '\0' ) s = strt;
  440. +             }
  441. +             }
  442. +             else
  443.               while (slen--)
  444.               *fp++ = *s++;
  445.               if (!((*pp)->flags & is_valid) || fieldlen != fwidth[col])
  446.               while(fp < last)
  447.                   *fp++ = ' ';
  448. ***************
  449. *** 944,949 ****
  450. --- 967,973 ----
  451.   char    *str;
  452.   int    delim;
  453.   {
  454. +     if( *str == '\\' ) str++; /* delete wheeling string operator, OK? */
  455.       while (*str)
  456.       {    if (((tbl_style == LATEX) || (tbl_style == SLATEX) ||
  457.               (tbl_style == TEX)) &&
  458. ***************
  459. *** 1275,1280 ****
  460. --- 1299,1305 ----
  461.   {
  462.       register struct ent **pp;
  463.       register r, c;
  464. +     extern char *v_name();
  465.   
  466.       (void) fprintf (f, "# This data file was generated by the Spreadsheet ");
  467.       (void) fprintf (f, "Calculator.\n");
  468. ***************
  469. *** 1321,1326 ****
  470. --- 1346,1352 ----
  471.       }
  472.       if (rndinfinity)
  473.       fprintf(f, "set rndinfinity\n");
  474. +     fprintf(f, "goto %s\n", v_name( currow, curcol ) );
  475.   }
  476.   
  477.   int
  478. ***************
  479. *** 1517,1525 ****
  480.    */
  481.   
  482.   void
  483. ! showstring (string, leftflush, hasvalue, row, col, nextcolp, mxcol, fieldlenp, r, c)
  484.       char *string;    /* to display */
  485. !     int leftflush;    /* or rightflush */
  486.       int hasvalue;    /* is there a numeric value? */
  487.       int row, col;    /* spreadsheet location */
  488.       int *nextcolp;    /* value returned through it */
  489. --- 1543,1551 ----
  490.    */
  491.   
  492.   void
  493. ! showstring (string, dirflush, hasvalue, row, col, nextcolp, mxcol, fieldlenp, r, c)
  494.       char *string;    /* to display */
  495. !     int dirflush;    /* or rightflush or centered */
  496.       int hasvalue;    /* is there a numeric value? */
  497.       int row, col;    /* spreadsheet location */
  498.       int *nextcolp;    /* value returned through it */
  499. ***************
  500. *** 1540,1545 ****
  501. --- 1566,1573 ----
  502.          slop over into the next blank field */
  503.   
  504.       slen = strlen (string);
  505. +     if( *string == '\\' && *(string+1)!= '\0' )
  506. +     slen = fwidth[col];
  507.       while ((slen > fieldlen) && (nextcol <= mxcol) &&
  508.          !((nc = lookat (row, nextcol)) -> flags & is_valid) &&
  509.          !(nc->label)) {
  510. ***************
  511. *** 1553,1565 ****
  512.       slen = fieldlen;
  513.   
  514.       /* Now justify and print */
  515. !     start = leftflush ? field : field + fieldlen - slen;
  516.       last = field+fieldlen;
  517.       fp = field;
  518.       while (fp < start)
  519.       *fp++ = ' ';
  520.       while (slen--)
  521.       *fp++ = *string++;
  522.       if ((! hasvalue) || fieldlen != fwidth[col]) 
  523.       while (fp < last)
  524.           *fp++ = ' ';
  525. --- 1581,1607 ----
  526.       slen = fieldlen;
  527.   
  528.       /* Now justify and print */
  529. !     start = (dirflush&is_leftflush) ? field : field + fieldlen - slen;
  530. !     if( dirflush & is_label )
  531. !     start = field + ((slen<fwidth[col])?(fieldlen-slen)/2:0);
  532.       last = field+fieldlen;
  533.       fp = field;
  534.       while (fp < start)
  535.       *fp++ = ' ';
  536. +     if( *string == '\\'  && *(string+1)!= '\0') {
  537. +     char *strt;
  538. +     strt = ++string;
  539. +     while(slen--) {
  540. +         *fp++ = *string++;
  541. +         if( *string == '\0' )
  542. +             string = strt;
  543. +     }
  544. +     }
  545. +     else
  546.       while (slen--)
  547.       *fp++ = *string++;
  548.       if ((! hasvalue) || fieldlen != fwidth[col]) 
  549.       while (fp < last)
  550.           *fp++ = ' ';
  551. ***************
  552. *** 1755,1757 ****
  553. --- 1797,1816 ----
  554.       return(0);
  555.   }
  556.   #endif
  557. + static int day_month_starts[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
  558. + double convert_date(d, m, y)
  559. + int d;
  560. + int m;
  561. + int y;
  562. + {
  563. +   /* Convert to years since 1970. (or 2000, fix by 2070) */
  564. +   if (y > 1970) y -= 1970;    /* Full year given */
  565. +   else if (y >= 70) y -= 70;    /* Years since 1900 */
  566. +   else y += 30;            /* Years since 2000 */
  567. +   /* Use quarter days to compensate for leap years. */
  568. +   return (double)((y * (365 * 4 + 1) + day_month_starts[m-1] * 4 + d * 4 - 2) *
  569. +           6 * 60 * 60);
  570. + }
  571. *** 6.17    1991/09/04 14:23:44
  572. --- format.c    1991/09/09 19:14:50
  573. ***************
  574. *** 3,9 ****
  575.    * Mark Nagel <nagel@ics.uci.edu>
  576.    * 20 July 1989
  577.    *
  578. !  * $Revision: 6.17 $
  579.    *
  580.    * bool
  581.    * format(fmt, num, buf, buflen)
  582. --- 3,9 ----
  583.    * Mark Nagel <nagel@ics.uci.edu>
  584.    * 20 July 1989
  585.    *
  586. !  * $Revision: 6.18 $
  587.    *
  588.    * bool
  589.    * format(fmt, num, buf, buflen)
  590. ***************
  591. *** 85,90 ****
  592. --- 85,92 ----
  593.   /*****************************************************************************/
  594.   
  595.   #include <stdio.h>
  596. + #include <sys/types.h>
  597. + #include <time.h>
  598.   #include "sc.h"
  599.   
  600.   #define bool    int
  601. ***************
  602. *** 508,516 ****
  603.    *
  604.    */
  605.   
  606. ! #define REFMTFIX 0
  607. ! #define REFMTFLT 1
  608. ! #define REFMTENG 2
  609.   char engmult[] = "afpnum kMGT";
  610.   
  611.   bool
  612. --- 510,523 ----
  613.    *
  614.    */
  615.   
  616. ! /* defined in sc.h */
  617. ! #ifndef REFMTFIX
  618. ! #define REFMTFIX    0
  619. ! #define REFMTFLT    1
  620. ! #define REFMTENG    2
  621. ! #define REFMTDATE    3
  622. ! #endif
  623.   char engmult[] = "afpnum kMGT";
  624.   
  625.   bool
  626. ***************
  627. *** 562,567 ****
  628. --- 569,599 ----
  629.           (void) sprintf(buf,"%*.*f%c", width-1,
  630.                         lprecision, engmant, engmult[engind]);
  631.         }
  632. +     }
  633. +   }
  634. +   if (fmt == REFMTDATE) {
  635. +     int i;
  636. +     char *time;
  637. +     long int secs;
  638. +     if (buflen < 9) {
  639. +       for (i = 0; i < width; i++) buf[i] = '*';
  640. +       buf[i] = '\0';
  641. +     }
  642. +     else {
  643. +       secs = (time_t)val;
  644. +       time = ctime(&secs);
  645. +       buf[0] = time[8];
  646. +       buf[1] = time[9];
  647. +       buf[2] = ' ';
  648. +       buf[3] = time[4];
  649. +       buf[4] = time[5];
  650. +       buf[5] = time[6];
  651. +       buf[6] = ' ';
  652. +       buf[7] = time[22];
  653. +       buf[8] = time[23];
  654. +       for (i = 9; i < width; i++) buf[i] = ' ';
  655. +       buf[i] = '\0';
  656.       }
  657.     }
  658.     return (true);
  659. *** 6.17    1991/09/04 14:20:49
  660. --- gram.y    1991/09/09 19:14:52
  661. ***************
  662. *** 9,15 ****
  663.    *
  664.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  665.    *
  666. !  *        $Revision: 6.17 $
  667.    */
  668.   
  669.   
  670. --- 9,15 ----
  671.    *
  672.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  673.    *
  674. !  *        $Revision: 6.18 $
  675.    */
  676.   
  677.   
  678. ***************
  679. *** 152,158 ****
  680.   %token K_MYROW
  681.   %token K_MYCOL
  682.   %token K_COLTOA
  683.   %left '?' ':'
  684.   %left '|'
  685.   %left '&'
  686. --- 152,163 ----
  687.   %token K_MYROW
  688.   %token K_MYCOL
  689.   %token K_COLTOA
  690. ! %token K_CRACTION
  691. ! %token K_CRROW
  692. ! %token K_CRCOL
  693. ! %token K_ROWLIMIT
  694. ! %token K_COLLIMIT
  695. !   
  696.   %left '?' ':'
  697.   %left '|'
  698.   %left '&'
  699. ***************
  700. *** 175,183 ****
  701.       |    S_FORMAT COL NUMBER NUMBER NUMBER
  702.                   { doformat($2,$2,$3,$4,$5); }
  703.           |       S_FORMAT COL ':' COL NUMBER NUMBER
  704. !                                 { doformat($2,$4,$5,$6, 0); }
  705.           |       S_FORMAT COL NUMBER NUMBER
  706. !                                 { doformat($2,$2,$3,$4, 0); }
  707.       |    S_GET strarg    {  /* This tmp hack is because readfile
  708.                       * recurses back through yyparse. */
  709.                     char *tmp;
  710. --- 180,188 ----
  711.       |    S_FORMAT COL NUMBER NUMBER NUMBER
  712.                   { doformat($2,$2,$3,$4,$5); }
  713.           |       S_FORMAT COL ':' COL NUMBER NUMBER
  714. !                                 { doformat($2,$4,$5,$6, REFMTFIX); }
  715.           |       S_FORMAT COL NUMBER NUMBER
  716. !                                 { doformat($2,$2,$3,$4, REFMTFIX); }
  717.       |    S_GET strarg    {  /* This tmp hack is because readfile
  718.                       * recurses back through yyparse. */
  719.                     char *tmp;
  720. ***************
  721. *** 360,365 ****
  722. --- 365,372 ----
  723.       |    '-' term    { $$ = new ('m', ENULL, $2); }
  724.       |    NUMBER        { $$ = new_const(O_CONST, (double) $1); }
  725.       |    FNUMBER        { $$ = new_const(O_CONST, $1); }
  726. +     |    NUMBER '_' NUMBER '_' NUMBER
  727. +             { $$ = new_const(O_CONST, convert_date($1,$3,$5)); }
  728.       |    K_PI { $$ = new_const(O_CONST, (double)3.14159265358979323846); }
  729.       | '@'   K_PI { $$ = new_const(O_CONST, (double)3.14159265358979323846); }
  730.       |    STRING            { $$ = new_str($1); }
  731. ***************
  732. *** 463,468 ****
  733. --- 470,478 ----
  734.       |    K_TBLSTYLE '=' K_TEX    { tbl_style = TEX; }
  735.       |    K_RNDINFINITY        { rndinfinity = 1; FullUpdate++; }
  736.       |    '!' K_RNDINFINITY    { rndinfinity = 0; FullUpdate++; }
  737. +     |    K_CRACTION '=' NUMBER    { craction = $3; }
  738. +     |    K_ROWLIMIT '=' NUMBER    { rowlimit = $3; }
  739. +     |    K_COLLIMIT '=' NUMBER    { collimit = $3; }
  740.         ;
  741.   
  742.   /* types of errors, to 'goto' */
  743. *** 6.17    1991/09/04 14:57:00
  744. --- help.c    1991/09/09 22:02:27
  745. ***************
  746. *** 2,13 ****
  747.    * Help functions for sc 
  748.    * R. Bond, 1988
  749.    * J. Buhrt 1990
  750. !  * $Revision: 6.17 $
  751.    */
  752.   
  753.   #ifdef QREF
  754.   #include <stdio.h>
  755. ! char    *header = " Quick Reference\n\n$Revision: 6.17 $";
  756.   #else
  757.   #include <curses.h>
  758.   #include "sc.h"
  759. --- 2,13 ----
  760.    * Help functions for sc 
  761.    * R. Bond, 1988
  762.    * J. Buhrt 1990
  763. !  * $Revision: 6.18 $
  764.    */
  765.   
  766.   #ifdef QREF
  767.   #include <stdio.h>
  768. ! char    *header = " Quick Reference\n\n$Revision: 6.18 $";
  769.   #else
  770.   #include <curses.h>
  771.   #include "sc.h"
  772. ***************
  773. *** 18,48 ****
  774.   " Overview:",
  775.   " ",
  776.   " A:   This overview",
  777. ! " B:   Options",
  778. ! " C:   Cursor movement commands",
  779. ! " D:   Cell entry and editing commands",
  780. ! " E:   Line Editing",
  781. ! " F:   File commands",
  782. ! " G:   Row and column commands",
  783. ! " H:   Range commands",
  784. ! " I:   Miscellaneous commands",
  785. ! " J:   Variable names/Expressions",
  786. ! " K:   Range functions",
  787. ! " L:   Numeric functions",
  788. ! " M:   String functions",
  789. ! " N:   Financial functions",
  790. ! " O:   Time and date functions",
  791.   " ",
  792.   " Q:   Return to main spreadsheet",
  793.   (char *)0
  794.   };
  795.   
  796. ! char *options[] = {
  797.   " ",
  798. ! " B: Options",
  799.   " ",
  800.   "     ^To  Toggle options. Toggle one option selected by o:",
  801. - " ",
  802.   "          a    Recalculate automatically or on ``@'' commands.",
  803.   "          c    Current cell highlighting enable/disable.",  
  804.   "          e    External function execution enable/disable.",
  805. --- 18,48 ----
  806.   " Overview:",
  807.   " ",
  808.   " A:   This overview",
  809. ! " B:   Toggle Options",
  810. ! " C:   Set Options",
  811. ! " D:   Cursor movement commands",
  812. ! " E:   Cell entry and editing commands",
  813. ! " F:   Line Editing",
  814. ! " G:   File commands",
  815. ! " H:   Row and column commands",
  816. ! " I:   Range commands",
  817. ! " J:   Miscellaneous commands",
  818. ! " K:   Variable names/Expressions",
  819. ! " L:   Range functions",
  820. ! " M:   Numeric functions",
  821. ! " N:   String functions",
  822. ! " O:   Financial functions",
  823. ! " P:   Time and date functions",
  824.   " ",
  825.   " Q:   Return to main spreadsheet",
  826.   (char *)0
  827.   };
  828.   
  829. ! char *toggleoptions[] = {
  830.   " ",
  831. ! " B: Toggle Options",
  832.   " ",
  833.   "     ^To  Toggle options. Toggle one option selected by o:",
  834.   "          a    Recalculate automatically or on ``@'' commands.",
  835.   "          c    Current cell highlighting enable/disable.",  
  836.   "          e    External function execution enable/disable.",
  837. ***************
  838. *** 50,60 ****
  839.   "          n    If enabled, a digit starts a numeric value.",
  840.   "          t    Top line display enable/disable.",
  841.   "          x    Encrypt/decrypt database and listing files.",
  842. ! "          $    Dollar prescale.  If enabled, all numeric constants.",
  843.   "               (not expressions) entered are multipled by 0.01.",
  844.   " ",
  845. ! "     S    Set options.  Options include:",
  846.   " ",
  847.   "          byrows        Recalculate in row order. (default)",
  848.   "          bycols        Recalculate in column order.",
  849.   "          iterations=n  Set the number of iterations allowed. (10)",
  850. --- 50,69 ----
  851.   "          n    If enabled, a digit starts a numeric value.",
  852.   "          t    Top line display enable/disable.",
  853.   "          x    Encrypt/decrypt database and listing files.",
  854. ! "          $    Dollar prescale.  If enabled, all numeric constants",
  855.   "               (not expressions) entered are multipled by 0.01.",
  856. + "          r    Newline action.  Toggle between no action, move down",
  857. + "               after entry and move right after entry.",
  858. + "          z    Set the newline action limits to the current row and column",
  859. + "            (for r && z see also set rowlimit=n, collimit=n)",
  860. + (char *)0
  861. + };
  862. + char *setoptions[] = {
  863.   " ",
  864. ! " C: Set Options",
  865.   " ",
  866. + "     S  Set options.  Options include:",
  867.   "          byrows        Recalculate in row order. (default)",
  868.   "          bycols        Recalculate in column order.",
  869.   "          iterations=n  Set the number of iterations allowed. (10)",
  870. ***************
  871. *** 61,72 ****
  872.   "          tblstyle=xx   Set ``T'' output style to:",
  873.   "                        0 (none), tex, latex, slatex, or tbl.",
  874.   "          rndinfinity   Round to infinity (round .5 up vs to nearest even).",
  875.   (char *)0
  876.   };
  877.   
  878.   char *cursor[] = {
  879.   " ",
  880. ! " C: Cell cursor movement (always OK):",
  881.   " ",
  882.   "     ^N ^P ^B ^F Down, up, back, forward",
  883.   "     ^Ed         Go to end of range.  Follow ^E by a direction indicator",
  884. --- 70,84 ----
  885.   "          tblstyle=xx   Set ``T'' output style to:",
  886.   "                        0 (none), tex, latex, slatex, or tbl.",
  887.   "          rndinfinity   Round to infinity (round .5 up vs to nearest even).",
  888. + "          rowlimit=n    Set the remembered row limit for newline action.",
  889. + "          collimit=n    Set the remembered column limit for newline action.",
  890. + "                     (rowlimit and collimit can both be set by ^Tz)",
  891.   (char *)0
  892.   };
  893.   
  894.   char *cursor[] = {
  895.   " ",
  896. ! " D: Cell cursor movement (always OK):",
  897.   " ",
  898.   "     ^N ^P ^B ^F Down, up, back, forward",
  899.   "     ^Ed         Go to end of range.  Follow ^E by a direction indicator",
  900. ***************
  901. *** 93,103 ****
  902.   
  903.   char *cell[] = {
  904.   " ",
  905. ! " D: Cell entry and editing commands:",
  906.   " ",
  907.   "     =    Enter a numeric constant or expression.",
  908.   "     <    Enter a left justified string or string expression.",
  909. ! "     \",>  Enter a right justified string or string expression.",
  910.   "     e    Edit the current cell's numeric value.",
  911.   "     E    Edit the current cell's string part.",
  912.   "     F    Assign a format to the current cell's numeric value.",
  913. --- 105,116 ----
  914.   
  915.   char *cell[] = {
  916.   " ",
  917. ! " E: Cell entry and editing commands:",
  918.   " ",
  919.   "     =    Enter a numeric constant or expression.",
  920.   "     <    Enter a left justified string or string expression.",
  921. ! "     \"    Enter a centered label.",
  922. ! "     >    Enter a right justified string or string expression.",
  923.   "     e    Edit the current cell's numeric value.",
  924.   "     E    Edit the current cell's string part.",
  925.   "     F    Assign a format to the current cell's numeric value.",
  926. ***************
  927. *** 116,122 ****
  928.   
  929.   char *vi[] = {
  930.   " ",
  931. ! " E: Line Editor",
  932.   " ",
  933.   "     Hitting the ESC key while entering any command on the top line",
  934.   "     will start a one-line vi-style editor.  Supported commands:",
  935. --- 129,135 ----
  936.   
  937.   char *vi[] = {
  938.   " ",
  939. ! " F: Line Editor",
  940.   " ",
  941.   "     Hitting the ESC key while entering any command on the top line",
  942.   "     will start a one-line vi-style editor.  Supported commands:",
  943. ***************
  944. *** 142,148 ****
  945.   
  946.   char *file[] = {
  947.   " ",
  948. ! " F: File commands:",
  949.   " ",
  950.   "     G    Get a new database from a file. ",
  951.   "     M    Merge a new file into the current database.",
  952. --- 155,161 ----
  953.   
  954.   char *file[] = {
  955.   " ",
  956. ! " G: File commands:",
  957.   " ",
  958.   "     G    Get a new database from a file. ",
  959.   "     M    Merge a new file into the current database.",
  960. ***************
  961. *** 165,171 ****
  962.   
  963.   char *row[] = {
  964.   " ",
  965. ! " G: Row and column commands:",
  966.   " ",
  967.   "     ir, ic      Insert a new, empty row (column)",
  968.   "     ar, ac      Append a new copy of the current row (column)",
  969. --- 178,184 ----
  970.   
  971.   char *row[] = {
  972.   " ",
  973. ! " H: Row and column commands:",
  974.   " ",
  975.   "     ir, ic      Insert a new, empty row (column)",
  976.   "     ar, ac      Append a new copy of the current row (column)",
  977. ***************
  978. *** 192,199 ****
  979.   
  980.   char *range[] = {
  981.   " ",
  982. ! " H: Range commands:",
  983. ! " ",
  984.   "     /x   Clear a range. ",
  985.   "     /v   Remove the expressions from a range of cells, leaving ",
  986.   "          just the values.",
  987. --- 205,211 ----
  988.   
  989.   char *range[] = {
  990.   " ",
  991. ! " I: Range commands:",
  992.   "     /x   Clear a range. ",
  993.   "     /v   Remove the expressions from a range of cells, leaving ",
  994.   "          just the values.",
  995. ***************
  996. *** 221,227 ****
  997.   
  998.   char *misc[] = {
  999.   " ",
  1000. ! " I: Miscellaneous commands:",
  1001.   " ",
  1002.   "     Q q ^C   Exit from the program.",
  1003.   "     ^G ESC   Abort entry of the current command.",
  1004. --- 233,239 ----
  1005.   
  1006.   char *misc[] = {
  1007.   " ",
  1008. ! " J: Miscellaneous commands:",
  1009.   " ",
  1010.   "     Q q ^C   Exit from the program.",
  1011.   "     ^G ESC   Abort entry of the current command.",
  1012. ***************
  1013. *** 243,249 ****
  1014.   
  1015.   char *var[] = {
  1016.   " ",
  1017. ! " J: Variable names:",
  1018.   " ",
  1019.   "     K20    Row and column can vary on copies.",
  1020.   "     $K$20  Row and column stay fixed on copies.",
  1021. --- 255,261 ----
  1022.   
  1023.   char *var[] = {
  1024.   " ",
  1025. ! " K: Variable names:",
  1026.   " ",
  1027.   "     K20    Row and column can vary on copies.",
  1028.   "     $K$20  Row and column stay fixed on copies.",
  1029. ***************
  1030. *** 269,275 ****
  1031.   
  1032.   char *rangef[] = {
  1033.   " ",
  1034. ! " K: Range functions:",
  1035.   " ",
  1036.   "     @sum(r)           Sum all valid cells in the range.",
  1037.   "     @prod(r)          Multiply together all valid cells in the range.",
  1038. --- 281,287 ----
  1039.   
  1040.   char *rangef[] = {
  1041.   " ",
  1042. ! " L: Range functions:",
  1043.   " ",
  1044.   "     @sum(r)           Sum all valid cells in the range.",
  1045.   "     @prod(r)          Multiply together all valid cells in the range.",
  1046. ***************
  1047. *** 295,301 ****
  1048.   
  1049.   char *numericf[] = {
  1050.   " ",
  1051. ! " L: Numeric functions:",
  1052.   " ",
  1053.   "     @atan2(e1,e2)     Arc tangent of e1/e2.",
  1054.   "     @ceil(e)          Smallest integer not less than e.",
  1055. --- 307,313 ----
  1056.   
  1057.   char *numericf[] = {
  1058.   " ",
  1059. ! " M: Numeric functions:",
  1060.   " ",
  1061.   "     @atan2(e1,e2)     Arc tangent of e1/e2.",
  1062.   "     @ceil(e)          Smallest integer not less than e.",
  1063. ***************
  1064. *** 307,313 ****
  1065.   "     @max(e1,e2,...)   The maximum of the values of the e's.",
  1066.   "     @min(e1,e2,...)   The minimum of the values of the e's",
  1067.   "     @nval(se,e)       The numeric value of a named cell.",
  1068. ! "     pi                A constant quite close to pi.",
  1069.   "     @pow(e1,e2)       e1 raised to the power of e2.",
  1070.   "     @rnd(e)           Round e to the nearest integer.",
  1071.   "     @round(e,n)       Round e to n decimal places.",
  1072. --- 319,325 ----
  1073.   "     @max(e1,e2,...)   The maximum of the values of the e's.",
  1074.   "     @min(e1,e2,...)   The minimum of the values of the e's",
  1075.   "     @nval(se,e)       The numeric value of a named cell.",
  1076. ! "     pi       @pi      A constant quite close to pi.",
  1077.   "     @pow(e1,e2)       e1 raised to the power of e2.",
  1078.   "     @rnd(e)           Round e to the nearest integer.",
  1079.   "     @round(e,n)       Round e to n decimal places.",
  1080. ***************
  1081. *** 322,328 ****
  1082.   
  1083.   char *stringf[] = {
  1084.   " ",
  1085. ! " M: String functions:",
  1086.   "     #                 Concatenate strings.  For example, the",
  1087.   "                       string expression ``A0 # \"zy dog\"'' yields",
  1088.   "                       ``the lazy dog'' if A0 is ``the la''.",
  1089. --- 334,340 ----
  1090.   
  1091.   char *stringf[] = {
  1092.   " ",
  1093. ! " N: String functions:",
  1094.   "     #                 Concatenate strings.  For example, the",
  1095.   "                       string expression ``A0 # \"zy dog\"'' yields",
  1096.   "                       ``the lazy dog'' if A0 is ``the la''.",
  1097. ***************
  1098. *** 350,356 ****
  1099.   
  1100.   char *finf[] = {
  1101.   " ",
  1102. ! " N: Financial functions:",
  1103.   " ",
  1104.   "     @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly",
  1105.   "                       payments for a $60000 mortgage at 12%",
  1106. --- 362,368 ----
  1107.   
  1108.   char *finf[] = {
  1109.   " ",
  1110. ! " O: Financial functions:",
  1111.   " ",
  1112.   "     @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly",
  1113.   "                       payments for a $60000 mortgage at 12%",
  1114. ***************
  1115. *** 377,383 ****
  1116.   
  1117.   char *timef[] = {
  1118.   " ",
  1119. ! " O: Time and date functions:",
  1120.   " ",
  1121.   "     @now              Return the time encoded in seconds since 1970.",
  1122.   "     @dts(m,d,y)       Return m/d/y encoded in seconds since 1970.",
  1123. --- 389,395 ----
  1124.   
  1125.   char *timef[] = {
  1126.   " ",
  1127. ! " P: Time and date functions:",
  1128.   " ",
  1129.   "     @now              Return the time encoded in seconds since 1970.",
  1130.   "     @dts(m,d,y)       Return m/d/y encoded in seconds since 1970.",
  1131. ***************
  1132. *** 413,432 ****
  1133.       while((option = pscreen(ns)) != 'q' && option != 'Q') {
  1134.           switch (option) {
  1135.       case 'a': case 'A': ns = intro; break;
  1136. !     case 'b': case 'B': ns = options; break;
  1137. !     case 'c': case 'C': ns = cursor; break;
  1138. !     case 'd': case 'D': ns = cell; break;
  1139. !     case 'e': case 'E': ns = vi; break;
  1140. !     case 'f': case 'F': ns = file; break;
  1141. !     case 'g': case 'G': ns = row; break;
  1142. !     case 'h': case 'H': ns = range; break;
  1143. !     case 'i': case 'I': ns = misc; break;
  1144. !     case 'j': case 'J': ns = var; break;
  1145. !     case 'k': case 'K': ns = rangef; break;
  1146. !     case 'l': case 'L': ns = numericf; break;
  1147. !     case 'm': case 'M': ns = stringf; break;
  1148. !     case 'n': case 'N': ns = finf; break;
  1149. !     case 'o': case 'O': ns = timef; break;
  1150.       default: ns = intro; break;
  1151.       }
  1152.       }
  1153. --- 425,445 ----
  1154.       while((option = pscreen(ns)) != 'q' && option != 'Q') {
  1155.           switch (option) {
  1156.       case 'a': case 'A': ns = intro; break;
  1157. !     case 'b': case 'B': ns = toggleoptions; break;
  1158. !     case 'c': case 'C': ns = setoptions; break;
  1159. !     case 'd': case 'D': ns = cursor; break;
  1160. !     case 'e': case 'E': ns = cell; break;
  1161. !     case 'f': case 'F': ns = vi; break;
  1162. !     case 'g': case 'G': ns = file; break;
  1163. !     case 'h': case 'H': ns = row; break;
  1164. !     case 'i': case 'I': ns = range; break;
  1165. !     case 'j': case 'J': ns = misc; break;
  1166. !     case 'k': case 'K': ns = var; break;
  1167. !     case 'l': case 'L': ns = rangef; break;
  1168. !     case 'm': case 'M': ns = numericf; break;
  1169. !     case 'n': case 'N': ns = stringf; break;
  1170. !     case 'o': case 'O': ns = finf; break;
  1171. !     case 'p': case 'P': ns = timef; break;
  1172.       default: ns = intro; break;
  1173.       }
  1174.       }
  1175. ***************
  1176. *** 457,464 ****
  1177.       return(nmgetch());
  1178.   }
  1179.   #else
  1180. ! char    ** pages[] = { intro, options, cursor, cell, vi, file, row,
  1181. !             range, misc, var, rangef, numericf, stringf,
  1182.               finf, timef, NULL};
  1183.   
  1184.   void
  1185. --- 470,477 ----
  1186.       return(nmgetch());
  1187.   }
  1188.   #else
  1189. ! char    ** pages[] = { intro, toggleoptions, setoptions, cursor, cell, vi,
  1190. !             file, row, range, misc, var, rangef, numericf, stringf,
  1191.               finf, timef, NULL};
  1192.   
  1193.   void
  1194. *** 6.17    1991/09/04 14:20:49
  1195. --- interp.c    1991/09/09 19:15:04
  1196. ***************
  1197. *** 7,13 ****
  1198.    *
  1199.    *              More mods Robert Bond, 12/86
  1200.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1201. !  *        $Revision: 6.17 $
  1202.    */
  1203.   
  1204.   #define DEBUGDTS 1        /* REMOVE ME */
  1205. --- 7,13 ----
  1206.    *
  1207.    *              More mods Robert Bond, 12/86
  1208.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1209. !  *        $Revision: 6.18 $
  1210.    */
  1211.   
  1212.   #define DEBUGDTS 1        /* REMOVE ME */
  1213. ***************
  1214. *** 1046,1056 ****
  1215.       static char *prevstr = (char *)0;    /* previous result */
  1216.       static unsigned    prevlen = 0;
  1217.       char buff[FBUFLEN];        /* command line/return, not permanently alloc */
  1218.   
  1219.       if (!extfunc)    {
  1220.       error ("Warning: external functions disabled; using %s value",
  1221.           ((prevstr == NULL) || (*prevstr == '\0')) ?
  1222. !             "previous" : "null");
  1223.   
  1224.       if (command) xfree (command);
  1225.       } else {
  1226. --- 1046,1057 ----
  1227.       static char *prevstr = (char *)0;    /* previous result */
  1228.       static unsigned    prevlen = 0;
  1229.       char buff[FBUFLEN];        /* command line/return, not permanently alloc */
  1230. +     extern char *strchr();
  1231.   
  1232.       if (!extfunc)    {
  1233.       error ("Warning: external functions disabled; using %s value",
  1234.           ((prevstr == NULL) || (*prevstr == '\0')) ?
  1235. !             "null" : "previous");
  1236.   
  1237.       if (command) xfree (command);
  1238.       } else {
  1239. ***************
  1240. *** 1191,1196 ****
  1241. --- 1192,1200 ----
  1242.   
  1243.   /*
  1244.    * make proper capitals of every word in a string
  1245. +  * if the string has mixed case we say the string is lower
  1246. +  *    and we will upcase only first letters of words
  1247. +  * if the string is all upper we will lower rest of words.
  1248.    */
  1249.   
  1250.   char *
  1251. ***************
  1252. *** 1199,1207 ****
  1253. --- 1203,1214 ----
  1254.   {
  1255.       char *p;
  1256.       int skip = 1;
  1257. +     int AllUpper = 1;
  1258.   
  1259.       if (s == NULL)
  1260.       return(NULL);
  1261. +     for( p = s; *p != '\0' && AllUpper != 0; p++ )
  1262. +     if( isalpha(*p) && islower(*p) )  AllUpper = 0;
  1263.       for (p = s; *p != '\0'; p++) {
  1264.       if (!isalnum(*p))
  1265.           skip = 1;
  1266. ***************
  1267. *** 1212,1218 ****
  1268.               *p = toupper(*p);
  1269.       }
  1270.       else    /* if the string was all upper before */
  1271. !     if (isupper(*p))
  1272.           *p = tolower(*p);
  1273.       }
  1274.       return(s);
  1275. --- 1219,1225 ----
  1276.               *p = toupper(*p);
  1277.       }
  1278.       else    /* if the string was all upper before */
  1279. !         if (isupper(*p) && AllUpper != 0)
  1280.           *p = tolower(*p);
  1281.       }
  1282.       return(s);
  1283. ***************
  1284. *** 1940,1947 ****
  1285.       v->expr = se;
  1286.       v->flags |= (is_changed|is_strexpr);
  1287.       if (flushdir<0) v->flags |= is_leftflush;
  1288. -     else v->flags &= ~is_leftflush;
  1289.   
  1290.       FullUpdate++;
  1291.       changed++;
  1292.       modflg++;
  1293. --- 1947,1957 ----
  1294.       v->expr = se;
  1295.       v->flags |= (is_changed|is_strexpr);
  1296.       if (flushdir<0) v->flags |= is_leftflush;
  1297.   
  1298. +     if (flushdir==0)
  1299. +     v->flags |= is_label;
  1300. +     else v->flags &= ~is_label;
  1301.       FullUpdate++;
  1302.       changed++;
  1303.       modflg++;
  1304. ***************
  1305. *** 2108,2113 ****
  1306. --- 2118,2125 ----
  1307.           v->label = (char *)0;
  1308.       if (flushdir<0) v->flags |= is_leftflush;
  1309.       else v->flags &= ~is_leftflush;
  1310. +     if (flushdir==0) v->flags |= is_label;
  1311. +     else v->flags &= ~is_label;
  1312.       FullUpdate++;
  1313.       modflg++;
  1314.       }
  1315. ***************
  1316. *** 2428,2433 ****
  1317. --- 2440,2448 ----
  1318.       register struct ent *p;
  1319.   
  1320.       p = lookat (row, col);
  1321. +     if( p->flags&is_label )
  1322. +     (void) sprintf( line, "label %s = ", v_name(row, col));
  1323. +     else
  1324.       (void) sprintf (line, "%sstring %s = ",
  1325.               ((p->flags&is_leftflush) ? "left" : "right"),
  1326.               v_name(row, col));
  1327. *** 6.17    1991/09/04 14:20:49
  1328. --- lex.c    1991/09/09 19:15:10
  1329. ***************
  1330. *** 7,13 ****
  1331.    *
  1332.    *              More mods Robert Bond, 12/86
  1333.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  1334. !  *        $Revision: 6.17 $
  1335.    *
  1336.    */
  1337.   
  1338. --- 7,13 ----
  1339.    *
  1340.    *              More mods Robert Bond, 12/86
  1341.    *        More mods by Alan Silverstein, 3/88, see list of changes.
  1342. !  *        $Revision: 6.18 $
  1343.    *
  1344.    */
  1345.   
  1346. ***************
  1347. *** 545,550 ****
  1348. --- 545,551 ----
  1349.   initkbd()
  1350.   {
  1351.       keypad(stdscr, TRUE);
  1352. +     notimeout(stdscr,TRUE);
  1353.   }
  1354.   
  1355.   void
  1356. ***************
  1357. *** 551,556 ****
  1358. --- 552,558 ----
  1359.   kbd_again()
  1360.   {
  1361.       keypad(stdscr, TRUE);
  1362. +     notimeout(stdscr,TRUE);
  1363.   }
  1364.   
  1365.   void
  1366. ***************
  1367. *** 557,562 ****
  1368. --- 559,565 ----
  1369.   resetkbd()
  1370.   {
  1371.       keypad(stdscr, FALSE);
  1372. +     notimeout(stdscr, FALSE);
  1373.   }
  1374.   
  1375.   int
  1376. ***************
  1377. *** 564,570 ****
  1378.   {
  1379.       register int c;
  1380.   
  1381. !     c = getch();
  1382.       switch (c) {
  1383.   #ifdef KEY_LEFT
  1384.       case KEY_LEFT:  c = ctl('b'); break;
  1385. --- 567,573 ----
  1386.   {
  1387.       register int c;
  1388.   
  1389. !     c = wgetch(stdscr);
  1390.       switch (c) {
  1391.   #ifdef KEY_LEFT
  1392.       case KEY_LEFT:  c = ctl('b'); break;
  1393. *** 6.17    1991/09/04 14:20:49
  1394. --- sc.c    1991/09/09 19:15:13
  1395. ***************
  1396. *** 8,14 ****
  1397.    *              More mods Robert Bond, 12/86
  1398.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1399.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1400. !  *        $Revision: 6.17 $
  1401.    *
  1402.    */
  1403.   
  1404. --- 8,14 ----
  1405.    *              More mods Robert Bond, 12/86
  1406.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1407.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1408. !  *        $Revision: 6.18 $
  1409.    *
  1410.    */
  1411.   
  1412. ***************
  1413. *** 88,93 ****
  1414. --- 88,96 ----
  1415.   int  tbl_style = 0;    /* headers for T command output */
  1416.   int  rndinfinity = 0;
  1417.   int  numeric_field = 0; /* Started the line editing with a number */
  1418. + int  craction = 0;    /* 1 for down, 2 for right */
  1419. + int  rowlimit = -1;
  1420. + int  collimit = -1;
  1421.   #ifdef    SIGWINCH
  1422.   int  hitwinch = 0;    /* got a SIGWINCH? */
  1423.   #endif
  1424. ***************
  1425. *** 233,238 ****
  1426. --- 236,247 ----
  1427.           case 'r':
  1428.               Ropt = 1;
  1429.               break;
  1430. +         case 'C':
  1431. +             craction = CRCOLS;
  1432. +             break;
  1433. +         case 'R':
  1434. +             craction = CRROWS;
  1435. +             break;
  1436.           default:
  1437.               (void) fprintf(stderr,"%s: unrecognized option: \"%c\"\n",
  1438.               progname,argv[0][1]);
  1439. ***************
  1440. *** 443,448 ****
  1441. --- 452,479 ----
  1442.           case ctl('j'):
  1443.               numeric_field = 0;
  1444.               write_line(ctl('m'));
  1445. +             switch(craction) {
  1446. +               case CRROWS:
  1447. +             if ((rowlimit >= 0) && (currow >= rowlimit)) {
  1448. +                 forwcol(1);
  1449. +                 currow = 0;
  1450. +             }
  1451. +             else {
  1452. +                 forwrow(1);
  1453. +             }
  1454. +             break;
  1455. +               case CRCOLS:
  1456. +             if ((collimit >= 0) && (curcol >= collimit)) {
  1457. +                 forwrow(1);
  1458. +                 curcol = 0;
  1459. +             }
  1460. +             else {
  1461. +                 forwcol(1);
  1462. +             }
  1463. +             break;
  1464. +               default:
  1465. +             break;
  1466. +               }
  1467.               break;
  1468.   
  1469.           case ctl('n'):
  1470. ***************
  1471. *** 469,475 ****
  1472.   
  1473.           case ctl('t'):
  1474.               error(
  1475. ! "Toggle: a:auto  c:cell  e:ext funcs  n:numeric  t:top  x:encrypt  $:pre-scale");
  1476.               (void) refresh();
  1477.   
  1478.               switch (nmgetch()) {
  1479. --- 500,506 ----
  1480.   
  1481.           case ctl('t'):
  1482.               error(
  1483. ! "Toggle: a:auto,c:cell,e:ext funcs,n:numeric,t:top,x:encrypt,$:pre-scale,<MORE>");
  1484.               (void) refresh();
  1485.   
  1486.               switch (nmgetch()) {
  1487. ***************
  1488. *** 521,526 ****
  1489. --- 552,580 ----
  1490.               case ctl('g'):
  1491.                   --modflg;    /* negate the modflg++ */
  1492.                   break;
  1493. +             case 'r': case 'R':
  1494. +                 ++craction;
  1495. +                 if(craction >= 3)
  1496. +                 craction = 0;
  1497. +                 switch(craction) {
  1498. +                 default:
  1499. +                     craction = 0; /* fall through */
  1500. +                 case 0:
  1501. +                     error("No action after new line");
  1502. +                     break;
  1503. +                 case CRROWS:
  1504. +                     error("Down row after new line");
  1505. +                     break;
  1506. +                 case CRCOLS:
  1507. +                     error("Right column after new line");
  1508. +                     break;
  1509. +                 }
  1510. +                 break;
  1511. +             case 'z': case 'Z':
  1512. +                 rowlimit = currow;
  1513. +                 collimit = curcol;
  1514. +                 error("Row and column limits set");
  1515. +                 break;
  1516.               default:
  1517.                   error ("Invalid toggle command");
  1518.                   --modflg;    /* negate the modflg++ */
  1519. ***************
  1520. *** 1062,1068 ****
  1521.               break;
  1522.           case 'S':    /* set options */
  1523.               (void) sprintf (line, "set ");
  1524. !             error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex),rndinfinity");
  1525.               linelim = strlen (line);
  1526.               insert_mode();
  1527.               break;
  1528. --- 1116,1122 ----
  1529.               break;
  1530.           case 'S':    /* set options */
  1531.               (void) sprintf (line, "set ");
  1532. !             error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex),<MORE>");
  1533.               linelim = strlen (line);
  1534.               insert_mode();
  1535.               break;
  1536. *** 6.17    1991/09/04 14:20:49
  1537. --- sc.h    1991/09/09 19:15:16
  1538. ***************
  1539. *** 6,12 ****
  1540.    *            University of Maryland
  1541.    *        R. Bond  12/86
  1542.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1543. !  *        $Revision: 6.17 $
  1544.    *
  1545.    */
  1546.   
  1547. --- 6,12 ----
  1548.    *            University of Maryland
  1549.    *        R. Bond  12/86
  1550.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1551. !  *        $Revision: 6.18 $
  1552.    *
  1553.    */
  1554.   
  1555. ***************
  1556. *** 20,31 ****
  1557.   #define MINCOLS 30 
  1558.   #define    ABSMAXCOLS 702    /* absolute cols: ZZ (base 26) */
  1559.   
  1560.   #define RESCOL 4    /* columns reserved for row numbers */
  1561.   #define RESROW 3 /* rows reserved for prompt, error, and column numbers */
  1562.   
  1563.   #define DEFWIDTH 10    /* Default column width and precision */
  1564.   #define DEFPREC   2
  1565. ! #define DEFREFMT  0     /* Make default format fixed point  THA 10/14/90 */
  1566.   
  1567.   #define HISTLEN  10    /* Number of history entries for vi emulation */
  1568.   #ifdef PSC
  1569. --- 20,39 ----
  1570.   #define MINCOLS 30 
  1571.   #define    ABSMAXCOLS 702    /* absolute cols: ZZ (base 26) */
  1572.   
  1573. + #define CRROWS 1
  1574. + #define CRCOLS 2
  1575.   #define RESCOL 4    /* columns reserved for row numbers */
  1576.   #define RESROW 3 /* rows reserved for prompt, error, and column numbers */
  1577.   
  1578. + /* formats for engformat() */
  1579. + #define REFMTFIX    0
  1580. + #define REFMTFLT    1
  1581. + #define REFMTENG    2
  1582. + #define REFMTDATE    3
  1583.   #define DEFWIDTH 10    /* Default column width and precision */
  1584.   #define DEFPREC   2
  1585. ! #define DEFREFMT  REFMTFIX /* Make default format fixed point  THA 10/14/90 */
  1586.   
  1587.   #define HISTLEN  10    /* Number of history entries for vi emulation */
  1588.   #ifdef PSC
  1589. ***************
  1590. *** 205,210 ****
  1591. --- 213,219 ----
  1592.   #define is_leftflush 0010
  1593.   #define is_deleted   0020
  1594.   #define is_locked    0040
  1595. + #define is_label     0100
  1596.   
  1597.   /* cell error (1st generation (ERROR) or 2nd+ (INVALID)) */
  1598.   #define    CELLOK        0
  1599. ***************
  1600. *** 390,395 ****
  1601. --- 399,407 ----
  1602.   extern    int tbl_style;
  1603.   extern    int rndinfinity;
  1604.   extern    char *progname;
  1605. + extern    int craction;
  1606. + extern    int rowlimit;
  1607. + extern    int collimit;
  1608.   
  1609.   #if BSD42 || SYSIII
  1610.   
  1611. *** 6.17    1991/09/04 14:20:49
  1612. --- screen.c    1991/09/09 19:15:18
  1613. ***************
  1614. *** 8,14 ****
  1615.    *              More mods Robert Bond, 12/86
  1616.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1617.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1618. !  *        $Revision: 6.17 $
  1619.    *
  1620.    */
  1621.   
  1622. --- 8,14 ----
  1623.    *              More mods Robert Bond, 12/86
  1624.    *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1625.    *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1626. !  *        $Revision: 6.18 $
  1627.    *
  1628.    */
  1629.   
  1630. ***************
  1631. *** 265,272 ****
  1632.           if ((showrange && (! showneed) && (! showexpr)
  1633.                  && (row >= minsr) && (row <= maxsr)
  1634.                  && (col >= minsc) && (col <= maxsc))
  1635. !             || (showneed && (*pp) && ((*pp) -> flags & is_valid)
  1636. !             && (((*pp) -> flags & is_strexpr) || !((*pp) -> expr)))
  1637.               || (showexpr && (*pp) && ((*pp) -> expr)))
  1638.           {
  1639.           (void) move(r, c);
  1640. --- 265,272 ----
  1641.           if ((showrange && (! showneed) && (! showexpr)
  1642.                  && (row >= minsr) && (row <= maxsr)
  1643.                  && (col >= minsc) && (col <= maxsc))
  1644. !             || (showneed && (*pp) && ((*pp) -> flags & is_valid) &&
  1645. !               (((*pp) -> flags & is_strexpr) || !((*pp) -> expr)))
  1646.               || (showexpr && (*pp) && ((*pp) -> expr)))
  1647.           {
  1648.           (void) move(r, c);
  1649. ***************
  1650. *** 283,289 ****
  1651.           else
  1652.           do_stand = 0;
  1653.   
  1654. !         if ((*pp) && ((*pp) -> flags & is_changed || FullUpdate) || do_stand) {
  1655.           if (do_stand) {
  1656.               (*pp) -> flags |= is_changed; 
  1657.           } else {
  1658. --- 283,289 ----
  1659.           else
  1660.           do_stand = 0;
  1661.   
  1662. !         if ((*pp) && (((*pp) -> flags & is_changed || FullUpdate) || do_stand)) {
  1663.           if (do_stand) {
  1664.               (*pp) -> flags |= is_changed; 
  1665.           } else {
  1666. ***************
  1667. *** 337,343 ****
  1668.   
  1669.               if ((*pp) -> label) {
  1670.               showstring((*pp) -> label,
  1671. !                     (*pp) -> flags & is_leftflush,
  1672.                       (*pp) -> flags & is_valid,
  1673.                       row, col, & nextcol, mxcol,
  1674.                       & fieldlen, r, c);
  1675. --- 337,343 ----
  1676.   
  1677.               if ((*pp) -> label) {
  1678.               showstring((*pp) -> label,
  1679. !                     (*pp) -> flags & (is_leftflush|is_label),
  1680.                       (*pp) -> flags & is_valid,
  1681.                       row, col, & nextcol, mxcol,
  1682.                       & fieldlen, r, c);
  1683. ***************
  1684. *** 405,411 ****
  1685.            */
  1686.   
  1687.           if ((p1 -> expr) && (p1 -> flags & is_strexpr)) {
  1688. !             (void) addstr((p1 -> flags & is_leftflush) ? "<{" : ">{");
  1689.               (void) addstr(line);
  1690.               (void) addstr("} ");    /* and this '}' is for vi % */
  1691.               printed = 1;
  1692. --- 405,414 ----
  1693.            */
  1694.   
  1695.           if ((p1 -> expr) && (p1 -> flags & is_strexpr)) {
  1696. !              if( (p1-> flags & is_label) )
  1697. !             (void) addstr("|{");
  1698. !             else
  1699. !             (void) addstr((p1 -> flags & is_leftflush) ? "<{" : ">{");
  1700.               (void) addstr(line);
  1701.               (void) addstr("} ");    /* and this '}' is for vi % */
  1702.               printed = 1;
  1703. ***************
  1704. *** 412,418 ****
  1705.   
  1706.           } else if (p1 -> label) {
  1707.               /* has constant label only */
  1708. !             (void) addstr ((p1 -> flags & is_leftflush) ? "<\"" : ">\"");
  1709.               (void) addstr (p1 -> label);
  1710.               (void) addstr ("\" ");
  1711.               printed = 1;
  1712. --- 415,424 ----
  1713.   
  1714.           } else if (p1 -> label) {
  1715.               /* has constant label only */
  1716. !             if( (p1-> flags & is_label) )
  1717. !             (void) addstr("|\"");
  1718. !             else
  1719. !             (void) addstr ((p1 -> flags & is_leftflush) ? "<\"" : ">\"");
  1720.               (void) addstr (p1 -> label);
  1721.               (void) addstr ("\" ");
  1722.               printed = 1;
  1723. ***************
  1724. *** 437,443 ****
  1725.           if (! printed)
  1726.           (void) addstr ("[]");
  1727.           /* Display if cell is locked */
  1728. !         if (p1->flags&is_locked)
  1729.           (void) addstr(" locked");
  1730.       }
  1731.       (void) move(lastmy, lastmx+fwidth[lastcol]);
  1732. --- 443,449 ----
  1733.           if (! printed)
  1734.           (void) addstr ("[]");
  1735.           /* Display if cell is locked */
  1736. !         if (p1 && p1->flags&is_locked)
  1737.           (void) addstr(" locked");
  1738.       }
  1739.       (void) move(lastmy, lastmx+fwidth[lastcol]);
  1740. *** 6.17    1991/09/04 14:20:49
  1741. --- version.c    1991/09/09 19:22:38
  1742. ***************
  1743. *** 4,7 ****
  1744.    * The part after the first colon, except the last char, appears on the screen.
  1745.    */
  1746.   
  1747. ! char *rev = "$Revision: 6.17 $";
  1748. --- 4,7 ----
  1749.    * The part after the first colon, except the last char, appears on the screen.
  1750.    */
  1751.   
  1752. ! char *rev = "$Revision: 6.18 $";
  1753. *** 6.17    1991/09/04 14:23:44
  1754. --- vi.c    1991/09/09 19:15:22
  1755. ***************
  1756. *** 1,7 ****
  1757.   /*    SC    A Spreadsheet Calculator
  1758.    *
  1759.    *    One line vi emulation
  1760. !  *    $Revision: 6.17 $
  1761.    */
  1762.   
  1763.   #include <sys/types.h>
  1764. --- 1,7 ----
  1765.   /*    SC    A Spreadsheet Calculator
  1766.    *
  1767.    *    One line vi emulation
  1768. !  *    $Revision: 6.18 $
  1769.    */
  1770.   
  1771.   #include <sys/types.h>
  1772. ***************
  1773. *** 661,667 ****
  1774.       prev_histp = histp;
  1775.       look_here = line;
  1776.       found_it = do_next = 0;
  1777. !     while ((look_here = strchr(look_here, last_search[0])) &&
  1778.                           !found_it && !do_next) {
  1779.   
  1780.           if (strncmp(look_here, last_search, strlen(last_search)) == 0)
  1781. --- 661,667 ----
  1782.       prev_histp = histp;
  1783.       look_here = line;
  1784.       found_it = do_next = 0;
  1785. !     while ((look_here = strchr(look_here, last_search[0])) != NULL &&
  1786.                           !found_it && !do_next) {
  1787.   
  1788.           if (strncmp(look_here, last_search, strlen(last_search)) == 0)
  1789.  
  1790. exit 0 # Just in case...
  1791. -- 
  1792. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1793. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1794. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1795. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1796. exit 0 # Just in case...
  1797. -- 
  1798. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1799. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1800. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1801. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1802.