[hackers] [sbase] Sort includes and more cleanup and fixes in util/ || FRIGN

From: <git_AT_suckless.org>
Date: Fri, 14 Nov 2014 11:54:14 +0100

commit 7d2683ddf2a9c5a308b21f7073a75d8b4d31b512
Author: FRIGN <dev_AT_frign.de>
Date: Thu Nov 13 19:54:28 2014 +0100

    Sort includes and more cleanup and fixes in util/

diff --git a/chgrp.c b/chgrp.c
index ab2ff29..a6ba4bc 100644
--- a/chgrp.c
+++ b/chgrp.c
_AT_@ -1,12 +1,12 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
 #include <errno.h>
 #include <grp.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/chmod.c b/chmod.c
index e0f0c02..e2a56de 100644
--- a/chmod.c
+++ b/chmod.c
_AT_@ -2,8 +2,9 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
+
 #include "util.h"
 
 static void chmodr(const char *);
diff --git a/cksum.c b/cksum.c
index e10558c..9e914ec 100644
--- a/cksum.c
+++ b/cksum.c
_AT_@ -1,6 +1,6 @@
 /* See LICENSE file for copyright and license details. */
-#include <stdint.h>
 #include <inttypes.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/cols.c b/cols.c
index 1d694dd..992d31a 100644
--- a/cols.c
+++ b/cols.c
_AT_@ -4,8 +4,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 
 #include "text.h"
 #include "util.h"
diff --git a/comm.c b/comm.c
index 14dfb72..29ffbe0 100644
--- a/comm.c
+++ b/comm.c
_AT_@ -1,9 +1,9 @@
 /* See LICENSE file for copyright and license details. */
+#include <limits.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <limits.h>
 
 #include "util.h"
 
diff --git a/du.c b/du.c
index 22c1c36..b4421d0 100644
--- a/du.c
+++ b/du.c
_AT_@ -1,13 +1,13 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <dirent.h>
-#include <unistd.h>
+#include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-#include <stdbool.h>
-#include <limits.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/env.c b/env.c
index 8d571aa..a7d7ef4 100644
--- a/env.c
+++ b/env.c
_AT_@ -1,9 +1,9 @@
 /* See LICENSE file for copyright and license details. */
-#include <unistd.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/kill.c b/kill.c
index 01fe394..907eed6 100644
--- a/kill.c
+++ b/kill.c
_AT_@ -1,5 +1,4 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/wait.h>
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
_AT_@ -8,6 +7,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 #include "util.h"
diff --git a/ls.c b/ls.c
index d915008..e4d7b20 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -7,9 +7,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sys/stat.h>
 
 #include "util.h"
 
diff --git a/md5sum.c b/md5sum.c
index a269121..3f182df 100644
--- a/md5sum.c
+++ b/md5sum.c
_AT_@ -4,9 +4,9 @@
 #include <stdlib.h>
 #include <stdint.h>
 
-#include "util.h"
 #include "crypt.h"
 #include "md5.h"
