[alt.sources.amiga] sc Part 9 of 9

sie@fulcrum.bt.co.uk (Simon Raybould) (03/20/91)

#!/bin/sh
# this is scshr.09 (part 9 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file tutorial.sc continued
#
if test ! -r _shar_seq_.tmp; then
	echo 'Please unpack part 1 first!'
	exit 1
fi
(read Scheck
 if test "$Scheck" != 9; then
	echo Please unpack part "$Scheck" next!
	exit 1
 else
	exit 0
 fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
	echo 'x - still skipping tutorial.sc'
else
echo 'x - continuing file tutorial.sc'
sed 's/^X//' << 'SHAR_EOF' >> 'tutorial.sc' &&
leftstring A11 = "^n, j and the <DOWN> arrow key go down"
leftstring A12 = "^p, k and the <UP> arrow key go up"
leftstring A13 = "^b, h and the <LEFT> arrow key go left"
leftstring A14 = "^f, l and the <RIGHT> arrow key go right"
leftstring A15 = "You can go directly to a cell by typing 'g' and the cell name. "
leftstring A16 = "'g c6' will take you to cell c6."
leftstring A18 = "Cells can contain numbers, formulas, or text."
leftstring A19 = "Most of the cells on this page contain text."
leftstring C20 = "<Type 'g page2' to continue>"
leftstring A22 = "Cell d22 contains text"
leftstring D22 = "Text "
leftstring A23 = "Cell d23 contains a number"
let D23 = 123.34
leftstring A24 = "Cell d24 contains a formula"
let D24 = D23+88
leftstring A26 = "To see what the cell contains, just move the cursor"
leftstring A27 = "onto the cell.  The contents will show up on line 1 in the brackets."
leftstring page2 = "You can enter data into cells like this:"
leftstring B30 = "'<text' enters left justified text."
leftstring B31 = "'>text' enters right justified text."
leftstring B32 = "'=number' enters a number"
leftstring B33 = "'=formula' enters a formula."
leftstring A35 = "Try duplicating d22 through d24 in e22 though e24."
leftstring A37 = "You erase a cell by typing 'x' with the cursor on the cell."
leftstring C40 = "<Type 'g page3' to continue>"
leftstring A42 = "Here is a typical use for numbers and formulas:"
let A44 = 10.3
let B44 = 1877.5
let C44 = 234.7
let E44 = @sum(A44:C44)
let A45 = 44.56
let B45 = 44.3
let C45 = -3
let E45 = @sum(A45:C45)
let A46 = 88.74
let B46 = 8000
let C46 = -9
let E46 = @sum(A46:C46)
let A47 = 99.2
let B47 = -88
let C47 = -44.6
let E47 = @sum(A47:C47)
let page3 = @sum(A44:A47)
let B49 = @sum(B44:B47)
let C49 = @sum(C44:C47)
let E49 = @sum(A44:C47)
leftstring A51 = "The data is entered in a44 through c47."
leftstring A52 = "Cells a49, b49 and c49 sum their respective columns."
leftstring A53 = "Cells e44, e45, e46, and e47 sum their respective rows."
leftstring A54 = "Cell E49 is a grand total."
leftstring A55 = "Try changing some of the data cells and watch the sums change."
leftstring A57 = "You can also edit cells by putting the cursor on the cell and typing:"
leftstring B58 = "'e' to edit the numeric portion."
leftstring B59 = "'E' to edit the string portion."
leftstring C60 = "<Type 'g page4' to continue>"
leftstring A62 = "Since you are reading this, you know that you can load "
leftstring A63 = "a data base from a file by typing the file name as an"
leftstring A64 = "argument to the program.  You can also load or save a "
leftstring A65 = "data base using the file commands:"
leftstring B67 = "'G file'"
leftstring C67 = "Gets the data from an sc file."
leftstring B68 = "'P file'"
leftstring C68 = "Puts the data from the spreadsheet into a file."
leftstring page4 = "Try 'P foo.sc' to write this to the file foo.sc"
leftstring A71 = "The Get command erases the current spreadsheet.  "
leftstring A72 = "To merge a spreadsheet with the one currently in"
leftstring A73 = "the machine, use:"
leftstring B75 = "'M file'"
leftstring C75 = "Merge the data from a saved sc file."
leftstring A77 = "You can also get human readable versions of the data"
leftstring A78 = "by using the Write command:"
leftstring C80 = "<Type 'g page5' to continue>"
leftstring A82 = "Try 'W tut.txt' for a clear text version of the tutorial."
leftstring A85 = "This is the end of the tutorial.  We have explored"
leftstring A86 = "The basic commands.  Much more detail is available"
leftstring A87 = "in the man page."
leftstring D91 = "GOOD LUCK!"
SHAR_EOF
echo 'File tutorial.sc is complete' &&
chmod 0666 tutorial.sc ||
echo 'restore of tutorial.sc failed'
Wc_c="`wc -c < 'tutorial.sc'`"
test 4292 -eq "$Wc_c" ||
	echo 'tutorial.sc: original size 4292, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= version.c ==============
if test -f 'version.c' -a X"$1" != X"-c"; then
	echo 'x - skipping version.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting version.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'version.c' &&
/*
X * CODE REVISION NUMBER:
X *
X * The part after the first colon, except the last char, appears on the screen.
X */
X
char *rev = "$Revision: 6.8 $";
SHAR_EOF
chmod 0666 version.c ||
echo 'restore of version.c failed'
Wc_c="`wc -c < 'version.c'`"
test 148 -eq "$Wc_c" ||
	echo 'version.c: original size 148, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= vi.c ==============
if test -f 'vi.c' -a X"$1" != X"-c"; then
	echo 'x - skipping vi.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting vi.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'vi.c' &&
/*	SC	A Spreadsheet Calculator
X *
X *	One line vi emulation
X *	$Revision: 6.8 $
X */
X
X
#include <signal.h>
#include <curses.h>
X
#ifdef BSD42
#include <strings.h>
#else
#ifndef SYSIII
#include <string.h>
#endif
#endif
X
#ifndef AMIGA
#if !defined(strchr) && !defined(UPORT)
#define strchr index
#endif
extern	char	*strchr();
#endif /* AMIGA */
X
#include <stdio.h>
#include <ctype.h>
#include "sc.h"
X
#define istext(a) (isalnum(a) || ((a) == '_'))
X
extern int showrange;
extern char mode_ind;		/* Mode indicator */
X
/* values for mode below */
X
#define INSERT_MODE	0	/* Insert mode */
#define EDIT_MODE       1	/* Edit mode */
#define REP_MODE        2	/* Replace mode */
#define SEARCH_MODE	3	/* Get arguments for '/' command */
X 
static int mode = INSERT_MODE;
static char *history[HISTLEN];
static int histp = -1;
static char *last_search;
static char *undo_line;
static int undo_lim;
static char dotb[100];
static int doti = 0;
static int do_dot = 0;
X
void
write_line(c)
int c;
{
X    if (mode == EDIT_MODE) {
X	switch(c) {
X	case (ctl('h')):	linelim = back_line();		break;
X	case (ctl('m')):  cr_line();			break;
X	case ESC:	stop_edit();			break;
X	case '+':	for_hist();			break;
X	case '-':	back_hist();			break;
X	case '$':	last_col();			break;
X	case '.':	dotcmd();			break;
X	case '/':	search_mode();			break;
X	case '0':	col_0();			break;
X	case 'D':	u_save(c);del_to_end();		break;
X	case 'I':	u_save(c);col_0();insert_mode();break;
X	case 'R':	replace_mode();			break;
X	case 'X':	u_save(c); back_space();	break;
X	case 'a':	u_save(c); append_line();	break;
X	case 'b':	linelim = back_word();		break;
X	case 'c':	u_save(c); change_cmd();	break;
X	case 'd':	u_save(c); delete_cmd();	break;
X	case 'f':	linelim = find_char();		break;
X	case 'h':	linelim = back_line();		break;
X	case 'i':	u_save(c); insert_mode();	break;
X	case 'j':	for_hist();			break;
X	case 'k':	back_hist();			break;
X	case 'l':	linelim = for_line(0);		break;
X	case 'n':	search_again();			break;
X	case 'q':	stop_edit();			break;
X	case 'r':	u_save(c); rep_char();		break;
X	case 't':	linelim = to_char();		break;
X	case 'u':	restore_it();			break;
X	case 'w':	linelim = for_word(0);		break;
X	case 'x':	u_save(c); del_in_line();	break;
X	default:	break;
X	}
X    } else if (mode == INSERT_MODE) { 
X	savedot(c);
X	switch(c) {
X	case (ctl('h')):	back_space();			break;
X	case (ctl('m')):  cr_line();			break;
X	case ESC:	edit_mode();			break;
X	default:	ins_in_line(c);			break;
X	}
X    } else if (mode == SEARCH_MODE) {
X	switch(c) {
X	case (ctl('h')):	back_space();			break;
X	case (ctl('m')):  search_hist();			break;
X	case ESC:	edit_mode();			break;
X	default:	ins_in_line(c);			break;
X	}
X   } else if (mode == REP_MODE) {
X	savedot(c);
X	switch(c) {
X	case (ctl('h')):	back_space();			break;
X	case (ctl('m')):  cr_line();			break;
X	case ESC:	edit_mode();			break;
X	default:	replace_in_line(c);		break;
X	}
X    }
}
X
edit_mode()
{
X    mode = EDIT_MODE;
X    mode_ind = 'e';
X    histp = -1;
X    if (line[linelim] == '\0')
X	linelim = back_line();
}
X
void
insert_mode()
{
X    mode_ind = 'i';
X    mode = INSERT_MODE;
}
X
search_mode()
{
X    line[0] = '/';
X    line[1] = 0;
X    linelim = 1;
X    histp = -1;
X    mode_ind = '/';
X    mode = SEARCH_MODE;
}
X
replace_mode()
{
X    mode_ind = 'R';
X    mode = REP_MODE;
}
X
/* dot command functions.  Saves info so we can redo on a '.' command */
X
savedot(c)
int c;
{
X    if (do_dot)
X	return;
X
X    dotb[doti++] = c;
X    dotb[doti] = 0;
}
X
dotcmd()
{
X    int c;
X
X    do_dot = 1;
X    doti = 0;
X    while(dotb[doti] != 0) {
X	c = dotb[doti++];
X	write_line(c);
X    }
X    do_dot = 0;
X    doti = 0;
}
X
vigetch()
{
X    int c;
X
X    if(do_dot) {
X	if (dotb[doti] != 0) {
X	    return(dotb[doti++]);
X	} else {
X	    do_dot = 0;
X	    doti = 0;
X	    return(nmgetch());
X	}
X    }
X    c = nmgetch();
X    savedot(c);
X    return(c);
}
X
/* saves the current line for possible use by an undo cmd */
X
u_save(c)
int c;
{
X    if (undo_line) {
X	xfree(undo_line);
X	undo_line = 0;
X    }
X    undo_line = strcpy(xmalloc((unsigned)(strlen(line)+1)), line);
X    undo_lim = linelim;
X
X    /* reset dot command if not processing it. */
X
X    if (!do_dot) {
X        doti = 0;
X	savedot(c);
X    }
}
X
/* Restores the current line saved by u_save() */
X
restore_it()
{
X    register char *tempc;
X    register int tempi;
X
X    if (!undo_line)
X	return;
X    tempc = strcpy(xmalloc((unsigned)(strlen(line)+1)), line);
X    tempi = linelim;
X    strcpy(line, undo_line);
X    linelim = undo_lim;
X    xfree(undo_line);
X    undo_line = tempc;
X    undo_lim = tempi;
}
X
/* This command stops the editing process. */
X
stop_edit()
{
X    showrange = 0;
X    linelim = -1;
X    (void) move(1, 0);
X    (void) clrtoeol();
}
X
/*
X * Motion commands.  Forward motion commands take an argument
X * which, when set, cause the forward motion to continue onto
X * the null at the end of the line instead of stopping at the
X * the last character of the line.
X */
X
for_line(stop_null)
int stop_null;
{
X    if (linelim >= 0 && line[linelim] != 0 && 
X    		        (line[linelim+1] != 0 || stop_null))
X	return(linelim+1);
X    else
X	return(linelim);
}
X
for_word(stop_null)
int stop_null;
{
X    register int c;
X    register int cpos;
X
X    cpos = linelim;
X
X    if (line[cpos] == ' ') {
X	while (line[cpos] == ' ')
X	    cpos++;
X	if (cpos > 0 && line[cpos] == 0)
X	    --cpos;
X	return(cpos);
X    }
X
X    if (istext(line[cpos])) {
X    	while ((c = line[cpos]) && istext(c)) 
X		cpos++;
X    } else {
X	while ((c = line[cpos]) && !istext(c) && c != ' ')
X		cpos++;
X    }
X
X    while (line[cpos] == ' ')
X        cpos++;
X
X    if (cpos > 0 && line[cpos] == 0 && !stop_null) 
X        --cpos;
X
X    return(cpos);
}
X
back_line()
{
X    if (linelim)
X        return(linelim-1);
X    else
X	return(0);
}
X
back_word()
{
X    register int c;
X    register int cpos;
X
X    cpos = linelim;
X
X    if (line[cpos] == ' ') {
X	/* Skip white space */
X        while (cpos > 0 && line[cpos] == ' ')
X	    --cpos;
X    } else if (cpos > 0 && (line[cpos-1] == ' ' 
X		     ||  istext(line[cpos]) && !istext(line[cpos-1])
X		     || !istext(line[cpos]) &&  istext(line[cpos-1]))) {
X	/* Started on the first char of a word - back up to prev. word */
X	--cpos;
X        while (cpos > 0 && line[cpos] == ' ')
X	    --cpos;
X    }
X
X    /* Skip across the word - goes 1 too far */
X    if (istext(line[cpos])) {
X    	while (cpos > 0 && (c = line[cpos]) && istext(c)) 
X		--cpos;
X    } else {
X	while (cpos > 0 && (c = line[cpos]) && !istext(c) && c != ' ')
X		--cpos;
X    }
X
X    /* We are done - fix up the one too far */
X    if (cpos > 0 && line[cpos] && line[cpos+1]) 
X	cpos++;
X
X    return(cpos);
}
X
/* Text manipulation commands */
X
del_in_line()
{
X    register int len, i;
X
X    if (linelim >= 0) {
X	len = strlen(line);
X	if (linelim == len && linelim > 0)
X	    linelim--;
X	for (i = linelim; i < len; i++)
X	    line[i] = line[i+1];
X    }
X    if (linelim > 0 && line[linelim] == 0)
X	--linelim;
}
X
ins_in_line(c)
int c;
{
X    register int i, len;
X
X    len = strlen(line);
X    for (i = len; i >= linelim; --i)
X	line[i+1] = line[i];
X    line[linelim++] = c;
X    line[len+1] = 0;
}
X
void
ins_string(s)
char *s;
{
X    while (*s)
X	ins_in_line(*s++);
}
X
append_line()
{
X    register int i;
X
X    i = linelim;
X    if (i >= 0 && line[i])
X	linelim++;
X    insert_mode();
}
X
rep_char()
{
X    int c;
X
X    c = vigetch();
X    if (line[linelim] != 0) {
X    	line[linelim] = c;
X    } else {
X	line[linelim] = c;
X	line[linelim+1] = 0;
X    }
}
X
replace_in_line(c)
{
X    register int len;
X
X    len = strlen(line);
X    line[linelim++] = c;
X    if (linelim > len)
X	line[linelim] = 0;
}
X    
back_space()
{
X    if (linelim == 0)
X	return;
X
X    if (line[linelim] == 0) {
X	linelim = back_line();
X	del_in_line();
X	linelim = strlen(line);
X    } else {
X	linelim = back_line();
X	del_in_line();
X    }
}
X
get_motion()
{
X    int c;
X
X    c = vigetch();
X    switch (c) {
X    case 'b':	return(back_word());
X    case 'f':	return(find_char()+1);
X    case 'h':	return(back_line());
X    case 'l':	return(for_line(1));
X    case 't':	return(to_char()+1);
X    case 'w':	return(for_word(1));
X    default:	return(linelim);
X    }
}
X
delete_cmd()
{
X    int cpos;
X
X    cpos = get_motion();
X    del_chars(cpos, linelim);
}
X
change_cmd()
{
X    delete_cmd();
X    insert_mode();
}
X
del_chars(first, last)
register int first, last;
{
X    int temp;
X
X    if (first == last)
X	return;
X
X    if (last < first) {
X	temp = last; last = first; first = temp;
X    }
X
X    linelim = first;
X    while(first < last) {
X	del_in_line();
X	--last;
X    }
}
X
del_to_end()
{
X    if (linelim < 0)
X	return;
X    line[linelim] = 0;
X    linelim = back_line();
}
X
cr_line()
{
X    showrange = 0;
X    insert_mode();
X    save_hist();
X    linelim = 0;
X    (void) yyparse ();
X    linelim = -1;
}
X
/* History functions */
X
save_hist()
{
X    register int i;
X
X    /* free the oldest one */
X    if (history[HISTLEN-1]) {
X	xfree(history[HISTLEN-1]);
X	history[HISTLEN-1] = 0;
X    }
X
X    /* Move the others back */
X    for (i = HISTLEN-1; i > 0; --i)
X	history[i] = history[i-1];
X
X    history[0] = xmalloc((unsigned) strlen(line)+1);
X    strcpy(history[0], line);
}
X
back_hist()
{
X    if (histp == -1 || histp < HISTLEN-1 && history[histp + 1])
X	histp++;
X
X    if (history[histp]) {
X    	strcpy(line, history[histp]);
X	linelim = 0;
X    } else
X	line[linelim = 0] = 0;
X
}
X
search_hist()
{
X    if (last_search) {
X	xfree(last_search);
X	last_search = 0;
X    }
X
X    if(linelim < 1) {
X	linelim = 0;
X	edit_mode();
X	return;
X    }
X
X    last_search = strcpy(xmalloc((unsigned)(strlen(line+1)+1)), line+1);
X    search_again();
X    mode = EDIT_MODE;
}
X
search_again()
{
X    int found_it;
X    int do_next;
X    int prev_histp;
X    char *look_here;
X
X    prev_histp = histp;
X    if (!last_search)
X	return;
X
X    do {
X	back_hist();
X	if (prev_histp == histp)
X	    break;
X	prev_histp = histp;
X	look_here = line;
X	found_it = do_next = 0;
X	while ((look_here = strchr(look_here, last_search[0])) &&
X						!found_it && !do_next) {
X
X	    if (strncmp(look_here, last_search, strlen(last_search)) == 0)
X		found_it++;
X	    else if (look_here < line + strlen(line) - 1)
X	        look_here++;
X	    else
X		do_next++;
X	}
X    } while (!found_it);
}
X
for_hist()
{
X    if (histp > 0)
X        histp--;
X
X    if (histp >= 0 && history[histp]) {
X    	strcpy(line, history[histp]);
X	linelim = 0;
X    } else
X	line[linelim = 0] = 0;
}
X
col_0()
{
X    linelim = 0;
}
X
last_col()
{
X    linelim = strlen(line);
X    if (linelim > 0)
X	--linelim;
}
X
find_char()
{
X    register int c;
X    register int i;
X
X
X    c = vigetch();
X    i = linelim;
X    while(line[i] && line[i] != c)
X	i++;
X    if (!line[i])
X	i = linelim;
X    return(i);
}
X
to_char()
{
X    register int i;
X
X    i = find_char();
X    if (i > 0 && i != linelim)
X	--i;
X
X    return(i);
}
SHAR_EOF
chmod 0666 vi.c ||
echo 'restore of vi.c failed'
Wc_c="`wc -c < 'vi.c'`"
test 10617 -eq "$Wc_c" ||
	echo 'vi.c: original size 10617, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= vms_notes ==============
if test -f 'vms_notes' -a X"$1" != X"-c"; then
	echo 'x - skipping vms_notes (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting vms_notes (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'vms_notes' &&
XFrom: ihnp4!gargoyle!oddjob!noao!arizona!naucse!jdc (John Campbell)
To: arizona!noao!oddjob!gargoyle!ihnp4!nsc!nscpdc!rgb
Subject: VMS SC
X
VMS USERS:
X
Bob Bond has been generous enough to give me free rein in adding what I
think is needed to make SC run on VMS.  Any problems with VMS should be
directed to me--they are not Bob's fault.
X
The VMS SC is "SIMPLE" for the most part, except that the arrow keys
(instead of hjkl) will move you around the cells.  The VMS version of SC
will not interact with the Bourne shell (obviously), which means that CRYPT
and EXTERNAL FUNCTIONS will not be available.
X
If you have a 'C' compiler and GNU Bison then you should be able to get
SC running on VMS by following the instructions below.
X
Step 1:  Get all the files
X
I've heard of a few sites that can unpack unix shar files directly on
VMS.  Most people, however, will need access to a unix machine to get
the original distribution unpacked.  At this time you should also build
experres.h and statres.h and perhaps run the man pages off if you need
to port the documentation. To build the two "missing" hearder files:
X   sed <gram.y >experres.h -f eres.sed
X   sed <gram.y >statres.h -f sres.sed
X
Step 2: Cut out BUILD.COM and GETOPT.C
X
At the end of this file are two other pieces: BUILD.COM and GETOPT.C.  After
you've moved everything to VMS, cut BUILD.COM and GETOPT.C out of here and
put them in the same directory as the rest of the SC distribution.
X
Step 3: Build it
X
Theoretically all you now need to do is @BUILD and SC (as well as PSC)
will be running on VMS.  If you have problems feel free to contact me
at ...!arizona!naucse!jdc  (or even call at 602-523-6259).
X
---------------------cut here for BUILD.COM--------------------------
$! VMS command file to build SC and PSC (requires bison)
$! SC:
$ bison -d gram.y
$ ren gram_tab.c gram.c
$ cc  /define=("SIMPLE","SIGVOID") sc.c
$ cc  /define=("SIMPLE","SIGVOID") gram.c
$ cc  /define=("SIMPLE","SIGVOID") lex.c
$ cc  /define=("SIMPLE","SIGVOID") interp
$ cc  /define=("SIMPLE","SIGVOID") cmds
$ cc  /define=("SIMPLE","SIGVOID") xmalloc
$ cc  /define=("SIMPLE","SIGVOID") range
$ cc  /define=("SIMPLE","SIGVOID") help
$ link sc.obj,lex.obj,gram.obj,interp.obj,cmds.obj,xmalloc.obj,-
X       range.obj,help.obj,sys$library:vaxcrtl.olb/lib
$ !
$ ! Create VMS foreign command symbol to test SC
$ !
$ sc == "$" + f$logical("SYS$DISK") + f$directory() + "SC.EXE"
$!
$! Now PSC
$!
$ cc psc.c
$ cc getopt.c
$ link psc,getopt,sys$library:vaxcrtl.olb/lib
$ !
$ ! Create VMS foreign command symbol to test PSC (Note that
$ ! PSC reads SYS$INPUT and writes to SYS$OUTPUT, so use
$ ! DEFINE/USER to redirect.)
$ !
$ psc == "$" + f$logical("SYS$DISK") + f$directory() + "PSC.EXE"
X
---------------------cut here for GETOPT.C------------------------
/*
X * getopt - get option letter from argv
X *      This software is in the public domain
X *      Originally written by Henry Spencer at the U. of Toronto
X */
X
#include <stdio.h>
X
char    *optarg;        /* Global argument pointer. */
int     optind = 0;     /* Global argv index. */
X
static char     *scan = NULL;   /* Private scan pointer. */
X
/* extern char     *index();  obsolete, used strchr (JDC). */
X
int
getopt(argc, argv, optstring)
int argc;
char *argv[];
char *optstring;
{
X        register char c;
X        register char *place;
X
X        optarg = NULL;
X
X        if (scan == NULL || *scan == '\0') {
X                if (optind == 0)
X                        optind++;
X
X                if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
X                        return(EOF);
X                if (strcmp(argv[optind], "--")==0) {
X                        optind++;
X                        return(EOF);
X                }
X
X                scan = argv[optind]+1;
X                optind++;
X        }
X
X        c = *scan++;
X        place = strchr(optstring, c);
X
X        if (place == NULL || c == ':') {
X                fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
X                return('?');
X        }
X
X        place++;
X        if (*place == ':') {
X                if (*scan != '\0') {
X                        optarg = scan;
X                        scan = NULL;
X                } else {
X                        optarg = argv[optind];
X                        optind++;
X                }
X        }
X
X        return(c);
}
SHAR_EOF
chmod 0666 vms_notes ||
echo 'restore of vms_notes failed'
Wc_c="`wc -c < 'vms_notes'`"
test 4341 -eq "$Wc_c" ||
	echo 'vms_notes: original size 4341, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= vmtbl.c ==============
if test -f 'vmtbl.c' -a X"$1" != X"-c"; then
	echo 'x - skipping vmtbl.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting vmtbl.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'vmtbl.c' &&
#ifdef PSC
# include <stdio.h>
# include "sc.h"
# ifndef FALSE
#  define	FALSE	0
#  define	TRUE	1
# endif /* !FALSE */
# undef	error
# define error(msg)	fprintf(stderr, msg);
#else /* PSC */
# include <curses.h>
# include "sc.h"
#endif /* PSC */
X
extern	char	*malloc();
extern	char	*realloc();
X
#if defined(BSD42) || defined(BSD43)
#define	memcpy(dest, source, len)	bcopy(source, dest, (unsigned int)len);
#define	memset(dest, zero, len)		bzero((dest), (unsigned int)(len));
#endif
X
/*
X * check to see if *rowp && *colp are currently allocated, if not expand the
X * current size if we can.
X */
#ifndef PSC
void
checkbounds(rowp, colp)
int	*rowp;
int	*colp;
{
X	if (*rowp < 0)
X		*rowp = 0;
X	else if (*rowp >= maxrows)
X	{	if (*colp >= maxcols)
X		{	if (!growtbl(GROWBOTH, *rowp, *colp))
X			{	*rowp = maxrows -1;
X				*colp = maxcols -1;
X			}
X			return;
X		}
X		else
X		{	if (!growtbl(GROWROW, *rowp, 0))
X				*rowp = maxrows-1;
X			return;
X		}
X	}
X	if (*colp < 0) 
X		*colp = 0;
X	else if (*colp >= maxcols)
X	{	if (!growtbl(GROWCOL, 0, *colp));
X			*colp = maxcols-1;
X	}
}
#endif /* !PSC */
X	
X
#define GROWALLOC(newptr, oldptr, nelem, type, msg) \
X	if (oldptr == (type *)NULL) \
X		newptr = (type *)malloc((unsigned)(nelem*sizeof(type))); \
X	else \
X		newptr = (type *)realloc((char *)oldptr, \
X					 (unsigned)(nelem*sizeof(type))); \
X	if (newptr == (type *)NULL) \
X	{   error(msg); \
X	    return(FALSE); \
X	} \
X	oldptr = newptr /* wait incase we can't alloc */
X
static	char	nolonger[] = "The table can't be any longer";
static	char	nowider[] = "The table can't be any wider";
X
/*
X * grow the main && auxiliary tables (reset maxrows/maxcols as needed)
X * toprow &&/|| topcol tell us a better guess of how big to become.
X * we return TRUE if we could grow, FALSE if not....
X */
int
growtbl(rowcol, toprow, topcol)
int	rowcol;
int	toprow, topcol;
{
X	struct ent ***tbl2;
X	int	*fwidth2;
X	int	*precision2;
X	char	*col_hidden2;
X	char	*row_hidden2;
X	int	newrows, newcols;
X	int	i;
X
#ifndef PSC
X	newrows = maxrows;
#endif /* !PSC */
X
X	newcols = maxcols;
X	if (rowcol == GROWNEW)
X	{
#ifndef PSC
X		maxrows = toprow = 0;
X		/* when we first start up, fill the screen w/ cells */
X		{	int startval;
X			startval = LINES - RESROW;
X			newrows = startval > MINROWS ? startval : MINROWS;
X			startval = ((COLS) - RESCOL) / DEFWIDTH;
X			newcols = startval > MINCOLS ? startval : MINCOLS;
X		}
#else
X		newcols = MINCOLS;
#endif /* !PSC */
X		maxcols = topcol = 0;
X	}
#ifndef PSC
X	/* set how much to grow */
X	if ((rowcol == GROWROW) || (rowcol == GROWBOTH))
X	{	if (toprow > maxrows)
X			newrows = GROWAMT + toprow;
X		else
X			newrows += GROWAMT;
X	}
#endif /* !PSC */
X	if ((rowcol == GROWCOL) || (rowcol == GROWBOTH))
X	{	if ((rowcol == GROWCOL) && ((maxcols == ABSMAXCOLS) ||
X					(topcol >= ABSMAXCOLS)))
X		{	error(nowider);
X			return(FALSE);
X		}
X
X		if (topcol > maxcols)
X			newcols = GROWAMT + topcol;
X		else
X			newcols += GROWAMT;
X
X		if (newcols > ABSMAXCOLS)
X			newcols = ABSMAXCOLS;
X	}
X
#ifndef PSC
X	if ((rowcol == GROWROW) || (rowcol == GROWBOTH) || (rowcol == GROWNEW))
X	{
X		GROWALLOC(row_hidden2, row_hidden, newrows, char, nolonger);
X		memset(row_hidden+maxrows, 0, (newrows-maxrows)*sizeof(char));
X
X		/* alloc tbl row pointers */
X		GROWALLOC(tbl2, tbl, newrows, struct ent **, nolonger);
X		memset(tbl+maxrows, 0, (newrows-maxrows)*(sizeof(struct ent **)));
X	}
#endif /* !PSC */
X
X	if ((rowcol == GROWCOL) || (rowcol == GROWBOTH) || (rowcol == GROWNEW))
X	{
X		GROWALLOC(fwidth2, fwidth, newcols, int, nowider);
X		GROWALLOC(precision2, precision, newcols, int, nowider);
#ifdef PSC
X		memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int));
X		memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int));
X	}
#else
X		GROWALLOC(col_hidden2, col_hidden, newcols, char, nowider);
X		memset(col_hidden+maxcols, 0, (newcols-maxcols)*sizeof(char));
X		for (i = maxcols; i < newcols; i++) {
X			fwidth[i] = DEFWIDTH;
X			precision[i] = DEFPREC;
X		}
X
X		/* [re]alloc the space for each row */
X		for (i = 0; i < maxrows; i++)
X		{
X		    if ((tbl[i] = (struct ent **)realloc((char *)tbl[i],
X			(unsigned)(newcols * sizeof(struct ent **)))) == (struct ent **)0)
X			{	error(nowider);
X				return(FALSE);
X			}
X		    memset((char *)ATBL(tbl,i, maxcols), 0,
X			   (newcols-maxcols)*sizeof(struct ent **));
X		}
X	}
X	else
X		i = maxrows;
X
X	/* fill in the bottom of the table */
X	for (; i < newrows; i++)
X	{	if ((tbl[i] = (struct ent **)malloc((unsigned)(newcols *
X				sizeof(struct ent **)))) == (struct ent **)0)
X		{	error(nowider);
X			return(FALSE);
X		}
X		memset((char *)tbl[i], 0, newcols*sizeof(struct ent **));
X	}
X
X	FullUpdate++;
X	maxrows = newrows;
#endif /* PSC */
X
X	maxcols = newcols;
X	return(TRUE);
}
SHAR_EOF
chmod 0666 vmtbl.c ||
echo 'restore of vmtbl.c failed'
Wc_c="`wc -c < 'vmtbl.c'`"
test 4643 -eq "$Wc_c" ||
	echo 'vmtbl.c: original size 4643, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= xmalloc.c ==============
