23319761 cd going dotty by removing leading periods in dir names
authorLijo George<lijo.x.george@oracle.com>
Thu, 13 Oct 2016 03:01:51 -0700
changeset 7098 a46c4562925e
parent 7096 c97796f93f28
child 7099 58b579e0ff32
23319761 cd going dotty by removing leading periods in dir names
components/ksh93/patches/270-23319761.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ksh93/patches/270-23319761.patch	Thu Oct 13 03:01:51 2016 -0700
@@ -0,0 +1,51 @@
+This fix comes from the community, this patch ports the relevant 
+changes from the upstream 2013-10-10-alpha version which fixed the issue.
+--- INIT.2012-08-01.old/src/cmd/ksh93/bltins/cd_pwd.c	2016-06-28 04:05:14.983264679 -0700
++++ INIT.2012-08-01/src/cmd/ksh93/bltins/cd_pwd.c	2016-06-28 04:12:16.937817270 -0700
+@@ -109,34 +109,20 @@
+ 		if(!oldpwd)
+ 			oldpwd = path_pwd(shp,1);
+ 	}
+-	if(*dir=='.')
++	if(*dir!='/')
+ 	{
+-		/* test for pathname . ./ .. or ../ */
+-		int	n=0;
+-		char	*sp;
+-		for(dp=dir; *dp=='.'; dp++)
++		/* check for leading .. */
++		char *cp;
++		sfprintf(shp->strbuf,"%s",dir);
++		cp = sfstruse(shp->strbuf);
++		pathcanon(cp, 0);
++		if(cp[0]=='.' && cp[1]=='.' && (cp[2]=='/' || cp[2]==0))
+ 		{
+-			if(*++dp=='.' && (*++dp=='/' || *dp==0))
+-				n++;
+-			else if(*dp && *dp!='/')
+-				break;
+-			if(*dp==0)
+-				break;
+-		}
+-		if(n)	
+-		{
+-			cdpath = 0;
+-			sp = oldpwd + strlen(oldpwd);
+-			while(n--)
+-			{
+-				while(--sp > oldpwd && *sp!='/');
+-				if(sp==oldpwd)
+-					break;
+-				
+-			}
+-			sfwrite(shp->strbuf,oldpwd,sp+1-oldpwd);
+-			sfputr(shp->strbuf,dp,0);
+-			dir = sfstruse(shp->strbuf);
++			if(!shp->strbuf2)
++				shp->strbuf2 = sfstropen();
++			sfprintf(shp->strbuf2,"%s/%s",oldpwd,cp);
++			dir = sfstruse(shp->strbuf2);
++			pathcanon(dir, 0);
+ 		}
+ 	}
+ 	rval = -1;