summaryrefslogtreecommitdiff
path: root/bin/ksh/syn.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-12-20 11:34:27 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-12-20 11:34:27 +0000
commite445c3ad8a040ce5aa9ffd47e72de71f7cd3dd16 (patch)
treef321abeceffdba61fb97e64b666e8793cf6e1d4e /bin/ksh/syn.c
parentc6e78b160bb0e446bb146be6b8b66890b48e5b31 (diff)
Ansification plus some minor knf. No binary change on i386 and
sparc64, binary change in lex.o on macppc due to introduction of dopprompt() prototype. ok millert@
Diffstat (limited to 'bin/ksh/syn.c')
-rw-r--r--bin/ksh/syn.c134
1 files changed, 51 insertions, 83 deletions
diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c
index 2d1ed02536c..d97fedadc54 100644
--- a/bin/ksh/syn.c
+++ b/bin/ksh/syn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syn.c,v 1.18 2004/12/18 22:42:26 millert Exp $ */
+/* $OpenBSD: syn.c,v 1.19 2004/12/20 11:34:26 otto Exp $ */
/*
* shell parser (C version)
@@ -13,33 +13,32 @@ struct nesting_state {
};
static void yyparse(void);
-static struct op *pipeline(int cf);
+static struct op *pipeline(int);
static struct op *andor(void);
-static struct op *c_list(int multi);
-static struct ioword *synio(int cf);
-static void musthave(int c, int cf);
-static struct op *nested(int type, int smark, int emark);
-static struct op *get_command(int cf);
+static struct op *c_list(int);
+static struct ioword *synio(int);
+static void musthave(int, int);
+static struct op *nested(int, int, int);
+static struct op *get_command(int);
static struct op *dogroup(void);
static struct op *thenpart(void);
static struct op *elsepart(void);
static struct op *caselist(void);
-static struct op *casepart(int endtok);
-static struct op *function_body(char *name, int ksh_func);
+static struct op *casepart(int);
+static struct op *function_body(char *, int);
static char ** wordlist(void);
-static struct op *block(int type, struct op *t1, struct op *t2, char **wp);
-static struct op *newtp(int type);
-static void syntaxerr(const char *what)
- __attribute__((__noreturn__));
-static void nesting_push(struct nesting_state *save, int tok);
-static void nesting_pop(struct nesting_state *saved);
-static int assign_command(char *s);
-static int inalias(struct source *s);
-static int dbtestp_isa(Test_env *te, Test_meta meta);
-static const char *dbtestp_getopnd(Test_env *te, Test_op op, int do_eval);
-static int dbtestp_eval(Test_env *te, Test_op op, const char *opnd1,
- const char *opnd2, int do_eval);
-static void dbtestp_error(Test_env *te, int offset, const char *msg);
+static struct op *block(int, struct op *, struct op *, char **);
+static struct op *newtp(int);
+static void syntaxerr(const char *) __attribute__((__noreturn__));
+static void nesting_push(struct nesting_state *, int);
+static void nesting_pop(struct nesting_state *);
+static int assign_command(char *);
+static int inalias(struct source *);
+static int dbtestp_isa(Test_env *, Test_meta);
+static const char *dbtestp_getopnd(Test_env *, Test_op, int);
+static int dbtestp_eval(Test_env *, Test_op, const char *, const char *,
+ int);
+static void dbtestp_error(Test_env *, int, const char *);
static struct op *outtree; /* yyparse output */
@@ -56,7 +55,7 @@ static int symbol; /* yylex value */
((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
static void
-yyparse()
+yyparse(void)
{
int c;
@@ -71,8 +70,7 @@ yyparse()
}
static struct op *
-pipeline(cf)
- int cf;
+pipeline(int cf)
{
struct op *t, *p, *tl = NULL;
@@ -92,7 +90,7 @@ pipeline(cf)
}
static struct op *
-andor()
+andor(void)
{
struct op *t, *p;
int c;
@@ -110,8 +108,7 @@ andor()
}
static struct op *
-c_list(multi)
- int multi;
+c_list(int multi)
{
struct op *t = NULL, *p, *tl = NULL;
int c;
@@ -148,8 +145,7 @@ c_list(multi)
}
static struct ioword *
-synio(cf)
- int cf;
+synio(int cf)
{
struct ioword *iop;
int ishere;
@@ -173,16 +169,14 @@ synio(cf)
}
static void
-musthave(c, cf)
- int c, cf;
+musthave(int c, int cf)
{
if ((token(cf)) != c)
syntaxerr((char *) 0);
}
static struct op *
-nested(type, smark, emark)
- int type, smark, emark;
+nested(int type, int smark, int emark)
{
struct op *t;
struct nesting_state old_nesting;
@@ -195,8 +189,7 @@ nested(type, smark, emark)
}
static struct op *
-get_command(cf)
- int cf;
+get_command(int cf)
{
struct op *t;
int c, iopn = 0, syniocf;
@@ -408,7 +401,7 @@ get_command(cf)
}
static struct op *
-dogroup()
+dogroup(void)
{
int c;
struct op *list;
@@ -431,7 +424,7 @@ dogroup()
}
static struct op *
-thenpart()
+thenpart(void)
{
struct op *t;
@@ -445,7 +438,7 @@ thenpart()
}
static struct op *
-elsepart()
+elsepart(void)
{
struct op *t;
@@ -468,7 +461,7 @@ elsepart()
}
static struct op *
-caselist()
+caselist(void)
{
struct op *t, *tl;
int c;
@@ -494,8 +487,7 @@ caselist()
}
static struct op *
-casepart(endtok)
- int endtok;
+casepart(int endtok)
{
struct op *t;
int c;
@@ -523,9 +515,8 @@ casepart(endtok)
}
static struct op *
-function_body(name, ksh_func)
- char *name;
- int ksh_func; /* function foo { ... } vs foo() { .. } */
+function_body(char *name,
+ int ksh_func) /* function foo { ... } vs foo() { .. } */
{
char *sname, *p;
struct op *t;
@@ -584,7 +575,7 @@ function_body(name, ksh_func)
}
static char **
-wordlist()
+wordlist(void)
{
int c;
XPtrV args;
@@ -614,10 +605,7 @@ wordlist()
*/
static struct op *
-block(type, t1, t2, wp)
- int type;
- struct op *t1, *t2;
- char **wp;
+block(int type, struct op *t1, struct op *t2, char **wp)
{
struct op *t;
@@ -666,7 +654,7 @@ const struct tokeninfo {
};
void
-initkeywords()
+initkeywords(void)
{
struct tokeninfo const *tt;
struct tbl *p;
@@ -683,8 +671,7 @@ initkeywords()
}
static void
-syntaxerr(what)
- const char *what;
+syntaxerr(const char *what)
{
char redir[6]; /* 2<<- is the longest redirection, I think */
const char *s;
@@ -736,9 +723,7 @@ syntaxerr(what)
}
static void
-nesting_push(save, tok)
- struct nesting_state *save;
- int tok;
+nesting_push(struct nesting_state *save, int tok)
{
*save = nesting;
nesting.start_token = tok;
@@ -746,15 +731,13 @@ nesting_push(save, tok)
}
static void
-nesting_pop(saved)
- struct nesting_state *saved;
+nesting_pop(struct nesting_state *saved)
{
nesting = *saved;
}
static struct op *
-newtp(type)
- int type;
+newtp(int type)
{
struct op *t;
@@ -769,8 +752,7 @@ newtp(type)
}
struct op *
-compile(s)
- Source *s;
+compile(Source *s)
{
nesting.start_token = 0;
nesting.start_line = 0;
@@ -791,8 +773,7 @@ compile(s)
* $
*/
static int
-assign_command(s)
- char *s;
+assign_command(char *s)
{
char c = *s;
@@ -806,8 +787,7 @@ assign_command(s)
/* Check if we are in the middle of reading an alias */
static int
-inalias(s)
- struct source *s;
+inalias(struct source *s)
{
for (; s && s->type == SALIAS; s = s->next)
if (!(s->flags & SF_ALIASEND))
@@ -839,9 +819,7 @@ const char db_gthan[] = { CHAR, '>', EOS };
* TM_UNOP and TM_BINOP, the returned value is a Test_op).
*/
static int
-dbtestp_isa(te, meta)
- Test_env *te;
- Test_meta meta;
+dbtestp_isa(Test_env *te, Test_meta meta)
{
int c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN));
int uqword = 0;
@@ -885,10 +863,7 @@ dbtestp_isa(te, meta)
}
static const char *
-dbtestp_getopnd(te, op, do_eval)
- Test_env *te;
- Test_op op;
- int do_eval;
+dbtestp_getopnd(Test_env *te, Test_op op, int do_eval)
{
int c = tpeek(ARRAYVAR);
@@ -902,21 +877,14 @@ dbtestp_getopnd(te, op, do_eval)
}
static int
-dbtestp_eval(te, op, opnd1, opnd2, do_eval)
- Test_env *te;
- Test_op op;
- const char *opnd1;
- const char *opnd2;
- int do_eval;
+dbtestp_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
+ int do_eval)
{
return 1;
}
static void
-dbtestp_error(te, offset, msg)
- Test_env *te;
- int offset;
- const char *msg;
+dbtestp_error(Test_env *te, int offset, const char *msg)
{
te->flags |= TEF_ERROR;