Read a name and append its bytes to d.buf. The name is delimited by any single-byte character not valid in names. All multi-byte characters are accepted; the caller must check their validity.
()
| 1195 | // The name is delimited by any single-byte character not valid in names. |
| 1196 | // All multi-byte characters are accepted; the caller must check their validity. |
| 1197 | func (d *Decoder) readName() (ok bool) { |
| 1198 | var b byte |
| 1199 | if b, ok = d.mustgetc(); !ok { |
| 1200 | return |
| 1201 | } |
| 1202 | if b < utf8.RuneSelf && !isNameByte(b) { |
| 1203 | d.ungetc(b) |
| 1204 | return false |
| 1205 | } |
| 1206 | d.buf.WriteByte(b) |
| 1207 | |
| 1208 | for { |
| 1209 | if b, ok = d.mustgetc(); !ok { |
| 1210 | return |
| 1211 | } |
| 1212 | if b < utf8.RuneSelf && !isNameByte(b) { |
| 1213 | d.ungetc(b) |
| 1214 | break |
| 1215 | } |
| 1216 | d.buf.WriteByte(b) |
| 1217 | } |
| 1218 | return true |
| 1219 | } |
| 1220 | |
| 1221 | func isNameByte(c byte) bool { |
| 1222 | return 'A' <= c && c <= 'Z' || |