"Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:
> Of course, I could parse the string when setting up the buffer looking for
> the number of expansions required. Instead I made the (I think reasonable)
> assumption that each possible expansion would be wanted at most once.
I think that's a reasonable assumption; the question was just about
whether your code acts sanely if the assumption isn't true.
regards, tom lane