if test -f 'xmalloc.c' -a X"$1" != X"-c"; then
	echo 'x - skipping xmalloc.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting xmalloc.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xmalloc.c' &&
/*
X * A safer saner malloc, for careless programmers
X * $Revision: 6.8 $
X */
X
#include <stdio.h>
#include <curses.h>
#include "sc.h"
X
extern char *malloc();
X
#ifdef SYSV3
extern void free();
extern void exit();
#endif
X
char *
xmalloc(n)
unsigned n;
{
register char *ptr;
X
if ((ptr = malloc(n + sizeof(double))) == NULL)
X    fatal("xmalloc: no memory");
*((int *) ptr) = 12345;		/* magic number */
return(ptr + sizeof(double));
}
X
xfree(p)
char *p;
{
if (p == NULL)
X    fatal("xfree: NULL");
p -= sizeof(double);
if (*((int *) p) != 12345)
X    fatal("xfree: storage not malloc'ed");
free(p);
}
X
fatal(str)
char *str;
{
X    deraw();
X    (void) fprintf(stderr,"%s\n", str);
X    exit(1);
}
SHAR_EOF
chmod 0666 xmalloc.c ||
echo 'restore of xmalloc.c failed'
Wc_c="`wc -c < 'xmalloc.c'`"
test 686 -eq "$Wc_c" ||
	echo 'xmalloc.c: original size 686, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= y.tab.h ==============
