patch3.diff

Masaki Matsushita, 04/30/2012 11:36 AM

Download (2.23 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)
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)