we got a decision on pathnames with exactly two leading slashes

thanks, Eric and David!
This commit is contained in:
tg 2011-03-28 21:31:01 +00:00
parent 6fddfc009b
commit b91b037e6a
2 changed files with 10 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.440 2011/03/28 21:18:00 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.441 2011/03/28 21:30:59 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -8664,8 +8664,7 @@ stdin:
pwd
cd ../lib
pwd
cd -P ../libexec
pwd
realpath //usr/include/../bin
expected-stdout:
/bin
//bin
@ -8677,8 +8676,8 @@ expected-stdout:
//bin
/bin
//usr/bin
//usr/bin/../lib
//usr/libexec
//usr/lib
//usr/bin
---
name: crash-1
description:

12
misc.c
View File

@ -29,7 +29,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.163 2011/03/26 21:46:03 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.164 2011/03/28 21:31:01 tg Exp $");
/* type bits for unsigned char */
unsigned char chtypes[UCHAR_MAX + 1];
@ -1368,9 +1368,9 @@ do_realpath(const char *upath)
/* assert: (ip == ipath)[0] == '/' */
/* assert: xp == xs.beg => start of path */
/* exactly two leading slashes? */
/* exactly two leading slashes? (SUSv4 3.266) */
if (ip[1] == '/' && ip[2] != '/') {
/* SUSv4 3.266 Pathname */
/* keep them, e.g. for UNC pathnames */
Xput(xs, xp, '/');
}
}
@ -1516,7 +1516,7 @@ make_path(const char *cwd, const char *file,
*
* simplify_path(this) = that
* /a/b/c/./../d/.. /a/b
* //./C/foo/bar/../baz //./C/foo/bar/../baz
* //./C/foo/bar/../baz //C/foo/baz
* /foo/ /foo
* /foo/../../bar /bar
* /foo/./blah/.. /foo
@ -1538,8 +1538,8 @@ simplify_path(char *p)
case '/':
/* exactly two leading slashes? (SUSv4 3.266) */
if (p[1] == '/' && p[2] != '/')
/* implementation defined, we CANNOT simplify this */
return;
/* keep them, e.g. for UNC pathnames */
++p;
needslash = true;
break;
default: