summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-05 15:40:42 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-05 15:40:42 +0000
commitbf1fed83f9a0d78ad078e497a12a4e988adb9031 (patch)
tree8df1d9ca1c848f8708f1a21e6f24d5ae65f3a839 /utf8.c
parent299b089d70d012ab45fb81fc8423448962619a13 (diff)
downloadperl-bf1fed83f9a0d78ad078e497a12a4e988adb9031.tar.gz
Do away with strncpy() and a fixed length buffer.
p4raw-id: //depot/perl@8332
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index 83e91fcc50..e82725ec72 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1115,7 +1115,7 @@ SV*
Perl_swash_init(pTHX_ char* pkg, char* name, SV *listsv, I32 minbits, I32 none)
{
SV* retval;
- char tmpbuf[256];
+ SV* tokenbufsv = sv_2mortal(NEWSV(0,0));
dSP;
if (!gv_stashpv(pkg, 0)) { /* demand load utf8 */
@@ -1137,8 +1137,9 @@ Perl_swash_init(pTHX_ char* pkg, char* name, SV *listsv, I32 minbits, I32 none)
SAVEI32(PL_hints);
PL_hints = 0;
save_re_context();
- if (PL_curcop == &PL_compiling) /* XXX ought to be handled by lex_start */
- strncpy(tmpbuf, PL_tokenbuf, sizeof tmpbuf);
+ if (PL_curcop == &PL_compiling)
+ /* XXX ought to be handled by lex_start */
+ sv_setpv(tokenbufsv, PL_tokenbuf);
if (call_method("SWASHNEW", G_SCALAR))
retval = newSVsv(*PL_stack_sp--);
else
@@ -1146,7 +1147,10 @@ Perl_swash_init(pTHX_ char* pkg, char* name, SV *listsv, I32 minbits, I32 none)
LEAVE;
POPSTACK;
if (PL_curcop == &PL_compiling) {
- strncpy(PL_tokenbuf, tmpbuf, sizeof tmpbuf);
+ STRLEN len;
+ char* pv = SvPV(tokenbufsv, len);
+
+ Copy(pv, PL_tokenbuf, len+1, char);
PL_curcop->op_private = PL_hints;
}
if (!SvROK(retval) || SvTYPE(SvRV(retval)) != SVt_PVHV)