summaryrefslogtreecommitdiff
path: root/shells/pdksh/files/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'shells/pdksh/files/path.c')
-rw-r--r--shells/pdksh/files/path.c90
1 files changed, 30 insertions, 60 deletions
diff --git a/shells/pdksh/files/path.c b/shells/pdksh/files/path.c
index f73c2abc27a..525b2d52974 100644
--- a/shells/pdksh/files/path.c
+++ b/shells/pdksh/files/path.c
@@ -1,55 +1,25 @@
+/* $NetBSD: path.c,v 1.2 2008/05/31 16:47:37 tnn Exp $ */
+#include <sys/cdefs.h>
+
+#ifndef lint
+__RCSID("$NetBSD: path.c,v 1.2 2008/05/31 16:47:37 tnn Exp $");
+#endif
+
+
#include "sh.h"
#include "ksh_stat.h"
/*
* Contains a routine to search a : separated list of
- * paths (a la CDPATH) and make appropiate file names.
+ * paths (a la CDPATH) and make appropriate file names.
* Also contains a routine to simplify .'s and ..'s out of
* a path name.
*
* Larry Bouzane (larry@cs.mun.ca)
*/
-/*
- * $Log: path.c,v $
- * Revision 1.1.1.1 2008/05/23 17:15:20 tnn
- * Import subset of pdksh-5.2.14 distribution.
- * Only the files required to build it, for pkgsrc bootstrap purposes.
- *
- * Revision 1.2 1994/05/19 18:32:40 michael
- * Merge complete, stdio replaced, various fixes. (pre autoconf)
- *
- * Revision 1.1 1994/04/06 13:14:03 michael
- * Initial revision
- *
- * Revision 4.2 1990/12/06 18:05:24 larry
- * Updated test code to reflect parameter change.
- * Fixed problem with /a/./.dir being simplified to /a and not /a/.dir due
- * to *(cur+2) == *f test instead of the correct cur+2 == f
- *
- * Revision 4.1 90/10/29 14:42:19 larry
- * base MUN version
- *
- * Revision 3.1.0.4 89/02/16 20:28:36 larry
- * Forgot to set *pathlist to NULL when last changed make_path().
- *
- * Revision 3.1.0.3 89/02/13 20:29:55 larry
- * Fixed up cd so that it knew when a node from CDPATH was used and would
- * print a message only when really necessary.
- *
- * Revision 3.1.0.2 89/02/13 17:51:22 larry
- * Merged with Eric Gisin's version.
- *
- * Revision 3.1.0.1 89/02/13 17:50:58 larry
- * *** empty log message ***
- *
- * Revision 3.1 89/02/13 17:49:28 larry
- * *** empty log message ***
- *
- */
-
#ifdef S_ISLNK
-static char *do_phys_path ARGS((XString *xsp, char *xp, const char *path));
+static char *do_phys_path ARGS((XString *, char *, const char *));
#endif /* S_ISLNK */
/*
@@ -65,7 +35,7 @@ static char *do_phys_path ARGS((XString *xsp, char *xp, const char *path));
* - cdpathp is set to the start of the next element in cdpathp (or NULL
* if there are no more elements.
* The return value indicates whether a non-null element from cdpathp
- * was appened to result.
+ * was appended to result.
*/
int
make_path(cwd, file, cdpathp, xsp, phys_pathp)
@@ -146,22 +116,22 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
* ie, simplify_path("/a/b/c/./../d/..") returns "/a/b"
*/
void
-simplify_path(path)
- char *path;
+simplify_path(pathx)
+ char *pathx;
{
char *cur;
char *t;
int isrooted;
- char *very_start = path;
+ char *very_start = pathx;
char *start;
- if (!*path)
+ if (!*pathx)
return;
- if ((isrooted = ISROOTEDPATH(path)))
+ if ((isrooted = ISROOTEDPATH(pathx)))
very_start++;
#if defined (OS2) || defined (__CYGWIN__)
- if (path[0] && path[1] == ':') /* skip a: */
+ if (pathx[0] && pathx[1] == ':') /* skip a: */
very_start += 2;
#endif /* OS2 || __CYGWIN__ */
@@ -182,7 +152,7 @@ simplify_path(path)
#ifdef __CYGWIN__
/* preserve leading double-slash on pathnames (for UNC paths) */
- if (path[0] && ISDIRSEP(path[0]) && path[1] && ISDIRSEP(path[1]))
+ if (pathx[0] && ISDIRSEP(pathx[0]) && pathx[1] && ISDIRSEP(pathx[1]))
very_start++;
#endif /* __CYGWIN__ */
@@ -192,7 +162,7 @@ simplify_path(path)
t++;
if (*t == '\0') {
- if (cur == path)
+ if (cur == pathx)
/* convert empty path to dot */
*cur++ = '.';
*cur = '\0';
@@ -229,11 +199,11 @@ simplify_path(path)
void
-set_current_wd(path)
- char *path;
+set_current_wd(pathx)
+ char *pathx;
{
int len;
- char *p = path;
+ char *p = pathx;
if (!p && !(p = ksh_get_wd((char *) 0, 0)))
p = null;
@@ -243,21 +213,21 @@ set_current_wd(path)
if (len > current_wd_size)
current_wd = aresize(current_wd, current_wd_size = len, APERM);
memcpy(current_wd, p, len);
- if (p != path && p != null)
+ if (p != pathx && p != null)
afree(p, ATEMP);
}
#ifdef S_ISLNK
char *
-get_phys_path(path)
- const char *path;
+get_phys_path(pathx)
+ const char *pathx;
{
XString xs;
char *xp;
- Xinit(xs, xp, strlen(path) + 1, ATEMP);
+ Xinit(xs, xp, strlen(pathx) + 1, ATEMP);
- xp = do_phys_path(&xs, xp, path);
+ xp = do_phys_path(&xs, xp, pathx);
if (!xp)
return (char *) 0;
@@ -270,10 +240,10 @@ get_phys_path(path)
}
static char *
-do_phys_path(xsp, xp, path)
+do_phys_path(xsp, xp, pathx)
XString *xsp;
char *xp;
- const char *path;
+ const char *pathx;
{
const char *p, *q;
int len, llen;
@@ -281,7 +251,7 @@ do_phys_path(xsp, xp, path)
char lbuf[PATH];
Xcheck(*xsp, xp);
- for (p = path; p; p = q) {
+ for (p = pathx; p; p = q) {
while (ISDIRSEP(*p))
p++;
if (!*p)