@@ -12,7 +12,7 @@ use File::Spec::Functions qw(catfile catdir splitdir);
12
12
use vars qw( $VERSION @Pagers $Bindir $Pod2man
13
13
$Temp_Files_Created $Temp_File_Lifetime
14
14
) ;
15
- $VERSION = ' 3.24' ;
15
+ $VERSION = ' 3.24' ; # ++
16
16
17
17
# ..........................................................................
18
18
@@ -1043,7 +1043,11 @@ sub search_perlvar {
1043
1043
open (PVAR, " <" , $perlvar ) # "Funk is its own reward"
1044
1044
or $self -> die(" Can't open $perlvar : $! " );
1045
1045
1046
- binmode (PVAR, " :encoding(UTF-8)" );
1046
+ my $binmode = $] < 5.008; # to do not call binmode()
1047
+ if ( $binmode ) {
1048
+ $self -> aside(" Your old perl doesn't really have proper unicode support." );
1049
+ }
1050
+
1047
1051
if ( $opt ne ' $0' && $opt =~ / ^\$\d +$ / ) { # handle $1, $2, ...
1048
1052
$opt = ' $<I<digits>>' ;
1049
1053
}
@@ -1055,6 +1059,8 @@ sub search_perlvar {
1055
1059
# Skip introduction
1056
1060
local $_ ;
1057
1061
while (<PVAR>) {
1062
+ # checks =encoding in some lines from the beginning.
1063
+ $binmode ||= /^=encoding\s + (\S + )/ && binmode(PVAR, ":encoding($1 )");
1058
1064
last if /^=over 8/;
1059
1065
}
1060
1066
@@ -1112,8 +1118,12 @@ sub search_perlop {
1112
1118
# XXX FIXME: getting filehandles should probably be done in a single place
1113
1119
# especially since we need to support UTF8 or other encoding when dealing
1114
1120
# with perlop, perlfunc, perlapi, perlfaq[1-9]
1121
+
1115
1122
open ( PERLOP, ' <' , $perlop ) or $self -> die( " Can't open $perlop : $! " );
1116
- binmode (PERLOP, " :encoding(UTF-8)" );
1123
+ my $binmode = $] < 5.008;
1124
+ if ( $binmode ) {
1125
+ $self -> aside(" Your old perl doesn't really have proper unicode support." );
1126
+ }
1117
1127
1118
1128
my $thing = $self -> opt_f;
1119
1129
@@ -1123,6 +1133,7 @@ sub search_perlop {
1123
1133
my $skip = 1;
1124
1134
1125
1135
while ( my $line = <PERLOP> ) {
1136
+ $binmode ||= $line =~ / ^=encoding\s +(\S +)/ && binmode (PERLOP, " :encoding($1 )" );
1126
1137
# only start search after we hit the operator section
1127
1138
if ($line =~ m ! ^X<operator, regexp>! ) {
1128
1139
$skip = 0;
@@ -1198,14 +1209,12 @@ sub search_perlapi {
1198
1209
print " Going to perlapi-scan for $search_re in $perlapi \n " ;
1199
1210
1200
1211
# Check available translator or backup to default (english)
1212
+ my $binmode = $] < 5.008;
1201
1213
if ( $self -> opt_L && defined $self -> {' translators' }-> [0] ) {
1202
1214
my $tr = $self -> {' translators' }-> [0];
1203
- if ( $] < 5.008 ) {
1215
+ if ( $binmode ) {
1204
1216
$self -> aside(" Your old perl doesn't really have proper unicode support." );
1205
1217
}
1206
- else {
1207
- binmode (PAPI, " :encoding(UTF-8)" );
1208
- }
1209
1218
}
1210
1219
1211
1220
local $_ ;
@@ -1217,6 +1226,7 @@ sub search_perlapi {
1217
1226
my @related ;
1218
1227
my $related_re ;
1219
1228
while (<PAPI>) { # "The Mothership Connection is here!"
1229
+ $binmode ||= /^=encoding\s + (\S + )/ && binmode(PAPI, ":encoding($1 )");
1220
1230
if ( m/^=item\s +$ search_re\b / ) {
1221
1231
$ found = 1;
1222
1232
}
@@ -1279,20 +1289,19 @@ sub search_perlfunc {
1279
1289
my $re = ' Alphabetical Listing of Perl Functions' ;
1280
1290
1281
1291
# Check available translator or backup to default (english)
1292
+ my $binmode = $] < 5.008;
1282
1293
if ( $self -> opt_L && defined $self -> {' translators' }-> [0] ) {
1283
1294
my $tr = $self -> {' translators' }-> [0];
1284
1295
$re = $tr -> search_perlfunc_re if $tr -> can(' search_perlfunc_re' );
1285
- if ( $] < 5.008 ) {
1296
+ if ( $binmode ) {
1286
1297
$self -> aside(" Your old perl doesn't really have proper unicode support." );
1287
1298
}
1288
- else {
1289
- binmode (PFUNC, " :encoding(UTF-8)" );
1290
- }
1291
1299
}
1292
1300
1293
1301
# Skip introduction
1294
1302
local $_ ;
1295
1303
while (<PFUNC>) {
1304
+ $binmode ||= /^=encoding\s + (\S + )/ && binmode(PFUNC, ":encoding($1 )");
1296
1305
last if /^=head2 $re /;
1297
1306
}
1298
1307
@@ -1381,8 +1390,14 @@ EOD
1381
1390
$self -> die( " invalid file spec: $! " ) if $file =~ / [<>|]/ ;
1382
1391
open (INFAQ, " <" , $file ) # XXX 5.6ism
1383
1392
or $self -> die( " Can't read-open $file : $! \n Aborting" );
1384
- binmode (INFAQ, " :encoding(UTF-8)" );
1393
+
1394
+ my $binmode = $] < 5.008;
1395
+ if ( $binmode ) {
1396
+ $self -> aside(" Your old perl doesn't really have proper unicode support." );
1397
+ }
1398
+
1385
1399
while (<INFAQ>) {
1400
+ $binmode ||= /^=encoding\s + (\S + )/ && binmode(INFAQ, ":encoding($1 )");
1386
1401
if ( m/^=head2\s +. *(?:$search_key )/i ) {
1387
1402
$found = 1;
1388
1403
push @$pod , "=head1 Found in $file \n\n " unless $found_in {$file }++;
0 commit comments