← Commit list

3f940c9c7

Denys Vlasenko
Denys Vlasenko
2018-12-18
SUCCESS Duration: 152s

Subject

bc: shrink bc_program_index()

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+11 -4
@@ -5256,11 +5256,18 @@ exec_err:
static size_t bc_program_index(char *code, size_t *bgn)
{
- char amt = code[(*bgn)++], i = 0;
- size_t res = 0;
+ unsigned char *bytes = (void*)(code + *bgn);
+ unsigned amt;
+ unsigned i;
+ size_t res;
+
+ amt = *bytes++;
+ *bgn += amt + 1;
- for (; i < amt; ++i, ++(*bgn))
- res |= (((size_t)((int) code[*bgn]) & UCHAR_MAX) << (i * CHAR_BIT));
+ amt *= 8;
+ res = 0;
+ for (i = 0; i < amt; i += 8)
+ res |= (size_t)(*bytes++) << i;
return res;
}