MCPcopy
hub / github.com/go-yaml/yaml / yaml_parser_scan_block_scalar_breaks

Function yaml_parser_scan_block_scalar_breaks

scannerc.go:2381–2432  ·  view source on GitHub ↗

Scan indentation spaces and line breaks for a block scalar. Determine the indentation level if needed.

(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t)

Source from the content-addressed store, hash-verified

2379// Scan indentation spaces and line breaks for a block scalar. Determine the
2380// indentation level if needed.
2381func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool {
2382 *end_mark = parser.mark
2383
2384 // Eat the indentation spaces and line breaks.
2385 max_indent := 0
2386 for {
2387 // Eat the indentation spaces.
2388 if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
2389 return false
2390 }
2391 for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) {
2392 skip(parser)
2393 if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
2394 return false
2395 }
2396 }
2397 if parser.mark.column > max_indent {
2398 max_indent = parser.mark.column
2399 }
2400
2401 // Check for a tab character messing the indentation.
2402 if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) {
2403 return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
2404 start_mark, "found a tab character where an indentation space is expected")
2405 }
2406
2407 // Have we found a non-empty line?
2408 if !is_break(parser.buffer, parser.buffer_pos) {
2409 break
2410 }
2411
2412 // Consume the line break.
2413 if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
2414 return false
2415 }
2416 // [Go] Should really be returning breaks instead.
2417 *breaks = read_line(parser, *breaks)
2418 *end_mark = parser.mark
2419 }
2420
2421 // Determine the indentation level if needed.
2422 if *indent == 0 {
2423 *indent = max_indent
2424 if *indent < parser.indent+1 {
2425 *indent = parser.indent + 1
2426 }
2427 if *indent < 1 {
2428 *indent = 1
2429 }
2430 }
2431 return true
2432}
2433
2434// Scan a quoted scalar.
2435func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool {

Callers 1

Calls 7

is_spaceFunction · 0.85
skipFunction · 0.85
is_tabFunction · 0.85
is_breakFunction · 0.85
read_lineFunction · 0.85

Tested by

no test coverage detected