MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_list_item

Function parse_list_item

src/foundation/yaml.c:134–158  ·  view source on GitHub ↗

Parse a list item "- value" and add to the correct parent. */

Source from the content-addressed store, hash-verified

132
133/* Parse a list item "- value" and add to the correct parent. */
134static void parse_list_item(const char *content, int content_len, cbm_yaml_node_t *parent) {
135 const char *item_start = content + YAML_LIST_PREFIX;
136 int item_len = content_len - YAML_LIST_PREFIX;
137 while (item_len > 0 && isspace((unsigned char)item_start[0])) {
138 item_start++;
139 item_len--;
140 }
141
142 /* If parent is a map, the list items belong to the last child */
143 cbm_yaml_node_t *list_parent = parent;
144 if (parent->type == YAML_MAP && parent->child_count > 0) {
145 cbm_yaml_node_t *last = parent->children[parent->child_count - SKIP_ONE];
146 if (last->type == YAML_LIST) {
147 list_parent = last;
148 }
149 }
150
151 cbm_yaml_node_t *item = node_new(YAML_SCALAR);
152 if (item) {
153 item->value = trim_dup(item_start, item_start + item_len);
154 if (!node_add_child(list_parent, item)) {
155 cbm_yaml_free(item);
156 }
157 }
158}
159
160/* Strip inline comments from a value string (not inside quotes).
161 * Returns the adjusted length. */

Callers 1

cbm_yaml_parseFunction · 0.85

Calls 4

node_newFunction · 0.85
trim_dupFunction · 0.85
node_add_childFunction · 0.85
cbm_yaml_freeFunction · 0.85

Tested by

no test coverage detected