-lfoo searches: foo.def, libfoo.def, foo.dll, libfoo.dll
Unified · Split
| @@ -1611,15 +1611,18 @@ PUB_FN int pe_load_file(struct TCCState *s1, const char *filename, int fd) · 1610 unmodified lines | ||
| 1611 | 1611 | return ret; |
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | −int pe_add_dll(struct TCCState *s, const char *libraryname) | |
| 1614 | +int pe_add_dll(struct TCCState *s, const char *libname) | |
| 1615 | 1615 | { |
| 1616 | − char buf[MAX_PATH]; | |
| 1617 | − snprintf(buf, sizeof(buf), "%s.def", libraryname); | |
| 1618 | − if (tcc_add_dll(s, buf, 0) == 0) | |
| 1619 | − return 0; | |
| 1620 | − snprintf(buf, sizeof(buf), "%s.dll", libraryname); | |
| 1621 | − if (tcc_add_dll(s, buf, 0) == 0) | |
| 1622 | − return 0; | |
| 1616 | + static const char *pat[] = { | |
| 1617 | + "%s.def", "lib%s.def", "%s.dll", "lib%s.dll", NULL | |
| 1618 | + }; | |
| 1619 | + const char **p = pat; | |
| 1620 | + do { | |
| 1621 | + char buf[MAX_PATH]; | |
| 1622 | + snprintf(buf, sizeof(buf), *p, libname); | |
| 1623 | + if (tcc_add_dll(s, buf, 0) == 0) | |
| 1624 | + return 0; | |
| 1625 | + } while (*++p); | |
| 1623 | 1626 | return -1; |
| 1624 | 1627 | } |
| 1625 | 1628 | |