[Python-checkins] python/dist/src/Modules readline.c,2.53,2.54

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sat, 26 Oct 2002 07:39:11 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv26440/Modules

Modified Files:
	readline.c 
Log Message:
Patch #512981: Update readline input stream on sys.stdin/out change.


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -d -r2.53 -r2.54
*** readline.c	9 Oct 2002 21:27:33 -0000	2.53
--- readline.c	26 Oct 2002 14:39:09 -0000	2.54
***************
*** 33,37 ****
  /* Pointers needed from outside (but not declared in a header file). */
  extern DL_IMPORT(int) (*PyOS_InputHook)(void);
! extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(char *);
  
  
--- 33,37 ----
  /* Pointers needed from outside (but not declared in a header file). */
  extern DL_IMPORT(int) (*PyOS_InputHook)(void);
! extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *,char *);
  
  
***************
*** 607,616 ****
  
  static char *
! call_readline(char *prompt)
  {
  	size_t n;
  	char *p, *q;
  	PyOS_sighandler_t old_inthandler;
! 	
  	old_inthandler = PyOS_setsig(SIGINT, onintr);
  	if (setjmp(jbuf)) {
--- 607,616 ----
  
  static char *
! call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
  {
  	size_t n;
  	char *p, *q;
  	PyOS_sighandler_t old_inthandler;
!         
  	old_inthandler = PyOS_setsig(SIGINT, onintr);
  	if (setjmp(jbuf)) {
***************
*** 623,626 ****
--- 623,633 ----
  	}
  	rl_event_hook = PyOS_InputHook;
+ 
+         if (sys_stdin != rl_instream || sys_stdout != rl_outstream) {
+                 rl_instream = sys_stdin;
+                 rl_outstream = sys_stdout;
+                 rl_prep_terminal (1);
+         }
+         
  	p = readline(prompt);
  	PyOS_setsig(SIGINT, old_inthandler);
***************
*** 677,683 ****
  	m = Py_InitModule4("readline", readline_methods, doc_module,
  			   (PyObject *)NULL, PYTHON_API_VERSION);
! 	if (isatty(fileno(stdin))) {
! 		PyOS_ReadlineFunctionPointer = call_readline;
! 		setup_readline();
! 	}
  }
--- 684,689 ----
  	m = Py_InitModule4("readline", readline_methods, doc_module,
  			   (PyObject *)NULL, PYTHON_API_VERSION);
! 
!         PyOS_ReadlineFunctionPointer = call_readline;
!         setup_readline();
  }