Strictly adhere to ANSI-C standard
This commit is contained in:
		
							parent
							
								
									a09b20c5e6
								
							
						
					
					
						commit
						4383a651c7
					
				
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -1,7 +1,7 @@ | |||||||
| VERSION = git-20111012 | VERSION = git-20111013 | ||||||
| 
 | 
 | ||||||
| CC      = gcc | CC      = gcc | ||||||
| CFLAGS  = -Wall -pedantic -O2 | CFLAGS  = -ansi -Wall -pedantic -O2 | ||||||
| LDFLAGS = | LDFLAGS = | ||||||
| LIBS    = -lX11 -lImlib2 | LIBS    = -lX11 -lImlib2 | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								config.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								config.c
									
									
									
									
									
								
							| @ -9,7 +9,7 @@ | |||||||
| #define PUT_MACRO(m) \ | #define PUT_MACRO(m) \ | ||||||
| 	printf(" -D%s=%s", #m, QUOTE(m)) | 	printf(" -D%s=%s", #m, QUOTE(m)) | ||||||
| 
 | 
 | ||||||
| inline int puts_if(const char *s, int c) { | int puts_if(const char *s, int c) { | ||||||
| 	return c ? printf(" %s", s) : 0; | 	return c ? printf(" %s", s) : 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								image.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								image.c
									
									
									
									
									
								
							| @ -43,7 +43,6 @@ enum { MIN_GIF_DELAY = 50 }; | |||||||
| float zoom_min; | float zoom_min; | ||||||
| float zoom_max; | float zoom_max; | ||||||
| 
 | 
 | ||||||
| static inline |  | ||||||
| bool zoomdiff(float z1, float z2) { | bool zoomdiff(float z1, float z2) { | ||||||
| 	const float mindelta = 0.001; | 	const float mindelta = 0.001; | ||||||
| 	return (z1 - z2 > mindelta) || (z1 - z2 < mindelta); | 	return (z1 - z2 > mindelta) || (z1 - z2 < mindelta); | ||||||
| @ -311,11 +310,11 @@ bool img_load(img_t *img, const fileinfo_t *file) { | |||||||
| 	(void) fmt; | 	(void) fmt; | ||||||
| 
 | 
 | ||||||
| #if EXIF_SUPPORT | #if EXIF_SUPPORT | ||||||
| 	if (streq(fmt, "jpeg")) | 	if (STREQ(fmt, "jpeg")) | ||||||
| 		exif_auto_orientate(file); | 		exif_auto_orientate(file); | ||||||
| #endif | #endif | ||||||
| #if GIF_SUPPORT | #if GIF_SUPPORT | ||||||
| 	if (streq(fmt, "gif")) | 	if (STREQ(fmt, "gif")) | ||||||
| 		img_load_gif(img, file); | 		img_load_gif(img, file); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.c
									
									
									
									
									
								
							| @ -145,7 +145,7 @@ void set_timeout(timeout_f handler, int time, bool overwrite) { | |||||||
| 		if (timeouts[i].handler == handler) { | 		if (timeouts[i].handler == handler) { | ||||||
| 			if (!timeouts[i].active || overwrite) { | 			if (!timeouts[i].active || overwrite) { | ||||||
| 				gettimeofday(&timeouts[i].when, 0); | 				gettimeofday(&timeouts[i].when, 0); | ||||||
| 				tv_add_msec(&timeouts[i].when, time); | 				TV_ADD_MSEC(&timeouts[i].when, time); | ||||||
| 				timeouts[i].active = true; | 				timeouts[i].active = true; | ||||||
| 			} | 			} | ||||||
| 			return; | 			return; | ||||||
| @ -171,7 +171,7 @@ bool check_timeouts(struct timeval *t) { | |||||||
| 	gettimeofday(&now, 0); | 	gettimeofday(&now, 0); | ||||||
| 	while (i < ARRLEN(timeouts)) { | 	while (i < ARRLEN(timeouts)) { | ||||||
| 		if (timeouts[i].active) { | 		if (timeouts[i].active) { | ||||||
| 			tdiff = tv_diff(&timeouts[i].when, &now); | 			tdiff = TV_DIFF(&timeouts[i].when, &now); | ||||||
| 			if (tdiff <= 0) { | 			if (tdiff <= 0) { | ||||||
| 				timeouts[i].active = false; | 				timeouts[i].active = false; | ||||||
| 				if (timeouts[i].handler != NULL) | 				if (timeouts[i].handler != NULL) | ||||||
| @ -184,7 +184,7 @@ bool check_timeouts(struct timeval *t) { | |||||||
| 		i++; | 		i++; | ||||||
| 	} | 	} | ||||||
| 	if (tmin > 0 && t != NULL) | 	if (tmin > 0 && t != NULL) | ||||||
| 		tv_set_msec(t, tmin); | 		TV_SET_MSEC(t, tmin); | ||||||
| 	return tmin > 0; | 	return tmin > 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -140,5 +140,5 @@ void parse_options(int argc, char **argv) { | |||||||
| 	_options.filenames = argv + optind; | 	_options.filenames = argv + optind; | ||||||
| 	_options.filecnt = argc - optind; | 	_options.filecnt = argc - optind; | ||||||
| 	_options.from_stdin = _options.filecnt == 1 && | 	_options.from_stdin = _options.filecnt == 1 && | ||||||
| 	                      streq(_options.filenames[0], "-"); | 	                      STREQ(_options.filenames[0], "-"); | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								thumbs.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								thumbs.c
									
									
									
									
									
								
							| @ -258,7 +258,7 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file, | |||||||
| 	(void) fmt; | 	(void) fmt; | ||||||
| 
 | 
 | ||||||
| #if EXIF_SUPPORT | #if EXIF_SUPPORT | ||||||
| 	if (!cache_hit && streq(fmt, "jpeg")) | 	if (!cache_hit && STREQ(fmt, "jpeg")) | ||||||
| 		exif_auto_orientate(file); | 		exif_auto_orientate(file); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								util.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								util.c
									
									
									
									
									
								
							| @ -272,7 +272,7 @@ char* r_readdir(r_dir_t *rdir) { | |||||||
| 
 | 
 | ||||||
| 	while (true) { | 	while (true) { | ||||||
| 		if (rdir->dir != NULL && (dentry = readdir(rdir->dir)) != NULL) { | 		if (rdir->dir != NULL && (dentry = readdir(rdir->dir)) != NULL) { | ||||||
| 			if (streq(dentry->d_name, ".") || streq(dentry->d_name, "..")) | 			if (STREQ(dentry->d_name, ".") || STREQ(dentry->d_name, "..")) | ||||||
| 				continue; | 				continue; | ||||||
| 
 | 
 | ||||||
| 			len = strlen(rdir->name) + strlen(dentry->d_name) + 2; | 			len = strlen(rdir->name) + strlen(dentry->d_name) + 2; | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								util.h
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								util.h
									
									
									
									
									
								
							| @ -36,6 +36,21 @@ | |||||||
| 
 | 
 | ||||||
| #define ARRLEN(a) (sizeof(a) / sizeof((a)[0])) | #define ARRLEN(a) (sizeof(a) / sizeof((a)[0])) | ||||||
| 
 | 
 | ||||||
|  | #define STREQ(s1,s2) (strcmp((s1), (s2)) == 0) | ||||||
|  | 
 | ||||||
|  | #define TV_DIFF(t1,t2) (((t1)->tv_sec  - (t2)->tv_sec ) * 1000 + \ | ||||||
|  |                         ((t1)->tv_usec - (t2)->tv_usec) / 1000) | ||||||
|  | 
 | ||||||
|  | #define TV_SET_MSEC(tv,t) {             \ | ||||||
|  |   (tv)->tv_sec  = (t) / 1000;           \ | ||||||
|  |   (tv)->tv_usec = (t) % 1000 * 1000;    \ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #define TV_ADD_MSEC(tv,t) {             \ | ||||||
|  |   (tv)->tv_sec  = (t) / 1000;           \ | ||||||
|  |   (tv)->tv_usec = (t) % 1000 * 1000;    \ | ||||||
|  | } | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
| 	DIR *dir; | 	DIR *dir; | ||||||
| 	char *name; | 	char *name; | ||||||
| @ -46,29 +61,6 @@ typedef struct { | |||||||
| 	int stlen; | 	int stlen; | ||||||
| } r_dir_t; | } r_dir_t; | ||||||
| 
 | 
 | ||||||
| static inline |  | ||||||
| bool streq(const char *a, const char *b) { |  | ||||||
| 	return strcmp(a, b) == 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline |  | ||||||
| long tv_diff(const struct timeval *t1, const struct timeval *t2) { |  | ||||||
| 	return (t1->tv_sec - t2->tv_sec) * 1000 + |  | ||||||
| 	       (t1->tv_usec - t2->tv_usec) / 1000; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline |  | ||||||
| void tv_set_msec(struct timeval *t, int msec) { |  | ||||||
| 	t->tv_sec = msec / 1000; |  | ||||||
| 	t->tv_usec = msec % 1000 * 1000; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline |  | ||||||
| void tv_add_msec(struct timeval *t, int msec) { |  | ||||||
| 	t->tv_sec += msec / 1000; |  | ||||||
| 	t->tv_usec += msec % 1000 * 1000; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void* s_malloc(size_t); | void* s_malloc(size_t); | ||||||
| void* s_realloc(void*, size_t); | void* s_realloc(void*, size_t); | ||||||
| char* s_strdup(char*); | char* s_strdup(char*); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Bert Münnich
						Bert Münnich