[Python-checkins] python/dist/src/Modules readline.c,2.55,2.56

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
2003年1月07日 12:01:37 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv10353
Modified Files:
	readline.c 
Log Message:
Various cleanups:
- Whitespace normalization.
- Cleaned up some comments.
- Broke long lines.
Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.55
retrieving revision 2.56
diff -C2 -d -r2.55 -r2.56
*** readline.c	30 Dec 2002 16:25:41 -0000	2.55
--- readline.c	7 Jan 2003 20:01:29 -0000	2.56
***************
*** 28,32 ****
 
 #ifdef HAVE_RL_COMPLETION_MATCHES
! #define completion_matches(x, y) rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
 #endif
 
--- 28,33 ----
 
 #ifdef HAVE_RL_COMPLETION_MATCHES
! #define completion_matches(x, y) \
! 	rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
 #endif
 
***************
*** 127,153 ****
 
 
! PyDoc_STRVAR(set_history_length_doc,
! "set_history_length(length) -> None\n\
! set the maximal number of items which will be written to\n\
! the history file. A negative length is used to inhibit\n\
! history truncation.");
 
 static PyObject*
 set_history_length(PyObject *self, PyObject *args)
 {
! int length = history_length;
! if (!PyArg_ParseTuple(args, "i:set_history_length", &length))
! 	return NULL;
! history_length = length;
! Py_INCREF(Py_None);
! return Py_None;
 }
 
 
 
! PyDoc_STRVAR(get_history_length_doc,
! "get_history_length() -> int\n\
! return the maximum number of items that will be written to\n\
! the history file.");
 
 static PyObject*
--- 128,152 ----
 
 
! /* Set history length */
 
 static PyObject*
 set_history_length(PyObject *self, PyObject *args)
 {
! 	int length = history_length;
! 	if (!PyArg_ParseTuple(args, "i:set_history_length", &length))
! 		return NULL;
! 	history_length = length;
! 	Py_INCREF(Py_None);
! 	return Py_None;
 }
 
+ PyDoc_STRVAR(set_history_length_doc,
+ "set_history_length(length) -> None\n\
+ set the maximal number of items which will be written to\n\
+ the history file. A negative length is used to inhibit\n\
+ history truncation.");
 
 
! /* Get history length */
 
 static PyObject*
***************
*** 159,166 ****
 }
 
 /* Generic hook function setter */
 
 static PyObject *
! set_hook(const char * funcname, PyObject **hook_var, PyThreadState **tstate, PyObject *args)
 {
 	PyObject *function = Py_None;
--- 158,172 ----
 }
 
+ PyDoc_STRVAR(get_history_length_doc,
+ "get_history_length() -> int\n\
+ return the maximum number of items that will be written to\n\
+ the history file.");
+ 
+ 
 /* Generic hook function setter */
 
 static PyObject *
! set_hook(const char *funcname, PyObject **hook_var,
! 	 PyThreadState **tstate, PyObject *args)
 {
 	PyObject *function = Py_None;
***************
*** 192,195 ****
--- 198,202 ----
 }
 
+ 
 /* Exported functions to specify hook functions in Python */
 
***************
*** 205,209 ****
 set_startup_hook(PyObject *self, PyObject *args)
 {
! 	return set_hook("startup_hook", &startup_hook, &startup_hook_tstate, args);
 }
 
--- 212,217 ----
 set_startup_hook(PyObject *self, PyObject *args)
 {
! 	return set_hook("startup_hook", &startup_hook,
! 			&startup_hook_tstate, args);
 }
 
***************
*** 214,222 ****
 before readline prints the first prompt.");
 
 #ifdef HAVE_RL_PRE_INPUT_HOOK
 static PyObject *
 set_pre_input_hook(PyObject *self, PyObject *args)
 {
! 	return set_hook("pre_input_hook", &pre_input_hook, &pre_input_hook_tstate, args);
 }
 
--- 222,235 ----
 before readline prints the first prompt.");
 
+ 
 #ifdef HAVE_RL_PRE_INPUT_HOOK
+ 
+ /* Set pre-input hook */
+ 
 static PyObject *
 set_pre_input_hook(PyObject *self, PyObject *args)
 {
! 	return set_hook("pre_input_hook", &pre_input_hook,
! 			&pre_input_hook_tstate, args);
 }
 
***************
*** 227,232 ****
--- 240,247 ----
 has been printed and just before readline starts reading input\n\
 characters.");
+ 
 #endif
 
