CCX  fix of trim function

2013.02.02 by CCX (cc@x.isla.pr)
>> trim "  x ^/"
== "x x^/"

Fixed that trim bug, found in trim_head_tail(). Changed some var
names to make the algorithm easier to understand. head and tail
are now trimmed first because its simpler this way.