From 64d8302da4f21fd974d074f0be4d039dda78c8a8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 27 Jan 2024 23:32:01 +0100 Subject: Require C23 --- src/compat.h | 29 ----------------------------- src/da.h | 2 +- src/grab.c | 17 ++++++++--------- 3 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 src/compat.h (limited to 'src') 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 /* IWYU pragma: export */ -#endif - -#if !LIBCOMPAT_IS_23 -# ifndef NULL -# include /* 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 */ diff --git a/src/da.h b/src/da.h index 57b7ed1..8891971 100644 --- a/src/da.h +++ b/src/da.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 */ diff --git a/src/grab.c b/src/grab.c index 39eba58..f262451 100644 --- a/src/grab.c +++ b/src/grab.c @@ -27,7 +27,6 @@ #include #include -#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); -- cgit v1.2.3