]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/mood_fix'
authorAndre Noll <maan@systemlinux.org>
Tue, 26 Mar 2013 00:07:08 +0000 (00:07 +0000)
committerAndre Noll <maan@systemlinux.org>
Tue, 26 Mar 2013 00:07:08 +0000 (00:07 +0000)
1  2 
mood.c

diff --combined mood.c
index 354ce3ca43cb7afe03349e7969153d7743814be3,74b00d35b2ddc4efd07f2e8783d1a37fcc3117b4..5d2d38b46637322ad93e802fce150b368cdae2e5
--- 1/mood.c
--- 2/mood.c
+++ b/mood.c
@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * Copyright (C) 2007-2012 Andre Noll <maan@systemlinux.org>
 + * Copyright (C) 2007-2013 Andre Noll <maan@systemlinux.org>
   *
   * Licensed under the GPL v2. For licencing details see COPYING.
   */
@@@ -77,6 -77,10 +77,10 @@@ struct mood 
        struct list_head score_list;
  };
  
+ /*
+  * If current_mood is NULL then no mood is currently open. If
+  * current_mood->name is NULL, the dummy mood is currently open
+  */
  static struct mood *current_mood;
  
  /**
@@@ -218,7 -222,8 +222,8 @@@ static void destroy_mood(struct mood *m
  static struct mood *alloc_new_mood(const char *name)
  {
        struct mood *m = para_calloc(sizeof(struct mood));
-       m->name = para_strdup(name);
+       if (name)
+               m->name = para_strdup(name);
        INIT_LIST_HEAD(&m->accept_list);
        INIT_LIST_HEAD(&m->deny_list);
        INIT_LIST_HEAD(&m->score_list);
@@@ -850,9 -855,9 +855,9 @@@ int change_current_mood(char *mood_name
                        return ret;
                close_current_mood();
                current_mood = m;
-       } else {
+       } else { /* load dummy mood */
                close_current_mood();
-               current_mood = alloc_new_mood("dummy");
+               current_mood = alloc_new_mood(NULL);
        }
        aa.m = current_mood;
        PARA_NOTICE_LOG("computing statistics of admissible files\n");
                if (ret < 0)
                        goto out;
        }
-       PARA_NOTICE_LOG("loaded mood %s\n", current_mood->name);
+       PARA_NOTICE_LOG("loaded mood %s\n", mood_name? mood_name : "(dummy)");
        ret = statistics.num;
  out:
        free(aa.array);