From d2d8e73e1e2005e5c0b3da16d50e3abd48fe12b6 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Wed, 1 Oct 2025 00:43:37 +0200 Subject: [PATCH] Fixed cosmetic incongruities --- lib.c | 33 ++++++++++++++++++++++++--------- main.c | 8 ++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib.c b/lib.c index fd67e72..5e211e3 100644 --- a/lib.c +++ b/lib.c @@ -40,12 +40,18 @@ #define MAX_MAIN_SIZE 256 #endif +#ifndef INK_STEP_BATCH_COUNT +#define INK_STEP_BATCH_COUNT 1 +#endif + struct label { int active; int dest; char* name; }; +static void noop(void) {} + #ifdef NOSTDLIB static size_t strlen(const char* c) { @@ -436,15 +442,15 @@ static char* ink_itoa(struct context* _, int cpy) { #ifndef NOSTDLIB static void* ink_malloc(struct context* _, size_t sz) { - _=_; + (void)(_); return malloc(sz); } static void* ink_realloc(struct context* _, void* ptr, size_t sz) { - _=_; + (void)(_); return realloc(ptr, sz); } static void ink_free(struct context* _, void* ptr) { - _=_; + (void)(_); free(ptr); } static int ink_putchar(struct context* _, int c) { @@ -498,7 +504,7 @@ static int ink_consume_one(int* end, struct context* pContext, char* r, int is_s return 0; } #endif - is_str = is_str; + (void)(is_str); if(*end == 0) { return 0; } @@ -986,7 +992,7 @@ static int ink_parse(struct context* pContext, struct elem* executable_buffer, i function_buffer_top += 1; break; } - next_token: i=i; + next_token: noop(); } #ifndef NOEXTRACHECKS if(mode == MODE_FUNCTION || mode == MODE_DO) { @@ -2084,10 +2090,15 @@ static void dump_stack(struct context* ctx) { return; } -static void collect_noop() {} +static void collect_noop(struct context* ctx, void* array) { + (void)(ctx); + (void)(array); +} -static struct ink_collection_list gc_noop() { - struct ink_collection_list c; +static struct ink_collection_list gc_noop(struct context* ctx, void* array) { + struct ink_collection_list c; + (void)(ctx); + (void)(array); c.elements = NULL; c.count = 0; return c; @@ -2235,7 +2246,7 @@ static void push_delimited_array(struct context* ctx) { /* Don't copy the delimiter */ idx -= 1; - ary->elements = malloc(sizeof(struct elem) * idx); + ary->elements = ctx->malloc(ctx, sizeof(struct elem) * idx); #ifndef NOEXTRACHECKS if(ary->elements == NULL) { currentRoutine->panic = -541; @@ -2507,3 +2518,7 @@ int ink_std_library(struct context* ctx) { return v; } + +#ifdef INK_DUMMY_MAIN +int main() {} +#endif diff --git a/main.c b/main.c index 9d7c888..c61d8e9 100644 --- a/main.c +++ b/main.c @@ -2,8 +2,12 @@ #include #include +#ifndef INK_SH_READ_BUFF +#define INK_SH_READ_BUFF 32768 +#endif // INK_SH_READ_BUFF + int main(int argc, char** argv) { - char read_buffer[2048]; + char read_buffer[INK_SH_READ_BUFF]; struct timespec start_time, end_time; clock_t begin, end; double time_spent; @@ -16,7 +20,7 @@ int main(int argc, char** argv) { FILE* file; size_t cnt; file = fopen(*argv, "r"); - cnt = fread(read_buffer, 1, 2047, file); + cnt = fread(read_buffer, 1, INK_SH_READ_BUFF - 1, file); if(cnt == 0) { fprintf(stderr, "Can't read file !! -> %s\n", *argv); }