X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0a032eea07f6d77ac6ea4d5a39c9491c34358058..7540f02725475698a47046ebf4e55b3e8dea5ab6:/sbr/folder_pack.c diff --git a/sbr/folder_pack.c b/sbr/folder_pack.c index 3ebb3539..7fdfcf85 100644 --- a/sbr/folder_pack.c +++ b/sbr/folder_pack.c @@ -1,5 +1,4 @@ -/* - * folder_pack.c -- pack (renumber) the messages in a folder +/* folder_pack.c -- pack (renumber) the messages in a folder * -- into a contiguous range from 1 to n. * * This code is Copyright (c) 2002, by the authors of nmh. See the @@ -7,7 +6,13 @@ * complete copyright information. */ -#include +#include "h/mh.h" +#include "m_name.h" +#include "seq_setcur.h" +#include "ext_hook.h" +#include "folder_realloc.h" +#include "folder_pack.h" +#include "error.h" /* * Pack the message in a folder. @@ -34,19 +39,18 @@ folder_pack (struct msgs **mpp, int verbose) * for all numbers from 1 to current high message. */ if (mp->lowoff > 1) { - if ((mp = folder_realloc (mp, 1, mp->hghmsg))) - *mpp = mp; - else { + if (!(mp = folder_realloc(mp, 1, mp->hghmsg))) { inform("unable to allocate folder storage"); return -1; } + *mpp = mp; } for (msgnum = mp->lowmsg, hole = 1; msgnum <= mp->hghmsg; msgnum++) { if (does_exist (mp, msgnum)) { if (msgnum != hole) { - strncpy (newmsg, m_name (hole), sizeof(newmsg)); - strncpy (oldmsg, m_name (msgnum), sizeof(oldmsg)); + strncpy (newmsg, m_name (hole), sizeof(newmsg) - 1); + strncpy (oldmsg, m_name (msgnum), sizeof(oldmsg) - 1); if (verbose) printf ("message %s becomes %s\n", oldmsg, newmsg);