aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/expr.c
AgeCommit message (Collapse)Author
2017-07-09Fix -Wformat compiler warning in expr.c.Elliott Hughes
Android forces -Wformat on for all source. toys/pending/expr.c:116:28: warning: field precision should have type 'int', but argument has type 'long' [-Wformat] ret->s = xmprintf("%.*s", m[1].rm_eo-m[1].rm_so, target+m[1].rm_so); ~~^~ ~~~~~~~~~~~~~~~~~~~~~
2016-03-20Posix requires "" to be false, and 00 should be false, and -0 should be false.Rob Landley
Fix memory leaks in regex. Simplify regex check (if we matched, subexpression had to match). Don't exit() from a command, set exitval and return.
2016-03-17expr cleanup: simplify get_str() and free returned allocations.Rob Landley
2016-03-16expr cleanup: traverse optargs with tok instead of incrementing optargs andRob Landley
copying itinto a second variable. Also add error message for empty ( )
2016-03-16Move whitespace and curly brackets around, move reference URLs to top of file,Rob Landley
eliminate syntax_error() function (just call error_exit() directly), eliminate advance() wrapper, pipe expected error messages in test to /dev/null
2016-03-16Fix type coercion bugs in expr.Andy Chu
All tests pass now; this fixes the 2 remaining failures, including a segfault. The structure of the code has changed a lot -- instead of having a tiny function per operator, we have eval_op() which does common type coercion and then evaluates the operator. I tried writing it a couple different ways, and this was the cleanest. The OPS table now contains the operator string, precedence level, signature for type coercion, and operator ID.
2016-03-16Fix the operator precedence in expr.Andy Chu
expr now uses the precedence table specified by POSIX, implemented using the "precedence climbing" algorithm. See the references at the top of eval_expr(). This fixes 3 of 4 failing tests. I also added more tests for correct behavior and for syntax errors. This includes a new test exposing a segfault, related to type coercion.
2015-01-01typo fixesElliott Hughes
2014-12-28Fluff out help text.Rob Landley
2014-12-02Note posix mailing list posting correcting a bug in the web version of the ↵Rob Landley
standard.
2014-12-01Refactor expr and add another test entry that works with TEST_HOST=1 but not ↵Rob Landley
with the one in pending.
2014-11-29expr.c: Added '==' sign into list of operations. Also added support for ↵Ashwini Sharma
regex pattern match.
2013-06-15Force 64 bit math in expr, from Daniel VerkampRob Landley
2013-06-05Start of expr, by Daniel Verkamp.Rob Landley