From: Jarkko Hietaniemi Date: Thu, 1 Nov 2001 13:59:42 +0000 (+0000) Subject: If an encoding is set by -M/-m, it must be in X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ec9efeca46af8ccad8021f3fbd9ab7f1721da05;p=p5sagit%2Fp5-mst-13.2.git If an encoding is set by -M/-m, it must be in effect only for the actual script, not any other required/-M/-m'ed module, otherwise we enter a nasty recursion in regexec.c while trying to init the simple UTF-8 charclasses like PL_utf8_alnum. p4raw-id: //depot/perl@12799 --- diff --git a/lib/encoding.pm b/lib/encoding.pm index 33c5113..fd9d19b 100644 --- a/lib/encoding.pm +++ b/lib/encoding.pm @@ -61,19 +61,13 @@ If no encoding is specified, the environment variable L is consulted. If that fails, "latin1" (ISO 8859-1) is assumed. If no encoding can be found, C error will be thrown. -=head1 FUTURE POSSIBILITIES +=head1 KNOWN PROBLEMS The C<\x..> and C<\0...> in regular expressions are not affected by -this pragma. They probably should. - -The charnames "\N{...}" does not work with this pragma. - -=head1 KNOWN PROBLEMS +this pragma. They very probably should. -Cannot be combined with C. Note that this is a problem -B if you would like to have Unicode identifiers in your scripts. -You should not need C for anything else these days -(since Perl 5.8.0). +The charnames pragma ("\N{LATIN SMALL SHARP LETTER S}") does not work +with this pragma. =head1 SEE ALSO diff --git a/pod/perlunicode.pod b/pod/perlunicode.pod index a5a69ff..106a4bf 100644 --- a/pod/perlunicode.pod +++ b/pod/perlunicode.pod @@ -53,8 +53,7 @@ B is needed>. You can also use the C pragma to change the default encoding -of the data in your script; see L. Currently this cannot -be combined with C. +of the data in your script; see L. =back diff --git a/pp_ctl.c b/pp_ctl.c index 567370b..9e73ca2 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3036,6 +3036,8 @@ PP(pp_require) SV *filter_state = 0; SV *filter_sub = 0; SV *hook_sv = 0; + SV *encoding; + OP *op; sv = POPs; if (SvNIOKp(sv)) { @@ -3379,7 +3381,17 @@ trylocal: { PL_eval_owner = thr; MUTEX_UNLOCK(&PL_eval_mutex); #endif /* USE_5005THREADS */ - return DOCATCH(doeval(gimme, NULL)); + + /* Store and reset encoding. */ + encoding = PL_encoding; + PL_encoding = Nullsv; + + op = DOCATCH(doeval(gimme, NULL)); + + /* Restore encoding. */ + PL_encoding = encoding; + + return op; } PP(pp_dofile)