Blame SOURCES/ksh-20120801-memlik3.patch

61d8f4
diff -up ksh-20120801/src/cmd/ksh93/include/name.h.memlik3 ksh-20120801/src/cmd/ksh93/include/name.h
61d8f4
--- ksh-20120801/src/cmd/ksh93/include/name.h.memlik3	2012-05-10 18:33:41.000000000 +0200
61d8f4
+++ ksh-20120801/src/cmd/ksh93/include/name.h	2014-01-22 14:14:32.774483776 +0100
61d8f4
@@ -215,7 +215,7 @@ extern Namval_t		*nv_mount(Namval_t*, co
61d8f4
 extern Namval_t		*nv_arraychild(Namval_t*, Namval_t*, int);
61d8f4
 extern int		nv_compare(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
61d8f4
 extern void		nv_outnode(Namval_t*,Sfio_t*, int, int);
61d8f4
-extern int		nv_subsaved(Namval_t*);
61d8f4
+extern int		nv_subsaved(Namval_t*,int);
61d8f4
 extern void		nv_typename(Namval_t*, Sfio_t*);
61d8f4
 extern void		nv_newtype(Namval_t*);
61d8f4
 extern int		nv_istable(Namval_t*);
61d8f4
diff -up ksh-20120801/src/cmd/ksh93/sh/name.c.memlik3 ksh-20120801/src/cmd/ksh93/sh/name.c
61d8f4
--- ksh-20120801/src/cmd/ksh93/sh/name.c.memlik3	2014-01-22 14:14:32.751483987 +0100
61d8f4
+++ ksh-20120801/src/cmd/ksh93/sh/name.c	2014-01-22 14:14:32.775483767 +0100
61d8f4
@@ -1297,7 +1297,7 @@ void nv_delete(Namval_t* np, Dt_t *root,
61d8f4
 	{
61d8f4
 		if(dtdelete(root,np))
61d8f4
 		{
61d8f4
-			if(!(flags&NV_NOFREE) && ((flags&NV_FUNCTION) || !nv_subsaved(np)))
61d8f4
+			if(!(flags&NV_NOFREE) && ((flags&NV_FUNCTION) || !nv_subsaved(np,flags&NV_TABLE)))
61d8f4
 				free((void*)np);
61d8f4
 		}
61d8f4
 #if 0
61d8f4
@@ -2461,14 +2461,14 @@ static void table_unset(Shell_t *shp, re
61d8f4
 			{
61d8f4
 				_nv_unset(nq,flags);
61d8f4
 				npnext = (Namval_t*)dtnext(root,nq);
61d8f4
-				nv_delete(nq,root,0);
61d8f4
+				nv_delete(nq,root,NV_TABLE);
61d8f4
 			}
61d8f4
 		}
61d8f4
 		npnext = (Namval_t*)dtnext(root,np);
61d8f4
                if(nv_arrayptr(np))
61d8f4
                        nv_putsub(np,NIL(char*),ARRAY_SCAN);
61d8f4
 		_nv_unset(np,flags);
61d8f4
-		nv_delete(np,root,0);
61d8f4
+		nv_delete(np,root,NV_TABLE);
61d8f4
 	}
61d8f4
 }
61d8f4
 
61d8f4
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.memlik3 ksh-20120801/src/cmd/ksh93/sh/subshell.c
61d8f4
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.memlik3	2014-01-22 14:14:32.768483831 +0100
61d8f4
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2014-01-22 14:20:50.810236676 +0100
61d8f4
@@ -218,16 +218,28 @@ void sh_subfork(void)
61d8f4
 	}
61d8f4
 }
61d8f4
 
61d8f4
-int nv_subsaved(register Namval_t *np)
61d8f4
+int nv_subsaved(register Namval_t *np,int table)
61d8f4
 {
61d8f4
 	register struct subshell	*sp;
61d8f4
-	register struct Link		*lp;
61d8f4
+	register struct Link		*lp, *lpprev;
61d8f4
 	for(sp = (struct subshell*)subshell_data; sp; sp=sp->prev)
61d8f4
 	{
61d8f4
-		for(lp=sp->svar; lp; lp = lp->next)
61d8f4
+		lpprev = 0;
61d8f4
+		for(lp=sp->svar; lp; lpprev=lp, lp=lp->next)
61d8f4
 		{
61d8f4
 			if(lp->node==np)
61d8f4
+			{
61d8f4
+				if(table&NV_TABLE)
61d8f4
+				{
61d8f4
+					if(lpprev)
61d8f4
+						lpprev->next = lp->next;
61d8f4
+					else
61d8f4
+						sp->svar = lp->next;
61d8f4
+					free((void*)np);
61d8f4
+					free((void*)lp);
61d8f4
+				}
61d8f4
 				return(1);
61d8f4
+			}
61d8f4
 		}
61d8f4
 	}
61d8f4
 	return(0);