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
, envp
) char **argv
, *envp
;
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)
73 if (s
== NULL
) usage();
78 xargc
= argc
; xargv
= argv
;
79 if (pfp
== NULL
&& xargc
> 0) {
80 srcprg
= *xargv
++; xargc
--;
83 if (pfp == NULL && xargc > 0) {
84 if (strpbrk(xargv[0], " !$^()={}[];<>,/~") != NULL) {
85 sprintf(record, "%s\n", xargv[0]);
86 srcprg = strsave(record);
89 sprintf(record, "%s.awk", xargv[0]);
90 if ((pfp = fopen(record, "r")) == NULL)
91 error("can't open %s", record);
97 if (pfp
== NULL
&& srcprg
== NULL
) usage();
99 while (*xargv
!= NULL
&& strchr(*xargv
, '=') != NULL
) {
104 initarg(cmd
, xargc
, xargv
, envp
);
106 ifp
= stdin
; *FILENAME
= "-";
114 efopen(file
, mode
) char *file
, *mode
;
118 if ((fp
= fopen(file
, mode
)) == NULL
)
119 error("cannot open %s", file
);
123 error(s
, t
) char *s
, *t
;
127 fprintf(stderr
, "awk: ");
128 fprintf(stderr
, s
, t
);
129 fprintf(stderr
, "\n");
131 fprintf(stderr
, "record number %g\n", *NR
);
150 "usage: %s [options] [-f <rulefile> | <rules>] [inputfiles]\n", cmd
);