if test -f 'y.tab.h' -a X"$1" != X"-c"; then
	echo 'x - skipping y.tab.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting y.tab.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'y.tab.h' &&
typedef union {
X    int ival;
X    double fval;
X    struct ent_ptr ent;
X    struct enode *enode;
X    char *sval;
X    struct range_s rval;
} YYSTYPE;
X
#ifndef YYLTYPE
typedef
X  struct yyltype
X    {
X      int timestamp;
X      int first_line;
X      int first_column;
X      int last_line;
X      int last_column;
X      char *text;
X   }
X  yyltype;
X
#define YYLTYPE yyltype
#endif
X
#define	YYACCEPT	return(0)
#define	YYABORT	return(1)
#define	YYERROR	return(1)
#define	STRING	258
#define	NUMBER	259
#define	FNUMBER	260
#define	RANGE	261
#define	VAR	262
#define	WORD	263
#define	COL	264
#define	S_FORMAT	265
#define	S_LABEL	266
#define	S_LEFTSTRING	267
#define	S_RIGHTSTRING	268
#define	S_GET	269
#define	S_PUT	270
#define	S_MERGE	271
#define	S_LET	272
#define	S_WRITE	273
#define	S_TBL	274
#define	S_COPY	275
#define	S_SHOW	276
#define	S_ERASE	277
#define	S_FILL	278
#define	S_GOTO	279
#define	S_DEFINE	280
#define	S_UNDEFINE	281
#define	S_VALUE	282
#define	S_MDIR	283
#define	S_HIDE	284
#define	S_SET	285
#define	K_FIXED	286
#define	K_SUM	287
#define	K_PROD	288
#define	K_AVG	289
#define	K_STDDEV	290
#define	K_COUNT	291
#define	K_ABS	292
#define	K_ACOS	293
#define	K_ASIN	294
#define	K_ATAN	295
#define	K_ATAN2	296
#define	K_CEIL	297
#define	K_COS	298
#define	K_EXP	299
#define	K_FABS	300
#define	K_FLOOR	301
#define	K_HYPOT	302
#define	K_LN	303
#define	K_LOG	304
#define	K_PI	305
#define	K_POW	306
#define	K_SIN	307
#define	K_SQRT	308
#define	K_TAN	309
#define	K_DTR	310
#define	K_RTD	311
#define	K_MAX	312
#define	K_MIN	313
#define	K_RND	314
#define	K_ROUND	315
#define	K_IF	316
#define	K_PV	317
#define	K_FV	318
#define	K_PMT	319
#define	K_HOUR	320
#define	K_MINUTE	321
#define	K_SECOND	322
#define	K_MONTH	323
#define	K_DAY	324
#define	K_YEAR	325
#define	K_NOW	326
#define	K_DATE	327
#define	K_DTS	328
#define	K_TTS	329
#define	K_FMT	330
#define	K_SUBSTR	331
#define	K_STON	332
#define	K_EQS	333
#define	K_EXT	334
#define	K_NVAL	335
#define	K_SVAL	336
#define	K_LOOKUP	337
#define	K_HLOOKUP	338
#define	K_VLOOKUP	339
#define	K_INDEX	340
#define	K_STINDEX	341
#define	K_AUTO	342
#define	K_AUTOCALC	343
#define	K_BYROWS	344
#define	K_BYCOLS	345
#define	K_BYGRAPH	346
#define	K_ITERATIONS	347
#define	K_NUMERIC	348
#define	K_PRESCALE	349
#define	K_EXTFUN	350
#define	K_CELLCUR	351
#define	K_TOPROW	352
#define	K_TBLSTYLE	353
#define	K_TBL	354
#define	K_LATEX	355
#define	K_TEX	356
X
SHAR_EOF
chmod 0666 y.tab.h ||
echo 'restore of y.tab.h failed'
Wc_c="`wc -c < 'y.tab.h'`"
test 2377 -eq "$Wc_c" ||
	echo 'y.tab.h: original size 2377, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo You have unpacked the last part
exit 0
--
Simon J Raybould    (sie@fulcrum.bt.co.uk)            //              {o.o}
                                                    \X/AMIGA           \-/
===========================================================================
British Telecom Fulcrum, Fordrough Lane, Birmingham, B9 5LD, ENGLAND.