From c41eda256d7a963ee651b2532e9e18f76581fcfb Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Thu, 29 Sep 2011 14:14:19 +0200
Subject: Do not hardcode paths to the default editor/pager

Use "vi" instead of "/usr/bin/vi" and "less" instead of "/usr/bin/less".
Hardcoding absolute paths is a bad idea:

    $ uname -rsv
    Linux 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011
    $ which less
    /bin/less

The "$PATH" environment variable will almost always have a better idea
of where these binaries are located.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/calcurse.h | 3 +++
 src/vars.c     | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/calcurse.h b/src/calcurse.h
index 383f53e..091d16a 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -100,6 +100,9 @@
 #define DPID_PATH        DIR_NAME DPID_PATH_NAME
 #define NOTES_DIR        DIR_NAME NOTES_DIR_NAME
 
+#define DEFAULT_EDITOR   "vi"
+#define DEFAULT_PAGER    "less"
+
 #define ATTR_FALSE	0
 #define ATTR_TRUE	1
 #define ATTR_LOWEST	2
diff --git a/src/vars.c b/src/vars.c
index 4b1d7cd..84f8b08 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -114,8 +114,6 @@ struct dmon_conf dmon;
 void
 vars_init (struct conf *conf)
 {
-  char *PATH_VI = "/usr/bin/vi";
-  char *PATH_LESS = "/usr/bin/less";
   char *ed, *pg;
 
   /* Variables for user configuration */
@@ -133,12 +131,12 @@ vars_init (struct conf *conf)
   if (ed == NULL || ed[0] == '\0')
     ed = getenv ("EDITOR");
   if (ed == NULL || ed[0] == '\0')
-    ed = PATH_VI;
+    ed = DEFAULT_EDITOR;
   conf->editor = ed;
 
   pg = getenv ("PAGER");
   if (pg == NULL || pg[0] == '\0')
-    pg = PATH_LESS;
+    pg = DEFAULT_PAGER;
   conf->pager = pg;
 
   wins_set_layout (1);
-- 
cgit v1.2.3-70-g09d2


From 4cd62fb0fba6ddb5c79e3d2dc109b5b7d98612e2 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Thu, 29 Sep 2011 14:34:57 +0200
Subject: src/io.c: Update todo item count on iCal import

Update the number of todo items when importing an iCal file to prevent
some items from being inaccessible.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/io.c | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src')

diff --git a/src/io.c b/src/io.c
index 12c9494..b64dd58 100644
--- a/src/io.c
+++ b/src/io.c
@@ -2780,6 +2780,9 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
   if (stream != stdin)
     file_close (stream, __FILE_POS__);
 
+  /* Update the number of todo items. */
+  todo_set_nb (todo_nb () + stats.todos);
+
   if (ui_mode == UI_CURSES && !conf->skip_system_dialogs)
     {
       char read[BUFSIZ], stat[BUFSIZ];
-- 
cgit v1.2.3-70-g09d2


From 3aefd00f6aebad7c50210e68650cb8c42e0835cd Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Tue, 4 Oct 2011 12:13:13 +0200
Subject: Cleanup joinable threads on termination

Always invoke pthread_join() when we blow up a thread via
pthread_cancel() (avoid zombie threads).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/calendar.c | 5 ++++-
 src/io.c       | 5 ++++-
 src/notify.c   | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/calendar.c b/src/calendar.c
index 6664a93..e303ab9 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -145,7 +145,10 @@ void
 calendar_stop_date_thread (void)
 {
   if (calendar_t_date)
-    pthread_cancel (calendar_t_date);
+    {
+      pthread_cancel (calendar_t_date);
+      pthread_join (calendar_t_date, NULL);
+    }
 }
 
 /* Set static variable today to current date */
diff --git a/src/io.c b/src/io.c
index b64dd58..22f8719 100644
--- a/src/io.c
+++ b/src/io.c
@@ -2927,7 +2927,10 @@ void
 io_stop_psave_thread (void)
 {
   if (io_t_psave)
-    pthread_cancel (io_t_psave);
+    {
+      pthread_cancel (io_t_psave);
+      pthread_join (io_t_psave, NULL);
+    }
 }
 
 /*
diff --git a/src/notify.c b/src/notify.c
index 1b7e924..188d92c 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -188,7 +188,10 @@ void
 notify_stop_main_thread (void)
 {
   if (notify_t_main)
-    pthread_cancel (notify_t_main);
+    {
+      pthread_cancel (notify_t_main);
+      pthread_join (notify_t_main, NULL);
+    }
 }
 
 /*
-- 
cgit v1.2.3-70-g09d2