Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-06-18 19:58:22 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-06-18 20:03:05 +0300
commit8309c9159f7d8ee8b0f6f4b401750c5a03a4b0b9 (patch)
tree38f2b3ce36fc8b11e3960e1fef3e49f39f55744a
parentb61fd8ec5a2e3b728c05a72b603fb4255b1022da (diff)
shell/math: eliminate redundant endofname()
function old new delta evaluate_string 1486 1498 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/math.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/shell/math.c b/shell/math.c
index fee325307..cb702b7f4 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -265,19 +265,18 @@ static arith_t
evaluate_string(arith_state_t *math_state, const char *expr);
static arith_t
-arith_lookup_val(arith_state_t *math_state, const char *name)
+arith_lookup_val(arith_state_t *math_state, const char *name, char *endname)
{
char c;
const char *p;
- char *e = (char*)endofname(name);
- c = *e;
- *e = '\0';
+ c = *endname;
+ *endname = '\0';
p = math_state->lookupvar(name);
- *e = c;
+ *endname = c;
if (p) {
arith_t val;
- size_t len = e - name;
+ size_t len = endname - name;
remembered_name *cur;
remembered_name remember;
@@ -685,9 +684,10 @@ evaluate_string(arith_state_t *math_state, const char *expr)
|| expr[1] == '=' /* or "==..." */
) {
/* Evaluate variable to value */
- numstackptr->val = arith_lookup_val(math_state, numstackptr->var_name);
+ arith_t val = arith_lookup_val(math_state, numstackptr->var_name, (char*)p);
if (math_state->errmsg)
- return numstackptr->val; /* -1 */
+ return val; /* -1 */
+ numstackptr->val = val;
}
} else {
dbg("[%d] var:IGNORED", (int)(numstackptr - numstack));