Code

removed the debugging function D()
authorMax Kellermann <max@duempel.org>
Thu, 2 Oct 2008 13:44:21 +0000 (15:44 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 2 Oct 2008 13:44:21 +0000 (15:44 +0200)
gdb is for debugging.  We don't need D() calls littered all over.

13 files changed:
src/conf.c
src/main.c
src/mpdclient.c
src/ncmpc.h
src/options.c
src/screen.c
src/screen_artist.c
src/screen_browser.c
src/screen_file.c
src/screen_play.c
src/screen_search.c
src/support.c
src/utils.c

index 557024dc52967ce726fda045552ea9dab03bb62a..79bbfd3a15effaa1c122a4bde89d0d29e0b0f0b5 100644 (file)
@@ -362,7 +362,6 @@ read_rc_file(char *filename, options_t *options)
   if( filename==NULL )
     return -1;
 
-  D("Reading configuration file %s\n", filename);
   if( (fd=open(filename,O_RDONLY)) <0 )
     {
       perror(filename);
@@ -474,8 +473,6 @@ read_rc_file(char *filename, options_t *options)
                {
                    g_free(options->timedisplay_type);
                    options->timedisplay_type=g_strdup(parse_timedisplay_type(value));
-                   D("deb");
-                   D(options->timedisplay_type);
                }
              /* color definition */
              else if( !strcasecmp(CONF_COLOR_DEFINITION, name) )
@@ -587,14 +584,10 @@ read_rc_file(char *filename, options_t *options)
                fprintf(stderr, 
                        _("Unknown configuration parameter: %s\n"), 
                        name);
-             D("conf>  %s = %s %s\n", name, value,
-               match_found ? "" : "- UNKNOWN SETTING!" );
            }
        }         
     }
 
-  D("--\n\n");
-
   if( free_filename )
     g_free(filename);
  
