code-style: minor cleanup and nitpicking

This commit is contained in:
Hiltjo Posthuma 2015-02-20 13:28:24 +01:00
parent 6c7ff5fda5
commit 31f0624f3d
8 changed files with 20 additions and 20 deletions

2
env.c
View File

@ -20,7 +20,7 @@ main(int argc, char *argv[])
{ {
ARGBEGIN { ARGBEGIN {
case 'i': case 'i':
if(environ) if (environ)
*environ = NULL; *environ = NULL;
break; break;
case 'u': case 'u':

6
expr.c
View File

@ -80,10 +80,10 @@ doop(int *op, int **opp, Val *val, Val **valp)
break; break;
case '=': ret = (Val){ NULL, valcmp(a, b) == 0 }; break; case '=': ret = (Val){ NULL, valcmp(a, b) == 0 }; 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 '<': ret = (Val){ NULL, valcmp(a, b) < 0 }; break;
case LE : 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 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;
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;

View File

@ -69,7 +69,7 @@ main(int argc, char *argv[])
openlog(tag ? tag : getlogin(), logflags, 0); openlog(tag ? tag : getlogin(), logflags, 0);
if (argc == 0) { if (argc == 0) {
while(getline(&buf, &sz, stdin) != -1) while (getline(&buf, &sz, stdin) != -1)
syslog(priority, "%s", buf); syslog(priority, "%s", buf);
if (ferror(stdin)) if (ferror(stdin))
eprintf("%s: read error:", "<stdin>"); eprintf("%s: read error:", "<stdin>");

20
sed.c
View File

@ -820,6 +820,7 @@ char *
get_s_arg(Cmd *c, char *s) get_s_arg(Cmd *c, char *s)
{ {
Rune delim, r; Rune delim, r;
Cmd buf;
char *p; char *p;
int esc; int esc;
@ -901,13 +902,13 @@ get_s_arg(Cmd *c, char *s)
for (; s < p; s++) { for (; s < p; s++) {
if (isdigit(*s)) { if (isdigit(*s)) {
c->u.s.occurrence = stol(s, &s); c->u.s.occurrence = stol(s, &s);
} else switch (*s) { } else {
case 'p' : c->u.s.p = 1; break; switch (*s) {
case 'g' : c->u.s.occurrence = 0; break; case 'g': c->u.s.occurrence = 0; break;
case 'w' : { case 'p': c->u.s.p = 1; break;
case 'w':
/* must be last flag, take everything up to newline/semicolon /* must be last flag, take everything up to newline/semicolon
* s == p after this */ * s == p after this */
Cmd buf;
s = get_w_arg(&buf, s); s = get_w_arg(&buf, s);
c->u.s.file = buf.u.file; c->u.s.file = buf.u.file;
break; break;
@ -927,7 +928,6 @@ free_s_arg(Cmd *c)
free(c->u.s.repl.str); free(c->u.s.repl.str);
} }
/* see get_r_arg notes */ /* see get_r_arg notes */
char * char *
get_w_arg(Cmd *c, char *s) get_w_arg(Cmd *c, char *s)
@ -1092,13 +1092,13 @@ match_addr(Addr *a)
switch (a->type) { switch (a->type) {
default: default:
case IGNORE: return 0; case IGNORE: return 0;
case EVERY : return 1; case EVERY: return 1;
case LINE : return lineno == a->u.lineno; case LINE: return lineno == a->u.lineno;
case LAST : case LAST:
while (is_eof(file) && !next_file()) while (is_eof(file) && !next_file())
; ;
return !file; return !file;
case REGEX : case REGEX:
lastre = a->u.re; lastre = a->u.re;
return !regexec(a->u.re, patt.str, 0, NULL, 0); return !regexec(a->u.re, patt.str, 0, NULL, 0);
case LASTRE: case LASTRE:

2
seq.c
View File

@ -27,7 +27,7 @@ main(int argc, char *argv[])
ARGBEGIN { ARGBEGIN {
case 'f': case 'f':
if(!validfmt(tmp=EARGF(usage()))) if (!validfmt(tmp=EARGF(usage())))
eprintf("%s: invalid format\n", tmp); eprintf("%s: invalid format\n", tmp);
fmt = tmp; fmt = tmp;
break; break;

4
sort.c
View File

@ -254,7 +254,7 @@ parse_keydef(struct keydef *kd, char *s, int flags)
static char * static char *
skipblank(char *s) skipblank(char *s)
{ {
while(*s && isblank(*s)) while (*s && isblank(*s))
s++; s++;
return s; return s;
} }
@ -264,7 +264,7 @@ nextcol(char *s)
{ {
if (!fieldsep) { if (!fieldsep) {
s = skipblank(s); s = skipblank(s);
while(*s && !isblank(*s)) while (*s && !isblank(*s))
s++; s++;
} else { } else {
if (!strchr(s, *fieldsep)) if (!strchr(s, *fieldsep))

2
tail.c
View File

@ -130,7 +130,7 @@ main(int argc, char *argv[])
if (fflag && argc == 1) { if (fflag && argc == 1) {
tmp = NULL; tmp = NULL;
tmpsize = 0; tmpsize = 0;
for(;;) { for (;;) {
while (getline(&tmp, &tmpsize, fp) != -1) { while (getline(&tmp, &tmpsize, fp) != -1) {
fputs(tmp, stdout); fputs(tmp, stdout);
fflush(stdout); fflush(stdout);