| 2161 | */ |
| 2162 | |
| 2163 | void balance_parentheses( char const * * s_, char const * * string, |
| 2164 | VAR_PARSE_GROUP * out) |
| 2165 | { |
| 2166 | int depth = 1; |
| 2167 | char const * s = *s_; |
| 2168 | for ( ; ; ) |
| 2169 | { |
| 2170 | if ( try_parse_variable( &s, string, out ) ) { } |
| 2171 | else if ( s[ 0 ] == ':' || s[ 0 ] == '[' ) |
| 2172 | { |
| 2173 | parse_error( "unbalanced parentheses" ); |
| 2174 | ++s; |
| 2175 | } |
| 2176 | else if ( s[ 0 ] == '\0' ) |
| 2177 | { |
| 2178 | parse_error( "unbalanced parentheses" ); |
| 2179 | break; |
| 2180 | } |
| 2181 | else if ( s[ 0 ] == ')' ) |
| 2182 | { |
| 2183 | ++s; |
| 2184 | if ( --depth == 0 ) break; |
| 2185 | } |
| 2186 | else if ( s[ 0 ] == '(' ) |
| 2187 | { |
| 2188 | ++depth; |
| 2189 | ++s; |
| 2190 | } |
| 2191 | else |
| 2192 | ++s; |
| 2193 | } |
| 2194 | *s_ = s; |
| 2195 | } |
| 2196 | |
| 2197 | |
| 2198 | /* |
no test coverage detected