diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-27 23:32:01 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-27 23:32:01 +0100 |
commit | 64d8302da4f21fd974d074f0be4d039dda78c8a8 (patch) | |
tree | 7ee2bb5dd578d702f3a6fbb32c1ec1c74c098d95 /src | |
parent | b8965345d9898ffee6f34b9e8b09925775b5a6dc (diff) |
Require C23
Diffstat (limited to 'src')
-rw-r--r-- | src/compat.h | 29 | ||||
-rw-r--r-- | src/da.h | 2 | ||||
-rw-r--r-- | src/grab.c | 17 |
3 files changed, 9 insertions, 39 deletions
diff --git a/src/compat.h b/src/compat.h deleted file mode 100644 index 87ab9fb..0000000 --- a/src/compat.h +++ /dev/null @@ -1,29 +0,0 @@ -/* 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> /* IWYU pragma: export */ -#endif - -#if !LIBCOMPAT_IS_23 -# ifndef NULL -# include <stddef.h> /* IWYU pragma: export */ -# endif -# define nullptr NULL -#endif - -#if !LIBCOMPAT_IS_23 -# ifdef static_assert -# undef static_assert -# endif -# define static_assert(e, ...) _Static_assert(e, ""__VA_ARGS__) -#endif - -#endif /* !LIBCOMPAT_COMPAT_H */ @@ -116,6 +116,6 @@ } while (0) #define da_foreach(a, p) \ - for (auto p = (a)->buf; (size_t)(p - (a)->buf) < (a)->len; p++) + for (typeof((a)->buf) p = (a)->buf; (size_t)(p - (a)->buf) < (a)->len; p++) #endif /* !MANGO_DA_H */ @@ -27,7 +27,6 @@ #include <rune.h> #include <utf8.h> -#include "compat.h" #include "da.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -254,9 +253,9 @@ main(int argc, char **argv) # if GIT_GRAB free(entry); # endif - for (size_t i = 0; i < ops.len; i++) { - if (ops.buf[i].alloced) - regfree(&ops.buf[i].pat); + da_foreach (&ops, op) { + if (op->alloced) + regfree(&op->pat); } free(ops.buf); #endif @@ -302,7 +301,7 @@ comppat(char8_t *s) delimiter if this is the last operation in the query pattern. */ p = s; len = strlen(s); - if (!(s = (char8_t *)u8chr(s, ch, len))) + if (!(s = u8chr(s, ch, len))) s = p + len; if (s - p == 0) { @@ -727,10 +726,10 @@ putm(struct sv sv, struct matches *ms, const char *filename) } p = sv.p; - for (size_t i = 0; i < valid.len; i++) { - struct sv m = valid.buf[i]; - printf("%.*s\33[%sm%.*s\33[0m", (int)(m.p - p), p, hl, (int)m.len, m.p); - p = m.p + m.len; + da_foreach (&valid, m) { + printf("%.*s\33[%sm%.*s\33[0m", (int)(m->p - p), p, hl, (int)m->len, + m->p); + p = m->p + m->len; } fwrite(p, 1, sv.p + sv.len - p, stdout); |