Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/57016: Ricky Zhou: Revert to trimming the las...



details:   https://anonhg.NetBSD.org/src/rev/fb6093b431fc
branches:  trunk
changeset: 370174:fb6093b431fc
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Sep 20 23:41:14 2022 +0000

description:
PR/57016: Ricky Zhou: Revert to trimming the last newline instead of the
first one so that multi-line commands work again.

diffstat:

 lib/libedit/readline.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (29 lines):

diff -r 14a120b74e75 -r fb6093b431fc lib/libedit/readline.c
--- a/lib/libedit/readline.c    Tue Sep 20 23:01:42 2022 +0000
+++ b/lib/libedit/readline.c    Tue Sep 20 23:41:14 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos Exp $  */
+/*     $NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos 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.174 2022/04/08 20:11:31 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.175 2022/09/20 23:41:14 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -481,7 +481,9 @@
                buf = strdup(ret);
                if (buf == NULL)
                        goto out;
-               buf[strcspn(buf, "\n")] = '\0';
+               lastidx = count - 1;
+               if (buf[lastidx] == '\n')
+                       buf[lastidx] = '\0';
        } else
                buf = NULL;
 



Home | Main Index | Thread Index | Old Index