+#include "util.h"
 
 struct md5 s;
 struct crypt_ops md5_ops = {
diff --git a/mkdir.c b/mkdir.c
index 0f4e8db..fed1bbf 100644
--- a/mkdir.c
+++ b/mkdir.c
_AT_@ -1,12 +1,11 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/mkfifo.c b/mkfifo.c
index f617571..30f61a5 100644
--- a/mkfifo.c
+++ b/mkfifo.c
_AT_@ -1,8 +1,8 @@
 /* See LICENSE file for copyright and license details. */
 #include <fcntl.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/mv.c b/mv.c
index d63fd51..81f778c 100644
--- a/mv.c
+++ b/mv.c
_AT_@ -2,8 +2,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include "fs.h"
 #include "util.h"
diff --git a/rmdir.c b/rmdir.c
index 60008b6..74fa907 100644
--- a/rmdir.c
+++ b/rmdir.c
_AT_@ -1,9 +1,9 @@
 /* See LICENSE file for copyright and license details. */
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <errno.h>
 
 #include "util.h"
 
diff --git a/setsid.c b/setsid.c
index 0d61a51..3941e77 100644
--- a/setsid.c
+++ b/setsid.c
_AT_@ -1,9 +1,9 @@
 /* See LICENSE file for copyright and license details. */
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/sha1sum.c b/sha1sum.c
index 49cc466..f6f9cf2 100644
--- a/sha1sum.c
+++ b/sha1sum.c
_AT_@ -1,12 +1,12 @@
 /* See LICENSE file for copyright and license details. */
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 
-#include "util.h"
 #include "crypt.h"
 #include "sha1.h"
+#include "util.h"
 
 struct sha1 s;
 struct crypt_ops sha1_ops = {
diff --git a/sha256sum.c b/sha256sum.c
index 9a57cde..943de2b 100644
--- a/sha256sum.c
+++ b/sha256sum.c
_AT_@ -1,12 +1,12 @@
 /* See LICENSE file for copyright and license details. */
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 
-#include "util.h"
 #include "crypt.h"
 #include "sha256.h"
+#include "util.h"
 
 struct sha256 s;
 struct crypt_ops sha256_ops = {
diff --git a/sha512sum.c b/sha512sum.c
index f4194df..83a5f27 100644
--- a/sha512sum.c
+++ b/sha512sum.c
_AT_@ -1,12 +1,12 @@
 /* See LICENSE file for copyright and license details. */
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 
-#include "util.h"
 #include "crypt.h"
 #include "sha512.h"
+#include "util.h"
 
 struct sha512 s;
 struct crypt_ops sha512_ops = {
diff --git a/split.c b/split.c
index 7b21e20..22f5029 100644
--- a/split.c
+++ b/split.c
_AT_@ -1,10 +1,10 @@
 /* See LICENSE file for copyright and license details. */
+#include <ctype.h>
+#include <limits.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
-#include <ctype.h>
-#include <limits.h>
 
 #include "util.h"
 
diff --git a/strings.c b/strings.c
index a7ae4c7..f4775ed 100644
--- a/strings.c
+++ b/strings.c
_AT_@ -1,7 +1,7 @@
 /* See LICENSE file for copyright and license details. */
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
 
 #include "util.h"
 
diff --git a/tar.c b/tar.c
index 5f9fbd0..81634c1 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -1,15 +1,15 @@
 /* See LICENSE file for copyright and license details. */
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
+#include <grp.h>
+#include <limits.h>
+#include <pwd.h>
 #include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <limits.h>
-#include <grp.h>
-#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/test.c b/test.c
index 2c54b34..0d771ef 100644
--- a/test.c
+++ b/test.c
_AT_@ -1,10 +1,10 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/stat.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include "util.h"
diff --git a/touch.c b/touch.c
index 23d9d6c..0884ee9 100644
--- a/touch.c
+++ b/touch.c
_AT_@ -3,10 +3,10 @@
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
 #include <utime.h>
-#include <sys/stat.h>
 
 #include "util.h"
 
diff --git a/tr.c b/tr.c
index f8062cf..3c047fb 100644
--- a/tr.c
+++ b/tr.c
_AT_@ -1,9 +1,9 @@
 /* See LICENSE file for copyright and license details. */
+#include <locale.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <locale.h>
 #include <wchar.h>
 
 #include "text.h"
diff --git a/tty.c b/tty.c
index 9bcc041..1682e73 100644
--- a/tty.c
+++ b/tty.c
_AT_@ -1,7 +1,7 @@
 /* See LICENSE file for copyright and license details. */
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/uname.c b/uname.c
index ef171fe..12cff59 100644
--- a/uname.c
+++ b/uname.c
_AT_@ -2,8 +2,8 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "util.h"
 
diff --git a/unlink.c b/unlink.c
index 0add3ca..12e88ad 100644
--- a/unlink.c
+++ b/unlink.c
_AT_@ -1,6 +1,7 @@
 /* See LICENSE file for copyright and license details. */
-#include <unistd.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "util.h"
 
 static void
diff --git a/util/agetcwd.c b/util/agetcwd.c
index a672bcf..4ebdb89 100644
--- a/util/agetcwd.c
+++ b/util/agetcwd.c
_AT_@ -10,7 +10,7 @@ agetcwd(void)
         long size;
 
         apathmax(&buf, &size);
- if(!getcwd(buf, size))
+ if (!getcwd(buf, size))
                 eprintf("getcwd:");
 
         return buf;
diff --git a/util/apathmax.c b/util/apathmax.c
index 109f0ac..348df4c 100644
--- a/util/apathmax.c
+++ b/util/apathmax.c
_AT_@ -11,14 +11,14 @@ apathmax(char **p, long *size)
 {
         errno = 0;
 
- if((*size = pathconf("/", _PC_PATH_MAX)) == -1) {
- if(errno == 0) {
+ if ((*size = pathconf("/", _PC_PATH_MAX)) == -1) {
+ if (errno == 0) {
                         *size = BUFSIZ;
                 } else {
                         eprintf("pathconf:");
                 }
         }
 
- if(!(*p = malloc(*size)))
+ if (!(*p = malloc(*size)))
                 eprintf("malloc:");
 }
diff --git a/util/cp.c b/util/cp.c
index 860c324..be80a61 100644
--- a/util/cp.c
+++ b/util/cp.c
_AT_@ -37,20 +37,20 @@ cp(const char *s1, const char *s2)
         DIR *dp;
         int r;
 
- if(cp_vflag)
+ if (cp_vflag)
                 printf("'%s' -> '%s'\n", s1, s2);
 
- if(cp_dflag == true)
+ if (cp_dflag == true)
                 r = lstat(s1, &st);
         else
                 r = stat(s1, &st);
 
- if(r == 0) {
- if(cp_dflag == true && S_ISLNK(st.st_mode)) {
- if(readlink(s1, buf, sizeof(buf) - 1) >= 0) {
- if(cp_fflag == true);
+ if (r == 0) {
+ if (cp_dflag == true && S_ISLNK(st.st_mode)) {
+ if (readlink(s1, buf, sizeof(buf) - 1) >= 0) {
+ if (cp_fflag == true);
                                         unlink(s2);
- if(symlink(buf, s2) != 0) {
+ if (symlink(buf, s2) != 0) {
                                         weprintf("%s: can't create '%s'\n", argv0, s2);
                                         cp_status = 1;
                                         return 0;
_AT_@ -58,11 +58,11 @@ cp(const char *s1, const char *s2)
                         }
                         goto preserve;
                 }
- if(S_ISDIR(st.st_mode)) {
+ if (S_ISDIR(st.st_mode)) {
                         if (!cp_rflag)
                                 eprintf("%s: is a directory\n", s1);
 
- if(!(dp = opendir(s1)))
+ if (!(dp = opendir(s1)))
                                 eprintf("opendir %s:", s1);
 
                         if (mkdir(s2, st.st_mode) == -1 && errno != EEXIST)
_AT_@ -70,15 +70,15 @@ cp(const char *s1, const char *s2)
 
                         apathmax(&ns1, &size1);
                         apathmax(&ns2, &size2);
- while((d = readdir(dp))) {
- if(strcmp(d->d_name, ".") && strcmp(d->d_name, "..")) {
+ while ((d = readdir(dp))) {
+ if (strcmp(d->d_name, ".") && strcmp(d->d_name, "..")) {
                                         r = snprintf(ns1, size1, "%s/%s", s1, d->d_name);
- if(r >= size1 || r < 0) {
+ if (r >= size1 || r < 0) {
                                                 eprintf("%s/%s: filename too long\n",
                                                         s1, d->d_name);
                                         }
                                         r = snprintf(ns2, size2, "%s/%s", s2, d->d_name);
- if(r >= size2 || r < 0) {
+ if (r >= size2 || r < 0) {
                                                 eprintf("%s/%s: filename too long\n",
                                                         s2, d->d_name);
                                         }
_AT_@ -92,11 +92,11 @@ cp(const char *s1, const char *s2)
                 }
         }
 
- if(cp_aflag == true) {
- if(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) ||
+ if (cp_aflag == true) {
+ if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) ||
                    S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode)) {
                         unlink(s2);
- if(mknod(s2, st.st_mode, st.st_rdev) < 0) {
+ if (mknod(s2, st.st_mode, st.st_rdev) < 0) {
                                 weprintf("%s: can't create '%s':", argv0, s2);
                                 cp_status = 1;
                                 return 0;
_AT_@ -105,16 +105,16 @@ cp(const char *s1, const char *s2)
                 }
         }
 
- if(!(f1 = fopen(s1, "r"))) {
+ if (!(f1 = fopen(s1, "r"))) {
                 weprintf("fopen %s:", s1);
                 cp_status = 1;
                 return 0;
         }
 
- if(!(f2 = fopen(s2, "w"))) {
+ if (!(f2 = fopen(s2, "w"))) {
                 if (cp_fflag == true) {
                         unlink(s2);
- if(!(f2 = fopen(s2, "w"))) {
+ if (!(f2 = fopen(s2, "w"))) {
                                 weprintf("fopen %s:", s2);
                                 cp_status = 1;
                                 return 0;
_AT_@ -131,19 +131,19 @@ cp(const char *s1, const char *s2)
         fclose(f1);
 
 preserve:
- if(cp_aflag == true || cp_pflag == true) {
- if(!(S_ISLNK(st.st_mode))) {
+ if (cp_aflag == true || cp_pflag == true) {
+ if (!(S_ISLNK(st.st_mode))) {
                         /* timestamp */
                         ut.actime = st.st_atime;
                         ut.modtime = st.st_mtime;
                         utime(s2, &ut);
                 }
                 /* preserve owner ? */
- if(S_ISLNK(st.st_mode))
+ if (S_ISLNK(st.st_mode))
                         r = lchown(s2, st.st_uid, st.st_gid);
                 else
                         r = chown(s2, st.st_uid, st.st_gid);
- if(r == -1) {
+ if (r == -1) {
                         weprintf("cp: can't preserve ownership of '%s':", s2);
                         cp_status = 1;
                 }
diff --git a/util/crypt.c b/util/crypt.c
index 19b4d0e..cbdf2df 100644
--- a/util/crypt.c
+++ b/util/crypt.c
_AT_@ -1,20 +1,21 @@
 /* See LICENSE file for copyright and license details. */
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
-#include "../util.h"
-#include "../text.h"
+
 #include "../crypt.h"
+#include "../text.h"
+#include "../util.h"
 
 static int
 hexdec(int c)
 {
- if(c >= '0' && c <= '9')
+ if (c >= '0' && c <= '9')
                 return c - '0';
- else if(c >= 'A' && c <= 'F')
+ else if (c >= 'A' && c <= 'F')
                 return c - 'A' + 10;
- else if(c >= 'a' && c <= 'f')
+ else if (c >= 'a' && c <= 'f')
                 return c - 'a' + 10;
         return -1; /* unknown character */
 }
_AT_@ -25,12 +26,12 @@ mdcheckline(const char *s, uint8_t *md, size_t sz)
         size_t i;
         int b1, b2;
 
- for(i = 0; i < sz; i++) {
- if(!*s || (b1 = hexdec(*s++)) < 0)
+ for (i = 0; i < sz; i++) {
+ if (!*s || (b1 = hexdec(*s++)) < 0)
                         return -1; /* invalid format */
- if(!*s || (b2 = hexdec(*s++)) < 0)
+ if (!*s || (b2 = hexdec(*s++)) < 0)
                         return -1; /* invalid format */
- if((uint8_t)((b1 << 4) | b2) != md[i])
+ if ((uint8_t)((b1 << 4) | b2) != md[i])
                         return 0; /* value mismatch */
         }
         return (i == sz) ? 1 : 0;
_AT_@ -45,34 +46,34 @@ cryptcheck(char *sumfile, int argc, char *argv[],
         int r, nonmatch = 0, formatsucks = 0, noread = 0, ret = 0;
         size_t bufsiz = 0;
 
- if(sumfile == NULL)
+ if (sumfile == NULL)
                 cfp = stdin;
- else if(!(cfp = fopen(sumfile, "r")))
+ else if (!(cfp = fopen(sumfile, "r")))
                 eprintf("fopen %s:", sumfile);
 
- while(agetline(&line, &bufsiz, cfp) != -1) {
- if(!(file = strstr(line, " "))) {
+ while (agetline(&line, &bufsiz, cfp) != -1) {
+ if (!(file = strstr(line, " "))) {
                         formatsucks++;
                         continue;
                 }
- if((file - line) / 2 != sz) {
+ if ((file - line) / 2 != sz) {
                         formatsucks++; /* checksum length mismatch */
                         continue;
                 }
                 *file = '\0';
                 file += 2;
- for(p = file; *p && *p != '\n' && *p != '\r'; p++); /* strip newline */
+ for (p = file; *p && *p != '\n' && *p != '\r'; p++); /* strip newline */
                 *p = '\0';
- if(!(fp = fopen(file, "r"))) {
+ if (!(fp = fopen(file, "r"))) {
                         weprintf("fopen %s:", file);
                         noread++;
                         continue;
                 }
                 cryptsum(ops, fp, file, md);
                 r = mdcheckline(line, md, sz);
- if(r == 1) {
+ if (r == 1) {
                         printf("%s: OK\n", file);
- } else if(r == 0) {
+ } else if (r == 0) {
                         printf("%s: FAILED\n", file);
                         nonmatch++;
                 } else {
_AT_@ -80,18 +81,18 @@ cryptcheck(char *sumfile, int argc, char *argv[],
                 }
                 fclose(fp);
         }
- if(sumfile != NULL)
+ if (sumfile != NULL)
                 fclose(cfp);
         free(line);
- if(formatsucks > 0) {
+ if (formatsucks > 0) {
                 weprintf("%d lines are improperly formatted\n", formatsucks);
                 ret = 1;
         }
- if(noread > 0) {
+ if (noread > 0) {
                 weprintf("%d listed file could not be read\n", noread);
                 ret = 1;
         }
- if(nonmatch > 0) {
+ if (nonmatch > 0) {
                 weprintf("%d computed checksums did NOT match\n", nonmatch);
                 ret = 1;
         }
_AT_@ -110,12 +111,12 @@ cryptmain(int argc, char *argv[],
                 mdprint(md, "<stdin>", sz);
         } else {
                 for (; argc > 0; argc--) {
- if((fp = fopen(*argv, "r")) == NULL) {
+ if ((fp = fopen(*argv, "r")) == NULL) {
                                 weprintf("fopen %s:", *argv);
                                 ret = 1;
                                 continue;
                         }
- if(cryptsum(ops, fp, *argv, md) == 1)
+ if (cryptsum(ops, fp, *argv, md) == 1)
                                 ret = 1;
                         else
                                 mdprint(md, *argv, sz);
diff --git a/util/enmasse.c b/util/enmasse.c
index a8ba4f7..7a2fa2a 100644
--- a/util/enmasse.c
+++ b/util/enmasse.c
_AT_@ -3,8 +3,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include "../util.h"
 
_AT_@ -17,7 +17,7 @@ enmasse(int argc, char *argv[], int (*fn)(const char *, const char *))
         struct stat st;
         size_t dlen;
 
- if(argc == 2 && !(stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))) {
+ if (argc == 2 && !(stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))) {
                 fnck(argv[0], argv[1], fn);
                 return;
         } else {
_AT_@ -25,13 +25,13 @@ enmasse(int argc, char *argv[], int (*fn)(const char *, const char *))
         }
 
         apathmax(&buf, &size);
- for(i = 0; i < argc; i++) {
+ for (i = 0; i < argc; i++) {
                 dlen = strlen(dir);
- if(dlen > 0 && dir[dlen - 1] == '/')
+ if (dlen > 0 && dir[dlen - 1] == '/')
                         len = snprintf(buf, size, "%s%s", dir, basename(argv[i]));
                 else
                         len = snprintf(buf, size, "%s/%s", dir, basename(argv[i]));
- if(len < 0 || len >= size) {
+ if (len < 0 || len >= size) {
                         eprintf("%s/%s: filename too long\n", dir,
                                 basename(argv[i]));
                 }
diff --git a/util/eprintf.c b/util/eprintf.c
index 5b7fb25..407c502 100644
--- a/util/eprintf.c
+++ b/util/eprintf.c
_AT_@ -39,7 +39,7 @@ venprintf(int status, const char *fmt, va_list ap)
 
         vfprintf(stderr, fmt, ap);
 
- if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
                 fputc(' ', stderr);
                 perror(NULL);
         }
diff --git a/util/estrtod.c b/util/estrtod.c
index 3590a65..24e4fdc 100644
--- a/util/estrtod.c
+++ b/util/estrtod.c
_AT_@ -12,7 +12,7 @@ estrtod(const char *s)
         double d;
 
         d = strtod(s, &end);
- if(end == s || *end != '\0')
+ if (end == s || *end != '\0')
                 eprintf("%s: not a real number\n", s);
         return d;
 }
diff --git a/util/estrtol.c b/util/estrtol.c
index ac37b8c..74c7fb4 100644
--- a/util/estrtol.c
+++ b/util/estrtol.c
_AT_@ -13,13 +13,13 @@ estrtol(const char *s, int base)
 
         errno = 0;
         n = strtol(s, &end, base);
- if(*end != '\0') {
- if(base == 0)
+ if (*end != '\0') {
+ if (base == 0)
                         eprintf("%s: not an integer\n", s);
                 else
                         eprintf("%s: not a base %d integer\n", s, base);
         }
- if(errno != 0)
+ if (errno != 0)
                 eprintf("%s:", s);
 
         return n;
diff --git a/util/fnck.c b/util/fnck.c
index 84123bc..8053267 100644
--- a/util/fnck.c
+++ b/util/fnck.c
_AT_@ -8,13 +8,13 @@ fnck(const char *a, const char *b, int (*fn)(const char *, const char *))
 {
         struct stat sta, stb;
 
- if(stat(a, &sta) == 0
+ if (stat(a, &sta) == 0
                         && stat(b, &stb) == 0
                         && sta.st_dev == stb.st_dev
                         && sta.st_ino == stb.st_ino) {
                 eprintf("%s -> %s: same file\n", a, b);
         }
 
- if(fn(a, b) == -1)
+ if (fn(a, b) == -1)
                 eprintf("%s -> %s:", a, b);
 }
diff --git a/util/getlines.c b/util/getlines.c
index 4d66acf..a766ba4 100644
--- a/util/getlines.c
+++ b/util/getlines.c
_AT_@ -13,16 +13,16 @@ getlines(FILE *fp, struct linebuf *b)
         size_t size = 0, linelen;
         ssize_t len;
 
- while((len = agetline(&line, &size, fp)) != -1) {
- if(++b->nlines > b->capacity) {
+ while ((len = agetline(&line, &size, fp)) != -1) {
+ if (++b->nlines > b->capacity) {
                         b->capacity += 512;
                         nline = realloc(b->lines, b->capacity * sizeof(*b->lines));
- if(nline == NULL)
+ if (nline == NULL)
                                 eprintf("realloc:");
                         b->lines = nline;
                 }
                 linelen = len + 1;
- if(!(b->lines[b->nlines-1] = malloc(linelen)))
+ if (!(b->lines[b->nlines-1] = malloc(linelen)))
                         eprintf("malloc:");
                 memcpy(b->lines[b->nlines-1], line, linelen);
         }
diff --git a/util/human.c b/util/human.c
index 422407b..5527bce 100644
--- a/util/human.c
+++ b/util/human.c
_AT_@ -1,3 +1,4 @@
+/* See LICENSE file for copyright and license details. */
 #include <stdio.h>
 #include <string.h>
 
_AT_@ -10,10 +11,10 @@ humansize(double n)
         const char postfixes[] = "BKMGTPE";
         size_t i;
 
- for(i = 0; n >= 1024 && i < strlen(postfixes); i++)
+ for (i = 0; n >= 1024 && i < strlen(postfixes); i++)
                 n /= 1024;
 
- if(!i)
+ if (!i)
                 snprintf(buf, sizeof(buf), "%lu", (unsigned long)n);
         else
                 snprintf(buf, sizeof(buf), "%.1f%c", n, postfixes[i]);
diff --git a/util/md5.c b/util/md5.c
index b1bf714..c7483ac 100644
--- a/util/md5.c
+++ b/util/md5.c
_AT_@ -1,6 +1,7 @@
 /* public domain md5 implementation based on rfc1321 and libtomcrypt */
 #include <stdint.h>
 #include <string.h>
+
 #include "../md5.h"
 
 static uint32_t rol(uint32_t n, int k) { return (n << k) | (n >> (32-k)); }
diff --git a/util/mode.c b/util/mode.c
index 0ab6f5d..16347d8 100644
--- a/util/mode.c
+++ b/util/mode.c
_AT_@ -1,7 +1,8 @@
-#include <unistd.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
+#include <unistd.h>
+
 #include "../util.h"
 
 mode_t
_AT_@ -21,30 +22,30 @@ parsemode(const char *str, mode_t mode, mode_t mask)
         mode_t who, perm, clear;
 
         octal = strtol(str, &end, 8);
- if(*end == '\0') {
- if(octal < 0 || octal > 07777) {
+ if (*end == '\0') {
+ if (octal < 0 || octal > 07777) {
                         eprintf("%s: invalid mode\n", str);
                         return -1;
                 }
                 mode = 0;
- if(octal & 04000) mode |= S_ISUID;
- if(octal & 02000) mode |= S_ISGID;
- if(octal & 01000) mode |= S_ISVTX;
- if(octal & 00400) mode |= S_IRUSR;
- if(octal & 00200) mode |= S_IWUSR;
- if(octal & 00100) mode |= S_IXUSR;
- if(octal & 00040) mode |= S_IRGRP;
- if(octal & 00020) mode |= S_IWGRP;
- if(octal & 00010) mode |= S_IXGRP;
- if(octal & 00004) mode |= S_IROTH;
- if(octal & 00002) mode |= S_IWOTH;
- if(octal & 00001) mode |= S_IXOTH;
+ if (octal & 04000) mode |= S_ISUID;
+ if (octal & 02000) mode |= S_ISGID;
+ if (octal & 01000) mode |= S_ISVTX;
+ if (octal & 00400) mode |= S_IRUSR;
+ if (octal & 00200) mode |= S_IWUSR;
+ if (octal & 00100) mode |= S_IXUSR;
+ if (octal & 00040) mode |= S_IRGRP;
+ if (octal & 00020) mode |= S_IWGRP;
+ if (octal & 00010) mode |= S_IXGRP;
+ if (octal & 00004) mode |= S_IROTH;
+ if (octal & 00002) mode |= S_IWOTH;
+ if (octal & 00001) mode |= S_IXOTH;
                 return mode;
         }
 next:
         /* first, determine which bits we will be modifying */
- for(who = 0; *p; p++) {
- switch(*p) {
+ for (who = 0; *p; p++) {
+ switch (*p) {
                 /* masks */
                 case 'u':
                         who |= S_IRWXU|S_ISUID;
_AT_@ -61,14 +62,14 @@ next:
                 }
                 break;
         }
- if(who) {
+ if (who) {
                 clear = who;
         } else {
                 clear = S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO;
                 who = ~mask;
         }
- while(*p) {
- switch(*p) {
+ while (*p) {
+ switch (*p) {
                 /* opers */
                 case '=':
                 case '+':
_AT_@ -81,42 +82,42 @@ next:
                 }
 
                 perm = 0;
- switch(*++p) {
+ switch (*++p) {
                 /* copy */
                 case 'u':
- if(mode & S_IRUSR)
+ if (mode & S_IRUSR)
                                 perm |= S_IRUSR|S_IRGRP|S_IROTH;
- if(mode & S_IWUSR)
+ if (mode & S_IWUSR)
                                 perm |= S_IWUSR|S_IWGRP|S_IWOTH;
- if(mode & S_IXUSR)
+ if (mode & S_IXUSR)
                                 perm |= S_IXUSR|S_IXGRP|S_IXOTH;
- if(mode & S_ISUID)
+ if (mode & S_ISUID)
                                 perm |= S_ISUID|S_ISGID;
                         p++;
                         break;
                 case 'g':
- if(mode & S_IRGRP)
+ if (mode & S_IRGRP)
                                 perm |= S_IRUSR|S_IRGRP|S_IROTH;
- if(mode & S_IWGRP)
+ if (mode & S_IWGRP)
                                 perm |= S_IWUSR|S_IWGRP|S_IWOTH;
- if(mode & S_IXGRP)
+ if (mode & S_IXGRP)
                                 perm |= S_IXUSR|S_IXGRP|S_IXOTH;
- if(mode & S_ISGID)
+ if (mode & S_ISGID)
                                 perm |= S_ISUID|S_ISGID;
                         p++;
                         break;
                 case 'o':
- if(mode & S_IROTH)
+ if (mode & S_IROTH)
                                 perm |= S_IRUSR|S_IRGRP|S_IROTH;
- if(mode & S_IWOTH)
+ if (mode & S_IWOTH)
                                 perm |= S_IWUSR|S_IWGRP|S_IWOTH;
- if(mode & S_IXOTH)
+ if (mode & S_IXOTH)
                                 perm |= S_IXUSR|S_IXGRP|S_IXOTH;
                         p++;
                         break;
                 default:
- for(; *p; p++) {
- switch(*p) {
+ for (; *p; p++) {
+ switch (*p) {
                                 /* modes */
                                 case 'r':
                                         perm |= S_IRUSR|S_IRGRP|S_IROTH;
_AT_@ -141,7 +142,7 @@ next:
 
         apply:
                 /* apply */
- switch(op) {
+ switch (op) {
                 case '=':
                         mode &= ~clear;
                         /* fallthrough */
_AT_@ -153,7 +154,7 @@ next:
                         break;
                 }
                 /* if we hit a comma, move on to the next clause */
- if(*p == ',') {
+ if (*p == ',') {
                         p++;
                         goto next;
                 }
diff --git a/util/putword.c b/util/putword.c
index 83c1c49..b5f3973 100644
--- a/util/putword.c
+++ b/util/putword.c
_AT_@ -9,10 +9,9 @@ putword(const char *s)
 {
         static bool first = true;
 
- if(!first)
+ if (!first)
                 putchar(' ');
 
         fputs(s, stdout);
         first = false;
 }
-
diff --git a/util/rm.c b/util/rm.c
index 873da72..ea84fa2 100644
--- a/util/rm.c
+++ b/util/rm.c
_AT_@ -10,9 +10,8 @@ bool rm_fflag = false, rm_rflag = false;
 void
 rm(const char *path)
 {
- if(rm_rflag)
+ if (rm_rflag)
                 recurse(path, rm);
- if(remove(path) == -1 && !rm_fflag)
+ if (remove(path) == -1 && !rm_fflag)
                 eprintf("remove %s:", path);
 }
-
diff --git a/util/sha1.c b/util/sha1.c
index 4de2ab6..3d76a1b 100644
--- a/util/sha1.c
+++ b/util/sha1.c
_AT_@ -1,6 +1,7 @@
 /* public domain sha1 implementation based on rfc3174 and libtomcrypt */
 #include <stdint.h>
 #include <string.h>
+
 #include "../sha1.h"
 
 static uint32_t rol(uint32_t n, int k) { return (n << k) | (n >> (32-k)); }
diff --git a/util/sha256.c b/util/sha256.c
index eb9f5da..e30169b 100644
--- a/util/sha256.c
+++ b/util/sha256.c
_AT_@ -1,9 +1,10 @@
 /* public domain sha256 implementation based on fips180-3 */
 #include <ctype.h>
-#include <stdlib.h>
+#include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
+
 #include "../sha256.h"
 
 static uint32_t ror(uint32_t n, int k) { return (n >> k) | (n << (32-k)); }
diff --git a/util/sha512.c b/util/sha512.c
index 394aec7..efe4f91 100644
--- a/util/sha512.c
+++ b/util/sha512.c
_AT_@ -1,10 +1,11 @@
 /* public domain sha256 implementation based on fips180-3 */
 
 #include <ctype.h>
-#include <stdlib.h>
+#include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
+
 #include "../sha512.h"
 
 static uint64_t ror(uint64_t n, int k) { return (n >> k) | (n << (64-k)); }
diff --git a/util/strlcat.c b/util/strlcat.c
index c64b1c7..9e2d251 100644
--- a/util/strlcat.c
+++ b/util/strlcat.c
_AT_@ -14,8 +14,9 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
 #include <string.h>
+#include <sys/types.h>
+
 #include "../util.h"
 
 /*
diff --git a/util/strlcpy.c b/util/strlcpy.c
index c67a199..388b426 100644
--- a/util/strlcpy.c
+++ b/util/strlcpy.c
_AT_@ -14,8 +14,9 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
 #include <string.h>
+#include <sys/types.h>
+
 #include "../util.h"
 
 /*
diff --git a/uudecode.c b/uudecode.c
index 3828cba..3ad4fed 100644
--- a/uudecode.c
+++ b/uudecode.c
_AT_@ -1,15 +1,15 @@
 /* See LICENSE file for copyright and license details. */
+#include <errno.h>
+#include <limits.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <errno.h>
-#include <limits.h>
 
-#include "util.h"
 #include "text.h"
+#include "util.h"
 
 static void uudecode(FILE *, FILE *);
 static void parseheader(FILE *, const char *, const char *, mode_t *, char **);
Received on Fri Nov 14 2014 - 11:54:14 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 14 2014 - 12:00:12 CET