X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=util.c;fp=util.c;h=e9f7813b8b378d13af2b7e322a5aaf9a3f612362;hp=49f5b4be13f46723b48da397487a7c79dc4419e3;hb=15ae422b7471cf6f41ccf450243d8afd8ea0a054;hpb=020379a7f7d2cca3ab37942db3d67d06c45083fe diff --git a/util.c b/util.c index 49f5b4be1..e9f7813b8 100644 --- a/util.c +++ b/util.c @@ -1140,6 +1140,39 @@ bool path_startswith(const char *path, const char *prefix) { } } +bool path_equal(const char *a, const char *b) { + assert(a); + assert(b); + + if ((a[0] == '/') != (b[0] == '/')) + return false; + + for (;;) { + size_t j, k; + + a += strspn(a, "/"); + b += strspn(b, "/"); + + if (*a == 0 && *b == 0) + return true; + + if (*a == 0 || *b == 0) + return false; + + j = strcspn(a, "/"); + k = strcspn(b, "/"); + + if (j != k) + return false; + + if (memcmp(a, b, j) != 0) + return false; + + a += j; + b += k; + } +} + char *ascii_strlower(char *t) { char *p;