You can also hand-tweak your config.h to try out different #ifdef
branches.
+=head2 Other tests
+
+=over 4
+
+=item CHECK_FORMAT
+
+To test the correct use of printf-style arguments, C<Configure> with
+S<-Dccflags='-DCHECK_FORMAT -Wformat'> and run C<make>. The compiler
+will produce warning of incorrect use of format arguments. CHECK_FORMAT
+changes perl-defined formats to common formats, so DO NOT USE the executable
+produced by this process.
+
+A more accurate approach is the following commands:
+
+ sh Configure -des -Dccflags=-Wformat ...
+ make miniperl # without -DCHECK_FORMAT
+ perl -i.orig -pwe 's/-Wformat/-DCHECK_FORMAT $&/' config.sh
+ sh Configure -S
+ make >& make.log # build from correct miniperl
+ make clean
+ make miniperl >& mini.log # build miniperl with -DCHECK_FORMAT
+ perl -nwe 'print if /^\S+:/ and not /^make\b/' mini.log make.log
+ make clean
+
+(-Wformat support by Robin Barker.)
+
+=back
+
=head1 Running Purify
Purify is a commercial tool that is helpful in identifying memory
Afnp |OP* |die_nocontext |const char* pat|...
Afnp |void |deb_nocontext |const char* pat|...
Afnp |char* |form_nocontext |const char* pat|...
-Afnp |void |load_module_nocontext|U32 flags|SV* name|SV* ver|...
+Anp |void |load_module_nocontext|U32 flags|SV* name|SV* ver|...
Afnp |SV* |mess_nocontext |const char* pat|...
Afnp |void |warn_nocontext |const char* pat|...
Afnp |void |warner_nocontext|U32 err|const char* pat|...
p |OP* |linklist |OP* o
p |OP* |list |OP* o
p |OP* |listkids |OP* o
-Afp |void |load_module|U32 flags|SV* name|SV* ver|...
+Ap |void |load_module|U32 flags|SV* name|SV* ver|...
Ap |void |vload_module|U32 flags|SV* name|SV* ver|va_list* args
p |OP* |localize |OP* arg|I32 lexical
Apd |I32 |looks_like_number|SV* sv
* -- BKS, June 2000
*/
-#define HEADER_FAIL(f, arg1, arg2) \
+#define HEADER_FAIL(f) \
+ Perl_croak(aTHX_ "Invalid bytecode for this architecture: " f)
+#define HEADER_FAIL1(f, arg1) \
+ Perl_croak(aTHX_ "Invalid bytecode for this architecture: " f, arg1)
+#define HEADER_FAIL2(f, arg1, arg2) \
Perl_croak(aTHX_ "Invalid bytecode for this architecture: " f, arg1, arg2)
#define BYTECODE_HEADER_CHECK \
\
BGET_U32(sz); /* Magic: 'PLBC' */ \
if (sz != 0x43424c50) { \
- HEADER_FAIL("bad magic (want 0x43424c50, got %#x)", sz, 0); \
+ HEADER_FAIL1("bad magic (want 0x43424c50, got %#x)", (int)sz); \
} \
BGET_strconst(str); /* archname */ \
if (strNE(str, ARCHNAME)) { \
- HEADER_FAIL("wrong architecture (want %s, you have %s)",str,ARCHNAME); \
+ HEADER_FAIL2("wrong architecture (want %s, you have %s)",str,ARCHNAME); \
} \
BGET_strconst(str); /* ByteLoader version */ \
if (strNE(str, VERSION)) { \
- HEADER_FAIL("mismatched ByteLoader versions (want %s, you have %s)", \
+ HEADER_FAIL2("mismatched ByteLoader versions (want %s, you have %s)", \
str, VERSION); \
} \
BGET_U32(sz); /* ivsize */ \
if (sz != IVSIZE) { \
- HEADER_FAIL("different IVSIZE", 0, 0); \
+ HEADER_FAIL("different IVSIZE"); \
} \
BGET_U32(sz); /* ptrsize */ \
if (sz != PTRSIZE) { \
- HEADER_FAIL("different PTRSIZE", 0, 0); \
+ HEADER_FAIL("different PTRSIZE"); \
} \
BGET_strconst(str); /* byteorder */ \
if (strNE(str, STRINGIFY(BYTEORDER))) { \
- HEADER_FAIL("different byteorder", 0, 0); \
+ HEADER_FAIL("different byteorder"); \
} \
} STMT_END
DumpProg()
PPCODE:
{
- warn("dumpindent is %d", PL_dumpindent);
+ warn("dumpindent is %d", (int)PL_dumpindent);
if (PL_main_root)
op_dump(PL_main_root);
}
dl_unload_file(libref)
void * libref
CODE:
- DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", libref));
+ DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", PTR2ul(libref)));
RETVAL = (dlclose(libref) == 0 ? 1 : 0);
if (!RETVAL)
SaveError(aTHX_ "%s", dlerror()) ;
sva = av_fetch(cxt->aclass, idx, FALSE);
if (!sva)
- CROAK(("Class name #%d should have been seen already", idx));
+ CROAK(("Class name #%d should have been seen already", (int)idx));
class = SvPVX(*sva); /* We know it's a PV, by construction */
sva = av_fetch(cxt->aclass, idx, FALSE);
if (!sva)
- CROAK(("Class name #%d should have been seen already", idx));
+ CROAK(("Class name #%d should have been seen already", (int)idx));
class = SvPVX(*sva); /* We know it's a PV, by construction */
TRACEME(("class ID %d => %s", idx, class));
tag = ntohl(tag);
svh = av_fetch(cxt->aseen, tag, FALSE);
if (!svh)
- CROAK(("Object #%d should have been retrieved already", tag));
+ CROAK(("Object #%d should have been retrieved already", (int)tag));
xsv = *svh;
ary[i] = SvREFCNT_inc(xsv);
}
I32 tagn;
svh = hv_fetch(cxt->hseen, (char *) &tag, sizeof(tag), FALSE);
if (!svh)
- CROAK(("Old tag 0x%x should have been mapped already", tag));
+ CROAK(("Old tag 0x%x should have been mapped already", (unsigned)tag));
tagn = SvIV(*svh); /* Mapped tag number computed earlier below */
/*
svh = av_fetch(cxt->aseen, tagn, FALSE);
if (!svh)
- CROAK(("Object #%d should have been retrieved already", tagn));
+ CROAK(("Object #%d should have been retrieved already", (int)tagn));
sv = *svh;
TRACEME(("has retrieved #%d at 0x%"UVxf, tagn, PTR2UV(sv)));
SvREFCNT_inc(sv); /* One more reference to this same sv */
tag = ntohl(tag);
svh = av_fetch(cxt->aseen, tag, FALSE);
if (!svh)
- CROAK(("Object #%d should have been retrieved already", tag));
+ CROAK(("Object #%d should have been retrieved already", (int)tag));
sv = *svh;
TRACEME(("had retrieved #%d at 0x%"UVxf, tag, PTR2UV(sv)));
SvREFCNT_inc(sv); /* One more reference to this same sv */
dTHX;
PerlIO_printf(PerlIO_stderr(),
"Unaligned `next' pointer in the free "
- "chain 0x"UVxf" at 0x%"UVxf"\n",
+ "chain 0x%"UVxf" at 0x%"UVxf"\n",
PTR2UV(p->ov_next), PTR2UV(p));
}
#endif
return s;
case 'v':
PerlIO_printf(PerlIO_stdout(),
- Perl_form(aTHX_ "\nThis is perl, v%vd built for %s",
+ Perl_form(aTHX_ "\nThis is perl, v%"VDf" built for %s",
PL_patchlevel, ARCHNAME));
#if defined(LOCAL_PATCH_COUNT)
if (LOCAL_PATCH_COUNT > 0)
#define PTR2IV(p) INT2PTR(IV,p)
#define PTR2UV(p) INT2PTR(UV,p)
#define PTR2NV(p) NUM2PTR(NV,p)
+#if PTRSIZE == LONGSIZE
+# define PTR2ul(p) (unsigned long)(p)
+#else
+# define PTR2ul(p) INT2PTR(unsigned long,p)
+#endif
#ifdef USE_LONG_DOUBLE
# if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
# endif
#endif
+#ifndef UVf
+# ifdef CHECK_FORMAT
+# define UVf UVuf
+# else
+# define UVf "Vu"
+# endif
+#endif
+
+#ifndef VDf
+# ifdef CHECK_FORMAT
+# define VDf "p"
+# else
+# define VDf "vd"
+# endif
+#endif
+
/* Some unistd.h's give a prototype for pause() even though
HAS_PAUSE ends up undefined. This causes the #define
- below to be rejected by the compmiler. Sigh.
+ below to be rejected by the compiler. Sigh.
*/
#ifdef HAS_PAUSE
#define Pause pause
char *t;
STRLEN n_a;
- sv = Perl_newSVpvf(aTHX_ "%.*Vu", (int)TYPE_DIGITS(UV), auv);
+ sv = Perl_newSVpvf(aTHX_ "%.*"UVf, (int)TYPE_DIGITS(UV), auv);
while (s < strend) {
sv = mul128(sv, *s & 0x7f);
if (!(*s++ & 0x80)) {
__attribute__((format(printf,1,2)))
#endif
;
-PERL_CALLCONV void Perl_load_module_nocontext(U32 flags, SV* name, SV* ver, ...)
-#ifdef CHECK_FORMAT
- __attribute__((format(printf,3,4)))
-#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)))
PERL_CALLCONV OP* Perl_linklist(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_list(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_listkids(pTHX_ OP* o);
-PERL_CALLCONV void Perl_load_module(pTHX_ U32 flags, SV* name, SV* ver, ...)
-#ifdef CHECK_FORMAT
- __attribute__((format(printf,pTHX_3,pTHX_4)))
-#endif
-;
+PERL_CALLCONV void Perl_load_module(pTHX_ U32 flags, SV* name, SV* ver, ...);
PERL_CALLCONV void Perl_vload_module(pTHX_ U32 flags, SV* name, SV* ver, va_list* args);
PERL_CALLCONV OP* Perl_localize(pTHX_ OP* arg, I32 lexical);
PERL_CALLCONV I32 Perl_looks_like_number(pTHX_ SV* sv);
ellipses = "..."; \
} \
Perl_croak(aTHX_ "%s in regex m/%.*s%s/", \
- msg, len, PL_regprecomp, ellipses); \
+ msg, (int)len, PL_regprecomp, ellipses); \
} STMT_END
/*
ellipses = "..."; \
} \
S_re_croak2(aTHX_ pat, " in regex m/%.*s%s/", \
- msg, len, PL_regprecomp, ellipses); \
+ msg, (int)len, PL_regprecomp, ellipses); \
} STMT_END
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-PL_regcomp_parse); \
\
Perl_croak(aTHX_ "%s" REPORT_LOCATION, \
- m, offset, PL_regprecomp, PL_regprecomp + offset); \
+ m, (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
/*
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-PL_regcomp_parse); \
\
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, \
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
/*
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-PL_regcomp_parse); \
\
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, \
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
/*
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-PL_regcomp_parse); \
\
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3,\
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
/*
STMT_START { \
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-PL_regcomp_parse); \
S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, a4,\
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
STMT_START { \
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-(loc)); \
Perl_warner(aTHX_ WARN_REGEXP, "%s" REPORT_LOCATION,\
- m, offset, PL_regprecomp, PL_regprecomp + offset); \
+ m, (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END \
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-(loc)); \
Perl_warner(aTHX_ WARN_REGEXP, m REPORT_LOCATION,\
a1, \
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
#define vWARN3(loc, m, a1, a2) \
unsigned offset = strlen(PL_regprecomp) - (PL_regxend - (loc)); \
Perl_warner(aTHX_ WARN_REGEXP, m REPORT_LOCATION, \
a1, a2, \
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
#define vWARN4(loc, m, a1, a2, a3) \
unsigned offset = strlen(PL_regprecomp)-(PL_regxend-(loc)); \
Perl_warner(aTHX_ WARN_REGEXP, m REPORT_LOCATION,\
a1, a2, a3, \
- offset, PL_regprecomp, PL_regprecomp + offset); \
+ (int)offset, PL_regprecomp, PL_regprecomp + offset); \
} STMT_END
if (min > max) {
Perl_croak(aTHX_
"Invalid [] range \"%c-%c\" in transliteration operator",
- min, max);
+ (char)min, (char)max);
}
#ifndef ASCIIish
qerror(msg);
if (PL_error_count >= 10) {
if (PL_in_eval && SvCUR(ERRSV))
- Perl_croak(aTHX_ "%_%s has too many errors.\n",
+ Perl_croak(aTHX_ "%"SVf"%s has too many errors.\n",
ERRSV, CopFILE(PL_curcop));
else
Perl_croak(aTHX_ "%s has too many errors.\n",
/* they said C<use Foo v1.2.3> and $Foo::VERSION
* doesn't look like a float: do string compare */
if (sv_cmp(req,sv) == 1) {
- Perl_croak(aTHX_ "%s v%vd required--"
- "this is only v%vd",
+ Perl_croak(aTHX_ "%s v%"VDf" required--"
+ "this is only v%"VDf,
HvNAME(pkg), req, sv);
}
goto finish;