aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-09 11:21:34 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-09 11:21:34 +0200
commitfb29f653b0d3868a8dde08ebf4689acd314eaa4d (patch)
tree11f1667b8a7284e733695bd6fb6da345598e75d4
parentb33ea7c90a1b22ea133f9aada442055c32e11b67 (diff)
Code style
-rw-r--r--cbs.h33
1 files changed, 16 insertions, 17 deletions
diff --git a/cbs.h b/cbs.h
index 2ec6247..a6cfb73 100644
--- a/cbs.h
+++ b/cbs.h
@@ -66,24 +66,24 @@ static void strspushenv(struct strs *, const char *, char **, size_t);
strspushenv((xs), (ev), _vtoxs(__VA_ARGS__), lengthof(_vtoxs(__VA_ARGS__)))
static bool fexists(const char *);
-static int fmdcmp(const char *, const char *);
+static int fmdcmp(const char *, const char *);
static bool fmdolder(const char *, const char *);
static bool fmdnewer(const char *, const char *);
static bool foutdated(const char *, char **, size_t);
#define foutdatedl(s, ...) \
- foutdated(s, _vtoxs(__VA_ARGS__), lengthof(_vtoxs(__VA_ARGS__)))
+ foutdated((s), _vtoxs(__VA_ARGS__), lengthof(_vtoxs(__VA_ARGS__)))
-static int cmdexec(struct strs);
+static int cmdexec(struct strs);
static pid_t cmdexec_async(struct strs);
-static int cmdexec_read(struct strs, char **, size_t *);
-static int cmdwait(pid_t);
-static void cmdput(struct strs);
-static void cmdfput(FILE *, struct strs);
+static int cmdexec_read(struct strs, char **, size_t *);
+static int cmdwait(pid_t);
+static void cmdput(struct strs);
+static void cmdfput(FILE *, struct strs);
static char *swpext(const char *, const char *);
-static bool pcquery(struct strs *, const char *, int);
-static bool binexists(const char *);
-static int nproc(void);
+static bool pcquery(struct strs *, const char *, int);
+static bool binexists(const char *);
+static int nproc(void);
#ifndef CBS_NO_THREADS
typedef void tjob(void *);
@@ -111,7 +111,7 @@ static void tpwait(tpool *);
static void tpenq(tpool *, tjob *, void *, tjob_free *);
#endif /* !CBS_NO_THREADS */
-static int _cbs_argc;
+static int _cbs_argc;
static char **_cbs_argv;
/* Implementation */
@@ -364,10 +364,9 @@ cmdfput(FILE *fp, struct strs xs)
flockfile(fp);
for (size_t i = 0; i < xs.len; i++) {
bool safe = true;
- char *p, *q;
+ const char *p = xs.buf[i];
- p = q = xs.buf[i];
- for (; *q; q++) {
+ for (const char *q = p; *q; q++) {
if (!strchr(_SHELL_SAFE, *q)) {
safe = false;
break;
@@ -378,7 +377,7 @@ cmdfput(FILE *fp, struct strs xs)
fputs(p, fp);
else {
putc('\'', fp);
- for (q = p; *q; q++) {
+ for (const char *q = p; *q; q++) {
if (*q == '\'')
fputs("'\"'\"'", fp);
else
@@ -585,8 +584,8 @@ tpenq(tpool *tp, tjob *fn, void *arg, tjob_free *free)
struct _tqueue *q = malloc(sizeof(*q));
assert(q != NULL);
*q = (struct _tqueue){
- .fn = fn,
- .arg = arg,
+ .fn = fn,
+ .arg = arg,
.free = free,
};