The string literal that follows `key =` in text[0..n), copied into `out`. * false when there is none, it holds an escape, or it does not fit. */
| 2536 | /* The string literal that follows `key =` in text[0..n), copied into `out`. |
| 2537 | * false when there is none, it holds an escape, or it does not fit. */ |
| 2538 | static bool rs_attr_string(const char *text, size_t n, char *out, size_t cap) { |
| 2539 | const char *eq = (const char *)memchr(text, '=', n); |
| 2540 | if (!eq) { |
| 2541 | return false; |
| 2542 | } |
| 2543 | size_t i = (size_t)(eq - text) + SKIP_ONE; |
| 2544 | while (i < n && isspace((unsigned char)text[i])) { |
| 2545 | i++; |
| 2546 | } |
| 2547 | if (i >= n || text[i] != '"') { |
| 2548 | return false; |
| 2549 | } |
| 2550 | size_t start = ++i; |
| 2551 | while (i < n && text[i] != '"' && text[i] != '\\' && (unsigned char)text[i] >= ' ') { |
| 2552 | i++; |
| 2553 | } |
| 2554 | if (i >= n || text[i] != '"' || i - start >= cap || i == start) { |
| 2555 | return false; |
| 2556 | } |
| 2557 | memcpy(out, text + start, i - start); |
| 2558 | out[i - start] = '\0'; |
| 2559 | return true; |
| 2560 | } |
| 2561 | |
| 2562 | /* The first identifier inside the parentheses of text[0..n). */ |
| 2563 | static void rs_attr_first_arg(const char *text, size_t n, char *out, size_t cap) { |