summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2022-09-20 23:41:14 +0000
committerchristos <christos@NetBSD.org>2022-09-20 23:41:14 +0000
commit10e205d70be80d69bf8bcc42e028e913bf96f112 (patch)
tree385a1401656abc5a249892c951969005ba584673 /lib/libedit
parentd69eb2cc32ee990625006ab5b148abf0c7728ddd (diff)
PR/57016: Ricky Zhou: Revert to trimming the last newline instead of the
first one so that multi-line commands work again.
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/readline.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index 7d7f1ec3b9f..8aa8af493b4 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -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 @@ readline(const char *p)
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;