main.c revision 0717e03de979bd98c63b0b48ccb2a5c2628ee4b9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <locale.h>
#include <libintl.h>
#include <stdarg.h>
#include <errno.h>
#include <values.h>
#include <langinfo.h>
#include "awk.h"
#include "y.tab.h"
char *version = "version Oct 11, 1989";
int dbg = 0;
/* 2 = cmdline, 1 = compile, 0 = running */
char radixpoint = '.';
static int npfile = 0; /* number of filenames */
static int curpfile = 0; /* current filename */
int
{
char *nl_radix;
/*
* At this point, numbers are still scanned as in
* the POSIX locale.
* (POSIX.2, volume 2, P867, L4742-4757)
*/
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc == 1) {
"Usage: %s [-f programfile | 'program'] [-Ffieldsep] "
"[-v var=value] [files]\n"), cmdname);
exit(1);
}
syminit();
/* explicit end of args */
argc--;
argv++;
break;
}
case 'f': /* next argument is program filename */
argc--;
argv++;
if (argc <= 1)
break;
case 'F': /* set field separator */
/* wart: t=>\t */
} else { /* arg is -F something */
if (argc > 1) {
/* wart: t=>\t */
else if (argv[1][0] != 0)
}
}
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
break;
case 'd':
if (dbg == 0)
dbg = 1;
break;
default:
break;
}
argc--;
argv++;
}
/* argv[1] is now the first argument */
if (npfile == 0) { /* no -f; first argument is program */
if (argc <= 1) {
if (dbg)
exit(0);
}
argc--;
argv++;
}
compile_time = 1;
(void) yyparse();
if (fs)
/*
* done parsing, so now activate the LC_NUMERIC
*/
if (nl_radix)
radixpoint = *nl_radix;
if (errorflag == 0) {
compile_time = 0;
} else
bracecheck();
return (errorflag);
}
int
pgetc(void) /* get program character */
{
int c;
for (;;) {
return (EOF);
ERROR "can't open file %s",
}
}
return (c);
curpfile++;
}
}