| 806 | /* MODULES */ |
| 807 | |
| 808 | txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot) |
| 809 | { |
| 810 | txLinker* linker = (txLinker*)(the->context); |
| 811 | char name[C_PATH_MAX]; |
| 812 | char buffer[C_PATH_MAX]; |
| 813 | char separator; |
| 814 | txInteger dot = 0; |
| 815 | txInteger i = 0; |
| 816 | txInteger hash = 0; |
| 817 | txString slash; |
| 818 | txString path; |
| 819 | txID id; |
| 820 | |
| 821 | fxToStringBuffer(the, slot, name, sizeof(name) - 4); |
| 822 | if (name[0] == '.') { |
| 823 | if (name[1] == '/') { |
| 824 | dot = 1; |
| 825 | i = 1; |
| 826 | } |
| 827 | else if ((name[1] == '.') && (name[2] == '/')) { |
| 828 | dot = 2; |
| 829 | i = 2; |
| 830 | while ((name[i + 1] == '.') && (name[i + 2] == '.') && (name[i + 3] == '/')) { |
| 831 | dot++; |
| 832 | i += 3; |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | else if (name[0] == '#') { |
| 837 | hash = 1; |
| 838 | } |
| 839 | else if (c_strncmp(name, "moddable:", 9) == 0) |
| 840 | c_memmove(name, name + 9, c_strlen(name) - 8); |
| 841 | |
| 842 | separator = linker->base[0]; |
| 843 | fxSlashPath(name, '/', separator); |
| 844 | slash = c_strrchr(name, separator); |
| 845 | if (!slash) |
| 846 | slash = name; |
| 847 | slash = c_strrchr(slash, '.'); |
| 848 | if (slash && (!c_strcmp(slash, ".js") || !c_strcmp(slash, ".mjs") || !c_strcmp(slash, ".xsb"))) |
| 849 | *slash = 0; |
| 850 | |
| 851 | if (dot > 0) { |
| 852 | if (moduleID == XS_NO_ID) |
| 853 | return XS_NO_ID; |
| 854 | buffer[0] = separator; |
| 855 | path = buffer + 1; |
| 856 | c_strcpy(path, fxGetKeyName(the, moduleID)); |
| 857 | slash = c_strrchr(buffer, separator); |
| 858 | if (!slash) |
| 859 | return XS_NO_ID; |
| 860 | *slash = 0; |
| 861 | dot--; |
| 862 | while (dot > 0) { |
| 863 | slash = c_strrchr(buffer, separator); |
| 864 | if (!slash) |
| 865 | return XS_NO_ID; |
nothing calls this directly
no test coverage detected