From 7e18ab1a8211d5ead0f5d32995d3b53e26550180 Mon Sep 17 00:00:00 2001 From: Andrew Clemons Date: Fri, 13 Dec 2024 06:27:12 +0900 Subject: [PATCH] Cast const char** in globalStringInternals to char**. Newer compilers error on this. They should do that - the code is incorrect - we are putting const char** values into this global array. If someone uses setVarStringImpl to write to one of these, it will crash. This is however already mentioned in the documentation: https://github.com/aclemons/java-readline/blob/99fe57e6c3544be476187fb7c66a664e6326c3ea/src/native/org_gnu_readline_Readline.c#L63-L64 and they all had a comment in front indicating they were: ```c const `/* const */* ``` Basically we are relying on code using java-readline to not call the wrong thing. It has been this way for more than 20 years, so for now I will not change this and will simply cast away the compiler error. Related to #41 --- src/native/org_gnu_readline_Readline.c | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/native/org_gnu_readline_Readline.c b/src/native/org_gnu_readline_Readline.c index d92cf28..84ce427 100644 --- a/src/native/org_gnu_readline_Readline.c +++ b/src/native/org_gnu_readline_Readline.c @@ -130,18 +130,18 @@ static int* globalIntegerInternals[] = { }; static char** globalStringInternals[] = { - /* const */ &rl_library_version, - /* const */ &rl_readline_name, + /* const */ (char**) &rl_library_version, + /* const */ (char**) &rl_readline_name, &rl_prompt, &rl_line_buffer, - /* const */ &rl_terminal_name, + /* const */ (char**) &rl_terminal_name, &rl_executing_macro, - /* const */ &rl_basic_word_break_characters, - /* const */ &rl_completer_word_break_characters, - /* const */ &rl_completer_quote_characters, - /* const */ &rl_basic_quote_characters, - /* const */ &rl_filename_quote_characters, - /* const */ &rl_special_prefixes, + /* const */ (char**) &rl_basic_word_break_characters, + /* const */ (char**) &rl_completer_word_break_characters, + /* const */ (char**) &rl_completer_quote_characters, + /* const */ (char**) &rl_basic_quote_characters, + /* const */ (char**) &rl_filename_quote_characters, + /* const */ (char**) &rl_special_prefixes, &history_word_delimiters, &history_no_expand_chars, @@ -198,18 +198,18 @@ static int* globalIntegerInternals[] = { }; static char** globalStringInternals[] = { - /* const */ &rl_library_version, - /* const */ &rl_readline_name, + /* const */ (char**) &rl_library_version, + /* const */ (char**) &rl_readline_name, &undefinedInternalString, /* &rl_prompt, */ &rl_line_buffer, &undefinedInternalString, /* const &rl_terminal_name, */ &undefinedInternalString, /* &rl_executing_macro, */ - /* const */ &rl_basic_word_break_characters, - /* const */ &rl_completer_word_break_characters, - /* const */ &rl_completer_quote_characters, + /* const */ (char**) &rl_basic_word_break_characters, + /* const */ (char**) &rl_completer_word_break_characters, + /* const */ (char**) &rl_completer_quote_characters, &undefinedInternalString, /* const &rl_basic_quote_characters, */ &undefinedInternalString, /* const &rl_filename_quote_characters, */ - /* const */ &rl_special_prefixes, + /* const */ (char**) &rl_special_prefixes, &undefinedInternalString, /* &history_word_delimiters, */ &undefinedInternalString, /* &history_no_expand_chars, */