Krolyxon
Commit f2f4903

Branches

Refs →

nsxivf2f4903

apply clang-format

minus the bogus changes
Author
NRK
Date
2023-02-10 11:35 +0600
Committer
NRK · 2023-03-11 18:37 +0600
Parent
2434e83
Commit
f2f4903de4bd3ce06c03dd66f0c9a7dda97a3550

+110 −87

8 files changed

  1. M autoreload.c +13 −7
  2. M commands.c +8 −6
  3. M image.c +18 −18
  4. M main.c +26 −21
  5. M options.c +3 −2
  6. M thumbs.c +15 −11
  7. M util.c +11 −10
  8. M window.c +16 −12
M autoreload.c View
@@ -28,7 +28,10 @@
2828 #include <sys/inotify.h>
2929 #include <unistd.h>
3030
31−static struct { char *buf; size_t len; } scratch;
31+static struct {
32+ char *buf;
33+ size_t len;
34+} scratch;
3235
3336 void arl_init(arl_t *arl)
3437 {
@@ -94,7 +97,10 @@ bool arl_handle(arl_t *arl)
9497 char *ptr;
9598 const struct inotify_event *e;
9699 /* inotify_event aligned buffer */
97− static union { char d[4096]; struct inotify_event e; } buf;
100+ static union {
101+ char d[4096];
102+ struct inotify_event e;
103+ } buf;
98104
99105 while (true) {
100106 ssize_t len = read(arl->fd, buf.d, sizeof(buf.d));
@@ -105,7 +111,7 @@ bool arl_handle(arl_t *arl)
105111 break;
106112 }
107113 for (ptr = buf.d; ptr < buf.d + len; ptr += sizeof(*e) + e->len) {
108− e = (const struct inotify_event*) ptr;
114+ e = (const struct inotify_event *)ptr;
109115 if (e->wd == arl->wd_file && (e->mask & IN_CLOSE_WRITE)) {
110116 reload = true;
111117 } else if (e->wd == arl->wd_file && (e->mask & IN_DELETE_SELF)) {
@@ -128,18 +134,18 @@ void arl_init(arl_t *arl)
128134
129135 void arl_cleanup(arl_t *arl)
130136 {
131− (void) arl;
137+ (void)arl;
132138 }
133139
134140 void arl_add(arl_t *arl, const char *filepath)
135141 {
136− (void) arl;
137− (void) filepath;
142+ (void)arl;
143+ (void)filepath;
138144 }
139145
140146 bool arl_handle(arl_t *arl)
141147 {
142− (void) arl;
148+ (void)arl;
143149 return false;
144150 }
145151
M commands.c View
@@ -326,10 +326,10 @@ bool ci_drag(arg_t drag_mode)
326326
327327 while (true) {
328328 if (drag_mode == DRAG_ABSOLUTE) {
329− px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) /
330− (win.w*0.8) * (win.w - img.w * img.zoom);
331− py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) /
332− (win.h*0.8) * (win.h - img.h * img.zoom);
329+ px = MIN(MAX(0.0, x - win.w * 0.1), win.w * 0.8) /
330+ (win.w * 0.8) * (win.w - img.w * img.zoom);
331+ py = MIN(MAX(0.0, y - win.h * 0.1), win.h * 0.8) /
332+ (win.h * 0.8) * (win.h - img.h * img.zoom);
333333 } else {
334334 px = img.x + x - ox;
335335 py = img.y + y - oy;
@@ -343,7 +343,8 @@ bool ci_drag(arg_t drag_mode)
343343 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e);
344344 if (e.type == ButtonPress || e.type == ButtonRelease)
345345 break;
346− while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e));
346+ while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e))
347+ ;
347348 ox = x;
348349 oy = y;
349350 x = e.xmotion.x;
@@ -443,7 +444,8 @@ bool ct_drag_mark_image(arg_t _)
443444 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e);
444445 if (e.type == ButtonPress || e.type == ButtonRelease)
445446 break;
446− while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e));
447+ while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e))
448+ ;
447449 sel = tns_translate(&tns, e.xbutton.x, e.xbutton.y);
448450 }
449451 }
M image.c View
@@ -55,7 +55,7 @@ enum { DEF_WEBP_DELAY = 75 };
5555 #endif
5656
5757 #define ZOOM_MIN (zoom_levels[0] / 100)
58−#define ZOOM_MAX (zoom_levels[ARRLEN(zoom_levels)-1] / 100)
58+#define ZOOM_MAX (zoom_levels[ARRLEN(zoom_levels) - 1] / 100)
5959
6060 static int calc_cache_size(void)
6161 {
@@ -69,7 +69,7 @@ static int calc_cache_size(void)
6969 #endif
7070 if (pages < 0 || page_size < 0)
7171 return CACHE_SIZE_FALLBACK;
72− cache = (pages/100) * CACHE_SIZE_MEM_PERCENTAGE;
72+ cache = (pages / 100) * CACHE_SIZE_MEM_PERCENTAGE;
7373 cache *= page_size;
7474
7575 return MIN(cache, CACHE_SIZE_LIMIT);
@@ -234,12 +234,12 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file)
234234 while (ext) {
235235 if (ext_code == GRAPHICS_EXT_FUNC_CODE) {
236236 if (ext[1] & 1)
237− transp = (int) ext[4];
237+ transp = (int)ext[4];
238238 else
239239 transp = -1;
240240
241− delay = 10 * ((unsigned int) ext[3] << 8 | (unsigned int) ext[2]);
242− disposal = (unsigned int) ext[1] >> 2 & 0x7;
241+ delay = 10 * ((unsigned int)ext[3] << 8 | (unsigned int)ext[2]);
242+ disposal = (unsigned int)ext[1] >> 2 & 0x7;
243243 }
244244 ext = NULL;
245245 DGifGetExtensionNext(gif, &ext);
@@ -280,7 +280,7 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file)
280280 for (i = 0; i < sh; i++) {
281281 for (j = 0; j < sw; j++) {
282282 if (i < y || i >= y + h || j < x || j >= x + w ||
283− rows[i-y][j-x] == transp)
283+ rows[i - y][j - x] == transp)
284284 {
285285 if (prev_frame != NULL &&
286286 (prev_disposal != 2 || i < py || i >= py + ph ||
@@ -292,9 +292,9 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file)
292292 }
293293 } else {
294294 assert(cmap != NULL);
295− r = cmap->Colors[rows[i-y][j-x]].Red;
296− g = cmap->Colors[rows[i-y][j-x]].Green;
297− b = cmap->Colors[rows[i-y][j-x]].Blue;
295+ r = cmap->Colors[rows[i - y][j - x]].Red;
296+ g = cmap->Colors[rows[i - y][j - x]].Green;
297+ b = cmap->Colors[rows[i - y][j - x]].Blue;
298298 *ptr = 0xffu << 24 | r << 16 | g << 8 | b;
299299 }
300300 ptr++;
@@ -418,7 +418,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file)
418418 imlib_context_set_image(im);
419419 imlib_image_set_format("webp");
420420 /* Get an iterator of this frame - used for frame info (duration, etc.) */
421− WebPDemuxGetFrame(demux, m->cnt+1, &iter);
421+ WebPDemuxGetFrame(demux, m->cnt + 1, &iter);
422422 imlib_image_set_has_alpha((flags & ALPHA_FLAG) == ALPHA_FLAG);
423423 /* Store info for this frame */
424424 m->frames[m->cnt].im = im;
@@ -674,8 +674,8 @@ static bool img_fit(img_t *img)
674674 if (img->scalemode == SCALE_ZOOM)
675675 return false;
676676
677− zw = (float) img->win->w / (float) img->w;
678− zh = (float) img->win->h / (float) img->h;
677+ zw = (float)img->win->w / (float)img->w;
678+ zh = (float)img->win->h / (float)img->h;
679679
680680 switch (img->scalemode) {
681681 case SCALE_FILL:
@@ -693,7 +693,7 @@ static bool img_fit(img_t *img)
693693 }
694694 z = MIN(z, img->scalemode == SCALE_DOWN ? 1.0 : ZOOM_MAX);
695695
696− if (ABS(img->zoom - z) > 1.0/MAX(img->w, img->h)) {
696+ if (ABS(img->zoom - z) > 1.0 / MAX(img->w, img->h)) {
697697 img->zoom = z;
698698 img->dirty = title_dirty = true;
699699 return true;
@@ -839,14 +839,14 @@ bool img_zoom_to(img_t *img, float z)
839839
840840 bool img_zoom(img_t *img, int d)
841841 {
842− int i = d > 0 ? 0 : (int)ARRLEN(zoom_levels)-1;
842+ int i = d > 0 ? 0 : (int)ARRLEN(zoom_levels) - 1;
843843 while (i >= 0 && i < (int)ARRLEN(zoom_levels) &&
844− (d > 0 ? zoom_levels[i]/100 <= img->zoom : zoom_levels[i]/100 >= img->zoom))
844+ (d > 0 ? zoom_levels[i] / 100 <= img->zoom : zoom_levels[i] / 100 >= img->zoom))
845845 {
846846 i += d;
847847 }
848− i = MIN(MAX(i, 0), (int)ARRLEN(zoom_levels)-1);
849− return img_zoom_to(img, zoom_levels[i]/100);
848+ i = MIN(MAX(i, 0), (int)ARRLEN(zoom_levels) - 1);
849+ return img_zoom_to(img, zoom_levels[i] / 100);
850850 }
851851
852852 bool img_pos(img_t *img, float x, float y)
@@ -883,7 +883,7 @@ bool img_pan(img_t *img, direction_t dir, int d)
883883 float x, y;
884884
885885 if (d > 0) {
886− x = y = MAX(1, (float) d * img->zoom);
886+ x = y = MAX(1, (float)d * img->zoom);
887887 } else {
888888 x = img->win->w / (d < 0 ? 1 : PAN_FRACTION);
889889 y = img->win->h / (d < 0 ? 1 : PAN_FRACTION);
M main.c View
@@ -45,10 +45,11 @@
4545
4646 #define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \
4747 ((t1)->tv_usec - (t2)->tv_usec) / 1000)
48−#define TV_ADD_MSEC(tv,t) do { \
49− (tv)->tv_sec += (t) / 1000; \
50− (tv)->tv_usec += (t) % 1000 * 1000; \
51−} while (0)
48+#define TV_ADD_MSEC(tv, t) \
49+ do { \
50+ (tv)->tv_sec += (t) / 1000; \
51+ (tv)->tv_usec += (t) % 1000 * 1000; \
52+ } while (0)
5253
5354 typedef struct {
5455 int err;
@@ -112,8 +113,8 @@ static void cleanup(void)
112113 static bool xgetline(char **lineptr, size_t *n)
113114 {
114115 ssize_t len = getdelim(lineptr, n, options->using_null ? '\0' : '\n', stdin);
115− if (!options->using_null && len > 0 && (*lineptr)[len-1] == '\n')
116− (*lineptr)[len-1] = '\0';
116+ if (!options->using_null && len > 0 && (*lineptr)[len - 1] == '\n')
117+ (*lineptr)[len - 1] = '\0';
117118 return len > 0;
118119 }
119120
@@ -140,7 +141,7 @@ static void check_add_file(const char *filename, bool given)
140141 if (fileidx == filecnt) {
141142 filecnt *= 2;
142143 files = erealloc(files, filecnt * sizeof(*files));
143− memset(&files[filecnt/2], 0, filecnt/2 * sizeof(*files));
144+ memset(&files[filecnt / 2], 0, filecnt / 2 * sizeof(*files));
144145 }
145146
146147 files[fileidx].name = estrdup(filename);
@@ -193,8 +194,8 @@ void remove_file(int n, bool manual)
193194 markcnt--;
194195
195196 if (files[n].path != files[n].name)
196− free((void*) files[n].path);
197− free((void*) files[n].name);
197+ free((void *)files[n].path);
198+ free((void *)files[n].name);
198199 if (tns.thumbs != NULL)
199200 tns_unload(&tns, n);
200201
@@ -287,7 +288,7 @@ static void read_title(void)
287288 ssize_t n;
288289 char buf[512];
289290
290− if ((n = read(wintitle.fd, buf, sizeof(buf)-1)) > 0) {
291+ if ((n = read(wintitle.fd, buf, sizeof(buf) - 1)) > 0) {
291292 buf[n] = '\0';
292293 win_set_title(&win, buf, n);
293294 }
@@ -308,7 +309,7 @@ static void open_title(void)
308309 snprintf(h, ARRLEN(h), "%d", img.h);
309310 snprintf(z, ARRLEN(z), "%d", (int)(img.zoom * 100));
310311 }
311− snprintf(fidx, ARRLEN(fidx), "%d", fileidx+1);
312+ snprintf(fidx, ARRLEN(fidx), "%d", fileidx + 1);
312313 snprintf(fcnt, ARRLEN(fcnt), "%d", filecnt);
313314 construct_argv(argv, ARRLEN(argv), wintitle.f.cmd, files[fileidx].path,
314315 fidx, fcnt, w, h, z, NULL);
@@ -426,7 +427,8 @@ static void update_info(void)
426427 /* update bar contents */
427428 if (win.bar.h == 0 || extprefix)
428429 return;
429− for (fw = 0, i = filecnt; i > 0; fw++, i /= 10);
430+ for (fw = 0, i = filecnt; i > 0; fw++, i /= 10)
431+ ;
430432 mark = files[fileidx].flags & FF_MARK ? "* " : "";
431433 l->p = l->buf;
432434 r->p = r->buf;
@@ -452,9 +454,10 @@ static void update_info(void)
452454 bar_put(r, "B%+d" BAR_SEP, img.brightness);
453455 if (img.contrast)
454456 bar_put(r, "C%+d" BAR_SEP, img.contrast);
455− bar_put(r, "%3d%%" BAR_SEP, (int) (img.zoom * 100.0));
457+ bar_put(r, "%3d%%" BAR_SEP, (int)(img.zoom * 100.0));
456458 if (img.multi.cnt > 0) {
457− for (fn = 0, i = img.multi.cnt; i > 0; fn++, i /= 10);
459+ for (fn = 0, i = img.multi.cnt; i > 0; fn++, i /= 10)
460+ ;
458461 bar_put(r, "%0*d/%d" BAR_SEP, fn, img.multi.sel + 1, img.multi.cnt);
459462 }
460463 bar_put(r, "%0*d/%d", fw, fileidx + 1, filecnt);
@@ -623,7 +626,8 @@ static bool run_key_handler(const char *key, unsigned int mask)
623626 }
624627 }
625628 fclose(pfs);
626− while (waitpid(pid, NULL, 0) == -1 && errno == EINTR);
629+ while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
630+ ;
627631
628632 for (f = i = 0; f < fcnt; i++) {
629633 if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) {
@@ -640,7 +644,8 @@ static bool run_key_handler(const char *key, unsigned int mask)
640644 }
641645 }
642646 /* drop user input events that occurred while running the key handler */
643− while (XCheckIfEvent(win.env.dpy, &dump, is_input_ev, NULL));
647+ while (XCheckIfEvent(win.env.dpy, &dump, is_input_ev, NULL))
648+ ;
644649
645650 if (mode == MODE_IMAGE && changed) {
646651 img_close(&img, true);
@@ -699,7 +704,7 @@ static void on_keypress(XKeyEvent *kev)
699704 handle_key_handler(false);
700705 } else if (key >= '0' && key <= '9') {
701706 /* number prefix for commands */
702− prefix = prefix * 10 + (int) (key - '0');
707+ prefix = prefix * 10 + (int)(key - '0');
703708 return;
704709 } else {
705710 dirty = process_bindings(keys, ARRLEN(keys), ksym, kev->state, sh);
@@ -730,7 +735,7 @@ static void run(void)
730735 enum { FD_X, FD_INFO, FD_TITLE, FD_ARL, FD_CNT };
731736 struct pollfd pfd[FD_CNT];
732737 int timeout = 0;
733− const struct timespec ten_ms = {0, 10000000};
738+ const struct timespec ten_ms = { 0, 10000000 };
734739 bool discard, init_thumb, load_thumb, to_set;
735740 XEvent ev, nextev;
736741
@@ -795,7 +800,7 @@ static void run(void)
795800 break;
796801 case KeyPress:
797802 discard = (nextev.type == KeyPress || nextev.type == KeyRelease) &&
798− ev.xkey.keycode == nextev.xkey.keycode;
803+ ev.xkey.keycode == nextev.xkey.keycode;
799804 break;
800805 }
801806 }
@@ -806,7 +811,7 @@ static void run(void)
806811 on_buttonpress(&ev.xbutton);
807812 break;
808813 case ClientMessage:
809− if ((Atom) ev.xclient.data.l[0] == atoms[ATOM_WM_DELETE_WINDOW])
814+ if ((Atom)ev.xclient.data.l[0] == atoms[ATOM_WM_DELETE_WINDOW])
810815 cg_quit(EXIT_SUCCESS);
811816 break;
812817 case DestroyNotify:
@@ -859,7 +864,7 @@ int main(int argc, char *argv[])
859864 size_t n;
860865 const char *homedir, *dsuffix = "";
861866
862− setup_signal(SIGCHLD, SIG_DFL, SA_RESTART|SA_NOCLDSTOP|SA_NOCLDWAIT);
867+ setup_signal(SIGCHLD, SIG_DFL, SA_RESTART | SA_NOCLDSTOP | SA_NOCLDWAIT);
863868 setup_signal(SIGPIPE, SIG_IGN, 0);
864869
865870 setlocale(LC_COLLATE, "");
M options.c View
@@ -43,7 +43,8 @@ void print_usage(void)
4343 {
4444 printf("usage: %s [-abcfhiopqrtvZ0] [-A FRAMERATE] [-e WID] [-G GAMMA] "
4545 "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] "
46− "[-z ZOOM] FILES...\n", progname);
46+ "[-z ZOOM] FILES...\n",
47+ progname);
4748 }
4849
4950 static void print_version(void)
@@ -227,7 +228,7 @@ void parse_options(int argc, char **argv)
227228 if (*end != '\0' || n <= 0)
228229 error(EXIT_FAILURE, 0, "Invalid zoom level: %s", op.optarg);
229230 _options.scalemode = SCALE_ZOOM;
230− _options.zoom = (float) n / 100.0f;
231+ _options.zoom = (float)n / 100.0f;
231232 break;
232233 case '0':
233234 _options.using_null = true;
M thumbs.c View
@@ -36,7 +36,7 @@
3636
3737 static char *cache_dir;
3838
39−static char* tns_cache_filepath(const char *filepath)
39+static char *tns_cache_filepath(const char *filepath)
4040 {
4141 size_t len;
4242 char *cfile = NULL;
@@ -201,8 +201,8 @@ static Imlib_Image tns_scale_down(Imlib_Image im, int dim)
201201 imlib_context_set_image(im);
202202 w = imlib_image_get_width();
203203 h = imlib_image_get_height();
204− zw = (float) dim / (float) w;
205− zh = (float) dim / (float) h;
204+ zw = (float)dim / (float)w;
205+ zh = (float)dim / (float)h;
206206 z = MIN(zw, zh);
207207 z = MIN(z, 1.0);
208208
@@ -219,7 +219,7 @@ static Imlib_Image tns_scale_down(Imlib_Image im, int dim)
219219
220220 bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
221221 {
222− int maxwh = thumb_sizes[ARRLEN(thumb_sizes)-1];
222+ int maxwh = thumb_sizes[ARRLEN(thumb_sizes) - 1];
223223 bool cache_hit = false;
224224 char *cfile;
225225 thumb_t *t;
@@ -290,8 +290,8 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
290290 h = imlib_image_get_height();
291291
292292 if (pw > w && ph > h && (pw - ph >= 0) == (w - h >= 0)) {
293− zw = (float) pw / (float) w;
294− zh = (float) ph / (float) h;
293+ zw = (float)pw / (float)w;
294+ zh = (float)ph / (float)h;
295295 if (zw < zh) {
296296 pw /= zh;
297297 x = (w - pw) / 2;
@@ -343,10 +343,14 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
343343 }
344344 file->flags |= FF_TN_INIT;
345345
346− if (n == tns->initnext)
347− while (++tns->initnext < *tns->cnt && ((++file)->flags & FF_TN_INIT));
348− if (n == tns->loadnext && !cache_only)
349− while (++tns->loadnext < tns->end && (++t)->im != NULL);
346+ if (n == tns->initnext) {
347+ while (++tns->initnext < *tns->cnt && ((++file)->flags & FF_TN_INIT))
348+ ;
349+ }
350+ if (n == tns->loadnext && !cache_only) {
351+ while (++tns->loadnext < tns->end && (++t)->im != NULL)
352+ ;
353+ }
350354
351355 return true;
352356 }
@@ -557,7 +561,7 @@ bool tns_zoom(tns_t *tns, int d)
557561 oldzl = tns->zl;
558562 tns->zl += -(d < 0) + (d > 0);
559563 tns->zl = MAX(tns->zl, 0);
560− tns->zl = MIN(tns->zl, (int)ARRLEN(thumb_sizes)-1);
564+ tns->zl = MIN(tns->zl, (int)ARRLEN(thumb_sizes) - 1);
561565
562566 tns->bw = ((thumb_sizes[tns->zl] - 1) >> 5) + 1;
563567 tns->bw = MIN(tns->bw, 4);
M util.c View
@@ -32,7 +32,7 @@
3232 extern char **environ;
3333 const char *progname = "nsxiv";
3434
35−void* emalloc(size_t size)
35+void *emalloc(size_t size)
3636 {
3737 void *ptr;
3838
@@ -42,7 +42,7 @@ void* emalloc(size_t size)
4242 return ptr;
4343 }
4444
45−void* ecalloc(size_t nmemb, size_t size)
45+void *ecalloc(size_t nmemb, size_t size)
4646 {
4747 void *ptr;
4848
@@ -52,7 +52,7 @@ void* ecalloc(size_t nmemb, size_t size)
5252 return ptr;
5353 }
5454
55−void* erealloc(void *ptr, size_t size)
55+void *erealloc(void *ptr, size_t size)
5656 {
5757 ptr = realloc(ptr, size);
5858 if (ptr == NULL)
@@ -60,13 +60,13 @@ void* erealloc(void *ptr, size_t size)
6060 return ptr;
6161 }
6262
63−char* estrdup(const char *s)
63+char *estrdup(const char *s)
6464 {
6565 size_t n = strlen(s) + 1;
6666 return memcpy(emalloc(n), s, n);
6767 }
6868
69−void error(int eval, int err, const char* fmt, ...)
69+void error(int eval, int err, const char *fmt, ...)
7070 {
7171 va_list ap;
7272
@@ -102,7 +102,7 @@ int r_opendir(r_dir_t *rdir, const char *dirname, bool recursive)
102102 rdir->stack = emalloc(rdir->stcap * sizeof(*rdir->stack));
103103 rdir->stlen = 0;
104104
105− rdir->name = (char*) dirname;
105+ rdir->name = (char *)dirname;
106106 rdir->d = 0;
107107 rdir->recursive = recursive;
108108
@@ -133,7 +133,7 @@ int r_closedir(r_dir_t *rdir)
133133 return ret;
134134 }
135135
136−char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
136+char *r_readdir(r_dir_t *rdir, bool skip_dotfiles)
137137 {
138138 size_t len;
139139 char *filename;
@@ -154,7 +154,7 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
154154 len = strlen(rdir->name) + strlen(dentry->d_name) + 2;
155155 filename = emalloc(len);
156156 snprintf(filename, len, "%s%s%s", rdir->name,
157− rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/",
157+ rdir->name[strlen(rdir->name) - 1] == '/' ? "" : "/",
158158 dentry->d_name);
159159
160160 if (stat(filename, &fstats) < 0) {
@@ -203,7 +203,8 @@ int r_mkdir(char *path)
203203 s++;
204204 continue;
205205 }
206− for (; *s != '\0' && *s != '/'; s++);
206+ for (; *s != '\0' && *s != '/'; s++)
207+ ;
207208 c = *s;
208209 *s = '\0';
209210 if (mkdir(path, 0755) == -1) {
@@ -226,7 +227,7 @@ void construct_argv(char **argv, unsigned int len, ...)
226227 for (i = 0; i < len; ++i)
227228 argv[i] = va_arg(args, char *);
228229 va_end(args);
229− assert(argv[len-1] == NULL && "argv should be NULL terminated");
230+ assert(argv[len - 1] == NULL && "argv should be NULL terminated");
230231 }
231232
232233 static int mkspawn_pipe(posix_spawn_file_actions_t *fa, const char *cmd, int *pfd, int dupidx)
M window.c View
@@ -34,7 +34,7 @@
3434
3535 #if HAVE_LIBFONTS
3636 #include "utf8.h"
37−#define UTF8_PADDING 4 /* utf8_decode requires 4 bytes of zero padding */
37+#define UTF8_PADDING 4 /* utf8_decode requires 4 bytes of zero padding */
3838 #define TEXTWIDTH(win, text, len) \
3939 win_draw_text(win, NULL, NULL, 0, 0, text, len, 0)
4040 #endif
@@ -56,8 +56,12 @@ static struct {
5656 int name;
5757 Cursor icon;
5858 } cursors[CURSOR_COUNT] = {
59− { XC_left_ptr }, { XC_dotbox }, { XC_fleur }, { XC_watch },
60− { XC_sb_left_arrow }, { XC_sb_right_arrow }
59+ { XC_left_ptr },
60+ { XC_dotbox },
61+ { XC_fleur },
62+ { XC_watch },
63+ { XC_sb_left_arrow },
64+ { XC_sb_right_arrow }
6165 };
6266
6367 #if HAVE_LIBFONTS
@@ -90,7 +94,7 @@ static void win_alloc_color(const win_env_t *e, const char *name, XColor *col)
9094 error(EXIT_FAILURE, 0, "Error allocating color '%s'", name);
9195 }
9296
93−static const char* win_res(XrmDatabase db, const char *name, const char *def)
97+static const char *win_res(XrmDatabase db, const char *name, const char *def)
9498 {
9599 char *type;
96100 XrmValue ret;
@@ -246,7 +250,7 @@ void win_open(win_t *win)
246250 /* set the _NET_WM_PID */
247251 pid = getpid();
248252 XChangeProperty(e->dpy, win->xwin, atoms[ATOM__NET_WM_PID], XA_CARDINAL,
249− 32, PropModeReplace, (unsigned char *) &pid, 1);
253+ 32, PropModeReplace, (unsigned char *)&pid, 1);
250254 if (gethostname(hostname, ARRLEN(hostname)) == 0) {
251255 XTextProperty tp;
252256 tp.value = (unsigned char *)hostname;
@@ -272,7 +276,7 @@ void win_open(win_t *win)
272276
273277 gc = XCreateGC(e->dpy, win->xwin, 0, None);
274278
275− n = icons[ARRLEN(icons)-1].size;
279+ n = icons[ARRLEN(icons) - 1].size;
276280 icon_data = emalloc((n * n + 2) * sizeof(*icon_data));
277281
278282 for (i = 0; i < (int)ARRLEN(icons); i++) {
@@ -286,7 +290,7 @@ void win_open(win_t *win)
286290 }
287291 XChangeProperty(e->dpy, win->xwin, atoms[ATOM__NET_WM_ICON], XA_CARDINAL, 32,
288292 i == 0 ? PropModeReplace : PropModeAppend,
289− (unsigned char *) icon_data, n);
293+ (unsigned char *)icon_data, n);
290294 }
291295 free(icon_data);
292296
@@ -311,7 +315,7 @@ void win_open(win_t *win)
311315 if (options->fullscreen) {
312316 XChangeProperty(e->dpy, win->xwin, atoms[ATOM__NET_WM_STATE],
313317 XA_ATOM, 32, PropModeReplace,
314− (unsigned char *) &atoms[ATOM__NET_WM_STATE_FULLSCREEN], 1);
318+ (unsigned char *)&atoms[ATOM__NET_WM_STATE_FULLSCREEN], 1);
315319 }
316320
317321 win->h -= win->bar.h;
@@ -432,10 +436,10 @@ static int win_draw_text(win_t *win, XftDraw *d, const XftColor *color,
432436 FC_SIZE, FcTypeDouble, fontsize, NULL);
433437 FcCharSetDestroy(fccharset);
434438 }
435− XftTextExtentsUtf8(win->env.dpy, f, (XftChar8*)t, next - t, &ext);
439+ XftTextExtentsUtf8(win->env.dpy, f, (XftChar8 *)t, next - t, &ext);
436440 tw += ext.xOff;
437441 if (tw <= w) {
438− XftDrawStringUtf8(d, color, f, x, y, (XftChar8*)t, next - t);
442+ XftDrawStringUtf8(d, color, f, x, y, (XftChar8 *)t, next - t);
439443 x += ext.xOff;
440444 }
441445 if (f != font)
@@ -456,7 +460,7 @@ static void win_draw_bar(win_t *win)
456460 r = &win->bar.r;
457461 assert(l->buf != NULL && r->buf != NULL);
458462 y = (win->bar.top ? 0 : win->h) + font->ascent + V_TEXT_PAD;
459− w = win->w - 2*H_TEXT_PAD;
463+ w = win->w - 2 * H_TEXT_PAD;
460464 d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, e->cmap);
461465
462466 XSetForeground(e->dpy, gc, win->bar_bg.pixel);
@@ -482,7 +486,7 @@ static void win_draw_bar(win_t *win)
482486 #else
483487 static void win_draw_bar(win_t *win)
484488 {
485− (void) win;
489+ (void)win;
486490 }
487491 #endif /* HAVE_LIBFONTS */
488492