Fix TRIM bug with multiple lines

Example code exhibiting the bug:

    >> trim "  x ^/"
    == "x x^/"  ;; Expected: "x^/"

The fix changes some variable names, to make the algorithm easier to
understand. head and tail are now trimmed first, because it is simpler
this way.

This fixes CureCode issue #1948.