+ 
 /* Exported function to specify a word completer in Python */
 
***************
*** 237,241 ****
 static PyObject *endidx = NULL;
 
! /* get the beginning index for the scope of the tab-completion */
 static PyObject *
 get_begidx(PyObject *self)
--- 252,258 ----
 static PyObject *endidx = NULL;
 
! 
! /* Get the beginning index for the scope of the tab-completion */
! 
 static PyObject *
 get_begidx(PyObject *self)
***************
*** 249,253 ****
 get the beginning index of the readline tab-completion scope");
 
! /* get the ending index for the scope of the tab-completion */
 static PyObject *
 get_endidx(PyObject *self)
--- 266,272 ----
 get the beginning index of the readline tab-completion scope");
 
! 
! /* Get the ending index for the scope of the tab-completion */
! 
 static PyObject *
 get_endidx(PyObject *self)
***************
*** 262,266 ****
 
 
! /* set the tab-completion word-delimiters that readline uses */
 
 static PyObject *
--- 281,285 ----
 
 
! /* Set the tab-completion word-delimiters that readline uses */
 
 static PyObject *
***************
*** 282,285 ****
--- 301,307 ----
 set the readline word delimiters for tab-completion");
 
+ 
+ /* Add a line to the history buffer */
+ 
 static PyObject *
 py_add_history(PyObject *self, PyObject *args)
***************
*** 300,304 ****
 
 
! /* get the tab-completion word-delimiters that readline uses */
 
 static PyObject *
--- 322,326 ----
 
 
! /* Get the tab-completion word-delimiters that readline uses */
 
 static PyObject *
***************
*** 307,315 ****
 	return PyString_FromString(rl_completer_word_break_characters);
 }
! 	
 PyDoc_STRVAR(doc_get_completer_delims,
 "get_completer_delims() -> string\n\
 get the readline word delimiters for tab-completion");
 
 static PyObject *
 set_completer(PyObject *self, PyObject *args)
--- 329,340 ----
 	return PyString_FromString(rl_completer_word_break_characters);
 }
! 
 PyDoc_STRVAR(doc_get_completer_delims,
 "get_completer_delims() -> string\n\
 get the readline word delimiters for tab-completion");
 
+ 
+ /* Set the completer function */
+ 
 static PyObject *
 set_completer(PyObject *self, PyObject *args)
***************
*** 325,328 ****
--- 350,354 ----
 It should return the next possible completion starting with 'text'.");
 
+ 
 /* Exported function to get any element of history */
 
***************
*** 347,350 ****
--- 373,377 ----
 return the current contents of history item at index.");
 
+ 
 /* Exported function to get current length of history */
 
***************
*** 362,365 ****
--- 389,393 ----
 return the current (not the maximum) length of history.");
 
+ 
 /* Exported function to read the current line buffer */
 
***************
*** 374,377 ****
--- 402,406 ----
 return the current contents of the line buffer.");
 
+ 
 /* Exported function to insert text into the line buffer */
 
***************
*** 391,394 ****
--- 420,426 ----
 Insert text into the command line.");
 
+ 
+ /* Redisplay the line buffer */
+ 
 static PyObject *
 redisplay(PyObject *self)
***************
*** 404,407 ****
--- 436,440 ----
 contents of the line buffer.");
 
+ 
 /* Table of functions exported by the module */
 
