diff --git a/ChangeLog b/ChangeLog index d3a4acf..d84d3b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2012-06-09 Christoph Mathys <eraserix@gmail.com> + + * Add support for ulimit -r. + +2012-03-11 Jim Meyering <meyering@redhat.com> + + * Avoid overflow for very long variable name. + $ perl -le 'print "v"x(2**31+1) ."=1"' | dash + +2012-02-25 Herbert Xu <herbert@gondor.apana.org.au> + + * Sanitise environment variable names on entry. + +2011-08-17 David S. Miller <davem@davemloft.net> + + * Allow building without LINEO support. + * Add top-level autogen.sh. + +2011-07-26 Harald van Dijk <harald@gigawatt.nl> + + * Avoid imaxdiv when only one of the results is wanted. + +2010-07-09 maximilian attems <max@stro.at> + + * Fix klibc DEBUG compilation. + +2011-07-09 Herbert Xu <herbert@gondor.apana.org.au> + + * Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving dotcmd. + 2011-07-08 Herbert Xu <herbert@gondor.apana.org.au> * Release 0.5.7. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..9879c53 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +aclocal \ +&& autoheader \ +&& automake --add-missing \ +&& autoconf diff --git a/configure.ac b/configure.ac index 7eae954..c6fb401 100644 --- a/configure.ac +++ b/configure.ac @@ -85,7 +85,7 @@ AC_CHECK_DECL([PRIdMAX],, ]) dnl Checks for library functions. -AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit imaxdiv isalpha killpg \ +AC_CHECK_FUNCS(bsearch faccessat getpwnam getrlimit isalpha killpg \ mempcpy \ sigsetmask stpcpy strchrnul strsignal strtod strtoimax \ strtoumax sysconf) @@ -131,5 +131,10 @@ if test "$use_libedit" != "yes"; then else export LIBS="$LIBS -ledit" fi +AC_ARG_ENABLE(lineno, AS_HELP_STRING(--disable-lineno, \ + [Disable LINENO support])) +if test "$enable_lineno" != "no"; then + AC_DEFINE([WITH_LINENO], 1, [Define if you build with -DWITH_LINENO]) +fi AC_CONFIG_FILES([Makefile src/Makefile]) AC_OUTPUT diff --git a/src/arith_yacc.c b/src/arith_yacc.c index bf21830..1a087c3 100644 --- a/src/arith_yacc.c +++ b/src/arith_yacc.c @@ -94,22 +94,13 @@ static inline int higher_prec(int op1, int op2) static intmax_t do_binop(int op, intmax_t a, intmax_t b) { -#ifdef HAVE_IMAXDIV - imaxdiv_t div; -#endif - switch (op) { default: case ARITH_REM: case ARITH_DIV: if (!b) yyerror("division by zero"); -#ifdef HAVE_IMAXDIV - div = imaxdiv(a, b); - return op == ARITH_REM ? div.rem : div.quot; -#else return op == ARITH_REM ? a % b : a / b; -#endif case ARITH_MUL: return a * b; case ARITH_ADD: diff --git a/src/dash.1 b/src/dash.1 index 3847d98..a9cb491 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -2163,6 +2163,8 @@ show or set the limit on the number of processes this user can have at one time .It Fl n show or set the limit on the number files a process can have open at once +.It Fl r +show or set the limit on the real-time scheduling priority of a process .El .Pp If none of these is specified, it is the limit on file size that is shown diff --git a/src/eval.c b/src/eval.c index 95d30f4..c7358a6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1039,7 +1039,7 @@ returncmd(int argc, char **argv) * If called outside a function, do what ksh does; * skip the rest of the file. */ - evalskip = funcline ? SKIPFUNC : SKIPFILE; + evalskip = SKIPFUNC; return argv[1] ? number(argv[1]) : exitstatus; } diff --git a/src/eval.h b/src/eval.h index 4e4de30..dc8acd2 100644 --- a/src/eval.h +++ b/src/eval.h @@ -61,4 +61,3 @@ extern int evalskip; #define SKIPBREAK (1 << 0) #define SKIPCONT (1 << 1) #define SKIPFUNC (1 << 2) -#define SKIPFILE (1 << 3) diff --git a/src/main.c b/src/main.c index af987c6..f79ad7d 100644 --- a/src/main.c +++ b/src/main.c @@ -242,7 +242,7 @@ cmdloop(int top) skip = evalskip; if (skip) { - evalskip = 0; + evalskip &= ~SKIPFUNC; break; } } diff --git a/src/miscbltin.c b/src/miscbltin.c index e354df4..b596fd2 100644 --- a/src/miscbltin.c +++ b/src/miscbltin.c @@ -392,6 +392,9 @@ static const struct limits limits[] = { #ifdef RLIMIT_LOCKS { "locks", RLIMIT_LOCKS, 1, 'w' }, #endif +#ifdef RLIMIT_RTPRIO + { "rtprio", RLIMIT_RTPRIO, 1, 'r' }, +#endif { (char *) 0, 0, 0, '\0' } }; diff --git a/src/parser.c b/src/parser.c index 6de2762..572cbcd 100644 --- a/src/parser.c +++ b/src/parser.c @@ -853,7 +853,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) { int c = firstc; char *out; - int len; + size_t len; struct nodelist *bqlist; int quotef; int dblquote; diff --git a/src/show.c b/src/show.c index 14dbef3..4a049e9 100644 --- a/src/show.c +++ b/src/show.c @@ -378,7 +378,11 @@ opentrace(void) scopy("./trace", s); #endif /* not_this_way */ if (tracefile) { +#ifndef __KLIBC__ if (!freopen(s, "a", tracefile)) { +#else + if (!(!fclose(tracefile) && (tracefile = fopen(s, "a")))) { +#endif /* __KLIBC__ */ fprintf(stderr, "Can't re-open %s\n", s); debug = 0; return; @@ -394,7 +398,9 @@ opentrace(void) if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0) fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND); #endif +#ifndef __KLIBC__ setlinebuf(tracefile); +#endif /* __KLIBC__ */ fputs("\nTracing started.\n", tracefile); } #endif /* DEBUG */ diff --git a/src/var.c b/src/var.c index ecc8c90..dc90249 100644 --- a/src/var.c +++ b/src/var.c @@ -101,7 +101,9 @@ struct var varinit[] = { { 0, VSTRFIXED|VTEXTFIXED, "PS2=> ", 0 }, { 0, VSTRFIXED|VTEXTFIXED, "PS4=+ ", 0 }, { 0, VSTRFIXED|VTEXTFIXED, "OPTIND=1", getoptsreset }, +#ifdef WITH_LINENO { 0, VSTRFIXED|VTEXTFIXED, linenovar, 0 }, +#endif #ifndef SMALL { 0, VSTRFIXED|VTEXTFIXED|VUNSET, "TERM\0", 0 }, { 0, VSTRFIXED|VTEXTFIXED|VUNSET, "HISTSIZE\0", sethistsize }, @@ -134,7 +136,8 @@ INIT { initvar(); for (envp = environ ; *envp ; envp++) { - if (strchr(*envp, '=')) { + p = endofname(*envp); + if (p != *envp && *p == '=') { setvareq(*envp, VEXPORT|VTEXTFIXED); } } @@ -335,9 +338,11 @@ lookupvar(const char *name) struct var *v; if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) { +#ifdef WITH_LINENO if (v == &vlineno && v->text == linenovar) { fmtstr(linenovar+7, sizeof(linenovar)-7, "%d", lineno); } +#endif return strchrnul(v->text, '=') + 1; } return NULL; diff --git a/src/var.h b/src/var.h index 54f7b2d..79ee71a 100644 --- a/src/var.h +++ b/src/var.h @@ -88,9 +88,15 @@ extern struct var varinit[]; #define vps2 (&vps1)[1] #define vps4 (&vps2)[1] #define voptind (&vps4)[1] +#ifdef WITH_LINENO #define vlineno (&voptind)[1] +#endif #ifndef SMALL +#ifdef WITH_LINENO #define vterm (&vlineno)[1] +#else +#define vterm (&voptind)[1] +#endif #define vhistsize (&vterm)[1] #endif