Fix dangerous typo in apply_subst()

Look at the diff, really :-) There was an `i' where a `0' needed to be
before the trailing memcpy() invocation in apply_subst(). Good thing we
have valgrind!
Don't allow a macro to have different equally-named parameters

This fixes cases such as

  #define f(a, a)	a

which would segfault with the former implementation and are also
theoretically non-sense.

The code was totally unaware of the parameter names, it only cared about
their lengths. It couldn't even check if there was a name at all
("#define f(,) a" may have worked but correctly raises an error now).

A trie is used to store the parameter names temporarily.