[Python-checkins] python/dist/src/Modules readline.c,2.49,2.50
montanaro@users.sourceforge.net
montanaro@users.sourceforge.net
Tue, 11 Jun 2002 07:32:50 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3072
Modified Files:
readline.c
Log Message:
patch #562492 - prevent duplicate lines in history
also call using_history() to properly initialize history variables
Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.49
retrieving revision 2.50
diff -C2 -d -r2.49 -r2.50
*** readline.c 30 May 2002 15:41:56 -0000 2.49
--- readline.c 11 Jun 2002 14:32:46 -0000 2.50
***************
*** 553,556 ****
--- 553,558 ----
setup_readline(void)
{
+ using_history();
+
rl_readline_name = "python";
#if defined(PYOS_OS2) && defined(PYCC_GCC)
***************
*** 629,634 ****
}
n = strlen(p);
! if (n > 0)
! add_history(p);
/* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and
release the original. */
--- 631,651 ----
}
n = strlen(p);
! if (n > 0) {
! char *line;
! HISTORY_STATE *state = history_get_history_state();
! if (state->length > 0)
! line = history_get(state->length)->line;
! else
! line = "";
! if (strcmp(p, line))
! add_history(p);
! /* the history docs don't say so, but the address of state
! changes each time history_get_history_state is called
! which makes me think it's freshly malloc'd memory...
! on the other hand, the address of the last line stays the
! same as long as history isn't extended, so it appears to
! be malloc'd but managed by the history package... */
! free(state);
! }
/* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and
release the original. */