Talk:Find common directory path: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 36: Line 36:
:I think that the last two lines of leastCommonPath are wrong: <lang c> t = strrchr(moving, '/');
:I think that the last two lines of leastCommonPath are wrong: <lang c> t = strrchr(moving, '/');
if (t && t != moving) *t = '\0';</lang>. This should place the null after the slash, and not eliminate the slash otherwise the slash will not be available for future comparisons. If you change "coverage" to "dovetail" in the example data, I think this problem would raise its head. --[[User:Rdm|Rdm]] 11:46, 14 April 2011 (UTC)
if (t && t != moving) *t = '\0';</lang>. This should place the null after the slash, and not eliminate the slash otherwise the slash will not be available for future comparisons. If you change "coverage" to "dovetail" in the example data, I think this problem would raise its head. --[[User:Rdm|Rdm]] 11:46, 14 April 2011 (UTC)

It is intended to work that way, and it works with "dovetail" also. The first conditional handles cases both with and without terminating slash. Try it. [[User:Per|Per]] 12:07, 14 April 2011 (UTC)