Please do not delete this commented-out version
Let me check, just how old is Emacs 10.31? According to the Emacs timeline Emacs 13.0x was the first public release - in 1985. Feel free to study the over 30 years old sources , simply because they’re significantly more readable than what’s making up expand-file-name these days.