儲存庫 kBuild 的更動 1705
- 時間撮記:
- 2008-9-2 上午03:17:42 (16 年 以前)
- 位置:
- trunk/src/kmk
- 檔案:
-
- 修改 5 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/kmk/Makefile.am
r1701 r1705 55 55 kmkbuiltin/append.c \ 56 56 kmkbuiltin/cat.c \ 57 kmkbuiltin/chmod.c \ 57 58 kmkbuiltin/cmp.c \ 58 59 kmkbuiltin/cmp_util.c \ -
trunk/src/kmk/Makefile.kmk
r1701 r1705 207 207 kmkbuiltin/append.c \ 208 208 kmkbuiltin/cat.c \ 209 kmkbuiltin/chmod.c \ 209 210 kmkbuiltin/cmp.c \ 210 211 kmkbuiltin/cmp_util.c \ … … 237 238 kmk_append \ 238 239 kmk_cat \ 240 kmk_chmod \ 239 241 kmk_cp \ 240 242 kmk_cmp \ … … 262 264 kmk_cat_SOURCES = \ 263 265 kmkbuiltin/cat.c 266 267 kmk_chmod_TEMPLATE = BIN-KMK 268 kmk_chmod_DEFS = kmk_builtin_chmod=main 269 kmk_chmod_SOURCES = \ 270 kmkbuiltin/chmod.c 264 271 265 272 kmk_cmp_TEMPLATE = BIN-KMK -
trunk/src/kmk/kmkbuiltin.c
r1293 r1705 208 208 rc = kmk_builtin_test(argc, argv, environ, ppapszArgvToSpawn); 209 209 /* rarely used commands: */ 210 else if (!strcmp(pszCmd, "chmod")) 211 rc = kmk_builtin_chmod(argc, argv, environ); 210 212 else if (!strcmp(pszCmd, "cp")) 211 213 rc = kmk_builtin_cp(argc, argv, environ); -
trunk/src/kmk/kmkbuiltin.h
r1292 r1705 39 39 extern int kmk_builtin_cp(int argc, char **argv, char **envp); 40 40 extern int kmk_builtin_cat(int argc, char **argv, char **envp); 41 extern int kmk_builtin_chmod(int argc, char **argv, char **envp); 41 42 extern int kmk_builtin_cmp(int argc, char **argv, char **envp); 42 43 extern int kmk_builtin_echo(int argc, char **argv, char **envp); -
trunk/src/kmk/kmkbuiltin/chmod.c
r1704 r1705 39 39 #endif /* not lint */ 40 40 #endif 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/bin/chmod/chmod.c,v 1.33 2005/01/10 08:39:20 imp Exp $"); 41 /*#include <sys/cdefs.h> */ 42 /*__FBSDID("$FreeBSD: src/bin/chmod/chmod.c,v 1.33 2005/01/10 08:39:20 imp Exp $");*/ 43 43 44 44 #include <sys/types.h> 45 45 #include <sys/stat.h> 46 46 47 #include <err.h>47 #include "err.h" 48 48 #include <errno.h> 49 49 #include <fts.h> … … 52 52 #include <stdlib.h> 53 53 #include <string.h> 54 #include <unistd.h> 55 56 void usage(void); 54 #ifndef _MSC_VER 55 # include <unistd.h> 56 #else 57 # include "mscfakes.h" 58 #endif 59 #include "getopt.h" 60 #include "kmkbuiltin.h" 61 62 #if defined(__APPLE__) && !defined(_DARWIN_FEATURE_UNIX_CONFORMANCE) 63 extern int lchmod(const char *, mode_t); 64 #endif 65 66 static int usage(FILE *); 67 68 static struct option long_options[] = 69 { 70 { "help", no_argument, 0, 261 }, 71 { "version", no_argument, 0, 262 }, 72 { 0, 0, 0, 0 }, 73 }; 74 57 75 58 76 int 59 main(int argc, char *argv[])77 kmk_builtin_chmod(int argc, char *argv[], char **envp) 60 78 { 61 79 FTS *ftsp; … … 68 86 int (*change_mode)(const char *, mode_t); 69 87 88 /* kmk: reset getopt and set progname */ 89 g_progname = argv[0]; 90 opterr = 1; 91 optarg = NULL; 92 optopt = 0; 93 optind = 0; /* init */ 94 70 95 set = NULL; 71 96 Hflag = Lflag = Rflag = fflag = hflag = vflag = 0; 72 while ((ch = getopt (argc, argv, "HLPRXfghorstuvwx")) != -1)97 while ((ch = getopt_long(argc, argv, "HLPRXfghorstuvwx", long_options, NULL)) != -1) 73 98 switch (ch) { 74 99 case 'H': … … 116 141 vflag++; 117 142 break; 143 case 261: 144 usage(stdout); 145 return 0; 146 case 262: 147 return kbuild_version(argv[0]); 118 148 case '?': 119 149 default: 120 usage();150 return usage(stderr); 121 151 } 122 152 done: argv += optind; … … 124 154 125 155 if (argc < 2) 126 usage();156 return usage(stderr); 127 157 128 158 if (Rflag) { 129 159 fts_options = FTS_PHYSICAL; 130 160 if (hflag) 131 errx(1,161 return errx(1, 132 162 "the -R and -h options may not be specified together."); 133 163 if (Hflag) … … 147 177 mode = *argv; 148 178 if ((set = setmode(mode)) == NULL) 149 errx(1, "invalid file mode: %s", mode);179 return errx(1, "invalid file mode: %s", mode); 150 180 151 181 if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL) 152 err(1, "fts_open");182 return err(1, "fts_open"); 153 183 for (rval = 0; (p = fts_read(ftsp)) != NULL;) { 154 184 switch (p->fts_info) { … … 208 238 } 209 239 if (errno) 210 err(1, "fts_read");240 rval = err(1, "fts_read"); 211 241 free(set); 212 exit(rval); 242 fts_close(ftsp); 243 return rval; 213 244 } 214 245 215 void 216 usage( void)246 int 247 usage(FILE *out) 217 248 { 218 (void)fprintf(stderr, 219 "usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...\n"); 220 exit(1); 249 (void)fprintf(out, 250 "usage: %s [-fhv] [-R [-H | -L | -P]] mode file ...\n" 251 " or: %s --version\n" 252 " or: %s --help\n", 253 g_progname, g_progname, g_progname); 254 255 return 1; 221 256 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器