Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whitespace tidy #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions envdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ int main(int argc,const char *const *argv)
if (sa.len) {
sa.len = byte_chr(sa.s,sa.len,'\n');
while (sa.len) {
if (sa.s[sa.len - 1] != ' ')
if (sa.s[sa.len - 1] != '\t')
break;
--sa.len;
if (sa.s[sa.len - 1] != ' ')
if (sa.s[sa.len - 1] != '\t')
break;
--sa.len;
}
for (i = 0;i < sa.len;++i)
if (!sa.s[i])
sa.s[i] = '\n';
if (!sa.s[i])
sa.s[i] = '\n';
if (!stralloc_0(&sa)) nomem();
if (!pathexec_env(saname.s,sa.s)) nomem();
}
Expand Down
42 changes: 21 additions & 21 deletions envini.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ static void parse(void)
++start;
if (end > start) {
if (sa.s[start] == '[' && sa.s[end-1] == ']') {
if (!stralloc_copyb(&section,sa.s+start+1,end-start-2)) nomem();
if (!stralloc_append(&section,'_')) nomem();
if (!stralloc_copyb(&section,sa.s+start+1,end-start-2)) nomem();
if (!stralloc_append(&section,'_')) nomem();
}
else if (sa.s[start] == ';')
;
;
else {
i = start;
while (i < end && sa.s[i] != '=' && !is_space(sa.s[i]))
++i;
if (!stralloc_copys(&name,prefix)) nomem();
if (!stralloc_cat(&name,&section)) nomem();
if (!stralloc_catb(&name,sa.s+start,i-start)) nomem();
if (!stralloc_0(&name)) nomem();
while (i < end && is_space(sa.s[i]))
++i;
if (i >= end || sa.s[i++] != '=')
continue; /* Ignore misformatted lines */
while (i < end && is_space(sa.s[i]))
++i;
if (!stralloc_copyb(&value,sa.s+i,end-i)) nomem();
if (!stralloc_0(&value)) nomem();
if (!pathexec_env(name.s,value.s)) nomem();
i = start;
while (i < end && sa.s[i] != '=' && !is_space(sa.s[i]))
++i;
if (!stralloc_copys(&name,prefix)) nomem();
if (!stralloc_cat(&name,&section)) nomem();
if (!stralloc_catb(&name,sa.s+start,i-start)) nomem();
if (!stralloc_0(&name)) nomem();
while (i < end && is_space(sa.s[i]))
++i;
if (i >= end || sa.s[i++] != '=')
continue; /* Ignore misformatted lines */
while (i < end && is_space(sa.s[i]))
++i;
if (!stralloc_copyb(&value,sa.s+i,end-i)) nomem();
if (!stralloc_0(&value)) nomem();
if (!pathexec_env(name.s,value.s)) nomem();
}
}
}
Expand All @@ -81,8 +81,8 @@ int main(int argc,const char *const *argv)

while ((opt = getopt(argc,argv,"p:")) != opteof)
switch (opt) {
case 'p': prefix = optarg; break;
default: die_usage();
case 'p': prefix = optarg; break;
default: die_usage();
}
argv += optind;

Expand Down
24 changes: 12 additions & 12 deletions installer.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,36 @@ void doit(stralloc *line)
case 'd':
if (mkdir(target.s,0700) == -1)
if (errno != error_exist)
strerr_die3sys(111,FATAL,"unable to mkdir ",target.s);
strerr_die3sys(111,FATAL,"unable to mkdir ",target.s);
break;

case 'c':
fdin = open_read(name);
if (fdin == -1) {
if (opt)
return;
else
strerr_die3sys(111,FATAL,"unable to read ",name);
if (opt)
return;
else
strerr_die3sys(111,FATAL,"unable to read ",name);
}
buffer_init(&bufin,buffer_unixread,fdin,inbuf,sizeof(inbuf));

fdout = open_trunc(target.s);
if (fdout == -1)
strerr_die3sys(111,FATAL,"unable to write ",target.s);
strerr_die3sys(111,FATAL,"unable to write ",target.s);
buffer_init(&bufout,buffer_unixwrite,fdout,outbuf,sizeof(outbuf));

switch(buffer_copy(&bufout,&bufin)) {
case -2:
strerr_die3sys(111,FATAL,"unable to read ",name);
case -3:
strerr_die3sys(111,FATAL,"unable to write ",target.s);
case -2:
strerr_die3sys(111,FATAL,"unable to read ",name);
case -3:
strerr_die3sys(111,FATAL,"unable to write ",target.s);
}

close(fdin);
if (buffer_flush(&bufout) == -1)
strerr_die3sys(111,FATAL,"unable to write ",target.s);
strerr_die3sys(111,FATAL,"unable to write ",target.s);
if (fsync(fdout) == -1)
strerr_die3sys(111,FATAL,"unable to write ",target.s);
strerr_die3sys(111,FATAL,"unable to write ",target.s);
close(fdout);
break;

