What may stand before a collection's bracket: nothing, Zig's `&.` / `.`, * Java's `new String[]`, or a collection constructor. A name before `[` is a * subscript (`record["argv"]`) and any other call's arguments are not the * command (`os.path.join("bin", tool)`). */
| 574 | * subscript (`record["argv"]`) and any other call's arguments are not the |
| 575 | * command (`os.path.join("bin", tool)`). */ |
| 576 | static bool spawn_collection_prefix(const char *p, size_t len) { |
| 577 | static const char *const ctors[] = { |
| 578 | "listOf", "arrayOf", "mutableListOf", "List.of", "Arrays.asList", "vec!", "c", "Cmd", NULL}; |
| 579 | if (len == 0 || (len <= 2 && strspn(p, "&.") == len) || |
| 580 | (len > 2 && strncmp(p + len - 2, "[]", 2) == 0 && strncmp(p, "new ", 4) == 0)) { |
| 581 | return true; |
| 582 | } |
| 583 | for (int i = 0; ctors[i]; i++) { |
| 584 | if (strlen(ctors[i]) == len && strncmp(p, ctors[i], len) == 0) { |
| 585 | return true; |
| 586 | } |
| 587 | } |
| 588 | return false; |
| 589 | } |
| 590 | |
| 591 | /* The first element of a collection written at `p` ([..], (..), {..}, |
| 592 | * listOf(..), &.{..}), copied into `out`. False when `p` is no collection. */ |
no outgoing calls
no test coverage detected