@@ -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 {
@@ -1080,7 +1077,6 @@ setup_readline(readlinestate *mod_state)
1080
1077
/* The name must be defined before initialization */
1081
1078
rl_readline_name = "python" ;
1082
1079
1083
- #ifdef __APPLE__
1084
1080
/* the libedit readline emulation resets key bindings etc
1085
1081
* when calling rl_initialize. So call it upfront
1086
1082
*/
@@ -1097,7 +1093,6 @@ setup_readline(readlinestate *mod_state)
1097
1093
libedit_history_start = 1 ;
1098
1094
}
1099
1095
clear_history ();
1100
- #endif /* __APPLE__ */
1101
1096
1102
1097
using_history ();
1103
1098
@@ -1126,9 +1121,7 @@ setup_readline(readlinestate *mod_state)
1126
1121
mod_state -> begidx = PyLong_FromLong (0L );
1127
1122
mod_state -> endidx = PyLong_FromLong (0L );
1128
1123
1129
- #ifdef __APPLE__
1130
1124
if (!using_libedit_emulation )
1131
- #endif
1132
1125
{
1133
1126
if (!isatty (STDOUT_FILENO )) {
1134
1127
/* Issue #19884: stdout is not a terminal. Disable meta modifier
@@ -1148,11 +1141,9 @@ setup_readline(readlinestate *mod_state)
1148
1141
* XXX: A bug in the readline-2.2 library causes a memory leak
1149
1142
* inside this function. Nothing we can do about it.
1150
1143
*/
1151
- #ifdef __APPLE__
1152
1144
if (using_libedit_emulation )
1153
1145
rl_read_init_file (NULL );
1154
1146
else
1155
- #endif /* __APPLE__ */
1156
1147
rl_initialize ();
1157
1148
1158
1149
RESTORE_LOCALE (saved_locale )
@@ -1281,12 +1272,10 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
1281
1272
int length = _py_get_history_length ();
1282
1273
if (length > 0 ) {
1283
1274
HIST_ENTRY * hist_ent ;
1284
- #ifdef __APPLE__
1285
1275
if (using_libedit_emulation ) {
1286
1276
/* handle older 0-based or newer 1-based indexing */
1287
1277
hist_ent = history_get (length + libedit_history_start - 1 );
1288
1278
} else
1289
- #endif /* __APPLE__ */
1290
1279
hist_ent = history_get (length );
1291
1280
line = hist_ent ? hist_ent -> line : "" ;
1292
1281
} else
@@ -1314,10 +1303,8 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
1314
1303
PyDoc_STRVAR (doc_module ,
1315
1304
"Importing this module enables command line editing using GNU readline." );
1316
1305
1317
- #ifdef __APPLE__
1318
1306
PyDoc_STRVAR (doc_module_le ,
1319
1307
"Importing this module enables command line editing using libedit readline." );
1320
- #endif /* __APPLE__ */
1321
1308
1322
1309
static struct PyModuleDef readlinemodule = {
1323
1310
PyModuleDef_HEAD_INIT ,
@@ -1338,15 +1325,13 @@ PyInit_readline(void)
1338
1325
PyObject * m ;
1339
1326
readlinestate * mod_state ;
1340
1327
1341
- #ifdef __APPLE__
1342
1328
if (strncmp (rl_library_version , libedit_version_tag , strlen (libedit_version_tag )) == 0 ) {
1343
1329
using_libedit_emulation = 1 ;
1344
1330
}
1345
1331
1346
1332
if (using_libedit_emulation )
1347
1333
readlinemodule .m_doc = doc_module_le ;
1348
1334
1349
- #endif /* __APPLE__ */
1350
1335
1351
1336
m = PyModule_Create (& readlinemodule );
1352
1337
0 commit comments