Jacek Caban : widl: Try to find imported typelib using .tlb extension if it wasn't specified.
Alexandre Julliard
julliard at winehq.org
Fri Jun 16 18:15:09 CDT 2017
Module: wine
Branch: master
Commit: fbdf119e2c8ac4233c4323835ff82fe3ad3de3d7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fbdf119e2c8ac4233c4323835ff82fe3ad3de3d7
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Jun 16 15:25:48 2017 +0200
widl: Try to find imported typelib using .tlb extension if it wasn't specified.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/widl/typelib.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c
index 6ac748f..e8dfcb1 100644
--- a/tools/widl/typelib.c
+++ b/tools/widl/typelib.c
@@ -326,22 +326,42 @@ static void read_msft_importlib(importlib_t *importlib, int fd)
free(typeinfo_offs);
}
+static int open_typelib(const char *name)
+{
+ char *file_name;
+ int fd;
+
+ file_name = wpp_find_include(name, NULL);
+ if(!file_name)
+ return open(name, O_RDONLY | O_BINARY );
+
+ fd = open(file_name, O_RDONLY | O_BINARY );
+ free(file_name);
+ return fd;
+}
+
static void read_importlib(importlib_t *importlib)
{
int fd;
INT magic;
- char *file_name;
- file_name = wpp_find_include(importlib->name, NULL);
- if(file_name) {
- fd = open(file_name, O_RDONLY | O_BINARY );
- free(file_name);
- }else {
- fd = open(importlib->name, O_RDONLY | O_BINARY );
+ fd = open_typelib(importlib->name);
+
+ /* widl extension: if importlib name has no .tlb extension, try using .tlb */
+ if(fd < 0) {
+ const char *p = strrchr(importlib->name, '.');
+ size_t len = p ? p - importlib->name : strlen(importlib->name);
+ if(strcmp(importlib->name + len, ".tlb")) {
+ char *tlb_name = xmalloc(len + 5);
+ memcpy(tlb_name, importlib->name, len);
+ strcpy(tlb_name + len, ".tlb");
+ fd = open_typelib(tlb_name);
+ free(tlb_name);
+ }
}
if(fd < 0)
- error("Could not open importlib %s.\n", importlib->name);
+ error("Could not find importlib %s.\n", importlib->name);
tlb_read(fd, &magic, sizeof(magic));
More information about the wine-cvs
mailing list