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

Function jl_build_member

src/cli/config_json_like.c:1051–1090  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1049}
1050
1051static int jl_build_member(jl_buffer_t *buffer, const char *const *object_path, size_t path_len,
1052 size_t missing_path_index, const char *entry_key, const char *entry_json,
1053 size_t entry_length, const char *newline, jl_slice_t base_indent,
1054 jl_slice_t indent_unit) {
1055 if (missing_path_index == SIZE_MAX) {
1056 if (jl_append_quoted_key(buffer, entry_key) != 0 || jl_buffer_string(buffer, ": ") != 0 ||
1057 jl_buffer_append(buffer, entry_json, entry_length) != 0) {
1058 return -1;
1059 }
1060 return 0;
1061 }
1062
1063 if (jl_append_quoted_key(buffer, object_path[missing_path_index]) != 0 ||
1064 jl_buffer_string(buffer, ": {") != 0 || jl_buffer_string(buffer, newline) != 0) {
1065 return -1;
1066 }
1067 size_t level = 1U;
1068 for (size_t i = missing_path_index + 1U; i < path_len; i++) {
1069 if (jl_append_styled_indent(buffer, base_indent, indent_unit, level + 1U) != 0 ||
1070 jl_append_quoted_key(buffer, object_path[i]) != 0 ||
1071 jl_buffer_string(buffer, ": {") != 0 || jl_buffer_string(buffer, newline) != 0) {
1072 return -1;
1073 }
1074 level++;
1075 }
1076 if (jl_append_styled_indent(buffer, base_indent, indent_unit, level + 1U) != 0 ||
1077 jl_append_quoted_key(buffer, entry_key) != 0 || jl_buffer_string(buffer, ": ") != 0 ||
1078 jl_buffer_append(buffer, entry_json, entry_length) != 0) {
1079 return -1;
1080 }
1081 while (level > 0U) {
1082 if (jl_buffer_string(buffer, newline) != 0 ||
1083 jl_append_styled_indent(buffer, base_indent, indent_unit, level) != 0 ||
1084 jl_buffer_char(buffer, '}') != 0) {
1085 return -1;
1086 }
1087 level--;
1088 }
1089 return 0;
1090}
1091
1092static bool jl_line_indent(const char *text, size_t pos, jl_slice_t *indent) {
1093 size_t line_start = pos;

Callers 1

jl_insert_memberFunction · 0.85

Calls 5

jl_append_quoted_keyFunction · 0.85
jl_buffer_stringFunction · 0.85
jl_buffer_appendFunction · 0.85
jl_append_styled_indentFunction · 0.85
jl_buffer_charFunction · 0.85

Tested by

no test coverage detected