Index: input.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/input.c,v retrieving revision 1.46 diff -r1.46 input.c 93,94d92 < static char *prev_hist = NULL; < 101c99,112 < if (useHistory && s && s[0]) --- > return s; > #else > return gets_basic(prompt); > #endif > } > > /* Put the line in the history buffer and also add the trailing \n */ > char *pgadd_history(char *s, char *history_buf, int *cur_len) > { > #ifdef USE_READLINE > > int slen; > char *history_buf1 = 0; > if (useReadline && useHistory && s && s[0]) 102a114,146 > slen = strlen(s); > history_buf1 = history_buf; > history_buf1 = realloc(history_buf1, (*cur_len + slen + 2) * sizeof(char)); > strcpy(history_buf1 + *cur_len, s); > if (s[slen-1]!='\n') > { > *cur_len += (slen + 1); > history_buf1[*cur_len - 1] = '\n'; > history_buf1[*cur_len] = 0; > } > else > { > *cur_len += (slen); > history_buf1[*cur_len] = 0; > } > > } > return history_buf1; > #endif > } > > /* Feed the contents of the history buffer to readline */ > void pgflush_history(char **history_buf, int *cur_len) > { > > #ifdef USE_READLINE > > char *s; > static char *prev_hist; > > if (useReadline && useHistory && ((*cur_len) > 0)) > { > 103a148,152 > > s = *history_buf; > prev_hist = NULL; > > s[(*cur_len) - 1] = 0; 117a167,170 > > free(s); > *history_buf = 0; > *cur_len = 0; 119,122d171 < < return s; < #else < return gets_basic(prompt); 124d172 < } 125a174 > } Index: input.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/input.h,v retrieving revision 1.23 diff -r1.23 input.h 41a42,44 > char *pgadd_history(char *s, char *history_buf, int *cur_len); > void pgflush_history(char **history_buf, int *cur_len); > Index: mainloop.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/mainloop.c,v retrieving revision 1.68 diff -r1.68 mainloop.c 40a41,42 > char *history_buf = 0; > int history_buf_len = 0; 140a143,151 > > if ( pset.cur_cmd_interactive ) > { > /* Pass all the contents of history_buf to readline > * and free the history buffer. > */ > pgflush_history(&history_buf, &history_buf_len); > } > 215c226,232 < --- > > if (pset.cur_cmd_interactive) > { > /* Put current line in the history buffer */ > history_buf = pgadd_history(line, history_buf, &history_buf_len); > } > 231a249 > 251a270,271 > > 255a276 > 268a290 > 289a312,319 > > if (pset.cur_cmd_interactive && (prompt_status != PROMPT_CONTINUE)) > { > /* Pass all the contents of history_buf to readline > and free the history buffer. > */ > pgflush_history(&history_buf, &history_buf_len); > }