Blame SOURCES/ksh-20120801-lexfix.patch

f38fd1
diff -up ksh-20120801/src/cmd/ksh93/edit/edit.c.trajfiks ksh-20120801/src/cmd/ksh93/edit/edit.c
f38fd1
--- ksh-20120801/src/cmd/ksh93/edit/edit.c.trajfiks	2012-08-02 00:18:19.000000000 +0200
f38fd1
+++ ksh-20120801/src/cmd/ksh93/edit/edit.c	2014-02-06 12:12:11.570942651 +0100
f38fd1
@@ -53,6 +53,7 @@
f38fd1
 
f38fd1
 static char CURSOR_UP[20] = { ESC, '[', 'A', 0 };
f38fd1
 static char KILL_LINE[20] = { ESC, '[', 'J', 0 };
f38fd1
+static char *savelex;
f38fd1
 
f38fd1
 
f38fd1
 
f38fd1
@@ -232,6 +233,8 @@ int tty_set(int fd, int action, struct t
f38fd1
 void tty_cooked(register int fd)
f38fd1
 {
f38fd1
 	register Edit_t *ep = (Edit_t*)(shgd->ed_context);
f38fd1
+	if(ep->sh->st.trap[SH_KEYTRAP] && savelex)
f38fd1
+		memcpy(ep->sh->lex_context,savelex,ep->sh->lexsize);
f38fd1
 	ep->e_keytrap = 0;
f38fd1
 	if(ep->e_raw==0)
f38fd1
 		return;
f38fd1
@@ -783,6 +786,13 @@ void	ed_setup(register Edit_t *ep, int f
f38fd1
 			ep->e_lbuf[n] = *pp++;
f38fd1
 		ep->e_default = 0;
f38fd1
 	}
f38fd1
+	if(ep->sh->st.trap[SH_KEYTRAP])
f38fd1
+	{
f38fd1
+		if(!savelex)
f38fd1
+			savelex = (char*)malloc(shp->lexsize);
f38fd1
+		if(savelex)
f38fd1
+			memcpy(savelex, ep->sh->lex_context, ep->sh->lexsize);
f38fd1
+	}
f38fd1
 }
f38fd1
 
f38fd1
 static void ed_putstring(register Edit_t *ep, const char *str)
f38fd1
diff -up ksh-20120801/src/cmd/ksh93/include/defs.h.trajfiks ksh-20120801/src/cmd/ksh93/include/defs.h
f38fd1
--- ksh-20120801/src/cmd/ksh93/include/defs.h.trajfiks	2014-02-06 12:18:13.149091836 +0100
f38fd1
+++ ksh-20120801/src/cmd/ksh93/include/defs.h	2014-02-06 12:18:13.175091784 +0100
f38fd1
@@ -224,6 +224,7 @@ struct shared
f38fd1
 	int		xargexit; \
f38fd1
 	int		nenv; \
f38fd1
 	mode_t		mask; \
f38fd1
+	int             lexsize; \
f38fd1
 	Env_t		*env; \
f38fd1
 	void		*init_context; \
f38fd1
 	void		*mac_context; \
f38fd1
diff -up ksh-20120801/src/cmd/ksh93/sh/lex.c.trajfiks ksh-20120801/src/cmd/ksh93/sh/lex.c
f38fd1
--- ksh-20120801/src/cmd/ksh93/sh/lex.c.trajfiks	2014-02-06 12:19:13.587950320 +0100
f38fd1
+++ ksh-20120801/src/cmd/ksh93/sh/lex.c	2014-02-06 12:19:13.623950219 +0100
f38fd1
@@ -268,6 +268,7 @@ Lex_t *sh_lexopen(Lex_t *lp, Shell_t *sp
f38fd1
 	{
f38fd1
 		lp = (Lex_t*)newof(0,Lex_t,1,0);
f38fd1
 		lp->sh = sp;
f38fd1
+		sp->lexsize = sizeof(Lex_t);
f38fd1
 	}
f38fd1
 	fcnotify(lex_advance,lp);
f38fd1
 	lp->lex.intest = lp->lex.incase = lp->lex.skipword = lp->lexd.warn = 0;