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)
list_append (bookie, imap_record);
list_append (bookie, pop_record);
if (args.argc < 1 && messages_count (getenv("MAIL")) < 0)
if (args.argc < 1 && messages_count (NULL) < 0)
err = 1;
else if (args.argc >= 1)
{
......@@ -81,18 +81,27 @@ static int
messages_count (char *box)
{
mailbox_t mbox;
url_t url = NULL;
int count;
if (box == NULL)
box = (char *)"";
if (mailbox_create_default (&mbox, box) != 0)
{
fprintf (stderr, "Couldn't create mailbox %s.\n", box);
return -1;
}
mailbox_get_url (mbox, &url);
box = url_to_string (url);
if (mailbox_open (mbox, MU_STREAM_READ) != 0)
{
fprintf (stderr, "Couldn't open mailbox %s.\n", box);
return -1;
}
if (mailbox_messages_count (mbox, &count) != 0)
{
fprintf (stderr, "Couldn't count messages in %s.\n", box);
......