From 702af1bdbfbbb99f841615ae37650ce392826526 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Sat, 17 May 2025 11:42:54 +0200 Subject: [PATCH] Added a macro for stoopid libc that made putchar a macro --- include/ink.h | 2 +- lib.c | 41 +++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/ink.h b/include/ink.h index b0ebe1c..62a882c 100644 --- a/include/ink.h +++ b/include/ink.h @@ -395,4 +395,4 @@ void array_push(struct context* ctx, struct ink_routine* currentRoutine, struct #ifdef __cplusplus }; -#endif \ No newline at end of file +#endif diff --git a/lib.c b/lib.c index e67a7d4..a4ef4f4 100644 --- a/lib.c +++ b/lib.c @@ -1491,6 +1491,10 @@ void ink_gc(struct context* ctx) { /**********************************************************************************************************************/ +#ifdef NUKE_PUTCHAR_MACRO +#undef putchar +#endif + static void print_stacktrace(struct context* _) { int i; struct ink_routine* currentRoutine; @@ -2033,6 +2037,25 @@ static void clear_stack(struct context* ctx) { return; } + +static void is_int(struct context* ctx) { + struct ink_routine *currentRoutine; + struct elem a; + + currentRoutine = ctx->routines + ctx->routine_current; +#ifndef NOEXTRACHECKS + if (currentRoutine->top < 1) { + currentRoutine->panic = -1; + return; + } +#endif + a.type = INK_INTEGER; + a.value = currentRoutine->stack[currentRoutine->top - 1].type == INK_INTEGER; + ink_pop(ctx); + + ink_push(ctx, a); +} + static void dump_stack(struct context* ctx) { struct ink_routine* currentRoutine; int index; @@ -2373,24 +2396,6 @@ static void is_array(struct context* ctx) { ink_push(ctx, a); } -static void is_int(struct context* ctx) { - struct ink_routine *currentRoutine; - struct elem a; - - currentRoutine = ctx->routines + ctx->routine_current; -#ifndef NOEXTRACHECKS - if (currentRoutine->top < 1) { - currentRoutine->panic = -1; - return; - } -#endif - a.type = INK_INTEGER; - a.value = currentRoutine->stack[currentRoutine->top - 1].type == INK_INTEGER; - ink_pop(ctx); - - ink_push(ctx, a); -} - static void print_array_of_codepoints(struct context* ctx) { int i; struct ink_routine *currentRoutine;