Skip to content

Commit 7f08506

Browse files
committed
rs274: Fix problem with 'history'
The identifier 'history' is also used internally by the library 'libedit.so', linked to provide readline functionality. The use of 'history' as a global variable made the rs274 program just segfault when invoked as 'rs274 -g'.
1 parent 0b61588 commit 7f08506

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/emc/sai/driver.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
InterpBase *pinterp;
4444
#define interp_new (*pinterp)
4545
const char *prompt = "READ => ";
46-
const char *history = "~/.rs274";
46+
const char *histfile = "~/.rs274";
4747
#define RS274_HISTORY "RS274_HISTORY"
4848

4949
#define active_settings interp_new.active_settings
@@ -137,15 +137,15 @@ void initialize_readline ()
137137
rl_readline_name = "rs274";
138138

139139
if ((s = getenv(RS274_HISTORY)))
140-
history = s;
140+
histfile = s;
141141
// tilde-expand
142-
if (wordexp(history, &p, WRDE_SHOWERR|WRDE_UNDEF )) {
142+
if (wordexp(histfile, &p, WRDE_SHOWERR|WRDE_UNDEF )) {
143143
perror("wordexp");
144144
} else {
145-
history = strdup(p.we_wordv[0]);
145+
histfile = strdup(p.we_wordv[0]);
146146
}
147-
if (history)
148-
read_history(history);
147+
if (histfile)
148+
read_history(histfile);
149149
}
150150

151151
/***********************************************************************/
@@ -186,8 +186,8 @@ int interpret_from_keyboard( /* ARGUMENTS */
186186
{
187187
line = readline ( prompt);
188188
if (!line || strcmp (line, "quit") == 0) {
189-
if (history)
190-
write_history(history);
189+
if (histfile)
190+
write_history(histfile);
191191
return 0;
192192
}
193193
if (*line)

0 commit comments

Comments
 (0)