summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-01-26 16:16:29 +0000
committerNicholas Clark <nick@ccl4.org>2007-01-26 16:16:29 +0000
commitd9095cec1bba87df718f5a1d0a9ab42fe217cea4 (patch)
treec9fa8049db941c9278d890ee93ab5c93553b70d7 /toke.c
parentabf8b121784743d34fc5407ef35129d1bbdffb2d (diff)
downloadperl-d9095cec1bba87df718f5a1d0a9ab42fe217cea4.tar.gz
Stop S_incline needing to temporarily write a '\0' into its passed-in
buffer. (Requires adding gv_fetchfile_flags(), savesharedpvn() and CopFILE_setn() to provide pointer/length versions of APIs) p4raw-id: //depot/perl@30015
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/toke.c b/toke.c
index de921aa310..51c0cf751c 100644
--- a/toke.c
+++ b/toke.c
@@ -735,13 +735,12 @@ Perl_lex_end(pTHX)
*/
STATIC void
-S_incline(pTHX_ char *s)
+S_incline(pTHX_ const char *s)
{
dVAR;
- char *t;
- char *n;
- char *e;
- char ch;
+ const char *t;
+ const char *n;
+ const char *e;
CopLINE_inc(PL_curcop);
if (*s++ != '#')
@@ -781,9 +780,8 @@ S_incline(pTHX_ char *s)
if (*e != '\n' && *e != '\0')
return; /* false alarm */
- ch = *t;
- *t = '\0';
if (t - s > 0) {
+ const STRLEN len = t - s;
#ifndef USE_ITHREADS
const char * const cf = CopFILE(PL_curcop);
STRLEN tmplen = cf ? strlen(cf) : 0;
@@ -793,7 +791,7 @@ S_incline(pTHX_ char *s)
char smallbuf[128], smallbuf2[128];
char *tmpbuf, *tmpbuf2;
GV **gvp, *gv2;
- STRLEN tmplen2 = strlen(s);
+ STRLEN tmplen2 = len;
if (tmplen + 2 <= sizeof smallbuf)
tmpbuf = smallbuf;
else
@@ -823,9 +821,8 @@ S_incline(pTHX_ char *s)
}
#endif
CopFILE_free(PL_curcop);
- CopFILE_set(PL_curcop, s);
+ CopFILE_setn(PL_curcop, s, len);
}
- *t = ch;
CopLINE_set(PL_curcop, atoi(n)-1);
}