Skip to content

Commit 7e18ab1

Browse files
committed
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
1 parent 99fe57e commit 7e18ab1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/native/org_gnu_readline_Readline.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,18 @@ static int* globalIntegerInternals[] = {
130130
};
131131

132132
static char** globalStringInternals[] = {
133-
/* const */ &rl_library_version,
134-
/* const */ &rl_readline_name,
133+
/* const */ (char**) &rl_library_version,
134+
/* const */ (char**) &rl_readline_name,
135135
&rl_prompt,
136136
&rl_line_buffer,
137-
/* const */ &rl_terminal_name,
137+
/* const */ (char**) &rl_terminal_name,
138138
&rl_executing_macro,
139-
/* const */ &rl_basic_word_break_characters,
140-
/* const */ &rl_completer_word_break_characters,
141-
/* const */ &rl_completer_quote_characters,
142-
/* const */ &rl_basic_quote_characters,
143-
/* const */ &rl_filename_quote_characters,
144-
/* const */ &rl_special_prefixes,
139+
/* const */ (char**) &rl_basic_word_break_characters,
140+
/* const */ (char**) &rl_completer_word_break_characters,
141+
/* const */ (char**) &rl_completer_quote_characters,
142+
/* const */ (char**) &rl_basic_quote_characters,
143+
/* const */ (char**) &rl_filename_quote_characters,
144+
/* const */ (char**) &rl_special_prefixes,
145145

146146
&history_word_delimiters,
147147
&history_no_expand_chars,
@@ -198,18 +198,18 @@ static int* globalIntegerInternals[] = {
198198
};
199199

200200
static char** globalStringInternals[] = {
201-
/* const */ &rl_library_version,
202-
/* const */ &rl_readline_name,
201+
/* const */ (char**) &rl_library_version,
202+
/* const */ (char**) &rl_readline_name,
203203
&undefinedInternalString, /* &rl_prompt, */
204204
&rl_line_buffer,
205205
&undefinedInternalString, /* const &rl_terminal_name, */
206206
&undefinedInternalString, /* &rl_executing_macro, */
207-
/* const */ &rl_basic_word_break_characters,
208-
/* const */ &rl_completer_word_break_characters,
209-
/* const */ &rl_completer_quote_characters,
207+
/* const */ (char**) &rl_basic_word_break_characters,
208+
/* const */ (char**) &rl_completer_word_break_characters,
209+
/* const */ (char**) &rl_completer_quote_characters,
210210
&undefinedInternalString, /* const &rl_basic_quote_characters, */
211211
&undefinedInternalString, /* const &rl_filename_quote_characters, */
212-
/* const */ &rl_special_prefixes,
212+
/* const */ (char**) &rl_special_prefixes,
213213

214214
&undefinedInternalString, /* &history_word_delimiters, */
215215
&undefinedInternalString, /* &history_no_expand_chars, */

0 commit comments

Comments
 (0)