code: plan9front

Download patch

ref: a6e8789ff9b5412cb207f7adcf31fcf831d9bc00
parent: fc1d4d1b24669d870a45310f8122e6b10ff953d0
author: Jacob Moody <moody@posixcafe.org>
date: Sun Jul 23 02:29:48 EDT 2023

ape/expr: ansi-ify function declarations

--- a/sys/src/ape/cmd/expr/expr.y
+++ b/sys/src/ape/cmd/expr/expr.y
@@ -71,7 +71,9 @@
 extern int nbra;
 int yyparse(void);
 
-main(argc, argv) char **argv; {
+void
+main(int argc, char **argv)
+{
 	Ac = argc;
 	Argi = 1;
 	Av = argv;
@@ -102,7 +104,9 @@
 	return A_STRING;
 }
 
-char *rel(op, r1, r2) register char *r1, *r2; {
+char*
+rel(int op, char *r1, char *r2)
+{
 	register i;
 
 	if(ematch(r1, "-\\{0,1\\}[0-9]*$") && ematch(r2, "-\\{0,1\\}[0-9]*$"))
@@ -120,7 +124,9 @@
 	return i? "1": "0";
 }
 
-char *arith(op, r1, r2) char *r1, *r2; {
+char*
+arith(int op, char *r1, char *r2)
+{
 	long i1, i2;
 	register char *rv;
 
@@ -140,7 +146,9 @@
 	strcpy(rv, ltoa(i1));
 	return rv;
 }
-char *conj(op, r1, r2) char *r1, *r2; {
+char*
+conj(int op, char *r1, char *r2)
+{
 	register char *rv;
 
 	switch(op) {
@@ -170,7 +178,9 @@
 	return rv;
 }
 
-char *substr(v, s, w) char *v, *s, *w; {
+char*
+substr(char *v, char *s, char *w)
+{
 register si, wi;
 register char *res;
 
@@ -186,7 +196,9 @@
 	return res;
 }
 
-char *length(s) register char *s; {
+char*
+length(char *s)
+{
 	register i = 0;
 	register char *rv;
 
@@ -197,7 +209,9 @@
 	return rv;
 }
 
-char *index(s, t) char *s, *t; {
+char*
+index(char *s, char *t)
+{
 	register i, j;
 	register char *rv;
 
@@ -210,9 +224,8 @@
 	return "0";
 }
 
-char *match(s, p)
-char *s;
-register char *p;
+char*
+match(char *s, char *p)
 {
 	register char *rv;
 
@@ -231,10 +244,8 @@
 #define RETURN(c)	return
 #define ERROR(c)	errxx(c)
 
-
-ematch(s, p)
-char *s;
-register char *p;
+int
+ematch(char *s, char *p)
 {
 	static char expbuf[ESIZE];
 	char *compile();
@@ -256,27 +267,25 @@
 	return(0);
 }
 
-errxx(c)
+errxx(int c)
 {
 	yyerror("RE error");
 }
 
 #include  "regexp.h"
-yyerror(s)
-
+yyerror(char *s)
 {
 	write(2, "expr: ", 6);
 	prt(2, s);
 	exit(2);
 }
-prt(fd, s)
-char *s;
+prt(int fd, char *s)
 {
 	write(fd, s, strlen(s));
 	write(fd, "\n", 1);
 }
-char *ltoa(l)
-long l;
+char*
+ltoa(long l)
 {
 	static char str[20];
 	register char *sp = &str[18];
--- a/sys/src/ape/cmd/expr/regexp.h
+++ b/sys/src/ape/cmd/expr/regexp.h
@@ -37,9 +37,7 @@
 };
 
 char *
-compile(instring, ep, endbuf, seof)
-register char *ep;
-char *instring, *endbuf;
+compile(char *instring, char *ep, char *endbuf, int seof)
 {
 	INIT	/* Dependent declarations and initializations */
 	register c;
@@ -215,8 +213,7 @@
 	}
 }
 
-step(p1, p2)
-register char *p1, *p2;
+step(char *p1, char *p2)
 {
 	register c;
 
@@ -247,8 +244,7 @@
 	return(0);
 }
 
-advance(lp, ep)
-register char *lp, *ep;
+advance(char *lp, char *ep)
 {
 	register char *curlp;
 	char c;
@@ -393,16 +389,13 @@
 	}
 }
 
-getrnge(str)
-register char *str;
+getrnge(char *str)
 {
 	low = *str++ & 0377;
 	size = *str == 255 ? 20000 : (*str &0377) - low;
 }
 
-ecmp(a, b, count)
-register char	*a, *b;
-register	count;
+ecmp(char *a, char *b, int count)
 {
 	while(count--)
 		if(*a++ != *b++)	return(0);