diff options
| author | Jakob Kaivo <jkk@ung.org> | 2023-11-27 14:08:35 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2023-11-27 14:08:35 -0500 |
| commit | 43bc9bea0773cce280c4d4442a494fe24f8e92bd (patch) | |
| tree | 3fbc8ec51783b86d6eb8fbfc2ddc14d2fc46c40f /src/__checked_i.c | |
| parent | 4d16801b9a6727d39a49dde70daa29eeac15a16c (diff) | |
add framework for marking function call location in diagnostics
Diffstat (limited to 'src/__checked_i.c')
| -rw-r--r-- | src/__checked_i.c | 41 |
1 files changed, 41 insertions, 0 deletions
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 <stdio.h> +#include <ctype.h> +#include <stdarg.h> +#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) +*/ |
