This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix to installing non-xs ext's in priv lib
[perl5.git] / x2p / a2py.c
index ad685fe..84fdc48 100644 (file)
@@ -1,36 +1,47 @@
-/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $
+/*    a2py.c
  *
- *    Copyright (c) 1991-1997, Larry Wall
+ *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ *    2000, 2001, 2002, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
- *
- * $Log:       a2py.c,v $
  */
 
-#ifdef OS2
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
+#if defined(WIN32)
+#include <io.h>
+#endif
+#if defined(NETWARE)
+#include "../netware/clibstuf.h"
+#endif
 #include "../patchlevel.h"
 #endif
 #include "util.h"
 
-char *filename;
-char *myname;
+const char *filename;
+const char *myname;
 
 int checkers = 0;
 
-int oper0();
-int oper1();
-int oper2();
-int oper3();
-int oper4();
-int oper5();
-STR *walk();
+int oper0(int type);
+int oper1(int type, int arg1);
+int oper2(int type, int arg1, int arg2);
+int oper3(int type, int arg1, int arg2, int arg3);
+int oper4(int type, int arg1, int arg2, int arg3, int arg4);
+int oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5);
+STR *walk(int useval, int level, register int node, int *numericptr, int minprec);
+#ifdef NETWARE
+char *savestr(char *str);
+char *cpy2(register char *to, register char *from, register int delim);
+#endif
+
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
+static void usage(void);
 
-#ifdef OS2
 static void
 usage()
 {
-    printf("\nThis is the AWK to PERL translator, version 5.0, patchlevel %d\n", PATCHLEVEL);
+    printf("\nThis is the AWK to PERL translator, revision %d.0, version %d\n", PERL_REVISION, PERL_VERSION);
     printf("\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n", myname);
     printf("\n  -D<number>      sets debugging flags."
            "\n  -F<character>   the awk script to translate is always invoked with"
@@ -43,15 +54,21 @@ usage()
 }
 #endif
 
+#ifdef __osf__
+#pragma message disable (mainparm) /* We have the envp in main(). */
+#endif
+
 int
-main(argc,argv,env)
-register int argc;
-register char **argv;
-register char **env;
+main(register int argc, register const char **argv, register const char **env)
 {
     register STR *str;
     int i;
     STR *tmpstr;
+    /* char *namelist;    */
+
+       #ifdef NETWARE
+               fnInitGpfGlobals();     /* For importing the CLIB calls in place of Watcom calls */
+       #endif  /* NETWARE */
 
     myname = argv[0];
     linestr = str_new(80);
@@ -59,12 +76,11 @@ register char **env;
     for (argc--,argv++; argc; argc--,argv++) {
        if (argv[0][0] != '-' || !argv[0][1])
            break;
-      reswitch:
        switch (argv[0][1]) {
 #ifdef DEBUGGING
        case 'D':
            debug = atoi(argv[0]+2);
-#ifdef YYDEBUG
+#if YYDEBUG
            yydebug = (debug & 1);
 #endif
            break;
@@ -89,9 +105,11 @@ register char **env;
        case 0:
            break;
        default:
-           fatal("Unrecognized switch: %s\n",argv[0]);
-#ifdef OS2
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
+           fprintf(stderr, "Unrecognized switch: %s\n",argv[0]);
             usage();
+#else
+           fatal("Unrecognized switch: %s\n",argv[0]);
 #endif
        }
     }
@@ -99,8 +117,8 @@ register char **env;
 
     /* open script */
 
-    if (argv[0] == Nullch) {
-#ifdef OS2
+    if (argv[0] == NULL) {
+#if defined(OS2) || defined(WIN32) || defined(NETWARE)
        if ( isatty(fileno(stdin)) )
            usage();
 #endif
@@ -108,14 +126,13 @@ register char **env;
     }
     filename = savestr(argv[0]);
 
-    filename = savestr(argv[0]);
     if (strEQ(filename,"-"))
        argv[0] = "";
     if (!*argv[0])
        rsfp = stdin;
     else
        rsfp = fopen(argv[0],"r");
-    if (rsfp == Nullfp)
+    if (rsfp == NULL)
        fatal("Awk script \"%s\" doesn't seem to exist.\n",filename);
 
     /* init tokener */
@@ -190,6 +207,8 @@ register char **env;
          "The operation I've selected may be wrong for the operand types.\n");
     }
     exit(0);
+    /* by ANSI specs return is needed. This also shuts up VC++ and his warnings */
+    return(0);
 }
 
 #define RETURN(retval) return (bufptr = s,retval)
