X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/1691e80890e5d8ba258c51c214a3e91880e1db2b..eacedee1a02f9e4be64929a2520099b14dc0a049:/sbr/path.c diff --git a/sbr/path.c b/sbr/path.c index df5d963b..fca85229 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -2,10 +2,13 @@ /* * path.c -- return a pathname * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include +#include #define CWD "./" #define NCWD (sizeof(CWD) - 1) @@ -22,11 +25,16 @@ static char *pwds; static char *expath(char *,int); static void compath(char *); +char * +pluspath(char *name) +{ + return path(name + 1, *name == '+' ? TFOLDER : TSUBCWF); +} char * path(char *name, int flag) { - register char *cp, *ep; + char *cp, *ep; if ((cp = expath (name, flag)) && (ep = cp + strlen (cp) - 1) > cp @@ -40,7 +48,7 @@ path(char *name, int flag) static char * expath (char *name, int flag) { - register char *cp, *ep; + char *cp, *ep; char buffer[BUFSIZ]; if (flag == TSUBCWF) { @@ -50,7 +58,7 @@ expath (char *name, int flag) snprintf (buffer, sizeof(buffer), "%s/", m_maildir ("")); if (ssequal (buffer, name)) { cp = name; - name = getcpy (name + strlen (buffer)); + name = mh_xstrdup(name + strlen(buffer)); free (cp); } flag = TFOLDER; @@ -62,13 +70,13 @@ expath (char *name, int flag) && strcmp (name, DOT) && strcmp (name, DOTDOT) && strncmp (name, PWD, NPWD)))) - return getcpy (name); + return mh_xstrdup(name); if (pwds == NULL) pwds = pwd (); if (strcmp (name, DOT) == 0 || strcmp (name, CWD) == 0) - return getcpy (pwds); + return mh_xstrdup(pwds); ep = pwds + strlen (pwds); if ((cp = strrchr(pwds, '/')) == NULL) @@ -81,8 +89,8 @@ expath (char *name, int flag) name += NCWD; if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) { - snprintf (buffer, sizeof(buffer), "%.*s", cp - pwds, pwds); - return getcpy (buffer); + snprintf (buffer, sizeof(buffer), "%.*s", (int)(cp - pwds), pwds); + return mh_xstrdup(buffer); } if (strncmp (name, PWD, NPWD) == 0) @@ -90,15 +98,15 @@ expath (char *name, int flag) else cp = ep; - snprintf (buffer, sizeof(buffer), "%.*s/%s", cp - pwds, pwds, name); - return getcpy (buffer); + snprintf (buffer, sizeof(buffer), "%.*s/%s", (int)(cp - pwds), pwds, name); + return mh_xstrdup(buffer); } static void compath (char *f) { - register char *cp, *dp; + char *cp, *dp; if (*f != '/') return;