diff options
author | Norbert Preining <norbert@preining.info> | 2024-03-15 03:06:35 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-03-15 03:06:35 +0000 |
commit | 12679ab7d3c2a210f4123163671b532b8b55d5f9 (patch) | |
tree | 0060d13467186ad977f4e73488ee20dd6c0017ab /systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm | |
parent | 62170822e034fdd3f81de7274835d0d3b0467100 (diff) |
CTAN sync 202403150306
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm')
-rw-r--r-- | systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm | 72 |
1 files changed, 22 insertions, 50 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm index db0d15f610..eff0e717c4 100644 --- a/systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/Text/Wrap.pm @@ -1,42 +1,32 @@ +use strict; use warnings; + package Text::Wrap; use warnings::register; -require Exporter; - -@ISA = qw(Exporter); -@EXPORT = qw(wrap fill); -@EXPORT_OK = qw($columns $break $huge); -$VERSION = 2013.0523; -$SUBVERSION = 'modern'; +BEGIN { require Exporter; *import = \&Exporter::import } -use 5.010_000; +our @EXPORT = qw( wrap fill ); +our @EXPORT_OK = qw( $columns $break $huge ); -use vars qw($VERSION $SUBVERSION $columns $debug $break $huge $unexpand $tabstop $separator $separator2); -use strict; - -BEGIN { - $columns = 76; # <= screen width - $debug = 0; - $break = '(?=\s)\X'; - $huge = 'wrap'; # alternatively: 'die' or 'overflow' - $unexpand = 1; - $tabstop = 8; - $separator = "\n"; - $separator2 = undef; -} +our $VERSION = '2021.0814'; +our $SUBVERSION = 'modern'; # back-compat vestige -my $CHUNK = qr/\X/; +our $columns = 76; # <= screen width +our $break = '(?=\s)(?:\r\n|\PM\pM*)'; +our $huge = 'wrap'; # alternatively: 'die' or 'overflow' +our $unexpand = 1; +our $tabstop = 8; +our $separator = "\n"; +our $separator2 = undef; -sub _xlen(_) { scalar(() = $_[0] =~ /$CHUNK/g) } - -sub _xpos(_) { _xlen( substr( $_[0], 0, pos($_[0]) ) ) } +sub _xlen { () = $_[0] =~ /\PM/g } use Text::Tabs qw(expand unexpand); sub wrap { - my ($ip, $xp, @t) = @_; + my ($ip, $xp, @t) = map +( defined $_ ? $_ : '' ), @_; local($Text::Tabs::tabstop) = $tabstop; my $r = ""; @@ -59,17 +49,17 @@ sub wrap pos($t) = 0; while ($t !~ /\G(?:$break)*\Z/gc) { - if ($t =~ /\G((?:(?=[^\n])\X){0,$ll})($break|\n+|\z)/xmgc) { + if ($t =~ /\G((?:(?!\n)\PM\pM*){0,$ll})($break|\n+|\z)/xmgc) { $r .= $unexpand ? unexpand($nl . $lead . $1) : $nl . $lead . $1; $remainder = $2; - } elsif ($huge eq 'wrap' && $t =~ /\G((?:(?=[^\n])\X){$ll})/gc) { + } elsif ($huge eq 'wrap' && $t =~ /\G((?:(?!\n)\PM\pM*){$ll})/gc) { $r .= $unexpand ? unexpand($nl . $lead . $1) : $nl . $lead . $1; $remainder = defined($separator2) ? $separator2 : $separator; - } elsif ($huge eq 'overflow' && $t =~ /\G((?:(?=[^\n])\X)*?)($break|\n+|\z)/xmgc) { + } elsif ($huge eq 'overflow' && $t =~ /\G((?:(?!\n)\PM\pM*)*?)($break|\n+|\z)/xmgc) { $r .= $unexpand ? unexpand($nl . $lead . $1) : $nl . $lead . $1; @@ -79,7 +69,7 @@ sub wrap } elsif ($columns < 2) { warnings::warnif "Increasing \$Text::Wrap::columns from $columns to 2"; $columns = 2; - return ($ip, $xp, @t); + return @_; } else { die "This shouldn't happen"; } @@ -94,23 +84,15 @@ sub wrap } $r .= $remainder; - print "-----------$r---------\n" if $debug; - - print "Finish up with '$lead'\n" if $debug; - - my($opos) = pos($t); - $r .= $lead . substr($t, pos($t), length($t) - pos($t)) if pos($t) ne length($t); - print "-----------$r---------\n" if $debug;; - return $r; } sub fill { - my ($ip, $xp, @raw) = @_; + my ($ip, $xp, @raw) = map +( defined $_ ? $_ : '' ), @_; my @para; my $pp; @@ -128,6 +110,7 @@ sub fill } 1; + __END__ =head1 NAME @@ -269,17 +252,6 @@ Result: "This is a bit of|text that forms a|normal book-style|paragraph" -=head1 SUBVERSION - -This module comes in two flavors: one for modern perls (5.10 and above) -and one for ancient obsolete perls. The version for modern perls has -support for Unicode. The version for old perls does not. You can tell -which version you have installed by looking at C<$Text::Wrap::SUBVERSION>: -it is C<old> for obsolete perls and C<modern> for current perls. - -This man page is for the version for modern perls and so that's probably -what you've got. - =head1 SEE ALSO For correct handling of East Asian half- and full-width characters, |