Re: embedded perl and top_env problem
[p5sagit/p5-mst-13.2.git] / x2p / a2py.c
index 59c2241..46ec604 100644 (file)
@@ -1,6 +1,6 @@
 /* $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.
 #include "../patchlevel.h"
 #endif
 #include "util.h"
-char *strchr();
 
 char *filename;
 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);
@@ -35,13 +42,14 @@ usage()
     exit(1);
 }
 #endif
+
+int
 main(argc,argv,env)
 register int argc;
 register char **argv;
 register char **env;
 {
     register STR *str;
-    register char *s;
     int i;
     STR *tmpstr;
 
@@ -148,11 +156,10 @@ register char **env;
     /* second pass to produce new program */
 
     tmpstr = walk(0,0,root,&i,P_MIN);
-    str = str_make("#!");
-    str_cat(str, BIN);
-    str_cat(str, "/perl\neval \"exec ");
+    str = str_make(STARTPERL);
+    str_cat(str, "\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");
@@ -189,6 +196,7 @@ register char **env;
 
 int idtype;
 
+int
 yylex()
 {
     register char *s = bufptr;
@@ -828,6 +836,7 @@ register char *s;
     return s;
 }
 
+void
 yyerror(s)
 char *s;
 {
@@ -872,8 +881,10 @@ register char *s;
     return s;
 }
 
+int
 string(ptr,len)
 char *ptr;
+int len;
 {
     int retval = mop;
 
@@ -888,6 +899,7 @@ char *ptr;
     return retval;
 }
 
+int
 oper0(type)
 int type;
 {
@@ -901,6 +913,7 @@ int type;
     return retval;
 }
 
+int
 oper1(type,arg1)
 int type;
 int arg1;
@@ -916,6 +929,7 @@ int arg1;
     return retval;
 }
 
+int
 oper2(type,arg1,arg2)
 int type;
 int arg1;
@@ -933,6 +947,7 @@ int arg2;
     return retval;
 }
 
+int
 oper3(type,arg1,arg2,arg3)
 int type;
 int arg1;
@@ -952,6 +967,7 @@ int arg3;
     return retval;
 }
 
+int
 oper4(type,arg1,arg2,arg3,arg4)
 int type;
 int arg1;
@@ -973,6 +989,7 @@ int arg4;
     return retval;
 }
 
+int
 oper5(type,arg1,arg2,arg3,arg4,arg5)
 int type;
 int arg1;
@@ -998,6 +1015,7 @@ int arg5;
 
 int depth = 0;
 
+void
 dump(branch)
 int branch;
 {
@@ -1025,6 +1043,7 @@ int branch;
     }
 }
 
+int
 bl(arg,maybe)
 int arg;
 int maybe;
@@ -1039,6 +1058,7 @@ int maybe;
        return arg;
 }
 
+void
 fixup(str)
 STR *str;
 {
@@ -1064,6 +1084,7 @@ STR *str;
     }
 }
 
+void
 putlines(str)
 STR *str;
 {
@@ -1140,6 +1161,7 @@ STR *str;
     }
 }
 
+void
 putone()
 {
     register char *t;
@@ -1162,6 +1184,7 @@ putone()
     fputs(tokenbuf,stdout);
 }
 
+int
 numary(arg)
 int arg;
 {
@@ -1176,6 +1199,7 @@ int arg;
     return arg;
 }
 
+int
 rememberargs(arg)
 int arg;
 {
@@ -1198,6 +1222,7 @@ int arg;
     return arg;
 }
 
+int
 aryrefarg(arg)
 int arg;
 {
@@ -1212,6 +1237,7 @@ int arg;
     return arg;
 }
 
+int
 fixfargs(name,arg,prevargs)
 int name;
 int arg;
@@ -1250,6 +1276,7 @@ int prevargs;
     return numargs;
 }
 
+int
 fixrargs(name,arg,prevargs)
 char *name;
 int arg;