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)
| 602 | // leaves the index untouched. A title is delimited by double quotes, single |
| 603 | // quotes, or parentheses. |
| 604 | func 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 ">". |