Our man page states that it's not portable to rely on dirname(3) not
modifying the contents of the passed string. Replace dirname(3) with
mg's xdirname portability helper function (a slightly different fix
than Gentoo's).

Report and initial analysis by Marien Zwart in Gentoo bug #487758 via
Han Boetes (hboetes _AT_ gmail).
Gentoo bugfix by Ulrich Mueller (ulm _AT_ gentoo).
testing on glibc / input Ulrich Mueller; testing on glibc Han Boetes.
Thanks!

OK jasper@
cvsimport
Fix previous; ENOCOFFEE.
Move xdirname call into the right if block, pointed out by Ulrich
Mueller.
cvsimport