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

Function read

scannerc.go:542–565  ·  view source on GitHub ↗

Copy a character to a string buffer and advance pointers.

(parser *yaml_parser_t, s []byte)

Source from the content-addressed store, hash-verified

540
541// Copy a character to a string buffer and advance pointers.
542func read(parser *yaml_parser_t, s []byte) []byte {
543 if !is_blank(parser.buffer, parser.buffer_pos) {
544 parser.newlines = 0
545 }
546 w := width(parser.buffer[parser.buffer_pos])
547 if w == 0 {
548 panic("invalid character sequence")
549 }
550 if len(s) == 0 {
551 s = make([]byte, 0, 32)
552 }
553 if w == 1 && len(s)+w <= cap(s) {
554 s = s[:len(s)+1]
555 s[len(s)-1] = parser.buffer[parser.buffer_pos]
556 parser.buffer_pos++
557 } else {
558 s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...)
559 parser.buffer_pos += w
560 }
561 parser.mark.index++
562 parser.mark.column++
563 parser.unread--
564 return s
565}
566
567// Copy a line break character to a string buffer and advance pointers.
568func read_line(parser *yaml_parser_t, s []byte) []byte {

Calls 2

is_blankFunction · 0.85
widthFunction · 0.85

Tested by

no test coverage detected