Kaydet (Commit) 0e986a31 authored tarafından Michael W. Hudson's avatar Michael W. Hudson

I was in this module anyway, so I did some janitorial things.

METH_NOARGS functions are still called with two arguments, one NULL,
so put that back into the function definitions (I didn't know this
until recently).

Make get_history_length() METH_NOARGS.
üst 796df156
...@@ -150,11 +150,9 @@ history truncation."); ...@@ -150,11 +150,9 @@ history truncation.");
/* Get history length */ /* Get history length */
static PyObject* static PyObject*
get_history_length(PyObject *self, PyObject *args) get_history_length(PyObject *self, PyObject *noarg)
{ {
if (!PyArg_ParseTuple(args, ":get_history_length")) return PyInt_FromLong(history_length);
return NULL;
return Py_BuildValue("i", history_length);
} }
PyDoc_STRVAR(get_history_length_doc, PyDoc_STRVAR(get_history_length_doc,
...@@ -255,7 +253,7 @@ static PyObject *endidx = NULL; ...@@ -255,7 +253,7 @@ static PyObject *endidx = NULL;
/* Get the beginning index for the scope of the tab-completion */ /* Get the beginning index for the scope of the tab-completion */
static PyObject * static PyObject *
get_begidx(PyObject *self) get_begidx(PyObject *self, PyObject *noarg)
{ {
Py_INCREF(begidx); Py_INCREF(begidx);
return begidx; return begidx;
...@@ -269,7 +267,7 @@ get the beginning index of the readline tab-completion scope"); ...@@ -269,7 +267,7 @@ get the beginning index of the readline tab-completion scope");
/* Get the ending index for the scope of the tab-completion */ /* Get the ending index for the scope of the tab-completion */
static PyObject * static PyObject *
get_endidx(PyObject *self) get_endidx(PyObject *self, PyObject *noarg)
{ {
Py_INCREF(endidx); Py_INCREF(endidx);
return endidx; return endidx;
...@@ -324,7 +322,7 @@ add a line to the history buffer"); ...@@ -324,7 +322,7 @@ add a line to the history buffer");
/* Get the tab-completion word-delimiters that readline uses */ /* Get the tab-completion word-delimiters that readline uses */
static PyObject * static PyObject *
get_completer_delims(PyObject *self) get_completer_delims(PyObject *self, PyObject *noarg)
{ {
return PyString_FromString(rl_completer_word_break_characters); return PyString_FromString(rl_completer_word_break_characters);
} }
...@@ -392,7 +390,7 @@ return the current contents of history item at index."); ...@@ -392,7 +390,7 @@ return the current contents of history item at index.");
/* Exported function to get current length of history */ /* Exported function to get current length of history */
static PyObject * static PyObject *
get_current_history_length(PyObject *self) get_current_history_length(PyObject *self, PyObject *noarg)
{ {
HISTORY_STATE *hist_st; HISTORY_STATE *hist_st;
...@@ -408,7 +406,7 @@ return the current (not the maximum) length of history."); ...@@ -408,7 +406,7 @@ return the current (not the maximum) length of history.");
/* Exported function to read the current line buffer */ /* Exported function to read the current line buffer */
static PyObject * static PyObject *
get_line_buffer(PyObject *self) get_line_buffer(PyObject *self, PyObject *noarg)
{ {
return PyString_FromString(rl_line_buffer); return PyString_FromString(rl_line_buffer);
} }
...@@ -439,7 +437,7 @@ Insert text into the command line."); ...@@ -439,7 +437,7 @@ Insert text into the command line.");
/* Redisplay the line buffer */ /* Redisplay the line buffer */
static PyObject * static PyObject *
redisplay(PyObject *self) redisplay(PyObject *self, PyObject *noarg)
{ {
rl_redisplay(); rl_redisplay();
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -457,10 +455,9 @@ contents of the line buffer."); ...@@ -457,10 +455,9 @@ contents of the line buffer.");
static struct PyMethodDef readline_methods[] = static struct PyMethodDef readline_methods[] =
{ {
{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
{"get_line_buffer", (PyCFunction)get_line_buffer, {"get_line_buffer", get_line_buffer, METH_NOARGS, doc_get_line_buffer},
METH_NOARGS, doc_get_line_buffer},
{"insert_text", insert_text, METH_VARARGS, doc_insert_text}, {"insert_text", insert_text, METH_VARARGS, doc_insert_text},
{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay}, {"redisplay", redisplay, METH_NOARGS, doc_redisplay},
{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file}, {"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
{"read_history_file", read_history_file, {"read_history_file", read_history_file,
METH_VARARGS, doc_read_history_file}, METH_VARARGS, doc_read_history_file},
...@@ -473,16 +470,16 @@ static struct PyMethodDef readline_methods[] = ...@@ -473,16 +470,16 @@ static struct PyMethodDef readline_methods[] =
{"set_history_length", set_history_length, {"set_history_length", set_history_length,
METH_VARARGS, set_history_length_doc}, METH_VARARGS, set_history_length_doc},
{"get_history_length", get_history_length, {"get_history_length", get_history_length,
METH_VARARGS, get_history_length_doc}, METH_NOARGS, get_history_length_doc},
{"set_completer", set_completer, METH_VARARGS, doc_set_completer}, {"set_completer", set_completer, METH_VARARGS, doc_set_completer},
{"get_completer", get_completer, METH_NOARGS, doc_get_completer}, {"get_completer", get_completer, METH_NOARGS, doc_get_completer},
{"get_begidx", (PyCFunction)get_begidx, METH_NOARGS, doc_get_begidx}, {"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx},
{"get_endidx", (PyCFunction)get_endidx, METH_NOARGS, doc_get_endidx}, {"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx},
{"set_completer_delims", set_completer_delims, {"set_completer_delims", set_completer_delims,
METH_VARARGS, doc_set_completer_delims}, METH_VARARGS, doc_set_completer_delims},
{"add_history", py_add_history, METH_VARARGS, doc_add_history}, {"add_history", py_add_history, METH_VARARGS, doc_add_history},
{"get_completer_delims", (PyCFunction)get_completer_delims, {"get_completer_delims", get_completer_delims,
METH_NOARGS, doc_get_completer_delims}, METH_NOARGS, doc_get_completer_delims},
{"set_startup_hook", set_startup_hook, {"set_startup_hook", set_startup_hook,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment