Ticket #5139: Properly handle recursive macro definitions

Hi,

This trivial patch fixes ticket #5139 by passing the set of already expanded variables by reference and not copy, so that recursive macros definitions are properly handled. Thanks to consider merging.

Best regards,
  Simon