Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit PR lib/52547 - read_history (readline.c) should ...



details:   https://anonhg.NetBSD.org/src/rev/7b41a0872339
branches:  trunk
changeset: 826618:7b41a0872339
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Sep 17 08:10:08 2017 +0000

description:
PR lib/52547 - read_history (readline.c) should now sets history_length.

Patch from Yen Chi Hsuan in the PR, extracted from Apple's version of
readline.c, then modified by me to be consistent about what the return
value really is.

diffstat:

 lib/libedit/readline.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r f3daaf6e44d3 -r 7b41a0872339 lib/libedit/readline.c
--- a/lib/libedit/readline.c    Sun Sep 17 05:47:19 2017 +0000
+++ b/lib/libedit/readline.c    Sun Sep 17 08:10:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.143 2017/09/05 18:07:59 christos Exp $  */
+/*     $NetBSD: readline.c,v 1.144 2017/09/17 08:10:08 kre Exp $       */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.143 2017/09/05 18:07:59 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.144 2017/09/17 08:10:08 kre Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -1355,8 +1355,14 @@
                rl_initialize();
        if (filename == NULL && (filename = _default_history_file()) == NULL)
                return errno;
-       return history(h, &ev, H_LOAD, filename) == -1 ?
-           (errno ? errno : EINVAL) : 0;
+       errno = 0;
+       if (history(h, &ev, H_LOAD, filename) == -1)
+           return errno ? errno : EINVAL;
+       if (history(h, &ev, H_GETSIZE) == 0)
+               history_length = ev.num;
+       if (history_length < 0)
+               return EINVAL;
+       return 0;
 }
 
 



Home | Main Index | Thread Index | Old Index