MCPcopy Create free account
hub / github.com/cli/cli / scanTitle

Function scanTitle

internal/attachments/references.go:604–625  ·  view source on GitHub ↗

scanTitle skips the optional title following a destination and returns the index just past it. i may point at anything: a byte that opens no title leaves the index untouched. A title is delimited by double quotes, single quotes, or parentheses.

(src []byte, i, hi int)

Source from the content-addressed store, hash-verified

602// leaves the index untouched. A title is delimited by double quotes, single
603// quotes, or parentheses.
604func scanTitle(src []byte, i, hi int) (int, bool) {
605 var closer byte
606 switch src[i] {
607 case '"', '\'':
608 closer = src[i]
609 case '(':
610 closer = ')'
611 default:
612 return i, true
613 }
614 i++
615 for i < hi && src[i] != closer {
616 if src[i] == '\\' && i+1 < hi {
617 i++
618 }
619 i++
620 }
621 if i >= hi {
622 return 0, false
623 }
624 return i + 1, true
625}
626
627// scanAngleDest reads a "<...>" destination beginning at the "<", returning the
628// index just past the closing ">".

Callers 1

inlineRangesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected