summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/expand_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cvs/src/expand_path.c')
-rw-r--r--contrib/cvs/src/expand_path.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/contrib/cvs/src/expand_path.c b/contrib/cvs/src/expand_path.c
index f46b39b..5aa1063 100644
--- a/contrib/cvs/src/expand_path.c
+++ b/contrib/cvs/src/expand_path.c
@@ -15,9 +15,11 @@
#include "cvs.h"
#include <sys/types.h>
-static char *expand_variable PROTO((char *env, char *file, int line));
+static char *expand_variable PROTO((const char *env, const char *file,
+ int line));
+
+
-
/* User variables. */
List *variable_list = NULL;
@@ -79,7 +81,9 @@ variable_set (nameval)
free (name);
}
}
-
+
+
+
/* This routine will expand the pathname to account for ~ and $
characters as described above. Returns a pointer to a newly
malloc'd string. If an error occurs, an error message is printed
@@ -89,11 +93,11 @@ variable_set (nameval)
known. */
char *
expand_path (name, file, line)
- char *name;
- char *file;
+ const char *name;
+ const char *file;
int line;
{
- char *s;
+ const char *s;
char *d;
char *mybuf = NULL;
@@ -179,8 +183,9 @@ expand_path (name, file, line)
if (*s++ == '~')
{
char *t;
- char *p=s;
- if (*s=='/' || *s==0)
+ char *p, *pstart;
+ pstart = p = xstrdup (s);
+ if (*pstart=='/' || *pstart==0)
t = get_homedir ();
else
{
@@ -201,14 +206,14 @@ expand_path (name, file, line)
for (; *p!='/' && *p; p++)
;
*p = 0;
- ps = getpwnam (s);
+ ps = getpwnam (pstart);
if (ps == 0)
{
if (line != 0)
error (0, 0, "%s:%d: no such user %s",
- file, line, s);
+ file, line, pstart);
else
- error (0, 0, "%s: no such user %s", file, s);
+ error (0, 0, "%s: no such user %s", file, pstart);
return NULL;
}
t = ps->pw_dir;
@@ -227,9 +232,8 @@ expand_path (name, file, line)
d = buf + doff;
}
--d;
- if (*p == 0)
- *p = '/'; /* always add / */
- s=p;
+ s+=p-pstart;
+ free (pstart);
}
else
--s;
@@ -267,12 +271,12 @@ expand_path (name, file, line)
static char *
expand_variable (name, file, line)
- char *name;
- char *file;
+ const char *name;
+ const char *file;
int line;
{
if (strcmp (name, CVSROOT_ENV) == 0)
- return current_parsed_root->original;
+ return current_parsed_root->directory;
else if (strcmp (name, "RCSBIN") == 0)
{
error (0, 0, "RCSBIN internal variable is no longer supported");
OpenPOWER on IntegriCloud