Use copy of marco as argument to basename_ex()

Avoid possible segfault by creating a non-constant copy of macros to
pass to basename_ex() since there is the possibility the arguments
passed could be modified. This is one of the suggestions made in the
documentation. Thanks to @cgzones for catching this issue.