inp_search_closing_paren(), static scope instead of local C99 scope
This commit is contained in:
parent
3f52f88244
commit
be4ce38eff
|
|
@ -1786,6 +1786,49 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
|||
}
|
||||
|
||||
|
||||
// find closing paren
|
||||
static char *
|
||||
inp_search_closing_paren1(char *str_ptr2)
|
||||
{
|
||||
int count = 1;
|
||||
// assert(*str_ptr2 == '(')
|
||||
while (count != 0 && *str_ptr2 != '\0') {
|
||||
str_ptr2++;
|
||||
if (*str_ptr2 == '(')
|
||||
count++;
|
||||
if (*str_ptr2 == ')')
|
||||
count--;
|
||||
}
|
||||
if (count != 0)
|
||||
str_ptr2 = NULL;
|
||||
return str_ptr2;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
inp_search_for_closing_paren2(char *str_ptr2)
|
||||
{
|
||||
// find end paren ')'
|
||||
bool found_paren = FALSE;
|
||||
int count = 0;
|
||||
// assert(*str_ptr2 == '(')
|
||||
while (*str_ptr2 != '\0') {
|
||||
if (*str_ptr2 == '(') {
|
||||
count++;
|
||||
found_paren = TRUE;
|
||||
}
|
||||
if (*str_ptr2 == ')')
|
||||
count--;
|
||||
str_ptr2++;
|
||||
if (found_paren && count == 0)
|
||||
break;
|
||||
}
|
||||
if (found_paren && count != 0)
|
||||
str_ptr2 = NULL;
|
||||
return str_ptr2;
|
||||
}
|
||||
|
||||
|
||||
/* replace ternary operator 'conditional ? if : else' by function
|
||||
* 'ternary_fcn(conditional, if, else)'
|
||||
* in .param, .func, and .meas lines, if all is FALSE,
|
||||
|
|
@ -1871,21 +1914,6 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
|||
// get if
|
||||
str_ptr = skip_ws(question + 1);
|
||||
if (*str_ptr == '(') {
|
||||
// find closing paren
|
||||
char *inp_search_closing_paren1(char *str_ptr2) {
|
||||
int count = 1;
|
||||
// assert(*str_ptr2 == '(')
|
||||
while (count != 0 && *str_ptr2 != '\0') {
|
||||
str_ptr2++;
|
||||
if (*str_ptr2 == '(')
|
||||
count++;
|
||||
if (*str_ptr2 == ')')
|
||||
count--;
|
||||
}
|
||||
if (count != 0)
|
||||
str_ptr2 = NULL;
|
||||
return str_ptr2;
|
||||
}
|
||||
str_ptr2 = inp_search_closing_paren1(str_ptr /* +1 */);
|
||||
if (!str_ptr2) {
|
||||
fprintf(stderr, "ERROR: problem parsing 'if' of ternary string %s!\n", line);
|
||||
|
|
@ -1914,26 +1942,6 @@ inp_fix_ternary_operator_str(char *line, bool all)
|
|||
str_ptr = skip_ws(colon + 1);
|
||||
/* ... : (else) */
|
||||
if (*str_ptr == '(') {
|
||||
char *inp_search_for_closing_paren2(char *str_ptr2) {
|
||||
// find end paren ')'
|
||||
bool found_paren = FALSE;
|
||||
int count = 0;
|
||||
// assert(*str_ptr2 == '(')
|
||||
while (*str_ptr2 != '\0') {
|
||||
if (*str_ptr2 == '(') {
|
||||
count++;
|
||||
found_paren = TRUE;
|
||||
}
|
||||
if (*str_ptr2 == ')')
|
||||
count--;
|
||||
str_ptr2++;
|
||||
if (found_paren && count == 0)
|
||||
break;
|
||||
}
|
||||
if (found_paren && count != 0)
|
||||
str_ptr2 = NULL;
|
||||
return str_ptr2;
|
||||
}
|
||||
str_ptr2 = inp_search_for_closing_paren2(str_ptr);
|
||||
if (!str_ptr2) {
|
||||
fprintf(stderr, "ERROR: problem parsing ternary line %s!\n", line);
|
||||
|
|
|
|||
Loading…
Reference in New Issue