From 93132e2702b1f74bc3abfddec5ab960f1eed5e6e Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 14 Nov 2024 15:46:23 +0100 Subject: [PATCH] config_lua_filename is local --- src/x49gpng/options.c | 13 +++++-------- src/x49gpng/options.h | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/x49gpng/options.c b/src/x49gpng/options.c index 5262377..00dbe60 100644 --- a/src/x49gpng/options.c +++ b/src/x49gpng/options.c @@ -14,8 +14,7 @@ struct options opt = { .datadir = NULL, - .config_lua_filename = NULL, - .state_filename = NULL, + .debug_port = 0, .start_debugger = false, .reinit = X49GP_REINIT_NONE, @@ -117,8 +116,6 @@ void config_init( char* progname, int argc, char* argv[] ) int option_index; int c = '?'; - char* config_lua_filename = ( char* )"config.lua"; - bool do_enable_debugger = false; bool do_start_debugger = false; bool do_reflash = false; @@ -255,14 +252,14 @@ void config_init( char* progname, int argc, char* argv[] ) opt.datadir = g_build_filename( user_config_dir, progname, NULL ); } - opt.config_lua_filename = g_build_filename( opt.datadir, config_lua_filename, NULL ); + const char* config_lua_filename = g_build_filename( opt.datadir, "config.lua", NULL ); opt.state_filename = g_build_filename( opt.datadir, "state", NULL ); /**********************/ /* 1. read config.lua */ /**********************/ - bool haz_config_file = config_read( opt.config_lua_filename ); + bool haz_config_file = config_read( config_lua_filename ); if ( haz_config_file ) { lua_getglobal( config_lua_values, "newrpl_keyboard" ); opt.newrpl = lua_toboolean( config_lua_values, -1 ); @@ -325,9 +322,9 @@ void config_init( char* progname, int argc, char* argv[] ) print_config(); if ( !haz_config_file ) { - fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", opt.config_lua_filename ); + fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", config_lua_filename ); fprintf( stderr, "You can solve this by running `mkdir -p %s/ && %s --print-config >> %s`\n\n", opt.datadir, progname, - opt.config_lua_filename ); + config_lua_filename ); } if ( do_enable_debugger ) { diff --git a/src/x49gpng/options.h b/src/x49gpng/options.h index c1d0d55..45556f4 100644 --- a/src/x49gpng/options.h +++ b/src/x49gpng/options.h @@ -31,7 +31,6 @@ struct options { char* font; int display_scale; int font_size; - char* config_lua_filename; bool verbose; char* datadir;