summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 88d9c23)
raw | patch | inline | side by side (parent: 88d9c23)
author | Max Kellermann <max@duempel.org> | |
Fri, 2 Oct 2009 17:23:32 +0000 (19:23 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 2 Oct 2009 17:23:32 +0000 (19:23 +0200) |
After parsing the query, return NULL immediately if no valid advanced
search query could be parsed. Our caller do_search() will then fall
back to the simple search.
search query could be parsed. Our caller do_search() will then fall
back to the simple search.
src/screen_search.c | patch | blob | history |
diff --git a/src/screen_search.c b/src/screen_search.c
index b1d480ddb207c3fb3e4bde5b42b9befbd88c15d5..3deaf09b6c427810e810baf3f8d8047e60ce52ba 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
int table[10];
char *arg[10];
struct filelist *fl = NULL;
+ struct mpd_entity *entity;
advanced_search_mode = FALSE;
if (strchr(query, ':') == NULL)
g_strfreev(strv);
+ if (!advanced_search_mode || j == 0) {
+ for (i = 0; arg[i] != NULL; ++i)
+ g_free(arg[i]);
+ return NULL;
+ }
- if (advanced_search_mode && j > 0) {
- int iter;
- struct mpd_entity *entity;
-
- /*-----------------------------------------------------------------------
- * NOTE (again): This code exists to test a new search ui,
- * Its ugly and MUST be redesigned before the next release!
- * + the code below should live in mpdclient.c
- *-----------------------------------------------------------------------
- */
- /** stupid - but this is just a test...... (fulhack) */
- mpd_search_db_songs(c->connection, false);
-
- for(iter = 0; iter < 10 && arg[iter] != NULL; iter++) {
- if (table[iter] == SEARCH_URI)
- mpd_search_add_uri_constraint(c->connection,
- MPD_OPERATOR_DEFAULT,
- arg[iter]);
- else
- mpd_search_add_tag_constraint(c->connection,
- MPD_OPERATOR_DEFAULT,
- table[iter], arg[iter]);
- }
+ /*-----------------------------------------------------------------------
+ * NOTE (again): This code exists to test a new search ui,
+ * Its ugly and MUST be redesigned before the next release!
+ * + the code below should live in mpdclient.c
+ *-----------------------------------------------------------------------
+ */
+ /** stupid - but this is just a test...... (fulhack) */
+ mpd_search_db_songs(c->connection, false);
+
+ for (i = 0; i < 10 && arg[i] != NULL; i++) {
+ if (table[i] == SEARCH_URI)
+ mpd_search_add_uri_constraint(c->connection,
+ MPD_OPERATOR_DEFAULT,
+ arg[i]);
+ else
+ mpd_search_add_tag_constraint(c->connection,
+ MPD_OPERATOR_DEFAULT,
+ table[i], arg[i]);
+ }
- mpd_search_commit(c->connection);
+ mpd_search_commit(c->connection);
- fl = filelist_new();
+ fl = filelist_new();
- while ((entity = mpd_recv_entity(c->connection)) != NULL)
- filelist_append(fl, entity);
+ while ((entity = mpd_recv_entity(c->connection)) != NULL)
+ filelist_append(fl, entity);
- if (!mpd_response_finish(c->connection)) {
- filelist_free(fl);
- fl = NULL;
+ if (!mpd_response_finish(c->connection)) {
+ filelist_free(fl);
+ fl = NULL;
- mpdclient_handle_error(c);
- }
+ mpdclient_handle_error(c);
}
- i=0;
- while( arg[i] )
- g_free(arg[i++]);
+ for (i = 0; arg[i] != NULL; ++i)
+ g_free(arg[i]);
return fl;
}