Talk:Find common directory path: Difference between revisions

New version. Ignore the old one.
m (Rename the function to avoid the implication that it finds the shortest common path (which would be much simpler).)
(New version. Ignore the old one.)
Line 1:
Much simplerShorter version for the C language:
 
<lang C>
Line 8:
static void longestSharedPath(const char *fixed, char *moving) {
char *t;
unsigned n = strspn(moving0, l = strlen(fixed);
ifwhile (strlen(fixed) > moving[n && strlen(moving)] == fixed[n] && fixed[n] ==< '/'l) returnn++;
strcpyif (strlen(moving,) == n && (l == n || (l > n && fixed[n] == '/'))) return;
moving[n] = '\0';
t = strrchr(moving, '/');
Anonymous user