From: Nicholas Clark Date: Mon, 17 Nov 2008 22:31:07 +0000 (+0000) Subject: No need to str*cpy() a string of known fixed length ("_<(eval )") when X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e389bba906c384f4fc3f3ad5e721e737cbd5d54e;p=p5sagit%2Fp5-mst-13.2.git No need to str*cpy() a string of known fixed length ("_<(eval )") when a simple 1 byte write has the same desired effect. Clearly the Campaign for the Elimination of strlen() needs to branch out into str*cat() and str*cpy(). p4raw-id: //depot/perl@34874 --- diff --git a/pp_ctl.c b/pp_ctl.c index b2cbbde..cd5c1c1 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3662,9 +3662,7 @@ PP(pp_entereval) CV* runcv; U32 seq; HV *saved_hh = NULL; - const char * const fakestr = "_<(eval )"; - const int fakelen = 9 + 1; - + if (PL_op->op_private & OPpEVAL_HAS_HH) { saved_hh = MUTABLE_HV(SvREFCNT_inc(POPs)); } @@ -3735,8 +3733,13 @@ PP(pp_entereval) if ((PERLDB_LINE || PERLDB_SAVESRC) && was != (I32)PL_sub_generation /* Some subs defined here. */ && ok) { - /* Copy in anything fake and short. */ - my_strlcpy(safestr, fakestr, fakelen); + /* Just need to change the string in our writable scratch buffer that + will be used at scope exit to delete this eval's "file" name, to + something safe. The key names are of the form "_<(eval 1)" upwards, + so the 8th char is the first digit, which will not have a leading + zero. So give it a leading zero, and it can't match anything, but + still sits within the pattern space "reserved" for evals. */ + safestr[8] = '0'; } return ok ? DOCATCH(PL_eval_start) : PL_op->op_next; }