diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-18 09:07:55 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-18 09:07:55 +0100 |
commit | 5f832714d383497618a9305a70d47a0da0922c6c (patch) | |
tree | a9ceb5db431f771fab70848b2f56af754721b462 | |
parent | bcda8465441452f9b55eba2c74acfb87321f2a13 (diff) |
Simplify code using libcompat
-rw-r--r-- | make.c | 5 | ||||
-rw-r--r-- | src/compat.h | 26 | ||||
-rw-r--r-- | src/grab.c | 6 |
3 files changed, 28 insertions, 9 deletions
@@ -1,12 +1,12 @@ #include <errno.h> #include <limits.h> -#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "cbs.h" +#include "src/compat.h" #define CC "cc" #define CFLAGS "-Wall", "-Wextra", "-Wpedantic", "-Werror", "-pipe" @@ -85,9 +85,6 @@ main(int argc, char **argv) cmdadd(&c, CC, CFLAGS); cmdadd(&c, buf); -#ifdef CBS_IS_C23 - cmdadd(&c, "-DGRAB_IS_C23=1"); -#endif if (pflag) cmdadd(&c, "-DGRAB_DO_PCRE=1", "-lpcre2-posix"); if (debug) diff --git a/src/compat.h b/src/compat.h new file mode 100644 index 0000000..fedea6a --- /dev/null +++ b/src/compat.h @@ -0,0 +1,26 @@ +/* This compatibility header was generated by the libcompat gen script. + You can find it over at https://git.sr.ht/~mango/libcompat. */ + +#ifndef LIBCOMPAT_COMPAT_H +#define LIBCOMPAT_COMPAT_H + +#if __STDC_VERSION__ >= 202311L +# define LIBCOMPAT_IS_23 1 +#endif + +#if !LIBCOMPAT_IS_23 +# include <stdbool.h> +#endif + +#if !LIBCOMPAT_IS_23 +# ifndef NULL +# include <stddef.h> +# endif +# define nullptr NULL +#endif + +#if !LIBCOMPAT_IS_23 +# define static_assert(e, ...) _Static_assert(e, ""__VA_ARGS__) +#endif + +#endif /* !LIBCOMPAT_COMPAT_H */ @@ -7,11 +7,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#if !GRAB_IS_C23 -# include <assert.h> -# include <stdbool.h> -# define nullptr NULL -#endif #if GRAB_DO_PCRE # include <pcre2posix.h> @@ -22,6 +17,7 @@ # endif #endif +#include "compat.h" #include "da.h" #define die(...) err(EXIT_FAILURE, __VA_ARGS__); |