Check if an anchor is valid.
(emitter *yaml_emitter_t, anchor []byte, alias bool)
| 1213 | |
| 1214 | // Check if an anchor is valid. |
| 1215 | func 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. |
| 1238 | func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { |
no test coverage detected