Use PATH_MAX if defined, only call pathconf() once - both to solve performance problems reported on Linux