MCPcopy
hub / github.com/go-yaml/yaml / yaml_emitter_analyze_anchor

Function yaml_emitter_analyze_anchor

emitterc.go:1215–1235  ·  view source on GitHub ↗

Check if an anchor is valid.

(emitter *yaml_emitter_t, anchor []byte, alias bool)

Source from the content-addressed store, hash-verified

1213
1214// Check if an anchor is valid.
1215func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool {
1216 if len(anchor) == 0 {
1217 problem := "anchor value must not be empty"
1218 if alias {
1219 problem = "alias value must not be empty"
1220 }
1221 return yaml_emitter_set_emitter_error(emitter, problem)
1222 }
1223 for i := 0; i < len(anchor); i += width(anchor[i]) {
1224 if !is_alpha(anchor, i) {
1225 problem := "anchor value must contain alphanumerical characters only"
1226 if alias {
1227 problem = "alias value must contain alphanumerical characters only"
1228 }
1229 return yaml_emitter_set_emitter_error(emitter, problem)
1230 }
1231 }
1232 emitter.anchor_data.anchor = anchor
1233 emitter.anchor_data.alias = alias
1234 return true
1235}
1236
1237// Check if a tag is valid.
1238func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool {

Callers 1

Calls 3

widthFunction · 0.85
is_alphaFunction · 0.85

Tested by

no test coverage detected