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.
17 #include <sys/types.h>
21 extern char **FS
, **FILENAME
;
27 FILE *efopen(), *fopen();
36 int iflg
; /* interactive mode */
39 main(argc
, argv
) char **argv
;
41 char *s
, *strpbrk(), *strchr();
47 signal(SIGINT
, onint
);
48 signal(SIGFPE
, onint
);
51 while (--argc
> 0 && (*++argv
)[0] == '-')
52 for (s
= argv
[0]+1; *s
; s
++)
53 if (strcmp(argv
[0], "-") == 0)
77 xargc
= argc
; xargv
= argv
;
78 if (pfp
== NULL
&& xargc
> 0) {
79 srcprg
= *xargv
++; xargc
--;
82 if (pfp == NULL && xargc > 0) {
83 if (strpbrk(xargv[0], " !$^()={}[];<>,/~") != NULL) {
84 sprintf(record, "%s\n", xargv[0]);
85 srcprg = strsave(record);
88 sprintf(record, "%s.awk", xargv[0]);
89 if ((pfp = fopen(record, "r")) == NULL)
90 error("can't open %s", record);
96 while (*xargv
!= NULL
&& strchr(*xargv
, '=') != NULL
) {
101 initarg(cmd
, xargc
, xargv
);
103 ifp
= stdin
; *FILENAME
= "-";
111 efopen(file
, mode
) char *file
, *mode
;
115 if ((fp
= fopen(file
, mode
)) == NULL
)
116 error("cannot open %s", file
);
120 error(s
, t
) char *s
, *t
;
124 fprintf(stderr
, "awk: ");
125 fprintf(stderr
, s
, t
);
126 fprintf(stderr
, "\n");
128 fprintf(stderr
, "record number %g\n", *NR
);