|
|
1.1 root 1: #include <stdio.h>
2: #include "sed.h"
3:
4: struct label *labtab = ltab;
5: char CGMES[] = "sed: Command garbled: %s\n";
6: char TMMES[] = "sed: Too much text: %s\n";
7: char LTL[] = "sed: Label too long: %s\n";
8: char AD0MES[] = "sed: No addresses allowed: %s\n";
9: char AD1MES[] = "sed: Only one address allowed: %s\n";
10: uchar bittab[] = {
11: 1,
12: 2,
13: 4,
14: 8,
15: 16,
16: 32,
17: 64,
18: 128
19: };
20:
21: main(argc, argv)
22: uchar *argv[];
23: {
24:
25: eargc = argc;
26: eargv = argv;
27:
28: badp = &bad;
29: aptr = abuf;
30: hspend = holdsp;
31: lab = labtab + 1; /* 0 reserved for end-pointer */
32: rep = ptrspace;
33: rep->r1.ad1 = respace;
34: lbend = &linebuf[LBSIZE];
35: hend = &holdsp[LBSIZE];
36: lcomend = &genbuf[64];
37: ptrend = &ptrspace[PTRSIZE];
38: reend = &respace[RESIZE];
39: labend = &labtab[LABSIZE];
40: lnum = 0;
41: pending = 0;
42: depth = 0;
43: spend = linebuf;
44: hspend = holdsp;
45: fcode[0] = stdout;
46: nfiles = 1;
47: lastre = NULL;
48:
49: if(eargc == 1)
50: exit(0);
51:
52:
53: while (--eargc > 0 && (++eargv)[0][0] == '-')
54: switch (eargv[0][1]) {
55:
56: case 'n':
57: nflag++;
58: continue;
59:
60: case 'f':
61: if(eargc-- <= 0) exit(2);
62:
63: if((fin = fopen(*++eargv, "r")) == NULL) {
64: fprintf(stderr, "sed: Cannot open pattern-file: %s\n", *eargv);
65: exit(2);
66: }
67:
68: fcomp();
69: fclose(fin);
70: continue;
71:
72: case 'e':
73: eflag++;
74: fcomp();
75: eflag = 0;
76: continue;
77:
78: case 'g':
79: gflag++;
80: continue;
81:
82: default:
83: fprintf(stderr, "sed: Unknown flag: %c\n", eargv[0][1]);
84: continue;
85: }
86:
87:
88: if(compfl == 0) {
89: eargv--;
90: eargc++;
91: eflag++;
92: fcomp();
93: eargv++;
94: eargc--;
95: eflag = 0;
96: }
97:
98: if(depth) {
99: fprintf(stderr, "sed: Too many {'s\n");
100: exit(2);
101: }
102:
103: labtab->address = rep;
104:
105: dechain();
106:
107: /* abort(); /*DEBUG*/
108:
109: if(eargc <= 0)
110: execute((uchar *)NULL);
111: else while(--eargc >= 0) {
112: execute(*eargv++);
113: }
114: fclose(stdout);
115: exit(0);
116: }
117: fcomp()
118: {
119:
120: register uchar *p, *op, *tp;
121: uchar *address();
122: union reptr *pt, *pt1;
123: int i;
124: struct label *lpt;
125:
126: compfl = 1;
127: op = lastre;
128:
129: if(rline(linebuf) < 0) {
130: lastre = op;
131: return;
132: }
133: if(*linebuf == '#') {
134: if(linebuf[1] == 'n')
135: nflag = 1;
136: }
137: else {
138: cp = linebuf;
139: goto comploop;
140: }
141:
142: for(;;) {
143: if(rline(linebuf) < 0) break;
144:
145: cp = linebuf;
146:
147: comploop:
148: /* fprintf(stdout, "cp: %s\n", cp); /*DEBUG*/
149: while(*cp == ' ' || *cp == '\t') cp++;
150: if(*cp == '\0' || *cp == '#') continue;
151: if(*cp == ';') {
152: cp++;
153: goto comploop;
154: }
155:
156: p = address(rep->r1.ad1);
157: if(p == badp) {
158: fprintf(stderr, CGMES, linebuf);
159: exit(2);
160: }
161:
162: if(p == 0) {
163: p = rep->r1.ad1;
164: rep->r1.ad1 = 0;
165: } else {
166: if(p == rep->r1.ad1) {
167: if(op)
168: rep->r1.ad1 = op;
169: else {
170: fprintf(stderr, "sed: First RE may not be null\n");
171: exit(2);
172: }
173: }
174: if(*rep->r1.ad1 != CLNUM && *rep->r1.ad1 != CEND)
175: op = rep->r1.ad1;
176: if(*cp == ',' || *cp == ';') {
177: cp++;
178: if((rep->r1.ad2 = p) > reend) {
179: fprintf(stderr, TMMES, linebuf);
180: exit(2);
181: }
182: p = address(rep->r1.ad2);
183: if(p == badp || p == 0) {
184: fprintf(stderr, CGMES, linebuf);
185: exit(2);
186: }
187: if(p == rep->r1.ad2)
188: rep->r1.ad2 = op;
189: else{
190: if(*rep->r1.ad2 != CLNUM && *rep->r1.ad2 != CEND)
191: op = rep->r1.ad2;
192: }
193:
194: } else
195: rep->r1.ad2 = 0;
196: }
197:
198: if(p > reend) {
199: fprintf(stderr, "sed: Too much text: %s\n", linebuf);
200: exit(2);
201: }
202:
203: while(*cp == ' ' || *cp == '\t') cp++;
204:
205: swit:
206: switch(*cp++) {
207:
208: default:
209: /*fprintf(stderr, "cp = %d; *cp = %o\n", cp - linebuf, *cp);*/
210: fprintf(stderr, "sed: Unrecognized command: %s\n", linebuf);
211: exit(2);
212:
213: case '!':
214: rep->r1.negfl = 1;
215: goto swit;
216:
217: case '{':
218: rep->r1.command = BCOM;
219: rep->r1.negfl = !(rep->r1.negfl);
220: cmpend[depth++] = &rep->r2.lb1;
221: if(++rep >= ptrend) {
222: fprintf(stderr, "sed: Too many commands: %s\n", linebuf);
223: exit(2);
224: }
225: rep->r1.ad1 = p;
226: if(*cp == '\0') continue;
227:
228: goto comploop;
229:
230: case '}':
231: if(rep->r1.ad1) {
232: fprintf(stderr, AD0MES, linebuf);
233: exit(2);
234: }
235:
236: if(--depth < 0) {
237: fprintf(stderr, "sed: Too many }'s\n");
238: exit(2);
239: }
240: *cmpend[depth] = rep;
241:
242: rep->r1.ad1 = p;
243: if(*cp == 0) continue;
244: goto comploop;
245:
246: case '=':
247: rep->r1.command = EQCOM;
248: if(rep->r1.ad2) {
249: fprintf(stderr, AD1MES, linebuf);
250: exit(2);
251: }
252: break;
253:
254: case ':':
255: if(rep->r1.ad1) {
256: fprintf(stderr, AD0MES, linebuf);
257: exit(2);
258: }
259:
260: while(*cp++ == ' ');
261: cp--;
262:
263:
264: tp = lab->asc;
265: while((*tp = *cp++) && *tp != ';')
266: if(++tp >= &(lab->asc[8])) {
267: fprintf(stderr, LTL, linebuf);
268: exit(2);
269: }
270: *tp = '\0';
271: if(*lab->asc == 0) {
272: fprintf(stderr, CGMES, linebuf);
273: exit(2);
274: }
275:
276: if(lpt = search(lab)) {
277: if(lpt->address) {
278: fprintf(stderr, "sed: Duplicate labels: %s\n", linebuf);
279: exit(2);
280: }
281: } else {
282: lab->chain = 0;
283: lpt = lab;
284: if(++lab >= labend) {
285: fprintf(stderr, "sed: Too many labels: %s\n", linebuf);
286: exit(2);
287: }
288: }
289: lpt->address = rep;
290: rep->r1.ad1 = p;
291:
292: continue;
293:
294: case 'a':
295: rep->r1.command = ACOM;
296: if(rep->r1.ad2) {
297: fprintf(stderr, AD1MES, linebuf);
298: exit(2);
299: }
300: if(*cp == '\\') cp++;
301: if(*cp++ != '\n') {
302: fprintf(stderr, CGMES, linebuf);
303: exit(2);
304: }
305: rep->r1.re1 = p;
306: p = text(rep->r1.re1);
307: break;
308: case 'c':
309: rep->r1.command = CCOM;
310: if(*cp == '\\') cp++;
311: if(*cp++ != ('\n')) {
312: fprintf(stderr, CGMES, linebuf);
313: exit(2);
314: }
315: rep->r1.re1 = p;
316: p = text(rep->r1.re1);
317: break;
318: case 'i':
319: rep->r1.command = ICOM;
320: if(rep->r1.ad2) {
321: fprintf(stderr, AD1MES, linebuf);
322: exit(2);
323: }
324: if(*cp == '\\') cp++;
325: if(*cp++ != ('\n')) {
326: fprintf(stderr, CGMES, linebuf);
327: exit(2);
328: }
329: rep->r1.re1 = p;
330: p = text(rep->r1.re1);
331: break;
332:
333: case 'g':
334: rep->r1.command = GCOM;
335: break;
336:
337: case 'G':
338: rep->r1.command = CGCOM;
339: break;
340:
341: case 'h':
342: rep->r1.command = HCOM;
343: break;
344:
345: case 'H':
346: rep->r1.command = CHCOM;
347: break;
348:
349: case 't':
350: rep->r1.command = TCOM;
351: goto jtcommon;
352:
353: case 'b':
354: rep->r1.command = BCOM;
355: jtcommon:
356: while(*cp++ == ' ');
357: cp--;
358:
359: if(*cp == '\0') {
360: if(pt = labtab->chain) {
361: while(pt1 = pt->r2.lb1)
362: pt = pt1;
363: pt->r2.lb1 = rep;
364: } else
365: labtab->chain = rep;
366: break;
367: }
368: tp = lab->asc;
369: while((*tp = *cp++) && *tp != ';')
370: if(++tp >= &(lab->asc[8])) {
371: fprintf(stderr, LTL, linebuf);
372: exit(2);
373: }
374: cp--;
375: *tp = '\0';
376: if(*lab->asc == 0) {
377: fprintf(stderr, CGMES, linebuf);
378: exit(2);
379: }
380:
381: if(lpt = search(lab)) {
382: if(lpt->address) {
383: rep->r2.lb1 = lpt->address;
384: } else {
385: pt = lpt->chain;
386: while(pt1 = pt->r2.lb1)
387: pt = pt1;
388: pt->r2.lb1 = rep;
389: }
390: } else {
391: lab->chain = rep;
392: lab->address = 0;
393: if(++lab >= labend) {
394: fprintf(stderr, "sed: Too many labels: %s\n", linebuf);
395: exit(2);
396: }
397: }
398: break;
399:
400: case 'n':
401: rep->r1.command = NCOM;
402: break;
403:
404: case 'N':
405: rep->r1.command = CNCOM;
406: break;
407:
408: case 'p':
409: rep->r1.command = PCOM;
410: break;
411:
412: case 'P':
413: rep->r1.command = CPCOM;
414: break;
415:
416: case 'r':
417: rep->r1.command = RCOM;
418: if(rep->r1.ad2) {
419: fprintf(stderr, AD1MES, linebuf);
420: exit(2);
421: }
422: if(*cp++ != ' ') {
423: fprintf(stderr, CGMES, linebuf);
424: exit(2);
425: }
426: rep->r1.re1 = p;
427: p = text(rep->r1.re1);
428: break;
429:
430: case 'd':
431: rep->r1.command = DCOM;
432: break;
433:
434: case 'D':
435: rep->r1.command = CDCOM;
436: rep->r2.lb1 = ptrspace;
437: break;
438:
439: case 'q':
440: rep->r1.command = QCOM;
441: if(rep->r1.ad2) {
442: fprintf(stderr, AD1MES, linebuf);
443: exit(2);
444: }
445: break;
446:
447: case 'l':
448: rep->r1.command = LCOM;
449: break;
450:
451: case 's':
452: rep->r1.command = SCOM;
453: seof = *cp++;
454: rep->r1.re1 = p;
455: p = compile(rep->r1.re1);
456: if(p == badp) {
457: fprintf(stderr, CGMES, linebuf);
458: exit(2);
459: }
460: if(p == rep->r1.re1) {
461: if(op == NULL) {
462: fprintf(stderr, "sed: First RE may not be null.\n");
463: exit(2);
464: }
465: rep->r1.re1 = op;
466: } else {
467: op = rep->r1.re1;
468: }
469:
470: if((rep->r1.rhs = p) > reend) {
471: fprintf(stderr, TMMES, linebuf);
472: exit(2);
473: }
474:
475: if((p = compsub(rep->r1.rhs)) == badp) {
476: fprintf(stderr, CGMES, linebuf);
477: exit(2);
478: }
479: if(*cp == 'g') {
480: cp++;
481: rep->r1.gfl++;
482: } else if(gflag)
483: rep->r1.gfl++;
484:
485: if(*cp == 'p') {
486: cp++;
487: rep->r1.pfl = 1;
488: }
489:
490: if(*cp == 'P') {
491: cp++;
492: rep->r1.pfl = 2;
493: }
494:
495: if(*cp == 'w') {
496: cp++;
497: if(*cp++ != ' ') {
498: fprintf(stderr, CGMES, linebuf);
499: exit(2);
500: }
501: if(nfiles >= MAXFILES) {
502: fprintf(stderr, "sed: Too many files in w commands 1 \n");
503: exit(2);
504: }
505:
506: text(fname[nfiles]);
507: for(i = nfiles - 1; i >= 0; i--)
508: if(cmp(fname[nfiles],fname[i]) == 0) {
509: rep->r1.fcode = fcode[i];
510: goto done;
511: }
512: if((rep->r1.fcode = fopen(fname[nfiles], "w")) == NULL) {
513: fprintf(stderr, "sed: Cannot open %s\n", fname[nfiles]);
514: exit(2);
515: }
516: fcode[nfiles++] = rep->r1.fcode;
517: }
518: break;
519:
520: case 'w':
521: rep->r1.command = WCOM;
522: if(*cp++ != ' ') {
523: fprintf(stderr, CGMES, linebuf);
524: exit(2);
525: }
526: if(nfiles >= MAXFILES){
527: fprintf(stderr, "sed: Too many files in w commands 2 \n");
528: fprintf(stderr, "nfiles = %d; MAXF = %d\n", nfiles, MAXFILES);
529: exit(2);
530: }
531:
532: text(fname[nfiles]);
533: for(i = nfiles - 1; i >= 0; i--)
534: if(cmp(fname[nfiles], fname[i]) == 0) {
535: rep->r1.fcode = fcode[i];
536: goto done;
537: }
538:
539: if((rep->r1.fcode = fopen(fname[nfiles], "w")) == NULL) {
540: fprintf(stderr, "sed: Cannot create %s\n", fname[nfiles]);
541: exit(2);
542: }
543: fcode[nfiles++] = rep->r1.fcode;
544: break;
545:
546: case 'x':
547: rep->r1.command = XCOM;
548: break;
549:
550: case 'y':
551: rep->r1.command = YCOM;
552: seof = *cp++;
553: rep->r1.re1 = p;
554: p = ycomp(rep->r1.re1);
555: if(p == badp) {
556: fprintf(stderr, CGMES, linebuf);
557: exit(2);
558: }
559: if(p > reend) {
560: fprintf(stderr, TMMES, linebuf);
561: exit(2);
562: }
563: break;
564:
565: }
566: done:
567: if(++rep >= ptrend) {
568: fprintf(stderr, "sed: Too many commands, last: %s\n", linebuf);
569: exit(2);
570: }
571:
572: rep->r1.ad1 = p;
573:
574: if(*cp++ != '\0') {
575: if(cp[-1] == ';')
576: goto comploop;
577: fprintf(stderr, CGMES, linebuf);
578: exit(2);
579: }
580:
581: }
582: }
583:
584: uchar *
585: compsub(rhsbuf)
586: uchar *rhsbuf;
587: {
588: register uchar *p, *q, *r;
589: p = rhsbuf;
590: q = cp;
591: for(;;) {
592: if((*p = *q++) == '\\') {
593: *++p = *q++;
594: if(*p >= '1' && *p <= '9' && *p > numbra + '0')
595: return(badp);
596: if(*p == 'n')
597: *--p = '\n';
598: } else if(*p == seof) {
599: *p++ = '\0';
600: cp = q;
601: return(p);
602: }
603: if(*p++ == '\0') {
604: return(badp);
605: }
606:
607: }
608: }
609:
610: uchar *
611: compile(expbuf)
612: uchar *expbuf;
613: {
614: register c;
615: register uchar *ep, *sp;
616: uchar neg;
617: uchar *lastep, *cstart;
618: int cclcnt;
619: int closed;
620: uchar bracket[NBRA], *bracketp;
621:
622: if(*cp == seof) {
623: cp++;
624: return(expbuf);
625: }
626:
627: ep = expbuf;
628: lastep = 0;
629: bracketp = bracket;
630: closed = numbra = 0;
631: sp = cp;
632: if (*sp == '^') {
633: *ep++ = 1;
634: sp++;
635: } else {
636: *ep++ = 0;
637: }
638: for (;;) {
639: if (ep >= reend) {
640: cp = sp;
641: return(badp);
642: }
643: if((c = *sp++) == seof) {
644: if(bracketp != bracket) {
645: cp = sp;
646: return(badp);
647: }
648: cp = sp;
649: *ep++ = CEOF;
650: return(ep);
651: }
652: if(c != '*')
653: lastep = ep;
654: switch (c) {
655:
656: case '\\':
657: if((c = *sp++) == '(') {
658: if(numbra >= NBRA) {
659: cp = sp;
660: return(badp);
661: }
662: *bracketp++ = numbra;
663: *ep++ = CBRA;
664: *ep++ = numbra++;
665: continue;
666: }
667: if(c == ')') {
668: if(bracketp <= bracket) {
669: cp = sp;
670: return(badp);
671: }
672: *ep++ = CKET;
673: *ep++ = *--bracketp;
674: closed++;
675: continue;
676: }
677:
678: if(c >= '1' && c <= '9') {
679: if((c -= '1') >= closed)
680: return(badp);
681:
682: *ep++ = CBACK;
683: *ep++ = c;
684: continue;
685: }
686: if(c == '\n') {
687: cp = sp;
688: return(badp);
689: }
690: if(c == 'n') {
691: c = '\n';
692: }
693: goto defchar;
694:
695: case '\0':
696: case '\n':
697: cp = sp;
698: return(badp);
699:
700: case '.':
701: *ep++ = CDOT;
702: continue;
703:
704: case '*':
705: if (lastep == 0)
706: goto defchar;
707: if(*lastep == CKET) {
708: cp = sp;
709: return(badp);
710: }
711: *lastep |= STAR;
712: continue;
713:
714: case '$':
715: if (*sp != seof)
716: goto defchar;
717: *ep++ = CDOL;
718: continue;
719:
720: case '[':
721: if(&ep[33] >= reend) {
722: fprintf(stderr, "sed: RE too long: %s\n", linebuf);
723: exit(2);
724: }
725:
726: *ep++ = CCL;
727:
728: neg = 0;
729: if((c = *sp++) == '^') {
730: neg = 1;
731: c = *sp++;
732: }
733:
734: cstart = sp;
735: do {
736: if(c == '\0') {
737: fprintf(stderr, CGMES, linebuf);
738: exit(2);
739: }
740: if (c=='-' && sp>cstart && *sp!=']') {
741: for (c = sp[-2]; c<*sp; c++)
742: ep[c>>3] |= bittab[c&07];
743: }
744: if(c == '\\') {
745: switch(c = *sp++) {
746: case 'n':
747: c = '\n';
748: break;
749: }
750: }
751:
752: ep[c >> 3] |= bittab[c & 07];
753: } while((c = *sp++) != ']');
754:
755: if(neg)
756: for(cclcnt = 0; cclcnt < 32; cclcnt++)
757: ep[cclcnt] ^= -1;
758: ep[0] &= 0376;
759:
760: ep += 32;
761:
762: continue;
763:
764: defchar:
765: default:
766: *ep++ = CCHR;
767: *ep++ = c;
768: }
769: }
770: }
771: rline(lbuf)
772: uchar *lbuf;
773: {
774: register uchar *p, *q;
775: register t;
776: static uchar *saveq;
777:
778: p = lbuf - 1;
779:
780: if(eflag) {
781: if(eflag > 0) {
782: eflag = -1;
783: if(eargc-- <= 0)
784: exit(2);
785: q = *++eargv;
786: while(*++p = *q++) {
787: if(*p == '\\') {
788: if((*++p = *q++) == '\0') {
789: saveq = 0;
790: return(-1);
791: } else
792: continue;
793: }
794: if(*p == '\n') {
795: *p = '\0';
796: saveq = q;
797: return(1);
798: }
799: }
800: saveq = 0;
801: return(1);
802: }
803: if((q = saveq) == 0) return(-1);
804:
805: while(*++p = *q++) {
806: if(*p == '\\') {
807: if((*++p = *q++) == '0') {
808: saveq = 0;
809: return(-1);
810: } else
811: continue;
812: }
813: if(*p == '\n') {
814: *p = '\0';
815: saveq = q;
816: return(1);
817: }
818: }
819: saveq = 0;
820: return(1);
821: }
822:
823: while((t = getc(fin)) != EOF) {
824: *++p = t;
825: if(*p == '\\') {
826: t = getc(fin);
827: *++p = t;
828: }
829: else if(*p == '\n') {
830: *p = '\0';
831: return(1);
832: }
833: }
834: *++p = '\0';
835: return(-1);
836: }
837:
838: uchar *address(expbuf)
839: uchar *expbuf;
840: {
841: register uchar *rcp;
842: long lno;
843:
844: if(*cp == '$') {
845: cp++;
846: *expbuf++ = CEND;
847: *expbuf++ = CEOF;
848: return(expbuf);
849: }
850:
851: if(*cp == '/') {
852: seof = '/';
853: cp++;
854: return(compile(expbuf));
855: }
856:
857: rcp = cp;
858: lno = 0;
859:
860: while(*rcp >= '0' && *rcp <= '9')
861: lno = lno*10 + *rcp++ - '0';
862:
863: if(rcp > cp) {
864: if(!lno){
865: fprintf(stderr, "sed: line number 0 is illegal\n");
866: exit(2);
867: }
868: *expbuf++ = CLNUM;
869: *expbuf++ = lno;
870: *expbuf++ = lno >> 8;
871: *expbuf++ = lno >> 16;
872: *expbuf++ = lno >> 24;
873: *expbuf++ = CEOF;
874: cp = rcp;
875: return(expbuf);
876: }
877: return(0);
878: }
879: cmp(a, b)
880: uchar *a,*b;
881: {
882: register uchar *ra, *rb;
883:
884: ra = a - 1;
885: rb = b - 1;
886:
887: while(*++ra == *++rb)
888: if(*ra == '\0') return(0);
889: return(1);
890: }
891:
892: uchar *text(textbuf)
893: uchar *textbuf;
894: {
895: register uchar *p, *q;
896:
897: p = textbuf;
898: q = cp;
899: while(*q == '\t' || *q == ' ') q++;
900: for(;;) {
901:
902: if((*p = *q++) == '\\')
903: *p = *q++;
904: if(*p == '\0') {
905: cp = --q;
906: return(++p);
907: }
908: if(*p == '\n') {
909: while(*q == '\t' || *q == ' ') q++;
910: }
911: p++;
912: }
913: }
914:
915:
916: struct label *search(ptr)
917: struct label *ptr;
918: {
919: struct label *rp;
920:
921: rp = labtab;
922: while(rp < ptr) {
923: if(cmp(rp->asc, ptr->asc) == 0)
924: return(rp);
925: rp++;
926: }
927:
928: return(0);
929: }
930:
931:
932: dechain()
933: {
934: struct label *lptr;
935: union reptr *rptr, *trptr;
936:
937: for(lptr = labtab; lptr < lab; lptr++) {
938:
939: if(lptr->address == 0) {
940: fprintf(stderr, "sed: Undefined label: %s\n", lptr->asc);
941: exit(2);
942: }
943:
944: if(lptr->chain) {
945: rptr = lptr->chain;
946: while(trptr = rptr->r2.lb1) {
947: rptr->r2.lb1 = lptr->address;
948: rptr = trptr;
949: }
950: rptr->r2.lb1 = lptr->address;
951: }
952: }
953: }
954:
955: uchar *ycomp(expbuf)
956: uchar *expbuf;
957: {
958: register uchar *ep, *tsp;
959: register c;
960: uchar *sp;
961:
962: ep = expbuf;
963: sp = cp;
964: for(tsp = cp; *tsp != seof; tsp++) {
965: if(*tsp == '\\')
966: tsp++;
967: if(*tsp == '\n' || *tsp == '\0')
968: return(badp);
969: }
970: tsp++;
971:
972: while((c = *sp++) != seof) {
973: if(c == '\\' && *sp == 'n') {
974: sp++;
975: c = '\n';
976: }
977: if((ep[c] = *tsp++) == '\\' && *tsp == 'n') {
978: ep[c] = '\n';
979: tsp++;
980: }
981: if(ep[c] == seof || ep[c] == '\0')
982: return(badp);
983: }
984: if(*tsp != seof)
985: return(badp);
986: cp = ++tsp;
987:
988: for(c = 0; c<0400; c++)
989: if(ep[c] == 0)
990: ep[c] = c;
991:
992: return(ep + 0400);
993: }
994:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.