Blame SOURCES/ksh-20120801-lexfix.patch

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