vm: include no-caching bits in PTF_ALLFLAGS for flags sanity check.
[minix.git] / commands / awk.old / y.c
blob6b5d8933de8c7f94df34c4af9b77ccfd0b97f103
1 /*
2 * a small awk clone
4 * (C) 1989 Saeko Hirabauashi & Kouichi Hirabayashi
6 * Absolutely no warranty. Use this software with your own risk.
8 * Permission to use, copy, modify and distribute this software for any
9 * purpose and without fee is hereby granted, provided that the above
10 * copyright and disclaimer notice.
12 * This program was written to fit into 64K+64K memory of the Minix 1.2.
16 #include <stdio.h>
17 #include "awk.h"
19 extern char *mkpat();
21 extern char *cmd;
22 extern char text[];
23 extern char funnam[];
24 extern int sym;
25 extern int sym1;
26 extern int regexflg;
27 extern int funflg;
28 extern int printflg;
29 extern int getlineflg;
31 extern SYMBOL *hashtab[], *funtab[];
33 extern CELL *field[];
35 char *emalloc(), *strsave();
36 NODE *node0(), *node1(), *node2(), *node3(), *node4();
37 NODE *stat(), *pastat();
38 NODE *expr(), *expr1(), *expr2(), *expr3(), *expr4();
39 NODE *expr5(), *expr6(), *expr7(), *expr8(), *expr9(), *expr10();
40 NODE *doprint(), *dofuncn(), *doif(), *dowhile(), *dofor(), *body();
41 NODE *doassign(), *dodo(), *doarray(), *doreturn(), *doelement();
42 CELL *mkcell(), *getvar();
43 CELL *execute(), *lookup();
45 int forflg; /* parsing for(expr in array), inhibit 'expr in array' */
46 int prmflg; /* parsing pass parameters */
47 NODE *begin, *loop, *End;
49 parse()
51 NODE *p, *q, *r, *stat();
52 CELL *u;
54 lex();
55 skipeol();
56 while (sym) {
57 switch (sym) {
58 case BEGIN:
59 lex();
60 begin = stat();
61 break;
62 case END:
63 lex();
64 if (End == NULL)
65 End = stat();
66 else {
67 for (p = End; p; p = q) {
68 if ((q = p->n_next) == NULL)
69 p->n_next = stat();
72 break;
73 case FUNC:
74 lex();
75 dousrfun();
76 break;
77 default:
78 q = loop = pastat();
79 skipeol();
80 while (sym && sym != BEGIN && sym != END && sym != FUNC) {
81 r = pastat();
82 q->n_next = r;
83 q = r;
84 skipeol();
86 break;
88 skipeol();
90 if (begin) {
91 u = execute(begin);
92 c_free(u);
94 if (End || loop)
95 while (Getrec(NULL)) {
96 if (loop) {
97 u = execute(loop);
98 c_free(u);
101 if (End) {
102 u = execute(End);
103 c_free(u);
107 #define MAXARG 100
108 static char *argnam[MAXARG];
109 static int narg;
111 static
112 dousrfun()
114 CELL *u;
116 strcpy(funnam, text);
117 u = getvar(text, funtab, FUN);
118 lex();
119 if (sym != '(')
120 synerr("'(' expected");
121 for (lex(); sym != ')'; narg++) {
122 if (sym != IDENT)
123 synerr("argument expected");
124 argnam[narg] = strsave(text);
125 lex();
126 if (sym == ',')
127 lex();
129 u->c_fval = (double) narg;
130 lex();
131 skipeol();
132 funflg++;
133 u->c_sval = (char *) stat();
134 funflg--;
135 if (narg > 0) {
136 do {
137 sfree(argnam[--narg]);
138 } while (narg > 0);
140 skipeol();
143 isarg(s) char *s;
145 int i;
147 if (narg > 0) {
148 for (i = narg - 1; i >= 0; i--)
149 if (strcmp(s, argnam[i]) == 0)
150 break;
152 else
153 i = -1;
154 return i;
158 interactive()
160 NODE *p, *q;
161 CELL *u;
163 for (lex(); sym; lex()) {
164 p = stat();
165 if (p->n_type != PRINT && !iscntl(p->n_type)) {
166 q = (NODE *) emalloc(sizeof(NODE) + sizeof(NODE *) * 4);
167 q->n_type = PRINT;
168 q->n_arg[0] = q->n_arg[1] = q->n_arg[3] = NULL;
169 q->n_arg[2] = p;
170 q->n_next = NULL;
171 p = q;
173 u = execute(p);
174 printf("[%g(%s)]\n", u->c_fval, u->c_sval);
175 c_free(u);
177 closeall();
178 exit(0);
182 static
183 iscntl(t)
185 static int tab[] = {
186 IF, DO, WHILE, FOR, JUMP, GETLINE, 0
188 int i;
190 for (i = 0; tab[i]; i++)
191 if (t == tab[i])
192 break;
193 return tab[i];
196 static NODE *
197 pastat()
199 NODE *p, *q, *r;
201 if (sym == '{') /* action only */
202 p = stat();
203 else { /* exp [, expr] [{ .. }] */
204 p = expr();
205 if (sym == ',') {
206 lex();
207 q = expr();
209 else
210 q = NULL;
211 if (sym && sym != EOL)
212 r = stat();
213 else
214 r = node0(PRINT0);
215 if (q)
216 p = node3(P2STAT, p, q, r);
217 else
218 p = node2(P1STAT, p, r);
220 return p;
223 static NODE *
224 stat()
226 NODE *p, *q, *r;
227 CELL *u, *v;
228 int op;
230 /*printf("@stat(%d)(%s)\n", sym, text);*/
231 while (sym == EOL)
232 lex();
233 switch(sym) {
234 case PRINT:
235 p = doprint(0);
236 break;
237 case PRINTF:
238 p = doprint(FORMAT);
239 break;
240 case IF:
241 p = doif();
242 break;
243 case WHILE:
244 p = dowhile();
245 break;
246 case DO:
247 p = dodo();
248 break;
249 case FOR:
250 p = dofor();
251 break;
252 case RETURN:
253 p = doreturn();
254 break;
255 case EXIT:
256 p = node2(JUMP, (NODE *)sym, (NODE *)NULL);
257 lex();
258 if (sym == IDENT || sym == NUMBER || sym == ARG)
259 p->n_arg[1] = expr();
260 break;
261 case BREAK: case CONTIN: case NEXT:
262 p = node1(JUMP, (NODE *)sym);
263 lex();
264 break;
265 case DELETE:
266 lex();
267 u = getvar(text, hashtab, ARR);
268 if (!isarrayindex())
269 synerr("'[' expected");
270 p = doarray(u);
271 p->n_type = DELETE;
272 lex(); /* ']' */
273 break;
274 case '{':
275 lex();
276 skipeol();
277 if (sym == '}')
278 p = node0(NULPROC);
279 else
280 p = q = stat();
281 skipeol();
282 while (sym != '}') {
283 r = stat();
284 q->n_next = r;
285 q = r;
286 skipeol();
288 lex();
289 break;
290 default:
291 p = expr();
292 #if 0
293 if (sym == BINOR) { /* expr | GETLINE */
294 lex();
295 if (sym != GETLINE)
296 synerr("'GETLINE' expected");
297 lex();
298 if (sym == IDENT || sym == STRING || sym == ARG) {
299 q = expr();
301 else
302 q = NULL;
303 p = node3(GETLINE, q, p, (NODE *)R_PIN);
305 #endif
306 break;
308 if (p->n_type == VALUE)
309 synerr("statement expected");
310 return p;
313 static
314 skipeol()
316 while (sym == EOL)
317 lex();
320 static NODE *
321 doprint(fmt)
323 NODE *p, *q, *r;
324 CELL *u;
325 int i, op;
326 int n = 0;
328 printflg++;
329 lex();
330 if (sym == '(')
331 lex();
332 if (sym != '}' && sym != ')' && sym != EOL && sym != R_OUT && sym != R_APD
333 && sym != R_POUT) {
334 p = q = expr(); n++;
335 while (sym == ',') {
336 lex();
337 skipeol();
338 r = expr(); n++;
339 q->n_next = r;
340 q = r;
343 if (sym == ')')
344 lex();
345 if (sym == R_OUT || sym == R_APD || sym == R_POUT) {
346 op = sym;
347 lex();
348 /* q = expr10();*/
349 q = expr(); /* 94-04-02 */
351 else
352 q = (NODE *) (op = 0); /* stdout */
353 printflg = 0;
354 r = (NODE *) emalloc(sizeof(*r) + sizeof(r) * (n + 3));
355 r->n_type = PRINT; /* convert list to arg */
356 r->n_next = NULL;
357 r->n_arg[0] = (NODE *) (op | fmt);
358 r->n_arg[1] = q;
359 if (n == 0) {
360 p = node1(VALUE, (NODE *)field[0]);
362 for (i = 2; p != NULL; i++) {
363 r->n_arg[i] = p;
364 q = p->n_next;
365 p->n_next = NULL;
366 p = q;
368 r->n_arg[i] = NULL;
369 return r;
372 static NODE *
373 doif()
375 NODE *p, *q, *r;
377 lex();
378 if (sym != '(')
379 synerr("'(' expected");
380 lex();
381 p = expr();
382 if (sym != ')')
383 synerr("')' expected");
384 lex();
385 skipeol();
386 q = stat();
387 skipeol();
388 if (sym == ELSE) {
389 lex();
390 skipeol();
391 r = stat();
393 else
394 r = NULL;
395 return node3(IF, p, q, r);
398 static NODE *
399 dowhile()
401 NODE *p, *q;
403 lex();
404 if (sym != '(')
405 synerr("'(' expected");
406 lex();
407 p = stat();
408 if (sym != ')')
409 synerr("')' expected");
410 q = body();
411 return node2(WHILE, p, q);
414 static NODE *
415 dofor()
417 NODE *p, *q, *r, *s;
418 CELL *u;
419 int i;
421 lex();
422 if (sym != '(')
423 synerr("'(' expected");
424 lex();
425 if (sym != EOL) {
426 forflg++; /* inhibit parsing 'expr IN array' */
427 p = expr();
428 forflg = 0;
430 else
431 p = NULL;
432 if (sym == IN) {
433 lex();
434 if (sym == ARG) {
436 printf("***FOR_IN_ARG(%d)***\n", sym);
438 u = mkcell(POS, NULL, (double)sym1);
439 q = node1(ARG, u);
441 else {
442 u = getvar(text, hashtab, ARR);
443 q = node1(VALUE, u);
445 lex();
446 if (sym != ')')
447 synerr("')' expected");
448 lex();
449 skipeol();
450 s = stat();
451 r = node3(FORIN, p, q, s);
453 else {
454 if (sym != EOL)
455 synerr("'in' or ';' expected");
456 lex();
457 if (sym != EOL)
458 q = expr();
459 else
460 q = NULL;
461 if (sym != EOL)
462 synerr("';' expected");
463 lex();
464 if (sym != ')')
465 r = expr();
466 else
467 r = NULL;
468 if (sym != ')')
469 synerr("')' expected");
470 s = body();
471 r = node4(FOR, p, q, r, s);
473 return r;
476 static NODE *
477 body()
479 NODE *r;
481 while ((sym = Getc()) == '\n' || sym == ' ' || sym == '\t')
483 if (sym == ';') {
484 r = node0(NULPROC);
485 lex();
487 else {
488 Ungetc(sym);
489 lex();
490 r = stat();
492 return r;
495 static NODE *
496 dodo()
498 NODE *p, *q;
500 lex();
501 skipeol();
502 p = stat();
503 skipeol();
504 if (sym != WHILE)
505 synerr("'while' expected");
506 lex();
507 if (sym != '(')
508 synerr("'(' expected");
509 lex();
510 q = stat();
511 if (sym != ')')
512 synerr("')' expected");
513 lex();
514 return node2(DO, p, q);
517 static NODE *
518 doreturn()
520 NODE *p, *q, *r;
521 int i, n = 0;
523 if (lex() != EOL) {
524 p = q = expr(); n++;
525 while (sym == ',') {
526 lex(); skipeol();
527 r = expr(); n++;
528 q ->n_next = r;
529 q = r;
532 else
533 p = (NODE *)NULL;
535 r = (NODE *) emalloc(sizeof(*r) + sizeof (r) * (n + 1));
536 r->n_type = JUMP;
537 r->n_next = NULL;
538 r->n_arg[0] = (NODE *) RETURN;
539 for (i = 1; p != NULL; i++) {
540 r->n_arg[i] = p;
541 q = p->n_next;
542 p->n_next = NULL;
543 p = q;
545 r->n_arg[i] = NULL;
546 return r;
549 static NODE *
550 expr()
552 NODE *p;
554 p = expr1();
555 if (isassign(sym))
556 p = doassign(sym, p);
557 return p;
560 static isassign(sym)
562 return (sym == ASSIGN || sym == ADDEQ || sym == SUBEQ || sym == MULTEQ
563 || sym == DIVEQ || sym == MODEQ || sym == POWEQ);
566 static NODE *
567 doassign(op, p) NODE *p;
568 { /* evaluate right to left */
569 NODE *q;
571 lex();
572 q = expr();
573 if (isassign(sym))
574 q = doassign(sym, q);
575 return node3(ASSIGN, (NODE *)op, p, q);
578 static NODE *
579 expr1()
581 NODE *p, *q;
584 printf("expr1(%d)(%s)\n", sym, text);
586 p = expr2();
587 if (sym == '?') {
588 lex();
589 #if 0
590 q = stat();
591 if (sym != ':')
592 synerr("':' expected");
593 lex();
594 return node3(IF, p, q, stat());
595 #else
596 q = expr();
597 if (sym != ':')
598 synerr("':' expected");
599 lex();
600 return node3(IF, p, q, expr());
601 #endif
603 return p; /* 930213 */
606 static NODE *
607 expr2()
609 NODE *p;
612 printf("expr2(%d)(%s)\n", sym, text);
614 p = expr3();
615 while (sym == OR) {
616 lex();
617 skipeol();
618 p = node3(COND, (NODE *)OR, p, expr3());
620 return p;
623 static NODE *
624 expr3()
626 NODE *p;
629 printf("expr3(%d)(%s)\n", sym, text);
631 p = expr4();
632 while (sym == AND) {
633 lex();
634 skipeol();
635 p = node3(COND, (NODE *)AND, p, expr4());
637 return p;
640 static NODE *
641 expr4()
643 NODE *p;
644 CELL *q;
645 int op;
648 printf("expr4(%d)(%s)\n", sym, text);
650 p = expr5();
651 if (!forflg && sym == IN) {
652 lex();
653 q = getvar(text, hashtab, ARR);
654 lex();
655 return node2(IN, p, q);
657 while (sym == EQ || sym == NE || sym == LT || sym == LE || sym == GT
658 || sym == GE || sym == MATCH || sym == NOMATCH) {
659 op = sym;
660 lex();
661 p = node3(COND, (NODE *)op, p, expr5());
663 return p;
666 static NODE *
667 expr5()
669 NODE *p, *q;
672 printf("expr5(%d)(%s)\n", sym, text);
674 p = expr6();
675 while (iscat(sym)) {
676 q = expr6();
677 p = node2(CAT, p, q);
679 return p;
682 static iscat(sym)
684 static int ctab[] = {
685 ADD, SUB, MULT, DIV, MOD, INC, DEC, STRING, NUMBER, IDENT, '(',
686 MATHFUN, STRFUN, SPRINTF, '$', SUBST, ARG, CALL, 0
688 register int i, j;
690 for (i = 0; j = ctab[i]; i++)
691 if (sym == j)
692 break;
693 return j;
696 static NODE *
697 expr6()
699 register int sign = sym;
700 NODE *p, *q;
703 printf("expr6(%d)(%s)\n", sym, text);
705 if (sym == SUB || sym == ADD)
706 lex();
707 p = expr7();
708 if (sign == SUB)
709 p = node2(ARITH, (NODE *)UMINUS, p);
710 while (sym == ADD || sym == SUB) {
711 sign = sym;
712 lex();
713 q = expr7();
714 if (sign == ADD) {
715 p = node3(ARITH, (NODE *)ADD, p, q);
717 else if (sign == SUB) {
718 p = node3(ARITH, (NODE *)SUB, p, q);
720 else
721 synerr("'+' or '-' expected");
723 return p;
726 static NODE *
727 expr7()
729 register int op;
730 NODE *p, *q;
733 printf("expr7(%d)(%s)\n", sym, text);
735 p = expr8();
736 while (sym == MULT || sym == DIV || sym == MOD) {
737 op = sym;
738 lex();
739 q = expr8();
740 switch (op) {
741 case MULT: p = node3(ARITH, (NODE *)MULT, p, q); break;
742 case DIV: p = node3(ARITH, (NODE *)DIV, p, q); break;
743 case MOD: p = node3(ARITH, (NODE *)MOD, p, q); break;
744 default: synerr("'*', '/' or '%' expected"); break;
747 return p;
750 static NODE *
751 expr8()
753 NODE *p;
754 int op;
757 printf("expr8(%d)(%s)\n", sym, text);
759 if (sym == NOT) {
760 lex();
761 p = node2(COND, (NODE *)NOT, expr9());
763 else {
764 p = expr9();
765 if (sym == POWER) {
766 lex();
767 p = node3(ARITH, (NODE *)POWER, p, expr9());
770 return p;
773 static NODE *
774 expr9()
776 NODE *p, *q;
777 int op, sym0;
780 printf("expr9(%d)(%s)\n", sym, text);
782 if (op = isincdec(sym)) {
783 lex();
784 if (sym != IDENT && sym != ARG)
785 synerr("illegal '++/--' operator");
786 p = expr10();
787 p = node4(ARITH, (NODE *)INCDEC, p, (NODE *)op, (NODE *)PRE);
789 else {
790 sym0 = sym;
791 p = expr10();
792 if (op = isincdec(sym)) {
793 /*printf("POST(%d)(%d)(%s)\n", sym, sym0, text);*/
794 if (sym0 == IDENT || sym0 == ARG) {
795 p = node4(ARITH, (NODE *)INCDEC, p, (NODE *)op,
796 (NODE *)POST);
797 lex();
800 if (sym == BINOR) { /* | getline */
801 lex();
802 if (sym != GETLINE)
803 synerr("'GETLINE' expected");
804 lex();
805 if (sym == IDENT || sym == STRING || sym == ARG) {
806 q = expr();
808 else
809 q = NULL;
810 p = node3(GETLINE, q, p, (NODE *)R_PIN);
813 return p;
816 static isincdec(sym)
818 return sym == INC ? 1 : (sym == DEC ? -1 : 0);
821 static NODE *
822 expr10()
824 NODE *p, *q;
825 CELL *u, *v;
826 int op;
827 int c;
828 int gsave, psave;
829 double atof();
832 printf("expr10(%d)(%s)\n", sym, text);
834 switch (sym) {
835 case STRING:
836 u = mkcell(STR, text, 0.0);
837 goto g1;
838 case NUMBER:
839 u = mkcell(NUM, NULL, atof(text));
841 p = node1(VALUE, u);
842 lex();
843 break;
844 case IDENT: case ARG:
845 if (isarrayindex()) { /* array */
846 /* 940403 */
847 if (sym == ARG) {
848 u = (CELL *)emalloc(sizeof(CELL));
849 u = mkcell(POS, NULL, (double)sym1);
850 p = doarray(u);
852 else {
853 u = getvar(text, hashtab, ARR);
854 p = doarray(u);
857 else {
858 if (sym == ARG) {
859 u = mkcell(POS, NULL, (double)sym1);
860 p = node1(ARG, u);
862 else { /* symple variable */
863 u = getvar(text, hashtab, VAR|STR|NUM);
864 p = node1(VALUE, u);
867 lex();
868 break;
869 case '(':
870 /* print >(x ? y : z) needs this */
871 gsave = getlineflg; psave = printflg;
872 getlineflg = printflg = 0;
873 lex();
874 p = expr();
875 if (sym == ',') /* (expr, expr, .. ) */
876 p = doelement(p);
877 if (sym != ')')
878 synerr("')' expected");
879 getlineflg = gsave; printflg = psave;
880 lex();
881 break;
882 case CALL:
883 p = dofuncn(sym, getvar(text, funtab, UDF));
884 break;
885 case MATHFUN: case STRFUN: case SUBST:
886 p = dofuncn(sym, (CELL *)sym1);
887 break;
888 case SPRINTF:
889 p = doprint(FORMAT|STROUT);
890 break;
891 case '$':
892 lex();
893 switch (sym) {
894 case NUMBER:
895 u = mkcell(NUM, NULL, atof(text));
896 p = node1(VALUE, u);
897 p = node1(FIELD, p);
898 lex();
899 break;
900 case IDENT: case ARG: case '(':
901 p = node1(FIELD, expr10());
902 break;
903 default:
904 synerr("number or identifier expected after '$'", (char *)0);
906 break;
907 case DIV:
908 regexflg++;
909 lex();
910 regexflg = 0;
911 u = mkcell(PAT, NULL, 0.0);
912 u->c_sval = (char *) mkpat(text);
913 p = node1(VALUE, u);
914 lex();
915 break;
916 case GETLINE:
917 getlineflg++;
918 lex();
919 if (sym == IDENT || sym == STRING || sym == ARG)
920 q = expr10(); /* read into var */
921 else
922 q = NULL;
923 getlineflg = 0;
924 if (sym == R_IN) {
925 op = R_IN;
926 lex();
927 p = expr10();
929 else
930 op = (int) (p = NULL);
931 p = node3(GETLINE, q, p, (NODE *)op);
932 break;
933 default:
934 synerr(
935 "identifier, number, string, argument, regexpr, call or '(' expected");
936 break;
938 return p;
941 static NODE *
942 dofuncn(fun, op) CELL *op;
944 NODE *p;
945 int i, j;
946 int n = 0;
947 NODE *a[100];
949 if (lex() == '(') {
950 prmflg++;
951 for (lex(); sym && (sym != ')'); n++) {
952 if ((int)op == SPLIT && n == 1) {
954 printf("sym(%d)sym1(%d)(%d)\n", sym, sym1, isarg(text));
956 if (sym != ARG) { /*isarg(text) == -1*/
957 /* make an array if not exist */
958 prmflg = 0;
959 getvar(text, hashtab, ARR);
960 prmflg++;
963 a[n] = expr();
964 if (sym == ',')
965 lex();
966 else if (sym != ')')
967 synerr("',' or ')' expected");
969 prmflg = 0;
971 if (sym == ')')
972 lex();
973 else
974 synerr("')' expected");
976 p = (NODE *) emalloc(sizeof(*p) + sizeof(p) * (n + 2));
977 p->n_type = fun;
978 p->n_next = NULL;
979 p->n_arg[0] = (NODE *) op;
980 p->n_arg[1] = (NODE *) n;
981 for (i = 0, j = 2; i < n; )
982 p->n_arg[j++] = a[i++];
983 p->n_arg[j] = NULL;
984 return p;
987 static NODE *
988 doarray(u) CELL *u;
990 NODE *p;
991 int i, j;
992 int n;
993 NODE *a[20];
995 for (lex(), n = 0; sym && sym != ']'; n++) {
996 a[n] = expr();
997 if (sym == ',')
998 lex();
1000 if (sym != ']')
1001 synerr("']' expected");
1002 /* left ']' for expr10() */
1003 p = (NODE *) emalloc(sizeof(*p) + sizeof(p) * (n + 1));
1004 p->n_type = ARRAY;
1005 p->n_next = NULL;
1006 p->n_arg[0] = (NODE *)u;
1007 p->n_arg[1] = (NODE *) n;
1008 for (i = 0, j = 2; i < n; )
1009 p->n_arg[j++] = a[i++];
1010 return p;
1013 static NODE *
1014 doelement(q) NODE *q;
1016 NODE *p;
1017 int i, j;
1018 int n;
1019 NODE *a[20];
1021 a[0] = q;
1022 for (lex(), n = 1; sym && sym != ')'; n++) {
1023 a[n] = expr();
1024 if (sym == ',')
1025 lex();
1026 else if (sym != ')')
1027 synerr("',' or ')' expected");
1029 /* left ')' for expr10() */
1030 p = (NODE *) emalloc(sizeof(*p) + sizeof(p) * (n + 1));
1031 p->n_type = ELEMENT;
1032 p->n_next = NULL;
1033 p->n_arg[0] = NULL;
1034 p->n_arg[1] = (NODE *) n;
1035 for (i = 0, j = 2; i < n; )
1036 p->n_arg[j++] = a[i++];
1037 return p;
1040 synerr(s, t) char *s, *t;
1042 extern int lineno;
1043 extern char line[], *linep;
1044 int c, i;
1045 char *u, *v;
1047 fprintf(stderr, "%s: Syntax error at line %d", cmd, lineno);
1048 if (funflg)
1049 fprintf(stderr, " in function %s", funnam);
1050 fprintf(stderr, ":\n");
1051 if ((v = linep - 1) < line)
1052 v = line + BUFSIZ - 1;
1053 for (i = 0, u = v - 1; ; --u) {
1054 if (u < line) {
1055 if (line[BUFSIZ - 1] == '\0')
1056 break;
1057 u = line + BUFSIZ - 1;
1059 if (*u == '\n' && ++i == 2)
1060 break;
1062 if (u != v) {
1063 while (u != v) {
1064 fputc(*u, stderr);
1065 if ((++u - line) == BUFSIZ)
1066 u = line;
1068 if (*u != '\n')
1069 fputc(*u, stderr);
1070 fprintf(stderr, " <--\n\n");
1072 fprintf(stderr, " <-- ");
1073 while ((c = Getc()) != EOF && c != '\n')
1074 fputc(c, stderr);
1075 fprintf(stderr, "\n");
1076 if (c == EOF);
1077 fprintf(stderr, "\n");
1080 fprintf(stderr, s, t);
1081 fprintf(stderr, "\n");
1082 #ifdef DOS
1083 closeall();
1084 #endif
1085 exit(1);