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
clang-analyzer-*,clang-diagnostic-*,bugprone-*,performance-*,modernize-*
misc-*,readability-*,android-cloexec-*,cert-*
llvm-include-order
# silence
-misc-unused-parameters

View File

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

View File

@ -19,14 +19,14 @@
#include "nsxiv.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.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 tns_t tns;
extern win_t win;

19
main.c
View File

@ -22,22 +22,23 @@
#include "commands.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 <stdio.h>
#include <stdlib.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/time.h>
#include <sys/wait.h>
#include <time.h>
#include <sys/time.h>
#include <X11/keysym.h>
#include <unistd.h>
#include <X11/XF86keysym.h>
#include <X11/keysym.h>
#define MODMASK(mask) ((mask) & USED_MODMASK)
#define BAR_SEP " "

View File

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

View File

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

4
util.c
View File

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

View File

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