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

Function kust_line

internal/cbm/extract_k8s.c:303–336  ·  view source on GitHub ↗

One line of an inline patch: its indent and `key: value` (the value unquoted, a trailing comment dropped); false for a blank or comment line.

Source from the content-addressed store, hash-verified

301// One line of an inline patch: its indent and `key: value` (the value
302// unquoted, a trailing comment dropped); false for a blank or comment line.
303static bool kust_line(const char *p, size_t len, int *indent, char *key, size_t ksz, char *val,
304 size_t vsz) {
305 size_t i = 0;
306 while (i < len && p[i] == ' ') {
307 i++;
308 }
309 if (i == len || p[i] == '#') {
310 return false;
311 }
312 *indent = (int)i;
313 size_t k = i;
314 while (k < len && p[k] != ':') {
315 k++;
316 }
317 snprintf(key, ksz, "%.*s", (int)(k - i), p + i);
318 val[0] = '\0';
319 size_t s = k < len ? k + SKIP_ONE : len;
320 while (s < len && p[s] == ' ') {
321 s++;
322 }
323 size_t e = s;
324 while (e < len && !(p[e] == '#' && p[e - SKIP_ONE] == ' ')) {
325 e++;
326 }
327 while (e > s && (p[e - SKIP_ONE] == ' ' || p[e - SKIP_ONE] == '\r')) {
328 e--;
329 }
330 if (e - s >= PAIR_LEN && (p[s] == '"' || p[s] == '\'') && p[e - SKIP_ONE] == p[s]) {
331 s++;
332 e--;
333 }
334 snprintf(val, vsz, "%.*s", (int)(e - s), p + s);
335 return true;
336}
337
338// Each document of an inline patch with a kind and a metadata.name: a PATCH
339// fact naming that object -- its kind, the group of its apiVersion ("core"

Callers 1

kust_inline_factsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected