Krolyxon
Commit 711494a

Branches

Refs →

nsxiv711494a

Avoid conflicting macros

Author
Bert
Date
2011-09-06 09:11 +0200
Parent
2bbdd2f
Commit
711494ad361dcce5075545b5886a5986f88b60ef

+15 −11

4 files changed

  1. M Makefile +1 −1
  2. M main.c +6 −6
  3. M util.c +2 −2
  4. M util.h +6 −2
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION = git-20110904
3+VERSION = git-20110906
44
55 CC = gcc
66 DESTDIR =
M main.c View
@@ -136,7 +136,7 @@ void remove_file(int n, unsigned char silent) {
136136 void set_timeout(timeout_f handler, int time, int overwrite) {
137137 int i;
138138
139− for (i = 0; i < LEN(timeouts); i++) {
139+ for (i = 0; i < ARRLEN(timeouts); i++) {
140140 if (timeouts[i].handler == handler) {
141141 if (!timeouts[i].active || overwrite) {
142142 gettimeofday(&timeouts[i].when, 0);
@@ -151,7 +151,7 @@ void set_timeout(timeout_f handler, int time, int overwrite) {
151151 void reset_timeout(timeout_f handler) {
152152 int i;
153153
154− for (i = 0; i < LEN(timeouts); i++) {
154+ for (i = 0; i < ARRLEN(timeouts); i++) {
155155 if (timeouts[i].handler == handler) {
156156 timeouts[i].active = False;
157157 return;
@@ -164,7 +164,7 @@ int check_timeouts(struct timeval *t) {
164164 struct timeval now;
165165
166166 gettimeofday(&now, 0);
167− while (i < LEN(timeouts)) {
167+ while (i < ARRLEN(timeouts)) {
168168 if (timeouts[i].active) {
169169 tdiff = TIMEDIFF(&timeouts[i].when, &now);
170170 if (tdiff <= 0) {
@@ -260,7 +260,7 @@ void reset_cursor() {
260260 cursor_t cursor = CURSOR_NONE;
261261
262262 if (mode == MODE_IMAGE) {
263− for (i = 0; i < LEN(timeouts); i++) {
263+ for (i = 0; i < ARRLEN(timeouts); i++) {
264264 if (timeouts[i].handler == reset_cursor) {
265265 if (timeouts[i].active)
266266 cursor = CURSOR_ARROW;
@@ -305,7 +305,7 @@ void on_keypress(XKeyEvent *kev) {
305305
306306 XLookupString(kev, &key, 1, &ksym, NULL);
307307
308− for (i = 0; i < LEN(keys); i++) {
308+ for (i = 0; i < ARRLEN(keys); i++) {
309309 if (keys[i].ksym == ksym && keymask(&keys[i], kev->state)) {
310310 if (keys[i].cmd && keys[i].cmd(keys[i].arg))
311311 redraw();
@@ -324,7 +324,7 @@ void on_buttonpress(XButtonEvent *bev) {
324324 win_set_cursor(&win, CURSOR_ARROW);
325325 set_timeout(reset_cursor, TO_CURSOR_HIDE, 1);
326326
327− for (i = 0; i < LEN(buttons); i++) {
327+ for (i = 0; i < ARRLEN(buttons); i++) {
328328 if (buttons[i].button == bev->button &&
329329 buttonmask(&buttons[i], bev->state))
330330 {
M util.c View
@@ -91,9 +91,9 @@ void size_readable(float *size, const char **unit) {
9191 const char *units[] = { "", "K", "M", "G" };
9292 int i;
9393
94− for (i = 0; i < LEN(units) && *size > 1024; i++)
94+ for (i = 0; i < ARRLEN(units) && *size > 1024; i++)
9595 *size /= 1024;
96− *unit = units[MIN(i, LEN(units) - 1)];
96+ *unit = units[MIN(i, ARRLEN(units) - 1)];
9797 }
9898
9999 char* absolute_path(const char *filename) {
M util.h View
@@ -23,10 +23,14 @@
2323 #include <stdarg.h>
2424 #include <dirent.h>
2525
26−#define ABS(a) ((a) < 0 ? (-(a)) : (a))
26+#ifndef MIN
2727 #define MIN(a,b) ((a) < (b) ? (a) : (b))
28+#endif
29+#ifndef MAX
2830 #define MAX(a,b) ((a) > (b) ? (a) : (b))
29−#define LEN(a) (sizeof(a) / sizeof(a[0]))
31+#endif
32+
33+#define ARRLEN(a) (sizeof(a) / sizeof(a[0]))
3034
3135 #define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 + \
3236 ((t1)->tv_usec - (t2)->tv_usec) / 1000)