From 43bc9bea0773cce280c4d4442a494fe24f8e92bd Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 27 Nov 2023 14:08:35 -0500 Subject: add framework for marking function call location in diagnostics --- src/__checked_i.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/__checked_i.c (limited to 'src/__checked_i.c') diff --git a/src/__checked_i.c b/src/__checked_i.c new file mode 100644 index 00000000..f3b62bcf --- /dev/null +++ b/src/__checked_i.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include "_assert.h" + +#define F(fn) (int(*)())(fn) + +int __checked_i(const char *file, const char *func, unsigned long long line, int (*fn)(), ...) +{ + va_list ap; + int ret = -1; + + __checked_call.func = (char*)func; + __checked_call.file = (char*)file; + __checked_call.line = line; + + va_start(ap, fn); + + if (fn == F(isalpha) + || fn == F(isdigit) + || fn == F(isupper) + || fn == F(islower) + || fn == F(toupper) + || fn == F(tolower) + ) { + int arg = va_arg(ap, int); + ret = fn(arg); + } + + va_end(ap); + + __checked_call.func = NULL; + __checked_call.file = NULL; + __checked_call.line = 0; + + return ret; +} + +/* +STDC(0) +*/ -- cgit v1.2.1