The 'WHITESPACE' case of the _calc_len method wrongly accessed the character before checking upper bound of the token. The problem is fixed by switching the order of both conditions. Fixes #3756