/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $
*
- * Copyright (c) 1991, Larry Wall
+ * Copyright (c) 1991-1997, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
char *myname;
int checkers = 0;
+
+int oper0();
+int oper1();
+int oper2();
+int oper3();
+int oper4();
+int oper5();
STR *walk();
#ifdef OS2
+static void
usage()
{
printf("\nThis is the AWK to PERL translator, version 5.0, patchlevel %d\n", PATCHLEVEL);
exit(1);
}
#endif
+
+int
main(argc,argv,env)
register int argc;
register char **argv;
case 'n':
namelist = savestr(argv[0]+2);
break;
+ case 'o':
+ old_awk = TRUE;
+ break;
case '-':
argc--,argv++;
goto switch_end;
/* second pass to produce new program */
tmpstr = walk(0,0,root,&i,P_MIN);
- str = str_make("#!");
+ str = str_make(STARTPERL);
+ str_cat(str, "\neval 'exec ");
str_cat(str, BIN);
- str_cat(str, "/perl\neval \"exec ");
- str_cat(str, BIN);
- str_cat(str, "/perl -S $0 $*\"\n\
+ str_cat(str, "/perl -S $0 ${1+\"$@\"}'\n\
if $running_under_some_shell;\n\
# this emulates #! processing on NIH machines.\n\
# (remove #! line above if indigestible)\n\n");
int idtype;
+int
yylex()
{
register char *s = bufptr;
return s;
}
+int
string(ptr,len)
char *ptr;
+int len;
{
int retval = mop;
return retval;
}
+int
oper0(type)
int type;
{
return retval;
}
+int
oper1(type,arg1)
int type;
int arg1;
return retval;
}
+int
oper2(type,arg1,arg2)
int type;
int arg1;
return retval;
}
+int
oper3(type,arg1,arg2,arg3)
int type;
int arg1;
return retval;
}
+int
oper4(type,arg1,arg2,arg3,arg4)
int type;
int arg1;
return retval;
}
+int
oper5(type,arg1,arg2,arg3,arg4,arg5)
int type;
int arg1;
}
}
+int
bl(arg,maybe)
int arg;
int maybe;
fputs(tokenbuf,stdout);
}
+int
numary(arg)
int arg;
{
return arg;
}
+int
rememberargs(arg)
int arg;
{
return arg;
}
+int
aryrefarg(arg)
int arg;
{
return arg;
}
+int
fixfargs(name,arg,prevargs)
int name;
int arg;
return numargs;
}
+int
fixrargs(name,arg,prevargs)
char *name;
int arg;
numargs = fixrargs(name,ops[arg+3].ival,numargs);
}
else {
- char tmpbuf[128];
-
+ char *tmpbuf = safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5);
sprintf(tmpbuf,"%s:%d",name,prevargs);
str = hfetch(curarghash,tmpbuf);
+ safefree(tmpbuf);
if (str && strEQ(str->str_ptr,"*")) {
if (type == OVAR || type == OSTAR) {
ops[arg].ival &= ~255;