* fileio.c (file_name_as_directory, directory_file_name):
(barf_or_query_if_file_exists, auto_save_error, auto_save_1):
Now static.
+ (file_name_as_directory): Use const pointers when appropriate.
+ (Fexpand_file_name): Likewise. In particular, newdir might
+ point at constant storage, so make it a const pointer.
* minibuf.c (choose_minibuf_frame_1): Now static.
(Ftry_completion, Fall_completions): Rename or remove locals
\f
static char *
-file_name_as_directory (char *out, char *in)
+file_name_as_directory (char *out, const char *in)
{
int size = strlen (in) - 1;
{
/* These point to SDATA and need to be careful with string-relocation
during GC (via DECODE_FILE). */
- char *nm, *newdir;
+ char *nm;
+ const char *newdir;
/* This should only point to alloca'd data. */
char *target;
if (!newdir && drive)
{
/* Get default directory if needed to make nm absolute. */
+ char *adir = NULL;
if (!IS_DIRECTORY_SEP (nm[0]))
{
- newdir = alloca (MAXPATHLEN + 1);
- if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
- newdir = NULL;
+ adir = alloca (MAXPATHLEN + 1);
+ if (!getdefdir (toupper (drive) - 'A' + 1, adir))
+ adir = NULL;
}
- if (!newdir)
+ if (!adir)
{
/* Either nm starts with /, or drive isn't mounted. */
- newdir = alloca (4);
- newdir[0] = DRIVE_LETTER (drive);
- newdir[1] = ':';
- newdir[2] = '/';
- newdir[3] = 0;
+ adir = alloca (4);
+ adir[0] = DRIVE_LETTER (drive);
+ adir[1] = ':';
+ adir[2] = '/';
+ adir[3] = 0;
}
+ newdir = adir;
}
#endif /* DOS_NT */
when we have pointers into lisp strings, we accomplish this
indirectly by prepending newdir to nm if necessary, and using
cwd (or the wd of newdir's drive) as the new newdir. */
-
+ char *adir;
if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
{
drive = (unsigned char) newdir[0];
strcat (tmp, nm);
nm = tmp;
}
- newdir = alloca (MAXPATHLEN + 1);
+ adir = alloca (MAXPATHLEN + 1);
if (drive)
{
- if (!getdefdir (toupper (drive) - 'A' + 1, newdir))
+ if (!getdefdir (toupper (drive) - 'A' + 1, adir))
newdir = "/";
}
else
- getwd (newdir);
+ getwd (adir);
+ newdir = adir;
}
/* Strip off drive name from prefix, if present. */
#ifdef WINDOWSNT
if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
{
- char *p;
- newdir = strcpy (alloca (strlen (newdir) + 1), newdir);
- p = newdir + 2;
+ char *adir = strcpy (alloca (strlen (newdir) + 1), newdir);
+ char *p = adir + 2;
while (*p && !IS_DIRECTORY_SEP (*p)) p++;
p++;
while (*p && !IS_DIRECTORY_SEP (*p)) p++;
*p = 0;
+ newdir = adir;
}
else
#endif