Split the `spaces` function according to its usage

The treatment of spaces at the beginning of a line or elsewhere is
different.  Make these two cases clearer.  (Also avoids doing again
tests that were already performed.)