A COPY / ADD in JSON form: its strings, expanded. */
| 597 | |
| 598 | /* A COPY / ADD in JSON form: its strings, expanded. */ |
| 599 | static int dk_copy_json(dk_t *d, const char *p, const char **out, int max) { |
| 600 | yyjson_doc *doc = yyjson_read(p, strlen(p), YYJSON_READ_STOP_WHEN_DONE); |
| 601 | yyjson_val *arr = doc ? yyjson_doc_get_root(doc) : NULL; |
| 602 | int n = 0; |
| 603 | yyjson_arr_iter it; |
| 604 | yyjson_val *v; |
| 605 | if (yyjson_is_arr(arr)) { |
| 606 | for (yyjson_arr_iter_init(arr, &it); n < max && (v = yyjson_arr_iter_next(&it));) { |
| 607 | const char *s = yyjson_get_str(v); |
| 608 | out[n++] = s ? dk_expand(d, d->local, cbm_arena_strdup(d->a, s)) : NULL; |
| 609 | } |
| 610 | } |
| 611 | if (doc) { |
| 612 | yyjson_doc_free(doc); |
| 613 | } |
| 614 | return n; |
| 615 | } |
| 616 | |
| 617 | /* COPY / ADD as Docker reads it, from the instruction's own text: flags |
| 618 | * first, then the JSON form or whitespace-separated words (a heredoc |
no test coverage detected