@@ -45,14 +45,14 @@ extern char **completion_matches(char *, CPFunction *);
45
45
#endif
46
46
#endif
47
47
48
- #ifdef __APPLE__
49
48
/*
50
49
* It is possible to link the readline module to the readline
51
50
* emulation library of editline/libedit.
52
51
*
53
- * On OSX this emulation library is not 100% API compatible
54
- * with the "real" readline and cannot be detected at compile-time,
55
- * hence we use a runtime check to detect if we're using libedit
52
+ * This emulation library is not 100% API compatible with the "real" readline
53
+ * and cannot be detected at compile-time,
54
+ * hence we use a runtime check to detect if the Python readlinke module is
55
+ * linked to libedit.
56
56
*
57
57
* Currently there is one known API incompatibility:
58
58
* - 'get_history' has a 1-based index with GNU readline, and a 0-based
@@ -64,7 +64,6 @@ static int using_libedit_emulation = 0;
64
64
static const char libedit_version_tag [] = "EditLine wrapper" ;
65
65
66
66
static int libedit_history_start = 0 ;
67
- #endif /* __APPLE__ */
68
67
69
68
#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
70
69
static void
@@ -693,7 +692,6 @@ get_history_item(PyObject *self, PyObject *args)
693
692
694
693
if (!PyArg_ParseTuple (args , "i:get_history_item" , & idx ))
695
694
return NULL ;
696
- #ifdef __APPLE__
697
695
if (using_libedit_emulation ) {
698
696
/* Older versions of libedit's readline emulation
699
697
* use 0-based indexes, while readline and newer
@@ -713,7 +711,6 @@ get_history_item(PyObject *self, PyObject *args)
713
711
Py_RETURN_NONE ;
714
712
}
715
713
}
716
- #endif /* __APPLE__ */
717
714
if ((hist_ent = history_get (idx )))
718
715
return decode (hist_ent -> line );
719
716
else {
@@ -1081,7 +1078,6 @@ setup_readline(readlinestate *mod_state)
1081
1078
/* The name must be defined before initialization */
1082
1079
rl_readline_name = "python" ;
1083
1080
1084
- #ifdef __APPLE__
1085
1081
/* the libedit readline emulation resets key bindings etc
1086
1082
* when calling rl_initialize. So call it upfront
1087
1083
*/
@@ -1098,7 +1094,6 @@ setup_readline(readlinestate *mod_state)
1098
1094
libedit_history_start = 1 ;
1099
1095
}
1100
1096
clear_history ();
1101
- #endif /* __APPLE__ */
1102
1097
1103
1098
using_history ();
1104
1099
@@ -1127,9 +1122,7 @@ setup_readline(readlinestate *mod_state)
1127
1122
mod_state -> begidx = PyLong_FromLong (0L );
1128
1123
mod_state -> endidx = PyLong_FromLong (0L );
1129
1124
1130
- #ifdef __APPLE__
1131
1125
if (!using_libedit_emulation )
1132
- #endif
1133
1126
{
1134
1127
if (!isatty (STDOUT_FILENO )) {
1135
1128
/* Issue #19884: stdout is not a terminal. Disable meta modifier
@@ -1149,11 +1142,9 @@ setup_readline(readlinestate *mod_state)
1149
1142
* XXX: A bug in the readline-2.2 library causes a memory leak
1150
1143
* inside this function. Nothing we can do about it.
1151
1144
*/
1152
- #ifdef __APPLE__
1153
1145
if (using_libedit_emulation )
1154
1146
rl_read_init_file (NULL );
1155
1147
else
1156
- #endif /* __APPLE__ */
1157
1148
rl_initialize ();
1158
1149
1159
1150
RESTORE_LOCALE (saved_locale )
@@ -1283,12 +1274,10 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
1283
1274
int length = _py_get_history_length ();
1284
1275
if (length > 0 ) {
1285
1276
HIST_ENTRY * hist_ent ;
1286
- #ifdef __APPLE__
1287
1277
if (using_libedit_emulation ) {
1288
1278
/* handle older 0-based or newer 1-based indexing */
1289
1279
hist_ent = history_get (length + libedit_history_start - 1 );
1290
1280
} else
1291
- #endif /* __APPLE__ */
1292
1281
hist_ent = history_get (length );
1293
1282
line = hist_ent ? hist_ent -> line : "" ;
1294
1283
} else
@@ -1316,10 +1305,8 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
1316
1305
PyDoc_STRVAR (doc_module ,
1317
1306
"Importing this module enables command line editing using GNU readline." );
1318
1307
1319
- #ifdef __APPLE__
1320
1308
PyDoc_STRVAR (doc_module_le ,
1321
1309
"Importing this module enables command line editing using libedit readline." );
1322
- #endif /* __APPLE__ */
1323
1310
1324
1311
static struct PyModuleDef readlinemodule = {
1325
1312
PyModuleDef_HEAD_INIT ,
@@ -1340,15 +1327,13 @@ PyInit_readline(void)
1340
1327
PyObject * m ;
1341
1328
readlinestate * mod_state ;
1342
1329
1343
- #ifdef __APPLE__
1344
1330
if (strncmp (rl_library_version , libedit_version_tag , strlen (libedit_version_tag )) == 0 ) {
1345
1331
using_libedit_emulation = 1 ;
1346
1332
}
1347
1333
1348
1334
if (using_libedit_emulation )
1349
1335
readlinemodule .m_doc = doc_module_le ;
1350
1336
1351
- #endif /* __APPLE__ */
1352
1337
1353
1338
m = PyModule_Create (& readlinemodule );
1354
1339
0 commit comments