Update sed.
This commit is contained in:
@@ -28,43 +28,43 @@
|
||||
#define LABSIZE 50
|
||||
#define NBRA 9
|
||||
|
||||
FILE *fin;
|
||||
union reptr *abuf[ABUFSIZE];
|
||||
union reptr **aptr;
|
||||
char *lastre;
|
||||
char ibuf[BUFSIZ];
|
||||
char *cbp;
|
||||
char *ebp;
|
||||
char genbuf[LBSIZE];
|
||||
char *loc1;
|
||||
char *loc2;
|
||||
char *locs;
|
||||
char seof;
|
||||
char *reend;
|
||||
char *lbend;
|
||||
char *hend;
|
||||
char *lcomend;
|
||||
union reptr *ptrend;
|
||||
int eflag;
|
||||
int dolflag;
|
||||
int sflag;
|
||||
int jflag;
|
||||
int numbra;
|
||||
int delflag;
|
||||
long lnum;
|
||||
char linebuf[LBSIZE+1];
|
||||
char holdsp[LBSIZE+1];
|
||||
char *spend;
|
||||
char *hspend;
|
||||
int nflag;
|
||||
int gflag;
|
||||
char *braelist[NBRA];
|
||||
char *braslist[NBRA];
|
||||
long tlno[NLINES];
|
||||
int nlno;
|
||||
char fname[12][40];
|
||||
FILE *fcode[12];
|
||||
int nfiles;
|
||||
extern FILE *fin;
|
||||
extern union reptr *abuf[ABUFSIZE];
|
||||
extern union reptr **aptr;
|
||||
extern char *lastre;
|
||||
extern char ibuf[BUFSIZ];
|
||||
extern char *cbp;
|
||||
extern char *ebp;
|
||||
extern char genbuf[LBSIZE];
|
||||
extern char *loc1;
|
||||
extern char *loc2;
|
||||
extern char *locs;
|
||||
extern char seof;
|
||||
extern char *reend;
|
||||
extern char *lbend;
|
||||
extern char *hend;
|
||||
extern char *lcomend;
|
||||
extern union reptr *ptrend;
|
||||
extern int eflag;
|
||||
extern int dolflag;
|
||||
extern int sflag;
|
||||
extern int jflag;
|
||||
extern int numbra;
|
||||
extern int delflag;
|
||||
extern long lnum;
|
||||
extern char linebuf[LBSIZE+1];
|
||||
extern char holdsp[LBSIZE+1];
|
||||
extern char *spend;
|
||||
extern char *hspend;
|
||||
extern int nflag;
|
||||
extern int gflag;
|
||||
extern char *braelist[NBRA];
|
||||
extern char *braslist[NBRA];
|
||||
extern long tlno[NLINES];
|
||||
extern int nlno;
|
||||
extern char fname[12][40];
|
||||
extern FILE *fcode[12];
|
||||
extern int nfiles;
|
||||
|
||||
#define ACOM 01
|
||||
#define BCOM 020
|
||||
@@ -94,9 +94,9 @@ int nfiles;
|
||||
#define YCOM 026
|
||||
#define XCOM 033
|
||||
|
||||
char *cp;
|
||||
char *reend;
|
||||
char *lbend;
|
||||
extern char *cp;
|
||||
extern char *reend;
|
||||
extern char *lbend;
|
||||
|
||||
union reptr {
|
||||
struct reptr1 {
|
||||
@@ -123,39 +123,34 @@ union reptr {
|
||||
char inar;
|
||||
char negfl;
|
||||
} B;
|
||||
} ptrspace[PTRSIZE], *rep;
|
||||
};
|
||||
extern union reptr ptrspace[PTRSIZE], *rep;
|
||||
|
||||
|
||||
char respace[RESIZE];
|
||||
extern char respace[RESIZE];
|
||||
|
||||
struct label {
|
||||
char asc[9];
|
||||
union reptr *chain;
|
||||
union reptr *address;
|
||||
} ltab[LABSIZE];
|
||||
};
|
||||
extern struct label ltab[LABSIZE];
|
||||
|
||||
struct label *lab;
|
||||
struct label *labend;
|
||||
extern struct label *lab;
|
||||
extern struct label *labend;
|
||||
|
||||
int f;
|
||||
int depth;
|
||||
extern int f;
|
||||
extern int depth;
|
||||
|
||||
int eargc;
|
||||
char **eargv;
|
||||
extern int eargc;
|
||||
extern char **eargv;
|
||||
|
||||
extern char bittab[];
|
||||
extern char bittab[];
|
||||
|
||||
union reptr **cmpend[DEPTH];
|
||||
int depth;
|
||||
union reptr *pending;
|
||||
char *badp;
|
||||
char bad;
|
||||
char *compile();
|
||||
char *ycomp();
|
||||
char *address();
|
||||
char *text();
|
||||
char *compsub();
|
||||
struct label *search();
|
||||
char *gline();
|
||||
char *place();
|
||||
char compfl;
|
||||
extern union reptr **cmpend[DEPTH];
|
||||
extern int depth;
|
||||
extern union reptr *pending;
|
||||
extern char *badp;
|
||||
extern char bad;
|
||||
extern char compfl;
|
||||
|
||||
void execute(char *file);
|
||||
|
||||
@@ -19,8 +19,75 @@ char bittab[] = {
|
||||
128
|
||||
};
|
||||
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
FILE *fin;
|
||||
union reptr *abuf[ABUFSIZE];
|
||||
union reptr **aptr;
|
||||
char *lastre;
|
||||
char ibuf[BUFSIZ];
|
||||
char *cbp;
|
||||
char *ebp;
|
||||
char genbuf[LBSIZE];
|
||||
char *loc1;
|
||||
char *loc2;
|
||||
char *locs;
|
||||
char seof;
|
||||
char *reend;
|
||||
char *lbend;
|
||||
char *hend;
|
||||
char *lcomend;
|
||||
union reptr *ptrend;
|
||||
int eflag;
|
||||
int dolflag;
|
||||
int sflag;
|
||||
int jflag;
|
||||
int numbra;
|
||||
int delflag;
|
||||
long lnum;
|
||||
char linebuf[LBSIZE+1];
|
||||
char holdsp[LBSIZE+1];
|
||||
char *spend;
|
||||
char *hspend;
|
||||
int nflag;
|
||||
int gflag;
|
||||
char *braelist[NBRA];
|
||||
char *braslist[NBRA];
|
||||
long tlno[NLINES];
|
||||
int nlno;
|
||||
char fname[12][40];
|
||||
FILE *fcode[12];
|
||||
int nfiles;
|
||||
char *cp;
|
||||
char *reend;
|
||||
char *lbend;
|
||||
union reptr ptrspace[PTRSIZE], *rep;
|
||||
char respace[RESIZE];
|
||||
struct label ltab[LABSIZE];
|
||||
struct label *lab;
|
||||
struct label *labend;
|
||||
int f;
|
||||
int depth;
|
||||
int eargc;
|
||||
char **eargv;
|
||||
char bittab[];
|
||||
union reptr **cmpend[DEPTH];
|
||||
int depth;
|
||||
union reptr *pending;
|
||||
char *badp;
|
||||
char bad;
|
||||
char compfl;
|
||||
|
||||
void fcomp(void);
|
||||
void dechain(void);
|
||||
int rline(char *lbuf);
|
||||
struct label *search(struct label *ptr);
|
||||
char *text(char *textbuf);
|
||||
char *compile(char *expbuf);
|
||||
char *compsub(char *rhsbuf);
|
||||
int cmp(char *a, char *b);
|
||||
char *ycomp(char *expbuf);
|
||||
|
||||
int main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
eargc = argc;
|
||||
@@ -45,7 +112,7 @@ char *argv[];
|
||||
fcode[0] = stdout;
|
||||
nfiles = 1;
|
||||
|
||||
if(eargc == 1)
|
||||
if (eargc == 1)
|
||||
exit(0);
|
||||
|
||||
|
||||
@@ -57,9 +124,9 @@ char *argv[];
|
||||
continue;
|
||||
|
||||
case 'f':
|
||||
if(eargc-- <= 0) exit(2);
|
||||
if (eargc-- <= 0) exit(2);
|
||||
|
||||
if((fin = fopen(*++eargv, "r")) == NULL) {
|
||||
if ((fin = fopen(*++eargv, "r")) == NULL) {
|
||||
fprintf(stderr, "Cannot open pattern-file: %s\n", *eargv);
|
||||
exit(2);
|
||||
}
|
||||
@@ -84,7 +151,7 @@ char *argv[];
|
||||
}
|
||||
|
||||
|
||||
if(compfl == 0) {
|
||||
if (compfl == 0) {
|
||||
eargv--;
|
||||
eargc++;
|
||||
eflag++;
|
||||
@@ -94,7 +161,7 @@ char *argv[];
|
||||
eflag = 0;
|
||||
}
|
||||
|
||||
if(depth) {
|
||||
if (depth) {
|
||||
fprintf(stderr, "Too many {'s");
|
||||
exit(2);
|
||||
}
|
||||
@@ -103,20 +170,20 @@ char *argv[];
|
||||
|
||||
dechain();
|
||||
|
||||
/* abort(); /*DEBUG*/
|
||||
/*abort();*/ /*DEBUG*/
|
||||
|
||||
if(eargc <= 0)
|
||||
if (eargc <= 0)
|
||||
execute((char *)NULL);
|
||||
else while(--eargc >= 0) {
|
||||
else while (--eargc >= 0) {
|
||||
execute(*eargv++);
|
||||
}
|
||||
fclose(stdout);
|
||||
exit(0);
|
||||
}
|
||||
fcomp()
|
||||
{
|
||||
|
||||
register char *p, *op, *tp;
|
||||
void fcomp()
|
||||
{
|
||||
char *p, *op, *tp;
|
||||
char *address();
|
||||
union reptr *pt, *pt1;
|
||||
int i;
|
||||
@@ -125,9 +192,9 @@ fcomp()
|
||||
compfl = 1;
|
||||
op = lastre;
|
||||
|
||||
if(rline(linebuf) < 0) return;
|
||||
if(*linebuf == '#') {
|
||||
if(linebuf[1] == 'n')
|
||||
if (rline(linebuf) < 0) return;
|
||||
if (*linebuf == '#') {
|
||||
if (linebuf[1] == 'n')
|
||||
nflag = 1;
|
||||
}
|
||||
else {
|
||||
@@ -135,50 +202,50 @@ fcomp()
|
||||
goto comploop;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
if(rline(linebuf) < 0) break;
|
||||
for (;;) {
|
||||
if (rline(linebuf) < 0) break;
|
||||
|
||||
cp = linebuf;
|
||||
|
||||
comploop:
|
||||
/* fprintf(stdout, "cp: %s\n", cp); /*DEBUG*/
|
||||
while(*cp == ' ' || *cp == '\t') cp++;
|
||||
if(*cp == '\0' || *cp == '#') continue;
|
||||
if(*cp == ';') {
|
||||
/*fprintf(stdout, "cp: %s\n", cp);*/ /*DEBUG*/
|
||||
while (*cp == ' ' || *cp == '\t') cp++;
|
||||
if (*cp == '\0' || *cp == '#') continue;
|
||||
if (*cp == ';') {
|
||||
cp++;
|
||||
goto comploop;
|
||||
}
|
||||
|
||||
p = address(rep->A.ad1);
|
||||
if(p == badp) {
|
||||
if (p == badp) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if(p == rep->A.ad1) {
|
||||
if(op)
|
||||
if (p == rep->A.ad1) {
|
||||
if (op)
|
||||
rep->A.ad1 = op;
|
||||
else {
|
||||
fprintf(stderr, "First RE may not be null\n");
|
||||
exit(2);
|
||||
}
|
||||
} else if(p == 0) {
|
||||
} else if (p == 0) {
|
||||
p = rep->A.ad1;
|
||||
rep->A.ad1 = 0;
|
||||
} else {
|
||||
op = rep->A.ad1;
|
||||
if(*cp == ',' || *cp == ';') {
|
||||
if (*cp == ',' || *cp == ';') {
|
||||
cp++;
|
||||
if((rep->A.ad2 = p) > reend) {
|
||||
if ((rep->A.ad2 = p) > reend) {
|
||||
fprintf(stderr, TMMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
p = address(rep->A.ad2);
|
||||
if(p == badp || p == 0) {
|
||||
if (p == badp || p == 0) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(p == rep->A.ad2)
|
||||
if (p == rep->A.ad2)
|
||||
rep->A.ad2 = op;
|
||||
else
|
||||
op = rep->A.ad2;
|
||||
@@ -187,15 +254,15 @@ comploop:
|
||||
rep->A.ad2 = 0;
|
||||
}
|
||||
|
||||
if(p > reend) {
|
||||
if (p > reend) {
|
||||
fprintf(stderr, "Too much text: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
while(*cp == ' ' || *cp == '\t') cp++;
|
||||
while (*cp == ' ' || *cp == '\t') cp++;
|
||||
|
||||
swit:
|
||||
switch(*cp++) {
|
||||
switch (*cp++) {
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized command: %s\n", linebuf);
|
||||
@@ -209,22 +276,22 @@ swit:
|
||||
rep->A.command = BCOM;
|
||||
rep->A.negfl = !(rep->A.negfl);
|
||||
cmpend[depth++] = &rep->B.lb1;
|
||||
if(++rep >= ptrend) {
|
||||
if (++rep >= ptrend) {
|
||||
fprintf(stderr, "Too many commands: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
rep->A.ad1 = p;
|
||||
if(*cp == '\0') continue;
|
||||
if (*cp == '\0') continue;
|
||||
|
||||
goto comploop;
|
||||
|
||||
case '}':
|
||||
if(rep->A.ad1) {
|
||||
if (rep->A.ad1) {
|
||||
fprintf(stderr, AD0MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if(--depth < 0) {
|
||||
if (--depth < 0) {
|
||||
fprintf(stderr, "Too many }'s\n");
|
||||
exit(2);
|
||||
}
|
||||
@@ -235,39 +302,39 @@ swit:
|
||||
|
||||
case '=':
|
||||
rep->A.command = EQCOM;
|
||||
if(rep->A.ad2) {
|
||||
if (rep->A.ad2) {
|
||||
fprintf(stderr, AD1MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if(rep->A.ad1) {
|
||||
if (rep->A.ad1) {
|
||||
fprintf(stderr, AD0MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
while(*cp++ == ' ');
|
||||
while (*cp++ == ' ');
|
||||
cp--;
|
||||
|
||||
|
||||
tp = lab->asc;
|
||||
while((*tp++ = *cp++))
|
||||
if(tp >= &(lab->asc[8])) {
|
||||
while ((*tp++ = *cp++))
|
||||
if (tp >= &(lab->asc[8])) {
|
||||
fprintf(stderr, LTL, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
*--tp = '\0';
|
||||
|
||||
if(lpt = search(lab)) {
|
||||
if(lpt->address) {
|
||||
if ((lpt = search(lab))) {
|
||||
if (lpt->address) {
|
||||
fprintf(stderr, "Duplicate labels: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
} else {
|
||||
lab->chain = 0;
|
||||
lpt = lab;
|
||||
if(++lab >= labend) {
|
||||
if (++lab >= labend) {
|
||||
fprintf(stderr, "Too many labels: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -279,12 +346,12 @@ swit:
|
||||
|
||||
case 'a':
|
||||
rep->A.command = ACOM;
|
||||
if(rep->A.ad2) {
|
||||
if (rep->A.ad2) {
|
||||
fprintf(stderr, AD1MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(*cp == '\\') cp++;
|
||||
if(*cp++ != '\n') {
|
||||
if (*cp == '\\') cp++;
|
||||
if (*cp++ != '\n') {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -293,8 +360,8 @@ swit:
|
||||
break;
|
||||
case 'c':
|
||||
rep->A.command = CCOM;
|
||||
if(*cp == '\\') cp++;
|
||||
if(*cp++ != ('\n')) {
|
||||
if (*cp == '\\') cp++;
|
||||
if (*cp++ != ('\n')) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -303,12 +370,12 @@ swit:
|
||||
break;
|
||||
case 'i':
|
||||
rep->A.command = ICOM;
|
||||
if(rep->A.ad2) {
|
||||
if (rep->A.ad2) {
|
||||
fprintf(stderr, AD1MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(*cp == '\\') cp++;
|
||||
if(*cp++ != ('\n')) {
|
||||
if (*cp == '\\') cp++;
|
||||
if (*cp++ != ('\n')) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -339,12 +406,12 @@ swit:
|
||||
case 'b':
|
||||
rep->A.command = BCOM;
|
||||
jtcommon:
|
||||
while(*cp++ == ' ');
|
||||
while (*cp++ == ' ');
|
||||
cp--;
|
||||
|
||||
if(*cp == '\0') {
|
||||
if(pt = labtab->chain) {
|
||||
while(pt1 = pt->B.lb1)
|
||||
if (*cp == '\0') {
|
||||
if ((pt = labtab->chain)) {
|
||||
while ((pt1 = pt->B.lb1))
|
||||
pt = pt1;
|
||||
pt->B.lb1 = rep;
|
||||
} else
|
||||
@@ -352,27 +419,27 @@ jtcommon:
|
||||
break;
|
||||
}
|
||||
tp = lab->asc;
|
||||
while((*tp++ = *cp++))
|
||||
if(tp >= &(lab->asc[8])) {
|
||||
while ((*tp++ = *cp++))
|
||||
if (tp >= &(lab->asc[8])) {
|
||||
fprintf(stderr, LTL, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
cp--;
|
||||
*--tp = '\0';
|
||||
|
||||
if(lpt = search(lab)) {
|
||||
if(lpt->address) {
|
||||
if ((lpt = search(lab))) {
|
||||
if (lpt->address) {
|
||||
rep->B.lb1 = lpt->address;
|
||||
} else {
|
||||
pt = lpt->chain;
|
||||
while(pt1 = pt->B.lb1)
|
||||
while ((pt1 = pt->B.lb1))
|
||||
pt = pt1;
|
||||
pt->B.lb1 = rep;
|
||||
}
|
||||
} else {
|
||||
lab->chain = rep;
|
||||
lab->address = 0;
|
||||
if(++lab >= labend) {
|
||||
if (++lab >= labend) {
|
||||
fprintf(stderr, "Too many labels: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -397,11 +464,11 @@ jtcommon:
|
||||
|
||||
case 'r':
|
||||
rep->A.command = RCOM;
|
||||
if(rep->A.ad2) {
|
||||
if (rep->A.ad2) {
|
||||
fprintf(stderr, AD1MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(*cp++ != ' ') {
|
||||
if (*cp++ != ' ') {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -420,7 +487,7 @@ jtcommon:
|
||||
|
||||
case 'q':
|
||||
rep->A.command = QCOM;
|
||||
if(rep->A.ad2) {
|
||||
if (rep->A.ad2) {
|
||||
fprintf(stderr, AD1MES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -435,12 +502,12 @@ jtcommon:
|
||||
seof = *cp++;
|
||||
rep->A.re1 = p;
|
||||
p = compile(rep->A.re1);
|
||||
if(p == badp) {
|
||||
if (p == badp) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(p == rep->A.re1) {
|
||||
if(op)
|
||||
if (p == rep->A.re1) {
|
||||
if (op)
|
||||
rep->A.re1 = op;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
@@ -451,49 +518,49 @@ jtcommon:
|
||||
op = rep->A.re1;
|
||||
}
|
||||
|
||||
if((rep->A.rhs = p) > reend) {
|
||||
if ((rep->A.rhs = p) > reend) {
|
||||
fprintf(stderr, TMMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if((p = compsub(rep->A.rhs)) == badp) {
|
||||
if ((p = compsub(rep->A.rhs)) == badp) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(*cp == 'g') {
|
||||
if (*cp == 'g') {
|
||||
cp++;
|
||||
rep->A.gfl++;
|
||||
} else if(gflag)
|
||||
} else if (gflag)
|
||||
rep->A.gfl++;
|
||||
|
||||
if(*cp == 'p') {
|
||||
if (*cp == 'p') {
|
||||
cp++;
|
||||
rep->A.pfl = 1;
|
||||
}
|
||||
|
||||
if(*cp == 'P') {
|
||||
if (*cp == 'P') {
|
||||
cp++;
|
||||
rep->A.pfl = 2;
|
||||
}
|
||||
|
||||
if(*cp == 'w') {
|
||||
if (*cp == 'w') {
|
||||
cp++;
|
||||
if(*cp++ != ' ') {
|
||||
if (*cp++ != ' ') {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(nfiles >= 10) {
|
||||
if (nfiles >= 10) {
|
||||
fprintf(stderr, "Too many files in w commands\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
text(fname[nfiles]);
|
||||
for(i = nfiles - 1; i >= 0; i--)
|
||||
if(cmp(fname[nfiles],fname[i]) == 0) {
|
||||
for (i = nfiles - 1; i >= 0; i--)
|
||||
if (cmp(fname[nfiles],fname[i]) == 0) {
|
||||
rep->A.fcode = fcode[i];
|
||||
goto done;
|
||||
}
|
||||
if((rep->A.fcode = fopen(fname[nfiles], "w")) == NULL) {
|
||||
if ((rep->A.fcode = fopen(fname[nfiles], "w")) == NULL) {
|
||||
fprintf(stderr, "cannot open %s\n", fname[nfiles]);
|
||||
exit(2);
|
||||
}
|
||||
@@ -503,23 +570,23 @@ jtcommon:
|
||||
|
||||
case 'w':
|
||||
rep->A.command = WCOM;
|
||||
if(*cp++ != ' ') {
|
||||
if (*cp++ != ' ') {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(nfiles >= 10){
|
||||
if (nfiles >= 10){
|
||||
fprintf(stderr, "Too many files in w commands\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
text(fname[nfiles]);
|
||||
for(i = nfiles - 1; i >= 0; i--)
|
||||
if(cmp(fname[nfiles], fname[i]) == 0) {
|
||||
for (i = nfiles - 1; i >= 0; i--)
|
||||
if (cmp(fname[nfiles], fname[i]) == 0) {
|
||||
rep->A.fcode = fcode[i];
|
||||
goto done;
|
||||
}
|
||||
|
||||
if((rep->A.fcode = fopen(fname[nfiles], "w")) == NULL) {
|
||||
if ((rep->A.fcode = fopen(fname[nfiles], "w")) == NULL) {
|
||||
fprintf(stderr, "Cannot create %s\n", fname[nfiles]);
|
||||
exit(2);
|
||||
}
|
||||
@@ -535,11 +602,11 @@ jtcommon:
|
||||
seof = *cp++;
|
||||
rep->A.re1 = p;
|
||||
p = ycomp(rep->A.re1);
|
||||
if(p == badp) {
|
||||
if (p == badp) {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
if(p > reend) {
|
||||
if (p > reend) {
|
||||
fprintf(stderr, TMMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -547,15 +614,15 @@ jtcommon:
|
||||
|
||||
}
|
||||
done:
|
||||
if(++rep >= ptrend) {
|
||||
if (++rep >= ptrend) {
|
||||
fprintf(stderr, "Too many commands, last: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
rep->A.ad1 = p;
|
||||
|
||||
if(*cp++ != '\0') {
|
||||
if(cp[-1] == ';')
|
||||
if (*cp++ != '\0') {
|
||||
if (cp[-1] == ';')
|
||||
goto comploop;
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
@@ -565,27 +632,28 @@ done:
|
||||
rep->A.command = 0;
|
||||
lastre = op;
|
||||
}
|
||||
char *compsub(rhsbuf)
|
||||
char *rhsbuf;
|
||||
|
||||
char *compsub(rhsbuf)
|
||||
char *rhsbuf;
|
||||
{
|
||||
register char *p, *q;
|
||||
char *p, *q;
|
||||
|
||||
p = rhsbuf;
|
||||
q = cp;
|
||||
for(;;) {
|
||||
if((*p = *q++) == '\\') {
|
||||
for (;;) {
|
||||
if ((*p = *q++) == '\\') {
|
||||
*p = *q++;
|
||||
if(*p > numbra + '0' && *p <= '9')
|
||||
if (*p > numbra + '0' && *p <= '9')
|
||||
return(badp);
|
||||
*p++ |= 0200;
|
||||
continue;
|
||||
}
|
||||
if(*p == seof) {
|
||||
if (*p == seof) {
|
||||
*p++ = '\0';
|
||||
cp = q;
|
||||
return(p);
|
||||
}
|
||||
if(*p++ == '\0') {
|
||||
if (*p++ == '\0') {
|
||||
return(badp);
|
||||
}
|
||||
|
||||
@@ -593,17 +661,17 @@ char *rhsbuf;
|
||||
}
|
||||
|
||||
char *compile(expbuf)
|
||||
char *expbuf;
|
||||
char *expbuf;
|
||||
{
|
||||
register c;
|
||||
register char *ep, *sp;
|
||||
int c;
|
||||
char *ep, *sp;
|
||||
char neg;
|
||||
char *lastep, *cstart;
|
||||
int cclcnt;
|
||||
int closed;
|
||||
char bracket[NBRA], *bracketp;
|
||||
|
||||
if(*cp == seof) {
|
||||
if (*cp == seof) {
|
||||
cp++;
|
||||
return(expbuf);
|
||||
}
|
||||
@@ -624,8 +692,8 @@ char *expbuf;
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
if((c = *sp++) == seof) {
|
||||
if(bracketp != bracket) {
|
||||
if ((c = *sp++) == seof) {
|
||||
if (bracketp != bracket) {
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
@@ -633,13 +701,13 @@ char *expbuf;
|
||||
*ep++ = CEOF;
|
||||
return(ep);
|
||||
}
|
||||
if(c != '*')
|
||||
if (c != '*')
|
||||
lastep = ep;
|
||||
switch (c) {
|
||||
|
||||
case '\\':
|
||||
if((c = *sp++) == '(') {
|
||||
if(numbra >= NBRA) {
|
||||
if ((c = *sp++) == '(') {
|
||||
if (numbra >= NBRA) {
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
@@ -648,8 +716,8 @@ char *expbuf;
|
||||
*ep++ = numbra++;
|
||||
continue;
|
||||
}
|
||||
if(c == ')') {
|
||||
if(bracketp <= bracket) {
|
||||
if (c == ')') {
|
||||
if (bracketp <= bracket) {
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
@@ -659,19 +727,19 @@ char *expbuf;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(c >= '1' && c <= '9') {
|
||||
if((c -= '1') >= closed)
|
||||
if (c >= '1' && c <= '9') {
|
||||
if ((c -= '1') >= closed)
|
||||
return(badp);
|
||||
|
||||
*ep++ = CBACK;
|
||||
*ep++ = c;
|
||||
continue;
|
||||
}
|
||||
if(c == '\n') {
|
||||
if (c == '\n') {
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
if(c == 'n') {
|
||||
if (c == 'n') {
|
||||
c = '\n';
|
||||
}
|
||||
goto defchar;
|
||||
@@ -689,7 +757,7 @@ char *expbuf;
|
||||
case '*':
|
||||
if (lastep == 0)
|
||||
goto defchar;
|
||||
if(*lastep == CKET) {
|
||||
if (*lastep == CKET) {
|
||||
cp = sp;
|
||||
return(badp);
|
||||
}
|
||||
@@ -703,7 +771,7 @@ char *expbuf;
|
||||
continue;
|
||||
|
||||
case '[':
|
||||
if(&ep[17] >= &expbuf[ESIZE]) {
|
||||
if (&ep[17] >= &expbuf[ESIZE]) {
|
||||
fprintf(stderr, "RE too long: %s\n", linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -711,14 +779,14 @@ char *expbuf;
|
||||
*ep++ = CCL;
|
||||
|
||||
neg = 0;
|
||||
if((c = *sp++) == '^') {
|
||||
if ((c = *sp++) == '^') {
|
||||
neg = 1;
|
||||
c = *sp++;
|
||||
}
|
||||
|
||||
cstart = sp;
|
||||
do {
|
||||
if(c == '\0') {
|
||||
if (c == '\0') {
|
||||
fprintf(stderr, CGMES, linebuf);
|
||||
exit(2);
|
||||
}
|
||||
@@ -726,8 +794,8 @@ char *expbuf;
|
||||
for (c = sp[-2]; c<*sp; c++)
|
||||
ep[c>>3] |= bittab[c&07];
|
||||
}
|
||||
if(c == '\\') {
|
||||
switch(c = *sp++) {
|
||||
if (c == '\\') {
|
||||
switch (c = *sp++) {
|
||||
case 'n':
|
||||
c = '\n';
|
||||
break;
|
||||
@@ -735,10 +803,10 @@ char *expbuf;
|
||||
}
|
||||
|
||||
ep[c >> 3] |= bittab[c & 07];
|
||||
} while((c = *sp++) != ']');
|
||||
} while ((c = *sp++) != ']');
|
||||
|
||||
if(neg)
|
||||
for(cclcnt = 0; cclcnt < 16; cclcnt++)
|
||||
if (neg)
|
||||
for (cclcnt = 0; cclcnt < 16; cclcnt++)
|
||||
ep[cclcnt] ^= -1;
|
||||
ep[0] &= 0376;
|
||||
|
||||
@@ -753,30 +821,31 @@ char *expbuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
rline(lbuf)
|
||||
char *lbuf;
|
||||
|
||||
int rline(lbuf)
|
||||
char *lbuf;
|
||||
{
|
||||
register char *p, *q;
|
||||
register t;
|
||||
char *p, *q;
|
||||
int t;
|
||||
static char *saveq;
|
||||
|
||||
p = lbuf - 1;
|
||||
|
||||
if(eflag) {
|
||||
if(eflag > 0) {
|
||||
if (eflag) {
|
||||
if (eflag > 0) {
|
||||
eflag = -1;
|
||||
if(eargc-- <= 0)
|
||||
if (eargc-- <= 0)
|
||||
exit(2);
|
||||
q = *++eargv;
|
||||
while(*++p = *q++) {
|
||||
if(*p == '\\') {
|
||||
if((*++p = *q++) == '\0') {
|
||||
while ((*++p = *q++)) {
|
||||
if (*p == '\\') {
|
||||
if ((*++p = *q++) == '\0') {
|
||||
saveq = 0;
|
||||
return(-1);
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
if(*p == '\n') {
|
||||
if (*p == '\n') {
|
||||
*p = '\0';
|
||||
saveq = q;
|
||||
return(1);
|
||||
@@ -785,17 +854,17 @@ char *lbuf;
|
||||
saveq = 0;
|
||||
return(1);
|
||||
}
|
||||
if((q = saveq) == 0) return(-1);
|
||||
if ((q = saveq) == 0) return(-1);
|
||||
|
||||
while(*++p = *q++) {
|
||||
if(*p == '\\') {
|
||||
if((*++p = *q++) == '0') {
|
||||
while ((*++p = *q++)) {
|
||||
if (*p == '\\') {
|
||||
if ((*++p = *q++) == '0') {
|
||||
saveq = 0;
|
||||
return(-1);
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
if(*p == '\n') {
|
||||
if (*p == '\n') {
|
||||
*p = '\0';
|
||||
saveq = q;
|
||||
return(1);
|
||||
@@ -805,13 +874,13 @@ char *lbuf;
|
||||
return(1);
|
||||
}
|
||||
|
||||
while((t = getc(fin)) != EOF) {
|
||||
while ((t = getc(fin)) != EOF) {
|
||||
*++p = t;
|
||||
if(*p == '\\') {
|
||||
if (*p == '\\') {
|
||||
t = getc(fin);
|
||||
*++p = t;
|
||||
}
|
||||
else if(*p == '\n') {
|
||||
else if (*p == '\n') {
|
||||
*p = '\0';
|
||||
return(1);
|
||||
}
|
||||
@@ -820,20 +889,20 @@ char *lbuf;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
char *address(expbuf)
|
||||
char *expbuf;
|
||||
char *address(expbuf)
|
||||
char *expbuf;
|
||||
{
|
||||
register char *rcp;
|
||||
char *rcp;
|
||||
long lno;
|
||||
|
||||
if(*cp == '$') {
|
||||
if (*cp == '$') {
|
||||
cp++;
|
||||
*expbuf++ = CEND;
|
||||
*expbuf++ = CEOF;
|
||||
return(expbuf);
|
||||
}
|
||||
|
||||
if(*cp == '/') {
|
||||
if (*cp == '/') {
|
||||
seof = '/';
|
||||
cp++;
|
||||
return(compile(expbuf));
|
||||
@@ -842,14 +911,14 @@ char *expbuf;
|
||||
rcp = cp;
|
||||
lno = 0;
|
||||
|
||||
while(*rcp >= '0' && *rcp <= '9')
|
||||
while (*rcp >= '0' && *rcp <= '9')
|
||||
lno = lno*10 + *rcp++ - '0';
|
||||
|
||||
if(rcp > cp) {
|
||||
if (rcp > cp) {
|
||||
*expbuf++ = CLNUM;
|
||||
*expbuf++ = nlno;
|
||||
tlno[nlno++] = lno;
|
||||
if(nlno >= NLINES) {
|
||||
if (nlno >= NLINES) {
|
||||
fprintf(stderr, "Too many line numbers\n");
|
||||
exit(2);
|
||||
}
|
||||
@@ -859,51 +928,51 @@ char *expbuf;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
cmp(a, b)
|
||||
char *a,*b;
|
||||
|
||||
int cmp(a, b)
|
||||
char *a,*b;
|
||||
{
|
||||
register char *ra, *rb;
|
||||
char *ra, *rb;
|
||||
|
||||
ra = a - 1;
|
||||
rb = b - 1;
|
||||
|
||||
while(*++ra == *++rb)
|
||||
if(*ra == '\0') return(0);
|
||||
while (*++ra == *++rb)
|
||||
if (*ra == '\0') return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
char *text(textbuf)
|
||||
char *textbuf;
|
||||
char *text(textbuf)
|
||||
char *textbuf;
|
||||
{
|
||||
register char *p, *q;
|
||||
char *p, *q;
|
||||
|
||||
p = textbuf;
|
||||
q = cp;
|
||||
while(*q == '\t' || *q == ' ') q++;
|
||||
for(;;) {
|
||||
while (*q == '\t' || *q == ' ') q++;
|
||||
for (;;) {
|
||||
|
||||
if((*p = *q++) == '\\')
|
||||
if ((*p = *q++) == '\\')
|
||||
*p = *q++;
|
||||
if(*p == '\0') {
|
||||
if (*p == '\0') {
|
||||
cp = --q;
|
||||
return(++p);
|
||||
}
|
||||
if(*p == '\n') {
|
||||
while(*q == '\t' || *q == ' ') q++;
|
||||
if (*p == '\n') {
|
||||
while (*q == '\t' || *q == ' ') q++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct label *search(ptr)
|
||||
struct label *ptr;
|
||||
struct label *search(ptr)
|
||||
struct label *ptr;
|
||||
{
|
||||
struct label *rp;
|
||||
|
||||
rp = labtab;
|
||||
while(rp < ptr) {
|
||||
if(cmp(rp->asc, ptr->asc) == 0)
|
||||
while (rp < ptr) {
|
||||
if (cmp(rp->asc, ptr->asc) == 0)
|
||||
return(rp);
|
||||
rp++;
|
||||
}
|
||||
@@ -911,22 +980,21 @@ struct label *ptr;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
dechain()
|
||||
void dechain()
|
||||
{
|
||||
struct label *lptr;
|
||||
union reptr *rptr, *trptr;
|
||||
|
||||
for(lptr = labtab; lptr < lab; lptr++) {
|
||||
for (lptr = labtab; lptr < lab; lptr++) {
|
||||
|
||||
if(lptr->address == 0) {
|
||||
if (lptr->address == 0) {
|
||||
fprintf(stderr, "Undefined label: %s\n", lptr->asc);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if(lptr->chain) {
|
||||
if (lptr->chain) {
|
||||
rptr = lptr->chain;
|
||||
while(trptr = rptr->B.lb1) {
|
||||
while ((trptr = rptr->B.lb1)) {
|
||||
rptr->B.lb1 = lptr->address;
|
||||
rptr = trptr;
|
||||
}
|
||||
@@ -936,39 +1004,39 @@ dechain()
|
||||
}
|
||||
|
||||
char *ycomp(expbuf)
|
||||
char *expbuf;
|
||||
char *expbuf;
|
||||
{
|
||||
register char c, *ep, *tsp;
|
||||
char c, *ep, *tsp;
|
||||
char *sp;
|
||||
|
||||
ep = expbuf;
|
||||
sp = cp;
|
||||
for(tsp = cp; *tsp != seof; tsp++) {
|
||||
if(*tsp == '\\')
|
||||
for (tsp = cp; *tsp != seof; tsp++) {
|
||||
if (*tsp == '\\')
|
||||
tsp++;
|
||||
if(*tsp == '\n')
|
||||
if (*tsp == '\n')
|
||||
return(badp);
|
||||
}
|
||||
tsp++;
|
||||
|
||||
while((c = *sp++ & 0177) != seof) {
|
||||
if(c == '\\' && *sp == 'n') {
|
||||
while ((c = *sp++ & 0177) != seof) {
|
||||
if (c == '\\' && *sp == 'n') {
|
||||
sp++;
|
||||
c = '\n';
|
||||
}
|
||||
if((ep[c] = *tsp++) == '\\' && *tsp == 'n') {
|
||||
if ((ep[c] = *tsp++) == '\\' && *tsp == 'n') {
|
||||
ep[c] = '\n';
|
||||
tsp++;
|
||||
}
|
||||
if(ep[c] == seof || ep[c] == '\0')
|
||||
if (ep[c] == seof || ep[c] == '\0')
|
||||
return(badp);
|
||||
}
|
||||
if(*tsp != seof)
|
||||
if (*tsp != seof)
|
||||
return(badp);
|
||||
cp = ++tsp;
|
||||
|
||||
for(c = 0; !(c & 0200); c++)
|
||||
if(ep[c] == 0)
|
||||
for (c = 0; !(c & 0200); c++)
|
||||
if (ep[c] == 0)
|
||||
ep[c] = c;
|
||||
|
||||
return(ep + 0200);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "sed.h"
|
||||
|
||||
char *trans[040] = {
|
||||
@@ -37,11 +39,20 @@ char *trans[040] = {
|
||||
};
|
||||
char rub[] = {"\177"};
|
||||
|
||||
execute(file)
|
||||
char *file;
|
||||
char *gline(char *addr);
|
||||
int match(char *expbuf, int gf);
|
||||
void command(union reptr *ipc);
|
||||
void arout(void);
|
||||
int advance(char *alp, char *aep);
|
||||
int ecmp(char *a, char *b, int count);
|
||||
void dosub(char *rhsbuf);
|
||||
char *place(char *asp, char *al1, char *al2);
|
||||
|
||||
void execute(file)
|
||||
char *file;
|
||||
{
|
||||
register char *p1, *p2;
|
||||
register union reptr *ipc;
|
||||
char *p1, *p2;
|
||||
union reptr *ipc;
|
||||
int c;
|
||||
char *execp;
|
||||
|
||||
@@ -55,86 +66,86 @@ char *file;
|
||||
ebp = ibuf;
|
||||
cbp = ibuf;
|
||||
|
||||
if(pending) {
|
||||
if (pending) {
|
||||
ipc = pending;
|
||||
pending = 0;
|
||||
goto yes;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
if((execp = gline(linebuf)) == badp) {
|
||||
for (;;) {
|
||||
if ((execp = gline(linebuf)) == badp) {
|
||||
close(f);
|
||||
return;
|
||||
}
|
||||
spend = execp;
|
||||
|
||||
for(ipc = ptrspace; ipc->A.command; ) {
|
||||
for (ipc = ptrspace; ipc->A.command; ) {
|
||||
|
||||
p1 = ipc->A.ad1;
|
||||
p2 = ipc->A.ad2;
|
||||
|
||||
if(p1) {
|
||||
if (p1) {
|
||||
|
||||
if(ipc->A.inar) {
|
||||
if(*p2 == CEND) {
|
||||
if (ipc->A.inar) {
|
||||
if (*p2 == CEND) {
|
||||
p1 = 0;
|
||||
} else if(*p2 == CLNUM) {
|
||||
} else if (*p2 == CLNUM) {
|
||||
c = p2[1];
|
||||
if(lnum > tlno[c]) {
|
||||
if (lnum > tlno[c]) {
|
||||
ipc->A.inar = 0;
|
||||
if(ipc->A.negfl)
|
||||
if (ipc->A.negfl)
|
||||
goto yes;
|
||||
ipc++;
|
||||
continue;
|
||||
}
|
||||
if(lnum == tlno[c]) {
|
||||
if (lnum == tlno[c]) {
|
||||
ipc->A.inar = 0;
|
||||
}
|
||||
} else if(match(p2, 0)) {
|
||||
} else if (match(p2, 0)) {
|
||||
ipc->A.inar = 0;
|
||||
}
|
||||
} else if(*p1 == CEND) {
|
||||
if(!dolflag) {
|
||||
if(ipc->A.negfl)
|
||||
} else if (*p1 == CEND) {
|
||||
if (!dolflag) {
|
||||
if (ipc->A.negfl)
|
||||
goto yes;
|
||||
ipc++;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if(*p1 == CLNUM) {
|
||||
} else if (*p1 == CLNUM) {
|
||||
c = p1[1];
|
||||
if(lnum != tlno[c]) {
|
||||
if(ipc->A.negfl)
|
||||
if (lnum != tlno[c]) {
|
||||
if (ipc->A.negfl)
|
||||
goto yes;
|
||||
ipc++;
|
||||
continue;
|
||||
}
|
||||
if(p2)
|
||||
if (p2)
|
||||
ipc->A.inar = 1;
|
||||
} else if(match(p1, 0)) {
|
||||
if(p2)
|
||||
} else if (match(p1, 0)) {
|
||||
if (p2)
|
||||
ipc->A.inar = 1;
|
||||
} else {
|
||||
if(ipc->A.negfl)
|
||||
if (ipc->A.negfl)
|
||||
goto yes;
|
||||
ipc++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(ipc->A.negfl) {
|
||||
if (ipc->A.negfl) {
|
||||
ipc++;
|
||||
continue;
|
||||
}
|
||||
yes:
|
||||
command(ipc);
|
||||
|
||||
if(delflag)
|
||||
if (delflag)
|
||||
break;
|
||||
|
||||
if(jflag) {
|
||||
if (jflag) {
|
||||
jflag = 0;
|
||||
if((ipc = ipc->B.lb1) == 0) {
|
||||
if ((ipc = ipc->B.lb1) == 0) {
|
||||
ipc = ptrspace;
|
||||
break;
|
||||
}
|
||||
@@ -142,13 +153,13 @@ char *file;
|
||||
ipc++;
|
||||
|
||||
}
|
||||
if(!nflag && !delflag) {
|
||||
for(p1 = linebuf; p1 < spend; p1++)
|
||||
if (!nflag && !delflag) {
|
||||
for (p1 = linebuf; p1 < spend; p1++)
|
||||
putc(*p1, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
|
||||
if(aptr > abuf) {
|
||||
if (aptr > abuf) {
|
||||
arout();
|
||||
}
|
||||
|
||||
@@ -156,16 +167,18 @@ char *file;
|
||||
|
||||
}
|
||||
}
|
||||
match(expbuf, gf)
|
||||
char *expbuf;
|
||||
{
|
||||
register char *p1, *p2, c;
|
||||
|
||||
if(gf) {
|
||||
if(*expbuf) return(0);
|
||||
int match(expbuf, gf)
|
||||
char *expbuf;
|
||||
{
|
||||
char *p1, *p2, c;
|
||||
|
||||
if (gf) {
|
||||
if (*expbuf)
|
||||
return(0);
|
||||
p1 = linebuf;
|
||||
p2 = genbuf;
|
||||
while(*p1++ = *p2++);
|
||||
while ((*p1++ = *p2++));
|
||||
locs = p1 = loc2;
|
||||
} else {
|
||||
p1 = linebuf;
|
||||
@@ -173,45 +186,46 @@ char *expbuf;
|
||||
}
|
||||
|
||||
p2 = expbuf;
|
||||
if(*p2++) {
|
||||
if (*p2++) {
|
||||
loc1 = p1;
|
||||
if(*p2 == CCHR && p2[1] != *p1)
|
||||
if (*p2 == CCHR && p2[1] != *p1)
|
||||
return(0);
|
||||
return(advance(p1, p2));
|
||||
}
|
||||
|
||||
/* fast check for first character */
|
||||
|
||||
if(*p2 == CCHR) {
|
||||
if (*p2 == CCHR) {
|
||||
c = p2[1];
|
||||
do {
|
||||
if(*p1 != c)
|
||||
if (*p1 != c)
|
||||
continue;
|
||||
if(advance(p1, p2)) {
|
||||
if (advance(p1, p2)) {
|
||||
loc1 = p1;
|
||||
return(1);
|
||||
}
|
||||
} while(*p1++);
|
||||
} while (*p1++);
|
||||
return(0);
|
||||
}
|
||||
|
||||
do {
|
||||
if(advance(p1, p2)) {
|
||||
if (advance(p1, p2)) {
|
||||
loc1 = p1;
|
||||
return(1);
|
||||
}
|
||||
} while(*p1++);
|
||||
} while (*p1++);
|
||||
return(0);
|
||||
}
|
||||
advance(alp, aep)
|
||||
char *alp, *aep;
|
||||
|
||||
int advance(alp, aep)
|
||||
char *alp, *aep;
|
||||
{
|
||||
register char *lp, *ep, *curlp;
|
||||
char *lp, *ep, *curlp;
|
||||
char c;
|
||||
char *bbeg;
|
||||
char *bbeg;
|
||||
int ct;
|
||||
|
||||
/*fprintf(stderr, "*lp = %c, %o\n*ep = %c, %o\n", *lp, *lp, *ep, *ep); /*DEBUG*/
|
||||
/*fprintf(stderr, "*lp = %c, %o\n*ep = %c, %o\n", *lp, *lp, *ep, *ep);*/ /*DEBUG*/
|
||||
|
||||
lp = alp;
|
||||
ep = aep;
|
||||
@@ -239,7 +253,7 @@ char *alp, *aep;
|
||||
|
||||
case CCL:
|
||||
c = *lp++ & 0177;
|
||||
if(ep[c>>3] & bittab[c & 07]) {
|
||||
if (ep[c>>3] & bittab[c & 07]) {
|
||||
ep += 16;
|
||||
continue;
|
||||
}
|
||||
@@ -257,7 +271,7 @@ char *alp, *aep;
|
||||
bbeg = braslist[*ep];
|
||||
ct = braelist[*ep++] - bbeg;
|
||||
|
||||
if(ecmp(bbeg, lp, ct)) {
|
||||
if (ecmp(bbeg, lp, ct)) {
|
||||
lp += ct;
|
||||
continue;
|
||||
}
|
||||
@@ -267,11 +281,11 @@ char *alp, *aep;
|
||||
bbeg = braslist[*ep];
|
||||
ct = braelist[*ep++] - bbeg;
|
||||
curlp = lp;
|
||||
while(ecmp(bbeg, lp, ct))
|
||||
while (ecmp(bbeg, lp, ct))
|
||||
lp += ct;
|
||||
|
||||
while(lp >= curlp) {
|
||||
if(advance(lp, ep)) return(1);
|
||||
while (lp >= curlp) {
|
||||
if (advance(lp, ep)) return(1);
|
||||
lp -= ct;
|
||||
}
|
||||
return(0);
|
||||
@@ -292,39 +306,39 @@ char *alp, *aep;
|
||||
curlp = lp;
|
||||
do {
|
||||
c = *lp++ & 0177;
|
||||
} while(ep[c>>3] & bittab[c & 07]);
|
||||
} while (ep[c>>3] & bittab[c & 07]);
|
||||
ep += 16;
|
||||
goto star;
|
||||
|
||||
star:
|
||||
if(--lp == curlp) {
|
||||
if (--lp == curlp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(*ep == CCHR) {
|
||||
if (*ep == CCHR) {
|
||||
c = ep[1];
|
||||
do {
|
||||
if(*lp != c)
|
||||
if (*lp != c)
|
||||
continue;
|
||||
if(advance(lp, ep))
|
||||
if (advance(lp, ep))
|
||||
return(1);
|
||||
} while(lp-- > curlp);
|
||||
} while (lp-- > curlp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(*ep == CBACK) {
|
||||
if (*ep == CBACK) {
|
||||
c = *(braslist[ep[1]]);
|
||||
do {
|
||||
if(*lp != c)
|
||||
if (*lp != c)
|
||||
continue;
|
||||
if(advance(lp, ep))
|
||||
if (advance(lp, ep))
|
||||
return(1);
|
||||
} while(lp-- > curlp);
|
||||
} while (lp-- > curlp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
do {
|
||||
if(lp == locs) break;
|
||||
if (lp == locs) break;
|
||||
if (advance(lp, ep))
|
||||
return(1);
|
||||
} while (lp-- > curlp);
|
||||
@@ -334,27 +348,28 @@ char *alp, *aep;
|
||||
fprintf(stderr, "RE botch, %o\n", *--ep);
|
||||
}
|
||||
}
|
||||
substitute(ipc)
|
||||
union reptr *ipc;
|
||||
|
||||
int substitute(ipc)
|
||||
union reptr *ipc;
|
||||
{
|
||||
if(match(ipc->A.re1, 0) == 0) return(0);
|
||||
if (match(ipc->A.re1, 0) == 0) return(0);
|
||||
|
||||
sflag = 1;
|
||||
dosub(ipc->A.rhs);
|
||||
|
||||
if(ipc->A.gfl) {
|
||||
while(*loc2) {
|
||||
if(match(ipc->A.re1, 1) == 0) break;
|
||||
if (ipc->A.gfl) {
|
||||
while (*loc2) {
|
||||
if (match(ipc->A.re1, 1) == 0) break;
|
||||
dosub(ipc->A.rhs);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
dosub(rhsbuf)
|
||||
char *rhsbuf;
|
||||
void dosub(rhsbuf)
|
||||
char *rhsbuf;
|
||||
{
|
||||
register char *lp, *sp, *rp;
|
||||
char *lp, *sp, *rp;
|
||||
int c;
|
||||
|
||||
lp = linebuf;
|
||||
@@ -362,7 +377,7 @@ char *rhsbuf;
|
||||
rp = rhsbuf;
|
||||
while (lp < loc1)
|
||||
*sp++ = *lp++;
|
||||
while(c = *rp++) {
|
||||
while ((c = *rp++)) {
|
||||
if (c == '&') {
|
||||
sp = place(sp, loc1, loc2);
|
||||
continue;
|
||||
@@ -376,19 +391,20 @@ char *rhsbuf;
|
||||
}
|
||||
lp = loc2;
|
||||
loc2 = sp - genbuf + linebuf;
|
||||
while (*sp++ = *lp++)
|
||||
while ((*sp++ = *lp++))
|
||||
if (sp >= &genbuf[LBSIZE]) {
|
||||
fprintf(stderr, "Output line too long.\n");
|
||||
}
|
||||
lp = linebuf;
|
||||
sp = genbuf;
|
||||
while (*lp++ = *sp++);
|
||||
while ((*lp++ = *sp++));
|
||||
spend = lp-1;
|
||||
}
|
||||
char *place(asp, al1, al2)
|
||||
char *asp, *al1, *al2;
|
||||
|
||||
char *place(asp, al1, al2)
|
||||
char *asp, *al1, *al2;
|
||||
{
|
||||
register char *sp, *l1, *l2;
|
||||
char *sp, *l1, *l2;
|
||||
|
||||
sp = asp;
|
||||
l1 = al1;
|
||||
@@ -401,19 +417,19 @@ char *asp, *al1, *al2;
|
||||
return(sp);
|
||||
}
|
||||
|
||||
command(ipc)
|
||||
union reptr *ipc;
|
||||
void command(ipc)
|
||||
union reptr *ipc;
|
||||
{
|
||||
register int i;
|
||||
register char *p1, *p2, *p3;
|
||||
int i;
|
||||
char *p1, *p2, *p3;
|
||||
char *execp;
|
||||
|
||||
|
||||
switch(ipc->A.command) {
|
||||
switch (ipc->A.command) {
|
||||
|
||||
case ACOM:
|
||||
*aptr++ = ipc;
|
||||
if(aptr >= &abuf[ABUFSIZE]) {
|
||||
if (aptr >= &abuf[ABUFSIZE]) {
|
||||
fprintf(stderr, "Too many appends after line %ld\n",
|
||||
lnum);
|
||||
}
|
||||
@@ -422,8 +438,8 @@ union reptr *ipc;
|
||||
|
||||
case CCOM:
|
||||
delflag = 1;
|
||||
if(!ipc->A.inar || dolflag) {
|
||||
for(p1 = ipc->A.re1; *p1; )
|
||||
if (!ipc->A.inar || dolflag) {
|
||||
for (p1 = ipc->A.re1; *p1; )
|
||||
putc(*p1++, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
@@ -434,15 +450,15 @@ union reptr *ipc;
|
||||
case CDCOM:
|
||||
p1 = p2 = linebuf;
|
||||
|
||||
while(*p1 != '\n') {
|
||||
if(*p1++ == 0) {
|
||||
while (*p1 != '\n') {
|
||||
if (*p1++ == 0) {
|
||||
delflag++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
p1++;
|
||||
while(*p2++ = *p1++);
|
||||
while ((*p2++ = *p1++));
|
||||
spend = p2-1;
|
||||
jflag++;
|
||||
break;
|
||||
@@ -454,7 +470,7 @@ union reptr *ipc;
|
||||
case GCOM:
|
||||
p1 = linebuf;
|
||||
p2 = holdsp;
|
||||
while(*p1++ = *p2++);
|
||||
while ((*p1++ = *p2++));
|
||||
spend = p1-1;
|
||||
break;
|
||||
|
||||
@@ -462,8 +478,8 @@ union reptr *ipc;
|
||||
*spend++ = '\n';
|
||||
p1 = spend;
|
||||
p2 = holdsp;
|
||||
while(*p1++ = *p2++)
|
||||
if(p1 >= lbend)
|
||||
while ((*p1++ = *p2++))
|
||||
if (p1 >= lbend)
|
||||
break;
|
||||
spend = p1-1;
|
||||
break;
|
||||
@@ -471,7 +487,7 @@ union reptr *ipc;
|
||||
case HCOM:
|
||||
p1 = holdsp;
|
||||
p2 = linebuf;
|
||||
while(*p1++ = *p2++);
|
||||
while ((*p1++ = *p2++));
|
||||
hspend = p1-1;
|
||||
break;
|
||||
|
||||
@@ -479,14 +495,14 @@ union reptr *ipc;
|
||||
*hspend++ = '\n';
|
||||
p1 = hspend;
|
||||
p2 = linebuf;
|
||||
while(*p1++ = *p2++)
|
||||
if(p1 >= hend)
|
||||
while ((*p1++ = *p2++))
|
||||
if (p1 >= hend)
|
||||
break;
|
||||
hspend = p1-1;
|
||||
break;
|
||||
|
||||
case ICOM:
|
||||
for(p1 = ipc->A.re1; *p1; )
|
||||
for (p1 = ipc->A.re1; *p1; )
|
||||
putc(*p1++, stdout);
|
||||
putc('\n', stdout);
|
||||
break;
|
||||
@@ -499,12 +515,12 @@ union reptr *ipc;
|
||||
p1 = linebuf;
|
||||
p2 = genbuf;
|
||||
genbuf[72] = 0;
|
||||
while(*p1)
|
||||
if(*p1 >= 040) {
|
||||
if(*p1 == 0177) {
|
||||
while (*p1)
|
||||
if (*p1 >= 040) {
|
||||
if (*p1 == 0177) {
|
||||
p3 = rub;
|
||||
while(*p2++ = *p3++)
|
||||
if(p2 >= lcomend) {
|
||||
while ((*p2++ = *p3++))
|
||||
if (p2 >= lcomend) {
|
||||
*p2 = '\\';
|
||||
fprintf(stdout, "%s\n", genbuf);
|
||||
p2 = genbuf;
|
||||
@@ -514,15 +530,15 @@ union reptr *ipc;
|
||||
continue;
|
||||
}
|
||||
*p2++ = *p1++;
|
||||
if(p2 >= lcomend) {
|
||||
if (p2 >= lcomend) {
|
||||
*p2 = '\\';
|
||||
fprintf(stdout, "%s\n", genbuf);
|
||||
p2 = genbuf;
|
||||
}
|
||||
} else {
|
||||
p3 = trans[*p1-1];
|
||||
while(*p2++ = *p3++)
|
||||
if(p2 >= lcomend) {
|
||||
while ((*p2++ = *p3++))
|
||||
if (p2 >= lcomend) {
|
||||
*p2 = '\\';
|
||||
fprintf(stdout, "%s\n", genbuf);
|
||||
p2 = genbuf;
|
||||
@@ -535,15 +551,15 @@ union reptr *ipc;
|
||||
break;
|
||||
|
||||
case NCOM:
|
||||
if(!nflag) {
|
||||
for(p1 = linebuf; p1 < spend; p1++)
|
||||
if (!nflag) {
|
||||
for (p1 = linebuf; p1 < spend; p1++)
|
||||
putc(*p1, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
|
||||
if(aptr > abuf)
|
||||
if (aptr > abuf)
|
||||
arout();
|
||||
if((execp = gline(linebuf)) == badp) {
|
||||
if ((execp = gline(linebuf)) == badp) {
|
||||
pending = ipc;
|
||||
delflag = 1;
|
||||
break;
|
||||
@@ -552,10 +568,10 @@ union reptr *ipc;
|
||||
|
||||
break;
|
||||
case CNCOM:
|
||||
if(aptr > abuf)
|
||||
if (aptr > abuf)
|
||||
arout();
|
||||
*spend++ = '\n';
|
||||
if((execp = gline(spend)) == badp) {
|
||||
if ((execp = gline(spend)) == badp) {
|
||||
pending = ipc;
|
||||
delflag = 1;
|
||||
break;
|
||||
@@ -564,30 +580,30 @@ union reptr *ipc;
|
||||
break;
|
||||
|
||||
case PCOM:
|
||||
for(p1 = linebuf; p1 < spend; p1++)
|
||||
for (p1 = linebuf; p1 < spend; p1++)
|
||||
putc(*p1, stdout);
|
||||
putc('\n', stdout);
|
||||
break;
|
||||
case CPCOM:
|
||||
cpcom:
|
||||
for(p1 = linebuf; *p1 != '\n' && *p1 != '\0'; )
|
||||
for (p1 = linebuf; *p1 != '\n' && *p1 != '\0'; )
|
||||
putc(*p1++, stdout);
|
||||
putc('\n', stdout);
|
||||
break;
|
||||
|
||||
case QCOM:
|
||||
if(!nflag) {
|
||||
for(p1 = linebuf; p1 < spend; p1++)
|
||||
if (!nflag) {
|
||||
for (p1 = linebuf; p1 < spend; p1++)
|
||||
putc(*p1, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
if(aptr > abuf) arout();
|
||||
if (aptr > abuf) arout();
|
||||
fclose(stdout);
|
||||
exit(0);
|
||||
case RCOM:
|
||||
|
||||
*aptr++ = ipc;
|
||||
if(aptr >= &abuf[ABUFSIZE])
|
||||
if (aptr >= &abuf[ABUFSIZE])
|
||||
fprintf(stderr, "Too many reads after line%ld\n",
|
||||
lnum);
|
||||
|
||||
@@ -597,20 +613,21 @@ union reptr *ipc;
|
||||
|
||||
case SCOM:
|
||||
i = substitute(ipc);
|
||||
if(ipc->A.pfl && i)
|
||||
if(ipc->A.pfl == 1) {
|
||||
for(p1 = linebuf; p1 < spend; p1++)
|
||||
if (ipc->A.pfl && i) {
|
||||
if (ipc->A.pfl == 1) {
|
||||
for (p1 = linebuf; p1 < spend; p1++)
|
||||
putc(*p1, stdout);
|
||||
putc('\n', stdout);
|
||||
}
|
||||
else
|
||||
goto cpcom;
|
||||
if(i && ipc->A.fcode)
|
||||
}
|
||||
if (i && ipc->A.fcode)
|
||||
goto wcom;
|
||||
break;
|
||||
|
||||
case TCOM:
|
||||
if(sflag == 0) break;
|
||||
if (sflag == 0) break;
|
||||
sflag = 0;
|
||||
jflag = 1;
|
||||
break;
|
||||
@@ -623,32 +640,32 @@ union reptr *ipc;
|
||||
case XCOM:
|
||||
p1 = linebuf;
|
||||
p2 = genbuf;
|
||||
while(*p2++ = *p1++);
|
||||
while ((*p2++ = *p1++));
|
||||
p1 = holdsp;
|
||||
p2 = linebuf;
|
||||
while(*p2++ = *p1++);
|
||||
while ((*p2++ = *p1++));
|
||||
spend = p2 - 1;
|
||||
p1 = genbuf;
|
||||
p2 = holdsp;
|
||||
while(*p2++ = *p1++);
|
||||
while ((*p2++ = *p1++));
|
||||
hspend = p2 - 1;
|
||||
break;
|
||||
|
||||
case YCOM:
|
||||
p1 = linebuf;
|
||||
p2 = ipc->A.re1;
|
||||
while(*p1 = p2[*p1]) p1++;
|
||||
while ((*p1 = p2[*p1]))
|
||||
p1++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
char *
|
||||
gline(addr)
|
||||
char *addr;
|
||||
char *gline(addr)
|
||||
char *addr;
|
||||
{
|
||||
register char *p1, *p2;
|
||||
register c;
|
||||
char *p1, *p2;
|
||||
int c;
|
||||
p1 = addr;
|
||||
p2 = cbp;
|
||||
for (;;) {
|
||||
@@ -660,10 +677,10 @@ char *addr;
|
||||
ebp = ibuf+c;
|
||||
}
|
||||
if ((c = *p2++) == '\n') {
|
||||
if(p2 >= ebp) {
|
||||
if((c = read(f, ibuf, BUFSIZ)) <= 0) {
|
||||
if (p2 >= ebp) {
|
||||
if ((c = read(f, ibuf, BUFSIZ)) <= 0) {
|
||||
close(f);
|
||||
if(eargc == 0)
|
||||
if (eargc == 0)
|
||||
dolflag = 1;
|
||||
}
|
||||
|
||||
@@ -672,8 +689,8 @@ char *addr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(c)
|
||||
if(p1 < lbend)
|
||||
if (c)
|
||||
if (p1 < lbend)
|
||||
*p1++ = c;
|
||||
}
|
||||
lnum++;
|
||||
@@ -682,31 +699,32 @@ char *addr;
|
||||
|
||||
return(p1);
|
||||
}
|
||||
ecmp(a, b, count)
|
||||
char *a, *b;
|
||||
|
||||
int ecmp(a, b, count)
|
||||
char *a, *b;
|
||||
{
|
||||
while(count--)
|
||||
if(*a++ != *b++) return(0);
|
||||
while (count--)
|
||||
if (*a++ != *b++) return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
arout()
|
||||
void arout()
|
||||
{
|
||||
register char *p1;
|
||||
char *p1;
|
||||
FILE *fi;
|
||||
char c;
|
||||
int t;
|
||||
|
||||
aptr = abuf - 1;
|
||||
while(*++aptr) {
|
||||
if((*aptr)->A.command == ACOM) {
|
||||
for(p1 = (*aptr)->A.re1; *p1; )
|
||||
while (*++aptr) {
|
||||
if ((*aptr)->A.command == ACOM) {
|
||||
for (p1 = (*aptr)->A.re1; *p1; )
|
||||
putc(*p1++, stdout);
|
||||
putc('\n', stdout);
|
||||
} else {
|
||||
if((fi = fopen((*aptr)->A.re1, "r")) == NULL)
|
||||
if ((fi = fopen((*aptr)->A.re1, "r")) == NULL)
|
||||
continue;
|
||||
while((t = getc(fi)) != EOF) {
|
||||
while ((t = getc(fi)) != EOF) {
|
||||
c = t;
|
||||
putc(c, stdout);
|
||||
}
|
||||
|
||||
@@ -54,12 +54,13 @@ alloc(nbytes)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
addblok(reqd)
|
||||
unsigned reqd;
|
||||
{
|
||||
if (stakbot == NIL)
|
||||
{
|
||||
extern end;
|
||||
extern int end;
|
||||
brkbegin = setbrk(BRKINCR * 5);
|
||||
bloktop = (struct blk *) &end;
|
||||
}
|
||||
@@ -94,6 +95,7 @@ addblok(reqd)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free(ap)
|
||||
struct blk *ap;
|
||||
{
|
||||
@@ -109,9 +111,8 @@ free(ap)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
void
|
||||
chkbptr(ptr)
|
||||
struct blk *ptr;
|
||||
{
|
||||
@@ -147,7 +148,7 @@ chkbptr(ptr)
|
||||
abort(1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chkmem()
|
||||
{
|
||||
register struct blk *p = (struct blk *)brkbegin;
|
||||
@@ -182,6 +183,5 @@ chkmem()
|
||||
blank();
|
||||
prn((char *)bloktop - brkbegin - (un + us));
|
||||
newline();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -93,36 +93,14 @@
|
||||
#include "name.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* error catching */
|
||||
extern int errno;
|
||||
|
||||
/* result type declarations */
|
||||
|
||||
#define free afree
|
||||
extern char *allat();
|
||||
extern char *make();
|
||||
extern char *alloc();
|
||||
extern char *movstr();
|
||||
extern char *movstrn();
|
||||
extern struct trenod *cmd();
|
||||
extern struct trenod *makefork();
|
||||
extern struct namnod *lookup();
|
||||
extern struct namnod *findnam();
|
||||
extern struct dolnod *useargs();
|
||||
extern float expr();
|
||||
extern char *catpath();
|
||||
extern char *getpath();
|
||||
extern char *nextpath();
|
||||
extern char **scan();
|
||||
extern char *mactrim();
|
||||
extern char *macro();
|
||||
extern int exname();
|
||||
extern int printnam();
|
||||
extern int printro();
|
||||
extern int printexp();
|
||||
extern char **setenvv();
|
||||
extern long time();
|
||||
#define free afree
|
||||
|
||||
#define attrib(n,f) (n->namflg |= f)
|
||||
#define round(a,b) (((int)(((char *)(a)+b)-1))&~((b)-1))
|
||||
@@ -272,8 +250,6 @@ extern unsigned brkincr;
|
||||
#define SIGMOD 8
|
||||
#define SIGCAUGHT 16
|
||||
|
||||
extern void done();
|
||||
extern void fault();
|
||||
extern BOOL trapnote;
|
||||
extern char *trapcom[];
|
||||
extern BOOL trapflg[];
|
||||
@@ -340,7 +316,7 @@ extern char badop[];
|
||||
#include "ctype.h"
|
||||
|
||||
extern int wasintr; /* used to tell if break or delete is hit
|
||||
* while executing a wait */
|
||||
* while executing a wait */
|
||||
extern int eflag;
|
||||
|
||||
|
||||
@@ -356,3 +332,10 @@ extern int eflag;
|
||||
#define exitset() retval = exitval
|
||||
|
||||
#define ENDPATH 27 /* see msg.c/defpath */
|
||||
|
||||
void addblok(unsigned reqd);
|
||||
char *movstr(char *a, char *b);
|
||||
char *setbrk(int incr);
|
||||
void error(char *s);
|
||||
void free(struct blk *ap);
|
||||
void rmtemp(struct ionod *base);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "defs.h"
|
||||
|
||||
/* ======== error handling ======== */
|
||||
|
||||
void
|
||||
failed(s1, s2)
|
||||
char *s1, *s2;
|
||||
{
|
||||
@@ -21,12 +21,14 @@ char *s1, *s2;
|
||||
exitsh(ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
error(s)
|
||||
char *s;
|
||||
{
|
||||
failed(s, NIL);
|
||||
}
|
||||
|
||||
void
|
||||
exitsh(xno)
|
||||
int xno;
|
||||
{
|
||||
@@ -75,6 +77,7 @@ done()
|
||||
exit(exitval);
|
||||
}
|
||||
|
||||
void
|
||||
rmtemp(base)
|
||||
struct ionod *base;
|
||||
{
|
||||
@@ -86,6 +89,7 @@ struct ionod *base;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rmfunctmp()
|
||||
{
|
||||
while (fiotemp)
|
||||
|
||||
@@ -5,12 +5,9 @@
|
||||
*/
|
||||
#include "defs.h"
|
||||
|
||||
char *sbrk();
|
||||
|
||||
char*
|
||||
setbrk(incr)
|
||||
{
|
||||
|
||||
register char *a = sbrk(incr);
|
||||
|
||||
brkend = a + incr;
|
||||
|
||||
@@ -29,7 +29,7 @@ locstak()
|
||||
{
|
||||
if (brkend - stakbot < BRKINCR)
|
||||
{
|
||||
if (setbrk(brkincr) == -1)
|
||||
if (setbrk(brkincr) == (char*)-1)
|
||||
error(nostack);
|
||||
if (brkincr < BRKMAX)
|
||||
brkincr += 256;
|
||||
@@ -56,6 +56,7 @@ register char *argp;
|
||||
return(oldstak);
|
||||
}
|
||||
|
||||
void
|
||||
tdystak(x) /* try to bring stack back to x */
|
||||
register char *x;
|
||||
{
|
||||
@@ -65,9 +66,10 @@ register char *x;
|
||||
stakbsy = stakbsy->word;
|
||||
}
|
||||
staktop = stakbot = max((char *)(x), (char *)(stakbas));
|
||||
rmtemp(x);
|
||||
rmtemp((struct ionod *)x);
|
||||
}
|
||||
|
||||
void
|
||||
stakchk()
|
||||
{
|
||||
if ((brkend - stakbas) > BRKINCR + BRKINCR)
|
||||
|
||||
Reference in New Issue
Block a user