fix handling of odd lengths in swab function