[hackers] [sbase] code style || Hiltjo Posthuma
commit 953ebf35730c986ca68b0cf7d97f22dceccb08a0
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Jun 1 14:59:47 2014 +0200
code style
Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
diff --git a/basename.c b/basename.c
index e3d1a14..f5f681c 100644
--- a/basename.c
+++ b/basename.c
_AT_@ -39,4 +39,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/cal.c b/cal.c
index c1ff8da..7fca626 100644
--- a/cal.c
+++ b/cal.c
_AT_@ -189,4 +189,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/chroot.c b/chroot.c
index 2b88937..e0a1577 100644
--- a/chroot.c
+++ b/chroot.c
_AT_@ -46,4 +46,3 @@ main(int argc, char *argv[])
_exit(savederrno == ENOENT ? 127 : 126);
return EXIT_FAILURE;
}
-
diff --git a/cksum.c b/cksum.c
index bb2c322..a252f93 100644
--- a/cksum.c
+++ b/cksum.c
_AT_@ -93,7 +93,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-void
+static void
cksum(FILE *fp, const char *s)
{
unsigned char buf[BUFSIZ];
_AT_@ -117,4 +117,3 @@ cksum(FILE *fp, const char *s)
printf(" %s", s);
putchar('
');
}
-
diff --git a/comm.c b/comm.c
index 694d48c..fe3323b 100644
--- a/comm.c
+++ b/comm.c
_AT_@ -66,7 +66,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-void
+static void
printline(int pos, char *line)
{
int i;
_AT_@ -81,7 +81,7 @@ printline(int pos, char *line)
printf("%s", line);
}
-char *
+static char *
nextline(char *buf, int n, FILE *f, char *name)
{
buf = fgets(buf, n, f);
_AT_@ -93,7 +93,7 @@ nextline(char *buf, int n, FILE *f, char *name)
return buf;
}
-void
+static void
finish(int pos, FILE *f, char *name)
{
char buf[LINE_MAX+1];
_AT_@ -103,4 +103,3 @@ finish(int pos, FILE *f, char *name)
exit(EXIT_FAILURE);
}
-
diff --git a/date.c b/date.c
index 2a798e5..0c0041c 100644
--- a/date.c
+++ b/date.c
_AT_@ -43,4 +43,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/dirname.c b/dirname.c
index 1c4297f..50820c6 100644
--- a/dirname.c
+++ b/dirname.c
_AT_@ -26,4 +26,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/echo.c b/echo.c
index 41ff4bb..fb7e3dd 100644
--- a/echo.c
+++ b/echo.c
_AT_@ -31,4 +31,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/env.c b/env.c
index f82c178..70fdfb1 100644
--- a/env.c
+++ b/env.c
_AT_@ -34,7 +34,7 @@ main(int argc, char *argv[])
if(*argv) {
execvp(*argv, argv);
- enprintf(127-(errno!=EEXIST), "env: '%s':", *argv);
+ enprintf(127 - (errno != EEXIST), "env: '%s':", *argv);
}
while(environ && *environ)
_AT_@ -42,4 +42,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/fold.c b/fold.c
index 6a95124..84888e5 100644
--- a/fold.c
+++ b/fold.c
_AT_@ -58,7 +58,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-void
+static void
fold(FILE *fp, long width)
{
char *buf = NULL;
_AT_@ -69,7 +69,7 @@ fold(FILE *fp, long width)
free(buf);
}
-void
+static void
foldline(const char *str, long width)
{
bool space;
diff --git a/head.c b/head.c
index 2903f49..93fd818 100644
--- a/head.c
+++ b/head.c
_AT_@ -46,7 +46,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-void
+static void
head(FILE *fp, const char *str, long n)
{
char buf[BUFSIZ];
diff --git a/kill.c b/kill.c
index 70e95f9..ea9a777 100644
--- a/kill.c
+++ b/kill.c
_AT_@ -76,4 +76,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/ln.c b/ln.c
index c0bd8f3..029bce5 100644
--- a/ln.c
+++ b/ln.c
_AT_@ -41,4 +41,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-
diff --git a/ls.c b/ls.c
index 5d98c92..88ae3c0 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -96,7 +96,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-int
+static int
entcmp(const void *va, const void *vb)
{
const Entry *a = va, *b = vb;
_AT_@ -107,7 +107,7 @@ entcmp(const void *va, const void *vb)
return strcmp(a->name, b->name);
}
-void
+static void
ls(Entry *ent)
{
if(S_ISDIR(ent->mode) && !dflag) {
_AT_@ -117,7 +117,7 @@ ls(Entry *ent)
}
}
-void
+static void
lsdir(const char *path)
{
char *cwd, *p;
_AT_@ -169,7 +169,7 @@ lsdir(const char *path)
free(cwd);
}
-void
+static void
mkent(Entry *ent, char *path, bool dostat)
{
struct stat st;
_AT_@ -188,7 +188,7 @@ mkent(Entry *ent, char *path, bool dostat)
ent->ino = st.st_ino;
}
-char *
+static char *
indicator(mode_t mode)
{
if(!Fflag)
_AT_@ -210,7 +210,7 @@ indicator(mode_t mode)
return "";
}
-void
+static void
output(Entry *ent)
{
char buf[BUFSIZ], *fmt;
_AT_@ -290,4 +290,3 @@ output(Entry *ent)
}
putchar('
');
}
-
diff --git a/mkdir.c b/mkdir.c
index 781654a..79c8167 100644
--- a/mkdir.c
+++ b/mkdir.c
_AT_@ -53,7 +53,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-void
+static void
mkdirp(char *path)
{
char *p = path;
_AT_@ -67,4 +67,3 @@ mkdirp(char *path)
*p = '/';
} while(p);
}
-
diff --git a/mkfifo.c b/mkfifo.c
index 3f2d618..f4ccee4 100644
--- a/mkfifo.c
+++ b/mkfifo.c
_AT_@ -33,4 +33,3 @@ main(int argc, char *argv[])
eprintf("mkfifo %s:", argv[0]);
return EXIT_SUCCESS;
}
-
diff --git a/mv.c b/mv.c
index 542f833..acf5e39 100644
--- a/mv.c
+++ b/mv.c
_AT_@ -7,7 +7,7 @@
#include "fs.h"
#include "util.h"
-int mv(const char *, const char *);
+static int mv(const char *, const char *);
static void
usage(void)
_AT_@ -37,7 +37,7 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
-int
+static int
mv(const char *s1, const char *s2)
{
if (rename(s1, s2) == 0)
_AT_@ -51,4 +51,3 @@ mv(const char *s1, const char *s2)
}
return -1;
}
-
diff --git a/nice.c b/nice.c
index b9fc3ea..5f5862f 100644
--- a/nice.c
+++ b/nice.c
_AT_@ -46,4 +46,3 @@ main(int argc, char *argv[])
weprintf("execvp %s:", argv[0]);
return (savederrno == ENOENT)? 127 : 126;
}
-
diff --git a/nl.c b/nl.c
index fcfd8de..4e2df70 100644
--- a/nl.c
+++ b/nl.c
_AT_@ -80,4 +80,3 @@ nl(FILE *fp)
}
free(buf);
}
-
diff --git a/nohup.c b/nohup.c
index 76d7ce3..6ac9d2b 100644
--- a/nohup.c
+++ b/nohup.c
_AT_@ -49,4 +49,3 @@ main(int argc, char *argv[])
return Error;
}
-
diff --git a/paste.c b/paste.c
index e536fde..7ec129a 100644
--- a/paste.c
+++ b/paste.c
_AT_@ -30,9 +30,9 @@ main(int argc, char *argv[])
{
const char *adelim = NULL;
bool seq = false;
- wchar_t *delim;
+ wchar_t *delim = NULL;
size_t len;
- Fdescr *dsc;
+ Fdescr *dsc = NULL;
int i;
setlocale(LC_CTYPE, "");
_AT_@ -59,8 +59,7 @@ main(int argc, char *argv[])
if(len == (size_t)-1)
eprintf("invalid delimiter
");
- delim = malloc((len + 1) * sizeof(*delim));
- if(!delim)
+ if(!(delim = malloc((len + 1) * sizeof(*delim))))
eprintf("out of memory
");
mbstowcs(delim, adelim, len);
_AT_@ -69,22 +68,19 @@ main(int argc, char *argv[])
eprintf("no delimiters specified
");
/* populate file list */
- dsc = malloc(argc * sizeof(*dsc));
- if(!dsc)
+ if(!(dsc = malloc(argc * sizeof(*dsc))))
eprintf("out of memory
");
for(i = 0; i < argc; i++) {
- const char *name = argv[i];
-
- if(strcmp(name, "-") == 0)
+ if(strcmp(argv[i], "-") == 0)
dsc[i].fp = stdin;
else
- dsc[i].fp = fopen(name, "r");
+ dsc[i].fp = fopen(argv[i], "r");
if(!dsc[i].fp)
- eprintf("can't open '%s':", name);
+ eprintf("can't open '%s':", argv[i]);
- dsc[i].name = name;
+ dsc[i].name = argv[i];
}
if(seq)
_AT_@ -160,10 +156,12 @@ static void
sequential(Fdescr *dsc, int len, const wchar_t *delim, size_t cnt)
{
int i;
+ size_t d;
+ wint_t c, last;
for(i = 0; i < len; i++) {
- size_t d = 0;
- wint_t c, last = WEOF;
+ d = 0;
+ last = WEOF;
while((c = in(&dsc[i])) != WEOF) {
if(last == '
') {
_AT_@ -188,19 +186,17 @@ sequential(Fdescr *dsc, int len, const wchar_t *delim, size_t cnt)
static void
parallel(Fdescr *dsc, int len, const wchar_t *delim, size_t cnt)
{
- int last;
+ int last, i;
+ wint_t c, o;
+ wchar_t d;
do {
- int i;
-
last = 0;
for(i = 0; i < len; i++) {
- wint_t c;
- wchar_t d = delim[i % cnt];
+ d = delim[i % cnt];
do {
- wint_t o = in(&dsc[i]);
-
+ o = in(&dsc[i]);
c = o;
switch(c) {
case WEOF:
_AT_@ -212,7 +208,6 @@ parallel(Fdescr *dsc, int len, const wchar_t *delim, size_t cnt)
case '
':
if(i != len - 1)
o = d;
-
break;
default:
break;
_AT_@ -224,11 +219,9 @@ parallel(Fdescr *dsc, int len, const wchar_t *delim, size_t cnt)
if(d != '
Received on Sun Jun 01 2014 - 19:02:35 CEST
This archive was generated by hypermail 2.3.0
: Sun Jun 01 2014 - 19:12:13 CEST