X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/ee0cec04d450c43ca0fef7990e18e4c73bee41e9..582d5e802ceb8e0c7f0dc5b83fdbf2a62fc10fb3:/sbr/path.c?ds=inline diff --git a/sbr/path.c b/sbr/path.c index 4ef4003f..7621aa52 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -1,6 +1,4 @@ - -/* - * path.c -- return a pathname +/* path.c -- return a pathname * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -11,11 +9,9 @@ #include #define CWD "./" -#define NCWD (sizeof(CWD) - 1) #define DOT "." #define DOTDOT ".." #define PWD "../" -#define NPWD (sizeof(PWD) - 1) static char *pwds; @@ -66,10 +62,10 @@ expath (char *name, int flag) if (*name == '/' || (flag == TFOLDER - && (!HasPrefix(name, CWD) + && (!has_prefix(name, CWD) && strcmp (name, DOT) && strcmp (name, DOTDOT) - && !HasPrefix(name, PWD)))) + && !has_prefix(name, PWD)))) return mh_xstrdup(name); if (pwds == NULL) @@ -85,16 +81,16 @@ expath (char *name, int flag) if (cp == pwds) cp++; - if (HasPrefix(name, CWD)) - name += NCWD; + if (has_prefix(name, CWD)) + name += LEN(CWD); if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) { snprintf (buffer, sizeof(buffer), "%.*s", (int)(cp - pwds), pwds); return mh_xstrdup(buffer); } - if (HasPrefix(name, PWD)) - name += NPWD; + if (has_prefix(name, PWD)) + name += LEN(PWD); else cp = ep; @@ -141,18 +137,18 @@ compath (char *f) *cp = '\0'; break; } - if (HasPrefix(cp, PWD)) { + if (has_prefix(cp, PWD)) { for (dp = cp - 2; dp > f; dp--) if (*dp == '/') break; if (dp <= f) dp = f; - strcpy (dp, cp + NPWD - 1); + strcpy (dp, cp + LEN(PWD) - 1); cp = dp; continue; } - if (HasPrefix(cp, CWD)) { - strcpy (cp - 1, cp + NCWD - 1); + if (has_prefix(cp, CWD)) { + strcpy (cp - 1, cp + LEN(CWD) - 1); cp--; continue; }