summaryrefslogtreecommitdiff
path: root/shell/math.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-12 23:29:57 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-12 23:29:57 +0100
commit03dad22f8a1b8b1410fdcccf69af1bb5cce4de7c (patch)
treeb134cbc7f0afbf76c54847624310e6a1d2774f83 /shell/math.c
parent045f4ad92c07434625e168bc8c37aa0e89f6e58e (diff)
downloadbusybox-w32-03dad22f8a1b8b1410fdcccf69af1bb5cce4de7c.tar.gz
busybox-w32-03dad22f8a1b8b1410fdcccf69af1bb5cce4de7c.tar.bz2
busybox-w32-03dad22f8a1b8b1410fdcccf69af1bb5cce4de7c.zip
hush: use ash's read builtin
function old new delta shell_builtin_read - 1000 +1000 set_local_var_from_halves - 24 +24 setvar2 - 7 +7 ... popstring 140 134 -6 ash_main 1375 1368 -7 setvar 184 174 -10 arith_set_local_var 36 - -36 builtin_read 1096 185 -911 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 5/23 up/down: 1038/-1007) Total: 31 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/math.c')
-rw-r--r--shell/math.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/shell/math.c b/shell/math.c
index 76159b299..91fb28f05 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -25,14 +25,6 @@
25 * 25 *
26 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 26 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
27 */ 27 */
28#include "libbb.h"
29#include "math.h"
30
31#define a_e_h_t arith_eval_hooks_t
32#define lookupvar (math_hooks->lookupvar)
33#define setvar (math_hooks->setvar)
34#define endofname (math_hooks->endofname)
35
36/* Copyright (c) 2001 Aaron Lehmann <aaronl@vitelus.com> 28/* Copyright (c) 2001 Aaron Lehmann <aaronl@vitelus.com>
37 29
38 Permission is hereby granted, free of charge, to any person obtaining 30 Permission is hereby granted, free of charge, to any person obtaining
@@ -99,7 +91,6 @@
99 * whitespace chars should be considered. Look below the "#include"s for a 91 * whitespace chars should be considered. Look below the "#include"s for a
100 * precompiler test. 92 * precompiler test.
101 */ 93 */
102
103/* 94/*
104 * Aug 26, 2001 Manuel Novoa III 95 * Aug 26, 2001 Manuel Novoa III
105 * 96 *
@@ -109,7 +100,6 @@
109 * modified slightly to take account of my changes to the code. 100 * modified slightly to take account of my changes to the code.
110 * 101 *
111 */ 102 */
112
113/* 103/*
114 * (C) 2003 Vladimir Oleynik <dzo@simtreas.ru> 104 * (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
115 * 105 *
@@ -126,6 +116,13 @@
126 * - protect $((num num)) as true zero expr (Manuel`s error) 116 * - protect $((num num)) as true zero expr (Manuel`s error)
127 * - always use special isspace(), see comment from bash ;-) 117 * - always use special isspace(), see comment from bash ;-)
128 */ 118 */
119#include "libbb.h"
120#include "math.h"
121
122#define a_e_h_t arith_eval_hooks_t
123#define lookupvar (math_hooks->lookupvar)
124#define setvar (math_hooks->setvar )
125#define endofname (math_hooks->endofname)
129 126
130#define arith_isspace(arithval) \ 127#define arith_isspace(arithval) \
131 (arithval == ' ' || arithval == '\n' || arithval == '\t') 128 (arithval == ' ' || arithval == '\n' || arithval == '\t')
@@ -420,7 +417,7 @@ arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr, a_e_h_t *math_hoo
420 } 417 }
421 /* save to shell variable */ 418 /* save to shell variable */
422 sprintf(buf, arith_t_fmt, rez); 419 sprintf(buf, arith_t_fmt, rez);
423 setvar(numptr_m1->var, buf, 0); 420 setvar(numptr_m1->var, buf);
424 /* after saving, make previous value for v++ or v-- */ 421 /* after saving, make previous value for v++ or v-- */
425 if (op == TOK_POST_INC) 422 if (op == TOK_POST_INC)
426 rez--; 423 rez--;