#ifdef SAVE_LOCALE
# define RESTORE_LOCALE(sl) { setlocale(LC_CTYPE, sl); free(sl); }
#else
-# define RESTORE_LOCALE(sl)
+# define RESTORE_LOCALE(sl)
#endif
/* GNU readline definitions */
#ifdef __APPLE__
/*
* It is possible to link the readline module to the readline
- * emulation library of editline/libedit.
- *
+ * emulation library of editline/libedit.
+ *
* On OSX this emulation library is not 100% API compatible
* with the "real" readline and cannot be detected at compile-time,
* hence we use a runtime check to detect if we're using libedit
*
- * Currently there is one know API incompatibility:
+ * Currently there is one know API incompatibility:
* - 'get_history' has a 1-based index with GNU readline, and a 0-based
* index with libedit's emulation.
* - Note that replace_history and remove_history use a 0-based index
}
/* free memory allocated for the history entry */
if (entry->line)
- free(entry->line);
+ free((void *)entry->line);
if (entry->data)
free(entry->data);
free(entry);
}
/* free memory allocated for the old history entry */
if (old_entry->line)
- free(old_entry->line);
+ free((void *)old_entry->line);
if (old_entry->data)
free(old_entry->data);
free(old_entry);
/*
* Apple's readline emulation crashes when
- * the index is out of range, therefore
+ * the index is out of range, therefore
* test for that and fail gracefully.
*/
if (idx < 0 || idx >= hist_st->length) {
result = 0;
else {
result = PyInt_AsLong(r);
- if (result == -1 && PyErr_Occurred())
+ if (result == -1 && PyErr_Occurred())
goto error;
}
Py_DECREF(r);
"sOi", matches[0], m, max_length);
Py_DECREF(m); m=NULL;
-
+
if (r == NULL ||
(r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
goto error;
char *result = NULL;
if (completer != NULL) {
PyObject *r;
-#ifdef WITH_THREAD
+#ifdef WITH_THREAD
PyGILState_STATE gilstate = PyGILState_Ensure();
#endif
rl_attempted_completion_over = 1;
PyErr_Clear();
Py_XDECREF(r);
done:
-#ifdef WITH_THREAD
+#ifdef WITH_THREAD
PyGILState_Release(gilstate);
#endif
return result;
rl_callback_handler_install (prompt, rlhandler);
FD_ZERO(&selectset);
-
+
completed_input_string = not_done_reading;
while (completed_input_string == not_done_reading) {
while (!has_input)
{ struct timeval timeout = {0, 100000}; /* 0.1 seconds */
- /* [Bug #1552726] Only limit the pause if an input hook has been
+ /* [Bug #1552726] Only limit the pause if an input hook has been
defined. */
struct timeval *timeoutp = NULL;
- if (PyOS_InputHook)
+ if (PyOS_InputHook)
timeoutp = &timeout;
FD_SET(fileno(rl_instream), &selectset);
/* select resets selectset if no input was available */
#endif
s = PyErr_CheckSignals();
#ifdef WITH_THREAD
- PyEval_SaveThread();
+ PyEval_SaveThread();
#endif
if (s < 0) {
rl_free_line_state();
{
PyOS_sighandler_t old_inthandler;
char *p;
-
+
*signal = 0;
old_inthandler = PyOS_setsig(SIGINT, onintr);
}
p = readline_until_enter_or_signal(prompt, &signal);
-
+
/* we got an interrupt signal */
if (signal) {
RESTORE_LOCALE(saved_locale)
/* we have a valid line */
n = strlen(p);
if (n > 0) {
- char *line;
+ const char *line;
HISTORY_STATE *state = history_get_history_state();
if (state->length > 0)
#ifdef __APPLE__
if (using_libedit_emulation) {
- /*
+ /*
* Libedit's emulation uses 0-based indexes,
* the real readline uses 1-based indexes.
*/
line = history_get(state->length - 1)->line;
- } else
+ } else
#endif /* __APPLE__ */
line = history_get(state->length)->line;
else
using_libedit_emulation = 1;
}
- if (using_libedit_emulation)
+ if (using_libedit_emulation)
m = Py_InitModule4("readline", readline_methods, doc_module_le,
(PyObject *)NULL, PYTHON_API_VERSION);
else