summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2002-02-08 19:16:31 +0000
committerEli Zaretskii <eliz@gnu.org>2002-02-08 19:16:31 +0000
commitdba493fec3aad076732210bd88ab1b390355b384 (patch)
treef5314eb459652ab64c93f3297a67494017e31070 /src/fileio.c
parentc7c8921f37b8e2daacba60dbf055bec29ae631b0 (diff)
downloademacs-dba493fec3aad076732210bd88ab1b390355b384.tar.gz
(Fsubstitute_in_file_name): If the file name includes ~user,
and there's no such user, don't discard everything before ~user.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 177d44aeae0..7a4362f413a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2025,6 +2025,7 @@ duplicates what `expand-file-name' does. */)
int total = 0;
int substituted = 0;
unsigned char *xnm;
+ struct passwd *pw;
Lisp_Object handler;
CHECK_STRING (filename);
@@ -2063,8 +2064,27 @@ duplicates what `expand-file-name' does. */)
#endif /* VMS */
|| IS_DIRECTORY_SEP (p[-1])))
{
- nm = p;
- substituted = 1;
+ for (s = p; *s && (!IS_DIRECTORY_SEP (*s)
+#ifdef VMS
+ && *s != ':'
+#endif /* VMS */
+ ); s++);
+ if (s > p + 1)
+ {
+ o = (unsigned char *) alloca (s - p + 1);
+ bcopy ((char *) p, o, s - p);
+ o [s - p] = 0;
+
+ pw = (struct passwd *) getpwnam (o + 1);
+ }
+ /* If we have ~/ or ~user and `user' exists, discard
+ everything up to ~. But if `user' does not exist, leave
+ ~user alone, it might be a literal file name. */
+ if (s == p + 1 || pw)
+ {
+ nm = p;
+ substituted = 1;
+ }
}
#ifdef DOS_NT
/* see comment in expand-file-name about drive specifiers */