patch4.diff

Masaki Matsushita, 11/11/2012 02:46 PM

Download (1.73 KB)

View differences:

configure.in
2894 2894
    ])])
2895 2895
fi
2896 2896

  
2897
AC_CHECK_FUNC(memmem, [
2898
  AC_CACHE_CHECK(for broken memmem, rb_cv_broken_memmem, [
2899
    AC_TRY_RUN([
2900
#include <string.h>
2901

  
2902
int
2903
main()
2904
{
2905
  char *str = "hogefugafoobar";
2906
  char *rs = "foo";
2907
  char *empty = "";
2908
  char *p;
2909

  
2910
  p = memmem(str, strlen(str), rs, strlen(rs));
2911
  if (p == str+8) {
2912
    p = memmem(str, strlen(str), empty, strlen(empty));
2913
    if (p == str)
2914
      return 0;
2915
    else
2916
      return 1;
2917
  }
2918
  else {
2919
    return 1;
2920
  }
2921
}
2922
    ],
2923
    rb_cv_broken_memmem=no,
2924
    rb_cv_broken_memmem=yes,
2925
    rb_cv_broken_memmem=yes)
2926
  ])
2927
  if test "$rb_cv_broken_memmem" = no; then
2928
    AC_DEFINE(HAVE_MEMMEM, 1)
2929
  fi
2930
])
2931

  
2932

  
2897 2933
CPPFLAGS="$CPPFLAGS "'$(DEFS)'
2898 2934
test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
2899 2935
if test -n "${cflags+set}"; then
re.c
97 97
    return memcmp(p1, p2, len);
98 98
}
99 99

  
100
#ifdef HAVE_MEMMEM
101
static inline long
102
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
103
{
104
    const unsigned char *y;
105

  
106
    if (y = memmem(ys, n, xs, m))
107
	return y - ys;
108
    else
109
	return -1;
110
}
111
#else
100 112
static inline long
101 113
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
102 114
{
......
132 144
    }
133 145
    return y - ys - m;
134 146
}
147
#endif
135 148

  
136 149
static inline long
137 150
rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)