@@ -200,19 +219,20 @@ register char **env;
 int idtype;
 
 int
-yylex()
+yylex(void)
 {
     register char *s = bufptr;
     register char *d;
     register int tmp;
 
   retry:
-#ifdef YYDEBUG
-    if (yydebug)
+#if YYDEBUG
+    if (yydebug) {
        if (strchr(s,'\n'))
            fprintf(stderr,"Tokener at %s",s);
        else
            fprintf(stderr,"Tokener at %s\n",s);
+    }
 #endif
     switch (*s) {
     default:
@@ -233,10 +253,10 @@ yylex()
        if (!rsfp)
            RETURN(0);
        line++;
-       if ((s = str_gets(linestr, rsfp)) == Nullch) {
+       if ((s = str_gets(linestr, rsfp)) == NULL) {
            if (rsfp != stdin)
                fclose(rsfp);
-           rsfp = Nullfp;
+           rsfp = NULL;
            s = str_get(linestr);
            RETURN(0);
        }
@@ -269,11 +289,15 @@ yylex()
     case ':':
        tmp = *s++;
        XOP(tmp);
+#ifdef EBCDIC
+    case 7:
+#else
     case 127:
+#endif
        s++;
        XTERM('}');
     case '}':
-       for (d = s + 1; isspace(*d); d++) ;
+       for (d = s + 1; isSPACE(*d); d++) ;
        if (!*d)
            s = d - 1;
        *s = 127;
@@ -375,7 +399,7 @@ yylex()
 
 #define SNARFWORD \
        d = tokenbuf; \
-       while (isalpha(*s) || isdigit(*s) || *s == '_') \
+       while (isALPHA(*s) || isDIGIT(*s) || *s == '_') \
            *d++ = *s++; \
        *d = '\0'; \
        d = tokenbuf; \
@@ -394,15 +418,22 @@ yylex()
            ID("0");
        }
        do_split = TRUE;
-       if (isdigit(*s)) {
-           for (d = s; isdigit(*s); s++) ;
+       if (isDIGIT(*s)) {
+           for (d = s; isDIGIT(*s); s++) ;
            yylval = string(d,s-d);
            tmp = atoi(d);
            if (tmp > maxfld)
                maxfld = tmp;
            XOP(FIELD);
        }
+       for (d = s; isALPHA(*s) || isDIGIT(*s) || *s == '_'; )
+           s++;
        split_to_array = set_array_base = TRUE;
+       if (d != s)
+       {
+           yylval = string(d,s-d);
+           XTERM(SVFIELD);
+       }
        XOP(VFIELD);
 
     case '/':                  /* may either be division or pattern */
@@ -465,15 +496,15 @@ yylex()
            XTERM(FUN1);
        }
        if (strEQ(d,"chdir"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"crypt"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"chop"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"chmod"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"chown"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'd': case 'D':
        SNARFWORD;
@@ -482,7 +513,7 @@ yylex()
        if (strEQ(d,"delete"))
            XTERM(DELETE);
        if (strEQ(d,"die"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'e': case 'E':
        SNARFWORD;
@@ -499,26 +530,26 @@ yylex()
            XTERM(FUN1);
        }
        if (strEQ(d,"elsif"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"eq"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"eval"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"eof"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"each"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"exec"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'f': case 'F':
        SNARFWORD;
        if (strEQ(d,"FS")) {
            saw_FS++;
            if (saw_FS == 1 && in_begin) {
-               for (d = s; *d && isspace(*d); d++) ;
+               for (d = s; *d && isSPACE(*d); d++) ;
                if (*d == '=') {
-                   for (d++; *d && isspace(*d); d++) ;
+                   for (d++; *d && isSPACE(*d); d++) ;
                    if (*d == '"' && d[2] == '"')
                        const_FS = d[1];
                }
@@ -530,15 +561,15 @@ yylex()
        else if (strEQ(d,"function"))
            XTERM(FUNCTION);
        if (strEQ(d,"FILENAME"))
-           d = "ARGV";
+           ID("ARGV");
        if (strEQ(d,"foreach"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"format"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"fork"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"fh"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'g': case 'G':
        SNARFWORD;
@@ -547,18 +578,18 @@ yylex()
        if (strEQ(d,"gsub"))
            XTERM(GSUB);
        if (strEQ(d,"ge"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"gt"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"goto"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"gmtime"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'h': case 'H':
        SNARFWORD;
        if (strEQ(d,"hex"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'i': case 'I':
        SNARFWORD;
@@ -578,14 +609,14 @@ yylex()
     case 'j': case 'J':
        SNARFWORD;
        if (strEQ(d,"join"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'k': case 'K':
        SNARFWORD;
        if (strEQ(d,"keys"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"kill"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'l': case 'L':
        SNARFWORD;
@@ -598,17 +629,17 @@ yylex()
            XTERM(FUN1);
        }
        if (strEQ(d,"last"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"local"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"lt"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"le"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"locatime"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"link"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'm': case 'M':
        SNARFWORD;
@@ -617,7 +648,7 @@ yylex()
            XTERM(MATCH);
        }
        if (strEQ(d,"m"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'n': case 'N':
        SNARFWORD;
@@ -628,27 +659,27 @@ yylex()
            XTERM(NEXT);
        }
        if (strEQ(d,"ne"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'o': case 'O':
        SNARFWORD;
        if (strEQ(d,"ORS")) {
            saw_ORS = TRUE;
-           d = "\\";
+           ID("\\");
        }
        if (strEQ(d,"OFS")) {
            saw_OFS = TRUE;
-           d = ",";
+           ID(",");
        }
        if (strEQ(d,"OFMT")) {
-           d = "#";
+           ID("#");
        }
        if (strEQ(d,"open"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"ord"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"oct"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'p': case 'P':
        SNARFWORD;
@@ -659,9 +690,9 @@ yylex()
            XTERM(PRINTF);
        }
        if (strEQ(d,"push"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"pop"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'q': case 'Q':
        SNARFWORD;
@@ -669,8 +700,8 @@ yylex()
     case 'r': case 'R':
        SNARFWORD;
        if (strEQ(d,"RS")) {
-           d = "/";
            saw_RS = TRUE;
+           ID("/");
        }
        if (strEQ(d,"rand")) {
            yylval = ORAND;
@@ -679,11 +710,11 @@ yylex()
        if (strEQ(d,"return"))
            XTERM(RET);
        if (strEQ(d,"reset"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"redo"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"rename"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 's': case 'S':
        SNARFWORD;
@@ -697,14 +728,21 @@ yylex()
        }
        if (strEQ(d,"sub"))
            XTERM(SUB);
-       if (strEQ(d,"sprintf"))
-           XTERM(SPRINTF);
+       if (strEQ(d,"sprintf")) {
+            /* In old awk, { print sprintf("str%sg"),"in" } prints
+             * "string"; in new awk, "in" is not considered an argument to
+             * sprintf, so the statement breaks.  To support both, the
+             * grammar treats arguments to SPRINTF_OLD like old awk,
+             * SPRINTF_NEW like new.  Here we return the appropriate one.
+             */
+           XTERM(old_awk ? SPRINTF_OLD : SPRINTF_NEW);
+        }
        if (strEQ(d,"sqrt")) {
            yylval = OSQRT;
            XTERM(FUN1);
        }
        if (strEQ(d,"SUBSEP")) {
-           d = ";";
+           ID(";");
        }
        if (strEQ(d,"sin")) {
            yylval = OSIN;
@@ -719,73 +757,73 @@ yylex()
            XTERM(FUN1);
        }
        if (strEQ(d,"s"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"shift"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"select"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"seek"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"stat"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"study"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"sleep"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"symlink"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"sort"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 't': case 'T':
        SNARFWORD;
        if (strEQ(d,"tr"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"tell"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"time"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"times"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'u': case 'U':
        SNARFWORD;
        if (strEQ(d,"until"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"unless"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"umask"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"unshift"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"unlink"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"utime"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'v': case 'V':
        SNARFWORD;
        if (strEQ(d,"values"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'w': case 'W':
        SNARFWORD;
        if (strEQ(d,"while"))
            XTERM(WHILE);
        if (strEQ(d,"write"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        else if (strEQ(d,"wait"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'x': case 'X':
        SNARFWORD;
        if (strEQ(d,"x"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'y': case 'Y':
        SNARFWORD;
        if (strEQ(d,"y"))
-           *d = toupper(*d);
+           *d = toUPPER(*d);
        ID(d);
     case 'z': case 'Z':
        SNARFWORD;
@@ -794,8 +832,7 @@ yylex()
 }
 
 char *
-scanpat(s)
-register char *s;
+scanpat(register char *s)
 {
     register char *d;
 
@@ -840,16 +877,14 @@ register char *s;
 }
 
 void
-yyerror(s)
-char *s;
+yyerror(const char *s)
 {
     fprintf(stderr,"%s in file %s at line %d\n",
       s,filename,line);
 }
 
 char *
-scannum(s)
-register char *s;
+scannum(register char *s)
 {
     register char *d;
 
@@ -857,13 +892,13 @@ register char *s;
     case '1': case '2': case '3': case '4': case '5':
     case '6': case '7': case '8': case '9': case '0' : case '.':
        d = tokenbuf;
-       while (isdigit(*s)) {
+       while (isDIGIT(*s)) {
            *d++ = *s++;
        }
        if (*s == '.') {
-           if (isdigit(s[1])) {
+           if (isDIGIT(s[1])) {
                *d++ = *s++;
-               while (isdigit(*s)) {
+               while (isDIGIT(*s)) {
                    *d++ = *s++;
                }
            }
@@ -874,7 +909,7 @@ register char *s;
            *d++ = *s++;
            if (*s == '+' || *s == '-')
                *d++ = *s++;
-           while (isdigit(*s))
+           while (isDIGIT(*s))
                *d++ = *s++;
        }
        *d = '\0';
@@ -885,16 +920,14 @@ register char *s;
 }
 
 int
-string(ptr,len)
-char *ptr;
-int len;
+string(const char *ptr, int len)
 {
     int retval = mop;
 
     ops[mop++].ival = OSTRING + (1<<8);
     if (!len)
        len = strlen(ptr);
-    ops[mop].cval = safemalloc(len+1);
+    ops[mop].cval = (char *) safemalloc(len+1);
     strncpy(ops[mop].cval,ptr,len);
     ops[mop++].cval[len] = '\0';
     if (mop >= OPSMAX)
@@ -903,8 +936,7 @@ int len;
 }
 
 int
-oper0(type)
-int type;
+oper0(int type)
 {
     int retval = mop;
 
@@ -917,9 +949,7 @@ int type;
 }
 
 int
-oper1(type,arg1)
-int type;
-int arg1;
+oper1(int type, int arg1)
 {
     int retval = mop;
 
@@ -933,10 +963,7 @@ int arg1;
 }
 
 int
-oper2(type,arg1,arg2)
-int type;
-int arg1;
-int arg2;
+oper2(int type, int arg1, int arg2)
 {
     int retval = mop;
 
@@ -951,11 +978,7 @@ int arg2;
 }
 
 int
-oper3(type,arg1,arg2,arg3)
-int type;
-int arg1;
-int arg2;
-int arg3;
+oper3(int type, int arg1, int arg2, int arg3)
 {
     int retval = mop;
 
@@ -971,12 +994,7 @@ int arg3;
 }
 
 int
-oper4(type,arg1,arg2,arg3,arg4)
-int type;
-int arg1;
-int arg2;
-int arg3;
-int arg4;
+oper4(int type, int arg1, int arg2, int arg3, int arg4)
 {
     int retval = mop;
 
@@ -993,13 +1011,7 @@ int arg4;
 }
 
 int
-oper5(type,arg1,arg2,arg3,arg4,arg5)
-int type;
-int arg1;
-int arg2;
-int arg3;
-int arg4;
-int arg5;
+oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5)
 {
     int retval = mop;
 
@@ -1019,8 +1031,7 @@ int arg5;
 int depth = 0;
 
 void
-dump(branch)
-int branch;
+dump(int branch)
 {
     register int type;
     register int len;
@@ -1047,9 +1058,7 @@ int branch;
 }
 
 int
-bl(arg,maybe)
-int arg;
-int maybe;
+bl(int arg, int maybe)
 {
     if (!arg)
        return 0;
@@ -1062,8 +1071,7 @@ int maybe;
 }
 
 void
-fixup(str)
-STR *str;
+fixup(STR *str)
 {
     register char *s;
     register char *t;
@@ -1074,9 +1082,9 @@ STR *str;
            s++;
        }
        else if (*s == '\n') {
-           for (t = s+1; isspace(*t & 127); t++) ;
+           for (t = s+1; isSPACE(*t & 127); t++) ;
            t--;
-           while (isspace(*t & 127) && *t != '\n') t--;
+           while (isSPACE(*t & 127) && *t != '\n') t--;
            if (*t == '\n' && t-s > 1) {
                if (s[-1] == '{')
                    s--;
@@ -1088,8 +1096,7 @@ STR *str;
 }
 
 void
-putlines(str)
-STR *str;
+putlines(STR *str)
 {
     register char *d, *s, *t, *e;
     register int pos, newpos;
@@ -1110,7 +1117,7 @@ STR *str;
        if (pos > 78) {         /* split a long line? */
            *d-- = '\0';
            newpos = 0;
-           for (t = tokenbuf; isspace(*t & 127); t++) {
+           for (t = tokenbuf; isSPACE(*t & 127); t++) {
                if (*t == '\t')
                    newpos += 8;
                else
@@ -1165,7 +1172,7 @@ STR *str;
 }
 
 void
-putone()
+putone(void)
 {
     register char *t;
 
@@ -1188,8 +1195,7 @@ putone()
 }
 
 int
-numary(arg)
-int arg;
+numary(int arg)
 {
     STR *key;
     int dummy;
@@ -1203,8 +1209,7 @@ int arg;
 }
 
 int
-rememberargs(arg)
-int arg;
+rememberargs(int arg)
 {
     int type;
     STR *str;
@@ -1226,8 +1231,7 @@ int arg;
 }
 
 int
-aryrefarg(arg)
-int arg;
+aryrefarg(int arg)
 {
     int type = ops[arg].ival & 255;
     STR *str;
@@ -1241,14 +1245,11 @@ int arg;
 }
 
 int
-fixfargs(name,arg,prevargs)
-int name;
-int arg;
-int prevargs;
+fixfargs(int name, int arg, int prevargs)
 {
     int type;
     STR *str;
-    int numargs;
+    int numargs = 0;
 
     if (!arg)
        return prevargs;
@@ -1280,10 +1281,7 @@ int prevargs;
 }
 
 int
-fixrargs(name,arg,prevargs)
-char *name;
-int arg;
-int prevargs;
+fixrargs(char *name, int arg, int prevargs)
 {
     int type;
     STR *str;
@@ -1297,10 +1295,10 @@ int prevargs;
        numargs = fixrargs(name,ops[arg+3].ival,numargs);
     }
     else {
-       char tmpbuf[128];
-
+       char *tmpbuf = (char *) 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;