Parse a bare key (ident-like). Stores arena-allocated copy in *out. */
| 37 | |
| 38 | /* Parse a bare key (ident-like). Stores arena-allocated copy in *out. */ |
| 39 | static int parse_key(CBMArena* a, const char* s, int len, int from, |
| 40 | const char** out) { |
| 41 | int start = from; |
| 42 | if (from < len && s[from] == '"') { |
| 43 | from++; |
| 44 | start = from; |
| 45 | while (from < len && s[from] != '"') { |
| 46 | if (s[from] == '\\' && from + 1 < len) from += 2; |
| 47 | else from++; |
| 48 | } |
| 49 | *out = cbm_arena_strndup(a, s + start, (size_t)(from - start)); |
| 50 | if (from < len && s[from] == '"') from++; |
| 51 | return from; |
| 52 | } |
| 53 | while (from < len && is_ident_char(s[from])) from++; |
| 54 | if (from > start) { |
| 55 | *out = cbm_arena_strndup(a, s + start, (size_t)(from - start)); |
| 56 | } |
| 57 | return from; |
| 58 | } |
| 59 | |
| 60 | /* Parse a string literal (single or double quoted). */ |
| 61 | static int parse_string(CBMArena* a, const char* s, int len, int from, |
no test coverage detected