Expand Down
34 changes: 17 additions & 17 deletions multilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ int filesfit(struct cyclog *d)
if (x->d_name[0] == '@')
if (str_len(x->d_name) >= 25)
if (str_start(x->d_name,fn.s)) {
unlink(x->d_name);
break;
unlink(x->d_name);
break;
}
}
if (errno) { closedir(dir); return -1; }
Expand All @@ -161,7 +161,7 @@ void finish(struct cyclog *d,const char *file,const char *code)
fnlen = fmt_tai64nstamp(fn.s);
fn.s[fnlen++] = '.';
do {
fn.s[fnlen++] = *code;
fn.s[fnlen++] = *code;
} while (*code++ != 0);

if (link(file,fn.s) == 0) break;
Expand Down Expand Up @@ -419,7 +419,7 @@ void c_init(char **script)
else if (script[i][0] == 'w') {
code_finished = script[i] + 1;
if (!stralloc_ready(&fn,str_len(code_finished)+TIMESTAMP+1))
strerr_die2sys(111,FATAL,"unable to allocate memory");
strerr_die2sys(111,FATAL,"unable to allocate memory");
}
else if ((script[i][0] == '.') || (script[i][0] == '/')) {
d->num = num;
Expand Down Expand Up @@ -469,7 +469,7 @@ int flushread(int fd,char *buf,int len)
if (flagforcerotate) {
for (j = 0;j < cnum;++j)
if (c[j].bytes > 0)
fullcurrent(&c[j]);
fullcurrent(&c[j]);
flagforcerotate = 0;
}

Expand Down Expand Up @@ -524,8 +524,8 @@ void doit(char **script)
return;
if (flagtimestamp) {
linelen = (flagtimestamp == 't')
? fmt_tai64nstamp(line)
: fmt_accustamp(line);
? fmt_tai64nstamp(line)
: fmt_accustamp(line);
line[linelen++] = ' ';
}
if (buffer_gets(&ssin,line+linelen,MAXLINE-linelen,'\n',&linelen) < 0)
Expand All @@ -538,11 +538,11 @@ void doit(char **script)
for (i = 0;(action = script[i]) != 0;++i)
switch(*action) {
case 'F':
match = match_fnmatch;
break;
match = match_fnmatch;
break;
case 'S':
match = match_simple;
break;
match = match_simple;
break;
case '+':
if (!flagselected)
if (match(action + 1,line,linelen))
Expand Down Expand Up @@ -590,19 +590,19 @@ void doit(char **script)
while (linelen == MAXLINE) {
linelen = 0;
if (buffer_gets(&ssin,line,MAXLINE,'\n',&linelen) < 0) {
flageof = 1;
break;
flageof = 1;
break;
}
if (linelen == 0)
break;
break;
for (j = 0;j < cnum;++j)
if (c[j].flagselected)
buffer_put(&c[j].ss,line,linelen);
if (c[j].flagselected)
buffer_put(&c[j].ss,line,linelen);
}

for (j = 0;j < cnum;++j)
if (c[j].flagselected) {
ch = '\n';
ch = '\n';
buffer_PUTC(&c[j].ss,ch);
}

Expand Down
14 changes: 7 additions & 7 deletions pathexec_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ void pathexec(const char *const *argv)
if (!plus.s[i]) {
split = str_chr(plus.s + j,'=');
for (t = 0;t < elen;++t)
if (byte_equal(plus.s + j,split,e[t]))
if (e[t][split] == '=') {
--elen;
e[t] = e[elen];
break;
}
if (byte_equal(plus.s + j,split,e[t]))
if (e[t][split] == '=') {
--elen;
e[t] = e[elen];
break;
}
if (plus.s[j + split])
e[elen++] = plus.s + j;
e[elen++] = plus.s + j;
j = i + 1;
}
e[elen] = 0;
Expand Down
14 changes: 7 additions & 7 deletions readproctitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ int main(int argc,char **argv)
for (;;)
switch(read(0,&ch,1)) {
case 1:
if (ch) {
for (i = 4;i < len;++i) buf[i - 1] = buf[i];
buf[len - 1] = ch;
}
break;
if (ch) {
for (i = 4;i < len;++i) buf[i - 1] = buf[i];
buf[len - 1] = ch;
}
break;
case 0:
_exit(0);
_exit(0);
case -1:
if (errno != error_intr) _exit(111);
if (errno != error_intr) _exit(111);
}
}
4 changes: 2 additions & 2 deletions softlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(int argc,const char *const *argv,const char *const *envp)
while ((opt = getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof)
switch(opt) {
case '?':
die_usage();
die_usage();
case 'a':
#ifdef RLIMIT_AS
doit(RLIMIT_AS,optarg);
Expand Down Expand Up @@ -144,7 +144,7 @@ int main(int argc,const char *const *argv,const char *const *envp)
#ifdef RLIMIT_AS
doit(RLIMIT_AS,optarg);
#endif
break;
break;
case 'o':
#ifdef RLIMIT_NOFILE
doit(RLIMIT_NOFILE,optarg);
Expand Down
2 changes: 1 addition & 1 deletion subgetopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int sgopt(int argc,const char *const *argv,const char *opts)
optproblem = c;
return '?';
}
++optind;
++optind;
}
}
return c;
Expand Down
Loading