Get name: /first(first|second)*/ Do not set d.err if the name is missing (unless unexpected EOF is received): let the caller provide better context.
()
| 1155 | // Do not set d.err if the name is missing (unless unexpected EOF is received): |
| 1156 | // let the caller provide better context. |
| 1157 | func (d *Decoder) name() (s string, ok bool) { |
| 1158 | d.buf.Reset() |
| 1159 | if !d.readName() { |
| 1160 | return "", false |
| 1161 | } |
| 1162 | |
| 1163 | // Now we check the characters. |
| 1164 | b := d.buf.Bytes() |
| 1165 | if !isName(b) { |
| 1166 | d.err = d.syntaxError("invalid XML name: " + string(b)) |
| 1167 | return "", false |
| 1168 | } |
| 1169 | return string(b), true |
| 1170 | } |
| 1171 | |
| 1172 | // Read a name and append its bytes to d.buf. |
| 1173 | // The name is delimited by any single-byte character not valid in names. |