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

Function cbm_sem_json_str

src/semantic/semantic.c:1804–1843  ·  view source on GitHub ↗

Until 2026-10 the reader stopped at the first '"' and kept escapes raw: * a docstring holding a quote lost everything after it, and "\nreturn" gave * the token "nreturn". */

Source from the content-addressed store, hash-verified

1802 * a docstring holding a quote lost everything after it, and "\nreturn" gave
1803 * the token "nreturn". */
1804const char *cbm_sem_json_str(const char *json, const char *key, char *buf, int bufsize) {
1805 if (!json || !key || !buf || bufsize <= 0) {
1806 return NULL;
1807 }
1808 char search[CBM_SZ_64];
1809 snprintf(search, sizeof(search), "\"%s\":\"", key);
1810 const char *p = strstr(json, search);
1811 if (!p) {
1812 return NULL;
1813 }
1814 p += strlen(search);
1815 int n = 0;
1816 for (; *p && *p != '"' && n + SKIP_ONE < bufsize; p++) {
1817 char c = *p;
1818 if (c == '\\' && p[SKIP_ONE]) {
1819 p++;
1820 switch (*p) {
1821 case 'n':
1822 case 't':
1823 case 'r':
1824 case 'b':
1825 case 'f':
1826 c = ' ';
1827 break;
1828 case 'u':
1829 c = ' ';
1830 for (int k = 0; k < 4 && isxdigit((unsigned char)p[SKIP_ONE]); k++) {
1831 p++;
1832 }
1833 break;
1834 default:
1835 c = *p; /* \" \\ \/ */
1836 break;
1837 }
1838 }
1839 buf[n++] = c;
1840 }
1841 buf[n] = '\0';
1842 return buf;
1843}
1844
1845/* Score bands at the quartiles of the admitted scores (0.773, 0.802, 0.838 at
1846 * the stored score's three decimals, so one shown score always carries one p),

Callers 2

json_str_valueFunction · 0.85
test_semantic.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected