develooper Front page | perl.perl5.porters | Postings from May 2003

[PATCH] RE: maint snapshot @ 19525

From:
Robin Barker
Date:
May 16, 2003 09:17
Subject:
[PATCH] RE: maint snapshot @ 19525
Message ID:
533D273D4014D411AB1D00062938C4D90404651D@hotel.npl.co.uk
Patch for format and other warnings (using gcc-3.3 !)
Appended and attached to beat the MS line wrapping.

Some questions.
(1) 	I have changed all 'format(printf)' to '__format__(__printf__)',
is this OK?

(2) 	The second change to MIME/Base64/Base64.xs is needed because
isxdigit has 
   	'(int)' prototype (on my machine, in ctype.h).  Is this right?
   	Should MIME/Base64 use isXDIGIT (a perl.h macro)?

(3)  	Why is the declaration of PerlIO_debug in perlio.c not perlio.h
?

(4)  	The 'gimme' variable is unused in pp_hot.c, line 766.  
	I wonder if the uses of 'GIMME' later in the function should be
'gimme' ?

(5)	The '#ifdef CHECK_FORMAT __attribute__(...) #endif' would be
more compact
	if there was an __attribute__format__() macro which was non-null
only when
	both HASATTRIBUTE and CHECK_FORMAT were set.  Should I do this?

Robin

diff -ur ../perl@19525/Configure ./Configure
--- ../perl@19525/Configure	Wed May 14 07:35:32 2003
+++ ./Configure	
@@ -9815,7 +9815,7 @@
 echo "Checking whether your compiler can handle __attribute__ ..." >&4
 $cat >attrib.c <<'EOCP'
 #include <stdio.h>
-void croak (char* pat,...)
__attribute__((format(printf,1,2),noreturn));
+void croak (char* pat,...)
__attribute__((__format__(__printf__,1,2),noreturn));
 EOCP
 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
 	if $contains 'warning' attrib.out >/dev/null 2>&1; then
diff -ur ../perl@19525/embed.pl ./embed.pl
--- ../perl@19525/embed.pl	Sun May  4 10:39:51 2003
+++ ./embed.pl
@@ -203,7 +203,8 @@
 	    my $prefix = $flags =~ /n/ ? '' : 'pTHX_';
 	    my $args = scalar @args;
 	    $ret .= "\n#ifdef CHECK_FORMAT\n";
-	    $ret .= sprintf "
__attribute__((format(__printf__,%s%d,%s%d)))",
+	    $ret .=
+		sprintf "
__attribute__((__format__(__printf__,%s%d,%s%d)))",
 				    $prefix, $args - 1, $prefix, $args;
 	    $ret .= "\n#endif\n";
 	}
diff -ur ../perl@19525/ext/MIME/Base64/Base64.xs
./ext/MIME/Base64/Base64.xs
--- ../perl@19525/ext/MIME/Base64/Base64.xs	Wed May 14 07:35:47 2003
+++ ./ext/MIME/Base64/Base64.xs
@@ -253,7 +253,7 @@
 
 MODULE = MIME::Base64		PACKAGE = MIME::QuotedPrint
 
-#define qp_isplain(c) ((c) == '\t' || ((c) >= ' ' && (c) <= '~') && (c)
!= '=')
+#define qp_isplain(c) ((c) == '\t' || ((c) >= ' ' && (c) <= '~' && (c)
!= '='))
 
 SV*
 encode_qp(sv,...)
