Changeset 601 for trunk/src/gmake/kmkbuiltin
- Timestamp:
- Nov 26, 2006, 1:19:19 AM (19 years ago)
- Location:
- trunk/src/gmake/kmkbuiltin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/kmkbuiltin/mkdir.c
r557 r601 58 58 #else 59 59 #include "mscfakes.h" 60 #include <malloc.h> 60 61 #endif 61 62 … … 161 162 char *p; 162 163 164 const size_t len = strlen(path); 165 p = alloca(len + 1); 166 path = memcpy(p, path, len + 1); 167 168 #if defined(_MSC_VER) || defined(__EMX__) 169 p = strchr(path, '\\'); 170 while (p) { 171 *p++ = '/'; 172 p = strchr(p, '\\'); 173 } 174 #endif 175 163 176 p = path; 164 177 oumask = 0; 165 178 retval = 0; 166 179 #if defined(_MSC_VER) || defined(__EMX__) 167 if ( ( (p[0] >= 'A' && p[0] <= 'Z')168 || (p[0] >= 'a' && p[0] <= 'z'))169 && p[1] == ':')170 p += 2;171 else if ( (p[0] == '/' || p[0] == '\\') 172 && (p[1] == '/' || p[1] == '\\') 173 && (p[2] != '/' && p[2] != '\\'))174 {175 char *p2;176 p += 2;177 p2 = strpbrk(p, "\\/");178 if (p2)179 p = p2 + 1;180 }180 if ( ( (p[0] >= 'A' && p[0] <= 'Z') 181 || (p[0] >= 'a' && p[0] <= 'z')) 182 && p[1] == ':') 183 p += 2; 184 else if ( p[0] == '/' 185 && p[1] == '/' 186 && p[2] != '/') 187 { 188 char *p2; 189 p += 2; 190 p2 = strchr(p, '/'); 191 if (p2) 192 p = p2 + 1; 193 } 181 194 #endif 182 195 if (p[0] == '/') /* Skip leading '/'. */ -
trunk/src/gmake/kmkbuiltin/rmdir.c
r598 r601 39 39 #endif /* not lint */ 40 40 #endif 41 #if 0 41 42 #include <sys/cdefs.h> 42 43 __FBSDID("$FreeBSD: src/bin/rmdir/rmdir.c,v 1.20 2005/01/26 06:51:28 ssouhlal Exp $"); 44 #endif 43 45 44 #include <err.h>46 #include "err.h" 45 47 #include <stdio.h> 46 48 #include <stdlib.h> 47 49 #include <string.h> 50 #ifndef _MSC_VER 48 51 #include <unistd.h> 52 #else 53 #include <malloc.h> 54 #include "mscfakes.h" 55 #endif 49 56 50 static int rm_path(c har *);51 static voidusage(void);57 static int rm_path(const char *); 58 static int usage(void); 52 59 53 60 static int pflag; … … 55 62 56 63 int 57 main(int argc, char *argv[])64 kmk_builtin_rmdir(int argc, char *argv[]) 58 65 { 59 66 int ch, errors; 60 67 68 /* reinitialize globals */ 69 vflag = 0; 70 71 /* kmk: reset getopt and set progname */ 72 g_progname = argv[0]; 73 opterr = 1; 74 optarg = NULL; 75 optopt = 0; 76 #if defined(__FreeBSD__) || defined(__EMX__) || defined(__APPLE__) 77 optreset = 1; 78 optind = 1; 79 #else 80 optind = 0; /* init */ 81 #endif 61 82 while ((ch = getopt(argc, argv, "pv")) != -1) 62 83 switch(ch) { … … 69 90 case '?': 70 91 default: 71 usage();92 return usage(); 72 93 } 73 94 argc -= optind; … … 75 96 76 97 if (argc == 0) 77 usage();98 return usage(); 78 99 79 100 for (errors = 0; *argv; argv++) { … … 89 110 } 90 111 91 exit(errors);112 return errors; 92 113 } 93 114 … … 96 117 { 97 118 char *p; 119 const size_t len = strlen(path); 120 p = alloca(len + 1); 121 path = memcpy(p, path, len + 1); 98 122 99 p = path + strlen(path); 123 #if defined(_MSC_VER) || defined(__EMX__) 124 p = strchr(path, '\\'); 125 while (p) { 126 *p++ = '/'; 127 p = strchr(p, '\\'); 128 } 129 #endif 130 131 p = path + len; 100 132 while (--p > path && *p == '/') 101 133 ; … … 108 140 if (p == path) 109 141 break; 142 #if defined(_MSC_VER) || defined(__EMX__) 143 if (p[-1] == ':' && p - 2 == path) 144 break; 145 #endif 110 146 111 147 if (rmdir(path) < 0) { … … 120 156 } 121 157 122 static void158 static int 123 159 usage(void) 124 160 { 125 161 126 162 (void)fprintf(stderr, "usage: rmdir [-pv] directory ...\n"); 127 exit(1);163 return 1; 128 164 }
Note:
See TracChangeset
for help on using the changeset viewer.
