summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-04-25 21:23:39 +0300
committerSteve Peters <steve@fisharerojo.org>2006-04-28 02:12:03 +0000
commite80fed9da44c731a6f85b5544b737325bd9a41a7 (patch)
treeed45b5a4741d1cebf6930d3baf33fb3c0d808797 /pp_ctl.c
parent658aef798ab992aed2b708fed0d12323ab3b1fcb (diff)
downloadperl-e80fed9da44c731a6f85b5544b737325bd9a41a7.tar.gz
Re: [PATCH] use snprintf/strlcpy/strlcat when useful
Message-ID: <444E3EFB.8020503@gmail.com> p4raw-id: //depot/perl@27987
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index dd7d122d0b..485a0043fd 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -831,7 +831,11 @@ PP(pp_formline)
/* Formats aren't yet marked for locales, so assume "yes". */
{
STORE_NUMERIC_STANDARD_SET_LOCAL();
+#ifdef USE_SNPRINTF
+ snprintf(t, SvLEN(PL_formtarget) - (t - SvPVX(PL_formtarget)), fmt, (int) fieldsize, (int) arg & 255, value);
+#else
sprintf(t, fmt, (int) fieldsize, (int) arg & 255, value);
+#endif /* ifdef USE_SNPRINTF */
RESTORE_NUMERIC_STANDARD();
}
t += fieldsize;
@@ -2769,8 +2773,13 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
len = SvCUR(sv);
}
else
+#ifdef USE_SNPRINTF
+ len = snprintf(tmpbuf, sizeof(tbuf), "_<(%.10s_eval %lu)", code,
+ (unsigned long)++PL_evalseq);
+#else
len = my_sprintf(tmpbuf, "_<(%.10s_eval %lu)", code,
(unsigned long)++PL_evalseq);
+#endif /* ifdef USE_SNPRINTF */
SAVECOPFILE_FREE(&PL_compiling);
CopFILE_set(&PL_compiling, tmpbuf+2);
SAVECOPLINE(&PL_compiling);
@@ -3422,6 +3431,10 @@ PP(pp_entereval)
CV* runcv;
U32 seq;
HV *saved_hh = NULL;
+ const char * const fakestr = "_<(eval )";
+#ifdef HAS_STRLCPY
+ const int fakelen = 9 + 1;
+#endif
if (PL_op->op_private & OPpEVAL_HAS_HH) {
saved_hh = (HV*) SvREFCNT_inc(POPs);
@@ -3447,7 +3460,11 @@ PP(pp_entereval)
len = SvCUR(temp_sv);
}
else
+#ifdef USE_SNPRINTF
+ len = snprintf(tmpbuf, sizeof(tbuf), "_<(eval %lu)", (unsigned long)++PL_evalseq);
+#else
len = my_sprintf(tmpbuf, "_<(eval %lu)", (unsigned long)++PL_evalseq);
+#endif /* ifdef USE_SNPRINTF */
SAVECOPFILE_FREE(&PL_compiling);
CopFILE_set(&PL_compiling, tmpbuf+2);
SAVECOPLINE(&PL_compiling);
@@ -3500,7 +3517,12 @@ PP(pp_entereval)
ret = doeval(gimme, NULL, runcv, seq);
if (PERLDB_INTER && was != (I32)PL_sub_generation /* Some subs defined here. */
&& ret != PL_op->op_next) { /* Successive compilation. */
- strcpy(safestr, "_<(eval )"); /* Anything fake and short. */
+ /* Copy in anything fake and short. */
+#ifdef HAS_STRLCPY
+ strlcpy(safestr, fakestr, fakelen);
+#else
+ strcpy(safestr, fakestr);
+#endif /* #ifdef HAS_STRLCPY */
}
return DOCATCH(ret);
}