Minor fixes to compile under C89

Hi, not a very "needed" patch, but hey why not. :)
(I'm developing something using MSVC 2012 which only has C89 support.)

Changes: Define INFINITY as DBL_MAX, as well as simple definitions for fmin and fmax. Moved some variable declarations to function head also.