Strip leading "/**", trailing "*/", and per-line "*" prefixes. Returns a * mutable arena-allocated cleaned copy. */
| 507 | /* Strip leading "/**", trailing "*/", and per-line "*" prefixes. Returns a |
| 508 | * mutable arena-allocated cleaned copy. */ |
| 509 | static char *phpdoc_clean(CBMArena *a, const char *raw) { |
| 510 | if (!raw) |
| 511 | return NULL; |
| 512 | size_t n = strlen(raw); |
| 513 | char *out = (char *)cbm_arena_alloc(a, n + 1); |
| 514 | if (!out) |
| 515 | return NULL; |
| 516 | size_t w = 0; |
| 517 | size_t i = 0; |
| 518 | /* Skip leading /* and ** */ |
| 519 | while (i < n && (raw[i] == '/' || raw[i] == '*' || raw[i] == ' ' || raw[i] == '\t')) |
| 520 | i++; |
| 521 | bool at_line_start = false; |
| 522 | for (; i < n; i++) { |
| 523 | char c = raw[i]; |
| 524 | if (c == '\n') { |
| 525 | out[w++] = ' '; |
| 526 | at_line_start = true; |
| 527 | continue; |
| 528 | } |
| 529 | if (at_line_start) { |
| 530 | if (c == ' ' || c == '\t' || c == '*') |
| 531 | continue; |
| 532 | at_line_start = false; |
| 533 | } |
| 534 | out[w++] = c; |
| 535 | } |
| 536 | /* Trim trailing */ if (w >= 2 && out[w - 1] == '/' && out[w - 2] == '*') |
| 537 | w -= 2; |
| 538 | out[w] = '\0'; |
| 539 | return out; |
| 540 | } |
| 541 | |
| 542 | /* (next_tag helper not currently needed — phpdoc parsers use strstr inline.) */ |
| 543 |
no test coverage detected