index 28cce938f97813ad103a7c013e89d2a5a21395b0..f6043d48a9613bd4e8e93b9e897049b57f4d86c2 100644 (file)
@@ -67,7 +67,6 @@ static void
 error_callback(mpd_unused mpdclient_t *c, gint error, const gchar *msg)
 {
        error = error & 0xFF;
-       D("Error [%d:%d]> \"%s\"\n", error, GET_ACK_ERROR_CODE(error), msg);
        switch (error) {
        case MPD_ERROR_CONNPORT:
        case MPD_ERROR_NORESPONSE:
@@ -138,7 +137,6 @@ catch_sigint(mpd_unused int sig)
 static void
 catch_sigcont(mpd_unused int sig)
 {
-       D("catch_sigcont()\n");
 #ifdef ENABLE_RAW_MODE
        reset_prog_mode(); /* restore tty modes */
        refresh();
@@ -179,24 +177,6 @@ catch_sigwinch(mpd_unused int sig)
        timer_sigwinch_id = g_timeout_add(100, timer_sigwinch, NULL);
 }
 
-#ifndef NDEBUG
-void 
-D(const char *format, ...)
-{
-  if( options.debug )
-    {
-      gchar *msg;
-      va_list ap;
-  
-      va_start(ap,format);
-      msg = g_strdup_vprintf(format,ap);
-      va_end(ap);
-      fprintf(stderr, "%s", msg);
-      g_free(msg);
-    }
-}
-#endif
-
 static gboolean
 timer_mpd_update(gpointer data);
 
@@ -351,7 +331,6 @@ main(int argc, const char *argv[])
        setlocale(LC_CTYPE,"");
        /* initialize charset conversions */
        charset_init(g_get_charset(&charset));
-       D("charset: %s\n", charset);
 #endif
 
        /* initialize i18n support */
index 5098226d4727ac51c20f6e6d278783002cf0571a..dbf285e0727bf60f941852102c308ab2984f758a 100644 (file)
@@ -232,10 +232,6 @@ mpdclient_update(mpdclient_t *c)
        c->status = mpd_getStatus(c->connection);
        if ((retval=mpdclient_finish_command(c)))
                return retval;
-#ifndef NDEBUG
-       if (c->status->error)
-               D("status> %s\n", c->status->error);
-#endif
 
        /* check if the playlist needs an update */
        if (c->playlist.id != c->status->playlist) {
@@ -266,7 +262,6 @@ mpdclient_cmd_play(mpdclient_t *c, gint idx)
 #ifdef ENABLE_SONG_ID
        struct mpd_song *song = playlist_get_song(c, idx);
 
-       D("Play id:%d\n", song ? song->id : -1);
        if (song)
                mpd_sendPlayIdCommand(c->connection, song->id);
        else
@@ -344,7 +339,6 @@ mpdclient_cmd_prev(mpdclient_t *c)
 gint
 mpdclient_cmd_seek(mpdclient_t *c, gint id, gint pos)
 {
-       D("Seek id:%d\n", id);
        mpd_sendSeekIdCommand(c->connection, id, pos);
        return mpdclient_finish_command(c);
 }
@@ -465,7 +459,6 @@ mpdclient_cmd_delete(mpdclient_t *c, gint idx)
 
        /* send the delete command to mpd */
 #ifdef ENABLE_SONG_ID
-       D("Delete id:%d\n", song->id);
        mpd_sendDeleteIdCommand(c->connection, song->id);
 #else
        mpd_sendDeleteCommand(c->connection, idx);
@@ -513,10 +506,8 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index)
 
        /* send the move command to mpd */
 #ifdef ENABLE_SONG_ID
-       D("Swapping id:%d with id:%d\n", song1->id, song2->id);
        mpd_sendSwapIdCommand(c->connection, song1->id, song2->id);
 #else
-       D("Moving index %d to id:%d\n", old_index, new_index);
        mpd_sendMoveCommand(c->connection, old_index, new_index);
 #endif
        if( (n=mpdclient_finish_command(c)) )
@@ -534,7 +525,6 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index)
 #endif
 
        /* call playlist updated callback */
-       D("move> new_index=%d, old_index=%d\n", new_index, old_index);
        mpdclient_playlist_callback(c, PLAYLIST_EVENT_MOVE, (gpointer) &new_index);
 
        return 0;
@@ -668,8 +658,6 @@ mpdclient_playlist_update(mpdclient_t *c)
 {
        mpd_InfoEntity *entity;
 
-       D("mpdclient_playlist_update() [%lld]\n", c->status->playlist);
-
        if (MPD_ERROR(c))
                return -1;
 
@@ -700,9 +688,6 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
 {
        mpd_InfoEntity *entity;
 
-       D("mpdclient_playlist_update_changes() [%lld -> %lld]\n",
-         c->status->playlist, c->playlist.id);
-
        if (MPD_ERROR(c))
                return -1;
 
@@ -713,12 +698,9 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
 
                if (song->pos >= 0 && (guint)song->pos < c->playlist.list->len) {
                        /* update song */
-                       D("updating pos:%d, id=%d - %s\n",
-                         song->pos, song->id, song->file);
                        playlist_replace(&c->playlist, song->pos, song);
                } else {
                        /* add a new song */
-                       D("adding song at pos %d\n", song->pos);
                        playlist_append(&c->playlist, song);
                }
 
@@ -730,7 +712,6 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
                guint pos = c->playlist.list->len - 1;
 
                /* Remove the last playlist entry */
-               D("removing song at pos %d\n", pos);
                playlist_remove(&c->playlist, pos);
        }
 
@@ -763,7 +744,6 @@ mpdclient_filelist_get(mpdclient_t *c, const gchar *path)
        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 = filelist_new(path);
        if (path && path[0] && strcmp(path, "/"))
@@ -784,10 +764,8 @@ mpdclient_filelist_get(mpdclient_t *c, const gchar *path)
        g_free(path_utf8);
 
        // If there are only directory entities in the filelist, we sort it
-       if (has_dirs_only) {
-               D("mpdclient_filelist_get: only dirs; sorting!\n");
+       if (has_dirs_only)
                filelist_sort(filelist, compare_filelistentry_dir);
-       }
 
        return filelist;
 }
@@ -801,7 +779,6 @@ mpdclient_filelist_search_utf8(mpdclient_t *c,
        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
@@ -829,7 +806,6 @@ mpdclient_filelist_search(mpdclient_t *c,
        mpdclient_filelist_t *filelist;
        gchar *filter_utf8 = locale_to_utf8(_filter);
 
-       D("mpdclient_filelist_search(%s)\n", _filter);
        filelist = mpdclient_filelist_search_utf8(c, exact_match, table,
                                                  filter_utf8);
        g_free(filter_utf8);
@@ -882,7 +858,6 @@ mpdclient_get_artists_utf8(mpdclient_t *c)
        gchar *str = NULL;
        GList *list = NULL;
 
-       D("mpdclient_get_artists()\n");
        mpd_sendListCommand(c->connection, MPD_TABLE_ARTIST, NULL);
        while ((str = mpd_getNextArtist(c->connection)))
                list = g_list_append(list, (gpointer) str);
@@ -899,7 +874,6 @@ mpdclient_get_albums_utf8(mpdclient_t *c, gchar *artist_utf8)
        gchar *str = NULL;
        GList *list = NULL;
 
-       D("mpdclient_get_albums(%s)\n", artist_utf8);
        mpd_sendListCommand(c->connection, MPD_TABLE_ALBUM, artist_utf8);
        while ((str = mpd_getNextAlbum(c->connection)))
                list = g_list_append(list, (gpointer) str);
index 5d4ca8425e586eec77454cc3f913df096bcf5550..ad6a6e302f80f681e5efdc35a43e20f6885b3cd8 100644 (file)
@@ -5,12 +5,6 @@
 #include "config.h"
 #endif
 
-#ifndef NDEBUG
-void D(const char *format, ...);
-#else
-#define D(...)
-#endif
-
 /* i18n */
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
index dc0475c4d1be040e61bbd896f70190dcb4ca573f..5b2b47c478fc93be5bf3d9c905b264eb4b8c4fc5 100644 (file)
@@ -137,7 +137,6 @@ display_help(void)
 static void
 handle_option(int c, const char *arg)
 {
-       D("option callback -%c %s\n", c, arg);
        switch (c) {
        case '?': /* --help */
                display_help();
index 3cfc813d9ce298061cb9f5eec3eac67fa7b07804..d0a3c74673bad1896723267b2a98a1a20b5ef921 100644 (file)
@@ -101,7 +101,6 @@ screen_next_mode(mpdclient_t *c, int offset)
        else if (next>=max)
                next = 0;
 
-       D("current mode: %d:%d    next:%d\n", current, max, next);
        sf = screen_lookup_name(options.screen_list[next]);
        if (sf != NULL)
                screen_switch(sf, c);
@@ -365,7 +364,6 @@ screen_exit(void)
 void
 screen_resize(void)
 {
-       D("Resize rows %d->%d, cols %d->%d\n",screen.rows,LINES,screen.cols,COLS);
        if (COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS) {
                screen_exit();
                fprintf(stderr, _("Error: Screen to small!\n"));
@@ -527,7 +525,6 @@ screen_paint(mpdclient_t *c)
        if (mode_fn->get_title != NULL)
                title = mode_fn->get_title(screen.buf, screen.buf_size);
 
-       D("screen_paint(%s)\n", title);
        /* paint the title/header window */
        if( title )
                paint_top_window(title, c, 1);
@@ -642,7 +639,6 @@ screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row)
 
        /* retreive the mouse event from ncurses */
        getmouse(&event);
-       D("mouse: id=%d  y=%d,x=%d,z=%d\n",event.id,event.y,event.x,event.z);
        /* calculate the selected row in the list window */
        *row = event.y - screen.top_window.rows;
        /* copy button state bits */
index 972de8f455b0af121a17eabc1bdbf737ab91b458..0593fee3c45369e0ceb0aff6bb04aa41616f9dd2 100644 (file)
@@ -307,7 +307,6 @@ browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
 {
        switch(event) {
        case BROWSE_DB_UPDATED:
-               D("screen_artist.c> browse_callback() [BROWSE_DB_UPDATED]\n");
                reload_lists(c);
                break;
        default:
index b8a1b1ee1e552d908135f917a74480d170c5bbff..6d23980208061a1f5d9bd48ec5f764d28a6c17eb 100644 (file)
@@ -93,7 +93,6 @@ browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c,
        if (browser->filelist == NULL)
                return;
 
-       D("screen_file.c> playlist_callback() [%d]\n", event);
        switch(event) {
        case PLAYLIST_EVENT_CLEAR:
                clear_highlights(browser->filelist);
index d12f77ef52b1ca5e57b5d66e463105a2048c4d76..fa741cd275b39997f099ed641ace302e03f12ea9 100644 (file)
@@ -58,7 +58,6 @@ static void
 file_changed_callback(mpdclient_t *c, mpd_unused int event,
                      mpd_unused gpointer data)
 {
-       D("screen_file.c> filelist_callback() [%d]\n", event);
        browser.filelist = mpdclient_filelist_update(c, browser.filelist);
        sync_highlights(c, browser.filelist);
        list_window_check_selected(browser.lw, filelist_length(browser.filelist));
index 67de5fa3e62d3d6ce73ec045b6613668a7351e3e..8c564c3fd56c701bf5d2f0a57c7ff7f27a93d6a2 100644 (file)
@@ -71,7 +71,6 @@ playlist_repaint_if_active(struct mpdclient *c)
 static void
 playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
 {
-       D("screen_play.c> playlist_callback() [%d]\n", event);
        switch (event) {
        case PLAYLIST_EVENT_DELETE:
                break;
@@ -121,7 +120,6 @@ center_playing_item(mpdclient_t *c)
 
        /* try to center the song that are playing */
        idx = playlist_get_index(c, c->song);
-       D("Autocenter song id:%d pos:%d index:%d\n", c->song->id,c->song->pos,idx);
        if (idx < 0)
                return;
 
@@ -201,7 +199,6 @@ playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname)
                return -1;
 
        /* send save command to mpd */
-       D("Saving playlist as \'%s \'...\n", filename);
        if ((error = mpdclient_cmd_save_playlist(c, filename))) {
                gint code = GET_ACK_ERROR_CODE(error);
 
@@ -256,7 +253,6 @@ static void add_pre_completion_cb(GCompletion *gcmp, gchar *line, void *data)
        GList **list = tmp->list;
        mpdclient_t *c = tmp->c;
 
-       D("pre_completion()...\n");
        if (*list == NULL) {
                /* create initial list */
                *list = gcmp_list_from_path(c, "", NULL, GCMP_TYPE_RFILE);
@@ -277,7 +273,6 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line,
        mpdclient_t *c = tmp->c;
        screen_t *screen = tmp->screen;
 
-       D("post_completion()...\n");
        if (g_list_length(items) >= 1)
                screen_display_completion_list(screen, items);
 
index b7020c04397ecae1dde586ff35bfbff3bfce9b4f..9d80e15a1d7250540260f84b907fc5690fcf4f96 100644 (file)
@@ -241,7 +241,6 @@ search_advanced_query(char *query, mpdclient_t *c)
 
        i=0;
        while (strv[i]) {
-               D("strv[%d] = \"%s\"\n", i, strv[i]);
                i++;
        }
 
@@ -258,12 +257,10 @@ search_advanced_query(char *query, mpdclient_t *c)
                                arg[j] = g_strdup_printf("%s %s", arg[j], strv[i]);
                                g_free(tmp);
                        } else {
-                               D("Bad search tag %s\n", strv[i]);
                                screen_status_printf(_("Bad search tag %s"), strv[i]);
                        }
                        i++;
                } else if (strv[i+1] == NULL || strlen(strv[i+1]) == 0) {
-                       D("No argument for search tag %s\n", strv[i]);
                        screen_status_printf(_("No argument for search tag %s"), strv[i]);
                        i++;
                        //        j--;
index 6cf61137c2534c09c184a208fa1163e9beff7f9a..bde8d1914b012fe7cb4a5cf35bb5d26679832b05 100644 (file)
@@ -200,7 +200,6 @@ utf8_to_locale(const char *utf8str)
                g_get_charset(&charset);
                screen_status_printf(_("Error: Unable to convert characters to %s"),
                                     charset);
-               D("utf8_to_locale(): %s\n", error->message);
                g_error_free(error);
                return g_strdup(utf8str);
        }
@@ -229,7 +228,6 @@ locale_to_utf8(const char *localestr)
                               &error);
        if (error) {
                screen_status_printf(_("Error: Unable to convert characters to UTF-8"));
-               D("locale_to_utf8: %s\n", error->message);
                g_error_free(error);
                return g_strdup(localestr);
        }
index 574b8fa49d9eba73d3f19cb5ea393160b1ffb283..5f5940b032027bc18382bc9f7ab8ab4a11f57ced 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include "utils.h"
-#include "ncmpc.h"
 #include "options.h"
 #include "support.h"
 
@@ -81,8 +80,6 @@ gcmp_list_from_path(mpdclient_t *c, const gchar *path, GList *list, gint types)
        if ((filelist = mpdclient_filelist_get(c, path)) == NULL)
                return list;
 
-       D("retrieved filelist!\n");
-
        for (i = 0; i < filelist_length(filelist); ++i) {
                struct filelist_entry *entry = filelist_get(filelist, i);
                mpd_InfoEntity *entity = entry ? entry->entity : NULL;