Module Name: src
Committed By: christos
Date: Tue Sep 20 23:41:14 UTC 2022
Modified Files:
src/lib/libedit: readline.c
Log Message:
PR/57016: Ricky Zhou: Revert to trimming the last newline instead of the
first one so that multi-line commands work again.
To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/lib/libedit/readline.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.174 src/lib/libedit/readline.c:1.175
--- src/lib/libedit/readline.c:1.174 Fri Apr 8 16:11:31 2022
+++ src/lib/libedit/readline.c Tue Sep 20 19:41:14 2022
@@ -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;