This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [PATCH Configure] was RE: [PATCH] was RE: Perl_die() /Perl_croak()
authorRobin Barker <RMBarker@cpan.org>
Wed, 15 Nov 2006 19:35:52 +0000 (19:35 +0000)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Wed, 15 Nov 2006 20:50:26 +0000 (20:50 +0000)
Message-ID: <2C2E01334A940D4792B3E115F95B7226120AB7@exchsvr1.npl.ad.local>

p4raw-id: //depot/metaconfig@29286

U/modified/d_attribut.U

index 5a16e78..f798ef8 100644 (file)
 ?RCS: Revision 3.0.1.1  1994/10/29  16:08:55  ram
 ?RCS: patch36: created by ADO
 ?RCS:
-?MAKE:d_attribute_format d_attribute_malloc d_attribute_nonnull d_attribute_noreturn d_attribute_pure d_attribute_unused d_attribute_warn_unused_result: Myread Oldconfig cat cc ccflags rm Setvar contains
+?MAKE:d_attribute_format d_attribute_malloc d_attribute_nonnull \
+       d_attribute_noreturn d_attribute_pure d_attribute_unused \
+       d_attribute_warn_unused_result d_printf_format_null: \
+           Myread Oldconfig cat cc ccflags rm Setvar contains i_stdlib run
 ?MAKE: -pick add $@ %<
 ?S:d_attribute_format (d_attribut_format.U):
 ?S:    This variable conditionally defines HASATTRIBUTE_FORMAT, which
 ?S:    indicates the C compiler can check for printf-like formats.
 ?S:.
+?S:d_printf_format_null:
+?S:    This variable conditionally defines PRINTF_FORMAT_NULL_OK, which
+?S:    indicates the C compiler allows printf-like formats to be null.
+?S:.
 ?S:d_attribute_malloc (d_attribute_malloc.U):
 ?S:    This variable conditionally defines HASATTRIBUTE_MALLOC, which
 ?S:    indicates the C compiler can understand functions as having
@@ -62,6 +69,9 @@
 ?C:HASATTRIBUTE_FORMAT ~ %< (GNUC_ATTRIBUTE_CHECK):
 ?C:    Can we handle GCC attribute for checking printf-style formats
 ?C:.
+?C:PRINTF_FORMAT_NULL_OK:
+?C:    Allows __printf__ format to be null when checking printf-style
+?C:.
 ?C:HASATTRIBUTE_MALLOC:
 ?C:    Can we handle GCC attribute for malloc-style functions.
 ?C:.
@@ -81,6 +91,7 @@
 ?C:    Can we handle GCC attribute for warning on unused results
 ?C:.
 ?H:?%<:#$d_attribute_format HASATTRIBUTE_FORMAT        /**/
+?H:?%<:#$d_printf_format_null PRINTF_FORMAT_NULL_OK    /**/
 ?H:?%<:#$d_attribute_noreturn HASATTRIBUTE_NORETURN    /**/
 ?H:?%<:#$d_attribute_malloc HASATTRIBUTE_MALLOC        /**/
 ?H:?%<:#$d_attribute_nonnull HASATTRIBUTE_NONNULL      /**/
 ?H:?%<:#$d_attribute_warn_unused_result HASATTRIBUTE_WARN_UNUSED_RESULT        /**/
 ?H:.
 ?LINT:set d_attribute_format
+?LINT:set d_printf_format_null
 ?LINT:set d_attribute_malloc
 ?LINT:set d_attribute_nonnull
 ?LINT:set d_attribute_noreturn
@@ -123,6 +135,50 @@ set d_attribute_format
 eval $setvar
 $rm -f attrib*
 
+: Look for GCC-style attribute format with null format allowed
+case "$d_printf_format_null" in
+'') case "$d_attribute_format" in
+    $define)
+       echo " "
+       echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
+$cat >attrib.c <<EOCP
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
+int null_printf (char* pat,...) { return (int)pat; }
+int main () { exit(null_printf(NULL)); }
+EOCP
+       if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
+           : run the executable in case it produces a run-time warning
+           if $run ./attrib >>attrib.out 2>&1; then
+               if $contains 'warning' attrib.out >/dev/null 2>&1; then
+                   echo "Your C compiler doesn't allow __printf__ format to be null."
+                   val="$undef"
+               else
+                   echo "Your C compiler allows __printf__ format to be null."
+                   val="$define"
+               fi
+           else
+           echo "Your C compiler executable failed with __printf__ format null."
+           val="$undef"
+       fi
+    else
+       echo "Your C compiler fails with __printf__ format null."
+       val="$undef"
+    fi
+    ;;
+    *)  val="$undef" ;;
+    esac
+;;
+*)  val="$d_printf_format_null" ;;
+esac
+set d_printf_format_null
+eval $setvar
+$rm -f attrib*
+
 : Look for GCC-style attribute malloc
 case "$d_attribute_malloc" in
 '')