From 2f05a766b02bad3342fa8620d2a6241bbc2d8a86 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 11 Feb 2019 23:09:59 -0500 Subject: [PATCH] fix GNU readline bug. linking libhistory is not necessary. In fact, it causes a SIGSEGV. --- src/CMakeLists.txt | 2 +- src/readline.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c5ac4d..b40220e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,7 +165,7 @@ if (READLINE MATCHES "AUTO") endif() if(READLINE MATCHES "READLINE") target_compile_definitions(x_readline PRIVATE USE_READLINE) - target_link_libraries(x_readline PUBLIC history readline) + target_link_libraries(x_readline PUBLIC readline) elseif(READLINE MATCHES "LIBEDIT") target_compile_definitions(x_readline PRIVATE USE_LIBEDIT) target_link_libraries(x_readline PUBLIC edit) diff --git a/src/readline.c b/src/readline.c index c855942..49d8291 100644 --- a/src/readline.c +++ b/src/readline.c @@ -121,7 +121,7 @@ char *x_readline(const char *prompt) { /* append to history, but only if unique from prev. entry */ if (*buffer) { - HIST_ENTRY *h = history_get(history_length-1); + HIST_ENTRY *h = history_get(history_length); if (h == NULL || strcmp(buffer, h->line)) add_history(buffer); }