@@ -399,7 +399,8 @@
 		    whitespace = 0;
                 }
             	if (*str == '=') {
-		    if ((str + 2) < end && isxdigit(str[1]) &&
isxdigit(str[2])) {
+		    if ((str + 2) < end && isxdigit((int)str[1])
+					&& isxdigit((int)str[2])) {
 	                char buf[3];
                         str++;
 	                buf[0] = *str++;
diff -ur ../perl@19525/hv.c ./hv.c
--- ../perl@19525/hv.c	Tue May 13 20:10:59 2003
+++ ./hv.c
@@ -1705,7 +1705,7 @@
 		    if (HeVAL(entry) && SvREADONLY(HeVAL(entry))) {
 			SV* keysv = hv_iterkeysv(entry);
 			Perl_croak(aTHX_
-		"Attempt to delete readonly key '%_' from a restricted
hash",
+	"Attempt to delete readonly key '%"SVf"' from a restricted
hash",
 				keysv);
 		    }
 		    SvREFCNT_dec(HeVAL(entry));
diff -ur ../perl@19525/perlio.c ./perlio.c
--- ../perl@19525/perlio.c	Tue May 13 19:38:49 2003
+++ ./perlio.c	
@@ -430,9 +430,14 @@
 #include <sys/mman.h>
 #endif
 
-
+/*
+ * Why is this here - not in perlio.h?  RMB
+ */ 
 void PerlIO_debug(const char *fmt, ...)
-    __attribute__ ((format(__printf__, 1, 2)));
+#ifdef CHECK_FORMAT
+    __attribute__ ((__format__(__printf__, 1, 2)))
+#endif
+;
 
 void
 PerlIO_debug(const char *fmt, ...)
diff -ur ../perl@19525/pp_hot.c ./pp_hot.c
--- ../perl@19525/pp_hot.c	Tue May 13 20:11:01 2003
+++ ./pp_hot.c
@@ -763,8 +763,11 @@
 {
     dSP; dTOPss;
     HV *hv;
-    I32 gimme = GIMME_V;
+/*
+ * Not used
 
+    I32 gimme = GIMME_V;
+ */
     if (SvROK(sv)) {
       wasref:
 	tryAMAGICunDEREF(to_hv);
diff -ur ../perl@19525/proto.h ./proto.h
--- ../perl@19525/proto.h	Wed May 14 07:45:12 2003
+++ ./proto.h	Wed May 14 19:05:57 2003
@@ -100,80 +100,80 @@
 PERL_CALLCONV OP*	Perl_convert(pTHX_ I32 optype, I32 flags, OP*
o);
 PERL_CALLCONV void	Perl_croak(pTHX_ const char* pat, ...)
__attribute__((noreturn))
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_vcroak(pTHX_ const char* pat, va_list*
args) __attribute__((noreturn));
 #if defined(PERL_IMPLICIT_CONTEXT)
 PERL_CALLCONV void	Perl_croak_nocontext(const char* pat, ...)
__attribute__((noreturn))
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV OP*	Perl_die_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_deb_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV char*	Perl_form_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_load_module_nocontext(U32 flags, SV* name,
SV* ver, ...);
 PERL_CALLCONV SV*	Perl_mess_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_warn_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_warner_nocontext(U32 err, const char* pat,
...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV SV*	Perl_newSVpvf_nocontext(const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_catpvf_nocontext(SV* sv, const char*
pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_setpvf_nocontext(SV* sv, const char*
pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_catpvf_mg_nocontext(SV* sv, const char*
pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_setpvf_mg_nocontext(SV* sv, const char*
pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV int	Perl_fprintf_nocontext(PerlIO* stream, const
char* fmt, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,2,3)))
+ __attribute__((__format__(__printf__,2,3)))
 #endif
 ;
 PERL_CALLCONV int	Perl_printf_nocontext(const char* fmt, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,1,2)))
+ __attribute__((__format__(__printf__,1,2)))
 #endif
 ;
 #endif
@@ -194,7 +194,7 @@
 PERL_CALLCONV I32	Perl_cxinc(pTHX);
 PERL_CALLCONV void	Perl_deb(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_vdeb(pTHX_ const char* pat, va_list* args);
@@ -207,7 +207,7 @@
 PERL_CALLCONV void	Perl_deprecate_old(pTHX_ char* s);
 PERL_CALLCONV OP*	Perl_die(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV OP*	Perl_vdie(pTHX_ const char* pat, va_list* args);
@@ -277,7 +277,7 @@
 PERL_CALLCONV OP*	Perl_fold_constants(pTHX_ OP* arg);
 PERL_CALLCONV char*	Perl_form(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV char*	Perl_vform(pTHX_ const char* pat, va_list*
args);
@@ -478,7 +478,7 @@
 #endif
 PERL_CALLCONV SV*	Perl_mess(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV SV*	Perl_vmess(pTHX_ const char* pat, va_list*
args);
@@ -577,7 +577,7 @@
 PERL_CALLCONV SV*	Perl_newSVpvn_share(pTHX_ const char* s, I32
len, U32 hash);
 PERL_CALLCONV SV*	Perl_newSVpvf(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV SV*	Perl_vnewSVpvf(pTHX_ const char* pat, va_list*
args);
@@ -757,7 +757,7 @@
 PERL_CALLCONV SV*	Perl_sv_bless(pTHX_ SV* sv, HV* stash);
 PERL_CALLCONV void	Perl_sv_catpvf(pTHX_ SV* sv, const char* pat,
...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_2,pTHX_3)))
+ __attribute__((__format__(__printf__,pTHX_2,pTHX_3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_vcatpvf(pTHX_ SV* sv, const char* pat,
va_list* args);
@@ -808,7 +808,7 @@
 PERL_CALLCONV void	Perl_sv_reset(pTHX_ char* s, HV* stash);
 PERL_CALLCONV void	Perl_sv_setpvf(pTHX_ SV* sv, const char* pat,
...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_2,pTHX_3)))
+ __attribute__((__format__(__printf__,pTHX_2,pTHX_3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_vsetpvf(pTHX_ SV* sv, const char* pat,
va_list* args);
@@ -881,13 +881,13 @@
 PERL_CALLCONV void	Perl_report_uninit(pTHX);
 PERL_CALLCONV void	Perl_warn(pTHX_ const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_1,pTHX_2)))
+ __attribute__((__format__(__printf__,pTHX_1,pTHX_2)))
 #endif
 ;
 PERL_CALLCONV void	Perl_vwarn(pTHX_ const char* pat, va_list*
args);
 PERL_CALLCONV void	Perl_warner(pTHX_ U32 err, const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_2,pTHX_3)))
+ __attribute__((__format__(__printf__,pTHX_2,pTHX_3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_vwarner(pTHX_ U32 err, const char* pat,
va_list* args);
@@ -918,7 +918,7 @@
 #endif
 PERL_CALLCONV void	Perl_sv_catpvf_mg(pTHX_ SV *sv, const char* pat,
...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_2,pTHX_3)))
+ __attribute__((__format__(__printf__,pTHX_2,pTHX_3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_vcatpvf_mg(pTHX_ SV* sv, const char*
pat, va_list* args);
@@ -927,7 +927,7 @@
 PERL_CALLCONV void	Perl_sv_catsv_mg(pTHX_ SV *dstr, SV *sstr);
 PERL_CALLCONV void	Perl_sv_setpvf_mg(pTHX_ SV *sv, const char* pat,
...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_2,pTHX_3)))
+ __attribute__((__format__(__printf__,pTHX_2,pTHX_3)))
 #endif
 ;
 PERL_CALLCONV void	Perl_sv_vsetpvf_mg(pTHX_ SV* sv, const char*
pat, va_list* args);
@@ -943,7 +943,7 @@
 PERL_CALLCONV char*	Perl_pv_display(pTHX_ SV *dsv, char *pv, STRLEN
cur, STRLEN len, STRLEN pvlim);
 PERL_CALLCONV void	Perl_dump_indent(pTHX_ I32 level, PerlIO *file,
const char* pat, ...)
 #ifdef CHECK_FORMAT
- __attribute__((format(__printf__,pTHX_3,pTHX_4)))
+ __attribute__((__format__(__printf__,pTHX_3,pTHX_4)))
 #endif
 ;
 PERL_CALLCONV void	Perl_dump_vindent(pTHX_ I32 level, PerlIO *file,
const char* pat, va_list *args);
End of patch



-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW.
-------------------------------------------------------------------


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About