Newsgroups: comp.sources.misc
From: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
Subject:  REPOST: v22i104:  sc - The SC Spreadsheet, Patch02
Message-ID: <1991Sep20.143836.6133@sparky.imd.sterling.com>
X-Md4-Signature: b30a94b2d9df7f39f935859849d5f57b
Date: Fri, 20 Sep 1991 14:38:36 GMT
Approved: kent@sparky.imd.sterling.com

Submitted-by: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
Posting-number: Volume 22, Issue 104
Archive-name: sc/patch02
Environment: UNIX, VMS, MS-DOS
Patch-To: sc: Volume 20, Issue 35-41

[ This is being reposted due to a propagation error. ]

REQUIRES patch01 be applied first, the new revision level will be: 6.18.

James found a potential NULL pointer in the last patch, I found another
that has been around a while that might have caused problems on: Suns,
VAX, CCI, and maybe IBM/370 type iron.

A few new, really nice features are listed below.

						-Jeff Buhrt
					{sequent,uunet}!sawmill!prslnk!buhrt
					812-275-0750 work
					Proslink, Inc.

*** 6.17	1991/09/04 14:20:49
--- CHANGES	1991/09/09 19:19:29
***************
*** 1,3 ****
--- 1,29 ----
+ CHANGES BETWEEN 6.18 and 6.17
+ James Dugal	
+ 	- NULL pointer fix for is_locked
+ Kevin Pye
+ 	- add a new mode suitable for entry of large amounts of data.
+ 		moves to next cell on return, maxrow/col when to start
+ 		entering in the next row/col. (see help screens B&C)
+ 	COMMANDS ADDED: ^Tz, ^Tr, Srowlimit=?, Scollimit=?
+ David Fox - added a date format so that columns whose values are the number
+ 	of seconds since 1/1/70 will be displayed as dates in the format
+ 	dd-mmm-yy, and a modification to the grammar so data entered in the
+ 	format dd_mm_yy will be converted into the number of seconds since
+ 	1/1/70.
+ 	COMMANDS ADDED: f # # 3
+ Teus Hagen
+ 	- labels are centered strings
+ 	- constant strings with '\' preceeding character will
+ 	  be wheeled over the column width
+ 	- a restart of sc on an sc file will go to last used cel
+ 	- added toupper, tolower and do proper word capitalization
+ 	COMMANDS ADDED: @toupper(), @tolower(), @capital(), @pi, "\[String]
+ Jeff Buhrt
+ 	- external functions null/previous message was backwards
+ 	- cleaned up help.c by inserting a new screen
+ 	- found a possible NULL pointer in screen.c
+ 
  CHANGES BETWEEN 6.17 and 6.16
  Ulf Noren
  	- added cell locking, disallowing input, to ranges of cells
*** 6.17	1991/09/04 14:20:49
--- README	1991/09/09 19:14:35
***************
*** 1,7 ****
  This is a much modified version of the public domain spread sheet sc,
  posted several years ago by Mark Weiser as vc, originally by James Gosling.
  
! CHANGES lists the changes since 6.1 to 6.17.
  Current maintainer: {sequent, uunet}!sawmill!prslnk!buhrt (Jeff Buhrt)
  
  When you get it built, try "sc tutorial.sc" for a simple introduction
--- 1,10 ----
  This is a much modified version of the public domain spread sheet sc,
  posted several years ago by Mark Weiser as vc, originally by James Gosling.
  
! CHANGES lists the changes since 6.1 to 6.18.
! 	Sc6.16 was released to comp.sources.misc and two sets of patches
! 	bring Sc6.16->6.17->6.18.
! 
  Current maintainer: {sequent, uunet}!sawmill!prslnk!buhrt (Jeff Buhrt)
  
  When you get it built, try "sc tutorial.sc" for a simple introduction
*** 6.17	1991/09/04 14:20:49
--- sc.doc	1991/09/09 19:14:40
***************
*** 15,21 ****
  .\" - TPs use default indent except for function names, then 18.
  .\" - Smallify uppercase strings.
  .\" - Avoid passive voice and third person.
! .\" $Revision: 6.17 $
  .\"
  .TH PNAME\ #REVISION#\  1
  .SH NAME
--- 15,21 ----
  .\" - TPs use default indent except for function names, then 18.
  .\" - Smallify uppercase strings.
  .\" - Avoid passive voice and third person.
! .\" $Revision: 6.18 $
  .\"
  .TH PNAME\ #REVISION#\  1
  .SH NAME
***************
*** 98,103 ****
--- 98,113 ----
  .I Put
  commands (see below) to encrypt and decrypt data files.
  .\" ----------
+ .TP
+ .B \-R
+ Start the program with automatic newline action set to increment the row
+ (see below).
+ .\" ----------
+ .TP
+ .B \-C
+ Start the program with automatic newline action set to increment the column
+ (see below).
+ .\" ----------
  .PP
  All of these options can be changed with the
  .I ^T
***************
*** 245,255 ****
  the name and value of the current cell is displayed on the top line.
  If there is an associated label string,
  the first character of the string value
! is ``<'' for a leftstring or ``>'' for a rightstring (see below),
  followed by "\fIstring\fP" for a constant string
  or
  .RI { expr }
  for a string expression.
  If the cell has a numeric value,
  it follows as
  .RI [ value ],
--- 255,269 ----
  the name and value of the current cell is displayed on the top line.
  If there is an associated label string,
  the first character of the string value
! is ``|'' for a centered string, ``<'' for a leftstring or ``>'' for a rightstring (see below),
  followed by "\fIstring\fP" for a constant string
  or
  .RI { expr }
  for a string expression.
