Fix substring operator in macro-processor.

The characters of the substring could be mixed with random characters from the
memory space. Thanks to Tom Holden for reporting the bug.

Closes #708