diff options
author | Roy Marples <uberlord@gentoo.org> | 2007-10-08 10:25:03 +0000 |
---|---|---|
committer | Roy Marples <uberlord@gentoo.org> | 2007-10-08 10:25:03 +0000 |
commit | ceed834fd8a5f5f1564eb3a77ed13a51ab97adce (patch) | |
tree | 5ec87227f719a28884bbd31d1f74b423f6779a46 /app-shells/dash | |
parent | Stable on ppc64 (diff) | |
download | gentoo-2-ceed834fd8a5f5f1564eb3a77ed13a51ab97adce.tar.gz gentoo-2-ceed834fd8a5f5f1564eb3a77ed13a51ab97adce.tar.bz2 gentoo-2-ceed834fd8a5f5f1564eb3a77ed13a51ab97adce.zip |
Fully support POSIX arithmetic
(Portage version: 2.1.3.11)
Diffstat (limited to 'app-shells/dash')
-rw-r--r-- | app-shells/dash/ChangeLog | 8 | ||||
-rw-r--r-- | app-shells/dash/dash-0.5.4.1-r1.ebuild | 70 | ||||
-rw-r--r-- | app-shells/dash/files/dash-0.5.4-posix-arith.patch | 420 | ||||
-rw-r--r-- | app-shells/dash/files/digest-dash-0.5.4.1-r1 | 6 |
4 files changed, 503 insertions, 1 deletions
diff --git a/app-shells/dash/ChangeLog b/app-shells/dash/ChangeLog index 57d127b980db..36686fe5682f 100644 --- a/app-shells/dash/ChangeLog +++ b/app-shells/dash/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for app-shells/dash # Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-shells/dash/ChangeLog,v 1.45 2007/08/13 12:32:26 uberlord Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-shells/dash/ChangeLog,v 1.46 2007/10/08 10:25:03 uberlord Exp $ + +*dash-0.5.4.1-r1 (08 Oct 2007) + + 08 Oct 2007; Roy Marples <uberlord@gentoo.org> + +files/dash-0.5.4-posix-arith.patch, +dash-0.5.4.1-r1.ebuild: + Fully support POSIX arithmetic *dash-0.5.4.1 (13 Aug 2007) diff --git a/app-shells/dash/dash-0.5.4.1-r1.ebuild b/app-shells/dash/dash-0.5.4.1-r1.ebuild new file mode 100644 index 000000000000..43c33229c1a0 --- /dev/null +++ b/app-shells/dash/dash-0.5.4.1-r1.ebuild @@ -0,0 +1,70 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-shells/dash/dash-0.5.4.1-r1.ebuild,v 1.1 2007/10/08 10:25:03 uberlord Exp $ + +inherit autotools eutils flag-o-matic toolchain-funcs + +DEB_PV=${PV%.*} +DEB_PATCH=${PV##*.} +DEB_PF="${PN}_${DEB_PV}-${DEB_PATCH}" +MY_P="${PN}-${DEB_PV}" + +DESCRIPTION="DASH is a direct descendant of the NetBSD version of ash (the +Almquist SHell) and is POSIX compliant" +HOMEPAGE="http://gondor.apana.org.au/~herbert/dash/" +SRC_URI="http://gondor.apana.org.au/~herbert/dash/files/${PN}-${DEB_PV}.tar.gz + mirror://debian/pool/main/d/dash/${DEB_PF}.diff.gz" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~x86" +IUSE="libedit static" + +DEPEND="libedit? ( dev-libs/libedit )" + +S="${WORKDIR}/${MY_P}" + +src_unpack() { + unpack ${A} + + epatch "${WORKDIR}/${DEB_PF}".diff + + cd "${S}" + epatch debian/diff/* + + # Fix reading of long lines + epatch "${FILESDIR}/${PN}"-0.5.3-read-length.patch + + # Support posix arithmetic expansion + epatch "${FILESDIR}/${PN}"-0.5.4-posix-arith.patch + + # Fix the invalid sort + sed -i -e 's/LC_COLLATE=C/LC_ALL=C/g' src/mkbuiltins + + # Always statically link libedit in to ensure we always boot if it changes + # which it has done in the past. + local s="s/-ledit/-Wl,-Bstatic -ledit -Wl,-Bdynamic -lcurses/g" + use static && s="s/-ledit/-ledit -lcurses/g" + sed -i -e "${s}" configure.ac || die "Failed to sed configure.ac" + + # May as well, as the debian patches force this anyway + eautoreconf +} + +src_compile() { + local myconf= + + use static && append-ldflags -static + use libedit && myconf="${myconf} --with-libedit" + export CC="$(tc-getCC)" + + econf ${myconf} || die "econf failed" + emake CFLAGS="${CFLAGS}" || die "emake failed" +} + +src_install() { + exeinto /bin + newexe src/dash dash + newman src/dash.1 dash.1 + dodoc COPYING ChangeLog +} diff --git a/app-shells/dash/files/dash-0.5.4-posix-arith.patch b/app-shells/dash/files/dash-0.5.4-posix-arith.patch new file mode 100644 index 000000000000..9665c4ac19d4 --- /dev/null +++ b/app-shells/dash/files/dash-0.5.4-posix-arith.patch @@ -0,0 +1,420 @@ +diff -ur a/src/arith.y b/src/arith.y +--- a/src/arith.y 2007-07-13 09:26:42.000000000 +0100 ++++ b/src/arith.y 2007-10-08 11:04:29.000000000 +0100 +@@ -34,14 +34,19 @@ + */ + + #include <stdlib.h> +-#include "expand.h" ++#include <stdio.h> + #include "shell.h" ++#include "arith.h" ++#include "expand.h" + #include "error.h" + #include "output.h" + #include "memalloc.h" ++#include "var.h" + + const char *arith_buf, *arith_startbuf; + ++static int arith_assign(char *, arith_t); ++ + #ifndef YYBISON + int yyparse(void); + #endif +@@ -52,8 +57,18 @@ + #endif + + %} +-%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN +- ++%union { ++ arith_t l_value; ++ char* s_value; ++} ++%token <l_value> ARITH_NUM ARITH_LPAREN ARITH_RPAREN ++%token <s_value> ARITH_VAR ++%type <l_value> expr ++%right ARITH_ASSIGN ++%right ARITH_ADDASSIGN ARITH_SUBASSIGN ++%right ARITH_MULASSIGN ARITH_DIVASSIGN ARITH_REMASSIGN ++%right ARITH_RSHASSIGN ARITH_LSHASSIGN ++%right ARITH_BANDASSIGN ARITH_BXORASSIGN ARITH_BORASSIGN + %left ARITH_OR + %left ARITH_AND + %left ARITH_BOR +@@ -105,8 +120,118 @@ + | ARITH_SUB expr %prec ARITH_UNARYMINUS { $$ = -($2); } + | ARITH_ADD expr %prec ARITH_UNARYPLUS { $$ = $2; } + | ARITH_NUM +- ; ++ | ARITH_VAR { ++ char *p; ++ arith_t arith_val; ++ char *str_val; ++ if (lookupvar($1) == NULL) ++ setvarsafe($1, "0", 0); ++ str_val = lookupvar($1); ++ arith_val = strtoarith_t(str_val, &p, 0); ++ /* ++ * Conversion is successful only in case ++ * we've converted _all_ characters. ++ */ ++ if (*p != '\0') ++ yyerror("variable conversion error"); ++ $$ = arith_val; ++ } ++ | ARITH_VAR ARITH_ASSIGN expr { ++ if (arith_assign($1, $3) != 0) ++ yyerror("variable assignment error"); ++ $$ = $3; ++ } ++ | ARITH_VAR ARITH_ADDASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) + $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_SUBASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) - $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_MULASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) * $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_DIVASSIGN expr { ++ arith_t value; ++ if ($3 == 0) ++ yyerror("division by zero"); ++ value = atoarith_t(lookupvar($1)) / $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_REMASSIGN expr { ++ arith_t value; ++ if ($3 == 0) ++ yyerror("division by zero"); ++ value = atoarith_t(lookupvar($1)) % $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_RSHASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) >> $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_LSHASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) << $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_BANDASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) & $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_BXORASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) ^ $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++ | ARITH_VAR ARITH_BORASSIGN expr { ++ arith_t value; ++ value = atoarith_t(lookupvar($1)) | $3; ++ if (arith_assign($1, value) != 0) ++ yyerror("variable assignment error"); ++ $$ = value; ++ } ++; + %% ++ ++#define lstrlen(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3) ++ ++static int ++arith_assign(char *name, arith_t value) { ++ char *str; ++ int ret; ++ ++ str = (char *)ckmalloc(lstrlen(value)); ++ sprintf(str, ARITH_FORMAT_STR, value); ++ ret = setvarsafe(name, str, 0); ++ free(str); ++ return ret; ++} ++ + int + arith(s) + const char *s; +diff -ur a/src/arith_yylex.c b/src/arith_yylex.c +--- a/src/arith_yylex.c 2007-07-13 09:26:42.000000000 +0100 ++++ b/src/arith_yylex.c 2007-10-08 11:10:44.000000000 +0100 +@@ -32,12 +32,16 @@ + * SUCH DAMAGE. + */ + ++#include <ctype.h> + #include <stdlib.h> ++#include <string.h> ++#include "shell.h" + #include "arith.h" + #include "expand.h" + #include "error.h" ++#include "memalloc.h" ++#include "var.h" + +-extern int yylval; + extern const char *arith_buf, *arith_startbuf; + + int +@@ -45,6 +49,9 @@ + { + int value; + const char *buf = arith_buf; ++ char *temp; ++ char *var; ++ char save; + + for (;;) { + switch (*buf) { +@@ -54,10 +61,16 @@ + buf++; + continue; + default: +-err: + sh_error("arith: syntax error: \"%s\"", arith_startbuf); + /* NOTREACHED */ + case '0': ++ if (*++buf == 'x') ++ yylval.l_value = strtoll(buf+1, (char **)&arith_buf, 16); ++ else ++ yylval.l_value = strtoll(buf+1, (char **)&arith_buf, 8); ++ if (isalnum(*arith_buf) || *arith_buf == '_') ++ sh_error("arith: value does not fit base: \"%s\"", arith_buf); ++ return ARITH_NUM; + case '1': + case '2': + case '3': +@@ -67,11 +80,79 @@ + case '7': + case '8': + case '9': +- yylval = strtoll(buf, (char **) &arith_buf, 0); ++ yylval.l_value = strtoll(buf, (char **)&arith_buf, 10); ++ if (isalnum(*arith_buf) || *arith_buf == '_') ++ sh_error("arith: value does not fit base: \"%s\"", arith_buf); + return ARITH_NUM; ++ case 'A': ++ case 'B': ++ case 'C': ++ case 'D': ++ case 'E': ++ case 'F': ++ case 'G': ++ case 'H': ++ case 'I': ++ case 'J': ++ case 'K': ++ case 'L': ++ case 'M': ++ case 'N': ++ case 'O': ++ case 'P': ++ case 'Q': ++ case 'R': ++ case 'S': ++ case 'T': ++ case 'U': ++ case 'V': ++ case 'W': ++ case 'X': ++ case 'Y': ++ case 'Z': ++ case 'a': ++ case 'b': ++ case 'c': ++ case 'd': ++ case 'e': ++ case 'f': ++ case 'g': ++ case 'h': ++ case 'i': ++ case 'j': ++ case 'k': ++ case 'l': ++ case 'm': ++ case 'n': ++ case 'o': ++ case 'p': ++ case 'q': ++ case 'r': ++ case 's': ++ case 't': ++ case 'u': ++ case 'v': ++ case 'w': ++ case 'x': ++ case 'y': ++ case 'z': ++ temp = (char *)buf; ++ while ((*temp && ++ (isalnum(*temp) || *temp == '_'))) ++ temp++; ++ save = *temp; ++ *temp = '\0'; ++ if (lookupvar(buf) == NULL) ++ setvarsafe(buf, "0", 0); ++ var = (char *)ckmalloc(strlen(buf) + 1); ++ yylval.s_value = strcpy(var, buf); ++ *temp = save; ++ arith_buf = temp; ++ return ARITH_VAR; + case '=': + if (*++buf != '=') { +- goto err; ++ value = ARITH_ASSIGN; ++ goto out; + } + value = ARITH_EQ; + break; +@@ -94,7 +175,11 @@ + value = ARITH_LE; + break; + case '<': +- value = ARITH_LSHIFT; ++ if (*++buf != '=') { ++ value = ARITH_LSHIFT; ++ goto out; ++ } ++ value = ARITH_LSHASSIGN; + break; + default: + value = ARITH_LT; +@@ -102,19 +187,29 @@ + } + break; + case '|': +- if (*++buf != '|') { ++ switch (*++buf) { ++ case '|': + value = ARITH_BOR; ++ break; ++ case '=': ++ value = ARITH_BORASSIGN; ++ break; ++ default: ++ value = ARITH_OR; + goto out; + } +- value = ARITH_OR; +- break; + case '&': +- if (*++buf != '&') { ++ switch (*++buf) { ++ case '&': ++ value = ARITH_AND; ++ break; ++ case '=': ++ value = ARITH_BANDASSIGN; ++ break; ++ default: + value = ARITH_BAND; + goto out; + } +- value = ARITH_AND; +- break; + case '!': + if (*++buf != '=') { + value = ARITH_NOT; +@@ -132,25 +227,49 @@ + value = ARITH_RPAREN; + break; + case '*': +- value = ARITH_MUL; ++ if (*++buf != '=') { ++ value = ARITH_MUL; ++ goto out; ++ } ++ value = ARITH_MULASSIGN; + break; + case '/': +- value = ARITH_DIV; ++ if (*++buf != '=') { ++ value = ARITH_DIV; ++ goto out; ++ } ++ value = ARITH_DIVASSIGN; + break; + case '%': +- value = ARITH_REM; ++ if (*++buf != '=') { ++ value = ARITH_REM; ++ goto out; ++ } ++ value = ARITH_REMASSIGN; + break; + case '+': +- value = ARITH_ADD; ++ if (*++buf != '=') { ++ value = ARITH_ADD; ++ goto out; ++ } ++ value = ARITH_ADDASSIGN; + break; + case '-': +- value = ARITH_SUB; ++ if (*++buf != '=') { ++ value = ARITH_SUB; ++ goto out; ++ } ++ value = ARITH_SUBASSIGN; + break; + case '~': + value = ARITH_BNOT; + break; + case '^': +- value = ARITH_BXOR; ++ if (*++buf != '=') { ++ value = ARITH_BXOR; ++ goto out; ++ } ++ value = ARITH_BXORASSIGN; + break; + } + break; +diff -ur a/src/shell.h b/src/shell.h +--- a/src/shell.h 2007-07-13 09:26:43.000000000 +0100 ++++ b/src/shell.h 2007-10-08 11:04:29.000000000 +0100 +@@ -58,6 +58,15 @@ + #define BSD 1 + #endif + ++/* ++ * Type of used arithmetics. SUSv3 requires us to have at least signed long. ++ */ ++typedef long arith_t; ++#define ARITH_FORMAT_STR "%ld" ++#define atoarith_t(arg) strtol(arg, NULL, 0) ++#define strtoarith_t(nptr, endptr, base) strtol(nptr, endptr, base) ++ ++ + #ifndef DO_SHAREDVFORK + #if __NetBSD_Version__ >= 104000000 + #define DO_SHAREDVFORK diff --git a/app-shells/dash/files/digest-dash-0.5.4.1-r1 b/app-shells/dash/files/digest-dash-0.5.4.1-r1 new file mode 100644 index 000000000000..66aa426f23b4 --- /dev/null +++ b/app-shells/dash/files/digest-dash-0.5.4.1-r1 @@ -0,0 +1,6 @@ +MD5 bc457e490a589d2f87f2333616b67931 dash-0.5.4.tar.gz 212145 +RMD160 322fc2fffc5fddf4223d39c57eaeb9b4222303fa dash-0.5.4.tar.gz 212145 +SHA256 a9dc8f0237f632dd2c1bfeff80b1052e75fafaef0d767e3beab0bd8becced623 dash-0.5.4.tar.gz 212145 +MD5 304e8c13d012585314d73589e50dea38 dash_0.5.4-1.diff.gz 24636 +RMD160 5013da584493f1147a3be8a321985cf464da22af dash_0.5.4-1.diff.gz 24636 +SHA256 0214f40865c2b904710cadf84ece22c932bbeac85b0fa9e6c5e9abd46d36e453 dash_0.5.4-1.diff.gz 24636 |