_linters/src/gopkg.in/yaml.v2/scannerc.go
func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool {
	// Eat the indicator '|' or '>'.
	start_mark := parser.mark
	skip(parser)

	// Scan the additional block scalar indicators.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}

	// Check for a chomping indicator.
	var chomping, increment int
	if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
		// Set the chomping method and eat the indicator.
		if parser.buffer[parser.buffer_pos] == '+' {
			chomping = +1
		} else {
			chomping = -1
		}
		skip(parser)

		// Check for an indentation indicator.
		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
		if is_digit(parser.buffer, parser.buffer_pos) {
			// Check that the indentation is greater than 0.
			if parser.buffer[parser.buffer_pos] == '0' {
				yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
					start_mark, "found an indentation indicator equal to 0")
				return false
			}

			// Get the indentation level and eat the indicator.
			increment = as_digit(parser.buffer, parser.buffer_pos)
			skip(parser)
		}

	} else if is_digit(parser.buffer, parser.buffer_pos) {
		// Do the same as above, but in the opposite order.

		if parser.buffer[parser.buffer_pos] == '0' {
			yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
				start_mark, "found an indentation indicator equal to 0")
			return false
		}
		increment = as_digit(parser.buffer, parser.buffer_pos)
		skip(parser)

		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
		if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
			if parser.buffer[parser.buffer_pos] == '+' {
				chomping = +1
			} else {
				chomping = -1
			}
			skip(parser)
		}
	}

	// Eat whitespaces and comments to the end of the line.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}
	for is_blank(parser.buffer, parser.buffer_pos) {
		skip(parser)
		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
	}
	if parser.buffer[parser.buffer_pos] == '#' {
		for !is_breakz(parser.buffer, parser.buffer_pos) {
			skip(parser)
			if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
				return false
			}
		}
	}

	// Check if we are at the end of the line.
	if !is_breakz(parser.buffer, parser.buffer_pos) {
		yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
			start_mark, "did not find expected comment or line break")
		return false
	}

	// Eat a line break.
	if is_break(parser.buffer, parser.buffer_pos) {
		if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
			return false
		}
		skip_line(parser)
	}

	end_mark := parser.mark

	// Set the indentation level if it was specified.
	var indent int
	if increment > 0 {
		if parser.indent >= 0 {
			indent = parser.indent + increment
		} else {
			indent = increment
		}
	}

	// Scan the leading line breaks and determine the indentation level if needed.
	var s, leading_break, trailing_breaks []byte
	if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
		return false
	}

	// Scan the block scalar content.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}
	var leading_blank, trailing_blank bool
	for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) {
		// We are at the beginning of a non-empty line.

		// Is it a trailing whitespace?
		trailing_blank = is_blank(parser.buffer, parser.buffer_pos)

		// Check if we need to fold the leading line break.
		if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' {
			// Do we need to join the lines by space?
			if len(trailing_breaks) == 0 {
				s = append(s, ' ')
			}
		} else {
			s = append(s, leading_break...)
		}
		leading_break = leading_break[:0]

		// Append the remaining line breaks.
		s = append(s, trailing_breaks...)
		trailing_breaks = trailing_breaks[:0]

		// Is it a leading whitespace?
		leading_blank = is_blank(parser.buffer, parser.buffer_pos)

		// Consume the current line.
		for !is_breakz(parser.buffer, parser.buffer_pos) {
			s = read(parser, s)
			if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
				return false
			}
		}

		// Consume the line break.
		if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
			return false
		}

		leading_break = read_line(parser, leading_break)

		// Eat the following indentation spaces and line breaks.
		if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
			return false
		}
	}

	// Chomp the tail.
	if chomping != -1 {
		s = append(s, leading_break...)
	}
	if chomping == 1 {
		s = append(s, trailing_breaks...)
	}

	// Create a token.
	*token = yaml_token_t{
		typ:        yaml_SCALAR_TOKEN,
		start_mark: start_mark,
		end_mark:   end_mark,
		value:      s,
		style:      yaml_LITERAL_SCALAR_STYLE,
	}
	if !literal {
		token.style = yaml_FOLDED_SCALAR_STYLE
	}
	return true
}
func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool {
	// Eat the indicator '|' or '>'.
	start_mark := parser.mark
	skip(parser)

	// Scan the additional block scalar indicators.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}

	// Check for a chomping indicator.
	var chomping, increment int
	if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
		// Set the chomping method and eat the indicator.
		if parser.buffer[parser.buffer_pos] == '+' {
			chomping = +1
		} else {
			chomping = -1
		}
		skip(parser)

		// Check for an indentation indicator.
		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
		if is_digit(parser.buffer, parser.buffer_pos) {
			// Check that the indentation is greater than 0.
			if parser.buffer[parser.buffer_pos] == '0' {
				yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
					start_mark, "found an indentation indicator equal to 0")
				return false
			}

			// Get the indentation level and eat the indicator.
			increment = as_digit(parser.buffer, parser.buffer_pos)
			skip(parser)
		}

	} else if is_digit(parser.buffer, parser.buffer_pos) {
		// Do the same as above, but in the opposite order.

		if parser.buffer[parser.buffer_pos] == '0' {
			yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
				start_mark, "found an indentation indicator equal to 0")
			return false
		}
		increment = as_digit(parser.buffer, parser.buffer_pos)
		skip(parser)

		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
		if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {
			if parser.buffer[parser.buffer_pos] == '+' {
				chomping = +1
			} else {
				chomping = -1
			}
			skip(parser)
		}
	}

	// Eat whitespaces and comments to the end of the line.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}
	for is_blank(parser.buffer, parser.buffer_pos) {
		skip(parser)
		if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
			return false
		}
	}
	if parser.buffer[parser.buffer_pos] == '#' {
		for !is_breakz(parser.buffer, parser.buffer_pos) {
			skip(parser)
			if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
				return false
			}
		}
	}

	// Check if we are at the end of the line.
	if !is_breakz(parser.buffer, parser.buffer_pos) {
		yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
			start_mark, "did not find expected comment or line break")
		return false
	}

	// Eat a line break.
	if is_break(parser.buffer, parser.buffer_pos) {
		if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
			return false
		}
		skip_line(parser)
	}

	end_mark := parser.mark

	// Set the indentation level if it was specified.
	var indent int
	if increment > 0 {
		if parser.indent >= 0 {
			indent = parser.indent + increment
		} else {
			indent = increment
		}
	}

	// Scan the leading line breaks and determine the indentation level if needed.
	var s, leading_break, trailing_breaks []byte
	if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
		return false
	}

	// Scan the block scalar content.
	if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
		return false
	}
	var leading_blank, trailing_blank bool
	for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) {
		// We are at the beginning of a non-empty line.

		// Is it a trailing whitespace?
		trailing_blank = is_blank(parser.buffer, parser.buffer_pos)

		// Check if we need to fold the leading line break.
		if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' {
			// Do we need to join the lines by space?
			if len(trailing_breaks) == 0 {
				s = append(s, ' ')
			}
		} else {
			s = append(s, leading_break...)
		}
		leading_break = leading_break[:0]

		// Append the remaining line breaks.
		s = append(s, trailing_breaks...)
		trailing_breaks = trailing_breaks[:0]

		// Is it a leading whitespace?
		leading_blank = is_blank(parser.buffer, parser.buffer_pos)

		// Consume the current line.
		for !is_breakz(parser.buffer, parser.buffer_pos) {
			s = read(parser, s)
			if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
				return false
			}
		}

		// Consume the line break.
		if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
			return false
		}

		leading_break = read_line(parser, leading_break)

		// Eat the following indentation spaces and line breaks.
		if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
			return false
		}
	}

	// Chomp the tail.
	if chomping != -1 {
		s = append(s, leading_break...)
	}
	if chomping == 1 {
		s = append(s, trailing_breaks...)
	}

	// Create a token.
	*token = yaml_token_t{
		typ:        yaml_SCALAR_TOKEN,
		start_mark: start_mark,
		end_mark:   end_mark,
		value:      s,
		style:      yaml_LITERAL_SCALAR_STYLE,
	}
	if !literal {
		token.style = yaml_FOLDED_SCALAR_STYLE
	}
	return true
}
func yaml_parser_scan_block_scalar ( parser * yaml_parser_t , token * yaml_token_t , literal bool ) bool { // Eat the indicator '|' or '>'. start_mark := parser . mark skip ( parser ) // Scan the additional block scalar indicators. if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } // Check for a chomping indicator. var chomping , increment int if parser . buffer [ parser . buffer_pos ] == '+' || parser . buffer [ parser . buffer_pos ] == '-' { // Set the chomping method and eat the indicator. if parser . buffer [ parser . buffer_pos ] == '+' { chomping = + 1 } else { chomping = - 1 } skip ( parser ) // Check for an indentation indicator. if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } if is_digit ( parser . buffer , parser . buffer_pos ) { // Check that the indentation is greater than 0. if parser . buffer [ parser . buffer_pos ] == '0' { yaml_parser_set_scanner_error ( parser , " " , start_mark , " " ) return false } // Get the indentation level and eat the indicator. increment = as_digit ( parser . buffer , parser . buffer_pos ) skip ( parser ) } } else if is_digit ( parser . buffer , parser . buffer_pos ) { // Do the same as above, but in the opposite order. if parser . buffer [ parser . buffer_pos ] == '0' { yaml_parser_set_scanner_error ( parser , " " , start_mark , " " ) return false } increment = as_digit ( parser . buffer , parser . buffer_pos ) skip ( parser ) if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } if parser . buffer [ parser . buffer_pos ] == '+' || parser . buffer [ parser . buffer_pos ] == '-' { if parser . buffer [ parser . buffer_pos ] == '+' { chomping = + 1 } else { chomping = - 1 } skip ( parser ) } } // Eat whitespaces and comments to the end of the line. if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } for is_blank ( parser . buffer , parser . buffer_pos ) { skip ( parser ) if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } } if parser . buffer [ parser . buffer_pos ] == '#' { for ! is_breakz ( parser . buffer , parser . buffer_pos ) { skip ( parser ) if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } } } // Check if we are at the end of the line. if ! is_breakz ( parser . buffer , parser . buffer_pos ) { yaml_parser_set_scanner_error ( parser , " " , start_mark , " " ) return false } // Eat a line break. if is_break ( parser . buffer , parser . buffer_pos ) { if parser . unread < 2 && ! yaml_parser_update_buffer ( parser , 2 ) { return false } skip_line ( parser ) } end_mark := parser . mark // Set the indentation level if it was specified. var indent int if increment > 0 { if parser . indent >= 0 { indent = parser . indent + increment } else { indent = increment } } // Scan the leading line breaks and determine the indentation level if needed. var s , leading_break , trailing_breaks [ ] byte if ! yaml_parser_scan_block_scalar_breaks ( parser , & indent , & trailing_breaks , start_mark , & end_mark ) { return false } // Scan the block scalar content. if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } var leading_blank , trailing_blank bool for parser . mark . column == indent && ! is_z ( parser . buffer , parser . buffer_pos ) { // We are at the beginning of a non-empty line. // Is it a trailing whitespace? trailing_blank = is_blank ( parser . buffer , parser . buffer_pos ) // Check if we need to fold the leading line break. if ! literal && ! leading_blank && ! trailing_blank && len ( leading_break ) > 0 && leading_break [ 0 ] == '\n' { // Do we need to join the lines by space? if len ( trailing_breaks ) == 0 { s = append ( s , ' ' ) } } else { s = append ( s , leading_break ... ) } leading_break = leading_break [ : 0 ] // Append the remaining line breaks. s = append ( s , trailing_breaks ... ) trailing_breaks = trailing_breaks [ : 0 ] // Is it a leading whitespace? leading_blank = is_blank ( parser . buffer , parser . buffer_pos ) // Consume the current line. for ! is_breakz ( parser . buffer , parser . buffer_pos ) { s = read ( parser , s ) if parser . unread < 1 && ! yaml_parser_update_buffer ( parser , 1 ) { return false } } // Consume the line break. if parser . unread < 2 && ! yaml_parser_update_buffer ( parser , 2 ) { return false } leading_break = read_line ( parser , leading_break ) // Eat the following indentation spaces and line breaks. if ! yaml_parser_scan_block_scalar_breaks ( parser , & indent , & trailing_breaks , start_mark , & end_mark ) { return false } } // Chomp the tail. if chomping != - 1 { s = append ( s , leading_break ... ) } if chomping == 1 { s = append ( s , trailing_breaks ... ) } // Create a token. * token = yaml_token_t { typ : yaml_SCALAR_TOKEN , start_mark : start_mark , end_mark : end_mark , value : s , style : yaml_LITERAL_SCALAR_STYLE , } if ! literal { token . style = yaml_FOLDED_SCALAR_STYLE } return true }
// Scan a block scalar.
Scan a block scalar .