aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-03-14 19:46:32 -0700
committerPaul Eggert2011-03-14 19:46:32 -0700
commit2893f1463d31f84556a78b1a714f2427064caf78 (patch)
treecbaa728007b6a8a9f2842252f6f69c159ed83013 /src
parentf14b7e14bb9284b6020431789ebc4c0dac1ef487 (diff)
downloademacs-2893f1463d31f84556a78b1a714f2427064caf78.tar.gz
emacs-2893f1463d31f84556a78b1a714f2427064caf78.zip
* fileio.c (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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog3
-rw-r--r--src/fileio.c40
2 files changed, 25 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1a7f0bbf7b0..9393cec02a9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,9 @@
3 * fileio.c (file_name_as_directory, directory_file_name): 3 * fileio.c (file_name_as_directory, directory_file_name):
4 (barf_or_query_if_file_exists, auto_save_error, auto_save_1): 4 (barf_or_query_if_file_exists, auto_save_error, auto_save_1):
5 Now static. 5 Now static.
6 (file_name_as_directory): Use const pointers when appropriate.
7 (Fexpand_file_name): Likewise. In particular, newdir might
8 point at constant storage, so make it a const pointer.
6 9
7 * minibuf.c (choose_minibuf_frame_1): Now static. 10 * minibuf.c (choose_minibuf_frame_1): Now static.
8 (Ftry_completion, Fall_completions): Rename or remove locals 11 (Ftry_completion, Fall_completions): Rename or remove locals
diff --git a/src/fileio.c b/src/fileio.c
index e68fcbc65b5..4b25d08f20d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -434,7 +434,7 @@ get a current directory to run processes in. */)
434 434
435 435
436static char * 436static char *
437file_name_as_directory (char *out, char *in) 437file_name_as_directory (char *out, const char *in)
438{ 438{
439 int size = strlen (in) - 1; 439 int size = strlen (in) - 1;
440 440
@@ -728,7 +728,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
728{ 728{
729 /* These point to SDATA and need to be careful with string-relocation 729 /* These point to SDATA and need to be careful with string-relocation
730 during GC (via DECODE_FILE). */ 730 during GC (via DECODE_FILE). */
731 char *nm, *newdir; 731 char *nm;
732 const char *newdir;
732 /* This should only point to alloca'd data. */ 733 /* This should only point to alloca'd data. */
733 char *target; 734 char *target;
734 735
@@ -1013,21 +1014,23 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1013 if (!newdir && drive) 1014 if (!newdir && drive)
1014 { 1015 {
1015 /* Get default directory if needed to make nm absolute. */ 1016 /* Get default directory if needed to make nm absolute. */
1017 char *adir = NULL;
1016 if (!IS_DIRECTORY_SEP (nm[0])) 1018 if (!IS_DIRECTORY_SEP (nm[0]))
1017 { 1019 {
1018 newdir = alloca (MAXPATHLEN + 1); 1020 adir = alloca (MAXPATHLEN + 1);
1019 if (!getdefdir (toupper (drive) - 'A' + 1, newdir)) 1021 if (!getdefdir (toupper (drive) - 'A' + 1, adir))
1020 newdir = NULL; 1022 adir = NULL;
1021 } 1023 }
1022 if (!newdir) 1024 if (!adir)
1023 { 1025 {
1024 /* Either nm starts with /, or drive isn't mounted. */ 1026 /* Either nm starts with /, or drive isn't mounted. */
1025 newdir = alloca (4); 1027 adir = alloca (4);
1026 newdir[0] = DRIVE_LETTER (drive); 1028 adir[0] = DRIVE_LETTER (drive);
1027 newdir[1] = ':'; 1029 adir[1] = ':';
1028 newdir[2] = '/'; 1030 adir[2] = '/';
1029 newdir[3] = 0; 1031 adir[3] = 0;
1030 } 1032 }
1033 newdir = adir;
1031 } 1034 }
1032#endif /* DOS_NT */ 1035#endif /* DOS_NT */
1033 1036
@@ -1074,7 +1077,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1074 when we have pointers into lisp strings, we accomplish this 1077 when we have pointers into lisp strings, we accomplish this
1075 indirectly by prepending newdir to nm if necessary, and using 1078 indirectly by prepending newdir to nm if necessary, and using
1076 cwd (or the wd of newdir's drive) as the new newdir. */ 1079 cwd (or the wd of newdir's drive) as the new newdir. */
1077 1080 char *adir;
1078 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) 1081 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
1079 { 1082 {
1080 drive = (unsigned char) newdir[0]; 1083 drive = (unsigned char) newdir[0];
@@ -1087,14 +1090,15 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1087 strcat (tmp, nm); 1090 strcat (tmp, nm);
1088 nm = tmp; 1091 nm = tmp;
1089 } 1092 }
1090 newdir = alloca (MAXPATHLEN + 1); 1093 adir = alloca (MAXPATHLEN + 1);
1091 if (drive) 1094 if (drive)
1092 { 1095 {
1093 if (!getdefdir (toupper (drive) - 'A' + 1, newdir)) 1096 if (!getdefdir (toupper (drive) - 'A' + 1, adir))
1094 newdir = "/"; 1097 newdir = "/";
1095 } 1098 }
1096 else 1099 else
1097 getwd (newdir); 1100 getwd (adir);
1101 newdir = adir;
1098 } 1102 }
1099 1103
1100 /* Strip off drive name from prefix, if present. */ 1104 /* Strip off drive name from prefix, if present. */
@@ -1111,13 +1115,13 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1111#ifdef WINDOWSNT 1115#ifdef WINDOWSNT
1112 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) 1116 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
1113 { 1117 {
1114 char *p; 1118 char *adir = strcpy (alloca (strlen (newdir) + 1), newdir);
1115 newdir = strcpy (alloca (strlen (newdir) + 1), newdir); 1119 char *p = adir + 2;
1116 p = newdir + 2;
1117 while (*p && !IS_DIRECTORY_SEP (*p)) p++; 1120 while (*p && !IS_DIRECTORY_SEP (*p)) p++;
1118 p++; 1121 p++;
1119 while (*p && !IS_DIRECTORY_SEP (*p)) p++; 1122 while (*p && !IS_DIRECTORY_SEP (*p)) p++;
1120 *p = 0; 1123 *p = 0;
1124 newdir = adir;
1121 } 1125 }
1122 else 1126 else
1123#endif 1127#endif