[hackers] [sbase] code-style: minor cleanup and nitpicking || Hiltjo Posthuma
commit 58e6b6096f2b9d86cef3b5fa2096fd5cccd47fc5
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Feb 20 13:28:24 2015 +0100
code-style: minor cleanup and nitpicking
diff --git a/env.c b/env.c
index 9d420ef..2b00902 100644
--- a/env.c
+++ b/env.c
_AT_@ -20,7 +20,7 @@ main(int argc, char *argv[])
{
ARGBEGIN {
case 'i':
- if(environ)
+ if (environ)
*environ = NULL;
break;
case 'u':
diff --git a/expr.c b/expr.c
index e98255e..bffbf31 100644
--- a/expr.c
+++ b/expr.c
_AT_@ -80,10 +80,10 @@ doop(int *op, int **opp, Val *val, Val **valp)
break;
case '=': ret = (Val){ NULL, valcmp(a, b) == 0 }; break;
case '>': ret = (Val){ NULL, valcmp(a, b) > 0 }; break;
- case GE : ret = (Val){ NULL, valcmp(a, b) >= 0 }; break;
+ case GE: ret = (Val){ NULL, valcmp(a, b) >= 0 }; break;
case '<': ret = (Val){ NULL, valcmp(a, b) < 0 }; break;
- case LE : ret = (Val){ NULL, valcmp(a, b) <= 0 }; break;
- case NE : ret = (Val){ NULL, valcmp(a, b) != 0 }; break;
+ case LE: ret = (Val){ NULL, valcmp(a, b) <= 0 }; break;
+ case NE: ret = (Val){ NULL, valcmp(a, b) != 0 }; break;
case '+': enan(a); enan(b); ret = (Val){ NULL, a.n + b.n }; break;
case '-': enan(a); enan(b); ret = (Val){ NULL, a.n - b.n }; break;
diff --git a/logger.c b/logger.c
index 0eb1156..5e1c0a4 100644
--- a/logger.c
+++ b/logger.c
_AT_@ -69,7 +69,7 @@ main(int argc, char *argv[])
openlog(tag ? tag : getlogin(), logflags, 0);
if (argc == 0) {
- while(getline(&buf, &sz, stdin) != -1)
+ while (getline(&buf, &sz, stdin) != -1)
syslog(priority, "%s", buf);
if (ferror(stdin))
eprintf("%s: read error:", "<stdin>");
diff --git a/sed.c b/sed.c
index 057c5a5..f848025 100644
--- a/sed.c
+++ b/sed.c
_AT_@ -820,6 +820,7 @@ char *
get_s_arg(Cmd *c, char *s)
{
Rune delim, r;
+ Cmd buf;
char *p;
int esc;
_AT_@ -901,13 +902,13 @@ get_s_arg(Cmd *c, char *s)
for (; s < p; s++) {
if (isdigit(*s)) {
c->u.s.occurrence = stol(s, &s);
- } else switch (*s) {
- case 'p' : c->u.s.p = 1; break;
- case 'g' : c->u.s.occurrence = 0; break;
- case 'w' : {
+ } else {
+ switch (*s) {
+ case 'g': c->u.s.occurrence = 0; break;
+ case 'p': c->u.s.p = 1; break;
+ case 'w':
/* must be last flag, take everything up to newline/semicolon
* s == p after this */
- Cmd buf;
s = get_w_arg(&buf, s);
c->u.s.file = buf.u.file;
break;
_AT_@ -927,7 +928,6 @@ free_s_arg(Cmd *c)
free(c->u.s.repl.str);
}
-
/* see get_r_arg notes */
char *
get_w_arg(Cmd *c, char *s)
_AT_@ -1092,13 +1092,13 @@ match_addr(Addr *a)
switch (a->type) {
default:
case IGNORE: return 0;
- case EVERY : return 1;
- case LINE : return lineno == a->u.lineno;
- case LAST :
+ case EVERY: return 1;
+ case LINE: return lineno == a->u.lineno;
+ case LAST:
while (is_eof(file) && !next_file())
;
return !file;
- case REGEX :
+ case REGEX:
lastre = a->u.re;
return !regexec(a->u.re, patt.str, 0, NULL, 0);
case LASTRE:
diff --git a/seq.c b/seq.c
index e3e856b..45bcae4 100644
--- a/seq.c
+++ b/seq.c
_AT_@ -27,7 +27,7 @@ main(int argc, char *argv[])
ARGBEGIN {
case 'f':
- if(!validfmt(tmp=EARGF(usage())))
+ if (!validfmt(tmp=EARGF(usage())))
eprintf("%s: invalid format\n", tmp);
fmt = tmp;
break;
diff --git a/sort.c b/sort.c
index 031343e..29e9c68 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -254,7 +254,7 @@ parse_keydef(struct keydef *kd, char *s, int flags)
static char *
skipblank(char *s)
{
- while(*s && isblank(*s))
+ while (*s && isblank(*s))
s++;
return s;
}
_AT_@ -264,7 +264,7 @@ nextcol(char *s)
{
if (!fieldsep) {
s = skipblank(s);
- while(*s && !isblank(*s))
+ while (*s && !isblank(*s))
s++;
} else {
if (!strchr(s, *fieldsep))
diff --git a/tail.c b/tail.c
index 491861e..dc77a68 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -130,7 +130,7 @@ main(int argc, char *argv[])
if (fflag && argc == 1) {
tmp = NULL;
tmpsize = 0;
- for(;;) {
+ for (;;) {
while (getline(&tmp, &tmpsize, fp) != -1) {
fputs(tmp, stdout);
fflush(stdout);
diff --git a/uuencode.c b/uuencode.c
index 55ac6d1..11e9f02 100644
--- a/uuencode.c
+++ b/uuencode.c
_AT_@ -44,7 +44,7 @@ uuencodeb64(FILE *fp, const char *name, const char *s)
if (m != 0) {
unsigned int mask = 0xffffffff, dest = 0x3d3d3d3d;
/* m==2 -> 0x00ffffff; m==1 -> 0x0000ffff */
- mask >>= ((3-m) << 3);
+ mask >>= ((3-m) << 3);
po[-1] = (po[-1] & mask) | (dest & ~mask);
}
*po++ = '\n';
Received on Fri Feb 20 2015 - 14:30:27 CET
This archive was generated by hypermail 2.3.0
: Fri Feb 20 2015 - 14:36:11 CET