Fix poor-man's dirname implementation. Reported by Matías A. Fonzo.