Append dotted path segments from rel_path (extension-stripped) to output buffer.
| 1752 | |
| 1753 | // Append dotted path segments from rel_path (extension-stripped) to output buffer. |
| 1754 | static char *append_path_segments(char *out, const char *rel_path, size_t plen, bool has_name) { |
| 1755 | const char *start = rel_path; |
| 1756 | const char *end_ptr = rel_path + plen; |
| 1757 | while (start < end_ptr) { |
| 1758 | const char *slash = (const char *)memchr(start, '/', end_ptr - start); |
| 1759 | const char *part_end = slash ? slash : end_ptr; |
| 1760 | size_t part_len = (size_t)(part_end - start); |
| 1761 | |
| 1762 | if (part_len > 0) { |
| 1763 | bool is_last = (part_end == end_ptr); |
| 1764 | if (!should_skip_fqn_part(start, part_len, is_last, has_name)) { |
| 1765 | /* Drop a leading '.' from a dotfile / hidden-dir segment |
| 1766 | * (".env" -> "env", ".github" -> "github"). Otherwise the QN |
| 1767 | * separator '.' plus the segment's own leading '.' produce a |
| 1768 | * malformed "proj..env" double-dot, and a root dotfile's empty |
| 1769 | * stem collides with the project QN. */ |
| 1770 | const char *seg = start; |
| 1771 | size_t seg_len = part_len; |
| 1772 | if (seg[0] == '.') { |
| 1773 | seg++; |
| 1774 | seg_len--; |
| 1775 | } |
| 1776 | if (seg_len > 0) { |
| 1777 | *out++ = '.'; |
| 1778 | memcpy(out, seg, seg_len); |
| 1779 | out += seg_len; |
| 1780 | } |
| 1781 | } |
| 1782 | } |
| 1783 | start = part_end + SKIP_ONE; |
| 1784 | } |
| 1785 | return out; |
| 1786 | } |
| 1787 | |
| 1788 | char *cbm_fqn_compute(CBMArena *a, const char *project, const char *rel_path, const char *name) { |
| 1789 | if (!project) |
no test coverage detected