Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/findutils/xargs.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/findutils/xargs.c
r821 r1770 18 18 */ 19 19 20 #include "busybox.h" 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include <string.h> 24 #include <unistd.h> 25 #include <getopt.h> 26 #include <errno.h> 27 #include <fcntl.h> 28 #include <sys/types.h> 29 #include <sys/wait.h> 20 #include "libbb.h" 21 22 /* This is a NOEXEC applet. Be very careful! */ 23 30 24 31 25 /* COMPAT: SYSV version defaults size (and has a max value of) to 470. … … 40 34 41 35 #ifdef TEST 42 # ifndef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION43 # define CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION36 # ifndef ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 37 # define ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 1 44 38 # endif 45 # ifndef CONFIG_FEATURE_XARGS_SUPPORT_QUOTES46 # define CONFIG_FEATURE_XARGS_SUPPORT_QUOTES39 # ifndef ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 40 # define ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 1 47 41 # endif 48 # ifndef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT49 # define CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT42 # ifndef ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 43 # define ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 1 50 44 # endif 51 # ifndef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM52 # define CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM45 # ifndef ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 46 # define ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 1 53 47 # endif 54 48 #endif 55 49 56 50 /* 57 This function ha vespecial algorithm.58 Don `t use fork and include to main!51 This function has special algorithm. 52 Don't use fork and include to main! 59 53 */ 60 static int xargs_exec(char *const *args) 61 { 62 pid_t p; 63 volatile int exec_errno = 0; /* shared vfork stack */ 64 65 if ((p = vfork()) >= 0) { 66 if (p == 0) { 67 /* vfork -- child */ 68 execvp(args[0], args); 69 exec_errno = errno; /* set error to shared stack */ 70 _exit(1); 71 } else { 72 /* vfork -- parent */ 73 int status; 74 75 while (wait(&status) == (pid_t) - 1) 76 if (errno != EINTR) 77 break; 78 if (exec_errno) { 79 errno = exec_errno; 80 bb_perror_msg("%s", args[0]); 81 return exec_errno == ENOENT ? 127 : 126; 82 } else { 83 if (WEXITSTATUS(status) == 255) { 84 bb_error_msg("%s: exited with status 255; aborting", args[0]); 85 return 124; 86 } 87 if (WIFSTOPPED(status)) { 88 bb_error_msg("%s: stopped by signal %d", 89 args[0], WSTOPSIG(status)); 90 return 125; 91 } 92 if (WIFSIGNALED(status)) { 93 bb_error_msg("%s: terminated by signal %d", 94 args[0], WTERMSIG(status)); 95 return 125; 96 } 97 if (WEXITSTATUS(status) != 0) 98 return 123; 99 return 0; 100 } 101 } 102 } else { 103 bb_perror_msg_and_die("vfork"); 104 } 105 } 106 107 108 typedef struct xlist_s { 109 char *data; 110 size_t lenght; 111 struct xlist_s *link; 54 static int xargs_exec(char **args) 55 { 56 int status; 57 58 status = spawn_and_wait(args); 59 if (status < 0) { 60 bb_perror_msg("%s", args[0]); 61 return errno == ENOENT ? 127 : 126; 62 } 63 if (status == 255) { 64 bb_error_msg("%s: exited with status 255; aborting", args[0]); 65 return 124; 66 } 67 /* Huh? I think we won't see this, ever. We don't wait with WUNTRACED! 68 if (WIFSTOPPED(status)) { 69 bb_error_msg("%s: stopped by signal %d", 70 args[0], WSTOPSIG(status)); 71 return 125; 72 } 73 */ 74 if (status >= 1000) { 75 bb_error_msg("%s: terminated by signal %d", 76 args[0], status - 1000); 77 return 125; 78 } 79 if (status) 80 return 123; 81 return 0; 82 } 83 84 85 typedef struct xlist_t { 86 struct xlist_t *link; 87 size_t length; 88 char xstr[1]; 112 89 } xlist_t; 113 90 114 static int eof_stdin_detected;91 static smallint eof_stdin_detected; 115 92 116 93 #define ISBLANK(c) ((c) == ' ' || (c) == '\t') 117 #define ISSPACE(c) (ISBLANK 94 #define ISSPACE(c) (ISBLANK(c) || (c) == '\n' || (c) == '\r' \ 118 95 || (c) == '\f' || (c) == '\v') 119 96 120 #if def CONFIG_FEATURE_XARGS_SUPPORT_QUOTES121 static xlist_t *process_stdin(xlist_t * 97 #if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 98 static xlist_t *process_stdin(xlist_t *list_arg, 122 99 const char *eof_str, size_t mc, char *buf) 123 100 { … … 129 106 char *s = NULL; /* start word */ 130 107 char *p = NULL; /* pointer to end word */ 131 char q = 0;/* quote char */108 char q = '\0'; /* quote char */ 132 109 char state = NORM; 133 110 char eof_str_detected = 0; … … 137 114 xlist_t *prev; 138 115 139 for (prev = cur = list_arg; cur; cur = cur->link) { 140 line_l += cur->lenght; /* previous allocated */ 141 if (prev != cur) 142 prev = prev->link; 116 prev = cur = list_arg; 117 while (1) { 118 if (!cur) break; 119 prev = cur; 120 line_l += cur->length; 121 cur = cur->link; 143 122 } 144 123 … … 146 125 c = getchar(); 147 126 if (c == EOF) { 148 eof_stdin_detected ++;127 eof_stdin_detected = 1; 149 128 if (s) 150 129 goto unexpected_eof; … … 157 136 goto set; 158 137 } else if (state == QUOTE) { 159 if (c == q) { 160 q = 0; 161 state = NORM; 162 } else { 138 if (c != q) 163 139 goto set; 164 }165 } else { /* if(state == NORM) */166 140 q = '\0'; 141 state = NORM; 142 } else { /* if (state == NORM) */ 167 143 if (ISSPACE(c)) { 168 144 if (s) { 169 unexpected_eof:145 unexpected_eof: 170 146 state = SPACE; 171 c = 0;147 c = '\0'; 172 148 goto set; 173 149 } … … 181 157 state = QUOTE; 182 158 } else { 183 set:159 set: 184 160 if ((size_t)(p - buf) >= mc) 185 161 bb_error_msg_and_die("argument line too long"); … … 195 171 /* word loaded */ 196 172 if (eof_str) { 197 eof_str_detected = strcmp(s, eof_str) == 0;173 eof_str_detected = (strcmp(s, eof_str) == 0); 198 174 } 199 175 if (!eof_str_detected) { 200 size_t lenght = (p - buf); 201 202 cur = xmalloc(sizeof(xlist_t) + lenght); 203 cur->data = memcpy(cur + 1, s, lenght); 204 cur->lenght = lenght; 176 size_t length = (p - buf); 177 /* Dont xzalloc - it can be quite big */ 178 cur = xmalloc(offsetof(xlist_t, xstr) + length); 205 179 cur->link = NULL; 180 cur->length = length; 181 memcpy(cur->xstr, s, length); 206 182 if (prev == NULL) { 207 183 list_arg = cur; … … 210 186 } 211 187 prev = cur; 212 line_l += leng ht;188 line_l += length; 213 189 if (line_l > mc) { 214 190 /* stop memory usage :-) */ … … 224 200 #else 225 201 /* The variant does not support single quotes, double quotes or backslash */ 226 static xlist_t *process_stdin(xlist_t * 227 const char *eof_str, size_t mc, char *buf)202 static xlist_t *process_stdin(xlist_t *list_arg, 203 const char *eof_str, size_t mc, char *buf) 228 204 { 229 205 230 206 int c; /* current char */ 231 inteof_str_detected = 0;207 char eof_str_detected = 0; 232 208 char *s = NULL; /* start word */ 233 209 char *p = NULL; /* pointer to end word */ … … 236 212 xlist_t *prev; 237 213 238 for (prev = cur = list_arg; cur; cur = cur->link) { 239 line_l += cur->lenght; /* previous allocated */ 240 if (prev != cur) 241 prev = prev->link; 214 prev = cur = list_arg; 215 while (1) { 216 if (!cur) break; 217 prev = cur; 218 line_l += cur->length; 219 cur = cur->link; 242 220 } 243 221 … … 245 223 c = getchar(); 246 224 if (c == EOF) { 247 eof_stdin_detected ++;225 eof_stdin_detected = 1; 248 226 } 249 227 if (eof_str_detected) … … 258 236 if ((p - buf) >= mc) 259 237 bb_error_msg_and_die("argument line too long"); 260 *p++ = c == EOF ? 0 : c;238 *p++ = (c == EOF ? '\0' : c); 261 239 if (c == EOF) { /* word's delimiter or EOF detected */ 262 240 /* word loaded */ 263 241 if (eof_str) { 264 eof_str_detected = strcmp(s, eof_str) == 0;242 eof_str_detected = (strcmp(s, eof_str) == 0); 265 243 } 266 244 if (!eof_str_detected) { 267 size_t lenght = (p - buf); 268 269 cur = xmalloc(sizeof(xlist_t) + lenght); 270 cur->data = memcpy(cur + 1, s, lenght); 271 cur->lenght = lenght; 245 size_t length = (p - buf); 246 /* Dont xzalloc - it can be quite big */ 247 cur = xmalloc(offsetof(xlist_t, xstr) + length); 272 248 cur->link = NULL; 249 cur->length = length; 250 memcpy(cur->xstr, s, length); 273 251 if (prev == NULL) { 274 252 list_arg = cur; … … 277 255 } 278 256 prev = cur; 279 line_l += leng ht;257 line_l += length; 280 258 if (line_l > mc) { 281 259 /* stop memory usage :-) */ … … 288 266 return list_arg; 289 267 } 290 #endif /* CONFIG_FEATURE_XARGS_SUPPORT_QUOTES */291 292 293 #if def CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION268 #endif /* FEATURE_XARGS_SUPPORT_QUOTES */ 269 270 271 #if ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 294 272 /* Prompt the user for a response, and 295 273 if the user responds affirmatively, return true; 296 otherwise, return false. Use d"/dev/tty", not stdin. */274 otherwise, return false. Uses "/dev/tty", not stdin. */ 297 275 static int xargs_ask_confirmation(void) 298 276 { 299 staticFILE *tty_stream;277 FILE *tty_stream; 300 278 int c, savec; 301 279 302 if (!tty_stream) { 303 tty_stream = bb_xfopen(CURRENT_TTY, "r"); 304 /* pranoidal security by vodz */ 305 fcntl(fileno(tty_stream), F_SETFD, FD_CLOEXEC); 306 } 280 tty_stream = xfopen(CURRENT_TTY, "r"); 307 281 fputs(" ?...", stderr); 308 282 fflush(stderr); … … 310 284 while (c != EOF && c != '\n') 311 285 c = getc(tty_stream); 312 if (savec == 'y' || savec == 'Y') 313 return 1; 314 return 0; 315 } 316 317 # define OPT_INC_P 1 286 fclose(tty_stream); 287 return (savec == 'y' || savec == 'Y'); 288 } 318 289 #else 319 # define OPT_INC_P 0320 290 # define xargs_ask_confirmation() 1 321 #endif /* CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION */ 322 323 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT 324 # define OPT_INC_X 1 325 #else 326 # define OPT_INC_X 0 327 #endif 328 329 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 330 static xlist_t *process0_stdin(xlist_t * list_arg, const char *eof_str ATTRIBUTE_UNUSED, 331 size_t mc, char *buf) 291 #endif /* FEATURE_XARGS_SUPPORT_CONFIRMATION */ 292 293 #if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 294 static xlist_t *process0_stdin(xlist_t *list_arg, 295 const char *eof_str ATTRIBUTE_UNUSED, size_t mc, char *buf) 332 296 { 333 297 int c; /* current char */ … … 338 302 xlist_t *prev; 339 303 340 for (prev = cur = list_arg; cur; cur = cur->link) { 341 line_l += cur->lenght; /* previous allocated */ 342 if (prev != cur) 343 prev = prev->link; 304 prev = cur = list_arg; 305 while (1) { 306 if (!cur) break; 307 prev = cur; 308 line_l += cur->length; 309 cur = cur->link; 344 310 } 345 311 … … 347 313 c = getchar(); 348 314 if (c == EOF) { 349 eof_stdin_detected ++;315 eof_stdin_detected = 1; 350 316 if (s == NULL) 351 317 break; 352 c = 0;318 c = '\0'; 353 319 } 354 320 if (s == NULL) … … 357 323 bb_error_msg_and_die("argument line too long"); 358 324 *p++ = c; 359 if (c == 0) { /* word's delimiter or EOF detected */325 if (c == '\0') { /* word's delimiter or EOF detected */ 360 326 /* word loaded */ 361 size_t lenght = (p - buf); 362 363 cur = xmalloc(sizeof(xlist_t) + lenght); 364 cur->data = memcpy(cur + 1, s, lenght); 365 cur->lenght = lenght; 327 size_t length = (p - buf); 328 /* Dont xzalloc - it can be quite big */ 329 cur = xmalloc(offsetof(xlist_t, xstr) + length); 366 330 cur->link = NULL; 331 cur->length = length; 332 memcpy(cur->xstr, s, length); 367 333 if (prev == NULL) { 368 334 list_arg = cur; … … 371 337 } 372 338 prev = cur; 373 line_l += leng ht;339 line_l += length; 374 340 if (line_l > mc) { 375 341 /* stop memory usage :-) */ … … 381 347 return list_arg; 382 348 } 383 384 # define READ_ARGS(l, e, nmc, mc) (*read_args)(l, e, nmc, mc) 385 # define OPT_INC_0 1 /* future use */ 386 #else 387 # define OPT_INC_0 0 /* future use */ 388 # define READ_ARGS(l, e, nmc, mc) process_stdin(l, e, nmc, mc) 389 #endif /* CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM */ 390 391 392 #define OPT_VERBOSE (1<<0) 393 #define OPT_NO_EMPTY (1<<1) 394 #define OPT_UPTO_NUMBER (1<<2) 395 #define OPT_UPTO_SIZE (1<<3) 396 #define OPT_EOF_STRING (1<<4) 397 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION 398 #define OPT_INTERACTIVE (1<<5) 399 #else 400 #define OPT_INTERACTIVE (0) /* require for algorithm &| */ 401 #endif 402 #define OPT_TERMINATE (1<<(5+OPT_INC_P)) 403 #define OPT_ZEROTERM (1<<(5+OPT_INC_P+OPT_INC_X)) 404 /* next future 405 #define OPT_NEXT_OTHER (1<<(5+OPT_INC_P+OPT_INC_X+OPT_INC_0)) 406 */ 407 349 #endif /* FEATURE_XARGS_SUPPORT_ZERO_TERM */ 350 351 /* Correct regardless of combination of CONFIG_xxx */ 352 enum { 353 OPTBIT_VERBOSE = 0, 354 OPTBIT_NO_EMPTY, 355 OPTBIT_UPTO_NUMBER, 356 OPTBIT_UPTO_SIZE, 357 OPTBIT_EOF_STRING, 358 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION(OPTBIT_INTERACTIVE,) 359 USE_FEATURE_XARGS_SUPPORT_TERMOPT( OPTBIT_TERMINATE ,) 360 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( OPTBIT_ZEROTERM ,) 361 362 OPT_VERBOSE = 1<<OPTBIT_VERBOSE , 363 OPT_NO_EMPTY = 1<<OPTBIT_NO_EMPTY , 364 OPT_UPTO_NUMBER = 1<<OPTBIT_UPTO_NUMBER, 365 OPT_UPTO_SIZE = 1<<OPTBIT_UPTO_SIZE , 366 OPT_EOF_STRING = 1<<OPTBIT_EOF_STRING , 367 OPT_INTERACTIVE = USE_FEATURE_XARGS_SUPPORT_CONFIRMATION((1<<OPTBIT_INTERACTIVE)) + 0, 368 OPT_TERMINATE = USE_FEATURE_XARGS_SUPPORT_TERMOPT( (1<<OPTBIT_TERMINATE )) + 0, 369 OPT_ZEROTERM = USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( (1<<OPTBIT_ZEROTERM )) + 0, 370 }; 371 #define OPTION_STR "+trn:s:e::" \ 372 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \ 373 USE_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ 374 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") 375 376 int xargs_main(int argc, char **argv); 408 377 int xargs_main(int argc, char **argv) 409 378 { 410 379 char **args; 411 int i, a,n;380 int i, n; 412 381 xlist_t *list = NULL; 413 382 xlist_t *cur; … … 418 387 long orig_arg_max; 419 388 const char *eof_str = "_"; 420 unsigned longopt;389 unsigned opt; 421 390 size_t n_max_chars; 422 423 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 424 xlist_t *(*read_args) (xlist_t *, const char *, size_t, char *) = process_stdin; 391 #if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 392 xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin; 393 #else 394 #define read_args process_stdin 425 395 #endif 426 396 427 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION 428 bb_opt_complementally = "pt"; 429 #endif 430 431 opt = bb_getopt_ulflags(argc, argv, "+trn:s:e::" 432 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION 433 "p" 434 #endif 435 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT 436 "x" 437 #endif 438 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 439 "0" 440 #endif 441 ,&max_args, &max_chars, &eof_str); 442 443 a = argc - optind; 397 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str); 398 399 if (opt & OPT_ZEROTERM) 400 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin); 401 444 402 argv += optind; 445 if (a == 0) { 403 argc -= optind; 404 if (!argc) { 446 405 /* default behavior is to echo all the filenames */ 447 *argv = "echo";448 a ++;406 *argv = (char*)"echo"; 407 argc++; 449 408 } 450 409 … … 452 411 if (orig_arg_max == -1) 453 412 orig_arg_max = LONG_MAX; 454 orig_arg_max -= 2048; /* POSIX.2 requires subtracting 2048. */ 455 if ((opt & OPT_UPTO_SIZE)) { 456 n_max_chars = bb_xgetularg10_bnd(max_chars, 1, orig_arg_max); 457 for (i = 0; i < a; i++) { 413 orig_arg_max -= 2048; /* POSIX.2 requires subtracting 2048 */ 414 415 if (opt & OPT_UPTO_SIZE) { 416 n_max_chars = xatoul_range(max_chars, 1, orig_arg_max); 417 for (i = 0; i < argc; i++) { 458 418 n_chars += strlen(*argv) + 1; 459 419 } 460 420 if (n_max_chars < n_chars) { 461 bb_error_msg_and_die("can 421 bb_error_msg_and_die("cannot fit single argument within argument list size limit"); 462 422 } 463 423 n_max_chars -= n_chars; … … 473 433 max_chars = xmalloc(n_max_chars); 474 434 475 if ( (opt & OPT_UPTO_NUMBER)) {476 n_max_arg = bb_xgetularg10_bnd(max_args, 1, INT_MAX);435 if (opt & OPT_UPTO_NUMBER) { 436 n_max_arg = xatoul_range(max_args, 1, INT_MAX); 477 437 } else { 478 438 n_max_arg = n_max_chars; 479 439 } 480 440 481 #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 482 if (opt & OPT_ZEROTERM) 483 read_args = process0_stdin; 484 #endif 485 486 while ((list = READ_ARGS(list, eof_str, n_max_chars, max_chars)) != NULL || 487 (opt & OPT_NO_EMPTY) == 0) 441 while ((list = read_args(list, eof_str, n_max_chars, max_chars)) != NULL || 442 !(opt & OPT_NO_EMPTY)) 488 443 { 489 444 opt |= OPT_NO_EMPTY; 490 445 n = 0; 491 446 n_chars = 0; 492 #if def CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT447 #if ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 493 448 for (cur = list; cur;) { 494 n_chars += cur->leng ht;449 n_chars += cur->length; 495 450 n++; 496 451 cur = cur->link; … … 503 458 #else 504 459 for (cur = list; cur; cur = cur->link) { 505 n_chars += cur->leng ht;460 n_chars += cur->length; 506 461 n++; 507 462 if (n_chars > n_max_chars || n == n_max_arg) { … … 509 464 } 510 465 } 511 #endif /* CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT */512 513 /* allocat ingpointers for execvp:514 a *arg, n*arg from stdin, NULL */515 args = x calloc(n + a + 1,sizeof(char *));516 517 /* Store the command to be executed466 #endif /* FEATURE_XARGS_SUPPORT_TERMOPT */ 467 468 /* allocate pointers for execvp: 469 argc*arg, n*arg from stdin, NULL */ 470 args = xzalloc((n + argc + 1) * sizeof(char *)); 471 472 /* store the command to be executed 518 473 (taken from the command line) */ 519 for (i = 0; i < a ; i++)474 for (i = 0; i < argc; i++) 520 475 args[i] = argv[i]; 521 476 /* (taken from stdin) */ 522 477 for (cur = list; n; cur = cur->link) { 523 args[i++] = cur-> data;478 args[i++] = cur->xstr; 524 479 n--; 525 480 } 526 481 527 if ( (opt & (OPT_INTERACTIVE | OPT_VERBOSE))) {482 if (opt & (OPT_INTERACTIVE | OPT_VERBOSE)) { 528 483 for (i = 0; args[i]; i++) { 529 484 if (i) … … 531 486 fputs(args[i], stderr); 532 487 } 533 if ( (opt & OPT_INTERACTIVE) == 0)488 if (!(opt & OPT_INTERACTIVE)) 534 489 fputc('\n', stderr); 535 490 } 536 if ( (opt & OPT_INTERACTIVE) == 0 || xargs_ask_confirmation() != 0) {491 if (!(opt & OPT_INTERACTIVE) || xargs_ask_confirmation()) { 537 492 child_error = xargs_exec(args); 538 493 } 539 494 540 495 /* clean up */ 541 for (i = a ; args[i]; i++) {496 for (i = argc; args[i]; i++) { 542 497 cur = list; 543 498 list = list->link; … … 549 504 } 550 505 } 551 #ifdef CONFIG_FEATURE_CLEAN_UP 552 free(max_chars); 553 #endif 506 if (ENABLE_FEATURE_CLEAN_UP) 507 free(max_chars); 554 508 return child_error; 555 509 } … … 558 512 #ifdef TEST 559 513 560 const char * bb_applet_name = "debug stuff usage";514 const char *applet_name = "debug stuff usage"; 561 515 562 516 void bb_show_usage(void) 563 517 { 564 518 fprintf(stderr, "Usage: %s [-p] [-r] [-t] -[x] [-n max_arg] [-s max_chars]\n", 565 bb_applet_name);519 applet_name); 566 520 exit(1); 567 521 }
Note:
See TracChangeset
for help on using the changeset viewer.