X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTabs.pm;h=36107fcfe3e33483b7dd55fff3b50e889624131b;hb=8dfcc1616e57fd4d21ae26bcb2e0c92ae93ab613;hp=b26f8f40548f59cecd2e437766f845cadf84c6e6;hpb=20fd23efee32fd4dc6fa842669b5cae4a592f9b2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Text/Tabs.pm b/lib/Text/Tabs.pm index b26f8f4..36107fc 100644 --- a/lib/Text/Tabs.pm +++ b/lib/Text/Tabs.pm @@ -7,7 +7,7 @@ require Exporter; @EXPORT = qw(expand unexpand $tabstop); use vars qw($VERSION $tabstop $debug); -$VERSION = 98.112801; +$VERSION = 2005.0824; use strict; @@ -16,15 +16,21 @@ BEGIN { $debug = 0; } -sub expand -{ - my (@l) = @_; - for $_ (@l) { - 1 while s/(^|\n)([^\t\n]*)(\t+)/ - $1. $2 . (" " x - ($tabstop * length($3) - - (length($2) % $tabstop))) - /sex; +sub expand { + my @l; + my $pad; + for ( @_ ) { + my $s = ''; + for (split(/^/m, $_, -1)) { + my $offs = 0; + s{\t}{ + $pad = $tabstop - (pos() + $offs) % $tabstop; + $offs += $pad - 1; + " " x $pad; + }eg; + $s .= $_; + } + push(@l, $s); } return @l if wantarray; return $l[0]; @@ -66,6 +72,20 @@ sub unexpand 1; __END__ +sub expand +{ + my (@l) = @_; + for $_ (@l) { + 1 while s/(^|\n)([^\t\n]*)(\t+)/ + $1. $2 . (" " x + ($tabstop * length($3) + - (length($2) % $tabstop))) + /sex; + } + return @l if wantarray; + return $l[0]; +} + =head1 NAME @@ -92,6 +112,10 @@ compression with plain ascii! expand doesn't handle newlines very quickly -- do not feed it an entire document in one string. Instead feed it an array of lines. -=head1 AUTHOR +=head1 LICENSE + +Copyright (C) 1996-2002,2005 David Muir Sharnoff. +Copyright (C) 2005 Aristotle Pagaltzis +This module may be modified, used, copied, and redistributed at your own risk. +Publicly redistributed modified versions must use a different name. -David Muir Sharnoff