source:
clfs-embedded/patches/busybox-1.13.3-branch_update-1.patch@
7c5d3a4
Last change on this file since 7c5d3a4 was 118c546, checked in by , 16 years ago | |
---|---|
|
|
File size: 15.2 KB |
-
coreutils/tail.c
Submitted By: Jim Gifford (jim at cross-lfs dot org) Date: 03-28-2009 Initial Package Version: 1.13.3 Origin: Upstream Upstream Status: Applied Description: This is a branch update for busybox-1.13.3, and should be rechecked periodically. diff -Naur busybox-1.13.3.orig/coreutils/tail.c busybox-1.13.3/coreutils/tail.c
old new 104 104 if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-') 105 105 && isdigit(argv[1][1]) 106 106 ) { 107 count = eat_num( &argv[1][1]);107 count = eat_num(argv[1]); 108 108 argv++; 109 109 argc--; 110 110 } -
busybox-1.13.3
diff -Naur busybox-1.13.3.orig/shell/ash.c busybox-1.13.3/shell/ash.c
old new 30 30 */ 31 31 32 32 /* 33 * The follow should be set to reflect the type of system you have:33 * The following should be set to reflect the type of system you have: 34 34 * JOBS -> 1 if you have Berkeley job control, 0 otherwise. 35 35 * define SYSV if you are running under System V. 36 36 * define DEBUG=1 to compile in debugging ('set -o debug' to turn on) … … 40 40 * a quit signal will generate a core dump. 41 41 */ 42 42 #define DEBUG 0 43 /* Tweak debug output verbosity here */ 44 #define DEBUG_TIME 0 45 #define DEBUG_PID 1 46 #define DEBUG_SIG 1 47 43 48 #define PROFILE 0 44 49 45 50 #define IFS_BROKEN … … 47 52 #define JOBS ENABLE_ASH_JOB_CONTROL 48 53 49 54 #if DEBUG 50 # ifndef _GNU_SOURCE51 # define _GNU_SOURCE52 # endif55 # ifndef _GNU_SOURCE 56 # define _GNU_SOURCE 57 # endif 53 58 #endif 54 59 55 60 #include "busybox.h" /* for applet_names */ … … 57 62 #include <setjmp.h> 58 63 #include <fnmatch.h> 59 64 #if JOBS || ENABLE_ASH_READ_NCHARS 60 # include <termios.h>65 # include <termios.h> 61 66 #endif 62 67 63 68 #ifndef PIPE_BUF 64 # define PIPE_BUF 4096 /* amount of buffering in a pipe */69 # define PIPE_BUF 4096 /* amount of buffering in a pipe */ 65 70 #endif 66 71 67 72 #if defined(__uClinux__) 68 # error "Do not even bother, ash will not run on uClinux"73 # error "Do not even bother, ash will not run on uClinux" 69 74 #endif 70 75 71 76 … … 76 81 #define CMDTABLESIZE 31 /* should be prime */ 77 82 78 83 79 /* ============ Misc helpers */80 81 #define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0)82 83 /* C99 say: "char" declaration may be signed or unsigned default */84 #define signed_char2int(sc) ((int)((signed char)sc))85 86 87 84 /* ============ Shell options */ 88 85 89 86 static const char *const optletters_optnames[] = { … … 245 242 } while (0) 246 243 247 244 245 /* ============ DEBUG */ 246 #if DEBUG 247 static void trace_printf(const char *fmt, ...); 248 static void trace_vprintf(const char *fmt, va_list va); 249 # define TRACE(param) trace_printf param 250 # define TRACEV(param) trace_vprintf param 251 # define close(f) do { \ 252 int dfd = (f); \ 253 if (close(dfd) < 0) \ 254 bb_error_msg("bug on %d: closing %d(%x)", \ 255 __LINE__, dfd, dfd); \ 256 } while (0) 257 #else 258 # define TRACE(param) 259 # define TRACEV(param) 260 #endif 261 262 248 263 /* ============ Utility functions */ 264 #define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0) 265 266 /* C99 say: "char" declaration may be signed or unsigned by default */ 267 #define signed_char2int(sc) ((int)(signed char)(sc)) 268 249 269 static int isdigit_str9(const char *str) 250 270 { 251 271 int maxlen = 9 + 1; /* max 9 digits: 999999999 */ … … 284 304 exception = e; 285 305 longjmp(exception_handler->loc, 1); 286 306 } 307 #if DEBUG 308 #define raise_exception(e) do { \ 309 TRACE(("raising exception %d on line %d\n", (e), __LINE__)); \ 310 raise_exception(e); \ 311 } while (0) 312 #endif 287 313 288 314 /* 289 315 * Called from trap.c when a SIGINT is received. (If the user specifies … … 316 342 raise_exception(i); 317 343 /* NOTREACHED */ 318 344 } 345 #if DEBUG 346 #define raise_interrupt() do { \ 347 TRACE(("raising interrupt on line %d\n", __LINE__)); \ 348 raise_interrupt(); \ 349 } while (0) 350 #endif 319 351 320 352 #if ENABLE_ASH_OPTIMIZE_FOR_SIZE 321 353 static void … … 334 366 raise_interrupt(); 335 367 } 336 368 #define FORCE_INT_ON force_int_on() 337 #else 369 370 #else /* !ASH_OPTIMIZE_FOR_SIZE */ 371 338 372 #define INT_ON do { \ 339 373 xbarrier(); \ 340 374 if (--suppressint == 0 && intpending) \ … … 346 380 if (intpending) \ 347 381 raise_interrupt(); \ 348 382 } while (0) 349 #endif /* ASH_OPTIMIZE_FOR_SIZE */383 #endif /* !ASH_OPTIMIZE_FOR_SIZE */ 350 384 351 385 #define SAVE_INT(v) ((v) = suppressint) 352 386 … … 376 410 onsig(int signo) 377 411 { 378 412 gotsig[signo - 1] = 1; 379 pendingsig = signo;380 413 381 414 if (/* exsig || */ (signo == SIGINT && !trap[SIGINT])) { 382 415 if (!suppressint) { … … 384 417 raise_interrupt(); /* does not return */ 385 418 } 386 419 intpending = 1; 420 } else { 421 pendingsig = signo; 387 422 } 388 423 } 389 424 … … 684 719 685 720 if (debug != 1) 686 721 return; 722 if (DEBUG_TIME) 723 fprintf(tracefile, "%u ", (int) time(NULL)); 724 if (DEBUG_PID) 725 fprintf(tracefile, "[%u] ", (int) getpid()); 726 if (DEBUG_SIG) 727 fprintf(tracefile, "pending s:%d i:%d(supp:%d) ", pendingsig, intpending, suppressint); 687 728 va_start(va, fmt); 688 729 vfprintf(tracefile, fmt, va); 689 730 va_end(va); … … 694 735 { 695 736 if (debug != 1) 696 737 return; 738 if (DEBUG_TIME) 739 fprintf(tracefile, "%u ", (int) time(NULL)); 740 if (DEBUG_PID) 741 fprintf(tracefile, "[%u] ", (int) getpid()); 742 if (DEBUG_SIG) 743 fprintf(tracefile, "pending s:%d i:%d(supp:%d) ", pendingsig, intpending, suppressint); 697 744 vfprintf(tracefile, fmt, va); 698 745 } 699 746 … … 998 1045 shtree(n, 1, NULL, stdout); 999 1046 } 1000 1047 1001 #define TRACE(param) trace_printf param1002 #define TRACEV(param) trace_vprintf param1003 1004 #else1005 1006 #define TRACE(param)1007 #define TRACEV(param)1008 1009 1048 #endif /* DEBUG */ 1010 1049 1011 1050 … … 3779 3818 * NB: _not_ safe_waitpid, we need to detect EINTR */ 3780 3819 pid = waitpid(-1, &status, 3781 3820 (doing_jobctl ? (wait_flags | WUNTRACED) : wait_flags)); 3782 TRACE(("wait returns pid=%d, status=0x%x \n", pid, status));3821 TRACE(("wait returns pid=%d, status=0x%x, errno=%d(%s)\n", pid, status, errno, strerror(errno))); 3783 3822 3784 3823 if (pid <= 0) { 3785 3824 /* If we were doing blocking wait and (probably) got EINTR, … … 5031 5070 if (newfd < 0) { 5032 5071 /* NTOFD/NFROMFD: copy redir->ndup.dupfd to fd */ 5033 5072 if (redir->ndup.dupfd < 0) { /* "fd>&-" */ 5034 close(fd); 5073 /* Don't want to trigger debugging */ 5074 if (fd != -1) 5075 close(fd); 5035 5076 } else { 5036 5077 copyfd(redir->ndup.dupfd, fd | COPYFD_EXACT); 5037 5078 } … … 5084 5125 /*close(fd);*/ 5085 5126 copyfd(copy, fd | COPYFD_EXACT); 5086 5127 } 5087 close(copy );5128 close(copy & ~COPYFD_RESTORE); 5088 5129 } 5089 5130 } 5090 5131 redirlist = rp->next; … … 7871 7912 pendingsig = 0; 7872 7913 xbarrier(); 7873 7914 7915 TRACE(("dotrap entered\n")); 7874 7916 for (i = 1, q = gotsig; i < NSIG; i++, q++) { 7875 7917 if (!*q) 7876 7918 continue; 7877 *q = '\0';7878 7919 7879 7920 p = trap[i]; 7921 /* non-trapped SIGINT is handled separately by raise_interrupt, 7922 * don't upset it by resetting gotsig[SIGINT-1] */ 7923 if (i == SIGINT && !p) 7924 continue; 7925 7926 TRACE(("sig %d is active, will run handler '%s'\n", i, p)); 7927 *q = '\0'; 7880 7928 if (!p) 7881 7929 continue; 7882 7930 skip = evalstring(p, SKIPEVAL); 7883 7931 exitstatus = savestatus; 7884 if (skip) 7932 if (skip) { 7933 TRACE(("dotrap returns %d\n", skip)); 7885 7934 return skip; 7935 } 7886 7936 } 7887 7937 7938 TRACE(("dotrap returns 0\n")); 7888 7939 return 0; 7889 7940 } 7890 7941 … … 7906 7957 static void 7907 7958 evaltree(union node *n, int flags) 7908 7959 { 7909 7910 7960 struct jmploc *volatile savehandler = exception_handler; 7911 7961 struct jmploc jmploc; 7912 7962 int checkexit = 0; 7913 7963 void (*evalfn)(union node *, int); 7914 7964 int status; 7965 int int_level; 7966 7967 SAVE_INT(int_level); 7915 7968 7916 7969 if (n == NULL) { 7917 7970 TRACE(("evaltree(NULL) called\n")); 7918 7971 goto out1; 7919 7972 } 7920 TRACE(("pid %d, evaltree(%p: %d, %d) called\n", 7921 getpid(), n, n->type, flags)); 7973 TRACE(("evaltree(%p: %d, %d) called\n", n, n->type, flags)); 7922 7974 7923 7975 exception_handler = &jmploc; 7924 7976 { 7925 7977 int err = setjmp(jmploc.loc); 7926 7978 if (err) { 7927 7979 /* if it was a signal, check for trap handlers */ 7928 if (exception == EXSIG) 7980 if (exception == EXSIG) { 7981 TRACE(("exception %d (EXSIG) in evaltree, err=%d\n", exception, err)); 7929 7982 goto out; 7983 } 7930 7984 /* continue on the way out */ 7985 TRACE(("exception %d in evaltree, propagating err=%d\n", exception, err)); 7931 7986 exception_handler = savehandler; 7932 7987 longjmp(exception_handler->loc, err); 7933 7988 } … … 8010 8065 if (exitstatus == 0) { 8011 8066 n = n->nif.ifpart; 8012 8067 goto evaln; 8013 } else if (n->nif.elsepart) { 8068 } 8069 if (n->nif.elsepart) { 8014 8070 n = n->nif.elsepart; 8015 8071 goto evaln; 8016 8072 } … … 8036 8092 exexit: 8037 8093 raise_exception(EXEXIT); 8038 8094 } 8095 8096 RESTORE_INT(int_level); 8097 TRACE(("leaving evaltree (no interrupts)\n")); 8039 8098 } 8040 8099 8041 8100 #if !defined(__alpha__) || (defined(__GNUC__) && __GNUC__ >= 3) … … 8281 8340 if (prevfd >= 0) 8282 8341 close(prevfd); 8283 8342 prevfd = pip[0]; 8284 close(pip[1]); 8343 /* Don't want to trigger debugging */ 8344 if (pip[1] != -1) 8345 close(pip[1]); 8285 8346 } 8286 8347 if (n->npipe.pipe_backgnd == 0) { 8287 8348 exitstatus = waitforjob(jp); … … 8913 8974 if (forkshell(jp, cmd, FORK_FG) != 0) { 8914 8975 exitstatus = waitforjob(jp); 8915 8976 INT_ON; 8977 TRACE(("forked child exited with %d\n", exitstatus)); 8916 8978 break; 8917 8979 } 8918 8980 FORCE_INT_ON; … … 13640 13702 exception_handler = &jmploc; 13641 13703 #if DEBUG 13642 13704 opentrace(); 13643 trace_puts("Shell args: ");13705 TRACE(("Shell args: ")); 13644 13706 trace_puts_args(argv); 13645 13707 #endif 13646 13708 rootpid = getpid(); … … 13692 13754 } 13693 13755 state3: 13694 13756 state = 4; 13695 if (minusc) 13757 if (minusc) { 13758 /* evalstring pushes parsefile stack. 13759 * Ensure we don't falsely claim that 0 (stdin) 13760 * is one of stacked source fds */ 13761 if (!sflag) 13762 g_parsefile->fd = -1; 13696 13763 evalstring(minusc, 0); 13764 } 13697 13765 13698 13766 if (sflag || minusc == NULL) { 13699 13767 #if ENABLE_FEATURE_EDITING_SAVEHISTORY … … 13720 13788 /* NOTREACHED */ 13721 13789 } 13722 13790 13723 #if DEBUG13724 const char *applet_name = "debug stuff usage";13725 int main(int argc, char **argv)13726 {13727 return ash_main(argc, argv);13728 }13729 #endif13730 13731 13791 13732 13792 /*- 13733 13793 * Copyright (c) 1989, 1991, 1993, 1994 -
busybox-1.13.3
diff -Naur busybox-1.13.3.orig/shell/hush.c busybox-1.13.3/shell/hush.c
old new 458 458 smallint fake_mode; 459 459 /* these three support $?, $#, and $1 */ 460 460 smalluint last_return_code; 461 char **global_argv; 461 /* is global_argv and global_argv[1..n] malloced? (note: not [0]) */ 462 smalluint global_args_malloced; 463 /* how many non-NULL argv's we have. NB: $# + 1 */ 462 464 int global_argc; 465 char **global_argv; 463 466 #if ENABLE_HUSH_LOOPS 464 467 unsigned depth_break_continue; 465 468 unsigned depth_of_loop; … … 633 636 return dst; 634 637 } 635 638 636 static char **add_strings_to_strings(char **strings, char **add )639 static char **add_strings_to_strings(char **strings, char **add, int need_to_dup) 637 640 { 638 641 int i; 639 642 unsigned count1; … … 658 661 v[count1 + count2] = NULL; 659 662 i = count2; 660 663 while (--i >= 0) 661 v[count1 + i] = add[i];664 v[count1 + i] = (need_to_dup ? xstrdup(add[i]) : add[i]); 662 665 return v; 663 666 } 664 667 … … 667 670 char *v[2]; 668 671 v[0] = add; 669 672 v[1] = NULL; 670 return add_strings_to_strings(strings, v );673 return add_strings_to_strings(strings, v, /*dup:*/ 0); 671 674 } 672 675 673 676 static void putenv_all(char **strings) … … 1213 1216 * Otherwise, just finish current list[] and start new */ 1214 1217 static int o_save_ptr(o_string *o, int n) 1215 1218 { 1216 if (o->o_glob) 1217 return o_glob(o, n); /* o_save_ptr_helper is inside */ 1219 if (o->o_glob) { /* if globbing is requested */ 1220 /* If o->has_empty_slot, list[n] was already globbed 1221 * (if it was requested back then when it was filled) 1222 * so don't do that again! */ 1223 if (!o->has_empty_slot) 1224 return o_glob(o, n); /* o_save_ptr_helper is inside */ 1225 } 1218 1226 return o_save_ptr_helper(o, n); 1219 1227 } 1220 1228 … … 4279 4287 switch (opt) { 4280 4288 case 'c': 4281 4289 G.global_argv = argv + optind; 4290 if (!argv[optind]) { 4291 /* -c 'script' (no params): prevent empty $0 */ 4292 *--G.global_argv = argv[0]; 4293 optind--; 4294 } /* else -c 'script' PAR0 PAR1: $0 is PAR0 */ 4282 4295 G.global_argc = argc - optind; 4283 4296 opt = parse_and_run_string(optarg, 0 /* parse_flag */); 4284 4297 goto final_return; … … 4639 4652 return set_local_var(string, 0); 4640 4653 } 4641 4654 4642 /* built-in 'set [VAR=value]' handler */ 4655 /* built-in 'set' handler 4656 * SUSv3 says: 4657 * set [-abCefmnuvx] [-h] [-o option] [argument...] 4658 * set [+abCefmnuvx] [+h] [+o option] [argument...] 4659 * set -- [argument...] 4660 * set -o 4661 * set +o 4662 * Implementations shall support the options in both their hyphen and 4663 * plus-sign forms. These options can also be specified as options to sh. 4664 * Examples: 4665 * Write out all variables and their values: set 4666 * Set $1, $2, and $3 and set "$#" to 3: set c a b 4667 * Turn on the -x and -v options: set -xv 4668 * Unset all positional parameters: set -- 4669 * Set $1 to the value of x, even if it begins with '-' or '+': set -- "$x" 4670 * Set the positional parameters to the expansion of x, even if x expands 4671 * with a leading '-' or '+': set -- $x 4672 * 4673 * So far, we only support "set -- [argument...]" by ignoring all options 4674 * (also, "-o option" will be mishandled by taking "option" as parameter #1). 4675 */ 4643 4676 static int builtin_set(char **argv) 4644 4677 { 4645 char *temp = argv[1];4646 4678 struct variable *e; 4679 char **pp; 4680 char *arg = *++argv; 4647 4681 4648 if ( temp == NULL)4682 if (arg == NULL) { 4649 4683 for (e = G.top_var; e; e = e->next) 4650 4684 puts(e->varstr); 4651 else 4652 set_local_var(xstrdup(temp), 0); 4685 } else { 4686 /* NB: G.global_argv[0] ($0) is never freed/changed */ 4687 4688 if (G.global_args_malloced) { 4689 pp = G.global_argv; 4690 while (*++pp) 4691 free(*pp); 4692 G.global_argv[1] = NULL; 4693 } else { 4694 G.global_args_malloced = 1; 4695 pp = xzalloc(sizeof(pp[0]) * 2); 4696 pp[0] = G.global_argv[0]; /* retain $0 */ 4697 G.global_argv = pp; 4698 } 4699 do { 4700 if (arg[0] == '+') 4701 continue; 4702 if (arg[0] != '-') 4703 break; 4704 if (arg[1] == '-' && arg[2] == '\0') { 4705 argv++; 4706 break; 4707 } 4708 } while ((arg = *++argv) != NULL); 4709 /* Now argv[0] is 1st argument */ 4710 4711 /* This realloc's G.global_argv */ 4712 G.global_argv = pp = add_strings_to_strings(G.global_argv, argv, /*dup:*/ 1); 4713 G.global_argc = 1; 4714 while (*++pp) 4715 G.global_argc++; 4716 } 4653 4717 4654 4718 return EXIT_SUCCESS; 4655 4719 } … … 4661 4725 n = atoi(argv[1]); 4662 4726 } 4663 4727 if (n >= 0 && n < G.global_argc) { 4664 G.global_argv[n] = G.global_argv[0]; 4728 if (G.global_args_malloced) { 4729 int m = 1; 4730 while (m <= n) 4731 free(G.global_argv[m++]); 4732 } 4665 4733 G.global_argc -= n; 4666 G.global_argv += n; 4734 memmove(&G.global_argv[1], &G.global_argv[n+1], 4735 G.global_argc * sizeof(G.global_argv[0])); 4667 4736 return EXIT_SUCCESS; 4668 4737 } 4669 4738 return EXIT_FAILURE; -
shell/hush_test/hush-parsing/starquoted2.right
diff -Naur busybox-1.13.3.orig/shell/hush_test/hush-parsing/starquoted2.right busybox-1.13.3/shell/hush_test/hush-parsing/starquoted2.right
old new 1 1 Should be printed 2 2 Should be printed 3 Empty: -
shell/hush_test/hush-parsing/starquoted2.tests
diff -Naur busybox-1.13.3.orig/shell/hush_test/hush-parsing/starquoted2.tests busybox-1.13.3/shell/hush_test/hush-parsing/starquoted2.tests
old new 12 12 for a in """$@"; do echo Should not be printed; done 13 13 for a in """$@"''"$@"''; do echo Should not be printed; done 14 14 for a in ""; do echo Should be printed; done 15 16 # Bug 207: "$@" expands to nothing, and we erroneously glob "%s\\n" twice: 17 printf "Empty:%s\\n" "$@"
Note:
See TracBrowser
for help on using the repository browser.