code-style: cleanup includes

* rm unused include <sys/types.h>
* move <sys/time.h> to main.c, it's the only file that needs it.
* move TV_* macros to main.c
* let *.c files explicitly include what they need instead of including
  them at nsxiv.h
This commit is contained in:
NRK 2022-05-31 17:25:14 +06:00 committed by Gitea
parent 86a83c1ec5
commit 6d5a04005d
7 changed files with 16 additions and 16 deletions

View File

@ -20,6 +20,7 @@
#include "nsxiv.h" #include "nsxiv.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>

View File

@ -26,7 +26,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#if HAVE_LIBEXIF #if HAVE_LIBEXIF

10
main.c
View File

@ -23,6 +23,8 @@
#include "config.h" #include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -33,12 +35,20 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <time.h> #include <time.h>
#include <sys/time.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/XF86keysym.h> #include <X11/XF86keysym.h>
#define MODMASK(mask) ((mask) & USED_MODMASK) #define MODMASK(mask) ((mask) & USED_MODMASK)
#define BAR_SEP " " #define BAR_SEP " "
#define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \
((t1)->tv_usec - (t2)->tv_usec) / 1000)
#define TV_ADD_MSEC(tv,t) { \
(tv)->tv_sec += (t) / 1000; \
(tv)->tv_usec += (t) % 1000 * 1000; \
}
typedef struct { typedef struct {
struct timeval when; struct timeval when;
bool active; bool active;

14
nsxiv.h
View File

@ -20,11 +20,8 @@
#ifndef NSXIV_H #ifndef NSXIV_H
#define NSXIV_H #define NSXIV_H
#include <stdarg.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <Imlib2.h> #include <Imlib2.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -39,17 +36,8 @@
#define ABS(a) ((a) > 0 ? (a) : -(a)) #define ABS(a) ((a) > 0 ? (a) : -(a))
#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 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_ADD_MSEC(tv,t) { \
(tv)->tv_sec += (t) / 1000; \
(tv)->tv_usec += (t) % 1000 * 1000; \
}
typedef enum { typedef enum {
MODE_ALL, MODE_ALL,
MODE_IMAGE, MODE_IMAGE,

View File

@ -21,6 +21,7 @@
#include "version.h" #include "version.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>

View File

@ -22,9 +22,9 @@
#include "config.h" #include "config.h"
#include <errno.h> #include <errno.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <utime.h> #include <utime.h>

3
util.c
View File

@ -21,8 +21,9 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>