MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / readName

Method readName

opensca/sca/java/xml/xml.go:1197–1219  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.
1197func (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
1221func isNameByte(c byte) bool {
1222 return 'A' <= c && c <= 'Z' ||

Callers 2

textMethod · 0.95
nameMethod · 0.95

Calls 4

mustgetcMethod · 0.95
ungetcMethod · 0.95
isNameByteFunction · 0.85
WriteByteMethod · 0.80

Tested by

no test coverage detected