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)
| 639 | // leaves the index untouched. A title is delimited by double quotes, single |
| 640 | // quotes, or parentheses. |
| 641 | func scanTitle(src []byte, i, hi int) (int, bool) { |
| 642 | var closer byte |
| 643 | switch src[i] { |
| 644 | case '"', '\'': |
| 645 | closer = src[i] |
| 646 | case '(': |
| 647 | closer = ')' |
| 648 | default: |
| 649 | return i, true |
| 650 | } |
| 651 | i++ |
| 652 | for i < hi && src[i] != closer { |
| 653 | if src[i] == '\\' && i+1 < hi { |
| 654 | i++ |
| 655 | } |
| 656 | i++ |
| 657 | } |
| 658 | if i >= hi { |
| 659 | return 0, false |
| 660 | } |
| 661 | return i + 1, true |
| 662 | } |
| 663 | |
| 664 | // scanAngleDest reads a "<...>" destination beginning at the "<", returning the |
| 665 | // index just past the closing ">". |