summaryrefslogtreecommitdiff
path: root/x2p
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>1997-10-31 23:54:01 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>1997-10-31 23:54:01 +0000
commitf0f333f45536802923a359d930d1dcfd5b4589ea (patch)
tree6f746f4b9cda56e2432754d6816467676c601820 /x2p
parent8ac853655d9b744749adcb9687c13d99cdd6e9fb (diff)
downloadperl-f0f333f45536802923a359d930d1dcfd5b4589ea.tar.gz
Further ANSI changes now builds and passes (most) tests
with gcc -x c++. p4raw-id: //depot/ansiperl@196
Diffstat (limited to 'x2p')
-rw-r--r--x2p/a2p.c2
-rw-r--r--x2p/a2p.h4
-rw-r--r--x2p/a2py.c105
-rw-r--r--x2p/hash.c26
-rw-r--r--x2p/str.c84
-rw-r--r--x2p/util.c41
-rw-r--r--x2p/walk.c36
7 files changed, 91 insertions, 207 deletions
diff --git a/x2p/a2p.c b/x2p/a2p.c
index 340e4bfad6..e79e156203 100644
--- a/x2p/a2p.c
+++ b/x2p/a2p.c
@@ -2014,7 +2014,9 @@ yyparse()
register int yym, yyn, yystate;
#if YYDEBUG
register char *yys;
+#ifndef __cplusplus
extern char *getenv();
+#endif
if (yys = getenv("YYDEBUG"))
{
diff --git a/x2p/a2p.h b/x2p/a2p.h
index b00b0723ea..085935d98f 100644
--- a/x2p/a2p.h
+++ b/x2p/a2p.h
@@ -63,10 +63,10 @@
# include <strings.h>
#endif
-#ifndef HAS_BCOPY
+#if !defined(HAS_BCOPY) || defined(__cplusplus)
# define bcopy(s1,s2,l) memcpy(s2,s1,l)
#endif
-#ifndef HAS_BZERO
+#if !defined(HAS_BZERO) || defined(__cplusplus)
# define bzero(s,l) memset(s,0,l)
#endif
diff --git a/x2p/a2py.c b/x2p/a2py.c
index 3a3cb5275d..202d5921e0 100644
--- a/x2p/a2py.c
+++ b/x2p/a2py.c
@@ -18,13 +18,13 @@ 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 OS2
static void
@@ -44,10 +44,7 @@ usage()
#endif
int
-main(argc,argv,env)
-register int argc;
-register char **argv;
-register char **env;
+main(register int argc, register char **argv, register char **env)
{
register STR *str;
int i;
@@ -200,7 +197,7 @@ register char **env;
int idtype;
int
-yylex()
+yylex(void)
{
register char *s = bufptr;
register char *d;
@@ -794,8 +791,7 @@ yylex()
}
char *
-scanpat(s)
-register char *s;
+scanpat(register char *s)
{
register char *d;
@@ -840,16 +836,14 @@ register char *s;
}
void
-yyerror(s)
-char *s;
+yyerror(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;
@@ -885,16 +879,14 @@ register char *s;
}
int
-string(ptr,len)
-char *ptr;
-int len;
+string(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 +895,7 @@ int len;
}
int
-oper0(type)
-int type;
+oper0(int type)
{
int retval = mop;
@@ -917,9 +908,7 @@ int type;
}
int
-oper1(type,arg1)
-int type;
-int arg1;
+oper1(int type, int arg1)
{
int retval = mop;
@@ -933,10 +922,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 +937,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 +953,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 +970,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 +990,7 @@ int arg5;
int depth = 0;
void
-dump(branch)
-int branch;
+dump(int branch)
{
register int type;
register int len;
@@ -1047,9 +1017,7 @@ int branch;
}
int
-bl(arg,maybe)
-int arg;
-int maybe;
+bl(int arg, int maybe)
{
if (!arg)
return 0;
@@ -1062,8 +1030,7 @@ int maybe;
}
void
-fixup(str)
-STR *str;
+fixup(STR *str)
{
register char *s;
register char *t;
@@ -1088,8 +1055,7 @@ STR *str;
}
void
-putlines(str)
-STR *str;
+putlines(STR *str)
{
register char *d, *s, *t, *e;
register int pos, newpos;
@@ -1165,7 +1131,7 @@ STR *str;
}
void
-putone()
+putone(void)
{
register char *t;
@@ -1188,8 +1154,7 @@ putone()
}
int
-numary(arg)
-int arg;
+numary(int arg)
{
STR *key;
int dummy;
@@ -1203,8 +1168,7 @@ int arg;
}
int
-rememberargs(arg)
-int arg;
+rememberargs(int arg)
{
int type;
STR *str;
@@ -1226,8 +1190,7 @@ int arg;
}
int
-aryrefarg(arg)
-int arg;
+aryrefarg(int arg)
{
int type = ops[arg].ival & 255;
STR *str;
@@ -1241,10 +1204,7 @@ int arg;
}
int
-fixfargs(name,arg,prevargs)
-int name;
-int arg;
-int prevargs;
+fixfargs(int name, int arg, int prevargs)
{
int type;
STR *str;
@@ -1280,10 +1240,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,7 +1254,7 @@ int prevargs;
numargs = fixrargs(name,ops[arg+3].ival,numargs);
}
else {
- char *tmpbuf = safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5);
+ char *tmpbuf = (char *) safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5);
sprintf(tmpbuf,"%s:%d",name,prevargs);
str = hfetch(curarghash,tmpbuf);
safefree(tmpbuf);
diff --git a/x2p/hash.c b/x2p/hash.c
index 5859eab470..9f6bbe9015 100644
--- a/x2p/hash.c
+++ b/x2p/hash.c
@@ -14,9 +14,7 @@
#include "util.h"
STR *
-hfetch(tb,key)
-register HASH *tb;
-char *key;
+hfetch(register HASH *tb, char *key)
{
register char *s;
register int i;
@@ -42,10 +40,7 @@ char *key;
}
bool
-hstore(tb,key,val)
-register HASH *tb;
-char *key;
-STR *val;
+hstore(register HASH *tb, char *key, STR *val)
{
register char *s;
register int i;
@@ -133,8 +128,7 @@ char *key;
#endif
void
-hsplit(tb)
-HASH *tb;
+hsplit(HASH *tb)
{
int oldsize = tb->tbl_max + 1;
register int newsize = oldsize * 2;
@@ -171,7 +165,7 @@ HASH *tb;
}
HASH *
-hnew()
+hnew(void)
{
register HASH *tb = (HASH*)safemalloc(sizeof(HASH));
@@ -195,8 +189,7 @@ register HASH *tb;
#endif
int
-hiterinit(tb)
-register HASH *tb;
+hiterinit(register HASH *tb)
{
tb->tbl_riter = -1;
tb->tbl_eiter = Null(HENT*);
@@ -204,8 +197,7 @@ register HASH *tb;
}
HENT *
-hiternext(tb)
-register HASH *tb;
+hiternext(register HASH *tb)
{
register HENT *entry;
@@ -228,15 +220,13 @@ register HASH *tb;
}
char *
-hiterkey(entry)
-register HENT *entry;
+hiterkey(register HENT *entry)
{
return entry->hent_key;
}
STR *
-hiterval(entry)
-register HENT *entry;
+hiterval(register HENT *entry)
{
return entry->hent_val;
}
diff --git a/x2p/str.c b/x2p/str.c
index 88b3c60405..ff2dd7ce59 100644
--- a/x2p/str.c
+++ b/x2p/str.c
@@ -13,9 +13,7 @@
#include "util.h"
void
-str_numset(str,num)
-register STR *str;
-double num;
+str_numset(register STR *str, double num)
{
str->str_nval = num;
str->str_pok = 0; /* invalidate pointer */
@@ -23,8 +21,7 @@ double num;
}
char *
-str_2ptr(str)
-register STR *str;
+str_2ptr(register STR *str)
{
register char *s;
@@ -47,8 +44,7 @@ register STR *str;
}
double
-str_2num(str)
-register STR *str;
+str_2num(register STR *str)
{
if (!str)
return 0.0;
@@ -65,9 +61,7 @@ register STR *str;
}
void
-str_sset(dstr,sstr)
-STR *dstr;
-register STR *sstr;
+str_sset(STR *dstr, register STR *sstr)
{
if (!sstr)
str_nset(dstr,No,0);
@@ -80,10 +74,7 @@ register STR *sstr;
}
void
-str_nset(str,ptr,len)
-register STR *str;
-register char *ptr;
-register int len;
+str_nset(register STR *str, register char *ptr, register int len)
{
GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
bcopy(ptr,str->str_ptr,len);
@@ -94,9 +85,7 @@ register int len;
}
void
-str_set(str,ptr)
-register STR *str;
-register char *ptr;
+str_set(register STR *str, register char *ptr)
{
register int len;
@@ -111,9 +100,9 @@ register char *ptr;
}
void
-str_chop(str,ptr) /* like set but assuming ptr is in str */
-register STR *str;
-register char *ptr;
+str_chop(register STR *str, register char *ptr) /* like set but assuming ptr is in str */
+
+
{
if (!(str->str_pok))
str_2ptr(str);
@@ -124,10 +113,7 @@ register char *ptr;
}
void
-str_ncat(str,ptr,len)
-register STR *str;
-register char *ptr;
-register int len;
+str_ncat(register STR *str, register char *ptr, register int len)
{
if (!(str->str_pok))
str_2ptr(str);
@@ -140,9 +126,7 @@ register int len;
}
void
-str_scat(dstr,sstr)
-STR *dstr;
-register STR *sstr;
+str_scat(STR *dstr, register STR *sstr)
{
if (!(sstr->str_pok))
str_2ptr(sstr);
@@ -151,9 +135,7 @@ register STR *sstr;
}
void
-str_cat(str,ptr)
-register STR *str;
-register char *ptr;
+str_cat(register STR *str, register char *ptr)
{
register int len;
@@ -170,11 +152,7 @@ register char *ptr;
}
char *
-str_append_till(str,from,delim,keeplist)
-register STR *str;
-register char *from;
-register int delim;
-char *keeplist;
+str_append_till(register STR *str, register char *from, register int delim, char *keeplist)
{
register char *to;
register int len;
@@ -209,8 +187,7 @@ char *keeplist;
}
STR *
-str_new(len)
-int len;
+str_new(int len)
{
register STR *str;
@@ -228,9 +205,7 @@ int len;
}
void
-str_grow(str,len)
-register STR *str;
-int len;
+str_grow(register STR *str, int len)
{
if (len && str)
GROWSTR(&(str->str_ptr), &(str->str_len), len + 1);
@@ -239,9 +214,7 @@ int len;
/* make str point to what nstr did */
void
-str_replace(str,nstr)
-register STR *str;
-register STR *nstr;
+str_replace(register STR *str, register STR *nstr)
{
Safefree(str->str_ptr);
str->str_ptr = nstr->str_ptr;
@@ -254,8 +227,7 @@ register STR *nstr;
}
void
-str_free(str)
-register STR *str;
+str_free(register STR *str)
{
if (!str)
return;
@@ -269,8 +241,7 @@ register STR *str;
}
int
-str_len(str)
-register STR *str;
+str_len(register STR *str)
{
if (!str)
return 0;
@@ -283,9 +254,7 @@ register STR *str;
}
char *
-str_gets(str,fp)
-register STR *str;
-register FILE *fp;
+str_gets(register STR *str, register FILE *fp)
{
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
/* Here is some breathtakingly efficient cheating */
@@ -366,8 +335,7 @@ thats_all_folks:
}
void
-str_inc(str)
-register STR *str;
+str_inc(register STR *str)
{
register char *d;
@@ -403,8 +371,7 @@ register STR *str;
}
void
-str_dec(str)
-register STR *str;
+str_dec(register STR *str)
{
register char *d;
@@ -436,8 +403,7 @@ register STR *str;
/* make a string that will exist for the duration of the expression eval */
STR *
-str_mortal(oldstr)
-STR *oldstr;
+str_mortal(STR *oldstr)
{
register STR *str = str_new(0);
static long tmps_size = -1;
@@ -458,8 +424,7 @@ STR *oldstr;
}
STR *
-str_make(s)
-char *s;
+str_make(char *s)
{
register STR *str = str_new(0);
@@ -468,8 +433,7 @@ char *s;
}
STR *
-str_nmake(n)
-double n;
+str_nmake(double n)
{
register STR *str = str_new(0);
diff --git a/x2p/util.c b/x2p/util.c
index 469beb0c14..3d3b99a952 100644
--- a/x2p/util.c
+++ b/x2p/util.c
@@ -24,8 +24,7 @@ static char nomem[] = "Out of memory!\n";
Malloc_t
-safemalloc(size)
-MEM_SIZE size;
+safemalloc(size_t size)
{
Malloc_t ptr;
@@ -48,9 +47,7 @@ MEM_SIZE size;
/* paranoid version of realloc */
Malloc_t
-saferealloc(where,size)
-Malloc_t where;
-MEM_SIZE size;
+saferealloc(void *where, size_t size)
{
Malloc_t ptr;
@@ -74,8 +71,7 @@ MEM_SIZE size;
/* safe version of free */
Free_t
-safefree(where)
-Malloc_t where;
+safefree(void *where)
{
#ifdef DEBUGGING
if (debug & 128)
@@ -87,10 +83,7 @@ Malloc_t where;
/* safe version of string copy */
char *
-safecpy(to,from,len)
-char *to;
-register char *from;
-register int len;
+safecpy(char *to, register char *from, register int len)
{
register char *dest = to;
@@ -103,9 +96,7 @@ register int len;
/* copy a string up to some (non-backslashed) delimiter, if any */
char *
-cpytill(to,from,delim)
-register char *to, *from;
-register int delim;
+cpytill(register char *to, register char *from, register int delim)
{
for (; *from; from++,to++) {
if (*from == '\\') {
@@ -124,9 +115,7 @@ register int delim;
char *
-cpy2(to,from,delim)
-register char *to, *from;
-register int delim;
+cpy2(register char *to, register char *from, register int delim)
{
for (; *from; from++,to++) {
if (*from == '\\')
@@ -144,9 +133,7 @@ register int delim;
/* return ptr to little string in big string, NULL if not found */
char *
-instr(big, little)
-char *big, *little;
-
+instr(char *big, char *little)
{
register char *t, *s, *x;
@@ -166,10 +153,9 @@ char *big, *little;
/* copy a string to a safe spot */
char *
-savestr(str)
-char *str;
+savestr(char *str)
{
- register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1));
+ register char *newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1));
(void)strcpy(newaddr,str);
return newaddr;
@@ -178,16 +164,13 @@ char *str;
/* grow a static string to at least a certain length */
void
-growstr(strptr,curlen,newlen)
-char **strptr;
-int *curlen;
-int newlen;
+growstr(char **strptr, int *curlen, int newlen)
{
if (newlen > *curlen) { /* need more room? */
if (*curlen)
- *strptr = saferealloc(*strptr,(MEM_SIZE)newlen);
+ *strptr = (char *) saferealloc(*strptr,(MEM_SIZE)newlen);
else
- *strptr = safemalloc((MEM_SIZE)newlen);
+ *strptr = (char *) safemalloc((MEM_SIZE)newlen);
*curlen = newlen;
}
}
diff --git a/x2p/walk.c b/x2p/walk.c
index cb40073b22..0b4065586b 100644
--- a/x2p/walk.c
+++ b/x2p/walk.c
@@ -37,12 +37,12 @@ STR * walk _(( int useval, int level, int node, int *numericptr, int minprec ));
STR *
-walk(useval,level,node,numericptr,minprec)
-int useval;
-int level;
-register int node;
-int *numericptr;
-int minprec; /* minimum precedence without parens */
+walk(int useval, int level, register int node, int *numericptr, int minprec)
+
+
+
+
+ /* minimum precedence without parens */
{
register int len;
register STR *str;
@@ -1556,9 +1556,7 @@ sub Pick {\n\
}
static void
-tab(str,lvl)
-register STR *str;
-register int lvl;
+tab(register STR *str, register int lvl)
{
while (lvl > 1) {
str_cat(str,"\t");
@@ -1569,9 +1567,7 @@ register int lvl;
}
static void
-fixtab(str,lvl)
-register STR *str;
-register int lvl;
+fixtab(register STR *str, register int lvl)
{
register char *s;
@@ -1589,8 +1585,7 @@ register int lvl;
}
static void
-addsemi(str)
-register STR *str;
+addsemi(register STR *str)
{
register char *s;
@@ -1602,9 +1597,7 @@ register STR *str;
}
static void
-emit_split(str,level)
-register STR *str;
-int level;
+emit_split(register STR *str, int level)
{
register int i;
@@ -1637,11 +1630,7 @@ int level;
}
int
-prewalk(numit,level,node,numericptr)
-int numit;
-int level;
-register int node;
-int *numericptr;
+prewalk(int numit, int level, register int node, int *numericptr)
{
register int len;
register int type;
@@ -2058,8 +2047,7 @@ int *numericptr;
}
static void
-numericize(node)
-register int node;
+numericize(register int node)
{
register int len;
register int type;