mirror of
https://github.com/sheumann/hush.git
synced 2024-07-04 21:29:34 +00:00
Remove C99isms in hush debug code to address compilation errors when debugging stuff enabled.
This commit is contained in:
parent
2669183517
commit
a3426d2782
93
shell/hush.c
93
shell/hush.c
@ -1870,7 +1870,7 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (flg_export == -1) { // "&& cur->flg_export" ?
|
if (flg_export == -1) { // "&& cur->flg_export" ?
|
||||||
debug_printf_env(("%s: unsetenv '%s'\n", __func__, str));
|
debug_printf_env(("%s: unsetenv '%s'\n", "set_local_var", str));
|
||||||
*eq_sign = '\0';
|
*eq_sign = '\0';
|
||||||
unsetenv(str);
|
unsetenv(str);
|
||||||
*eq_sign = '=';
|
*eq_sign = '=';
|
||||||
@ -1940,7 +1940,7 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
|
|||||||
cur->flg_export = 0;
|
cur->flg_export = 0;
|
||||||
/* unsetenv was already done */
|
/* unsetenv was already done */
|
||||||
} else {
|
} else {
|
||||||
debug_printf_env(("%s: putenv '%s'\n", __func__, cur->varstr));
|
debug_printf_env(("%s: putenv '%s'\n", "set_local_var", cur->varstr));
|
||||||
return putenv(cur->varstr);
|
return putenv(cur->varstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1969,7 +1969,7 @@ static int unset_local_var_len(const char *name, int name_len)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
*var_pp = cur->next;
|
*var_pp = cur->next;
|
||||||
debug_printf_env(("%s: unsetenv '%s'\n", __func__, cur->varstr));
|
debug_printf_env(("%s: unsetenv '%s'\n", "unset_local_var_len", cur->varstr));
|
||||||
bb_unsetenv(cur->varstr);
|
bb_unsetenv(cur->varstr);
|
||||||
if (name_len == 3 && cur->varstr[0] == 'P' && cur->varstr[1] == 'S')
|
if (name_len == 3 && cur->varstr[0] == 'P' && cur->varstr[1] == 'S')
|
||||||
cmdedit_update_prompt();
|
cmdedit_update_prompt();
|
||||||
@ -2022,10 +2022,10 @@ static void add_vars(struct variable *var)
|
|||||||
var->next = G.top_var;
|
var->next = G.top_var;
|
||||||
G.top_var = var;
|
G.top_var = var;
|
||||||
if (var->flg_export) {
|
if (var->flg_export) {
|
||||||
debug_printf_env(("%s: restoring exported '%s'\n", __func__, var->varstr));
|
debug_printf_env(("%s: restoring exported '%s'\n", "add_vars", var->varstr));
|
||||||
putenv(var->varstr);
|
putenv(var->varstr);
|
||||||
} else {
|
} else {
|
||||||
debug_printf_env(("%s: restoring variable '%s'\n", __func__, var->varstr));
|
debug_printf_env(("%s: restoring variable '%s'\n", "add_vars", var->varstr));
|
||||||
}
|
}
|
||||||
var = next;
|
var = next;
|
||||||
}
|
}
|
||||||
@ -2050,7 +2050,7 @@ static struct variable *set_vars_and_save_old(char **strings)
|
|||||||
if (var_pp) {
|
if (var_pp) {
|
||||||
/* Remove variable from global linked list */
|
/* Remove variable from global linked list */
|
||||||
var_p = *var_pp;
|
var_p = *var_pp;
|
||||||
debug_printf_env(("%s: removing '%s'\n", __func__, var_p->varstr));
|
debug_printf_env(("%s: removing '%s'\n", "set_vars_and_save_old", var_p->varstr));
|
||||||
*var_pp = var_p->next;
|
*var_pp = var_p->next;
|
||||||
/* Add it to returned list */
|
/* Add it to returned list */
|
||||||
var_p->next = old;
|
var_p->next = old;
|
||||||
@ -2910,41 +2910,9 @@ static void free_pipe_list(struct pipe *pi)
|
|||||||
#ifndef debug_print_tree
|
#ifndef debug_print_tree
|
||||||
static void debug_print_tree(struct pipe *pi, int lvl)
|
static void debug_print_tree(struct pipe *pi, int lvl)
|
||||||
{
|
{
|
||||||
static const char *const PIPE[] = {
|
static bool initialized = 0;
|
||||||
[PIPE_SEQ] = "SEQ",
|
static const char *PIPE[PIPE_BG + 1];
|
||||||
[PIPE_AND] = "AND",
|
static const char *RES[RES_SNTX + 1];
|
||||||
[PIPE_OR ] = "OR" ,
|
|
||||||
[PIPE_BG ] = "BG" ,
|
|
||||||
};
|
|
||||||
static const char *RES[] = {
|
|
||||||
[RES_NONE ] = "NONE" ,
|
|
||||||
# if ENABLE_HUSH_IF
|
|
||||||
[RES_IF ] = "IF" ,
|
|
||||||
[RES_THEN ] = "THEN" ,
|
|
||||||
[RES_ELIF ] = "ELIF" ,
|
|
||||||
[RES_ELSE ] = "ELSE" ,
|
|
||||||
[RES_FI ] = "FI" ,
|
|
||||||
# endif
|
|
||||||
# if ENABLE_HUSH_LOOPS
|
|
||||||
[RES_FOR ] = "FOR" ,
|
|
||||||
[RES_WHILE] = "WHILE",
|
|
||||||
[RES_UNTIL] = "UNTIL",
|
|
||||||
[RES_DO ] = "DO" ,
|
|
||||||
[RES_DONE ] = "DONE" ,
|
|
||||||
# endif
|
|
||||||
# if ENABLE_HUSH_LOOPS || ENABLE_HUSH_CASE
|
|
||||||
[RES_IN ] = "IN" ,
|
|
||||||
# endif
|
|
||||||
# if ENABLE_HUSH_CASE
|
|
||||||
[RES_CASE ] = "CASE" ,
|
|
||||||
[RES_CASE_IN ] = "CASE_IN" ,
|
|
||||||
[RES_MATCH] = "MATCH",
|
|
||||||
[RES_CASE_BODY] = "CASE_BODY",
|
|
||||||
[RES_ESAC ] = "ESAC" ,
|
|
||||||
# endif
|
|
||||||
[RES_XXXX ] = "XXXX" ,
|
|
||||||
[RES_SNTX ] = "SNTX" ,
|
|
||||||
};
|
|
||||||
static const char *const CMDTYPE[] = {
|
static const char *const CMDTYPE[] = {
|
||||||
"{}",
|
"{}",
|
||||||
"()",
|
"()",
|
||||||
@ -2956,6 +2924,43 @@ static void debug_print_tree(struct pipe *pi, int lvl)
|
|||||||
|
|
||||||
int pin, prn;
|
int pin, prn;
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
PIPE[PIPE_SEQ] = "SEQ";
|
||||||
|
PIPE[PIPE_AND] = "AND";
|
||||||
|
PIPE[PIPE_OR ] = "OR";
|
||||||
|
PIPE[PIPE_BG ] = "BG";
|
||||||
|
|
||||||
|
RES[RES_NONE ] = "NONE" ,
|
||||||
|
# if ENABLE_HUSH_IF
|
||||||
|
RES[RES_IF ] = "IF" ,
|
||||||
|
RES[RES_THEN ] = "THEN" ,
|
||||||
|
RES[RES_ELIF ] = "ELIF" ,
|
||||||
|
RES[RES_ELSE ] = "ELSE" ,
|
||||||
|
RES[RES_FI ] = "FI" ,
|
||||||
|
# endif
|
||||||
|
# if ENABLE_HUSH_LOOPS
|
||||||
|
RES[RES_FOR ] = "FOR" ,
|
||||||
|
RES[RES_WHILE] = "WHILE",
|
||||||
|
RES[RES_UNTIL] = "UNTIL",
|
||||||
|
RES[RES_DO ] = "DO" ,
|
||||||
|
RES[RES_DONE ] = "DONE" ,
|
||||||
|
# endif
|
||||||
|
# if ENABLE_HUSH_LOOPS || ENABLE_HUSH_CASE
|
||||||
|
RES[RES_IN ] = "IN" ,
|
||||||
|
# endif
|
||||||
|
# if ENABLE_HUSH_CASE
|
||||||
|
RES[RES_CASE ] = "CASE" ,
|
||||||
|
RES[RES_CASE_IN ] = "CASE_IN" ,
|
||||||
|
RES[RES_MATCH] = "MATCH",
|
||||||
|
RES[RES_CASE_BODY] = "CASE_BODY",
|
||||||
|
RES[RES_ESAC ] = "ESAC" ,
|
||||||
|
# endif
|
||||||
|
RES[RES_XXXX ] = "XXXX" ,
|
||||||
|
RES[RES_SNTX ] = "SNTX" ,
|
||||||
|
|
||||||
|
initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
pin = 0;
|
pin = 0;
|
||||||
while (pi) {
|
while (pi) {
|
||||||
fdprintf(STDERR_FILENO, "%*spipe %d res_word=%s followup=%d %s\n", lvl*2, "",
|
fdprintf(STDERR_FILENO, "%*spipe %d res_word=%s followup=%d %s\n", lvl*2, "",
|
||||||
@ -8543,7 +8548,7 @@ static int FAST_FUNC builtin_exec(char **argv)
|
|||||||
|
|
||||||
static int FAST_FUNC builtin_exit(char **argv)
|
static int FAST_FUNC builtin_exit(char **argv)
|
||||||
{
|
{
|
||||||
debug_printf_exec(("%s()\n", __func__));
|
debug_printf_exec(("%s()\n", "builtin_exit"));
|
||||||
|
|
||||||
/* interactive bash:
|
/* interactive bash:
|
||||||
* # trap "echo EEE" EXIT
|
* # trap "echo EEE" EXIT
|
||||||
@ -8609,7 +8614,7 @@ static void helper_export_local(char **argv, int exp, int lvl)
|
|||||||
/* export -n NAME (without =VALUE) */
|
/* export -n NAME (without =VALUE) */
|
||||||
if (var) {
|
if (var) {
|
||||||
var->flg_export = 0;
|
var->flg_export = 0;
|
||||||
debug_printf_env(("%s: unsetenv '%s'\n", __func__, name));
|
debug_printf_env(("%s: unsetenv '%s'\n", "helper_export_local", name));
|
||||||
unsetenv(name);
|
unsetenv(name);
|
||||||
} /* else: export -n NOT_EXISTING_VAR: no-op */
|
} /* else: export -n NOT_EXISTING_VAR: no-op */
|
||||||
continue;
|
continue;
|
||||||
@ -8618,7 +8623,7 @@ static void helper_export_local(char **argv, int exp, int lvl)
|
|||||||
/* export NAME (without =VALUE) */
|
/* export NAME (without =VALUE) */
|
||||||
if (var) {
|
if (var) {
|
||||||
var->flg_export = 1;
|
var->flg_export = 1;
|
||||||
debug_printf_env(("%s: putenv '%s'\n", __func__, var->varstr));
|
debug_printf_env(("%s: putenv '%s'\n", "helper_export_local", var->varstr));
|
||||||
putenv(var->varstr);
|
putenv(var->varstr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user