Improve function dir.c:trim_trailing_spaces()

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