1N/A/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $ 1N/A * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 1N/A * 2000, 2001, 2002, by Larry Wall and others 1N/A * You may distribute under the terms of either the GNU General Public 1N/A * License or the Artistic License, as specified in the README file. 1N/A printf(
"\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n",
myname);
1N/A "\n -F<character> the awk script to translate is always invoked with" 1N/A "\n this -F switch." 1N/A "\n -n<fieldlist> specifies the names of the input fields if input does" 1N/A "\n not have to be split into an array." 1N/A "\n -<number> causes a2p to assume that input will always have that" 1N/A "\n many fields.\n");
1N/A /* char *namelist; */ 1N/A #
endif /* NETWARE */ 1N/A case '0':
case '1':
case '2':
case '3':
case '4':
1N/A case '5':
case '6':
case '7':
case '8':
case '9':
1N/A /* now parse the report spec */ 1N/A fatal(
"Translation aborted due to syntax errors.\n");
1N/A /* first pass to look for numeric variables */ 1N/A /* second pass to produce new program */ 1N/A if $running_under_some_shell;\n\ 1N/A # this emulates #! processing on NIH machines.\n\ 1N/A # (remove #! line above if indigestible)\n\n");
1N/A "eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;\n");
1N/A " # process any FOO=bar switches\n\n");
1N/A "Please check my work on the %d line%s I've marked with \"#???\".\n",
1N/A "The operation I've selected may be wrong for the operand types.\n");
1N/A /* by ANSI specs return is needed. This also shuts up VC++ and his warnings */ 1N/A "Unrecognized character %c in file %s line %d--ignoring.\n",
1N/A if (*s && *s !=
'\n') {
1N/A case ' ':
case '\t':
1N/A while (*s ==
' ' || *s ==
'\t')
1N/A case '/':
/* may either be division or pattern */ 1N/A case '0':
case '1':
case '2':
case '3':
case '4':
1N/A case '5':
case '6':
case '7':
case '8':
case '9':
case '.':
1N/A if (*d ==
'"' && d[
2] ==
'"')
1N/A /* In old awk, { print sprintf("str%sg"),"in" } prints 1N/A * "string"; in new awk, "in" is not considered an argument to 1N/A * sprintf, so the statement breaks. To support both, the 1N/A * grammar treats arguments to SPRINTF_OLD like old awk, 1N/A * SPRINTF_NEW like new. Here we return the appropriate one. 1N/A for (; *s; s++,d++) {
1N/A else if (s[
1] ==
'\\')
1N/A else if (s[
1] ==
'[')
1N/A else if (*s ==
'[') {
1N/A if (*s ==
'\\' && s[
1])
1N/A if (*s ==
'/' || (*s ==
'-' && s[
1] ==
']'))
1N/A }
while (*s && *s !=
']');
1N/A case '1':
case '2':
case '3':
case '4':
case '5':
1N/A case '6':
case '7':
case '8':
case '9':
case '0' :
case '.':
1N/A if (*s ==
'+' || *s ==
'-')
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A fatal(
"Recompile a2p with larger OPSMAX\n");
1N/A if (*s ==
';' && s[
1] ==
' ' && s[
2] ==
'\n') {
1N/A else if (*s ==
'\n') {
1N/A if (*t ==
'\n' && t-s >
1) {
1N/A register char *d, *s, *t, *e;
1N/A else if (*s ==
'\t')
1N/A if (
pos >
78) {
/* split a long line? */ 1N/A (*d !=
' ' || d[-
1] !=
'|' || d[-
2] !=
'|') )
1N/A (*d !=
' ' || d[-
1] !=
'&' || d[-
2] !=
'&') )
1N/A fatal(
"panic: unknown argument type %d, arg %d, line %d\n",
1N/A fatal(
"Can't pass expression by reference as arg %d of %s\n",