X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/5dd6771b28c257af405d7248639ed0e3bcdce38b..54fb590089a2bf43d7987861ba57acb17cebc150:/sbr/m_maildir.c?ds=sidebyside diff --git a/sbr/m_maildir.c b/sbr/m_maildir.c index 6c8c5841..0f9584b6 100644 --- a/sbr/m_maildir.c +++ b/sbr/m_maildir.c @@ -1,6 +1,4 @@ - -/* - * m_maildir.c -- get the path for the mail directory +/* m_maildir.c -- get the path for the mail directory * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -8,13 +6,13 @@ */ #include +#include +#include "m_maildir.h" #define CWD "./" -#define NCWD (sizeof(CWD) - 1) #define DOT "." #define DOTDOT ".." #define PWD "../" -#define NPWD (sizeof(PWD) - 1) static char mailfold[BUFSIZ]; @@ -27,7 +25,7 @@ static char *exmaildir (char *); char * m_maildir (char *folder) { - register char *cp, *ep; + char *cp, *ep; if ((cp = exmaildir (folder)) && (ep = cp + strlen (cp) - 1) > cp @@ -41,14 +39,14 @@ m_maildir (char *folder) char * m_mailpath (char *folder) { - register char *cp; + char *cp; char maildir[BUFSIZ]; if (*folder != '/' - && strncmp (folder, CWD, NCWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && strncmp (folder, PWD, NPWD)) { + && !has_prefix(folder, PWD)) { strncpy (maildir, mailfold, sizeof(maildir)); /* preserve... */ cp = getcpy (m_maildir (folder)); strncpy (mailfold, maildir, sizeof(mailfold)); @@ -63,17 +61,17 @@ m_mailpath (char *folder) static char * exmaildir (char *folder) { - register char *cp, *pp; + char *cp, *pp; /* use current folder if none is specified */ if (folder == NULL) folder = getfolder(1); if (!(*folder != '/' - && strncmp (folder, CWD, NCWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && strncmp (folder, PWD, NPWD))) { + && !has_prefix(folder, PWD))) { strncpy (mailfold, folder, sizeof(mailfold)); return mailfold; } @@ -81,12 +79,12 @@ exmaildir (char *folder) cp = mailfold; if ((pp = context_find ("path")) && *pp) { if (*pp != '/') { - sprintf (cp, "%s/", mypath); + snprintf(cp, sizeof mailfold, "%s/", mypath); cp += strlen (cp); } - cp = copy (pp, cp); + cp = stpcpy(cp, pp); } else { - cp = copy (path ("./", TFOLDER), cp); + cp = stpcpy(cp, path("./", TFOLDER)); } if (cp[-1] != '/') *cp++ = '/';