File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 3
3
*
4
4
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.47 2006/02/11 21:55:35 momjian Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.48 2006/02/12 05:24:38 momjian Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
@@ -26,6 +26,15 @@ static bool useReadline;
26
26
static bool useHistory ;
27
27
char * psql_history ;
28
28
29
+ /*
30
+ * Preserve newlines in saved queries by mapping '\n' to NL_IN_HISTORY
31
+ *
32
+ * It is assumed NL_IN_HISTORY will never be entered by the user
33
+ * nor appear inside a multi-byte string. 0x00 is not properly
34
+ * handled by the readline routines so it can not be used
35
+ * for this purpose.
36
+ */
37
+ #define NL_IN_HISTORY 0x01
29
38
30
39
enum histcontrol
31
40
{
@@ -213,7 +222,7 @@ static void encode_history()
213
222
cur_hist ; cur_hist = next_history ())
214
223
for (cur_ptr = cur_hist -> line ; * cur_ptr ; cur_ptr ++ )
215
224
if (* cur_ptr == '\n' )
216
- * cur_ptr = '\0' ;
225
+ * cur_ptr = NL_IN_HISTORY ;
217
226
}
218
227
219
228
static void decode_history ()
@@ -224,7 +233,7 @@ static void decode_history()
224
233
for (history_set_pos (0 ), cur_hist = current_history ();
225
234
cur_hist ; cur_hist = next_history ())
226
235
for (cur_ptr = cur_hist -> line ; * cur_ptr ; cur_ptr ++ )
227
- if (* cur_ptr == '\0' )
236
+ if (* cur_ptr == NL_IN_HISTORY )
228
237
* cur_ptr = '\n' ;
229
238
}
230
239
You can’t perform that action at this time.
0 commit comments