Changeset 1194 in kBuild for trunk/src/kmk/kmkbuiltin/install.c
- Timestamp:
- Oct 6, 2007 1:59:35 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/install.c
r1193 r1194 115 115 #endif 116 116 117 #if defined(__WIN32__) || defined(__WIN64__) || defined(__OS2__) 118 # define IS_SLASH(ch) ((ch) == '/' || (ch) == '\\') 119 #else 120 # define IS_SLASH(ch) ((ch) == '/') 121 #endif 122 117 123 static gid_t gid; 118 124 static uid_t uid; … … 141 147 #endif 142 148 static int usage(FILE *); 149 static char *last_slash(const char *); 143 150 144 151 int … … 389 396 (void)snprintf(pathbuf, sizeof(pathbuf), "%s/%s", 390 397 to_name, 391 (p = strrchr(from_name, '/')) ? ++p : from_name);398 (p = last_slash(from_name)) ? ++p : from_name); 392 399 to_name = pathbuf; 393 400 } … … 744 751 (void)strncpy(temp, path, tsize); 745 752 temp[tsize - 1] = '\0'; 746 if ((p = strrchr(temp, '/')) != NULL)753 if ((p = last_slash(temp)) != NULL) 747 754 p++; 748 755 else … … 915 922 916 923 for (p = path;; ++p) 917 if (!*p || (p != path && *p == '/')) {924 if (!*p || (p != path && IS_SLASH(*p))) { 918 925 ch = *p; 919 926 *p = '\0'; … … 981 988 } 982 989 #endif 990 991 /* figures out where the last slash or colon is. */ 992 static char * 993 last_slash(const char *path) 994 { 995 #if defined(__WIN32__) || defined(__WIN64__) || defined(__OS2__) 996 char *p = (char *)strrchr(path, '/'); 997 if (p) 998 { 999 char *p2 = strrchr(p, '\\'); 1000 if (p2) 1001 p = p2; 1002 } 1003 else 1004 { 1005 p = (char *)strrchr(path, '\\'); 1006 if (!p && isalpha(path[0]) && path[1] == ':') 1007 p = (char *)&path[1]; 1008 } 1009 return p; 1010 #else 1011 return strrchr(path, '/'); 1012 #endif 1013 } 1014
Note:
See TracChangeset
for help on using the changeset viewer.