sexp.c: Use strncasecmp instead of strcasestr

strcasestr is not available on MS C runtime. Use strncasecmp instead
which is in POSIX. MS C runtime has _strnicmp().
This commit is contained in:
okuoku 2017-11-07 07:27:05 +09:00
parent 231c4bc04b
commit 7693881125
2 changed files with 3 additions and 7 deletions

View file

@ -773,16 +773,12 @@
#define SHUT_RD 0 /* SD_RECEIVE */
#define SHUT_WR 1 /* SD_SEND */
#define SHUT_RDWR 2 /* SD_BOTH */
#if !defined(__MINGW32__) && !defined(__MINGW64__)
#define strcasecmp lstrcmpi
#define strncasecmp(s1, s2, n) lstrcmpi(s1, s2)
#endif
#include <shlwapi.h>
#define strcasestr StrStrI
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
#define _USE_MATH_DEFINES /* For M_LN10 */
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#pragma warning(disable:4146) /* unary minus operator to unsigned type */
#if _MSC_VER < 1900
#define snprintf(buf, len, fmt, val) sprintf(buf, fmt, val)

2
sexp.c
View file

@ -3226,7 +3226,7 @@ sexp sexp_read_raw (sexp ctx, sexp in, sexp *shares) {
else if (strcasecmp(str+1, "nan.0") == 0)
res = sexp_make_flonum(ctx, sexp_nan);
#if SEXP_USE_COMPLEX
else if (strcasestr(str+1, "inf.0") == str+1) {
else if (strncasecmp(str+1, "inf.0", 5) == 0) {
tmp = sexp_make_flonum(ctx, c1 == '+' ? sexp_pos_infinity : sexp_neg_infinity);
if (str[6] == 0) {
res = tmp;