nsxivf2f4903
apply clang-format
minus the bogus changes
+110 −87
8 files changed
- M autoreload.c +13 −7
- M commands.c +8 −6
- M image.c +18 −18
- M main.c +26 −21
- M options.c +3 −2
- M thumbs.c +15 −11
- M util.c +11 −10
- M window.c +16 −12
| @@ -28,7 +28,10 @@ | |||
| 28 | 28 | #include <sys/inotify.h> | |
| 29 | 29 | #include <unistd.h> | |
| 30 | 30 | ||
| 31 | − | static struct { char *buf; size_t len; } scratch; | |
| 31 | + | static struct { | |
| 32 | + | char *buf; | |
| 33 | + | size_t len; | |
| 34 | + | } scratch; | |
| 32 | 35 | ||
| 33 | 36 | void arl_init(arl_t *arl) | |
| 34 | 37 | { | |
| @@ -94,7 +97,10 @@ bool arl_handle(arl_t *arl) | |||
| 94 | 97 | char *ptr; | |
| 95 | 98 | const struct inotify_event *e; | |
| 96 | 99 | /* 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; | |
| 98 | 104 | ||
| 99 | 105 | while (true) { | |
| 100 | 106 | ssize_t len = read(arl->fd, buf.d, sizeof(buf.d)); | |
| @@ -105,7 +111,7 @@ bool arl_handle(arl_t *arl) | |||
| 105 | 111 | break; | |
| 106 | 112 | } | |
| 107 | 113 | 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; | |
| 109 | 115 | if (e->wd == arl->wd_file && (e->mask & IN_CLOSE_WRITE)) { | |
| 110 | 116 | reload = true; | |
| 111 | 117 | } else if (e->wd == arl->wd_file && (e->mask & IN_DELETE_SELF)) { | |
| @@ -128,18 +134,18 @@ void arl_init(arl_t *arl) | |||
| 128 | 134 | ||
| 129 | 135 | void arl_cleanup(arl_t *arl) | |
| 130 | 136 | { | |
| 131 | − | (void) arl; | |
| 137 | + | (void)arl; | |
| 132 | 138 | } | |
| 133 | 139 | ||
| 134 | 140 | void arl_add(arl_t *arl, const char *filepath) | |
| 135 | 141 | { | |
| 136 | − | (void) arl; | |
| 137 | − | (void) filepath; | |
| 142 | + | (void)arl; | |
| 143 | + | (void)filepath; | |
| 138 | 144 | } | |
| 139 | 145 | ||
| 140 | 146 | bool arl_handle(arl_t *arl) | |
| 141 | 147 | { | |
| 142 | − | (void) arl; | |
| 148 | + | (void)arl; | |
| 143 | 149 | return false; | |
| 144 | 150 | } | |
| 145 | 151 | ||
| @@ -326,10 +326,10 @@ bool ci_drag(arg_t drag_mode) | |||
| 326 | 326 | ||
| 327 | 327 | while (true) { | |
| 328 | 328 | 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); | |
| 333 | 333 | } else { | |
| 334 | 334 | px = img.x + x - ox; | |
| 335 | 335 | py = img.y + y - oy; | |
| @@ -343,7 +343,8 @@ bool ci_drag(arg_t drag_mode) | |||
| 343 | 343 | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e); | |
| 344 | 344 | if (e.type == ButtonPress || e.type == ButtonRelease) | |
| 345 | 345 | break; | |
| 346 | − | while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e)); | |
| 346 | + | while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e)) | |
| 347 | + | ; | |
| 347 | 348 | ox = x; | |
| 348 | 349 | oy = y; | |
| 349 | 350 | x = e.xmotion.x; | |
| @@ -443,7 +444,8 @@ bool ct_drag_mark_image(arg_t _) | |||
| 443 | 444 | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e); | |
| 444 | 445 | if (e.type == ButtonPress || e.type == ButtonRelease) | |
| 445 | 446 | break; | |
| 446 | − | while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e)); | |
| 447 | + | while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e)) | |
| 448 | + | ; | |
| 447 | 449 | sel = tns_translate(&tns, e.xbutton.x, e.xbutton.y); | |
| 448 | 450 | } | |
| 449 | 451 | } | |
| @@ -55,7 +55,7 @@ enum { DEF_WEBP_DELAY = 75 }; | |||
| 55 | 55 | #endif | |
| 56 | 56 | ||
| 57 | 57 | #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) | |
| 59 | 59 | ||
| 60 | 60 | static int calc_cache_size(void) | |
| 61 | 61 | { | |
| @@ -69,7 +69,7 @@ static int calc_cache_size(void) | |||
| 69 | 69 | #endif | |
| 70 | 70 | if (pages < 0 || page_size < 0) | |
| 71 | 71 | return CACHE_SIZE_FALLBACK; | |
| 72 | − | cache = (pages/100) * CACHE_SIZE_MEM_PERCENTAGE; | |
| 72 | + | cache = (pages / 100) * CACHE_SIZE_MEM_PERCENTAGE; | |
| 73 | 73 | cache *= page_size; | |
| 74 | 74 | ||
| 75 | 75 | return MIN(cache, CACHE_SIZE_LIMIT); | |
| @@ -234,12 +234,12 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file) | |||
| 234 | 234 | while (ext) { | |
| 235 | 235 | if (ext_code == GRAPHICS_EXT_FUNC_CODE) { | |
| 236 | 236 | if (ext[1] & 1) | |
| 237 | − | transp = (int) ext[4]; | |
| 237 | + | transp = (int)ext[4]; | |
| 238 | 238 | else | |
| 239 | 239 | transp = -1; | |
| 240 | 240 | ||
| 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; | |
| 243 | 243 | } | |
| 244 | 244 | ext = NULL; | |
| 245 | 245 | DGifGetExtensionNext(gif, &ext); | |
| @@ -280,7 +280,7 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file) | |||
| 280 | 280 | for (i = 0; i < sh; i++) { | |
| 281 | 281 | for (j = 0; j < sw; j++) { | |
| 282 | 282 | 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) | |
| 284 | 284 | { | |
| 285 | 285 | if (prev_frame != NULL && | |
| 286 | 286 | (prev_disposal != 2 || i < py || i >= py + ph || | |
| @@ -292,9 +292,9 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file) | |||
| 292 | 292 | } | |
| 293 | 293 | } else { | |
| 294 | 294 | 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; | |
| 298 | 298 | *ptr = 0xffu << 24 | r << 16 | g << 8 | b; | |
| 299 | 299 | } | |
| 300 | 300 | ptr++; | |
| @@ -418,7 +418,7 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) | |||
| 418 | 418 | imlib_context_set_image(im); | |
| 419 | 419 | imlib_image_set_format("webp"); | |
| 420 | 420 | /* 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); | |
| 422 | 422 | imlib_image_set_has_alpha((flags & ALPHA_FLAG) == ALPHA_FLAG); | |
| 423 | 423 | /* Store info for this frame */ | |
| 424 | 424 | m->frames[m->cnt].im = im; | |
| @@ -674,8 +674,8 @@ static bool img_fit(img_t *img) | |||
| 674 | 674 | if (img->scalemode == SCALE_ZOOM) | |
| 675 | 675 | return false; | |
| 676 | 676 | ||
| 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; | |
| 679 | 679 | ||
| 680 | 680 | switch (img->scalemode) { | |
| 681 | 681 | case SCALE_FILL: | |
| @@ -693,7 +693,7 @@ static bool img_fit(img_t *img) | |||
| 693 | 693 | } | |
| 694 | 694 | z = MIN(z, img->scalemode == SCALE_DOWN ? 1.0 : ZOOM_MAX); | |
| 695 | 695 | ||
| 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)) { | |
| 697 | 697 | img->zoom = z; | |
| 698 | 698 | img->dirty = title_dirty = true; | |
| 699 | 699 | return true; | |
| @@ -839,14 +839,14 @@ bool img_zoom_to(img_t *img, float z) | |||
| 839 | 839 | ||
| 840 | 840 | bool img_zoom(img_t *img, int d) | |
| 841 | 841 | { | |
| 842 | − | int i = d > 0 ? 0 : (int)ARRLEN(zoom_levels)-1; | |
| 842 | + | int i = d > 0 ? 0 : (int)ARRLEN(zoom_levels) - 1; | |
| 843 | 843 | 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)) | |
| 845 | 845 | { | |
| 846 | 846 | i += d; | |
| 847 | 847 | } | |
| 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); | |
| 850 | 850 | } | |
| 851 | 851 | ||
| 852 | 852 | 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) | |||
| 883 | 883 | float x, y; | |
| 884 | 884 | ||
| 885 | 885 | if (d > 0) { | |
| 886 | − | x = y = MAX(1, (float) d * img->zoom); | |
| 886 | + | x = y = MAX(1, (float)d * img->zoom); | |
| 887 | 887 | } else { | |
| 888 | 888 | x = img->win->w / (d < 0 ? 1 : PAN_FRACTION); | |
| 889 | 889 | y = img->win->h / (d < 0 ? 1 : PAN_FRACTION); | |
| @@ -45,10 +45,11 @@ | |||
| 45 | 45 | ||
| 46 | 46 | #define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \ | |
| 47 | 47 | ((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) | |
| 52 | 53 | ||
| 53 | 54 | typedef struct { | |
| 54 | 55 | int err; | |
| @@ -112,8 +113,8 @@ static void cleanup(void) | |||
| 112 | 113 | static bool xgetline(char **lineptr, size_t *n) | |
| 113 | 114 | { | |
| 114 | 115 | 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'; | |
| 117 | 118 | return len > 0; | |
| 118 | 119 | } | |
| 119 | 120 | ||
| @@ -140,7 +141,7 @@ static void check_add_file(const char *filename, bool given) | |||
| 140 | 141 | if (fileidx == filecnt) { | |
| 141 | 142 | filecnt *= 2; | |
| 142 | 143 | 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)); | |
| 144 | 145 | } | |
| 145 | 146 | ||
| 146 | 147 | files[fileidx].name = estrdup(filename); | |
| @@ -193,8 +194,8 @@ void remove_file(int n, bool manual) | |||
| 193 | 194 | markcnt--; | |
| 194 | 195 | ||
| 195 | 196 | 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); | |
| 198 | 199 | if (tns.thumbs != NULL) | |
| 199 | 200 | tns_unload(&tns, n); | |
| 200 | 201 | ||
| @@ -287,7 +288,7 @@ static void read_title(void) | |||
| 287 | 288 | ssize_t n; | |
| 288 | 289 | char buf[512]; | |
| 289 | 290 | ||
| 290 | − | if ((n = read(wintitle.fd, buf, sizeof(buf)-1)) > 0) { | |
| 291 | + | if ((n = read(wintitle.fd, buf, sizeof(buf) - 1)) > 0) { | |
| 291 | 292 | buf[n] = '\0'; | |
| 292 | 293 | win_set_title(&win, buf, n); | |
| 293 | 294 | } | |
| @@ -308,7 +309,7 @@ static void open_title(void) | |||
| 308 | 309 | snprintf(h, ARRLEN(h), "%d", img.h); | |
| 309 | 310 | snprintf(z, ARRLEN(z), "%d", (int)(img.zoom * 100)); | |
| 310 | 311 | } | |
| 311 | − | snprintf(fidx, ARRLEN(fidx), "%d", fileidx+1); | |
| 312 | + | snprintf(fidx, ARRLEN(fidx), "%d", fileidx + 1); | |
| 312 | 313 | snprintf(fcnt, ARRLEN(fcnt), "%d", filecnt); | |
| 313 | 314 | construct_argv(argv, ARRLEN(argv), wintitle.f.cmd, files[fileidx].path, | |
| 314 | 315 | fidx, fcnt, w, h, z, NULL); | |
| @@ -426,7 +427,8 @@ static void update_info(void) | |||
| 426 | 427 | /* update bar contents */ | |
| 427 | 428 | if (win.bar.h == 0 || extprefix) | |
| 428 | 429 | return; | |
| 429 | − | for (fw = 0, i = filecnt; i > 0; fw++, i /= 10); | |
| 430 | + | for (fw = 0, i = filecnt; i > 0; fw++, i /= 10) | |
| 431 | + | ; | |
| 430 | 432 | mark = files[fileidx].flags & FF_MARK ? "* " : ""; | |
| 431 | 433 | l->p = l->buf; | |
| 432 | 434 | r->p = r->buf; | |
| @@ -452,9 +454,10 @@ static void update_info(void) | |||
| 452 | 454 | bar_put(r, "B%+d" BAR_SEP, img.brightness); | |
| 453 | 455 | if (img.contrast) | |
| 454 | 456 | 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)); | |
| 456 | 458 | 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 | + | ; | |
| 458 | 461 | bar_put(r, "%0*d/%d" BAR_SEP, fn, img.multi.sel + 1, img.multi.cnt); | |
| 459 | 462 | } | |
| 460 | 463 | 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) | |||
| 623 | 626 | } | |
| 624 | 627 | } | |
| 625 | 628 | fclose(pfs); | |
| 626 | − | while (waitpid(pid, NULL, 0) == -1 && errno == EINTR); | |
| 629 | + | while (waitpid(pid, NULL, 0) == -1 && errno == EINTR) | |
| 630 | + | ; | |
| 627 | 631 | ||
| 628 | 632 | for (f = i = 0; f < fcnt; i++) { | |
| 629 | 633 | 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) | |||
| 640 | 644 | } | |
| 641 | 645 | } | |
| 642 | 646 | /* 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 | + | ; | |
| 644 | 649 | ||
| 645 | 650 | if (mode == MODE_IMAGE && changed) { | |
| 646 | 651 | img_close(&img, true); | |
| @@ -699,7 +704,7 @@ static void on_keypress(XKeyEvent *kev) | |||
| 699 | 704 | handle_key_handler(false); | |
| 700 | 705 | } else if (key >= '0' && key <= '9') { | |
| 701 | 706 | /* number prefix for commands */ | |
| 702 | − | prefix = prefix * 10 + (int) (key - '0'); | |
| 707 | + | prefix = prefix * 10 + (int)(key - '0'); | |
| 703 | 708 | return; | |
| 704 | 709 | } else { | |
| 705 | 710 | dirty = process_bindings(keys, ARRLEN(keys), ksym, kev->state, sh); | |
| @@ -730,7 +735,7 @@ static void run(void) | |||
| 730 | 735 | enum { FD_X, FD_INFO, FD_TITLE, FD_ARL, FD_CNT }; | |
| 731 | 736 | struct pollfd pfd[FD_CNT]; | |
| 732 | 737 | int timeout = 0; | |
| 733 | − | const struct timespec ten_ms = {0, 10000000}; | |
| 738 | + | const struct timespec ten_ms = { 0, 10000000 }; | |
| 734 | 739 | bool discard, init_thumb, load_thumb, to_set; | |
| 735 | 740 | XEvent ev, nextev; | |
| 736 | 741 | ||
| @@ -795,7 +800,7 @@ static void run(void) | |||
| 795 | 800 | break; | |
| 796 | 801 | case KeyPress: | |
| 797 | 802 | discard = (nextev.type == KeyPress || nextev.type == KeyRelease) && | |
| 798 | − | ev.xkey.keycode == nextev.xkey.keycode; | |
| 803 | + | ev.xkey.keycode == nextev.xkey.keycode; | |
| 799 | 804 | break; | |
| 800 | 805 | } | |
| 801 | 806 | } | |
| @@ -806,7 +811,7 @@ static void run(void) | |||
| 806 | 811 | on_buttonpress(&ev.xbutton); | |
| 807 | 812 | break; | |
| 808 | 813 | 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]) | |
| 810 | 815 | cg_quit(EXIT_SUCCESS); | |
| 811 | 816 | break; | |
| 812 | 817 | case DestroyNotify: | |
| @@ -859,7 +864,7 @@ int main(int argc, char *argv[]) | |||
| 859 | 864 | size_t n; | |
| 860 | 865 | const char *homedir, *dsuffix = ""; | |
| 861 | 866 | ||
| 862 | − | setup_signal(SIGCHLD, SIG_DFL, SA_RESTART|SA_NOCLDSTOP|SA_NOCLDWAIT); | |
| 867 | + | setup_signal(SIGCHLD, SIG_DFL, SA_RESTART | SA_NOCLDSTOP | SA_NOCLDWAIT); | |
| 863 | 868 | setup_signal(SIGPIPE, SIG_IGN, 0); | |
| 864 | 869 | ||
| 865 | 870 | setlocale(LC_COLLATE, ""); | |
| @@ -43,7 +43,8 @@ void print_usage(void) | |||
| 43 | 43 | { | |
| 44 | 44 | printf("usage: %s [-abcfhiopqrtvZ0] [-A FRAMERATE] [-e WID] [-G GAMMA] " | |
| 45 | 45 | "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] " | |
| 46 | − | "[-z ZOOM] FILES...\n", progname); | |
| 46 | + | "[-z ZOOM] FILES...\n", | |
| 47 | + | progname); | |
| 47 | 48 | } | |
| 48 | 49 | ||
| 49 | 50 | static void print_version(void) | |
| @@ -227,7 +228,7 @@ void parse_options(int argc, char **argv) | |||
| 227 | 228 | if (*end != '\0' || n <= 0) | |
| 228 | 229 | error(EXIT_FAILURE, 0, "Invalid zoom level: %s", op.optarg); | |
| 229 | 230 | _options.scalemode = SCALE_ZOOM; | |
| 230 | − | _options.zoom = (float) n / 100.0f; | |
| 231 | + | _options.zoom = (float)n / 100.0f; | |
| 231 | 232 | break; | |
| 232 | 233 | case '0': | |
| 233 | 234 | _options.using_null = true; | |
| @@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | static char *cache_dir; | |
| 38 | 38 | ||
| 39 | − | static char* tns_cache_filepath(const char *filepath) | |
| 39 | + | static char *tns_cache_filepath(const char *filepath) | |
| 40 | 40 | { | |
| 41 | 41 | size_t len; | |
| 42 | 42 | char *cfile = NULL; | |
| @@ -201,8 +201,8 @@ static Imlib_Image tns_scale_down(Imlib_Image im, int dim) | |||
| 201 | 201 | imlib_context_set_image(im); | |
| 202 | 202 | w = imlib_image_get_width(); | |
| 203 | 203 | 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; | |
| 206 | 206 | z = MIN(zw, zh); | |
| 207 | 207 | z = MIN(z, 1.0); | |
| 208 | 208 | ||
| @@ -219,7 +219,7 @@ static Imlib_Image tns_scale_down(Imlib_Image im, int dim) | |||
| 219 | 219 | ||
| 220 | 220 | bool tns_load(tns_t *tns, int n, bool force, bool cache_only) | |
| 221 | 221 | { | |
| 222 | − | int maxwh = thumb_sizes[ARRLEN(thumb_sizes)-1]; | |
| 222 | + | int maxwh = thumb_sizes[ARRLEN(thumb_sizes) - 1]; | |
| 223 | 223 | bool cache_hit = false; | |
| 224 | 224 | char *cfile; | |
| 225 | 225 | thumb_t *t; | |
| @@ -290,8 +290,8 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) | |||
| 290 | 290 | h = imlib_image_get_height(); | |
| 291 | 291 | ||
| 292 | 292 | 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; | |
| 295 | 295 | if (zw < zh) { | |
| 296 | 296 | pw /= zh; | |
| 297 | 297 | x = (w - pw) / 2; | |
| @@ -343,10 +343,14 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) | |||
| 343 | 343 | } | |
| 344 | 344 | file->flags |= FF_TN_INIT; | |
| 345 | 345 | ||
| 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 | + | } | |
| 350 | 354 | ||
| 351 | 355 | return true; | |
| 352 | 356 | } | |
| @@ -557,7 +561,7 @@ bool tns_zoom(tns_t *tns, int d) | |||
| 557 | 561 | oldzl = tns->zl; | |
| 558 | 562 | tns->zl += -(d < 0) + (d > 0); | |
| 559 | 563 | 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); | |
| 561 | 565 | ||
| 562 | 566 | tns->bw = ((thumb_sizes[tns->zl] - 1) >> 5) + 1; | |
| 563 | 567 | tns->bw = MIN(tns->bw, 4); | |
| @@ -32,7 +32,7 @@ | |||
| 32 | 32 | extern char **environ; | |
| 33 | 33 | const char *progname = "nsxiv"; | |
| 34 | 34 | ||
| 35 | − | void* emalloc(size_t size) | |
| 35 | + | void *emalloc(size_t size) | |
| 36 | 36 | { | |
| 37 | 37 | void *ptr; | |
| 38 | 38 | ||
| @@ -42,7 +42,7 @@ void* emalloc(size_t size) | |||
| 42 | 42 | return ptr; | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | − | void* ecalloc(size_t nmemb, size_t size) | |
| 45 | + | void *ecalloc(size_t nmemb, size_t size) | |
| 46 | 46 | { | |
| 47 | 47 | void *ptr; | |
| 48 | 48 | ||
| @@ -52,7 +52,7 @@ void* ecalloc(size_t nmemb, size_t size) | |||
| 52 | 52 | return ptr; | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | − | void* erealloc(void *ptr, size_t size) | |
| 55 | + | void *erealloc(void *ptr, size_t size) | |
| 56 | 56 | { | |
| 57 | 57 | ptr = realloc(ptr, size); | |
| 58 | 58 | if (ptr == NULL) | |
| @@ -60,13 +60,13 @@ void* erealloc(void *ptr, size_t size) | |||
| 60 | 60 | return ptr; | |
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | − | char* estrdup(const char *s) | |
| 63 | + | char *estrdup(const char *s) | |
| 64 | 64 | { | |
| 65 | 65 | size_t n = strlen(s) + 1; | |
| 66 | 66 | return memcpy(emalloc(n), s, n); | |
| 67 | 67 | } | |
| 68 | 68 | ||
| 69 | − | void error(int eval, int err, const char* fmt, ...) | |
| 69 | + | void error(int eval, int err, const char *fmt, ...) | |
| 70 | 70 | { | |
| 71 | 71 | va_list ap; | |
| 72 | 72 | ||
| @@ -102,7 +102,7 @@ int r_opendir(r_dir_t *rdir, const char *dirname, bool recursive) | |||
| 102 | 102 | rdir->stack = emalloc(rdir->stcap * sizeof(*rdir->stack)); | |
| 103 | 103 | rdir->stlen = 0; | |
| 104 | 104 | ||
| 105 | − | rdir->name = (char*) dirname; | |
| 105 | + | rdir->name = (char *)dirname; | |
| 106 | 106 | rdir->d = 0; | |
| 107 | 107 | rdir->recursive = recursive; | |
| 108 | 108 | ||
| @@ -133,7 +133,7 @@ int r_closedir(r_dir_t *rdir) | |||
| 133 | 133 | return ret; | |
| 134 | 134 | } | |
| 135 | 135 | ||
| 136 | − | char* r_readdir(r_dir_t *rdir, bool skip_dotfiles) | |
| 136 | + | char *r_readdir(r_dir_t *rdir, bool skip_dotfiles) | |
| 137 | 137 | { | |
| 138 | 138 | size_t len; | |
| 139 | 139 | char *filename; | |
| @@ -154,7 +154,7 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles) | |||
| 154 | 154 | len = strlen(rdir->name) + strlen(dentry->d_name) + 2; | |
| 155 | 155 | filename = emalloc(len); | |
| 156 | 156 | snprintf(filename, len, "%s%s%s", rdir->name, | |
| 157 | − | rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/", | |
| 157 | + | rdir->name[strlen(rdir->name) - 1] == '/' ? "" : "/", | |
| 158 | 158 | dentry->d_name); | |
| 159 | 159 | ||
| 160 | 160 | if (stat(filename, &fstats) < 0) { | |
| @@ -203,7 +203,8 @@ int r_mkdir(char *path) | |||
| 203 | 203 | s++; | |
| 204 | 204 | continue; | |
| 205 | 205 | } | |
| 206 | − | for (; *s != '\0' && *s != '/'; s++); | |
| 206 | + | for (; *s != '\0' && *s != '/'; s++) | |
| 207 | + | ; | |
| 207 | 208 | c = *s; | |
| 208 | 209 | *s = '\0'; | |
| 209 | 210 | if (mkdir(path, 0755) == -1) { | |
| @@ -226,7 +227,7 @@ void construct_argv(char **argv, unsigned int len, ...) | |||
| 226 | 227 | for (i = 0; i < len; ++i) | |
| 227 | 228 | argv[i] = va_arg(args, char *); | |
| 228 | 229 | 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"); | |
| 230 | 231 | } | |
| 231 | 232 | ||
| 232 | 233 | static int mkspawn_pipe(posix_spawn_file_actions_t *fa, const char *cmd, int *pfd, int dupidx) | |
| @@ -34,7 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | 35 | #if HAVE_LIBFONTS | |
| 36 | 36 | #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 */ | |
| 38 | 38 | #define TEXTWIDTH(win, text, len) \ | |
| 39 | 39 | win_draw_text(win, NULL, NULL, 0, 0, text, len, 0) | |
| 40 | 40 | #endif | |
| @@ -56,8 +56,12 @@ static struct { | |||
| 56 | 56 | int name; | |
| 57 | 57 | Cursor icon; | |
| 58 | 58 | } 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 } | |
| 61 | 65 | }; | |
| 62 | 66 | ||
| 63 | 67 | #if HAVE_LIBFONTS | |
| @@ -90,7 +94,7 @@ static void win_alloc_color(const win_env_t *e, const char *name, XColor *col) | |||
| 90 | 94 | error(EXIT_FAILURE, 0, "Error allocating color '%s'", name); | |
| 91 | 95 | } | |
| 92 | 96 | ||
| 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) | |
| 94 | 98 | { | |
| 95 | 99 | char *type; | |
| 96 | 100 | XrmValue ret; | |
| @@ -246,7 +250,7 @@ void win_open(win_t *win) | |||
| 246 | 250 | /* set the _NET_WM_PID */ | |
| 247 | 251 | pid = getpid(); | |
| 248 | 252 | 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); | |
| 250 | 254 | if (gethostname(hostname, ARRLEN(hostname)) == 0) { | |
| 251 | 255 | XTextProperty tp; | |
| 252 | 256 | tp.value = (unsigned char *)hostname; | |
| @@ -272,7 +276,7 @@ void win_open(win_t *win) | |||
| 272 | 276 | ||
| 273 | 277 | gc = XCreateGC(e->dpy, win->xwin, 0, None); | |
| 274 | 278 | ||
| 275 | − | n = icons[ARRLEN(icons)-1].size; | |
| 279 | + | n = icons[ARRLEN(icons) - 1].size; | |
| 276 | 280 | icon_data = emalloc((n * n + 2) * sizeof(*icon_data)); | |
| 277 | 281 | ||
| 278 | 282 | for (i = 0; i < (int)ARRLEN(icons); i++) { | |
| @@ -286,7 +290,7 @@ void win_open(win_t *win) | |||
| 286 | 290 | } | |
| 287 | 291 | XChangeProperty(e->dpy, win->xwin, atoms[ATOM__NET_WM_ICON], XA_CARDINAL, 32, | |
| 288 | 292 | i == 0 ? PropModeReplace : PropModeAppend, | |
| 289 | − | (unsigned char *) icon_data, n); | |
| 293 | + | (unsigned char *)icon_data, n); | |
| 290 | 294 | } | |
| 291 | 295 | free(icon_data); | |
| 292 | 296 | ||
| @@ -311,7 +315,7 @@ void win_open(win_t *win) | |||
| 311 | 315 | if (options->fullscreen) { | |
| 312 | 316 | XChangeProperty(e->dpy, win->xwin, atoms[ATOM__NET_WM_STATE], | |
| 313 | 317 | XA_ATOM, 32, PropModeReplace, | |
| 314 | − | (unsigned char *) &atoms[ATOM__NET_WM_STATE_FULLSCREEN], 1); | |
| 318 | + | (unsigned char *)&atoms[ATOM__NET_WM_STATE_FULLSCREEN], 1); | |
| 315 | 319 | } | |
| 316 | 320 | ||
| 317 | 321 | win->h -= win->bar.h; | |
| @@ -432,10 +436,10 @@ static int win_draw_text(win_t *win, XftDraw *d, const XftColor *color, | |||
| 432 | 436 | FC_SIZE, FcTypeDouble, fontsize, NULL); | |
| 433 | 437 | FcCharSetDestroy(fccharset); | |
| 434 | 438 | } | |
| 435 | − | XftTextExtentsUtf8(win->env.dpy, f, (XftChar8*)t, next - t, &ext); | |
| 439 | + | XftTextExtentsUtf8(win->env.dpy, f, (XftChar8 *)t, next - t, &ext); | |
| 436 | 440 | tw += ext.xOff; | |
| 437 | 441 | 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); | |
| 439 | 443 | x += ext.xOff; | |
| 440 | 444 | } | |
| 441 | 445 | if (f != font) | |
| @@ -456,7 +460,7 @@ static void win_draw_bar(win_t *win) | |||
| 456 | 460 | r = &win->bar.r; | |
| 457 | 461 | assert(l->buf != NULL && r->buf != NULL); | |
| 458 | 462 | 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; | |
| 460 | 464 | d = XftDrawCreate(e->dpy, win->buf.pm, e->vis, e->cmap); | |
| 461 | 465 | ||
| 462 | 466 | XSetForeground(e->dpy, gc, win->bar_bg.pixel); | |
| @@ -482,7 +486,7 @@ static void win_draw_bar(win_t *win) | |||
| 482 | 486 | #else | |
| 483 | 487 | static void win_draw_bar(win_t *win) | |
| 484 | 488 | { | |
| 485 | − | (void) win; | |
| 489 | + | (void)win; | |
| 486 | 490 | } | |
| 487 | 491 | #endif /* HAVE_LIBFONTS */ | |
| 488 | 492 | ||