Commit b70bdb73 b70bdb73834eb4687fd3763b511f17f179277041 by Alain Magloire

* messages/message.c (messages_count): getenv ("MAIL") may return NULL.

	In this case we were trying to printf (" ..%s\n", NULL); GNU/Linux
	seems to cope with it but QNX/Neutrino sigsegv miserably.  Fix the code
	by getting the url of the mailbox and calling url_to_string().
1 parent b58d0ff1
...@@ -65,7 +65,7 @@ main (int argc, char **argv) ...@@ -65,7 +65,7 @@ main (int argc, char **argv)
65 list_append (bookie, imap_record); 65 list_append (bookie, imap_record);
66 list_append (bookie, pop_record); 66 list_append (bookie, pop_record);
67 67
68 if (args.argc < 1 && messages_count (getenv("MAIL")) < 0) 68 if (args.argc < 1 && messages_count (NULL) < 0)
69 err = 1; 69 err = 1;
70 else if (args.argc >= 1) 70 else if (args.argc >= 1)
71 { 71 {
...@@ -81,18 +81,27 @@ static int ...@@ -81,18 +81,27 @@ static int
81 messages_count (char *box) 81 messages_count (char *box)
82 { 82 {
83 mailbox_t mbox; 83 mailbox_t mbox;
84 url_t url = NULL;
84 int count; 85 int count;
85 86
87 if (box == NULL)
88 box = (char *)"";
89
86 if (mailbox_create_default (&mbox, box) != 0) 90 if (mailbox_create_default (&mbox, box) != 0)
87 { 91 {
88 fprintf (stderr, "Couldn't create mailbox %s.\n", box); 92 fprintf (stderr, "Couldn't create mailbox %s.\n", box);
89 return -1; 93 return -1;
90 } 94 }
95
96 mailbox_get_url (mbox, &url);
97 box = url_to_string (url);
98
91 if (mailbox_open (mbox, MU_STREAM_READ) != 0) 99 if (mailbox_open (mbox, MU_STREAM_READ) != 0)
92 { 100 {
93 fprintf (stderr, "Couldn't open mailbox %s.\n", box); 101 fprintf (stderr, "Couldn't open mailbox %s.\n", box);
94 return -1; 102 return -1;
95 } 103 }
104
96 if (mailbox_messages_count (mbox, &count) != 0) 105 if (mailbox_messages_count (mbox, &count) != 0)
97 { 106 {
98 fprintf (stderr, "Couldn't count messages in %s.\n", box); 107 fprintf (stderr, "Couldn't count messages in %s.\n", box);
......