Fix compile under MingW

This should fix compiling with MingW.  Apparently Mingw doesn't have either strtok_r or strtok_s, so I wrote mystrtok_r and used that for Mingw.