Improve function dir.c:trim_trailing_spaces()

Move backwards from the end of the string.
Slightly more rare occurences of 'text  \   ' with a backslash
in between spaces are handled correctly