From: Max Kellermann Date: Wed, 17 Sep 2008 10:03:43 +0000 (+0200) Subject: code style, indent with tabs III X-Git-Tag: v0.12_alpha1~283 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b126dbbfecd92850528b37b7f580e48601023748;p=ncmpc.git code style, indent with tabs III Follow the same code style als MPD itself. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index 58a3e8f..2318dcf 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -739,113 +739,106 @@ mpdclient_playlist_update_changes(mpdclient_t *c) mpdclient_filelist_t * mpdclient_filelist_free(mpdclient_filelist_t *filelist) { - GList *list = g_list_first(filelist->list); - - D("mpdclient_filelist_free()\n"); - if( list == NULL ) - return NULL; - while( list!=NULL ) - { - filelist_entry_t *entry = list->data; - - if( entry->entity ) - mpd_freeInfoEntity(entry->entity); - g_free(entry); - list=list->next; - } - g_list_free(filelist->list); - g_free(filelist->path); - filelist->path = NULL; - filelist->list = NULL; - filelist->length = 0; - g_free(filelist); + GList *list = g_list_first(filelist->list); + + D("mpdclient_filelist_free()\n"); + if (list == NULL) + return NULL; + while (list != NULL) { + filelist_entry_t *entry = list->data; + + if (entry->entity) + mpd_freeInfoEntity(entry->entity); + g_free(entry); + list=list->next; + } + g_list_free(filelist->list); + g_free(filelist->path); + filelist->path = NULL; + filelist->list = NULL; + filelist->length = 0; + g_free(filelist); - return NULL; + return NULL; } mpdclient_filelist_t * mpdclient_filelist_get(mpdclient_t *c, const gchar *path) { - mpdclient_filelist_t *filelist; - mpd_InfoEntity *entity; - gchar *path_utf8 = locale_to_utf8(path); - gboolean has_dirs_only = TRUE; + mpdclient_filelist_t *filelist; + mpd_InfoEntity *entity; + gchar *path_utf8 = locale_to_utf8(path); + gboolean has_dirs_only = TRUE; + + D("mpdclient_filelist_get(%s)\n", path); + mpd_sendLsInfoCommand(c->connection, path_utf8); + filelist = g_malloc0(sizeof(mpdclient_filelist_t)); + if (path && path[0] && strcmp(path, "/")) { + /* add a dummy entry for ./.. */ + filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); + entry->entity = NULL; + filelist->list = g_list_append(filelist->list, entry); + filelist->length++; + } - D("mpdclient_filelist_get(%s)\n", path); - mpd_sendLsInfoCommand(c->connection, path_utf8); - filelist = g_malloc0(sizeof(mpdclient_filelist_t)); - if( path && path[0] && strcmp(path, "/") ) - { - /* add a dummy entry for ./.. */ - filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); - entry->entity = NULL; - filelist->list = g_list_append(filelist->list, (gpointer) entry); - filelist->length++; - } + while ((entity=mpd_getNextInfoEntity(c->connection))) { + filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); - while( (entity=mpd_getNextInfoEntity(c->connection)) ) - { - filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); - - entry->entity = entity; - filelist->list = g_list_append(filelist->list, (gpointer) entry); - filelist->length++; + entry->entity = entity; + filelist->list = g_list_append(filelist->list, entry); + filelist->length++; - if (has_dirs_only && entity->type != MPD_INFO_ENTITY_TYPE_DIRECTORY) - { - has_dirs_only = FALSE; + if (has_dirs_only && entity->type != MPD_INFO_ENTITY_TYPE_DIRECTORY) { + has_dirs_only = FALSE; + } } - } - - /* If there's an error, ignore it. We'll return an empty filelist. */ - mpdclient_finish_command(c); - - g_free(path_utf8); - filelist->path = g_strdup(path); - filelist->updated = TRUE; - // If there are only directory entities in the filelist, we sort it - if (has_dirs_only) - { - D("mpdclient_filelist_get: only dirs; sorting!\n"); - filelist->list = g_list_sort(filelist->list, compare_filelistentry_dir); - } + /* If there's an error, ignore it. We'll return an empty filelist. */ + mpdclient_finish_command(c); - return filelist; + g_free(path_utf8); + filelist->path = g_strdup(path); + filelist->updated = TRUE; + + // If there are only directory entities in the filelist, we sort it + if (has_dirs_only) { + D("mpdclient_filelist_get: only dirs; sorting!\n"); + filelist->list = g_list_sort(filelist->list, compare_filelistentry_dir); + } + + return filelist; } mpdclient_filelist_t * -mpdclient_filelist_search_utf8(mpdclient_t *c, +mpdclient_filelist_search_utf8(mpdclient_t *c, int exact_match, - int table, + int table, gchar *filter_utf8) { - mpdclient_filelist_t *filelist; - mpd_InfoEntity *entity; + mpdclient_filelist_t *filelist; + mpd_InfoEntity *entity; - D("mpdclient_filelist_search(%s)\n", filter_utf8); - if( exact_match ) - mpd_sendFindCommand(c->connection, table, filter_utf8); - else - mpd_sendSearchCommand(c->connection, table, filter_utf8); - filelist = g_malloc0(sizeof(mpdclient_filelist_t)); + D("mpdclient_filelist_search(%s)\n", filter_utf8); + if (exact_match) + mpd_sendFindCommand(c->connection, table, filter_utf8); + else + mpd_sendSearchCommand(c->connection, table, filter_utf8); + filelist = g_malloc0(sizeof(mpdclient_filelist_t)); - while( (entity=mpd_getNextInfoEntity(c->connection)) ) - { - filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); - - entry->entity = entity; - filelist->list = g_list_append(filelist->list, (gpointer) entry); - filelist->length++; - } - - if( mpdclient_finish_command(c) ) - return mpdclient_filelist_free(filelist); + while ((entity=mpd_getNextInfoEntity(c->connection))) { + filelist_entry_t *entry = g_malloc0(sizeof(filelist_entry_t)); + + entry->entity = entity; + filelist->list = g_list_append(filelist->list, entry); + filelist->length++; + } - filelist->updated = TRUE; + if (mpdclient_finish_command(c)) + return mpdclient_filelist_free(filelist); - return filelist; + filelist->updated = TRUE; + return filelist; } diff --git a/src/screen.c b/src/screen.c index c616715..0b335ef 100644 --- a/src/screen.c +++ b/src/screen.c @@ -626,17 +626,16 @@ screen_init(mpdclient_t *c) /* initialize screens */ i=0; - while( screens[i].get_mode_functions ) - { - struct screen_functions *fn = screens[i].get_mode_functions(); + while (screens[i].get_mode_functions) { + struct screen_functions *fn = screens[i].get_mode_functions(); - if( fn && fn->init ) - fn->init(screen->main_window.w, - screen->main_window.cols, - screen->main_window.rows); + if (fn && fn->init) + fn->init(screen->main_window.w, + screen->main_window.cols, + screen->main_window.rows); - i++; - } + i++; + } #if 0 /* broken */ diff --git a/src/screen_search.c b/src/screen_search.c index 9ec189d..6e2a0d6 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -179,16 +179,14 @@ static void search_clear(mpd_unused screen_t *screen, mpdclient_t *c, gboolean clear_pattern) { - if( filelist ) - { - mpdclient_remove_playlist_callback(c, playlist_changed_callback); - filelist = mpdclient_filelist_free(filelist); - } - if( clear_pattern && pattern ) - { - g_free(pattern); - pattern = NULL; - } + if (filelist) { + mpdclient_remove_playlist_callback(c, playlist_changed_callback); + filelist = mpdclient_filelist_free(filelist); + } + if (clear_pattern && pattern) { + g_free(pattern); + pattern = NULL; + } } #ifdef FUTURE @@ -366,20 +364,22 @@ search_new(screen_t *screen, mpdclient_t *c) static void init(WINDOW *w, int cols, int rows) { - lw = list_window_init(w, cols, rows); + lw = list_window_init(w, cols, rows); } static void quit(void) { - if( search_history ) - string_list_free(search_history); - if( filelist ) - filelist = mpdclient_filelist_free(filelist); - list_window_free(lw); - if( pattern ) - g_free(pattern); - pattern = NULL; + if (search_history) + string_list_free(search_history); + if (filelist) + filelist = mpdclient_filelist_free(filelist); + list_window_free(lw); + + if (pattern) { + g_free(pattern); + pattern = NULL; + } } static void