fix for 5.17.7's new padrange op

Also relearn a valuable lesson in writing the simplest code that you can, and
documenting the approach the code takes.

In my defense the original code was written 11 years ago and I
understood it *perfectly* then.