readTokenAsLabelValue copies a label value from p.buf into p.currentToken. In contrast to the other 'readTokenAs...' functions, which start with the last read byte in p.currentByte, this method ignores p.currentByte and starts with reading a new byte from p.buf. The first byte not part of a label va
()
| 866 | // with reading a new byte from p.buf. The first byte not part of a label value |
| 867 | // is still copied into p.currentByte, but not into p.currentToken. |
| 868 | func (p *TextParser) readTokenAsLabelValue() { |
| 869 | p.currentToken.Reset() |
| 870 | escaped := false |
| 871 | for { |
| 872 | if p.currentByte, p.err = p.buf.ReadByte(); p.err != nil { |
| 873 | return |
| 874 | } |
| 875 | if escaped { |
| 876 | switch p.currentByte { |
| 877 | case '"', '\\': |
| 878 | p.currentToken.WriteByte(p.currentByte) |
| 879 | case 'n': |
| 880 | p.currentToken.WriteByte('\n') |
| 881 | default: |
| 882 | p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte)) |
| 883 | p.currentLabelPairs = nil |
| 884 | return |
| 885 | } |
| 886 | escaped = false |
| 887 | continue |
| 888 | } |
| 889 | switch p.currentByte { |
| 890 | case '"': |
| 891 | return |
| 892 | case '\n': |
| 893 | p.parseError(fmt.Sprintf("label value %q contains unescaped new-line", p.currentToken.String())) |
| 894 | return |
| 895 | case '\\': |
| 896 | escaped = true |
| 897 | default: |
| 898 | p.currentToken.WriteByte(p.currentByte) |
| 899 | } |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | func (p *TextParser) setOrCreateCurrentMF() { |
| 904 | p.currentIsSummaryCount = false |
no test coverage detected