Skip to content

Commit 81ae0fd

Browse files
committed
Added HAVE_UNICODE_LIBEDIT instead of doing platform checks
1 parent 28ff480 commit 81ae0fd

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

include/swift/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
include(CheckSymbolExists)
2+
3+
check_symbol_exists(el_wgets "histedit.h" HAVE_UNICODE_LIBEDIT)
4+
15
configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
26
ESCAPE_QUOTES @ONLY)
37

include/swift/Config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
#cmakedefine SWIFT_HAVE_WORKING_STD_REGEX 1
88

9+
#cmakedefine HAVE_UNICODE_LIBEDIT 1
10+
911
#endif // SWIFT_CONFIG_H

lib/Immediate/REPL.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "swift/Immediate/Immediate.h"
1414
#include "ImmediateImpl.h"
1515

16+
#include "swift/Config.h"
1617
#include "swift/Subsystems.h"
1718
#include "swift/AST/ASTContext.h"
1819
#include "swift/AST/DiagnosticsFrontend.h"
@@ -34,11 +35,9 @@
3435
#include "llvm/Support/PrettyStackTrace.h"
3536
#include "llvm/Support/Process.h"
3637

37-
#if defined(__APPLE__) || defined(__FreeBSD__)
38-
// FIXME: Support REPL on non-Apple platforms. Ubuntu 14.10's editline does not
39-
// include the wide character entry points needed by the REPL yet.
38+
#if HAVE_UNICODE_LIBEDIT
4039
#include <histedit.h>
41-
#endif // __APPLE__
40+
#endif
4241

4342
using namespace swift;
4443
using namespace swift::immediate;
@@ -131,7 +130,7 @@ class ConvertForWcharSize<4> {
131130

132131
using Convert = ConvertForWcharSize<sizeof(wchar_t)>;
133132

134-
#if defined(__APPLE__) || defined(__FreeBSD__)
133+
#if HAVE_UNICODE_LIBEDIT
135134
static void convertFromUTF8(llvm::StringRef utf8,
136135
llvm::SmallVectorImpl<wchar_t> &out) {
137136
size_t reserve = out.size() + utf8.size();
@@ -163,7 +162,7 @@ static void convertToUTF8(llvm::ArrayRef<wchar_t> wide,
163162

164163
} // end anonymous namespace
165164

166-
#if defined(__APPLE__) || defined(__FreeBSD__)
165+
#if HAVE_UNICODE_LIBEDIT
167166

168167
static bool appendToREPLFile(SourceFile &SF,
169168
PersistentParserState &PersistentState,
@@ -1182,7 +1181,7 @@ void swift::runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
11821181
} while (env.handleREPLInput(inputKind, Line));
11831182
}
11841183

1185-
#else // __APPLE__
1184+
#else
11861185

11871186
void swift::runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
11881187
bool ParseStdlib) {

0 commit comments

Comments
 (0)