A name node's text without white space (`A \ B` is `A\B`), in the arena. */
| 409 | |
| 410 | /* A name node's text without white space (`A \ B` is `A\B`), in the arena. */ |
| 411 | static const char *php_name_text(php_walk_t *w, TSNode n, size_t *len) { |
| 412 | uint32_t b = ts_node_start_byte(n); |
| 413 | uint32_t e = ts_node_end_byte(n); |
| 414 | char *out = (char *)cbm_arena_alloc(w->sb->a, (size_t)(e - b) + SKIP_ONE); |
| 415 | if (!out) { |
| 416 | w->sb->oom = true; |
| 417 | *len = 0; |
| 418 | return ""; |
| 419 | } |
| 420 | size_t k = 0; |
| 421 | for (uint32_t i = b; i < e; i++) { |
| 422 | char c = w->ctx->source[i]; |
| 423 | if (!isspace((unsigned char)c)) { |
| 424 | out[k++] = c; |
| 425 | } |
| 426 | } |
| 427 | out[k] = '\0'; |
| 428 | *len = k; |
| 429 | return out; |
| 430 | } |
| 431 | |
| 432 | /* All named children of a node, read with one cursor walk (indexing them is |
| 433 | * quadratic). */ |
no test coverage detected