diff options
author | Adrian M. Enache <enache@rdslink.ro> | 2003-03-02 07:43:54 +0200 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-03-04 05:14:13 +0000 |
commit | efd8b2bacfee8a05a6684f052b8bf5610dd1fa01 (patch) | |
tree | 14a91b8a60e7cc749c49ab57241fd2521a39edc9 /sv.c | |
parent | 3995db9d6ce174a8383f94c41f5d5b8abec975e8 (diff) | |
download | perl-efd8b2bacfee8a05a6684f052b8bf5610dd1fa01.tar.gz |
Re: [perl #21395] rcatline doesn't grok utf8
Message-ID: <20030302034354.GA4905@ratsnest.hole>
p4raw-id: //depot/perl@18822
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -6247,7 +6247,27 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) (void)SvUPGRADE(sv, SVt_PV); SvSCREAM_off(sv); - SvPOK_only(sv); /* Validate pointer */ + + if (append) { + if (PerlIO_isutf8(fp)) { + if (!SvUTF8(sv)) { + sv_utf8_upgrade_nomg(sv); + sv_pos_u2b(sv,&append,0); + } + } else if (SvUTF8(sv)) { + SV *tsv = NEWSV(0,0); + sv_gets(tsv, fp, 0); + sv_utf8_upgrade_nomg(tsv); + SvCUR_set(sv,append); + sv_catsv(sv,tsv); + sv_free(tsv); + goto return_string_or_null; + } + } + + SvPOK_only(sv); + if (PerlIO_isutf8(fp)) + SvUTF8_on(sv); if (PL_curcop == &PL_compiling) { /* we always read code in line mode */ @@ -6290,7 +6310,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) #endif SvCUR_set(sv, bytesread += append); buffer[bytesread] = '\0'; - goto check_utf8_and_return; + goto return_string_or_null; } else if (RsPARA(PL_rs)) { rsptr = "\n\n"; @@ -6543,12 +6563,7 @@ screamer2: } } -check_utf8_and_return: - if (PerlIO_isutf8(fp)) - SvUTF8_on(sv); - else - SvUTF8_off(sv); - +return_string_or_null: return (SvCUR(sv) - append) ? SvPVX(sv) : Nullch; } |