From 1d0cc3149668703ee990fdd562582dccc73c8864 Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Fri, 20 Sep 2013 17:26:42 +0700 Subject: modules: store module name in the module struct. * m4/m4private.h (m4_module): Add name field. * m4/module.c (m4__module_open): Save the name field. * m4/path.c (m4_load_filename): Pass the raw filename to m4_module_load. * m4/module.c (m4_get_module_name): Replace all the ltdl twiddling with returning the saved name field. Signed-off-by: Gary V. Vaughan --- m4/m4private.h | 1 + m4/module.c | 14 +++++--------- m4/path.c | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/m4/m4private.h b/m4/m4private.h index 35957223..916330ca 100644 --- a/m4/m4private.h +++ b/m4/m4private.h @@ -178,6 +178,7 @@ extern void m4__builtin_print (m4_obstack *, const m4__builtin *, bool, /* Representation of a loaded m4 module. */ struct m4_module { + const char *name; /* Name of the module. */ lt_dlhandle handle; /* All ltdl module information. */ m4__builtin *builtins; /* Sorted array of builtins. */ m4_macro *macros; /* Unsorted array of macros. */ diff --git a/m4/module.c b/m4/module.c index a2215f0e..db26198a 100644 --- a/m4/module.c +++ b/m4/module.c @@ -79,13 +79,8 @@ static lt_dlinterface_id iface_id = NULL; const char * m4_get_module_name (const m4_module *module) { - const lt_dlinfo *info; - - assert (module && module->handle); - - info = lt_dlgetinfo (module->handle); - - return info ? info->name : NULL; + assert (module); + return module->name; } void * @@ -212,7 +207,7 @@ install_macro_table (m4 *context, m4_module *module) m4_debug_message (context, M4_DEBUG_TRACE_MODULE, _("module %s: macros loaded"), - m4_get_module_name (module)); + m4_get_module_name (module)); } } @@ -229,7 +224,7 @@ m4_module_load (m4 *context, const char *name, m4_obstack *obs) { install_builtin_table (context, module); install_macro_table (context, module); - } + } } return module; @@ -417,6 +412,7 @@ m4__module_open (m4 *context, const char *name, m4_obstack *obs) const char *err; module = (m4_module *) xzalloc (sizeof *module); + module->name = xstrdup (name); module->handle = handle; /* clear out any stale errors, since we have to use diff --git a/m4/path.c b/m4/path.c index c69cdbac..9437e936 100644 --- a/m4/path.c +++ b/m4/path.c @@ -299,7 +299,7 @@ m4_load_filename (m4 *context, const m4_call_info *caller, && suffix && (STREQ (suffix, LT_MODULE_EXT) || STREQ (suffix, ".la"))) { - m4_module_load (context, filepath, obs); + m4_module_load (context, filename, obs); } else { -- cgit v1.2.1