From d2b5538f556ba8fe9b05c652b2d5a4b71203567a Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 7 Apr 2009 19:13:11 +0000 Subject: [PATCH] some int->bool, KNF, ... --- exec.c | 8 ++++---- lex.c | 7 +++---- syn.c | 9 ++++----- tree.c | 11 ++++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/exec.c b/exec.c index 4b9bbff..e6b7152 100644 --- a/exec.c +++ b/exec.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.53 2009/03/22 18:28:34 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.54 2009/04/07 19:13:09 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, const char **, int volatile, volatile int *); @@ -811,13 +811,13 @@ int define(const char *name, struct op *t) { struct tbl *tp; - int was_set = 0; + bool was_set = false; while (1) { tp = findfunc(name, hash(name), true); if (tp->flag & ISSET) - was_set = 1; + was_set = true; /* If this function is currently being executed, we zap this * table entry so findfunc() won't see it */ @@ -836,7 +836,7 @@ define(const char *name, struct op *t) if (t == NULL) { /* undefine */ ktdelete(tp); - return was_set ? 0 : 1; + return (was_set ? 0 : 1); } tp->val.t = tcopy(t->left, tp->areap); diff --git a/lex.c b/lex.c index b310361..fd57165 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.81 2009/04/07 19:06:43 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.82 2009/04/07 19:13:10 tg Exp $"); /* * states while lexing word @@ -78,11 +78,10 @@ struct lex_state { } ls_info; }; -typedef struct State_info State_info; -struct State_info { +typedef struct { Lex_state *base; Lex_state *end; -}; +} State_info; static void readhere(struct ioword *); static int getsc__(void); diff --git a/syn.c b/syn.c index ad35e03..c180595 100644 --- a/syn.c +++ b/syn.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.33 2009/04/07 19:06:43 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.34 2009/04/07 19:13:11 tg Exp $"); struct nesting_state { int start_token; /* token than began nesting (eg, FOR) */ @@ -107,8 +107,7 @@ static struct op * c_list(int multi) { struct op *t = NULL, *p, *tl = NULL; - int c; - int have_sep; + int c, have_sep; while (1) { p = andor(); @@ -145,7 +144,7 @@ synio(int cf) { struct ioword *iop; static struct ioword *nextiop = NULL; - int ishere; + bool ishere; if (nextiop != NULL) { iop = nextiop; @@ -581,7 +580,7 @@ function_body(char *name, { char *sname, *p; struct op *t; - int old_func_parse; + bool old_func_parse; sname = wdstrip(name, false, false); /* Check for valid characters in name. posix and ksh93 say only diff --git a/tree.c b/tree.c index bace2fd..6edd722 100644 --- a/tree.c +++ b/tree.c @@ -2,11 +2,11 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.24 2008/12/13 17:02:17 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.25 2009/04/07 19:13:11 tg Exp $"); #define INDENT 4 -#define tputc(c, shf) shf_putchar(c, shf); +#define tputc(c, shf) shf_putchar(c, shf); static void ptree(struct op *, int, struct shf *); static void pioact(struct shf *, int, struct ioword *); static void tputC(int, struct shf *); @@ -252,7 +252,8 @@ tputC(int c, struct shf *shf) static void tputS(char *wp, struct shf *shf) { - int c, quoted=0; + int c; + bool quoted = false; /* problems: * `...` -> $(...) @@ -290,11 +291,11 @@ tputS(char *wp, struct shf *shf) wp++; break; case OQUOTE: - quoted = 1; + quoted = true; tputc('"', shf); break; case CQUOTE: - quoted = 0; + quoted = false; tputc('"', shf); break; case OSUBST: