cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.55k stars 1.64k forks source link

Use re-entrant version of strtok(), i.e. strtok_r(), to get tokens #57

Open brchiu opened 8 years ago

brchiu commented 8 years ago

Use re-entrant version of strtok(), i.e. strtok_r(), to get tokens.

brchiu commented 8 years ago

Due to there are static variables used in files, changed to strtok_r() does not make the built library thread safe. There is another pull request #45 addressed this issue by totally removing strtok().

tavianator commented 8 years ago

I believe Windows does not have strtok_r, which is part of the reason I open-coded it in #45 instead.

brchiu commented 8 years ago

@tavianator You are right, there is no strtok_r in Windows. However, there is strtok_s in Windows API having the same signature. So one way to resolve it is adding

#if defined(_WIN32) || defined(_WIN64)
#define strtok_r strtok_s
#endif

in certain header file to change it from strtok_r() to strtok_s().