This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport detection improvements for memrchr, strlcat, and strlcpy
[metaconfig.git] / U / perl / d_memrchr.U
index 4fea9a6..c20ff59 100644 (file)
@@ -1,7 +1,7 @@
 ?RCS: You may distribute under the terms of either the GNU General Public
 ?RCS: License or the Artistic License, as specified in the README file.
 ?RCS:
-?MAKE:d_memrchr: Inlibc
+?MAKE:d_memrchr: Inlibc Hasproto d_gnulibc
 ?MAKE: -pick add $@ %<
 ?S:d_memrchr:
 ?S:    This variable conditionally defines the HAS_MEMRCHR symbol, which
 ?C:.
 ?H:#$d_memrchr HAS_MEMRCHR             /**/
 ?H:.
+?T:d_memrchr_proto xx1 xx2 xx3 xx4
 ?LINT:set d_memrchr
 : see if memrchr exists
-set memrchr d_memrchr
-eval $inlibc
+: We need both a prototype in string.h and the symbol in libc.
+echo " "
+d_memrchr_proto=''
+xx1="#$d_gnulibc HAS_GNULIBC"
+xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
+xx3='#   define _GNU_SOURCE'
+xx4='#endif'
+set d_memrchr_proto memrchr literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
+eval $hasproto
+case "$d_memrchr_proto" in
+    define) # see if memrchr exists
+       set memrchr d_memrchr
+       eval $inlibc
+       ;;
+    *)  val=$undef
+       set d_memrchr
+       eval $setvar
+       ;;
+esac