From 51609224e3006503f71b1c0d1f6e15fb8b036ccc Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Mon, 5 Oct 2020 15:59:42 +0200
Subject: [PATCH] Added new Makefile switch for older versions of libedit (Bug
 565893)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: If390fe6a5b331513b4b2316e97d3221360659a6d
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 Makefile.cfg       | 8 ++++++++
 core/DebuggerUI.cc | 2 +-
 mctr2/cli/Cli.cc   | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile.cfg b/Makefile.cfg
index 91988b776..35dc06943 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -65,6 +65,10 @@ COVERAGE := no
 # Set it to 'no' to use a simplified debugger UI.
 ADVANCED_DEBUGGER_UI := no
 
+# Should be set to 'yes' if the version of the 'editline' library is 2.0.53 or older
+# (i.e. 'readline.h' v1.34 or older).
+OLD_LIBEDIT := no
+
 # Your platform. Allowed values: SOLARIS, SOLARIS8, LINUX, FREEBSD,
 # WIN32. Decided automagically if not defined (recommended).
 # PLATFORM :=
@@ -239,6 +243,10 @@ ifeq ($(ADVANCED_DEBUGGER_UI), yes)
   CPPFLAGS += -DADVANCED_DEBUGGER_UI
 endif
 
+ifeq ($(OLD_LIBEDIT), yes)
+  CPPFLAGS += -DOLD_LIBEDIT
+endif
+
 # Directory which contains the code for POSIX regular expression handling.
 # It is needed on platforms where the system's libc does not support POSIX
 # regexps. This is the case for Mingw.
diff --git a/core/DebuggerUI.cc b/core/DebuggerUI.cc
index b17699010..f95160e8f 100644
--- a/core/DebuggerUI.cc
+++ b/core/DebuggerUI.cc
@@ -221,7 +221,7 @@ void TTCN_Debugger_UI::init()
   // read history from file, don't bother if it does not exist
   read_history(ttcn3_history_filename);
   // set our own command completion function
-#ifdef WIN32
+#ifdef OLD_LIBEDIT
   rl_completion_entry_function = (Function*)complete_command;
 #else
   rl_completion_entry_function = complete_command;
diff --git a/mctr2/cli/Cli.cc b/mctr2/cli/Cli.cc
index 85088e8bf..eb747a84e 100644
--- a/mctr2/cli/Cli.cc
+++ b/mctr2/cli/Cli.cc
@@ -372,7 +372,7 @@ int Cli::interactiveMode()
   // Read history from file, don't bother if it does not exist!
   read_history(ttcn3_history_filename);
   // Set our own command completion function
-#ifdef WIN32
+#ifdef OLD_LIBEDIT
   rl_completion_entry_function = (Function*)completeCommand;
 #else
   rl_completion_entry_function = completeCommand;
-- 
GitLab