diff options
author | Bert <ber.t@gmx.com> | 2011-09-06 09:11:03 +0200 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-09-06 09:11:03 +0200 |
commit | 711494ad361dcce5075545b5886a5986f88b60ef (patch) | |
tree | 92c87628d23fedb9a5f1f2590356cf3c732c40cc | |
parent | 2bbdd2f5b9529ab7cebd8fafa5cd4aa491a24010 (diff) |
Avoid conflicting macros
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | util.c | 4 | ||||
-rw-r--r-- | util.h | 8 |
4 files changed, 15 insertions, 11 deletions
@@ -1,6 +1,6 @@ all: sxiv -VERSION = git-20110904 +VERSION = git-20110906 CC = gcc DESTDIR = @@ -136,7 +136,7 @@ void remove_file(int n, unsigned char silent) { void set_timeout(timeout_f handler, int time, int overwrite) { int i; - for (i = 0; i < LEN(timeouts); i++) { + for (i = 0; i < ARRLEN(timeouts); i++) { if (timeouts[i].handler == handler) { if (!timeouts[i].active || overwrite) { gettimeofday(&timeouts[i].when, 0); @@ -151,7 +151,7 @@ void set_timeout(timeout_f handler, int time, int overwrite) { void reset_timeout(timeout_f handler) { int i; - for (i = 0; i < LEN(timeouts); i++) { + for (i = 0; i < ARRLEN(timeouts); i++) { if (timeouts[i].handler == handler) { timeouts[i].active = False; return; @@ -164,7 +164,7 @@ int check_timeouts(struct timeval *t) { struct timeval now; gettimeofday(&now, 0); - while (i < LEN(timeouts)) { + while (i < ARRLEN(timeouts)) { if (timeouts[i].active) { tdiff = TIMEDIFF(&timeouts[i].when, &now); if (tdiff <= 0) { @@ -260,7 +260,7 @@ void reset_cursor() { cursor_t cursor = CURSOR_NONE; if (mode == MODE_IMAGE) { - for (i = 0; i < LEN(timeouts); i++) { + for (i = 0; i < ARRLEN(timeouts); i++) { if (timeouts[i].handler == reset_cursor) { if (timeouts[i].active) cursor = CURSOR_ARROW; @@ -305,7 +305,7 @@ void on_keypress(XKeyEvent *kev) { XLookupString(kev, &key, 1, &ksym, NULL); - for (i = 0; i < LEN(keys); i++) { + for (i = 0; i < ARRLEN(keys); i++) { if (keys[i].ksym == ksym && keymask(&keys[i], kev->state)) { if (keys[i].cmd && keys[i].cmd(keys[i].arg)) redraw(); @@ -324,7 +324,7 @@ void on_buttonpress(XButtonEvent *bev) { win_set_cursor(&win, CURSOR_ARROW); set_timeout(reset_cursor, TO_CURSOR_HIDE, 1); - for (i = 0; i < LEN(buttons); i++) { + for (i = 0; i < ARRLEN(buttons); i++) { if (buttons[i].button == bev->button && buttonmask(&buttons[i], bev->state)) { @@ -91,9 +91,9 @@ void size_readable(float *size, const char **unit) { const char *units[] = { "", "K", "M", "G" }; int i; - for (i = 0; i < LEN(units) && *size > 1024; i++) + for (i = 0; i < ARRLEN(units) && *size > 1024; i++) *size /= 1024; - *unit = units[MIN(i, LEN(units) - 1)]; + *unit = units[MIN(i, ARRLEN(units) - 1)]; } char* absolute_path(const char *filename) { @@ -23,10 +23,14 @@ #include <stdarg.h> #include <dirent.h> -#define ABS(a) ((a) < 0 ? (-(a)) : (a)) +#ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define LEN(a) (sizeof(a) / sizeof(a[0])) +#endif + +#define ARRLEN(a) (sizeof(a) / sizeof(a[0])) #define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 + \ ((t1)->tv_usec - (t2)->tv_usec) / 1000) |