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

Function toml_parse_assignment

src/cli/config_toml_edit.c:1611–1702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1609}
1610
1611static int toml_parse_assignment(const char *data, const toml_line_t *line,
1612 toml_assignment_t *assignment) {
1613 memset(assignment, 0, sizeof(*assignment));
1614 size_t start = line->start;
1615 size_t end = line->content_end;
1616 if (start == 0U && end >= 3U && (unsigned char)data[0] == 0xefU &&
1617 (unsigned char)data[1] == 0xbbU && (unsigned char)data[2] == 0xbfU) {
1618 start = 3U;
1619 }
1620 while (start < end && (data[start] == ' ' || data[start] == '\t')) {
1621 start++;
1622 }
1623 if (start == end || data[start] == '#') {
1624 return TOML_EDIT_OK;
1625 }
1626
1627 size_t equals = SIZE_MAX;
1628 char quote = '\0';
1629 int escaped = 0;
1630 for (size_t pos = start; pos < end; ++pos) {
1631 char ch = data[pos];
1632 if (quote) {
1633 if (quote == '"' && !escaped && ch == '\\') {
1634 escaped = 1;
1635 } else {
1636 if (!escaped && ch == quote) {
1637 quote = '\0';
1638 }
1639 escaped = 0;
1640 }
1641 continue;
1642 }
1643 if (ch == '"' || ch == '\'') {
1644 quote = ch;
1645 } else if (ch == '=') {
1646 equals = pos;
1647 break;
1648 } else if (ch == '#') {
1649 break;
1650 }
1651 }
1652 if (quote || equals == SIZE_MAX) {
1653 return TOML_EDIT_OK;
1654 }
1655 size_t key_end = equals;
1656 toml_trim(data, &start, &key_end);
1657 if (toml_parse_key_path(data, start, key_end, &assignment->key) != TOML_EDIT_OK) {
1658 return TOML_EDIT_ERR;
1659 }
1660
1661 size_t value_start = equals + 1U;
1662 while (value_start < end && (data[value_start] == ' ' || data[value_start] == '\t')) {
1663 value_start++;
1664 }
1665 size_t value_end = end;
1666 quote = '\0';
1667 escaped = 0;
1668 for (size_t pos = value_start; pos < end; ++pos) {

Callers 10

toml_declared_writes_keyFunction · 0.85
toml_line_is_usersFunction · 0.85
toml_scan_named_tablesFunction · 0.85
toml_validate_table_bodyFunction · 0.85
toml_merge_named_tableFunction · 0.85
toml_strip_legacy_tableFunction · 0.85
toml_codex_owned_spanFunction · 0.85
toml_codex_scan_inlineFunction · 0.85

Calls 3

toml_trimFunction · 0.85
toml_parse_key_pathFunction · 0.85
toml_key_path_disposeFunction · 0.85

Tested by

no test coverage detected