| 550 | } |
| 551 | |
| 552 | txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot) |
| 553 | { |
| 554 | txPreparation* preparation = the->preparation; |
| 555 | char name[PATH_MAX]; |
| 556 | char path[PATH_MAX]; |
| 557 | txBoolean absolute = 0, relative = 0, search = 0; |
| 558 | txInteger dot = 0; |
| 559 | txString slash; |
| 560 | txID id; |
| 561 | |
| 562 | fxToStringBuffer(the, slot, name, sizeof(name)); |
| 563 | // #if MODDEF_XS_MODS |
| 564 | // if (findMod(the, name, NULL)) { |
| 565 | // c_strcpy(path, "/"); |
| 566 | // c_strcat(path, name); |
| 567 | // c_strcat(path, ".xsb"); |
| 568 | // return fxNewNameC(the, path); |
| 569 | // } |
| 570 | // #endif |
| 571 | // |
| 572 | if (!c_strncmp(name, "/", 1)) { |
| 573 | absolute = 1; |
| 574 | } |
| 575 | else if (!c_strncmp(name, "./", 2)) { |
| 576 | dot = 1; |
| 577 | relative = 1; |
| 578 | } |
| 579 | else if (!c_strncmp(name, "../", 3)) { |
| 580 | dot = 2; |
| 581 | relative = 1; |
| 582 | } |
| 583 | else { |
| 584 | relative = 1; |
| 585 | search = 1; |
| 586 | } |
| 587 | if (absolute) { |
| 588 | c_strcpy(path, preparation->base); |
| 589 | c_strcat(path, name + 1); |
| 590 | if (fxFindScript(the, realm, path, &id)) |
| 591 | return id; |
| 592 | } |
| 593 | if (relative && (moduleID != XS_NO_ID)) { |
| 594 | c_strcpy(path, fxGetKeyName(the, moduleID)); |
| 595 | slash = c_strrchr(path, '/'); |
| 596 | if (!slash) |
| 597 | return XS_NO_ID; |
| 598 | if (dot == 0) |
| 599 | slash++; |
| 600 | else if (dot == 2) { |
| 601 | *slash = 0; |
| 602 | slash = c_strrchr(path, '/'); |
| 603 | if (!slash) |
| 604 | return XS_NO_ID; |
| 605 | } |
| 606 | if (!c_strncmp(path, preparation->base, preparation->baseLength)) { |
| 607 | *slash = 0; |
| 608 | c_strcat(path, name + dot); |
| 609 | if (fxFindScript(the, realm, path, &id)) |
nothing calls this directly
no test coverage detected