summaryrefslogtreecommitdiffstats
path: root/bin/sh/arith_yacc.c
Commit message (Collapse)AuthorAgeFilesLines
* sh: Remove two redundant (uintmax_t) casts.jilles2014-08-201-3/+2
| | | | Submitted by: jmallett
* sh: Mask off shift distance (<< and >>) in arithmetic.jilles2014-08-151-2/+3
| | | | | | | | | | | In C, shift distances equal to or larger than the number of bits in the operand result in undefined behaviour. As part of eliminating undefined behaviour in arithmetic, mask off the distance like Java and JavaScript specify and C on x86 usually does. Assumption: conversion from unsigned to signed retains the two's complement bits. Assumption: uintmax_t has no padding bits.
* sh: Avoid undefined behaviour shifting negative values left in arithmetic.jilles2014-06-011-1/+1
| | | | With i386 base clang, arith_yacc.o remains unchanged.
* Add prototypes, ANSIfy functions definitions to reduce WARNS=6 output.charnier2012-01-251-1/+2
|
* sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic.jilles2011-11-081-3/+3
| | | | With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged.
* sh: Include <limits.h> instead of non-standard <sys/limits.h>.jilles2011-06-261-1/+1
|
* sh: Remove the "exp" builtin.jilles2011-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The "exp" builtin is undocumented, non-standard and not very useful. If exp's return value is not used, something like VAR=$(exp EXPRESSION) is equivalent to VAR=$((EXPRESSION)) except that errors in the expression are fatal and quoting special characters is not needed in the latter case. If exp's return value is used, something like if exp EXPRESSION >/dev/null can be replaced by if [ $((EXPRESSION)) -ne 0 ] with similar differences. The exp-run showed that "let" is close enough to bash's and ksh's builtin that removing it would break a few ports. Therefore, "let" remains in 9.x. PR: bin/104432 Exp-run done by: pav (with some other sh(1) changes)
* sh: Apply set -u to variables in arithmetic.jilles2011-05-041-0/+2
| | | | | | | Note that this only applies to variables that are actually used. Things like (0 && unsetvar) do not cause an error. Exp-run done by: pav (with some other sh(1) changes)
* sh: Fix some warnings in code for arithmetic expressions.jilles2011-03-051-2/+2
| | | | Submitted by: eadler
* sh: Detect dividing the smallest integer by -1.jilles2011-02-121-0/+2
| | | | | This overflows and on some architectures such as amd64 it generates SIGFPE. Generate an error on all architectures.
* sh: Import arithmetic expression code from dash.jilles2011-02-081-0/+376
New features: * proper lazy evaluation of || and && * ?: ternary operator * executable is considerably smaller (8K on i386) because lex and yacc are no longer used Differences from dash: * arith_t instead of intmax_t * imaxdiv() not used * unset or null variables default to 0 * let/exp builtin (undocumented, will probably be removed later) Obtained from: dash
OpenPOWER on IntegriCloud