Subject: lib/32817: libedit: write_history and read_history returncode is not readline compatible
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <msvensson@mysql.com>
List: netbsd-bugs
Date: 02/13/2006 12:55:01
>Number: 32817
>Category: lib
>Synopsis: libedit: write_history and read_history returncode is not readline compatible
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 13 12:55:00 +0000 2006
>Originator: Magnus Svensson
>Release:
>Organization:
MySQL AB
>Environment:
Linux neptunus 2.6.15-1.1830_FC4smp #1 SMP Thu Feb 2 17:39:38 EST 2006 i686 i686 i386 GNU/Linux
>Description:
The write_history and rwad_history functions in readline.c should return the same returncodes as the readline library would. Ie 0 if succes and greater than 0 if error.
history_save returns the number of items saved, and that value is passed as a returncode from history and eventually write_history. This is interpreted as an error code by the mysql command line client which an be used both with readline and libedit(via the readline interface).
From readline/history.h:
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
extern int read_history PARAMS((const char *));
/* Write the current history to FILENAME. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history (). */
extern int write_history PARAMS((const char *));
>How-To-Repeat:
I got this problem reported by one of our users and would like to fix it in the upstream source. This is the link to our bug report http://bugs.mysql.com/bug.php?id=16557
>Fix:
===== readline.c 1.9 vs edited =====
--- 1.9/cmd-line-utils/libedit/readline.c 2005-05-12 19:01:53 +02:00
+++ edited/readline.c 2006-02-13 13:36:29 +01:00
@@ -1109,7 +1109,7 @@
if (h == NULL || e == NULL)
rl_initialize();
- return (history(h, &ev, H_LOAD, filename));
+ return (history(h, &ev, H_LOAD, filename) == -1);
}
@@ -1123,7 +1123,7 @@
if (h == NULL || e == NULL)
rl_initialize();
- return (history(h, &ev, H_SAVE, filename));
+ return (history(h, &ev, H_SAVE, filename) == -1);
}