| 673 | /* ── Paths in the image and in the repository ────────────────────────── */ |
| 674 | |
| 675 | static const char *dk_join(dk_t *d, const char *a, const char *b) { |
| 676 | if (!a || !a[0]) { |
| 677 | return b; |
| 678 | } |
| 679 | if (!b || !b[0]) { |
| 680 | return a; |
| 681 | } |
| 682 | size_t al = strlen(a); |
| 683 | size_t bl = strlen(b); |
| 684 | char *s = cbm_arena_alloc(d->a, al + bl + PAIR_LEN); |
| 685 | if (s) { |
| 686 | memcpy(s, a, al); |
| 687 | size_t n = al; |
| 688 | if (a[al - SKIP_ONE] != '/') { |
| 689 | s[n++] = '/'; |
| 690 | } |
| 691 | memcpy(s + n, b, bl); |
| 692 | s[n + bl] = '\0'; |
| 693 | } |
| 694 | return s; |
| 695 | } |
| 696 | |
| 697 | /* `p` with "." and empty segments dropped and ".." applied; an absolute path |
| 698 | * stays absolute ("/" at most), a relative one climbing out keeps "..". */ |
no test coverage detected