Sync OpenBSD patchset 550:
Sync OpenBSD patchset 550:

Tidy up by breaking the # replacement code into a separate function, also add a
few comments.


klaxalk/tmux,klaxalk/tmux,klaxalk/tmux,klaxalk/tmux,klaxalk/tmux