aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2002-02-08 19:16:31 +0000
committerEli Zaretskii2002-02-08 19:16:31 +0000
commitdba493fec3aad076732210bd88ab1b390355b384 (patch)
treef5314eb459652ab64c93f3297a67494017e31070 /src
parentc7c8921f37b8e2daacba60dbf055bec29ae631b0 (diff)
downloademacs-dba493fec3aad076732210bd88ab1b390355b384.tar.gz
emacs-dba493fec3aad076732210bd88ab1b390355b384.zip
(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')
-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. */)
2025 int total = 0; 2025 int total = 0;
2026 int substituted = 0; 2026 int substituted = 0;
2027 unsigned char *xnm; 2027 unsigned char *xnm;
2028 struct passwd *pw;
2028 Lisp_Object handler; 2029 Lisp_Object handler;
2029 2030
2030 CHECK_STRING (filename); 2031 CHECK_STRING (filename);
@@ -2063,8 +2064,27 @@ duplicates what `expand-file-name' does. */)
2063#endif /* VMS */ 2064#endif /* VMS */
2064 || IS_DIRECTORY_SEP (p[-1]))) 2065 || IS_DIRECTORY_SEP (p[-1])))
2065 { 2066 {
2066 nm = p; 2067 for (s = p; *s && (!IS_DIRECTORY_SEP (*s)
2067 substituted = 1; 2068#ifdef VMS
2069 && *s != ':'
2070#endif /* VMS */
2071 ); s++);
2072 if (s > p + 1)
2073 {
2074 o = (unsigned char *) alloca (s - p + 1);
2075 bcopy ((char *) p, o, s - p);
2076 o [s - p] = 0;
2077
2078 pw = (struct passwd *) getpwnam (o + 1);
2079 }
2080 /* If we have ~/ or ~user and `user' exists, discard
2081 everything up to ~. But if `user' does not exist, leave
2082 ~user alone, it might be a literal file name. */
2083 if (s == p + 1 || pw)
2084 {
2085 nm = p;
2086 substituted = 1;
2087 }
2068 } 2088 }
2069#ifdef DOS_NT 2089#ifdef DOS_NT
2070 /* see comment in expand-file-name about drive specifiers */ 2090 /* see comment in expand-file-name about drive specifiers */