Add setenv.c in compat

Based on the work from @n1xim, this patch removes the `set_environment_variable()` code and adds a `compat/setenv.c` file. This work is based on the `gh-152-missing-mkstemps` branch which implements Drew's work.