Mercurial > hg > xemacs-beta
comparison src/fileio.c @ 664:6e99cc8c6ca5
[xemacs-hg @ 2001-09-18 05:04:26 by ben]
fileio.c: Fix various C++ compile errors in Andy's recent code.
callint.c, editfns.c, emacs.c, lread.c, redisplay-x.c: Fix sign-compare warnings.
scrollbar-msw.c: Fix crash under MS Windows. See comment around line 223 for
explanation.
font-lock.el: fix problem when you insert a comment on the line before a line of
code: if we use the following char, then when you hit backspace,
the following line of code turns the comment color.
configure.in: Don't use -Wshadow when compiling with g++ or you get buried in
silly warnings. This patch was already applied but somehow got
unapplied. Stephen?
author | ben |
---|---|
date | Tue, 18 Sep 2001 05:06:57 +0000 |
parents | ce0b3f2eff35 |
children | fdefd0186b75 |
comparison
equal
deleted
inserted
replaced
663:ebdebdbf3f84 | 664:6e99cc8c6ca5 |
---|---|
66 #ifndef CORRECT_DIR_SEPS | 66 #ifndef CORRECT_DIR_SEPS |
67 #define CORRECT_DIR_SEPS(s) \ | 67 #define CORRECT_DIR_SEPS(s) \ |
68 normalize_filename(s, DIRECTORY_SEP) | 68 normalize_filename(s, DIRECTORY_SEP) |
69 /* Default implementation that coerces a file to use path_sep. */ | 69 /* Default implementation that coerces a file to use path_sep. */ |
70 static void | 70 static void |
71 normalize_filename (char *fp, char path_sep) | 71 normalize_filename (Bufbyte *fp, Bufbyte path_sep) |
72 { | 72 { |
73 /* Always lower-case drive letters a-z, even if the filesystem | 73 /* Always lower-case drive letters a-z, even if the filesystem |
74 preserves case in filenames. | 74 preserves case in filenames. |
75 This is so filenames can be compared by string comparison | 75 This is so filenames can be compared by string comparison |
76 functions that are case-sensitive. Even case-preserving filesystems | 76 functions that are case-sensitive. Even case-preserving filesystems |
796 nm = XSTRING_DATA (name); | 796 nm = XSTRING_DATA (name); |
797 | 797 |
798 #ifdef WIN32_FILENAMES | 798 #ifdef WIN32_FILENAMES |
799 /* We will force directory separators to be either all \ or /, so make | 799 /* We will force directory separators to be either all \ or /, so make |
800 a local copy to modify, even if there ends up being no change. */ | 800 a local copy to modify, even if there ends up being no change. */ |
801 nm = strcpy ((char *)alloca (strlen ((char *)nm) + 1), (char *)nm); | 801 nm = (Bufbyte *) strcpy ((char *) alloca (strlen ((char *) nm) + 1), |
802 (char *) nm); | |
802 | 803 |
803 /* Find and remove drive specifier if present; this makes nm absolute | 804 /* Find and remove drive specifier if present; this makes nm absolute |
804 even if the rest of the name appears to be relative. */ | 805 even if the rest of the name appears to be relative. */ |
805 { | 806 { |
806 Bufbyte *colon = (Bufbyte *) strrchr ((char *)nm, ':'); | 807 Bufbyte *colon = (Bufbyte *) strrchr ((char *)nm, ':'); |
880 desired, but avoid allocation of a new string when not | 881 desired, but avoid allocation of a new string when not |
881 required. */ | 882 required. */ |
882 CORRECT_DIR_SEPS (nm); | 883 CORRECT_DIR_SEPS (nm); |
883 if (IS_DIRECTORY_SEP (nm[1])) | 884 if (IS_DIRECTORY_SEP (nm[1])) |
884 { | 885 { |
885 if (strcmp (nm, XSTRING_DATA (name)) != 0) | 886 if (strcmp ((char *) nm, (char *) XSTRING_DATA (name)) != 0) |
886 name = build_string (nm); | 887 name = build_string ((CBufbyte *) nm); |
887 } | 888 } |
888 /* drive must be set, so this is okay */ | 889 /* drive must be set, so this is okay */ |
889 else if (strcmp (nm - 2, XSTRING_DATA (name)) != 0) | 890 else if (strcmp ((char *) nm - 2, |
891 (char *) XSTRING_DATA (name)) != 0) | |
890 { | 892 { |
891 name = make_string (nm - 2, p - nm + 2); | 893 name = make_string (nm - 2, p - nm + 2); |
892 XSTRING_DATA (name)[0] = DRIVE_LETTER (drive); | 894 XSTRING_DATA (name)[0] = DRIVE_LETTER (drive); |
893 XSTRING_DATA (name)[1] = ':'; | 895 XSTRING_DATA (name)[1] = ':'; |
894 } | 896 } |
993 { | 995 { |
994 #ifdef WIN32_NATIVE | 996 #ifdef WIN32_NATIVE |
995 /* Get default directory if needed to make nm absolute. */ | 997 /* Get default directory if needed to make nm absolute. */ |
996 if (!IS_DIRECTORY_SEP (nm[0])) | 998 if (!IS_DIRECTORY_SEP (nm[0])) |
997 { | 999 { |
998 newdir = alloca (MAXPATHLEN + 1); | 1000 newdir = (Bufbyte *) alloca (MAXPATHLEN + 1); |
999 if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN)) | 1001 if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN)) |
1000 newdir = NULL; | 1002 newdir = NULL; |
1001 } | 1003 } |
1002 #endif /* WIN32_NATIVE */ | 1004 #endif /* WIN32_NATIVE */ |
1003 if (!newdir) | 1005 if (!newdir) |
1004 { | 1006 { |
1005 /* Either nm starts with /, or drive isn't mounted. */ | 1007 /* Either nm starts with /, or drive isn't mounted. */ |
1006 newdir = alloca (4); | 1008 newdir = (Bufbyte *) alloca (4); |
1007 newdir[0] = DRIVE_LETTER (drive); | 1009 newdir[0] = DRIVE_LETTER (drive); |
1008 newdir[1] = ':'; | 1010 newdir[1] = ':'; |
1009 newdir[2] = '/'; | 1011 newdir[2] = '/'; |
1010 newdir[3] = 0; | 1012 newdir[3] = 0; |
1011 } | 1013 } |
1057 drive = newdir[0]; | 1059 drive = newdir[0]; |
1058 newdir += 2; | 1060 newdir += 2; |
1059 } | 1061 } |
1060 if (!IS_DIRECTORY_SEP (nm[0])) | 1062 if (!IS_DIRECTORY_SEP (nm[0])) |
1061 { | 1063 { |
1062 char * tmp = alloca (strlen (newdir) + strlen (nm) + 2); | 1064 Bufbyte *tmp = (Bufbyte *) alloca (strlen ((char *) newdir) + |
1063 file_name_as_directory (tmp, newdir); | 1065 strlen ((char *) nm) + 2); |
1064 strcat (tmp, nm); | 1066 file_name_as_directory ((char *) tmp, (char *) newdir); |
1067 strcat ((char *) tmp, (char *) nm); | |
1065 nm = tmp; | 1068 nm = tmp; |
1066 } | 1069 } |
1067 newdir = alloca (MAXPATHLEN + 1); | 1070 newdir = (Bufbyte *) alloca (MAXPATHLEN + 1); |
1068 if (drive) | 1071 if (drive) |
1069 { | 1072 { |
1070 #ifdef WIN32_NATIVE | 1073 #ifdef WIN32_NATIVE |
1071 if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN)) | 1074 if (!_getdcwd (toupper (drive) - 'A' + 1, newdir, MAXPATHLEN)) |
1072 #endif | 1075 #endif |
1073 newdir = "/"; | 1076 newdir = (Bufbyte *) "/"; |
1074 } | 1077 } |
1075 else | 1078 else |
1076 getwd (newdir); | 1079 getcwd ((char *) newdir, MAXPATHLEN); |
1077 } | 1080 } |
1078 | 1081 |
1079 /* Strip off drive name from prefix, if present. */ | 1082 /* Strip off drive name from prefix, if present. */ |
1080 if (IS_DRIVE (newdir[0]) && newdir[1] == ':') | 1083 if (IS_DRIVE (newdir[0]) && newdir[1] == ':') |
1081 { | 1084 { |
1091 #endif | 1094 #endif |
1092 && collapse_newdir) | 1095 && collapse_newdir) |
1093 { | 1096 { |
1094 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) | 1097 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) |
1095 { | 1098 { |
1096 newdir = strcpy (alloca (strlen (newdir) + 1), newdir); | 1099 newdir = |
1100 (Bufbyte *) | |
1101 strcpy ((char *) alloca (strlen ((char *) newdir) + 1), | |
1102 (char *) newdir); | |
1097 p = newdir + 2; | 1103 p = newdir + 2; |
1098 while (*p && !IS_DIRECTORY_SEP (*p)) p++; | 1104 while (*p && !IS_DIRECTORY_SEP (*p)) p++; |
1099 p++; | 1105 p++; |
1100 while (*p && !IS_DIRECTORY_SEP (*p)) p++; | 1106 while (*p && !IS_DIRECTORY_SEP (*p)) p++; |
1101 *p = 0; | 1107 *p = 0; |
1102 } | 1108 } |
1103 else | 1109 else |
1104 newdir = ""; | 1110 newdir = (Bufbyte *) ""; |
1105 } | 1111 } |
1106 } | 1112 } |
1107 #endif /* WIN32_FILENAMES */ | 1113 #endif /* WIN32_FILENAMES */ |
1108 | 1114 |
1109 if (newdir) | 1115 if (newdir) |