inp_fix_ternary_operator_str, use a local variable to improve readability
This commit is contained in:
parent
7452971177
commit
dfcbc52ee6
|
|
@ -1836,7 +1836,7 @@ static char*
|
||||||
inp_fix_ternary_operator_str(char *line, bool all)
|
inp_fix_ternary_operator_str(char *line, bool all)
|
||||||
{
|
{
|
||||||
char *conditional, *if_str, *else_str, *question, *colon, keep, *str_ptr, *str_ptr2, *new_str;
|
char *conditional, *if_str, *else_str, *question, *colon, keep, *str_ptr, *str_ptr2, *new_str;
|
||||||
char *end_str = NULL, *beg_str = NULL;
|
char *end_str, *beg_str = NULL;
|
||||||
|
|
||||||
if (!strchr(line, '?') && !strchr(line, ':'))
|
if (!strchr(line, '?') && !strchr(line, ':'))
|
||||||
return line;
|
return line;
|
||||||
|
|
@ -1925,25 +1925,27 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
||||||
str_ptr = skip_ws(colon + 1);
|
str_ptr = skip_ws(colon + 1);
|
||||||
/* ... : (else) */
|
/* ... : (else) */
|
||||||
if (*str_ptr == '(') {
|
if (*str_ptr == '(') {
|
||||||
str_ptr2 = inp_search_closing_paren(str_ptr);
|
char *s = inp_search_closing_paren(str_ptr);
|
||||||
if (!str_ptr2) {
|
if (!s) {
|
||||||
fprintf(stderr, "ERROR: problem parsing ternary line %s!\n", line);
|
fprintf(stderr, "ERROR: problem parsing ternary line %s!\n", line);
|
||||||
controlled_exit(EXIT_FAILURE);
|
controlled_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (*str_ptr2 == '\0')
|
if (*s == '\0')
|
||||||
str_ptr2--;
|
s--;
|
||||||
else_str = inp_fix_ternary_operator_str(copy_substring(str_ptr, str_ptr2), all);
|
else_str = inp_fix_ternary_operator_str(copy_substring(str_ptr, s), all);
|
||||||
if ((*str_ptr2 != '}') && (*str_ptr2 != ')'))
|
if ((*s != '}') && (*s != ')'))
|
||||||
end_str = inp_fix_ternary_operator_str(strdup(str_ptr2+1), all);
|
end_str = inp_fix_ternary_operator_str(strdup(s+1), all);
|
||||||
else
|
else
|
||||||
end_str = strdup(str_ptr2);
|
end_str = strdup(s);
|
||||||
/* ... : else */
|
/* ... : else */
|
||||||
} else {
|
} else {
|
||||||
if ((str_ptr2 = strchr(str_ptr, '}')) != NULL) {
|
char *s = strchr(str_ptr, '}');
|
||||||
else_str = inp_fix_ternary_operator_str(copy_substring(str_ptr, str_ptr2), all);
|
if (s) {
|
||||||
end_str = strdup(str_ptr2);
|
else_str = inp_fix_ternary_operator_str(copy_substring(str_ptr, s), all);
|
||||||
|
end_str = strdup(s);
|
||||||
} else {
|
} else {
|
||||||
else_str = inp_fix_ternary_operator_str(strdup(str_ptr), all);
|
else_str = inp_fix_ternary_operator_str(strdup(str_ptr), all);
|
||||||
|
end_str = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue