sort and group includes

* includes are sorted alphabetically

* their grouping and layout is the following:
  - nsxiv.h will be the first include
  - followed by any internal headers (e.g "commands.h" "config.h")
  - followed by system headers (<stdlib.h> etc)
  - followed by third party headers (X.h libwebp etc)

* also add `llvm-include-order` check to clang-tidy so that it can catch
  unsorted includes during CI.
This commit is contained in:
NRK 2022-06-16 13:39:03 +06:00 committed by Gitea
parent 6d5a04005d
commit b162aee497
8 changed files with 26 additions and 22 deletions

View file

@ -1,6 +1,7 @@
# checks # checks
clang-analyzer-*,clang-diagnostic-*,bugprone-*,performance-*,modernize-* clang-analyzer-*,clang-diagnostic-*,bugprone-*,performance-*,modernize-*
misc-*,readability-*,android-cloexec-*,cert-* misc-*,readability-*,android-cloexec-*,cert-*
llvm-include-order
# silence # silence
-misc-unused-parameters -misc-unused-parameters

View file

@ -23,8 +23,8 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <sys/inotify.h> #include <sys/inotify.h>
#include <unistd.h>
static union { static union {
char d[4096]; /* aligned buffer */ char d[4096]; /* aligned buffer */

View file

@ -19,14 +19,14 @@
#include "nsxiv.h" #include "nsxiv.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include "commands.h" #include "commands.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
extern img_t img; extern img_t img;
extern tns_t tns; extern tns_t tns;
extern win_t win; extern win_t win;

19
main.c
View file

@ -22,22 +22,23 @@
#include "commands.h" #include "commands.h"
#include "config.h" #include "config.h"
#include <stdlib.h> #include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <poll.h>
#include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <locale.h>
#include <signal.h>
#include <poll.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <time.h> #include <time.h>
#include <sys/time.h> #include <unistd.h>
#include <X11/keysym.h>
#include <X11/XF86keysym.h> #include <X11/XF86keysym.h>
#include <X11/keysym.h>
#define MODMASK(mask) ((mask) & USED_MODMASK) #define MODMASK(mask) ((mask) & USED_MODMASK)
#define BAR_SEP " " #define BAR_SEP " "

View file

@ -20,8 +20,9 @@
#ifndef NSXIV_H #ifndef NSXIV_H
#define NSXIV_H #define NSXIV_H
#include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#include <Imlib2.h> #include <Imlib2.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>

View file

@ -20,8 +20,8 @@
#include "nsxiv.h" #include "nsxiv.h"
#include "version.h" #include "version.h"
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>

4
util.c
View file

@ -20,13 +20,13 @@
#include "nsxiv.h" #include "nsxiv.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
const char *progname; const char *progname;

View file

@ -22,13 +22,14 @@
#include "config.h" #include "config.h"
#include "icon/data.h" #include "icon/data.h"
#include <locale.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <locale.h>
#include <unistd.h> #include <unistd.h>
#include <X11/cursorfont.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <X11/cursorfont.h>
#if HAVE_LIBFONTS #if HAVE_LIBFONTS
#include "utf8.h" #include "utf8.h"