Scan a block scalar.
(parser *yaml_parser_t, token *yaml_token_t, literal bool)
| 2188 | |
| 2189 | // Scan a block scalar. |
| 2190 | func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { |
| 2191 | // Eat the indicator '|' or '>'. |
| 2192 | start_mark := parser.mark |
| 2193 | skip(parser) |
| 2194 | |
| 2195 | // Scan the additional block scalar indicators. |
| 2196 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 2197 | return false |
| 2198 | } |
| 2199 | |
| 2200 | // Check for a chomping indicator. |
| 2201 | var chomping, increment int |
| 2202 | if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { |
| 2203 | // Set the chomping method and eat the indicator. |
| 2204 | if parser.buffer[parser.buffer_pos] == '+' { |
| 2205 | chomping = +1 |
| 2206 | } else { |
| 2207 | chomping = -1 |
| 2208 | } |
| 2209 | skip(parser) |
| 2210 | |
| 2211 | // Check for an indentation indicator. |
| 2212 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 2213 | return false |
| 2214 | } |
| 2215 | if is_digit(parser.buffer, parser.buffer_pos) { |
| 2216 | // Check that the indentation is greater than 0. |
| 2217 | if parser.buffer[parser.buffer_pos] == '0' { |
| 2218 | yaml_parser_set_scanner_error(parser, "while scanning a block scalar", |
| 2219 | start_mark, "found an indentation indicator equal to 0") |
| 2220 | return false |
| 2221 | } |
| 2222 | |
| 2223 | // Get the indentation level and eat the indicator. |
| 2224 | increment = as_digit(parser.buffer, parser.buffer_pos) |
| 2225 | skip(parser) |
| 2226 | } |
| 2227 | |
| 2228 | } else if is_digit(parser.buffer, parser.buffer_pos) { |
| 2229 | // Do the same as above, but in the opposite order. |
| 2230 | |
| 2231 | if parser.buffer[parser.buffer_pos] == '0' { |
| 2232 | yaml_parser_set_scanner_error(parser, "while scanning a block scalar", |
| 2233 | start_mark, "found an indentation indicator equal to 0") |
| 2234 | return false |
| 2235 | } |
| 2236 | increment = as_digit(parser.buffer, parser.buffer_pos) |
| 2237 | skip(parser) |
| 2238 | |
| 2239 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 2240 | return false |
| 2241 | } |
| 2242 | if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { |
| 2243 | if parser.buffer[parser.buffer_pos] == '+' { |
| 2244 | chomping = +1 |
| 2245 | } else { |
| 2246 | chomping = -1 |
| 2247 | } |
no test coverage detected