&& strchr(oname, '\n')
)
+ {
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* PL_warn_nl is constant */
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "open");
+ GCC_DIAG_RESTORE;
+ }
goto say_false;
}
s = SvPVX_const(PL_statname); /* s now NUL-terminated */
PL_laststype = OP_STAT;
PL_laststatval = PerlLIO_stat(s, &PL_statcache);
- if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
+ if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n')) {
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* PL_warn_nl is constant */
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "stat");
+ GCC_DIAG_RESTORE;
+ }
return PL_laststatval;
}
}
file = SvPV_flags_const_nolen(sv, flags);
sv_setpv(PL_statname,file);
PL_laststatval = PerlLIO_lstat(file,&PL_statcache);
- if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n'))
- Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "lstat");
+ if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n')) {
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* PL_warn_nl is constant */
+ Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "lstat");
+ GCC_DIAG_RESTORE;
+ }
return PL_laststatval;
}
|NN SV* const invlist
#endif
Ap |void |taint_env
-Ap |void |taint_proper |NULLOK const char* f|NN const char *const s
+Afp |void |taint_proper |NULLOK const char* f|NN const char *const s
Apd |UV |to_utf8_case |NN const U8 *p|NN U8* ustrp|NULLOK STRLEN *lenp \
|NN SV **swashp|NN const char *normal|NULLOK const char *special
Abmd |UV |to_utf8_lower |NN const U8 *p|NN U8* ustrp|NULLOK STRLEN *lenp
# endif
# if defined(DEBUGGING)
s |int |tokereport |I32 rv|NN const YYSTYPE* lvalp
-s |void |printbuf |NN const char *const fmt|NN const char *const s
+sf |void |printbuf |NN const char *const fmt|NN const char *const s
# endif
#endif
EXMp |bool |validate_proto |NN SV *name|NULLOK SV *proto|bool warn
int isdst
CODE:
{
- char *buf = my_strftime(SvPV_nolen(fmt), sec, min, hour, mday, mon, year, wday, yday, isdst);
+ char *buf;
+
+ /* allowing user-supplied (rather than literal) formats
+ * is normally frowned upon as a potential security risk;
+ * but this is part of the API so we have to allow it */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
+ buf = my_strftime(SvPV_nolen(fmt), sec, min, hour, mday, mon, year, wday, yday, isdst);
+ GCC_DIAG_RESTORE;
if (buf) {
SV *const sv = sv_newmortal();
sv_usepvn_flags(sv, buf, strlen(buf), SV_HAS_TRAILING_NUL);
our ($AUTOLOAD, %SIGRT);
-our $VERSION = '1.36';
+our $VERSION = '1.37';
require XSLoader;
STRLEN linemax; /* estimate of output size in bytes */
bool item_is_utf8 = FALSE;
bool targ_is_utf8 = FALSE;
- const char *fmt;
MAGIC *mg = NULL;
U8 *source; /* source of bytes to append */
STRLEN to_copy; /* how may bytes to append */
}
case FF_0DECIMAL: /* like FF_DECIMAL but for 0### */
- arg = *fpc++;
-#if defined(USE_LONG_DOUBLE)
- fmt = (const char *)
- ((arg & FORM_NUM_POINT) ?
- "%#0*.*" PERL_PRIfldbl : "%0*.*" PERL_PRIfldbl);
-#else
- fmt = (const char *)
- ((arg & FORM_NUM_POINT) ?
- "%#0*.*f" : "%0*.*f");
-#endif
- goto ff_dec;
-
case FF_DECIMAL: /* do @##, ^##, where <arg>=(precision|flags) */
+ {
+ I32 form_num_point;
+
arg = *fpc++;
-#if defined(USE_LONG_DOUBLE)
- fmt = (const char *)
- ((arg & FORM_NUM_POINT) ? "%#*.*" PERL_PRIfldbl : "%*.*" PERL_PRIfldbl);
-#else
- fmt = (const char *)
- ((arg & FORM_NUM_POINT) ? "%#*.*f" : "%*.*f");
-#endif
- ff_dec:
+ form_num_point = (arg & FORM_NUM_POINT);
+
/* If the field is marked with ^ and the value is undefined,
blank it out. */
if ((arg & FORM_NUM_BLANK) && !SvOK(sv)) {
{
STORE_NUMERIC_STANDARD_SET_LOCAL();
arg &= ~(FORM_NUM_POINT|FORM_NUM_BLANK);
- my_snprintf(t, SvLEN(PL_formtarget) - (t - SvPVX(PL_formtarget)), fmt, (int) fieldsize, (int) arg, value);
+ my_snprintf(t,
+ SvLEN(PL_formtarget) - (t - SvPVX(PL_formtarget)),
+ (fpc[-2] == FF_0DECIMAL)
+ ?
+ form_num_point
+#if defined(USE_LONG_DOUBLE)
+ ? "%#0*.*" PERL_PRIfldbl
+ : "%0*.*" PERL_PRIfldbl
+#else
+ ? "%#0*.*f"
+ : "%0*.*f"
+#endif
+ :
+ form_num_point
+#if defined(USE_LONG_DOUBLE)
+ ? "%#*.*" PERL_PRIfldbl
+ : "%*.*" PERL_PRIfldbl
+#else
+ ? "%#*.*f"
+ : "%*.*f"
+#endif
+ , (int) fieldsize, (int) arg, value);
+
RESTORE_NUMERIC_STANDARD();
}
t += fieldsize;
break;
+ }
case FF_NEWLINE: /* delete trailing spaces, then append \n */
f++;
else
PL_laststatval = PerlLIO_stat(SvPV_nolen_const(PL_statname), &PL_statcache);
if (PL_laststatval < 0) {
- if (ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(PL_statname), '\n'))
+ if (ckWARN(WARN_NEWLINE) &&
+ strchr(SvPV_nolen_const(PL_statname), '\n'))
+ {
+ /* PL_warn_nl is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "stat");
+ GCC_DIAG_RESTORE;
+ }
max = 0;
}
}
}
if (ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(PL_statname),
'\n'))
+ {
+ /* PL_warn_nl is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "open");
+ GCC_DIAG_RESTORE;
+ }
FT_RETURNUNDEF;
}
PL_laststype = OP_STAT;
/* PERL_CALLCONV I32 Perl_my_stat(pTHX); */
PERL_CALLCONV I32 Perl_my_stat_flags(pTHX_ const U32 flags);
PERL_CALLCONV char * Perl_my_strftime(pTHX_ const char *fmt, int sec, int min, int hour, int mday, int mon, int year, int wday, int yday, int isdst)
- __attribute__format__null_ok__(__strftime__,pTHX_1,0)
+ __attribute__format__(__strftime__,pTHX_1,0)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_MY_STRFTIME \
assert(fmt)
PERL_CALLCONV void Perl_sys_term(void);
PERL_CALLCONV void Perl_taint_env(pTHX);
PERL_CALLCONV void Perl_taint_proper(pTHX_ const char* f, const char *const s)
+ __attribute__format__null_ok__(__printf__,pTHX_1,0)
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_TAINT_PROPER \
assert(s)
# endif
# if defined(PERL_IN_TOKE_C)
STATIC void S_printbuf(pTHX_ const char *const fmt, const char *const s)
+ __attribute__format__(__printf__,pTHX_1,0)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_2);
#define PERL_ARGS_ASSERT_PRINTBUF \
}
if( $flags =~ /f/ ) {
my $prefix = $has_context ? 'pTHX_' : '';
- my $args = scalar @args;
- my $pat = $args - 1;
- my $macro = @nonnull && $nonnull[-1] == $pat
+ my ($args, $pat);
+ if ($args[-1] eq '...') {
+ $args = scalar @args;
+ $pat = $args - 1;
+ $args = $prefix . $args;
+ }
+ else {
+ # don't check args, and guess which arg is the pattern
+ # (one of 'fmt', 'pat', 'f'),
+ $args = 0;
+ my @fmts = grep $args[$_] =~ /\b(f|pat|fmt)$/, 0..$#args;
+ if (@fmts != 1) {
+ die "embed.pl: '$plain_func': can't determine pattern arg\n";
+ }
+ $pat = $fmts[0] + 1;
+ }
+ my $macro = grep($_ == $pat, @nonnull)
? '__attribute__format__'
: '__attribute__format__null_ok__';
if ($plain_func =~ /strftime/) {
push @attrs, sprintf "%s(__strftime__,%s1,0)", $macro, $prefix;
}
else {
- push @attrs, sprintf "%s(__printf__,%s%d,%s%d)", $macro,
- $prefix, $pat, $prefix, $args;
+ push @attrs, sprintf "%s(__printf__,%s%d,%s)", $macro,
+ $prefix, $pat, $args;
}
}
if ( @nonnull ) {
}
#endif
+ /* hopefully the above makes ptr a very constrained format
+ * that is safe to use, even though it's not literal */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
#if defined(HAS_LONG_DOUBLE)
elen = ((intsize == 'q')
? my_snprintf(PL_efloatbuf, PL_efloatsize, ptr, nv)
#else
elen = my_sprintf(PL_efloatbuf, ptr, nv);
#endif
+ GCC_DIAG_RESTORE;
}
float_converted:
eptr = PL_efloatbuf;
if (varname)
sv_insert(varname, 0, 0, " ", 1);
}
+ /* PL_warn_uninit_sv is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
/* diag_listed_as: Use of uninitialized value%s */
Perl_warner(aTHX_ packWARN(WARN_UNINITIALIZED), PL_warn_uninit_sv,
SVfARG(varname ? varname : &PL_sv_no),
" in ", OP_DESC(PL_op));
+ GCC_DIAG_RESTORE;
}
- else
+ else {
+ /* PL_warn_uninit is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
Perl_warner(aTHX_ packWARN(WARN_UNINITIALIZED), PL_warn_uninit,
"", "", "");
+ GCC_DIAG_RESTORE;
+ }
}
/*
ug = " while running with -t switch";
else
ug = " while running with -T switch";
+
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */
if (PL_unsafe || TAINT_WARN_get) {
Perl_ck_warner_d(aTHX_ packWARN(WARN_TAINT), f, s, ug);
}
else {
Perl_croak(aTHX_ f, s, ug);
}
+ GCC_DIAG_RESTORE;
+
}
}
PERL_ARGS_ASSERT_PRINTBUF;
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */
PerlIO_printf(Perl_debug_log, fmt, pv_display(tmp, s, strlen(s), 0, 60));
+ GCC_DIAG_RESTORE;
SvREFCNT_dec(tmp);
}
while (isLOWER(*d))
d++;
if (!*d && !gv_stashpv(PL_tokenbuf, UTF ? SVf_UTF8 : 0))
+ {
+ /* PL_warn_reserved is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
Perl_warner(aTHX_ packWARN(WARN_RESERVED), PL_warn_reserved,
PL_tokenbuf);
+ GCC_DIAG_RESTORE;
+ }
}
}
}
tmp = allocmy(PL_tokenbuf, tokenbuf_len, UTF ? SVf_UTF8 : 0);
}
else {
- if (has_colon)
+ if (has_colon) {
+ /* PL_no_myglob is constant */
+ GCC_DIAG_IGNORE(-Wformat-nonliteral);
yyerror_pv(Perl_form(aTHX_ PL_no_myglob,
PL_in_my == KEY_my ? "my" : "state", PL_tokenbuf),
UTF ? SVf_UTF8 : 0);
+ GCC_DIAG_RESTORE;
+ }
pl_yylval.opval = newOP(OP_PADANY, 0);
pl_yylval.opval->op_targ = allocmy(PL_tokenbuf, tokenbuf_len,
#endif
buflen = 64;
Newx(buf, buflen, char);
+
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */
len = strftime(buf, buflen, fmt, &mytm);
+ GCC_DIAG_RESTORE;
+
/*
** The following is needed to handle to the situation where
** tmpbuf overflows. Basically we want to allocate a buffer
Renew(buf, bufsize, char);
while (buf) {
+
+ GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */
buflen = strftime(buf, bufsize, fmt, &mytm);
+ GCC_DIAG_RESTORE;
+
if (buflen > 0 && buflen < bufsize)
break;
/* heuristic to prevent out-of-memory errors */