From db5621dbf8abec3ff4f4450845439a014eb6d121 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 27 Jan 2021 05:56:12 +0000 Subject: [PATCH] Fix editor prediction code garbling input This applies a patch from OpenSUSE. Source: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-edpredict.dif | Tue Jul 5 14:49:03 CEST 2016 - mls@suse.de | | - fix editor prediction code garbling input [bnc#964966] | new patch: ksh93-edpredict.dif Unfortunately the bug report is not currently public: https://bugzilla.opensuse.org/show_bug.cgi?id=964966 but this one seems sensible enough and is in production use, so I'll take it on faith. --- src/cmd/ksh93/edit/edit.c | 2 +- src/cmd/ksh93/edit/emacs.c | 4 +--- src/cmd/ksh93/edit/vi.c | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c index e19a7d2775aa..ec9725b59f97 100644 --- a/src/cmd/ksh93/edit/edit.c +++ b/src/cmd/ksh93/edit/edit.c @@ -621,8 +621,8 @@ void ed_setup(register Edit_t *ep, int fd, int reedit) ep->hoff = 0; #endif /* SHOPT_EDPREDICT */ #if KSHELL - ep->e_stkptr = stakptr(0); ep->e_stkoff = staktell(); + ep->e_stkptr = stakfreeze(0); if(!(last = shp->prompt)) last = ""; shp->prompt = 0; diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index f086fe1acb46..a580dd447b99 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -726,10 +726,8 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) draw(ep,FINAL); tty_cooked(ERRIO); if(ed->e_nlist) - { ed->e_nlist = 0; - stakset(ed->e_stkptr,ed->e_stkoff); - } + stakset(ed->e_stkptr,ed->e_stkoff); if(c == '\n') { out[eol++] = '\n'; diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index 3c1a5650b47c..c4c05653341e 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -593,10 +593,8 @@ int ed_viread(void *context, int fd, register char *shbuf, int nchar, int reedit /* to cause the shell to process the line */ tty_cooked(ERRIO); if(ed->e_nlist) - { ed->e_nlist = 0; - stakset(ed->e_stkptr,ed->e_stkoff); - } + stakset(ed->e_stkptr,ed->e_stkoff); if( vp->addnl ) { virtual[++last_virt] = '\n';