From c530cf20fd7f9785a5dfef2b66654e199852ec18 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Mon, 8 Jan 2024 10:53:38 +0900 Subject: [PATCH] file names passed to krk_interpret, krk_compile, krk_runfile can be const --- src/compiler.c | 2 +- src/kuroko/compiler.h | 2 +- src/kuroko/vm.h | 4 ++-- src/vm.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler.c b/src/compiler.c index fab7628..a9d9122 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -4090,7 +4090,7 @@ void _createAndBind_compilerClass(void) { * @return A compiled code object, or NULL on error. * @exception SyntaxError if @p src could not be compiled. */ -KrkCodeObject * krk_compile(const char * src, char * fileName) { +KrkCodeObject * krk_compile(const char * src, const char * fileName) { struct GlobalState * state = (void*)krk_newInstance(KRK_BASE_CLASS(CompilerState)); krk_push(OBJECT_VAL(state)); diff --git a/src/kuroko/compiler.h b/src/kuroko/compiler.h index 969040f..aba17ed 100644 --- a/src/kuroko/compiler.h +++ b/src/kuroko/compiler.h @@ -14,5 +14,5 @@ * @param fileName Path name of the source file or a representative string like "" * @return The code object resulting from the compilation, or NULL if compilation failed. */ -extern KrkCodeObject * krk_compile(const char * src, char * fileName); +extern KrkCodeObject * krk_compile(const char * src, const char * fileName); diff --git a/src/kuroko/vm.h b/src/kuroko/vm.h index 50d39ba..95ab93b 100644 --- a/src/kuroko/vm.h +++ b/src/kuroko/vm.h @@ -316,7 +316,7 @@ extern void krk_resetStack(void); * indicate @c KRK_THREAD_HAS_EXCEPTION and @c krk_currentThread.currentException * should contain the raised exception value. */ -extern KrkValue krk_interpret(const char * src, char * fromFile); +extern KrkValue krk_interpret(const char * src, const char * fromFile); /** * @brief Load and run a source file and return when execution completes. @@ -330,7 +330,7 @@ extern KrkValue krk_interpret(const char * src, char * fromFile); * @return As with @c krk_interpret, an object representing the newly created module, * or the final return value of the VM execution. */ -extern KrkValue krk_runfile(const char * fileName, char * fromFile); +extern KrkValue krk_runfile(const char * fileName, const char * fromFile); /** * @brief Push a stack value. diff --git a/src/vm.c b/src/vm.c index f23167b..c895ecb 100644 --- a/src/vm.c +++ b/src/vm.c @@ -3229,7 +3229,7 @@ KrkInstance * krk_startModule(const char * name) { return module; } -KrkValue krk_interpret(const char * src, char * fromFile) { +KrkValue krk_interpret(const char * src, const char * fromFile) { KrkCodeObject * function = krk_compile(src, fromFile); if (!function) { if (!krk_currentThread.frameCount) handleException(); @@ -3246,7 +3246,7 @@ KrkValue krk_interpret(const char * src, char * fromFile) { } #ifndef KRK_NO_FILESYSTEM -KrkValue krk_runfile(const char * fileName, char * fromFile) { +KrkValue krk_runfile(const char * fileName, const char * fromFile) { FILE * f = fopen(fileName,"r"); if (!f) { fprintf(stderr, "%s: could not open file '%s': %s\n", "kuroko", fileName, strerror(errno));