diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
commit | d9095cec1bba87df718f5a1d0a9ab42fe217cea4 (patch) | |
tree | c9fa8049db941c9278d890ee93ab5c93553b70d7 /toke.c | |
parent | abf8b121784743d34fc5407ef35129d1bbdffb2d (diff) | |
download | perl-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.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -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); } |