|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1515 (0x5eb)
Types: TextFile
Notes: UNIX file
Names: »sed1.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »cmd/sed/sed1.c«
/*
* A stream editor.
* Main.
*/
#include <stdio.h>
#include <ctype.h>
#include "sed.h"
main(argc, argv)
char *argv[];
{
ECL **eclpp;
int scrflag;
register ECL *ep;
register int i;
register char *cp;
scrflag = 0;
initialise();
eclpp = &eclp;
for (i=1; i<argc; i++) {
cp = &argv[i][0];
if (*cp++ != '-') {
*eclpp = ep = (ECL *)salloc(sizeof (ECL));
eclpp = &ep->e_next;
ep->e_argp = argv[i];
continue;
}
while (*cp) {
switch (*cp++) {
case 'e':
if (++i >= argc)
usage();
compstr(argv[i]);
scrflag++;
continue;
case 'f':
if (++i >= argc)
usage();
compfil(argv[i]);
scrflag++;
continue;
case 'n':
nflag++;
continue;
case 's':
sflag++;
continue;
default:
usage();
}
}
}
*eclpp = NULL;
if (scrflag==0 && eclp!=NULL) {
ep = eclp;
eclp = eclp->e_next;
compstr(ep->e_argp);
free(ep);
}
load();
if (nerr != 0)
exit(1);
ifp = eclp==NULL ? stdin : NULL;
process();
}
/*
* Print out a usage message.
*/
usage()
{
fprintf(stderr, "Usage: sed [-n] [-e script] [-f sfile] [file]\n");
exit(1);
}
/*
* Initialisation.
*/
initialise()
{
compp = ∁
filp = NULL;
labp = NULL;
qcbp = NULL;
pattlen = 0;
holdlen = 0;
nflag = 0;
sflag = 0;
nerr = 0;
lno = 0;
}
/*
* Leave.
*/
leave()
{
exit(0);
}
/*
* Allocate `n' bytes of memory.
*/
char *
salloc(n)
{
register char *cp;
if ((cp=malloc(n)) == NULL) {
fprintf(stderr, "Out of core\n");
exit(1);
}
return (cp);
}