inp_search_closing_paren(), finally fold them
This commit is contained in:
parent
a683431d57
commit
246dc2e614
|
|
@ -1788,26 +1788,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
|||
|
||||
// find closing paren
|
||||
static char *
|
||||
inp_search_closing_paren1(char *s)
|
||||
{
|
||||
int count = 0;
|
||||
// assert(*s == '(')
|
||||
while (*s) {
|
||||
if (*s == '(')
|
||||
count++;
|
||||
if (*s == ')')
|
||||
count--;
|
||||
if (count == 0)
|
||||
return s + 1;
|
||||
s++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
inp_search_for_closing_paren2(char *s)
|
||||
inp_search_closing_paren(char *s)
|
||||
{
|
||||
int count = 0;
|
||||
// assert(*s == '(')
|
||||
|
|
@ -1910,7 +1891,7 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
|||
// get if
|
||||
str_ptr = skip_ws(question + 1);
|
||||
if (*str_ptr == '(') {
|
||||
colon = inp_search_closing_paren1(str_ptr);
|
||||
colon = inp_search_closing_paren(str_ptr);
|
||||
if (!colon) {
|
||||
fprintf(stderr, "ERROR: problem parsing 'if' of ternary string %s!\n", line);
|
||||
controlled_exit(EXIT_FAILURE);
|
||||
|
|
@ -1937,7 +1918,7 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
|||
str_ptr = skip_ws(colon + 1);
|
||||
/* ... : (else) */
|
||||
if (*str_ptr == '(') {
|
||||
str_ptr2 = inp_search_for_closing_paren2(str_ptr);
|
||||
str_ptr2 = inp_search_closing_paren(str_ptr);
|
||||
if (!str_ptr2) {
|
||||
fprintf(stderr, "ERROR: problem parsing ternary line %s!\n", line);
|
||||
controlled_exit(EXIT_FAILURE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue