summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 78c92e9)
raw | patch | inline | side by side (parent: 78c92e9)
author | Thomas Jansen <mithi@mithi.net> | |
Wed, 7 Oct 2009 21:33:34 +0000 (23:33 +0200) | ||
committer | Thomas Jansen <mithi@mithi.net> | |
Wed, 7 Oct 2009 21:33:34 +0000 (23:33 +0200) |
Handle missing artist and/or title for lyrics by defining an empty list of
plugins that fails almost immediately. Note that args in lyrics_load may now
start with NULL as the first array element. make_argv() in plugin.c made the
assumption that at least one argument is passed. If the first argument is
NULL a bogus pointer is returned by make_argv(). By converting do {} while
into while {}, we allow the first argument to be NULL.
plugins that fails almost immediately. Note that args in lyrics_load may now
start with NULL as the first array element. make_argv() in plugin.c made the
assumption that at least one argument is passed. If the first argument is
NULL a bogus pointer is returned by make_argv(). By converting do {} while
into while {}, we allow the first argument to be NULL.
src/lyrics.c | patch | blob | history | |
src/plugin.c | patch | blob | history |
diff --git a/src/lyrics.c b/src/lyrics.c
index 43800eb48fb6d128dd65623f4084ee82a5d28899..3f73690fd13fb6301555434ad663df3134a12aaf 100644 (file)
--- a/src/lyrics.c
+++ b/src/lyrics.c
#include <assert.h>
-static struct plugin_list plugins;
+static struct plugin_list empty, plugins;
void lyrics_init(void)
{
+ plugin_list_init(&empty);
plugin_list_init(&plugins);
plugin_list_load_directory(&plugins, LYRICS_PLUGIN_DIR);
}
void lyrics_deinit(void)
{
+ plugin_list_deinit(&empty);
plugin_list_deinit(&plugins);
}
{
const char *args[3] = { artist, title, NULL };
- assert(artist != NULL);
- assert(title != NULL);
+ if (artist == NULL || title == NULL)
+ return plugin_run(&empty, args, callback, data);
return plugin_run(&plugins, args, callback, data);
}
diff --git a/src/plugin.c b/src/plugin.c
index d7849009887ae92e9c1fba785376a2b465e6b098..d89e210b1bd3e7bf456817b4ac0557263491ee22 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
/* reserve space for the program name */
*ret++ = NULL;
- do {
+ while (*args != NULL)
*ret++ = g_strdup(*args++);
- } while (*args != NULL);
/* end of argument vector */
*ret++ = NULL;