← Commit list

ee0775dd1

Denys Vlasenko
Denys Vlasenko
2010-05-20
FAILED Duration: 29s

Subject

hush: small code shrink

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 →

shell/hush.c+6 -7
@@ -2569,7 +2569,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char
default: /* <SPECIAL_VAR_SYMBOL>varname<SPECIAL_VAR_SYMBOL> */
case_default: {
char *var = arg;
- bool exp_len;
+ char exp_len; /* '#' if it's ${#var} */
char exp_op;
char exp_save = exp_save; /* for compiler */
char *exp_saveptr = exp_saveptr; /* points to expansion operator */
@@ -2579,12 +2579,11 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char
arg[0] = first_ch & 0x7f;
/* prepare for expansions */
- exp_len = false;
exp_op = 0;
- if (var[0] == '#') {
+ exp_len = var[0];
+ if (exp_len == '#') {
/* handle length expansion ${#var} */
- exp_len = true;
- ++var;
+ var++;
} else {
/* maybe handle parameter expansion */
exp_saveptr = var + strcspn(var, ":-=+?%#");
@@ -2609,8 +2608,8 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char
val = get_local_var_value(var);
/* handle any expansions */
- if (exp_len) {
- debug_printf_expand("expand: length of '%s' = ", val);
+ if (exp_len == '#') {
+ debug_printf_expand("expand: length(%s)=", val);
val = utoa(val ? strlen(val) : 0);
debug_printf_expand("%s\n", val);
} else if (exp_op) {