Fix CAML_LD_LIBRARY_PATH when switching from system

Closes #1847, #1849.

Supersedes #1875 -- thanks @antegallya for helping out (your fix was
ok but didn't handle the new switch case, where the state given to the
function wasn't up-to-date enough; I wish all writing functions
returned the modified state but we're not there yet)
Merge pull request #1928 from OCamlPro/fix-switch-vars

Fix CAML_LD_LIBRARY_PATH when switching from system