Strip leading "/**", trailing "*/", and per-line "*" prefixes. Returns a * mutable arena-allocated cleaned copy. */
| 492 | /* Strip leading "/**", trailing "*/", and per-line "*" prefixes. Returns a |
| 493 | * mutable arena-allocated cleaned copy. */ |
| 494 | static char *phpdoc_clean(CBMArena *a, const char *raw) { |
| 495 | if (!raw) |
| 496 | return NULL; |
| 497 | size_t n = strlen(raw); |
| 498 | char *out = (char *)cbm_arena_alloc(a, n + 1); |
| 499 | if (!out) |
| 500 | return NULL; |
| 501 | size_t w = 0; |
| 502 | size_t i = 0; |
| 503 | /* Skip leading /* and ** */ |
| 504 | while (i < n && (raw[i] == '/' || raw[i] == '*' || raw[i] == ' ' || raw[i] == '\t')) |
| 505 | i++; |
| 506 | bool at_line_start = false; |
| 507 | for (; i < n; i++) { |
| 508 | char c = raw[i]; |
| 509 | if (c == '\n') { |
| 510 | out[w++] = ' '; |
| 511 | at_line_start = true; |
| 512 | continue; |
| 513 | } |
| 514 | if (at_line_start) { |
| 515 | if (c == ' ' || c == '\t' || c == '*') |
| 516 | continue; |
| 517 | at_line_start = false; |
| 518 | } |
| 519 | out[w++] = c; |
| 520 | } |
| 521 | /* Trim trailing */ if (w >= 2 && out[w - 1] == '/' && out[w - 2] == '*') |
| 522 | w -= 2; |
| 523 | out[w] = '\0'; |
| 524 | return out; |
| 525 | } |
| 526 | |
| 527 | /* (next_tag helper not currently needed — phpdoc parsers use strstr inline.) */ |
| 528 |
no test coverage detected