← Commit list

a7f1a3654

Denys Vlasenko
Denys Vlasenko
2018-12-10
SUCCESS Duration: 151s

Subject

bc: simplify bc_program_len()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/bc.c+7 -5
@@ -6254,12 +6254,14 @@ static unsigned long bc_program_scale(BcNum *n)
static unsigned long bc_program_len(BcNum *n)
{
- unsigned long len = n->len;
- size_t i;
-
- if (n->rdx != n->len) return len;
- for (i = n->len - 1; i < n->len && n->num[i] == 0; --len, --i);
+ size_t len = n->len;
+ if (n->rdx != len) return len;
+ for (;;) {
+ if (len == 0) break;
+ len--;
+ if (n->num[len] != 0) break;
+ }
return len;
}