* MAX_NEGATIVE_INT / -1 = MAX_POSITIVE_INT+1
* and thus is not representable.
* Some CPUs segfault trying such op.
- * Others overfolw MAX_POSITIVE_INT+1 to
+ * Others overflow MAX_POSITIVE_INT+1 to
* MAX_NEGATIVE_INT (0x7fff+1 = 0x8000).
* Make sure to at least not SEGV here:
*/
}
/* Should be an operator */
+
+ /* Special case: NUM-- and NUM++ are not recognized if NUM
+ * is a literal number, not a variable. IOW:
+ * "a+++v" is a++ + v.
+ * "7+++v" is 7 + ++v, not 7++ + v.
+ */
+ if (lasttok == TOK_NUM && !numstackptr[-1].var /* number literal */
+ && (expr[0] == '+' || expr[0] == '-')
+ && (expr[1] == expr[0])
+ ) {
+ //bb_error_msg("special %c%c", expr[0], expr[0]);
+ op = (expr[0] == '+' ? TOK_ADD : TOK_SUB);
+ expr += 1;
+ goto tok_found1;
+ }
+
p = op_tokens;
while (1) {
-// TODO: bash allows 7+++v, treats it as 7 + ++v
-// we treat it as 7++ + v and reject
/* Compare expr to current op_tokens[] element */
const char *e = expr;
while (1) {
}
tok_found:
op = p[1]; /* fetch TOK_foo value */
+ tok_found1:
/* NB: expr now points past the operator */
/* post grammar: a++ reduce to num */
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE