| 2382 | */ |
| 2383 | |
| 2384 | void balance_parentheses( char const * * s_, char const * * string, |
| 2385 | VAR_PARSE_GROUP * out) |
| 2386 | { |
| 2387 | int32_t depth = 1; |
| 2388 | char const * s = *s_; |
| 2389 | for ( ; ; ) |
| 2390 | { |
| 2391 | if ( try_parse_variable( &s, string, out ) ) { } |
| 2392 | else if ( s[ 0 ] == ':' || s[ 0 ] == '[' ) |
| 2393 | { |
| 2394 | parse_error( "unbalanced parentheses" ); |
| 2395 | ++s; |
| 2396 | } |
| 2397 | else if ( s[ 0 ] == '\0' ) |
| 2398 | { |
| 2399 | parse_error( "unbalanced parentheses" ); |
| 2400 | break; |
| 2401 | } |
| 2402 | else if ( s[ 0 ] == ')' ) |
| 2403 | { |
| 2404 | ++s; |
| 2405 | if ( --depth == 0 ) break; |
| 2406 | } |
| 2407 | else if ( s[ 0 ] == '(' ) |
| 2408 | { |
| 2409 | ++depth; |
| 2410 | ++s; |
| 2411 | } |
| 2412 | else |
| 2413 | ++s; |
| 2414 | } |
| 2415 | *s_ = s; |
| 2416 | } |
| 2417 | |
| 2418 | |
| 2419 | /* |
no test coverage detected