+ A constant string may be preceeded with a backslash (`\\').
+ In this case the constant string will be used as a ``wheel''
+ to fill a column, e.g. "\\-" for a line in a column,
+ and "\\Yeh " for "Yeh Yeh Ye".
  If the cell has a numeric value,
  it follows as
  .RI [ value ],
***************
*** 270,275 ****
--- 284,333 ----
  (not expressions) which you enter are multipled by 0.01
  so you don't have to keep typing the decimal point
  if you enter lots of dollar figures.
+ .\" ----------
+ .TP
+ .B r
+ Newline action.
+ This option toggles between three cases.
+ The default is no action.
+ If this option is used once, after each command which is terminated
+ by a newline character is completed, the current cell will be moved
+ down one row.
+ If this option is used again, after each command which is terminated
+ by a newline character is completed, the current cell will be moved
+ right one column.
+ Another use of this option will restore the default action.
+ .\" ----------
+ .TP
+ .B z
+ Set newline action limits.
+ This option sets limits to the newline action option above.
+ When this option is invoked, the row and column of the current cell are
+ remembered.
+ If a later newline action would take the current cell to the right of
+ the remembered column, then the current cell is instead moved to the
+ first column of the next row.
+ If a newline action would take the current cell below the remembered row,
+ then the current cell is instead moved to the top row of the next column.
+ .PP
+ The quick numeric entry, newline action and set newline action limits options
+ can be combined to allow very quick entry of large amounts of data.
+ If all the data to be entered is in a single row or column then setting
+ the quick numeric entry and the appropriate newline action will allow
+ the numbers to be entered without any explicit commands to position the
+ current cell or enter a number.
+ .PP
+ If the data entry involves several entries in each row for many rows, then
+ setting the quick numeric entry option, setting the newline action to move
+ right after each entry and setting the newline action limits on the last
+ column on which data should be entered will allow the data to entered
+ quickly.
+ If necessary, columns which do not need data to be entered can be hidden with
+ the
+ .B z
+ command.
+ Similar arrangements can be made for entering several rows of data
+ in each column.
  .RE
  .\" ----------
  \0 \" exactly one blank line (hard to get)
***************
*** 354,359 ****
--- 412,446 ----
  default: round-to-even (banker's round), *.5 will round to the closest even
  number; doing a 'set rndinfinity' will round *.5 up to the next integer
  (rounding to infinity).
+ .TP
+ .BI craction =n
+ Set the newline action.
+ .I n
+ can be:
+ .B 0
+ (default) to give no action;
+ .B 1
+ to move down after each entry; or
+ .B 2
+ to move right after each entry.
+ .TP
+ .BI rowlimit =n
+ Set the remembered limit for the maximum row below which
+ the current cell will be moved to the top of the next column
+ if the newline action is set to move the current cell down.
+ .I n
+ can be
+ .B -1
+ (default) to disable this facility.
+ .TP
+ .BI collimit =n
+ Set the remembered limit for the maximum column to the right of which
+ the current cell will be moved to the left of the next row
+ if the newline action is set to move the current cell right.
+ .I n
+ can be
+ .B -1
+ (default) to disable this facility.
  .RE
  .\" ==========
  .SS "Cursor Control Commands"
***************
*** 540,545 ****
--- 627,635 ----
  .\" ----------
  .IP \fB"\fP
  .PD 0
+ Enter a label string into the current cell
+ to be centered in the column.
+ .\" ----------
  .TP
  .B >
  Enter a label string into the current cell
***************
*** 1052,1058 ****
  the total width in characters of the column,
  the number of digits to follow decimal points,
  and the format type.  Format types are 0 for fixed point,
! 1 for scientific notation, and 2 for engineering notation.
  Values are rounded off to the least significant digit displayed.
  The total column width affects displays of strings as well as numbers.
  A preceding count can be used to affect more than one column.
--- 1142,1148 ----
  the total width in characters of the column,
  the number of digits to follow decimal points,
  and the format type.  Format types are 0 for fixed point,
! 1 for scientific notation, 2 for engineering notation, and 3 for dates.
  Values are rounded off to the least significant digit displayed.
  The total column width affects displays of strings as well as numbers.
  A preceding count can be used to affect more than one column.
***************
*** 1798,1804 ****
  and string functions.
  Note that string expressions are only allowed
  when entering a cell's label string, not its numeric part.
! Also note that string expression results may be left or right flushed,
  according to the type of the cell's string label.
  .\" ----------
  .TP
--- 1888,1894 ----
  and string functions.
  Note that string expressions are only allowed
  when entering a cell's label string, not its numeric part.
! Also note that string expression results may be left or right flushed or centered,
  according to the type of the cell's string label.
  .\" ----------
  .TP
***************
*** 1874,1879 ****
--- 1964,1981 ----
  the result is the null string.
  You can use this for simple table lookups.
  Be sure the table doesn't move unexpectedly!
+ .\" ----------
+ .TP 18
+ .BR @upper (e)
+ and
+ .BR @lower (e)
+ will case the string expression to upper or lower.
+ .\" ----------
+ .TP 18
+ .BR @capital (e)
+ will convert the first letter of words in a string
+ into upper case and other letters to lower case
+ (the latter if all letters of the string are upper case).
  .\" ----------
  .TP 18
  .BR @upper (e)
*** 6.17	1991/09/04 14:20:49
--- cmds.c	1991/09/09 19:14:46
***************
*** 7,13 ****
   *
   *              More mods Robert Bond, 12/86
   *
!  *		$Revision: 6.17 $
   */
  
  #include <sys/types.h>
--- 7,13 ----
   *
   *              More mods Robert Bond, 12/86
   *
!  *		$Revision: 6.18 $
   */
  
  #include <sys/types.h>
***************
*** 189,195 ****
      for (r = sr; r <= er; r++) {
  	for (c = sc; c <= ec; c++) {
  	    p = *ATBL(tbl, r, c);
! 	    if (p->flags&is_locked) {
  		error(" Cell %s%d is locked", coltoa(c), r);
  		continue;
  	    }
--- 189,195 ----
      for (r = sr; r <= er; r++) {
  	for (c = sc; c <= ec; c++) {
  	    p = *ATBL(tbl, r, c);
! 	    if (p && p->flags&is_locked) {
  		error(" Cell %s%d is locked", coltoa(c), r);
  		continue;
  	    }
***************
*** 620,629 ****
  	error("Precision too large");
  	p = w;
      }
!     /* format statement may record format of an as yet unused column
!      * which causes it to run off the end of fwidth and precision --
!      * causing a bus error later
!      */
      checkbounds(&crows, &ccols);
      if (ccols < c2) {
  	error("Format statement failed to create implied column %d", c2);
--- 620,626 ----
  	error("Precision too large");
  	p = w;
      }
! 
      checkbounds(&crows, &ccols);
      if (ccols < c2) {
  	error("Format statement failed to create implied column %d", c2);
***************
*** 650,656 ****
         !extfunc &&
         showcell &&
         showtop &&
!        tbl_style == 0
        )
  		return;		/* No reason to do this */
  
--- 647,656 ----
         !extfunc &&
         showcell &&
         showtop &&
!        tbl_style == 0 &&
!        craction == 0 &&
!        rowlimit == -1 &&
!        collimit == -1
        )
  		return;		/* No reason to do this */
  
***************
*** 676,681 ****
--- 676,687 ----
  					tbl_style == LATEX ? "latex" :
  					tbl_style == SLATEX ? "slatex" :
  					tbl_style == TEX ? "tex" : "0" );
+     if (craction)
+ 	(void) fprintf(f, " craction = %d", craction);
+     if (rowlimit >= 0)
+ 	(void) fprintf(f, " rowlimit = %d", rowlimit);
+     if (collimit >= 0)
+ 	(void) fprintf(f, " collimit = %d", collimit);
      (void) fprintf(f, "\n");
  }
  
***************
*** 785,792 ****
  		    register char *fp;
  		    struct ent *nc;
  
! 		    /* Figure out if the label slops over to a blank field */
  		    slen = strlen(s);
  		    while (slen > fieldlen && nextcol <= cn &&
  			    !((nc = lookat(row,nextcol))->flags & is_valid) &&
  			    !(nc->label)) {
--- 791,803 ----
  		    register char *fp;
  		    struct ent *nc;
  
! 		    /*
! 		     * Figure out if the label slops over to a blank field. A
! 		     * string started with backslah is defining repition char
! 		     */
  		    slen = strlen(s);
+ 		    if ( *s == '\\' && *(s+1)!= '\0' )
+ 			slen = fwidth[col];
  		    while (slen > fieldlen && nextcol <= cn &&
  			    !((nc = lookat(row,nextcol))->flags & is_valid) &&
  			    !(nc->label)) {
***************
*** 812,823 ****
--- 823,846 ----
  		    /* Now justify and print */
  		    start = (*pp)->flags & is_leftflush ? pline + c
  					: pline + c + fieldlen - slen;
+ 		    if( (*pp)->flags & is_label )
+ 			start = pline + (c + ((fwidth[col]>slen)?(fwidth[col]-slen)/2:0));
  		    last = pline + c + fieldlen;
  		    fp = plinelim < c ? pline + plinelim : pline + c;
  		    while (fp < start)
  			*fp++ = ' ';
+ 		    if( *s == '\\' && *(s+1)!= '\0' ) {
+ 			char *strt;
+ 			strt = ++s;
+ 
+ 			while(slen--) {
+ 				*fp++ = *s++; if( *s == '\0' ) s = strt;
+ 			}
+ 		    }
+ 		    else
  		    while (slen--)
  			*fp++ = *s++;
+ 
  		    if (!((*pp)->flags & is_valid) || fieldlen != fwidth[col])
  			while(fp < last)
  			    *fp++ = ' ';
***************
*** 944,949 ****
--- 967,973 ----
  char	*str;
  int	delim;
  {
+ 	if( *str == '\\' ) str++; /* delete wheeling string operator, OK? */
  	while (*str)
  	{	if (((tbl_style == LATEX) || (tbl_style == SLATEX) ||
  		    (tbl_style == TEX)) &&
***************
*** 1275,1280 ****
--- 1299,1305 ----
  {
      register struct ent **pp;
      register r, c;
+     extern char *v_name();
  
      (void) fprintf (f, "# This data file was generated by the Spreadsheet ");
      (void) fprintf (f, "Calculator.\n");
***************
*** 1321,1326 ****
--- 1346,1352 ----
      }
      if (rndinfinity)
  	fprintf(f, "set rndinfinity\n");
+     fprintf(f, "goto %s\n", v_name( currow, curcol ) );
  }
  
  int
***************
*** 1517,1525 ****
   */
  
  void
! showstring (string, leftflush, hasvalue, row, col, nextcolp, mxcol, fieldlenp, r, c)
      char *string;	/* to display */
!     int leftflush;	/* or rightflush */
      int hasvalue;	/* is there a numeric value? */
      int row, col;	/* spreadsheet location */
      int *nextcolp;	/* value returned through it */
--- 1543,1551 ----
   */
  
  void
! showstring (string, dirflush, hasvalue, row, col, nextcolp, mxcol, fieldlenp, r, c)
      char *string;	/* to display */
!     int dirflush;	/* or rightflush or centered */
      int hasvalue;	/* is there a numeric value? */
      int row, col;	/* spreadsheet location */
      int *nextcolp;	/* value returned through it */
***************
*** 1540,1545 ****
--- 1566,1573 ----
         slop over into the next blank field */
  
      slen = strlen (string);
+     if( *string == '\\' && *(string+1)!= '\0' )
+ 	slen = fwidth[col];
      while ((slen > fieldlen) && (nextcol <= mxcol) &&
  	   !((nc = lookat (row, nextcol)) -> flags & is_valid) &&
  	   !(nc->label)) {
***************
*** 1553,1565 ****
  	slen = fieldlen;
  
      /* Now justify and print */
!     start = leftflush ? field : field + fieldlen - slen;
      last = field+fieldlen;
      fp = field;
      while (fp < start)
  	*fp++ = ' ';
      while (slen--)
  	*fp++ = *string++;
      if ((! hasvalue) || fieldlen != fwidth[col]) 
  	while (fp < last)
  	    *fp++ = ' ';
--- 1581,1607 ----
  	slen = fieldlen;
  
      /* Now justify and print */
!     start = (dirflush&is_leftflush) ? field : field + fieldlen - slen;
!     if( dirflush & is_label )
! 	start = field + ((slen<fwidth[col])?(fieldlen-slen)/2:0);
      last = field+fieldlen;
      fp = field;
      while (fp < start)
  	*fp++ = ' ';
+     if( *string == '\\'  && *(string+1)!= '\0') {
+ 	char *strt;
+ 	strt = ++string;
+ 
+ 	while(slen--) {
+ 		*fp++ = *string++;
+ 		if( *string == '\0' )
+ 			string = strt;
+ 	}
+     }
+     else
      while (slen--)
  	*fp++ = *string++;
+ 
      if ((! hasvalue) || fieldlen != fwidth[col]) 
  	while (fp < last)
  	    *fp++ = ' ';
***************
*** 1755,1757 ****
--- 1797,1816 ----
  	return(0);
  }
  #endif
+ 
+ static int day_month_starts[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
+ 
+ double convert_date(d, m, y)
+ int d;
+ int m;
+ int y;
+ {
+   /* Convert to years since 1970. (or 2000, fix by 2070) */
+   if (y > 1970) y -= 1970;	/* Full year given */
+   else if (y >= 70) y -= 70;	/* Years since 1900 */
+   else y += 30;			/* Years since 2000 */
+   /* Use quarter days to compensate for leap years. */
+   return (double)((y * (365 * 4 + 1) + day_month_starts[m-1] * 4 + d * 4 - 2) *
+ 		  6 * 60 * 60);
+ }
+ 
*** 6.17	1991/09/04 14:23:44
--- format.c	1991/09/09 19:14:50
***************
*** 3,9 ****
   * Mark Nagel <nagel@ics.uci.edu>
   * 20 July 1989
   *
!  * $Revision: 6.17 $
   *
   * bool
   * format(fmt, num, buf, buflen)
--- 3,9 ----
   * Mark Nagel <nagel@ics.uci.edu>
   * 20 July 1989
   *
!  * $Revision: 6.18 $
   *
   * bool
   * format(fmt, num, buf, buflen)
***************
*** 85,90 ****
--- 85,92 ----
  /*****************************************************************************/
  
  #include <stdio.h>
+ #include <sys/types.h>
+ #include <time.h>
  #include "sc.h"
  
  #define bool	int
***************
*** 508,516 ****
   *
   */
  
! #define REFMTFIX 0
! #define REFMTFLT 1
! #define REFMTENG 2
  char engmult[] = "afpnum kMGT";
  
  bool
--- 510,523 ----
   *
   */
  
! /* defined in sc.h */
! #ifndef REFMTFIX
! #define REFMTFIX	0
! #define REFMTFLT	1
! #define REFMTENG	2
! #define REFMTDATE	3
! #endif
! 
  char engmult[] = "afpnum kMGT";
  
  bool
***************
*** 562,567 ****
--- 569,599 ----
          (void) sprintf(buf,"%*.*f%c", width-1,
                        lprecision, engmant, engmult[engind]);
        }
+     }
+   }
+   if (fmt == REFMTDATE) {
+     int i;
+     char *time;
+     long int secs;
+ 
+     if (buflen < 9) {
+       for (i = 0; i < width; i++) buf[i] = '*';
+       buf[i] = '\0';
+     }
+     else {
+       secs = (time_t)val;
+       time = ctime(&secs);
+       buf[0] = time[8];
+       buf[1] = time[9];
+       buf[2] = ' ';
+       buf[3] = time[4];
+       buf[4] = time[5];
+       buf[5] = time[6];
+       buf[6] = ' ';
+       buf[7] = time[22];
+       buf[8] = time[23];
+       for (i = 9; i < width; i++) buf[i] = ' ';
+       buf[i] = '\0';
      }
    }
    return (true);
*** 6.17	1991/09/04 14:20:49
--- gram.y	1991/09/09 19:14:52
***************
*** 9,15 ****
   *
   *		More mods by Alan Silverstein, 3/88, see list of changes.
   *
!  *		$Revision: 6.17 $
   */
  
  
--- 9,15 ----
   *
   *		More mods by Alan Silverstein, 3/88, see list of changes.
   *
!  *		$Revision: 6.18 $
   */
  
  
***************
*** 152,158 ****
  %token K_MYROW
  %token K_MYCOL
  %token K_COLTOA
! 
  %left '?' ':'
  %left '|'
  %left '&'
--- 152,163 ----
  %token K_MYROW
  %token K_MYCOL
  %token K_COLTOA
! %token K_CRACTION
! %token K_CRROW
! %token K_CRCOL
! %token K_ROWLIMIT
! %token K_COLLIMIT
!   
  %left '?' ':'
  %left '|'
  %left '&'
***************
*** 175,183 ****
  	|	S_FORMAT COL NUMBER NUMBER NUMBER
  				{ doformat($2,$2,$3,$4,$5); }
          |       S_FORMAT COL ':' COL NUMBER NUMBER
!                                 { doformat($2,$4,$5,$6, 0); }
          |       S_FORMAT COL NUMBER NUMBER
!                                 { doformat($2,$2,$3,$4, 0); }
  	|	S_GET strarg	{  /* This tmp hack is because readfile
  				    * recurses back through yyparse. */
  				  char *tmp;
--- 180,188 ----
  	|	S_FORMAT COL NUMBER NUMBER NUMBER
  				{ doformat($2,$2,$3,$4,$5); }
          |       S_FORMAT COL ':' COL NUMBER NUMBER
!                                 { doformat($2,$4,$5,$6, REFMTFIX); }
          |       S_FORMAT COL NUMBER NUMBER
!                                 { doformat($2,$2,$3,$4, REFMTFIX); }
  	|	S_GET strarg	{  /* This tmp hack is because readfile
  				    * recurses back through yyparse. */
  				  char *tmp;
***************
*** 360,365 ****
--- 365,372 ----
  	|	'-' term	{ $$ = new ('m', ENULL, $2); }
  	|	NUMBER		{ $$ = new_const(O_CONST, (double) $1); }
  	|	FNUMBER		{ $$ = new_const(O_CONST, $1); }
+ 	|	NUMBER '_' NUMBER '_' NUMBER
+ 			{ $$ = new_const(O_CONST, convert_date($1,$3,$5)); }
  	|	K_PI { $$ = new_const(O_CONST, (double)3.14159265358979323846); }
  	| '@'   K_PI { $$ = new_const(O_CONST, (double)3.14159265358979323846); }
  	|	STRING	        { $$ = new_str($1); }
***************
*** 463,468 ****
--- 470,478 ----
  	|	K_TBLSTYLE '=' K_TEX	{ tbl_style = TEX; }
  	|	K_RNDINFINITY		{ rndinfinity = 1; FullUpdate++; }
  	|	'!' K_RNDINFINITY	{ rndinfinity = 0; FullUpdate++; }
+ 	|	K_CRACTION '=' NUMBER	{ craction = $3; }
+ 	|	K_ROWLIMIT '=' NUMBER	{ rowlimit = $3; }
+ 	|	K_COLLIMIT '=' NUMBER	{ collimit = $3; }
    	;
  
  /* types of errors, to 'goto' */
*** 6.17	1991/09/04 14:57:00
--- help.c	1991/09/09 22:02:27
***************
*** 2,13 ****
   * Help functions for sc 
   * R. Bond, 1988
   * J. Buhrt 1990
!  * $Revision: 6.17 $
   */
  
  #ifdef QREF
  #include <stdio.h>
! char	*header = " Quick Reference\n\n$Revision: 6.17 $";
  #else
  #include <curses.h>
  #include "sc.h"
--- 2,13 ----
   * Help functions for sc 
   * R. Bond, 1988
   * J. Buhrt 1990
!  * $Revision: 6.18 $
   */
  
  #ifdef QREF
  #include <stdio.h>
! char	*header = " Quick Reference\n\n$Revision: 6.18 $";
  #else
  #include <curses.h>
  #include "sc.h"
***************
*** 18,48 ****
  " Overview:",
  " ",
  " A:   This overview",
! " B:   Options",
! " C:   Cursor movement commands",
! " D:   Cell entry and editing commands",
! " E:   Line Editing",
! " F:   File commands",
! " G:   Row and column commands",
! " H:   Range commands",
! " I:   Miscellaneous commands",
! " J:   Variable names/Expressions",
! " K:   Range functions",
! " L:   Numeric functions",
! " M:   String functions",
! " N:   Financial functions",
! " O:   Time and date functions",
  " ",
  " Q:   Return to main spreadsheet",
  (char *)0
  };
  
! char *options[] = {
  " ",
! " B: Options",
  " ",
  "     ^To  Toggle options. Toggle one option selected by o:",
- " ",
  "          a    Recalculate automatically or on ``@'' commands.",
  "          c    Current cell highlighting enable/disable.",  
  "          e    External function execution enable/disable.",
--- 18,48 ----
  " Overview:",
  " ",
  " A:   This overview",
! " B:   Toggle Options",
! " C:   Set Options",
! " D:   Cursor movement commands",
! " E:   Cell entry and editing commands",
! " F:   Line Editing",
! " G:   File commands",
! " H:   Row and column commands",
! " I:   Range commands",
! " J:   Miscellaneous commands",
! " K:   Variable names/Expressions",
! " L:   Range functions",
! " M:   Numeric functions",
! " N:   String functions",
! " O:   Financial functions",
! " P:   Time and date functions",
  " ",
  " Q:   Return to main spreadsheet",
  (char *)0
  };
  
! char *toggleoptions[] = {
  " ",
! " B: Toggle Options",
  " ",
  "     ^To  Toggle options. Toggle one option selected by o:",
  "          a    Recalculate automatically or on ``@'' commands.",
  "          c    Current cell highlighting enable/disable.",  
  "          e    External function execution enable/disable.",
***************
*** 50,60 ****
  "          n    If enabled, a digit starts a numeric value.",
  "          t    Top line display enable/disable.",
  "          x    Encrypt/decrypt database and listing files.",
! "          $    Dollar prescale.  If enabled, all numeric constants.",
  "               (not expressions) entered are multipled by 0.01.",
  " ",
! "     S    Set options.  Options include:",
  " ",
  "          byrows        Recalculate in row order. (default)",
  "          bycols        Recalculate in column order.",
  "          iterations=n  Set the number of iterations allowed. (10)",
--- 50,69 ----
  "          n    If enabled, a digit starts a numeric value.",
  "          t    Top line display enable/disable.",
  "          x    Encrypt/decrypt database and listing files.",
! "          $    Dollar prescale.  If enabled, all numeric constants",
  "               (not expressions) entered are multipled by 0.01.",
+ "          r    Newline action.  Toggle between no action, move down",
+ "               after entry and move right after entry.",
+ "          z    Set the newline action limits to the current row and column",
+ "            (for r && z see also set rowlimit=n, collimit=n)",
+ (char *)0
+ };
+ 
+ char *setoptions[] = {
  " ",
! " C: Set Options",
  " ",
+ "     S  Set options.  Options include:",
  "          byrows        Recalculate in row order. (default)",
  "          bycols        Recalculate in column order.",
  "          iterations=n  Set the number of iterations allowed. (10)",
***************
*** 61,72 ****
  "          tblstyle=xx   Set ``T'' output style to:",
  "                        0 (none), tex, latex, slatex, or tbl.",
  "          rndinfinity   Round to infinity (round .5 up vs to nearest even).",
  (char *)0
  };
  
  char *cursor[] = {
  " ",
! " C: Cell cursor movement (always OK):",
  " ",
  "     ^N ^P ^B ^F Down, up, back, forward",
  "     ^Ed         Go to end of range.  Follow ^E by a direction indicator",
--- 70,84 ----
  "          tblstyle=xx   Set ``T'' output style to:",
  "                        0 (none), tex, latex, slatex, or tbl.",
  "          rndinfinity   Round to infinity (round .5 up vs to nearest even).",
+ "          rowlimit=n    Set the remembered row limit for newline action.",
+ "          collimit=n    Set the remembered column limit for newline action.",
+ "                     (rowlimit and collimit can both be set by ^Tz)",
  (char *)0
  };
  
  char *cursor[] = {
  " ",
! " D: Cell cursor movement (always OK):",
  " ",
  "     ^N ^P ^B ^F Down, up, back, forward",
  "     ^Ed         Go to end of range.  Follow ^E by a direction indicator",
***************
*** 93,103 ****
  
  char *cell[] = {
  " ",
! " D: Cell entry and editing commands:",
  " ",
  "     =    Enter a numeric constant or expression.",
  "     <    Enter a left justified string or string expression.",
! "     \",>  Enter a right justified string or string expression.",
  "     e    Edit the current cell's numeric value.",
  "     E    Edit the current cell's string part.",
  "     F    Assign a format to the current cell's numeric value.",
--- 105,116 ----
  
  char *cell[] = {
  " ",
! " E: Cell entry and editing commands:",
  " ",
  "     =    Enter a numeric constant or expression.",
  "     <    Enter a left justified string or string expression.",
! "     \"    Enter a centered label.",
! "     >    Enter a right justified string or string expression.",
  "     e    Edit the current cell's numeric value.",
  "     E    Edit the current cell's string part.",
  "     F    Assign a format to the current cell's numeric value.",
***************
*** 116,122 ****
  
  char *vi[] = {
  " ",
! " E: Line Editor",
  " ",
  "     Hitting the ESC key while entering any command on the top line",
  "     will start a one-line vi-style editor.  Supported commands:",
--- 129,135 ----
  
  char *vi[] = {
  " ",
! " F: Line Editor",
  " ",
  "     Hitting the ESC key while entering any command on the top line",
  "     will start a one-line vi-style editor.  Supported commands:",
***************
*** 142,148 ****
  
  char *file[] = {
  " ",
! " F: File commands:",
  " ",
  "     G    Get a new database from a file. ",
  "     M    Merge a new file into the current database.",
--- 155,161 ----
  
  char *file[] = {
  " ",
! " G: File commands:",
  " ",
  "     G    Get a new database from a file. ",
  "     M    Merge a new file into the current database.",
***************
*** 165,171 ****
  
  char *row[] = {
  " ",
! " G: Row and column commands:",
  " ",
  "     ir, ic      Insert a new, empty row (column)",
  "     ar, ac      Append a new copy of the current row (column)",
--- 178,184 ----
  
  char *row[] = {
  " ",
! " H: Row and column commands:",
  " ",
  "     ir, ic      Insert a new, empty row (column)",
  "     ar, ac      Append a new copy of the current row (column)",
***************
*** 192,199 ****
  
  char *range[] = {
  " ",
! " H: Range commands:",
! " ",
  "     /x   Clear a range. ",
  "     /v   Remove the expressions from a range of cells, leaving ",
  "          just the values.",
--- 205,211 ----
  
  char *range[] = {
  " ",
! " I: Range commands:",
  "     /x   Clear a range. ",
  "     /v   Remove the expressions from a range of cells, leaving ",
  "          just the values.",
***************
*** 221,227 ****
  
  char *misc[] = {
  " ",
! " I: Miscellaneous commands:",
  " ",
  "     Q q ^C   Exit from the program.",
  "     ^G ESC   Abort entry of the current command.",
--- 233,239 ----
  
  char *misc[] = {
  " ",
! " J: Miscellaneous commands:",
  " ",
  "     Q q ^C   Exit from the program.",
  "     ^G ESC   Abort entry of the current command.",
***************
*** 243,249 ****
  
  char *var[] = {
  " ",
! " J: Variable names:",
  " ",
  "     K20    Row and column can vary on copies.",
  "     $K$20  Row and column stay fixed on copies.",
--- 255,261 ----
  
  char *var[] = {
  " ",
! " K: Variable names:",
  " ",
  "     K20    Row and column can vary on copies.",
  "     $K$20  Row and column stay fixed on copies.",
***************
*** 269,275 ****
  
  char *rangef[] = {
  " ",
! " K: Range functions:",
  " ",
  "     @sum(r)           Sum all valid cells in the range.",
  "     @prod(r)          Multiply together all valid cells in the range.",
--- 281,287 ----
  
  char *rangef[] = {
  " ",
! " L: Range functions:",
  " ",
  "     @sum(r)           Sum all valid cells in the range.",
  "     @prod(r)          Multiply together all valid cells in the range.",
***************
*** 295,301 ****
  
  char *numericf[] = {
  " ",
! " L: Numeric functions:",
  " ",
  "     @atan2(e1,e2)     Arc tangent of e1/e2.",
  "     @ceil(e)          Smallest integer not less than e.",
--- 307,313 ----
  
  char *numericf[] = {
  " ",
! " M: Numeric functions:",
  " ",
  "     @atan2(e1,e2)     Arc tangent of e1/e2.",
  "     @ceil(e)          Smallest integer not less than e.",
***************
*** 307,313 ****
  "     @max(e1,e2,...)   The maximum of the values of the e's.",
  "     @min(e1,e2,...)   The minimum of the values of the e's",
  "     @nval(se,e)       The numeric value of a named cell.",
! "     pi                A constant quite close to pi.",
  "     @pow(e1,e2)       e1 raised to the power of e2.",
  "     @rnd(e)           Round e to the nearest integer.",
  "     @round(e,n)       Round e to n decimal places.",
--- 319,325 ----
  "     @max(e1,e2,...)   The maximum of the values of the e's.",
  "     @min(e1,e2,...)   The minimum of the values of the e's",
  "     @nval(se,e)       The numeric value of a named cell.",
! "     pi       @pi      A constant quite close to pi.",
  "     @pow(e1,e2)       e1 raised to the power of e2.",
  "     @rnd(e)           Round e to the nearest integer.",
  "     @round(e,n)       Round e to n decimal places.",
***************
*** 322,328 ****
  
  char *stringf[] = {
  " ",
! " M: String functions:",
  "     #                 Concatenate strings.  For example, the",
  "                       string expression ``A0 # \"zy dog\"'' yields",
  "                       ``the lazy dog'' if A0 is ``the la''.",
--- 334,340 ----
  
  char *stringf[] = {
  " ",
! " N: String functions:",
  "     #                 Concatenate strings.  For example, the",
  "                       string expression ``A0 # \"zy dog\"'' yields",
  "                       ``the lazy dog'' if A0 is ``the la''.",
***************
*** 350,356 ****
  
  char *finf[] = {
  " ",
! " N: Financial functions:",
  " ",
  "     @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly",
  "                       payments for a $60000 mortgage at 12%",
--- 362,368 ----
  
  char *finf[] = {
  " ",
! " O: Financial functions:",
  " ",
  "     @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly",
  "                       payments for a $60000 mortgage at 12%",
***************
*** 377,383 ****
  
  char *timef[] = {
  " ",
! " O: Time and date functions:",
  " ",
  "     @now              Return the time encoded in seconds since 1970.",
  "     @dts(m,d,y)       Return m/d/y encoded in seconds since 1970.",
--- 389,395 ----
  
  char *timef[] = {
  " ",
! " P: Time and date functions:",
  " ",
  "     @now              Return the time encoded in seconds since 1970.",
  "     @dts(m,d,y)       Return m/d/y encoded in seconds since 1970.",
***************
*** 413,432 ****
      while((option = pscreen(ns)) != 'q' && option != 'Q') {
      	switch (option) {
  	case 'a': case 'A': ns = intro; break;
! 	case 'b': case 'B': ns = options; break;
! 	case 'c': case 'C': ns = cursor; break;
! 	case 'd': case 'D': ns = cell; break;
! 	case 'e': case 'E': ns = vi; break;
! 	case 'f': case 'F': ns = file; break;
! 	case 'g': case 'G': ns = row; break;
! 	case 'h': case 'H': ns = range; break;
! 	case 'i': case 'I': ns = misc; break;
! 	case 'j': case 'J': ns = var; break;
! 	case 'k': case 'K': ns = rangef; break;
! 	case 'l': case 'L': ns = numericf; break;
! 	case 'm': case 'M': ns = stringf; break;
! 	case 'n': case 'N': ns = finf; break;
! 	case 'o': case 'O': ns = timef; break;
  	default: ns = intro; break;
  	}
      }
--- 425,445 ----
      while((option = pscreen(ns)) != 'q' && option != 'Q') {
      	switch (option) {
  	case 'a': case 'A': ns = intro; break;
! 	case 'b': case 'B': ns = toggleoptions; break;
! 	case 'c': case 'C': ns = setoptions; break;
! 	case 'd': case 'D': ns = cursor; break;
! 	case 'e': case 'E': ns = cell; break;
! 	case 'f': case 'F': ns = vi; break;
! 	case 'g': case 'G': ns = file; break;
! 	case 'h': case 'H': ns = row; break;
! 	case 'i': case 'I': ns = range; break;
! 	case 'j': case 'J': ns = misc; break;
! 	case 'k': case 'K': ns = var; break;
! 	case 'l': case 'L': ns = rangef; break;
! 	case 'm': case 'M': ns = numericf; break;
! 	case 'n': case 'N': ns = stringf; break;
! 	case 'o': case 'O': ns = finf; break;
! 	case 'p': case 'P': ns = timef; break;
  	default: ns = intro; break;
  	}
      }
***************
*** 457,464 ****
      return(nmgetch());
  }
  #else
! char	** pages[] = { intro, options, cursor, cell, vi, file, row,
! 			range, misc, var, rangef, numericf, stringf,
  			finf, timef, NULL};
  
  void
--- 470,477 ----
      return(nmgetch());
  }
  #else
! char	** pages[] = { intro, toggleoptions, setoptions, cursor, cell, vi,
! 			file, row, range, misc, var, rangef, numericf, stringf,
  			finf, timef, NULL};
  
  void
*** 6.17	1991/09/04 14:20:49
--- interp.c	1991/09/09 19:15:04
***************
*** 7,13 ****
   *
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
!  *		$Revision: 6.17 $
   */
  
  #define DEBUGDTS 1		/* REMOVE ME */
--- 7,13 ----
   *
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
!  *		$Revision: 6.18 $
   */
  
  #define DEBUGDTS 1		/* REMOVE ME */
***************
*** 1046,1056 ****
      static char *prevstr = (char *)0;	/* previous result */
      static unsigned	prevlen = 0;
      char buff[FBUFLEN];		/* command line/return, not permanently alloc */
  
      if (!extfunc)    {
  	error ("Warning: external functions disabled; using %s value",
  		((prevstr == NULL) || (*prevstr == '\0')) ?
! 			"previous" : "null");
  
  	if (command) xfree (command);
      } else {
--- 1046,1057 ----
      static char *prevstr = (char *)0;	/* previous result */
      static unsigned	prevlen = 0;
      char buff[FBUFLEN];		/* command line/return, not permanently alloc */
+     extern char *strchr();
  
      if (!extfunc)    {
  	error ("Warning: external functions disabled; using %s value",
  		((prevstr == NULL) || (*prevstr == '\0')) ?
! 			"null" : "previous");
  
  	if (command) xfree (command);
      } else {
***************
*** 1191,1196 ****
--- 1192,1200 ----
  
  /*
   * make proper capitals of every word in a string
+  * if the string has mixed case we say the string is lower
+  *	and we will upcase only first letters of words
+  * if the string is all upper we will lower rest of words.
   */
  
  char *
***************
*** 1199,1207 ****
--- 1203,1214 ----
  {
      char *p;
      int skip = 1;
+     int AllUpper = 1;
  
      if (s == NULL)
  	return(NULL);
+     for( p = s; *p != '\0' && AllUpper != 0; p++ )
+ 	if( isalpha(*p) && islower(*p) )  AllUpper = 0;
      for (p = s; *p != '\0'; p++) {
  	if (!isalnum(*p))
  		skip = 1;
***************
*** 1212,1218 ****
  			*p = toupper(*p);
  	}
  	else	/* if the string was all upper before */
! 	if (isupper(*p))
  		*p = tolower(*p);
      }
      return(s);
--- 1219,1225 ----
  			*p = toupper(*p);
  	}
  	else	/* if the string was all upper before */
!         if (isupper(*p) && AllUpper != 0)
  		*p = tolower(*p);
      }
      return(s);
***************
*** 1940,1947 ****
      v->expr = se;
      v->flags |= (is_changed|is_strexpr);
      if (flushdir<0) v->flags |= is_leftflush;
-     else v->flags &= ~is_leftflush;
  
      FullUpdate++;
      changed++;
      modflg++;
--- 1947,1957 ----
      v->expr = se;
      v->flags |= (is_changed|is_strexpr);
      if (flushdir<0) v->flags |= is_leftflush;
  
+     if (flushdir==0)
+ 	v->flags |= is_label;
+     else v->flags &= ~is_label;
+ 
      FullUpdate++;
      changed++;
      modflg++;
***************
*** 2108,2113 ****
--- 2118,2125 ----
  	    v->label = (char *)0;
  	if (flushdir<0) v->flags |= is_leftflush;
  	else v->flags &= ~is_leftflush;
+ 	if (flushdir==0) v->flags |= is_label;
+ 	else v->flags &= ~is_label;
  	FullUpdate++;
  	modflg++;
      }
***************
*** 2428,2433 ****
--- 2440,2448 ----
      register struct ent *p;
  
      p = lookat (row, col);
+     if( p->flags&is_label )
+ 	(void) sprintf( line, "label %s = ", v_name(row, col));
+     else
      (void) sprintf (line, "%sstring %s = ",
  			((p->flags&is_leftflush) ? "left" : "right"),
  			v_name(row, col));
*** 6.17	1991/09/04 14:20:49
--- lex.c	1991/09/09 19:15:10
***************
*** 7,13 ****
   *
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3/88, see list of changes.
!  *		$Revision: 6.17 $
   *
   */
  
--- 7,13 ----
   *
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3/88, see list of changes.
!  *		$Revision: 6.18 $
   *
   */
  
***************
*** 545,550 ****
--- 545,551 ----
  initkbd()
  {
      keypad(stdscr, TRUE);
+     notimeout(stdscr,TRUE);
  }
  
  void
***************
*** 551,556 ****
--- 552,558 ----
  kbd_again()
  {
      keypad(stdscr, TRUE);
+     notimeout(stdscr,TRUE);
  }
  
  void
***************
*** 557,562 ****
--- 559,565 ----
  resetkbd()
  {
      keypad(stdscr, FALSE);
+     notimeout(stdscr, FALSE);
  }
  
  int
***************
*** 564,570 ****
  {
      register int c;
  
!     c = getch();
      switch (c) {
  #ifdef KEY_LEFT
      case KEY_LEFT:  c = ctl('b'); break;
--- 567,573 ----
  {
      register int c;
  
!     c = wgetch(stdscr);
      switch (c) {
  #ifdef KEY_LEFT
      case KEY_LEFT:  c = ctl('b'); break;
*** 6.17	1991/09/04 14:20:49
--- sc.c	1991/09/09 19:15:13
***************
*** 8,14 ****
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
   *		Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
!  *		$Revision: 6.17 $
   *
   */
  
--- 8,14 ----
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
   *		Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
!  *		$Revision: 6.18 $
   *
   */
  
***************
*** 88,93 ****
--- 88,96 ----
  int  tbl_style = 0;	/* headers for T command output */
  int  rndinfinity = 0;
  int  numeric_field = 0; /* Started the line editing with a number */
+ int  craction = 0;	/* 1 for down, 2 for right */
+ int  rowlimit = -1;
+ int  collimit = -1;
  #ifdef	SIGWINCH
  int  hitwinch = 0;	/* got a SIGWINCH? */
  #endif
***************
*** 233,238 ****
--- 236,247 ----
  	    case 'r':
  		    Ropt = 1;
  		    break;
+ 	    case 'C':
+ 		    craction = CRCOLS;
+ 		    break;
+ 	    case 'R':
+ 		    craction = CRROWS;
+ 		    break;
  	    default:
  		    (void) fprintf(stderr,"%s: unrecognized option: \"%c\"\n",
  			progname,argv[0][1]);
***************
*** 443,448 ****
--- 452,479 ----
  		case ctl('j'):
  		    numeric_field = 0;
  		    write_line(ctl('m'));
+ 		    switch(craction) {
+ 		      case CRROWS:
+ 			if ((rowlimit >= 0) && (currow >= rowlimit)) {
+ 			    forwcol(1);
+ 			    currow = 0;
+ 			}
+ 			else {
+ 			    forwrow(1);
+ 			}
+ 			break;
+ 		      case CRCOLS:
+ 			if ((collimit >= 0) && (curcol >= collimit)) {
+ 			    forwrow(1);
+ 			    curcol = 0;
+ 			}
+ 			else {
+ 			    forwcol(1);
+ 			}
+ 			break;
+ 		      default:
+ 			break;
+ 		      }
  		    break;
  
  		case ctl('n'):
***************
*** 469,475 ****
  
  		case ctl('t'):
  		    error(
! "Toggle: a:auto  c:cell  e:ext funcs  n:numeric  t:top  x:encrypt  $:pre-scale");
  		    (void) refresh();
  
  		    switch (nmgetch()) {
--- 500,506 ----
  
  		case ctl('t'):
  		    error(
! "Toggle: a:auto,c:cell,e:ext funcs,n:numeric,t:top,x:encrypt,$:pre-scale,<MORE>");
  		    (void) refresh();
  
  		    switch (nmgetch()) {
***************
*** 521,526 ****
--- 552,580 ----
  			case ctl('g'):
  			    --modflg;	/* negate the modflg++ */
  			    break;
+ 			case 'r': case 'R':
+ 			    ++craction;
+ 			    if(craction >= 3)
+ 				craction = 0;
+ 			    switch(craction) {
+ 				default:
+ 				    craction = 0; /* fall through */
+ 				case 0:
+ 				    error("No action after new line");
+ 				    break;
+ 				case CRROWS:
+ 				    error("Down row after new line");
+ 				    break;
+ 				case CRCOLS:
+ 				    error("Right column after new line");
+ 				    break;
+ 			    }
+ 			    break;
+ 			case 'z': case 'Z':
+ 			    rowlimit = currow;
+ 			    collimit = curcol;
+ 			    error("Row and column limits set");
+ 			    break;
  			default:
  			    error ("Invalid toggle command");
  			    --modflg;	/* negate the modflg++ */
***************
*** 1062,1068 ****
  		    break;
  		case 'S':	/* set options */
  		    (void) sprintf (line, "set ");
! 		    error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex),rndinfinity");
  		    linelim = strlen (line);
  		    insert_mode();
  		    break;
--- 1116,1122 ----
  		    break;
  		case 'S':	/* set options */
  		    (void) sprintf (line, "set ");
! 		    error("Options:byrows,bycols,iterations=n,tblstyle=(0|tbl|latex|slatex|tex),<MORE>");
  		    linelim = strlen (line);
  		    insert_mode();
  		    break;
*** 6.17	1991/09/04 14:20:49
--- sc.h	1991/09/09 19:15:16
***************
*** 6,12 ****
   *			University of Maryland
   *		R. Bond  12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
!  *		$Revision: 6.17 $
   *
   */
  
--- 6,12 ----
   *			University of Maryland
   *		R. Bond  12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
!  *		$Revision: 6.18 $
   *
   */
  
***************
*** 20,31 ****
  #define MINCOLS 30 
  #define	ABSMAXCOLS 702	/* absolute cols: ZZ (base 26) */
  
  #define RESCOL 4	/* columns reserved for row numbers */
  #define RESROW 3 /* rows reserved for prompt, error, and column numbers */
  
  #define DEFWIDTH 10	/* Default column width and precision */
  #define DEFPREC   2
! #define DEFREFMT  0     /* Make default format fixed point  THA 10/14/90 */
  
  #define HISTLEN  10	/* Number of history entries for vi emulation */
  #ifdef PSC
--- 20,39 ----
  #define MINCOLS 30 
  #define	ABSMAXCOLS 702	/* absolute cols: ZZ (base 26) */
  
+ #define CRROWS 1
+ #define CRCOLS 2
  #define RESCOL 4	/* columns reserved for row numbers */
  #define RESROW 3 /* rows reserved for prompt, error, and column numbers */
  
+ /* formats for engformat() */
+ #define REFMTFIX	0
+ #define REFMTFLT	1
+ #define REFMTENG	2
+ #define REFMTDATE	3
+ 
  #define DEFWIDTH 10	/* Default column width and precision */
  #define DEFPREC   2
! #define DEFREFMT  REFMTFIX /* Make default format fixed point  THA 10/14/90 */
  
  #define HISTLEN  10	/* Number of history entries for vi emulation */
  #ifdef PSC
***************
*** 205,210 ****
--- 213,219 ----
  #define is_leftflush 0010
  #define is_deleted   0020
  #define is_locked    0040
+ #define is_label     0100
  
  /* cell error (1st generation (ERROR) or 2nd+ (INVALID)) */
  #define	CELLOK		0
***************
*** 390,395 ****
--- 399,407 ----
  extern	int tbl_style;
  extern	int rndinfinity;
  extern	char *progname;
+ extern	int craction;
+ extern	int rowlimit;
+ extern	int collimit;
  
  #if BSD42 || SYSIII
  
*** 6.17	1991/09/04 14:20:49
--- screen.c	1991/09/09 19:15:18
***************
*** 8,14 ****
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
   *		Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
!  *		$Revision: 6.17 $
   *
   */
  
--- 8,14 ----
   *              More mods Robert Bond, 12/86
   *		More mods by Alan Silverstein, 3-4/88, see list of changes.
   *		Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
!  *		$Revision: 6.18 $
   *
   */
  
***************
*** 265,272 ****
  	    if ((showrange && (! showneed) && (! showexpr)
  			   && (row >= minsr) && (row <= maxsr)
  			   && (col >= minsc) && (col <= maxsc))
! 		    || (showneed && (*pp) && ((*pp) -> flags & is_valid)
! 			&& (((*pp) -> flags & is_strexpr) || !((*pp) -> expr)))
  		    || (showexpr && (*pp) && ((*pp) -> expr)))
  	    {
  		(void) move(r, c);
--- 265,272 ----
  	    if ((showrange && (! showneed) && (! showexpr)
  			   && (row >= minsr) && (row <= maxsr)
  			   && (col >= minsc) && (col <= maxsc))
! 		    || (showneed && (*pp) && ((*pp) -> flags & is_valid) &&
! 			  (((*pp) -> flags & is_strexpr) || !((*pp) -> expr)))
  		    || (showexpr && (*pp) && ((*pp) -> expr)))
  	    {
  		(void) move(r, c);
***************
*** 283,289 ****
  	    else
  		do_stand = 0;
  
! 	    if ((*pp) && ((*pp) -> flags & is_changed || FullUpdate) || do_stand) {
  		if (do_stand) {
  		    (*pp) -> flags |= is_changed; 
  		} else {
--- 283,289 ----
  	    else
  		do_stand = 0;
  
! 	    if ((*pp) && (((*pp) -> flags & is_changed || FullUpdate) || do_stand)) {
  		if (do_stand) {
  		    (*pp) -> flags |= is_changed; 
  		} else {
***************
*** 337,343 ****
  
  		    if ((*pp) -> label) {
  			showstring((*pp) -> label,
! 				    (*pp) -> flags & is_leftflush,
  				    (*pp) -> flags & is_valid,
  				    row, col, & nextcol, mxcol,
  				    & fieldlen, r, c);
--- 337,343 ----
  
  		    if ((*pp) -> label) {
  			showstring((*pp) -> label,
! 				    (*pp) -> flags & (is_leftflush|is_label),
  				    (*pp) -> flags & is_valid,
  				    row, col, & nextcol, mxcol,
  				    & fieldlen, r, c);
***************
*** 405,411 ****
  		 */
  
  		if ((p1 -> expr) && (p1 -> flags & is_strexpr)) {
! 		    (void) addstr((p1 -> flags & is_leftflush) ? "<{" : ">{");
  		    (void) addstr(line);
  		    (void) addstr("} ");	/* and this '}' is for vi % */
  		    printed = 1;
--- 405,414 ----
  		 */
  
  		if ((p1 -> expr) && (p1 -> flags & is_strexpr)) {
!  		    if( (p1-> flags & is_label) )
! 			(void) addstr("|{");
! 		    else
! 			(void) addstr((p1 -> flags & is_leftflush) ? "<{" : ">{");
  		    (void) addstr(line);
  		    (void) addstr("} ");	/* and this '}' is for vi % */
  		    printed = 1;
***************
*** 412,418 ****
  
  		} else if (p1 -> label) {
  		    /* has constant label only */
! 		    (void) addstr ((p1 -> flags & is_leftflush) ? "<\"" : ">\"");
  		    (void) addstr (p1 -> label);
  		    (void) addstr ("\" ");
  		    printed = 1;
--- 415,424 ----
  
  		} else if (p1 -> label) {
  		    /* has constant label only */
! 		    if( (p1-> flags & is_label) )
! 			(void) addstr("|\"");
! 		    else
! 			(void) addstr ((p1 -> flags & is_leftflush) ? "<\"" : ">\"");
  		    (void) addstr (p1 -> label);
  		    (void) addstr ("\" ");
  		    printed = 1;
***************
*** 437,443 ****
  	    if (! printed)
  		(void) addstr ("[]");
  	    /* Display if cell is locked */
! 	    if (p1->flags&is_locked)
  		(void) addstr(" locked");
  	}
  	(void) move(lastmy, lastmx+fwidth[lastcol]);
--- 443,449 ----
  	    if (! printed)
  		(void) addstr ("[]");
  	    /* Display if cell is locked */
! 	    if (p1 && p1->flags&is_locked)
  		(void) addstr(" locked");
  	}
  	(void) move(lastmy, lastmx+fwidth[lastcol]);
*** 6.17	1991/09/04 14:20:49
--- version.c	1991/09/09 19:22:38
***************
*** 4,7 ****
   * The part after the first colon, except the last char, appears on the screen.
   */
  
! char *rev = "$Revision: 6.17 $";
--- 4,7 ----
   * The part after the first colon, except the last char, appears on the screen.
   */
  
! char *rev = "$Revision: 6.18 $";
*** 6.17	1991/09/04 14:23:44
--- vi.c	1991/09/09 19:15:22
***************
*** 1,7 ****
  /*	SC	A Spreadsheet Calculator
   *
   *	One line vi emulation
!  *	$Revision: 6.17 $
   */
  
  #include <sys/types.h>
--- 1,7 ----
  /*	SC	A Spreadsheet Calculator
   *
   *	One line vi emulation
!  *	$Revision: 6.18 $
   */
  
  #include <sys/types.h>
***************
*** 661,667 ****
  	prev_histp = histp;
  	look_here = line;
  	found_it = do_next = 0;
! 	while ((look_here = strchr(look_here, last_search[0])) &&
  						!found_it && !do_next) {
  
  	    if (strncmp(look_here, last_search, strlen(last_search)) == 0)
--- 661,667 ----
  	prev_histp = histp;
  	look_here = line;
  	found_it = do_next = 0;
! 	while ((look_here = strchr(look_here, last_search[0])) != NULL &&
  						!found_it && !do_next) {
  
  	    if (strncmp(look_here, last_search, strlen(last_search)) == 0)

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.
exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.
