Control: tags -1 + patch On Tue, 09 May 2017 23:48:21 +0200 Gilles Filippini <p...@debian.org> wrote: > Package: csh > Version: 20110502-2.2+b1 > Severity: important > > bsd-csh returns wrong results for simple arithmetic expressions such as 'a - > b + c': > $ /bin/bsd-csh -c '@ var = 10 - 2 + 3; echo $var # should be 11' > 5 # should be 11 > > It seems it operates from the right to the left, computing a - (b + c) > instead of (a - b) + c. > > tcsh gives the correct result: > $ /bin/tcsh -c '@ var = 10 - 2 + 3; echo $var # should be 11' > 11 # should be 11
This goes for consecutive *, /, % as well: $ /bin/bsd-csh -c "@ var = 100 / 10 / 5; echo \$var # should be 2" 50 # should be 2 Please find attached a very simple patch proposal. Thanks, _g.
diff -Nru csh-20110502/debian/changelog csh-20110502/debian/changelog --- csh-20110502/debian/changelog 2016-09-30 18:25:06.000000000 +0200 +++ csh-20110502/debian/changelog 2017-05-10 17:17:55.000000000 +0200 @@ -1,3 +1,11 @@ +csh (20110502-2.3) UNRELEASED; urgency=medium + + * Non-maintainer upload + * Add patches/13_fix_arithmetic_precedence.diff to fix precedence for + consecutive ADDOP (+, -) or MULOP (*, /, %) (closes: #862221) + + -- Gilles Filippini <p...@debian.org> Wed, 10 May 2017 17:17:55 +0200 + csh (20110502-2.2) unstable; urgency=medium * Non-maintainer upload. diff -Nru csh-20110502/debian/patches/13_fix_arithmetic_precedence.diff csh-20110502/debian/patches/13_fix_arithmetic_precedence.diff --- csh-20110502/debian/patches/13_fix_arithmetic_precedence.diff 1970-01-01 01:00:00.000000000 +0100 +++ csh-20110502/debian/patches/13_fix_arithmetic_precedence.diff 2017-05-10 17:17:55.000000000 +0200 @@ -0,0 +1,51 @@ +Description: Fix arithmetic precedence for consecutive ADDOP or MULOP +Author: Gilles Filippini <p...@debian.org> +Bug-Debian: https://bugs.debian.org/862221 +Index: csh-20110502/exp.c +=================================================================== +--- csh-20110502.orig/exp.c ++++ csh-20110502/exp.c +@@ -317,10 +317,10 @@ exp4(Char ***vp, bool ignore) + #ifdef EDEBUG + etracc("exp4 p1", p1, vp); + #endif +- if (isa(**vp, ADDOP)) { ++ while (isa(**vp, ADDOP)) { + Char *op = *(*vp)++; + +- p2 = exp4(vp, ignore); ++ p2 = exp5(vp, ignore); + #ifdef EDEBUG + etracc("exp4 p2", p2, vp); + #endif +@@ -337,7 +337,7 @@ exp4(Char ***vp, bool ignore) + } + xfree((ptr_t) p1); + xfree((ptr_t) p2); +- return (putn(i)); ++ p1 = putn(i); + } + return (p1); + } +@@ -352,10 +352,10 @@ exp5(Char ***vp, bool ignore) + #ifdef EDEBUG + etracc("exp5 p1", p1, vp); + #endif +- if (isa(**vp, MULOP)) { ++ while (isa(**vp, MULOP)) { + Char *op = *(*vp)++; + +- p2 = exp5(vp, ignore); ++ p2 = exp6(vp, ignore); + #ifdef EDEBUG + etracc("exp5 p2", p2, vp); + #endif +@@ -382,7 +382,7 @@ exp5(Char ***vp, bool ignore) + } + xfree((ptr_t) p1); + xfree((ptr_t) p2); +- return (putn(i)); ++ p1 = putn(i); + } + return (p1); + } diff -Nru csh-20110502/debian/patches/series csh-20110502/debian/patches/series --- csh-20110502/debian/patches/series 2016-09-30 18:23:06.000000000 +0200 +++ csh-20110502/debian/patches/series 2017-05-10 17:17:55.000000000 +0200 @@ -10,3 +10,4 @@ 10_groff_no_sgr.diff 11_groff_schar.diff 12_glibc_union_wait.diff +13_fix_arithmetic_precedence.diff
signature.asc
Description: OpenPGP digital signature