Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2204566

Browse files
committed
Fix saveHistory() to not emit bogus complaint during psql exit when using
Darwin's libedit; per my proposal last August. Also, suppress cast-away-const warnings.
1 parentf1e671a commit2204566

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

‎src/bin/psql/input.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.55 2006/06/14 16:49:02 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.56 2006/06/18 17:30:48 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -245,11 +245,14 @@ encode_history(void)
245245
HIST_ENTRY*cur_hist;
246246
char*cur_ptr;
247247

248-
for (history_set_pos(0),cur_hist=current_history();
249-
cur_hist;cur_hist=next_history())
250-
for (cur_ptr=cur_hist->line;*cur_ptr;cur_ptr++)
248+
history_set_pos(0);
249+
for (cur_hist=current_history();cur_hist;cur_hist=next_history())
250+
{
251+
/* some platforms declare HIST_ENTRY.line as const char * */
252+
for (cur_ptr= (char*)cur_hist->line;*cur_ptr;cur_ptr++)
251253
if (*cur_ptr=='\n')
252254
*cur_ptr=NL_IN_HISTORY;
255+
}
253256
}
254257

255258
/*
@@ -261,11 +264,14 @@ decode_history(void)
261264
HIST_ENTRY*cur_hist;
262265
char*cur_ptr;
263266

264-
for (history_set_pos(0),cur_hist=current_history();
265-
cur_hist;cur_hist=next_history())
266-
for (cur_ptr=cur_hist->line;*cur_ptr;cur_ptr++)
267+
history_set_pos(0);
268+
for (cur_hist=current_history();cur_hist;cur_hist=next_history())
269+
{
270+
/* some platforms declare HIST_ENTRY.line as const char * */
271+
for (cur_ptr= (char*)cur_hist->line;*cur_ptr;cur_ptr++)
267272
if (*cur_ptr==NL_IN_HISTORY)
268273
*cur_ptr='\n';
274+
}
269275
}
270276
#endif/* USE_READLINE */
271277

@@ -339,13 +345,22 @@ saveHistory(char *fname, bool encodeFlag)
339345
{
340346
if (encodeFlag)
341347
encode_history();
342-
if (write_history(fname)==0)
348+
349+
/*
350+
* return value of write_history is not standardized across GNU
351+
* readline and libedit. Therefore, check for errno becoming set
352+
* to see if the write failed.
353+
*/
354+
errno=0;
355+
(void)write_history(fname);
356+
if (errno==0)
343357
return true;
344358

345359
psql_error("could not save history to file \"%s\": %s\n",
346360
fname,strerror(errno));
347361
}
348362
#else
363+
/* only get here in \s case, so complain */
349364
psql_error("history is not supported by this installation\n");
350365
#endif
351366

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp