diff options
author | Tim Janik <timj@gtk.org> | 2001-05-27 18:28:58 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2001-05-27 18:28:58 +0000 |
commit | e28e398eb03fcfc467524d17fed666d1afc6dc82 (patch) | |
tree | 0dbcab04a38b74ed3bbf29c52c95e78f3dab7efd /gmodule | |
parent | 477106292a13666e1b97921957f84ef35312c56f (diff) | |
download | glib-e28e398eb03fcfc467524d17fed666d1afc6dc82.tar.gz glib-e28e398eb03fcfc467524d17fed666d1afc6dc82.tar.bz2 glib-e28e398eb03fcfc467524d17fed666d1afc6dc82.zip |
unlock context when bailing out with a warning. (g_main_context_check):
Sun May 27 05:09:18 2001 Tim Janik <timj@gtk.org>
* gmain.c (g_main_context_prepare): unlock context when bailing
out with a warning.
(g_main_context_check): same here.
* gmain.c (g_main_context_check): before returning due to
changed pollfds, unlock context.
Sun May 27 04:52:28 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc] (g_signal_stop_emission_by_name): added variant
to stop signal emissions through a detailed_signal string.
* gsignal.c (signal_emit_R) (g_signal_emit_valist): account for
the fact that g_value_* functions may cause signal emissons by
unlocking the global signal system lock around g_value_* functions.
(signal_emit_unlocked_R): renamed this from signal_emit_R() to reflect
that this functions acquires the lock on its own now.
Diffstat (limited to 'gmodule')
-rw-r--r-- | gmodule/ChangeLog | 7 | ||||
-rw-r--r-- | gmodule/gmodule.c | 69 |
2 files changed, 49 insertions, 27 deletions
diff --git a/gmodule/ChangeLog b/gmodule/ChangeLog index 3a37a82d9..15e629e5f 100644 --- a/gmodule/ChangeLog +++ b/gmodule/ChangeLog @@ -1,3 +1,10 @@ +Thu May 24 03:43:12 2001 Tim Janik <timj@gtk.org> + + * gmodule.c (g_module_open): reordered code so we have a single + module loading point (for reliable error messages). do access() + tests to figure plausible file names. + make error messages more verbose so users canfigure what's going on. + 2001-04-20 Dan Winship <danw@ximian.com> * gmodule-dyld.c: gmodule implementation for Darwin/Mac OS X diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index e006b8b60..49cadf95a 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -124,12 +124,18 @@ g_module_find_by_name (const gchar *name) } static inline void -g_module_set_error (const gchar *error) +g_module_set_error_unduped (const gchar *error) { g_static_private_set (&module_error_private, g_strdup (error), g_free); errno = 0; } +static inline void +g_module_set_error (const gchar *error) +{ + g_module_set_error_unduped (g_strdup (error)); +} + /* --- include platform specifc code --- */ #define SUPPORT_OR_RETURN(rv) { g_module_set_error (NULL); } @@ -200,7 +206,7 @@ parse_libtool_archive (const gchar* libtool_name) int fd = open (libtool_name, O_RDONLY, 0); if (fd < 0) { - g_module_set_error ("couldn't open libtool archive"); + g_module_set_error_unduped (g_strdup_printf ("failed to open libtool archive \"%s\"", libtool_name)); return NULL; } /* search libtool's dlname specification */ @@ -224,7 +230,7 @@ parse_libtool_archive (const gchar* libtool_name) (token == TOKEN_INSTALLED ? G_TOKEN_IDENTIFIER : G_TOKEN_STRING)) { - g_module_set_error ("libtool archive has unknown format"); + g_module_set_error_unduped (g_strdup_printf ("unable to parse libtool archive \"%s\"", libtool_name)); g_free (lt_dlname); g_free (lt_libdir); @@ -270,7 +276,8 @@ parse_libtool_archive (const gchar* libtool_name) } static inline gboolean -g_str_check_suffix (const gchar* string, const gchar* suffix) +str_check_suffix (const gchar* string, + const gchar* suffix) { guint string_len = strlen (string); guint suffix_len = strlen (suffix); @@ -286,7 +293,8 @@ g_module_open (const gchar *file_name, GModuleFlags flags) { GModule *module; - gpointer handle; + gpointer handle = NULL; + gchar *name = NULL; SUPPORT_OR_RETURN (NULL); @@ -321,42 +329,49 @@ g_module_open (const gchar *file_name, g_static_rec_mutex_unlock (&g_module_global_lock); return module; } - - /* First we try to open the module as provided */ - handle = _g_module_open (file_name, (flags & G_MODULE_BIND_LAZY) != 0); - /* If not found, we check, if it is a libtool archive */ - if (!handle && g_str_check_suffix (file_name, ".la")) + /* check whether we have a readable file right away */ + if (g_file_test (file_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) + name = g_strdup (file_name); + /* try completing file name with standard library suffix */ + if (!name) { - gchar *name = parse_libtool_archive (file_name); - if (name) + name = g_strconcat (file_name, "." G_MODULE_SUFFIX, NULL); + if (!g_file_test (file_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0); g_free (name); + name = NULL; } } - - /* If still not found, we check, if it is a library name without suffix */ - if (!handle && !g_str_check_suffix (file_name, "." G_MODULE_SUFFIX)) + /* last resort, try appending libtool suffix */ + if (!name) { - gchar *name = g_strconcat (file_name, "." G_MODULE_SUFFIX, NULL); - handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0); - g_free (name); + name = g_strconcat (file_name, ".la"); + if (!g_file_test (name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) + { + g_free (name); + name = NULL; + } } - /* If still not found, we check, if it is a libtool archive name - * without suffix */ - if (!handle && !g_str_check_suffix (file_name, ".la")) + /* ok, try loading the module */ + if (name) { - gchar *la_name = g_strconcat (file_name, ".la", NULL); - gchar *name = parse_libtool_archive (la_name); - if (name) + /* if it's a libtool archive, figure library file to load */ + if (str_check_suffix (name, ".la")) /* libtool archive? */ { - handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0); + gchar *real_name = parse_libtool_archive (name); + + /* real_name might be NULL, but then module error is already set */ g_free (name); + name = real_name; } - g_free (la_name); + if (name) + handle = _g_module_open (name, (flags & G_MODULE_BIND_LAZY) != 0); } + else + g_module_set_error_unduped (g_strdup_printf ("unable to access file \"%s\"", file_name)); + g_free (name); if (handle) { |