/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include "awk.h"
#include "y.tab.h"
static struct fldtab_chunk {
static void cleanfld(int, int);
static void bcheck2(int, int, int);
static void eprint(void);
static void bclass(int);
static void
initgetrec(void)
{
int i;
uchar *p;
for (i = 1; i < *ARGC; i++) {
return;
setclvar(p); /* a commandline assignment before filename */
argno++;
}
/* *FILENAME = file = (uchar*) "-"; */
}
int
{
int c;
if (firsttime) {
firsttime = 0;
initgetrec();
}
dprintf(("RS=<%s>, FS=<%s>, ARGC=%f, FILENAME=%s\n",
donefld = 0;
donerec = 1;
argno++;
continue;
}
argno++;
continue;
}
}
}
}
return (1);
}
/* EOF arrived on this file; set up next */
argno++;
}
return (0); /* true end of file */
}
int
{
int sep, c;
int count;
sep = '\n';
/* skip leading \n's */
;
if (c != EOF)
}
count = 0;
for (;;) {
}
break;
break;
}
dprintf(("readrec saw <%s>, returns %d\n",
}
/* get ARGV[n] */
static uchar *
getargv(int n)
{
Cell *x;
s = getsval(x);
dprintf(("getargv(%d) returns |%s|\n", n, s));
return (s);
}
void
{
uchar *p;
Cell *q;
for (p = s; *p != '='; p++)
;
*p++ = 0;
p = qstring(p, '\0');
(void) setsval(q, p);
}
dprintf(("command line set %s to |%s|\n", s, p));
free(p);
}
void
fldbld(void)
{
Cell *p;
int i;
if (donefld)
return;
/* make sure fields is always allocated */
/*
* make sure fields has enough size. We don't expand the buffer
* in the middle of the loop, since p->sval has already pointed
* the address in the fields.
*/
i = 0; /* number of fields accumulated here */
for (i = 0; ; ) {
while (*r == ' ' || *r == '\t' || *r == '\n')
r++;
if (*r == 0)
break;
i++;
p = getfld(i);
do
*fr++ = *r++;
while (*r != ' ' && *r != '\t' && *r != '\n' &&
*r != '\0')
;
*fr++ = 0;
}
*fr = 0;
} else if (*r != 0) { /* if 0, it's a null field */
for (;;) {
i++;
p = getfld(i);
/* \n always a separator */
*fr++ = *r++;
*fr++ = 0;
if (*r++ == 0)
break;
}
*fr = 0;
}
/* clean out junk from previous record */
maxfld = i;
donefld = 1;
for (i = 1; i <= maxfld; i++) {
p = getfld(i);
}
}
if (dbg) {
for (i = 0; i <= maxfld; i++) {
p = getfld(i);
}
}
}
static void
{
Cell *p;
int i;
p = getfld(i);
}
}
void
{
if (n < 0)
(void) getfld(n);
maxfld = n;
}
/*
* allocate field table. We don't reallocate the table since there
* might be somewhere recording the address of the table.
*/
static void
morefld(void)
{
int i;
for (i = 0; i < FLD_INCR; i++) {
}
/*
* link this field chunk
*/
if (fldtab_head == NULL)
fldtab_head = fldcp;
else
fldtab_tail = fldcp;
}
Cell *
{
int cbase;
if (idx < 0)
while (idx >= fldtab_maxidx)
morefld();
cbase = 0;
}
/* should never happen */
return (NULL);
}
int
{
int cbase;
cbase = 0;
}
/* should never happen */
return (0);
}
static int
{
int i, tempstat;
Cell *p;
/* make sure fields is allocated */
*fr = '\0';
if (*rec == '\0')
return (0);
for (i = 1; ; i++) {
p = getfld(i);
dprintf(("refldbld: i=%d\n", i));
} else {
break;
}
}
return (i);
}
void
recbld(void)
{
int i;
uchar *p;
if (donerec == 1)
return;
cnt = 0;
for (i = 1; i <= *NF; i++) {
if (i < *NF) {
}
}
donerec = 1;
}
Cell *
fieldadr(int n)
{
if (n < 0)
return (getfld(n));
}
int errorflag = 0;
void
yyerror(char *s)
{
static int been_here = 0;
if (been_here++ > 2)
return;
errorflag = 2;
eprint();
}
/*ARGSUSED*/
void
{
}
void
bracecheck(void)
{
int c;
static int beenhere = 0;
if (beenhere++)
return;
bclass(c);
}
/*ARGSUSED*/
static void
{
if (n == 1)
else if (n > 1)
else if (n == -1)
else if (n < -1)
}
void
error(int f, char *s)
{
}
}
eprint();
if (f) {
if (dbg)
abort();
exit(2);
}
}
static void
{
uchar *p, *q;
int c;
static int been_here = 0;
return;
p = ep - 1;
if (p > ebuf && *p == '\n')
p--;
;
while (*p == '\n')
p++;
;
for (; p < q; p++)
if (*p)
for (; p < ep; p++)
if (*p)
if (*ep)
bclass(c);
}
}
static void
bclass(int c)
{
switch (c) {
case '{': bracecnt++; break;
case '}': bracecnt--; break;
case '[': brackcnt++; break;
case ']': brackcnt--; break;
case '(': parencnt++; break;
case ')': parencnt--; break;
}
}
double
errcheck(double x, char *s)
{
extern int errno;
errno = 0;
x = 1;
errno = 0;
x = 1;
}
return (x);
}
void
{
dprintf(("%s\n", s));
}
int
{
if (s != NULL) {
/* Must begin with an underscore or alphabetic character */
if (isalpha(*s) || (*s == '_')) {
for (s++; *s; s++) {
/*
* followed by a sequence of underscores,
* digits, and alphabetics
*/
if (!(isalnum(*s) || *s == '_')) {
break;
}
}
return (*s == '=' && *(s + 1) != '=');
}
}
return (0);
}
int
{
int point;
extern char radixpoint;
while (*s == ' ' || *s == '\t' || *s == '\n')
s++;
if (*s == '\0')
return (0); /* empty stuff isn't number */
if (*s == '+' || *s == '-')
s++;
if (!isdigit(*s) && *s != radixpoint)
return (0);
if (isdigit(*s)) {
do {
d1++;
s++;
} while (isdigit(*s));
}
return (0); /* too many digits to convert */
if (*s == radixpoint) {
point++;
s++;
}
if (isdigit(*s)) {
d2++;
do {
s++;
} while (isdigit(*s));
}
return (0);
if (*s == 'e' || *s == 'E') {
s++;
if (*s == '+' || *s == '-')
s++;
if (!isdigit(*s))
return (0);
es = s;
do {
s++;
} while (isdigit(*s));
if (s - es > 2) {
return (0);
} else if (s - es == 2 &&
return (0);
}
}
while (*s == ' ' || *s == '\t' || *s == '\n')
s++;
if (*s == '\0')
return (1);
else
return (0);
}
void
{
/* initial buffer should have NULL terminated */
*nptr = '\0';
}
void
{
return;
/* initial buffer should have NULL terminated */
if (size == 0)
*nptr = '\0';
}
void
{
}