From 62dcad589592633db6cf3e47b2256513c84767f4 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 31 Jul 2012 19:11:50 +0000 Subject: [PATCH] Give it a better chance to work on MacOS X --- src/asm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/asm.c b/src/asm.c index dda5f16..5517bb1 100644 --- a/src/asm.c +++ b/src/asm.c @@ -302,6 +302,11 @@ int asm_plugin_list(AsmPluginType type, int decode) struct dirent * de; size_t len; char const * sep = ""; +#ifdef __APPLE__ + char const ext[] = ".dylib"; +#else + char const ext[] = ".so"; +#endif AsmArch * arch; AsmFormat * format; @@ -325,11 +330,11 @@ int asm_plugin_list(AsmPluginType type, int decode) } while((de = readdir(dir)) != NULL) { - if((len = strlen(de->d_name)) < 4) + if((len = strlen(de->d_name)) < sizeof(ext)) continue; - if(strcmp(".so", &de->d_name[len - 3]) != 0) + if(strcmp(ext, &de->d_name[len - sizeof(ext) + 1]) != 0) continue; - de->d_name[len - 3] = '\0'; + de->d_name[len - sizeof(ext) + 1] = '\0'; if(type == APT_ARCH && (arch = arch_new(de->d_name)) != NULL && (decode == 0 || arch_can_decode(arch))) {