***************
*** 409,420 ****
 {
 	{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
! 	{"get_line_buffer", (PyCFunction)get_line_buffer, 
 	 METH_NOARGS, doc_get_line_buffer},
 	{"insert_text", insert_text, METH_VARARGS, doc_insert_text},
 	{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay},
 	{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
! 	{"read_history_file", read_history_file, 
 	 METH_VARARGS, doc_read_history_file},
! 	{"write_history_file", write_history_file, 
 	 METH_VARARGS, doc_write_history_file},
 	{"get_history_item", get_history_item,
--- 442,453 ----
 {
 	{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
! 	{"get_line_buffer", (PyCFunction)get_line_buffer,
 	 METH_NOARGS, doc_get_line_buffer},
 	{"insert_text", insert_text, METH_VARARGS, doc_insert_text},
 	{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay},
 	{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
! 	{"read_history_file", read_history_file,
 	 METH_VARARGS, doc_read_history_file},
! 	{"write_history_file", write_history_file,
 	 METH_VARARGS, doc_write_history_file},
 	{"get_history_item", get_history_item,
***************
*** 422,428 ****
 	{"get_current_history_length", (PyCFunction)get_current_history_length,
 	 METH_NOARGS, doc_get_current_history_length},
! 	{"set_history_length", set_history_length, 
 	 METH_VARARGS, set_history_length_doc},
! 	{"get_history_length", get_history_length, 
 	 METH_VARARGS, get_history_length_doc},
 	{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
--- 455,461 ----
 	{"get_current_history_length", (PyCFunction)get_current_history_length,
 	 METH_NOARGS, doc_get_current_history_length},
! 	{"set_history_length", set_history_length,
 	 METH_VARARGS, set_history_length_doc},
! 	{"get_history_length", get_history_length,
 	 METH_VARARGS, get_history_length_doc},
 	{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
***************
*** 430,442 ****
 	{"get_endidx", (PyCFunction)get_endidx, METH_NOARGS, doc_get_endidx},
 
! 	{"set_completer_delims", set_completer_delims, 
 	 METH_VARARGS, doc_set_completer_delims},
 	{"add_history", py_add_history, METH_VARARGS, doc_add_history},
! 	{"get_completer_delims", (PyCFunction)get_completer_delims, 
 	 METH_NOARGS, doc_get_completer_delims},
! 	
! 	{"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook},
 #ifdef HAVE_RL_PRE_INPUT_HOOK
! 	{"set_pre_input_hook", set_pre_input_hook, METH_VARARGS, doc_set_pre_input_hook},
 #endif
 	{0, 0}
--- 463,477 ----
 	{"get_endidx", (PyCFunction)get_endidx, METH_NOARGS, doc_get_endidx},
 
! 	{"set_completer_delims", set_completer_delims,
 	 METH_VARARGS, doc_set_completer_delims},
 	{"add_history", py_add_history, METH_VARARGS, doc_add_history},
! 	{"get_completer_delims", (PyCFunction)get_completer_delims,
 	 METH_NOARGS, doc_get_completer_delims},
! 
! 	{"set_startup_hook", set_startup_hook,
! 	 METH_VARARGS, doc_set_startup_hook},
 #ifdef HAVE_RL_PRE_INPUT_HOOK
! 	{"set_pre_input_hook", set_pre_input_hook,
! 	 METH_VARARGS, doc_set_pre_input_hook},
 #endif
 	{0, 0}
***************
*** 459,465 ****
 		if (r == NULL)
 			goto error;
! 		if (r == Py_None) 
 			result = 0;
! 		else 
 			result = PyInt_AsLong(r);
 		Py_DECREF(r);
--- 494,500 ----
 		if (r == NULL)
 			goto error;
! 		if (r == Py_None)
 			result = 0;
! 		else
 			result = PyInt_AsLong(r);
 		Py_DECREF(r);
***************
*** 614,618 ****
 	char *p, *q;
 	PyOS_sighandler_t old_inthandler;
! 
 	old_inthandler = PyOS_setsig(SIGINT, onintr);
 	if (setjmp(jbuf)) {
--- 649,653 ----
 	char *p, *q;
 	PyOS_sighandler_t old_inthandler;
! 
 	old_inthandler = PyOS_setsig(SIGINT, onintr);
 	if (setjmp(jbuf)) {
***************
*** 626,637 ****
 	rl_event_hook = PyOS_InputHook;
 
! if (sys_stdin != rl_instream || sys_stdout != rl_outstream) {
! rl_instream = sys_stdin;
! rl_outstream = sys_stdout;
 #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
! rl_prep_terminal (1);
 #endif
! }
! 
 	p = readline(prompt);
 	PyOS_setsig(SIGINT, old_inthandler);
--- 661,672 ----
 	rl_event_hook = PyOS_InputHook;
 
! 	if (sys_stdin != rl_instream || sys_stdout != rl_outstream) {
! 		rl_instream = sys_stdin;
! 		rl_outstream = sys_stdout;
 #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
! 		rl_prep_terminal (1);
 #endif
! 	}
! 
 	p = readline(prompt);
 	PyOS_setsig(SIGINT, old_inthandler);
***************
*** 689,693 ****
 			 (PyObject *)NULL, PYTHON_API_VERSION);
 
! PyOS_ReadlineFunctionPointer = call_readline;
! setup_readline();
 }
--- 724,728 ----
 			 (PyObject *)NULL, PYTHON_API_VERSION);
 
! 	PyOS_ReadlineFunctionPointer = call_readline;
! 	setup_readline();
 }

AltStyle によって変換されたページ (->オリジナル) /