r19519 - in /branches/upstream/libtext-wrapper-perl: ./ current/ current/Changes current/MANIFEST current/Makefile.PL current/README current/Wrapper.pm current/test.pl
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Tue May 6 14:21:34 UTC 2008
Author: dmn
Date: Tue May 6 14:21:34 2008
New Revision: 19519
URL: http://svn.debian.org/wsvn/?sc=1&rev=19519
Log:
[svn-inject] Installing original source of libtext-wrapper-perl
Added:
branches/upstream/libtext-wrapper-perl/
branches/upstream/libtext-wrapper-perl/current/
branches/upstream/libtext-wrapper-perl/current/Changes
branches/upstream/libtext-wrapper-perl/current/MANIFEST
branches/upstream/libtext-wrapper-perl/current/Makefile.PL
branches/upstream/libtext-wrapper-perl/current/README
branches/upstream/libtext-wrapper-perl/current/Wrapper.pm (with props)
branches/upstream/libtext-wrapper-perl/current/test.pl (with props)
Added: branches/upstream/libtext-wrapper-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/Changes?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/Changes (added)
+++ branches/upstream/libtext-wrapper-perl/current/Changes Tue May 6 14:21:34 2008
@@ -1,0 +1,12 @@
+Revision history for Perl extension Text::Wrapper.
+
+1.000 Oct 26 1998
+ - updated my email address
+
+0.008 Oct 22 1998
+ - Mention that you need Perl 5.004 or later
+ - Don't infinite loop on long words (but it still doesn't break them)
+ (thanks to Ken Williams <ken at forum.swarthmore.edu>)
+
+0.007 May 14 1998
+ - First public release
Added: branches/upstream/libtext-wrapper-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/MANIFEST?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/MANIFEST (added)
+++ branches/upstream/libtext-wrapper-perl/current/MANIFEST Tue May 6 14:21:34 2008
@@ -1,0 +1,6 @@
+Changes Revision history
+MANIFEST See MANIFEST
+Makefile.PL MakeMaker Makefile
+README About the Text::Wrapper module
+Wrapper.pm The Text::Wrapper module
+test.pl Testing... 1, 2, 3, Testing... 1, 2, 3
Added: branches/upstream/libtext-wrapper-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/Makefile.PL?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/Makefile.PL (added)
+++ branches/upstream/libtext-wrapper-perl/current/Makefile.PL Tue May 6 14:21:34 2008
@@ -1,0 +1,13 @@
+# $Id: Makefile.PL 0.1 1998/05/14 22:25:07 Madsen Exp $
+
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Text::Wrapper',
+ 'VERSION_FROM' => 'Wrapper.pm', # finds $VERSION
+ 'dist' => {COMPRESS => 'gzip -9f', SUFFIX => 'gz',
+# This next line is just for my own use, you should comment it out:
+ PREOP => 'cjm_fixup $(DISTVNAME)' # Converts CRLF to LF
+ }
+);
Added: branches/upstream/libtext-wrapper-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/README?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/README (added)
+++ branches/upstream/libtext-wrapper-perl/current/README Tue May 6 14:21:34 2008
@@ -1,0 +1,40 @@
+Text::Wrapper 1.000
+Copyright 1998 Christopher J. Madsen
+
+DESCRIPTION
+
+ This module provides simple word wrapping. It breaks long lines,
+ but does not alter spacing or remove existing line breaks. If
+ you're looking for more sophisticated text formatting, try the
+ Text::Format module.
+
+ Reasons to use Text::Wrapper instead of Text::Format:
+
+ * Text::Wrapper is significantly smaller.
+
+ * It does not alter existing whitespace or combine short lines.
+ It only breaks long lines. By design, Text::Format removes
+ all whitespace and then adds whitespace where it thinks
+ appropriate.
+
+ In short, Text::Wrapper is the object-oriented equivalent of
+ Text::Wrap, but with fewer bugs (I hope).
+
+ Text::Wrapper requires Perl 5.004 or later.
+
+RECENT CHANGES
+
+ Version 1.000 ends the beta stage and updates my email address.
+
+ Version 0.008 corrects a bug that caused an infinite loop if a
+ word was too long to fit on a single line.
+
+LICENSE
+
+ This program is free software; you can redistribute it and/or modify
+ it under the same terms as Perl itself.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
+ GNU General Public License or the Artistic License for more details.
Added: branches/upstream/libtext-wrapper-perl/current/Wrapper.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/Wrapper.pm?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/Wrapper.pm (added)
+++ branches/upstream/libtext-wrapper-perl/current/Wrapper.pm Tue May 6 14:21:34 2008
@@ -1,0 +1,201 @@
+#---------------------------------------------------------------------
+package Text::Wrapper;
+#
+# Copyright 1998 Christopher J. Madsen
+#
+# Author: Christopher J. Madsen <chris_madsen at geocities.com>
+# Created: 06 Mar 1998
+# Version: 1.000 (27-Oct-1998)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the same terms as Perl itself.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
+# GNU General Public License or the Artistic License for more details.
+#
+# Word wrap text by breaking long lines
+#---------------------------------------------------------------------
+
+require 5.004;
+use Carp;
+use strict;
+use vars qw($AUTOLOAD $VERSION);
+
+#=====================================================================
+# Package Global Variables:
+
+BEGIN
+{
+ # Convert RCS revision number to d.ddd format:
+ $VERSION = sprintf('%d.%03d', '1.000 ' =~ /(\d+)\.(\d+)/);
+} # end BEGIN
+
+#=====================================================================
+# Methods:
+#---------------------------------------------------------------------
+# Provide methods for getting/setting fields:
+
+sub AUTOLOAD
+{
+ my $self = $_[0];
+ my $type = ref($self) or croak("$self is not an object");
+ my $name = $AUTOLOAD;
+ $name =~ s/.*://; # strip fully-qualified portion
+ my $field = $name;
+ $field =~ s/_([a-z])/\u$1/g; # squash underlines into mixed case
+ unless (exists $self->{$field}) {
+ # Ignore special methods like DESTROY:
+ return undef if $name =~ /^[A-Z]+$/;
+ croak("Can't locate object method \"$name\" via package \"$type\"");
+ }
+ return $self->{$field} = $_[1] if $#_;
+ $self->{$field};
+} # end AUTOLOAD
+
+#---------------------------------------------------------------------
+sub new
+{
+ my $self = bless {
+ 'bodyStart' => '',
+ 'columns' => 70,
+ 'parStart' => '',
+ }, shift;
+
+ croak "Missing parameter" unless (scalar @_ % 2) == 0;
+ while (@_) {
+ $AUTOLOAD = shift;
+ defined eval { &AUTOLOAD($self, shift) }
+ or croak("Unknown parameter `$AUTOLOAD'");
+ }
+
+ $self;
+} # end new
+
+#---------------------------------------------------------------------
+sub wrap
+{
+ my $self = shift;
+ my $width = $self->{'columns'};
+ my $text = $self->{'parStart'};
+ my $length = length $text;
+ my $lineStart = $length;
+ my $parStart = $text;
+ my $parStartLen = $length;
+ my $continue = "\n" . $self->{'bodyStart'};
+ my $contLen = length $self->{'bodyStart'};
+ pos($_[0]) = 0; # Make sure we start at the beginning
+ for (;;) {
+ if ($_[0] =~ m/\G[ \t]*(\n+)/gc) {
+ $text .= $1 . $parStart;
+ $lineStart = $length = $parStartLen;
+ } else {
+ $_[0] =~ m/\G(\s*(?:[^-\s]+-*|\S+))/g or last;
+ my $word = $1;
+ again:
+ if (($length + length $word <= $width) or ($length == $lineStart)) {
+ $length += length $word;
+ $text .= $word;
+ } else {
+ $text .= $continue;
+ $lineStart = $length = $contLen;
+ $word =~ s/^\s+//;
+ goto again;
+ }
+ }
+ } # end forever
+ if ($length != $lineStart) { $text .= "\n" }
+ else { $text =~ s/(?:\Q$continue\E|\n\Q$parStart\E)\Z/\n/ }
+
+ $text;
+} # end wrap
+
+#=====================================================================
+# Package Return Value:
+
+1;
+
+__END__
+
+=head1 NAME
+
+Text::Wrapper - Simple word wrapping routine
+
+=head1 SYNOPSIS
+
+ require Text::Wrapper;
+ $wrapper = Text::Wrapper->new(columns => 60, body_start => ' ');
+ print $wrapper->wrap($text);
+
+=head1 DESCRIPTION
+
+B<Text::Wrapper> provides simple word wrapping. It breaks long lines,
+but does not alter spacing or remove existing line breaks. If you're
+looking for more sophisticated text formatting, try the
+B<Text::Format> module.
+
+Reasons to use B<Text::Wrapper> instead of B<Text::Format>:
+
+=over 4
+
+=item *
+
+B<Text::Wrapper> is significantly smaller.
+
+=item *
+
+It does not alter existing whitespace or combine short lines.
+It only breaks long lines.
+
+=back
+
+Again, if B<Text::Wrapper> doesn't meet your needs, try
+B<Text::Format>.
+
+=head2 Methods
+
+=over 4
+
+=item $wrapper = Text::Wrapper->new( [options] )
+
+Constructs a new B<Text::Wrapper> object. The options are specified
+by key and value. The keys are:
+
+ body_start The text that begins the second and following lines of
+ a paragraph. (Default '')
+
+ columns The number of columns to use. This includes any text
+ in body_start or par_start. (Default 70)
+
+ par_start The text that begins the first line of each paragraph.
+ (Default '')
+
+=item $wrapper->body_start( [$value] )
+
+=item $wrapper->columns( [$value] )
+
+=item $wrapper->par_start( [$value] )
+
+If C<$value> is supplied, sets the option and returns the previous value.
+If omitted, just returns the current value.
+
+=item $wrapper->wrap($text)
+
+Returns a word wrapped copy of C<$text>. The original is not altered.
+
+=head1 BUGS
+
+Does not handle tabs (they're treated just like spaces).
+
+Does not break words that can't fit on one line.
+
+=head1 AUTHOR
+
+Christopher J. Madsen E<lt>F<chris_madsen at geocities.com>E<gt>
+
+=cut
+
+# Local Variables:
+# tmtrack-file-task: "Text::Wrapper.pm"
+# End:
Propchange: branches/upstream/libtext-wrapper-perl/current/Wrapper.pm
------------------------------------------------------------------------------
svn:keywords = Id
Added: branches/upstream/libtext-wrapper-perl/current/test.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libtext-wrapper-perl/current/test.pl?rev=19519&op=file
==============================================================================
--- branches/upstream/libtext-wrapper-perl/current/test.pl (added)
+++ branches/upstream/libtext-wrapper-perl/current/test.pl Tue May 6 14:21:34 2008
@@ -1,0 +1,361 @@
+# $Id$
+#
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..5\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Text::Wrapper;
+$loaded = 1;
+$generate = (@ARGV and $ARGV[0] eq 'print');
+print "ok 1\n" unless $generate;
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+sub read_data
+{
+ my $text = '';
+ while (<DATA>) {
+ return ($1, $text) if /^\*\s*(.*)/;
+ $text .= $_;
+ }
+ die "Unexpected end of file";
+} # end read_data
+
+# First, read the sample text, remove single line breaks, and condense
+# double line breaks into one:
+
+my $text = (read_data)[1];
+$text =~ s/\n(?=\S)/ /g;
+$text =~ s/\n /\n/g;
+
+# Now try each set of parameters and compare it to the expected result:
+# (Or, if invoked as 'test.pl print', print out the actual
+# results and parameters in the required format.)
+
+my ($test,$args,$expect,$w,$result) = 1;
+for (;;) {
+ ($args,$expect) = read_data;
+ last unless $expect;
+ $w = Text::Wrapper->new(eval $args);
+ $result = $w->wrap($text);
+ if ($generate) { print "$result* $args\n" }
+ else {
+ print 'not ' if $result ne $expect;
+ printf "ok %d\n", ++$test;
+ }
+} # end forever
+
+# Here is the sample text followed by the test cases. Each test case
+# is terminated by a line beginning with *, followed by the parameters
+# for that test. The test cases are terminated by an empty case.
+# Don't forget to change the count in the BEGIN routine.
+
+__DATA__
+Fourscore and seven years ago our fathers brought forth on this
+continent a new nation, conceived in liberty and dedicated to the
+proposition that all men are created equal.
+
+Now we are engaged in a great civil war, testing whether that nation
+or any nation so conceived and so dedicated can long endure. We are
+met on a great battlefield of that war. We have come to dedicate a
+portion of that field as a final resting-place for those who here gave
+their lives that that nation might live. It is altogether fitting and
+proper that we should do this.
+
+But in a larger sense, we cannot dedicate, we cannot consecrate, we
+cannot hallow this ground. The brave men, living and dead who
+struggled here have consecrated it far above our poor power to add or
+detract. The world will little note nor long remember what we say
+here, but it can never forget what they did here. It is for us the
+living rather to be dedicated here to the unfinished work which they
+who fought here have thus far so nobly advanced. It is rather for us
+to be here dedicated to the great task remaining before us--that from
+these honored dead we take increased devotion to that cause for which
+they gave the last full measure of devotion--that we here highly
+resolve that these dead shall not have died in vain, that this nation
+under God shall have a new birth of freedom, and that government of
+the people, by the people, for the people shall not perish from the
+earth.
+*
+Fourscore and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that all
+men are created equal.
+Now we are engaged in a great civil war,
+testing whether that nation or any
+nation so conceived and so dedicated can
+long endure. We are met on a great
+battlefield of that war. We have come to
+dedicate a portion of that field as a
+final resting-place for those who here
+gave their lives that that nation might
+live. It is altogether fitting and
+proper that we should do this.
+But in a larger sense, we cannot
+dedicate, we cannot consecrate, we
+cannot hallow this ground. The brave
+men, living and dead who struggled here
+have consecrated it far above our poor
+power to add or detract. The world will
+little note nor long remember what we
+say here, but it can never forget what
+they did here. It is for us the living
+rather to be dedicated here to the
+unfinished work which they who fought
+here have thus far so nobly advanced. It
+is rather for us to be here dedicated to
+the great task remaining before us--that
+from these honored dead we take
+increased devotion to that cause for
+which they gave the last full measure of
+devotion--that we here highly resolve
+that these dead shall not have died in
+vain, that this nation under God shall
+have a new birth of freedom, and that
+government of the people, by the people,
+for the people shall not perish from the
+earth.
+* (columns => 40)
+> Fourscore and seven years ago our fathers
+ brought forth on this continent a new nation,
+ conceived in liberty and dedicated to the
+ proposition that all men are created equal.
+> Now we are engaged in a great civil war,
+ testing whether that nation or any nation so
+ conceived and so dedicated can long endure. We
+ are met on a great battlefield of that war. We
+ have come to dedicate a portion of that field
+ as a final resting-place for those who here
+ gave their lives that that nation might live.
+ It is altogether fitting and proper that we
+ should do this.
+> But in a larger sense, we cannot dedicate, we
+ cannot consecrate, we cannot hallow this
+ ground. The brave men, living and dead who
+ struggled here have consecrated it far above
+ our poor power to add or detract. The world
+ will little note nor long remember what we say
+ here, but it can never forget what they did
+ here. It is for us the living rather to be
+ dedicated here to the unfinished work which
+ they who fought here have thus far so nobly
+ advanced. It is rather for us to be here
+ dedicated to the great task remaining before
+ us--that from these honored dead we take
+ increased devotion to that cause for which
+ they gave the last full measure of devotion--
+ that we here highly resolve that these dead
+ shall not have died in vain, that this nation
+ under God shall have a new birth of freedom,
+ and that government of the people, by the
+ people, for the people shall not perish from
+ the earth.
+* (par_start => '> ', body_start => ' ', columns => 49)
+> Fourscore and seven years ago our fathers brought forth on this
+ | continent a new nation, conceived in liberty and dedicated to the
+ | proposition that all men are created equal.
+> Now we are engaged in a great civil war, testing whether that
+ | nation or any nation so conceived and so dedicated can long endure.
+ | We are met on a great battlefield of that war. We have come to
+ | dedicate a portion of that field as a final resting-place for those
+ | who here gave their lives that that nation might live. It is
+ | altogether fitting and proper that we should do this.
+> But in a larger sense, we cannot dedicate, we cannot consecrate,
+ | we cannot hallow this ground. The brave men, living and dead who
+ | struggled here have consecrated it far above our poor power to add
+ | or detract. The world will little note nor long remember what we
+ | say here, but it can never forget what they did here. It is for us
+ | the living rather to be dedicated here to the unfinished work which
+ | they who fought here have thus far so nobly advanced. It is rather
+ | for us to be here dedicated to the great task remaining before us--
+ | that from these honored dead we take increased devotion to that
+ | cause for which they gave the last full measure of devotion--that
+ | we here highly resolve that these dead shall not have died in vain,
+ | that this nation under God shall have a new birth of freedom, and
+ | that government of the people, by the people, for the people shall
+ | not perish from the earth.
+* (par_start => '> ', body_start => ' | ')
+Fourscore
+and seven
+years ago
+our
+fathers
+brought
+forth on
+this
+continent
+a new
+nation,
+conceived
+in liberty
+and
+dedicated
+to the
+proposition
+that all
+men are
+created
+equal.
+Now we are
+engaged in
+a great
+civil war,
+testing
+whether
+that
+nation or
+any nation
+so
+conceived
+and so
+dedicated
+can long
+endure. We
+are met on
+a great
+battlefield
+of that
+war. We
+have come
+to
+dedicate a
+portion of
+that field
+as a final
+resting-
+place for
+those who
+here gave
+their
+lives that
+that
+nation
+might
+live. It
+is
+altogether
+fitting
+and proper
+that we
+should do
+this.
+But in a
+larger
+sense, we
+cannot
+dedicate,
+we cannot
+consecrate,
+we cannot
+hallow
+this
+ground.
+The brave
+men,
+living and
+dead who
+struggled
+here have
+consecrated
+it far
+above our
+poor power
+to add or
+detract.
+The world
+will
+little
+note nor
+long
+remember
+what we
+say here,
+but it can
+never
+forget
+what they
+did here.
+It is for
+us the
+living
+rather to
+be
+dedicated
+here to
+the
+unfinished
+work which
+they who
+fought
+here have
+thus far
+so nobly
+advanced.
+It is
+rather for
+us to be
+here
+dedicated
+to the
+great task
+remaining
+before
+us--that
+from these
+honored
+dead we
+take
+increased
+devotion
+to that
+cause for
+which they
+gave the
+last full
+measure of
+devotion--
+that we
+here
+highly
+resolve
+that these
+dead shall
+not have
+died in
+vain, that
+this
+nation
+under God
+shall have
+a new
+birth of
+freedom,
+and that
+government
+of the
+people, by
+the
+people,
+for the
+people
+shall not
+perish
+from the
+earth.
+* (columns => 10)
+* This line marks the end of the test cases
+
+Local Variables:
+ tmtrack-file-task: "Text::Wrapper: test.pl"
+End:
Propchange: branches/upstream/libtext-wrapper-perl/current/test.pl
------------------------------------------------------------------------------
svn:keywords = Id
More information about the Pkg-perl-cvs-commits
mailing list