patch2.diff

Masaki Matsushita, 04/28/2012 01:34 PM

Download (2.46 KB)

View differences:

configure.in
1437 1437
	      setuid setgid daemon select_large_fdset setenv unsetenv\
1438 1438
              mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
1439 1439
              pread sendfile shutdown sigaltstack dl_iterate_phdr\
1440
              dup3 pipe2 posix_memalign memalign)
1440
              dup3 pipe2 posix_memalign memalign memmem)
1441 1441

  
1442 1442
AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
1443 1443
  [AC_TRY_COMPILE([
......
2738 2738
    ])])
2739 2739
fi
2740 2740

  
2741
AC_CACHE_CHECK(for broken memmem, rb_cv_broken_memmem,
2742
  [AC_TRY_RUN([
2743
#include <string.h>
2744

  
2745
int
2746
main()
2747
{
2748
  char *str = "hogefugafoobar";
2749
  char *rs = "foo";
2750
  char *empty = "";
2751
  char *p;
2752

  
2753
  p = memmem(str, strlen(str), rs, strlen(rs));
2754
  if (p == str+8) {
2755
    p = memmem(str, strlen(str), empty, strlen(empty));
2756
    if (p == str)
2757
      return 0;
2758
    else
2759
      return 1;
2760
  }
2761
  else {
2762
    return 1;
2763
  }
2764
}
2765
  ],
2766
  rb_cv_broken_memmem=no,
2767
  rb_cv_broken_memmem=yes,
2768
  rb_cv_broken_memmem=yes)
2769
])
2770

  
2771
if test "$rb_cv_broken_memmem" = yes; then
2772
  AC_DEFINE(BROKEN_MEMMEM, 1)
2773
fi
2774

  
2741 2775
CPPFLAGS="$CPPFLAGS "'$(DEFS)'
2742 2776
test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
2743 2777
if test -n "${cflags+set}"; then
re.c
97 97
    return memcmp(p1, p2, len);
98 98
}
99 99

  
100
#if !defined(HAVE_MEMMEM) || defined(BROKEN_MEMMEM)
100 101
static inline long
101 102
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
102 103
{
......
132 133
    }
133 134
    return y - ys - m;
134 135
}
136
#endif
135 137

  
136 138
static inline long
137 139
rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
......
228 230
	return -1;
229 231
    }
230 232
    else if (m <= SIZEOF_VALUE) {
233
#if defined(HAVE_MEMMEM) && !defined(BROKEN_MEMMEM)
234
	const unsigned char *ys;
235

  
236
	if (ys = memmem(y, n, x, m))
237
	    return ys - y;
238
	else
239
	    return -1;
240
#else
231 241
	return rb_memsearch_ss(x0, m, y0, n);
242
#endif
232 243
    }
233 244
    else if (enc == rb_utf8_encoding()){
234 245
	return rb_memsearch_qs_utf8(x0, m, y0, n);