Parse a string literal (single or double quoted). */
| 59 | |
| 60 | /* Parse a string literal (single or double quoted). */ |
| 61 | static int parse_string(CBMArena* a, const char* s, int len, int from, |
| 62 | const char** out) { |
| 63 | if (from >= len) return from; |
| 64 | char q = s[from]; |
| 65 | if (q != '"' && q != '\'') return from; |
| 66 | from++; |
| 67 | int start = from; |
| 68 | while (from < len && s[from] != q) { |
| 69 | if (s[from] == '\\' && from + 1 < len) from += 2; |
| 70 | else from++; |
| 71 | } |
| 72 | *out = cbm_arena_strndup(a, s + start, (size_t)(from - start)); |
| 73 | if (from < len) from++; |
| 74 | return from; |
| 75 | } |
| 76 | |
| 77 | /* Skip a value (used for keys we don't care about). Handles strings, |
| 78 | * arrays, inline tables, bare values. */ |
no test coverage detected