X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/ee0cec04d450c43ca0fef7990e18e4c73bee41e9..9322ba2854211794c27fae9468768b80b767c211:/sbr/path.c?ds=sidebyside diff --git a/sbr/path.c b/sbr/path.c index 4ef4003f..79d7f38c 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -11,11 +11,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 +64,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 +83,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 +139,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; }