lift handling of ->immutable into dup_token()

We need to make sure that any struct string with more than one token
refering to it will have ->immutable set; that's what de1fa7e60 ("Make
macro expanded string immutable") tried to achieve.  Unfortunately, it
was not enough - constructing an example where an unexpanded argument gets
several copies is very easy (see the testcase in this commit).

A better place for dealing with that is dup_token() - that's guaranteed
to catch all such tokens and with sane code generation (== with compiler
made certain that *streampos can't be altered by stores to alloc->pos)
it's quite cheap; we already have alloc->pos in registers and checking
if the lower 6 bits happen to be 001000 or 001001 (TOKEN_STRING and
TOKEN_WIDE_STRING resp.) doesn't take much.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2 files changed