* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.proprietary.c%
"@(#) Copyright (c) 1991 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)main.c 4.6 (Berkeley) %G%";
#define TOLOWER(c) (isupper(c) ? tolower(c) : c) /* ugh!!! */
extern FILE *yyin
; /* lex input file */
char *lexprog
; /* points to program argument if it exists */
extern errorflag
; /* non-zero if any syntax errors; set by yyerror */
int filefd
, symnum
, ansfd
;
extern int maxsym
, errno
;
main(argc
, argv
) int argc
; char *argv
[]; {
error(FATAL
, "Usage: awk [-f source | 'cmds'] [files]");
/* this nonsense is because gcos argument handling */
/* folds -F into -f. accordingly, one checks the next
/* character after f to see if it's -f file or -Fx.
if (argv
[0][0] == '-' && TOLOWER(argv
[0][1]) == 'f' && argv
[0][2] == '\0') {
if (argv
[1][0] == '-' && argv
[1][1] == '\0')
yyin
= fopen(argv
[1], "r");
error(FATAL
, "can't open %s", argv
[1]);
} else if (argv
[0][0] == '-' && TOLOWER(argv
[0][1]) == 'f') { /* set field sep */
if (argv
[0][2] == 't') /* special case for tab */
} else if (argv
[0][0] != '-') {
dprintf("cmds=|%s|\n", argv
[0], NULL
, NULL
);
argv
[0] = argv
[-1]; /* need this space */
} else if (strcmp("-d", argv
[0])==0) {
else if (strcmp("-l", argv
[0])==0) {
else if(strcmp("-S", argv
[0]) == 0) {
else if(strncmp("-R", argv
[0], 2) == 0) {
if(thaw(argv
[0] + 2) == 0)
fprintf(stderr
, "not restored\n");
dprintf("svargc=%d svargv[0]=%s\n", svargc
, svargv
[0], NULL
);
*FILENAME
= *svargv
; /* initial file name */
dprintf("errorflag=%d\n", errorflag
, NULL
, NULL
);
if(freeze("awk.out") != 0)
fprintf(stderr
, "not saved\n");