Module: wine Branch: master Commit: 77e880e6d22ef9be031f783fbb4b6a5e8c8826e8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=77e880e6d22ef9be031f783fb...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Mar 23 16:15:44 2020 +0100
dbghelp: Use file_name helper in more places.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dbghelp/dbghelp_private.h | 2 ++ dlls/dbghelp/elf_module.c | 14 +++++--------- dlls/dbghelp/macho_module.c | 21 +++++++-------------- dlls/dbghelp/module.c | 4 ++-- dlls/dbghelp/path.c | 4 ++-- 5 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 8fa9e799c0..81ae1507e0 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -670,6 +670,8 @@ extern BOOL path_find_symbol_file(const struct process* pcs, const struc PCSTR full_path, const GUID* guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN; extern WCHAR *get_dos_file_name(const WCHAR *filename) DECLSPEC_HIDDEN; +extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN; +extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN;
/* pe_module.c */ extern BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS* nth) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index a11e73a0e1..34fffdae5b 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -727,8 +727,7 @@ static const Elf64_Sym *elf_lookup_symtab(const struct module* module, { compiland_name = source_get(module, ((const struct symt_compiland*)compiland)->source); - compiland_basename = strrchr(compiland_name, '/'); - if (!compiland_basename++) compiland_basename = compiland_name; + compiland_basename = file_nameA(compiland_name); } else compiland_name = compiland_basename = NULL;
@@ -745,8 +744,7 @@ static const Elf64_Sym *elf_lookup_symtab(const struct module* module, const char* filename = source_get(module, ste->compiland->source); if (strcmp(filename, compiland_name)) { - base = strrchr(filename, '/'); - if (!base++) base = filename; + base = file_nameA(filename); if (strcmp(base, compiland_basename)) continue; } } @@ -1434,7 +1432,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename, if (strstrW(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */ ret = elf_load_file(pcs, filename, load_offset, dyn_addr, elf_info); /* if relative pathname, try some absolute base dirs */ - if (!ret && !strchrW(filename, '/')) + if (!ret && filename == file_name(filename)) { ret = elf_load_file_from_path(pcs, filename, load_offset, dyn_addr, getenv("PATH"), elf_info) || @@ -1689,8 +1687,7 @@ static BOOL elf_load_cb(const WCHAR* name, unsigned long load_addr, /* memcmp is needed for matches when bufstr contains also version information * el->name: libc.so, name: libc.so.6.0 */ - p = strrchrW(name, '/'); - if (!p++) p = name; + p = file_name(name); }
if (!el->name || !memcmp(p, el->name, lstrlenW(el->name) * sizeof(WCHAR))) @@ -1724,8 +1721,7 @@ struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned /* do only the lookup from the filename, not the path (as we lookup module * name in the process' loaded module list) */ - el.name = strrchrW(name, '/'); - if (!el.name++) el.name = name; + el.name = file_name(name); el.ret = FALSE;
if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el)) diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 8fa05d312a..4bc0a3e903 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1193,10 +1193,7 @@ static void find_and_map_dsym(struct process *pcs, struct module* module) if (!fmap->uuid) return;
- if ((p = strrchrW(module->module.LoadedImageName, '/'))) - p++; - else - p = module->module.LoadedImageName; + p = file_name(module->module.LoadedImageName); len = strlenW(module->module.LoadedImageName) + strlenW(dot_dsym) + strlenW(dsym_subpath) + strlenW(p) + 1; path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!path) @@ -1637,19 +1634,17 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam if (strstrW(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */
/* If has no directories, try PATH first. */ - if (!strchrW(filename, '/')) + p = file_name(filename); + if (p == filename) { ret = macho_load_file_from_path(pcs, filename, load_addr, getenv("PATH"), macho_info); } /* Try DYLD_LIBRARY_PATH, with just the filename (no directories). */ if (!ret) - { - if ((p = strrchrW(filename, '/'))) p++; - else p = filename; ret = macho_load_file_from_path(pcs, p, load_addr, getenv("DYLD_LIBRARY_PATH"), macho_info); - } + /* Try the path as given. */ if (!ret) ret = macho_load_file(pcs, filename, load_addr, macho_info); @@ -1661,7 +1656,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam fallback = "/usr/local/lib:/lib:/usr/lib"; ret = macho_load_file_from_path(pcs, p, load_addr, fallback, macho_info); } - if (!ret && !strchrW(filename, '/')) + if (!ret && p == filename) ret = macho_load_file_from_dll_path(pcs, filename, load_addr, macho_info);
return ret; @@ -1957,8 +1952,7 @@ static BOOL macho_load_cb(const WCHAR* name, unsigned long addr, void* user) /* memcmp is needed for matches when bufstr contains also version information * ml->name: libc.so, name: libc.so.6.0 */ - p = strrchrW(name, '/'); - if (!p++) p = name; + p = file_name(name); if (!memcmp(p, ml->name, lstrlenW(ml->name) * sizeof(WCHAR))) { ml->ret = macho_search_and_load_file(ml->pcs, name, addr, &ml->macho_info); @@ -1989,8 +1983,7 @@ struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsign /* do only the lookup from the filename, not the path (as we lookup module * name in the process' loaded module list) */ - ml.name = strrchrW(name, '/'); - if (!ml.name++) ml.name = name; + ml.name = file_name(name); ml.ret = FALSE;
if (!macho_enum_modules_internal(pcs, NULL, macho_load_cb, &ml)) diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 0a90595b8c..74502a9d6b 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -82,14 +82,14 @@ static BOOL is_wine_loader(const WCHAR *module) static const WCHAR wineW[] = {'w','i','n','e',0}; static const WCHAR suffixW[] = {'6','4',0}; const WCHAR *filename = get_filename(module, NULL); - const char *ptr, *p; + const char *ptr; BOOL ret = FALSE; WCHAR *buffer; DWORD len;
if ((ptr = getenv("WINELOADER"))) { - if ((p = strrchr(ptr, '/'))) ptr = p + 1; + ptr = file_nameA(ptr); len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, NULL, 0 ); buffer = heap_alloc( len * sizeof(WCHAR) ); MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, buffer, len ); diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c index 704fbbdee3..1b04d97e13 100644 --- a/dlls/dbghelp/path.c +++ b/dlls/dbghelp/path.c @@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); static inline BOOL is_sepA(char ch) {return ch == '/' || ch == '\';} static inline BOOL is_sep(WCHAR ch) {return ch == '/' || ch == '\';}
-static inline const char* file_nameA(const char* str) +const char* file_nameA(const char* str) { const char* p;
@@ -42,7 +42,7 @@ static inline const char* file_nameA(const char* str) return p + 1; }
-static inline const WCHAR* file_name(const WCHAR* str) +const WCHAR* file_name(const WCHAR* str) { const WCHAR* p;