Compilation fixes for MSVC 8. Move support fixes for light_function and other components based on it.
Fixes #10700. Don't use vsnprintf_s on MSVC as it does not behave as the standard vsnprintf. Also corrected error checking for snprintf in different places.