The callee as its import makes it: `sp.run` -> subprocess.run (an alias), * `run` -> subprocess.run (a member import), `spawn` -> child_process.spawn * (a named import mapped to its module). Empty when no import applies. */
| 419 | * `run` -> subprocess.run (a member import), `spawn` -> child_process.spawn |
| 420 | * (a named import mapped to its module). Empty when no import applies. */ |
| 421 | static void spawn_expand(const char *callee, const CBMImport *imports, int count, char *out, |
| 422 | size_t n) { |
| 423 | out[0] = '\0'; |
| 424 | size_t head = spawn_head_len(callee); |
| 425 | size_t key_len = head ? head : strlen(callee); |
| 426 | for (int i = 0; i < count; i++) { |
| 427 | const char *key = imports[i].local_name; |
| 428 | if (!key || !imports[i].module_path || strlen(key) != key_len || |
| 429 | strncmp(key, callee, key_len) != 0) { |
| 430 | continue; |
| 431 | } |
| 432 | const char *val = spawn_module(imports[i].module_path); |
| 433 | if (head) { |
| 434 | snprintf(out, n, "%s%s", val, callee + head); |
| 435 | } else if (spawn_val_names(val, callee)) { |
| 436 | snprintf(out, n, "%s", val); |
| 437 | } else { |
| 438 | snprintf(out, n, "%s.%s", val, callee); |
| 439 | } |
| 440 | return; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | static bool spawn_imports_module(const CBMImport *imports, int count, const char *module) { |
| 445 | size_t ml = strlen(module); |
no test coverage detected