aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-15 12:27:29 +0200
committerMax Kellermann <max@duempel.org>2008-09-15 12:27:29 +0200
commit6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b (patch)
treec8f9ebb406e85fcb712e2dae8e5c80a2acaa8421 /src
parent08c055113f2eacd42fde57b952b548ca45e29eb2 (diff)
downloadmpd-6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b.tar.gz
mpd-6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b.tar.xz
mpd-6e81a1b3e08a423c6f4c6976aecae915bd1a3f0b.zip
fixed mixed declaration + code
Although they are allowedd in C99, try to avoid them. Move variable declarations to the top of the current scope.
Diffstat (limited to '')
-rw-r--r--src/screen_lyrics.c12
-rw-r--r--src/screen_search.c8
-rw-r--r--src/src_lyrics.c15
3 files changed, 19 insertions, 16 deletions
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index 8943d4f22..2c770ff59 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -71,6 +71,8 @@ static int store_lyr_hd(void)
char title[512];
static char path[1024];
FILE *lyr_file;
+ int i;
+ char line_buf[1024];
get_text_line(&lyr_text, 0, artist, 512);
get_text_line(&lyr_text, 1, title, 512);
@@ -83,9 +85,6 @@ static int store_lyr_hd(void)
if (lyr_file == NULL)
return -1;
- int i;
- char line_buf[1024];
-
for (i = 3; i <= lyr_text.text->len; i++) {
if(get_text_line(&lyr_text, i, line_buf, 1024) == -1);
fputs(line_buf, lyr_file);
@@ -106,6 +105,9 @@ static gpointer get_lyr(void *c)
{
mpd_Status *status = ((retrieval_spec*)c)->client->status;
mpd_Song *cur = ((retrieval_spec*)c)->client->song;
+ char artist[MAX_SONGNAME_LENGTH];
+ char title[MAX_SONGNAME_LENGTH];
+
//mpdclient_update((mpdclient_t*)c);
if(!(IS_PAUSED(status->state)||IS_PLAYING(status->state))) {
@@ -114,8 +116,6 @@ static gpointer get_lyr(void *c)
}
- char artist[MAX_SONGNAME_LENGTH];
- char title[MAX_SONGNAME_LENGTH];
lock=2;
result = 0;
@@ -160,8 +160,8 @@ list_callback(int idx, int *highlight, void *data)
if ((idx == lyr_text.lines->len && lyr_text.lines->len > 4) ||
((lyr_text.lines->len == 0 || lyr_text.lines->len == 4) &&
idx == 0)) {
- *highlight=3;
src_lyr* selected = g_array_index(src_lyr_stack, src_lyr*, src_selection);
+ *highlight=3;
if (selected != NULL)
return selected->description;
return "";
diff --git a/src/screen_search.c b/src/screen_search.c
index 982fe34e0..dd2353c00 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -247,8 +247,6 @@ search_advanced_query(char *query, mpdclient_t *c)
i=0;
j=0;
while (strv[i] && strlen(strv[i]) > 0 && i < 9) {
- D("strv[%d] = \"%s\"\n", i, strv[i]);
-
int id = search_get_tag_id(strv[i]);
if (id == -1) {
if (table[j]) {
@@ -281,6 +279,9 @@ search_advanced_query(char *query, mpdclient_t *c)
if (advanced_search_mode && j > 0) {
+ int iter;
+ mpd_InfoEntity *entity;
+
/*-----------------------------------------------------------------------
* NOTE (again): This code exists to test a new search ui,
* Its ugly and MUST be redesigned before the next release!
@@ -290,7 +291,6 @@ search_advanced_query(char *query, mpdclient_t *c)
/** stupid - but this is just a test...... (fulhack) */
mpd_startSearch(c->connection, FALSE);
- int iter;
for(iter = 0; iter < 10; iter++) {
mpd_addConstraintSearch(c->connection, table[iter], arg[iter]);
}
@@ -299,8 +299,6 @@ search_advanced_query(char *query, mpdclient_t *c)
fl = g_malloc0(sizeof(mpdclient_filelist_t));
- mpd_InfoEntity *entity;
-
while ((entity=mpd_getNextInfoEntity(c->connection))) {
filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t));
diff --git a/src/src_lyrics.c b/src/src_lyrics.c
index 4d41aea37..448c301ad 100644
--- a/src/src_lyrics.c
+++ b/src/src_lyrics.c
@@ -28,10 +28,12 @@
int get_text_line(formed_text *text, int num, char *dest, int len)
{
+ int linelen;
+
memset(dest, '\0', len*sizeof(char));
if (num >= text->lines->len - 1)
return -1;
- int linelen;
+
if (num == 0) {
linelen = g_array_index(text->lines, int, num);
memcpy(dest, text->text->str, linelen*sizeof(char));
@@ -128,9 +130,10 @@ void src_lyr_stack_init(void)
int src_lyr_init(void)
{
+ int i = 0;
+
src_lyr_stack_init ();
- int i = 0;
while (g_array_index (src_lyr_stack, src_lyr*, i) != NULL) {
src_lyr *i_stack;
i_stack = g_array_index (src_lyr_stack, src_lyr*, i);
@@ -150,12 +153,14 @@ int get_lyr_by_src (int priority, char *artist, char *title)
static int src_lyr_load_plugin_file(const char *file)
{
GString *path;
+ src_lyr *new_src;
+ src_lyr_plugin_register register_func;
+
path = g_string_new (PLUGIN_DIR_SYSTEM);
g_string_append (path, "/");
g_string_append (path, file);
- src_lyr_plugin_register register_func;
- src_lyr *new_src = malloc (sizeof (src_lyr));
+ new_src = malloc(sizeof(src_lyr));
new_src->module = g_module_open (path->str, G_MODULE_BIND_LAZY);
if (!g_module_symbol (new_src->module, "register_me", (gpointer*) &register_func))
return -1;
@@ -178,13 +183,13 @@ static void src_lyr_plugins_load_from_dir(GDir *plugin_dir)
static int src_lyr_plugins_load(void)
{
GDir *plugin_dir;
+ GString *user_dir_path;
plugin_dir = g_dir_open (PLUGIN_DIR_SYSTEM, 0, NULL);
if (plugin_dir == NULL)
return -1;
src_lyr_plugins_load_from_dir (plugin_dir);
- GString *user_dir_path;
user_dir_path = g_string_new (g_get_home_dir());
g_string_append (user_dir_path, PLUGIN_DIR_USER);