Subject: bin/24674: ksh doesn't truncate prompt in emacs mode
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <rix@estpak.ee>
List: netbsd-bugs
Date: 03/04/2004 20:44:39
>Number: 24674
>Category: bin
>Synopsis: ksh doesn't truncate prompt in emacs mode
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 04 20:47:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: rivo nurges
>Release: NetBSD 1.6ZK
>Organization:
>Environment:
System: NetBSD anarchy.estpak.ee 1.6ZK NetBSD 1.6ZK (ANARCHY) #1: Tue Mar 2 15:30:21 UTC 2004 root@anarchy.estpak.ee:/usr/src/sys/arch/i386/compile/ANARCHY i386
Architecture: i386
Machine: i386
>Description:
Ksh doesn't truncate prompt in emacs mode and will not echo any typed chars if prompt is longer than terminal width.
>How-To-Repeat:
export PS1="asdasdasdasdsadsadasdsadsadasdasdsadsadasdsadasdasdasdasdasdasdasdasdasdasdasdasdadasdasdadasdasdasdasdasdasdsadadsadasd" # more if you have larger terminal
try to type something...
>Fix:
Index: bin/ksh/emacs.c
===================================================================
RCS file: /NetBSD/src/bin/ksh/emacs.c,v
retrieving revision 1.23
diff -u -3 -p -r1.23 emacs.c
--- bin/ksh/emacs.c 26 Feb 2004 08:24:03 -0000 1.23
+++ bin/ksh/emacs.c 4 Mar 2004 20:22:58 -0000
@@ -125,6 +125,7 @@ static char *killstack[KILLSIZE];
static int killsp, killtp;
static int x_curprefix;
static char *macroptr;
+static int prompt_trunc; /* how much of prompt to truncate */
static int prompt_skip;
static int x_ins ARGS((char *cp));
@@ -358,11 +359,17 @@ x_emacs(buf, len)
xx_cols = x_cols;
x_col = promptlen(prompt, &p);
prompt_skip = p - prompt;
+ if (x_col > x_cols - 3 - MIN_EDIT_SPACE) {
+ x_col = x_cols - 3 - MIN_EDIT_SPACE;
+ prompt_trunc = x_cols - x_col;
+ } else
+ prompt_trunc = 0;
+
x_adj_ok = 1;
x_displen = xx_cols - 2 - x_col;
x_adj_done = 0;
- pprompt(prompt, 0);
+ pprompt(prompt, prompt_trunc);
if (x_nextcmd >= 0) {
int off = source->line - x_nextcmd;
>Release-Note:
>Audit-Trail:
>Unformatted: