* lib/Automake/Makefile.am (dist_perllib_DATA): Add Wrap.pm.
* lib/Automake/tests/Makefile.am (TESTS): Add Wrap.pl.
* automake.in (handle_texinfo_helper, pretty_print_rule)
(variable_output): Adjust to use makefile_wrap instead of
pretty_print_internal.
(pretty_print_internal): Remove. Renamed as Automake::Wrap::wrap
and augmented to accept the $eol and $max_len arguments.
+2003-05-21 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * lib/Automake/Wrap.pm, lib/Automake/tests/Wrap.pl: New files.
+ * lib/Automake/Makefile.am (dist_perllib_DATA): Add Wrap.pm.
+ * lib/Automake/tests/Makefile.am (TESTS): Add Wrap.pl.
+ * automake.in (handle_texinfo_helper, pretty_print_rule)
+ (variable_output): Adjust to use makefile_wrap instead of
+ pretty_print_internal.
+ (pretty_print_internal): Remove. Renamed as Automake::Wrap::wrap
+ and augmented to accept the $eol and $max_len arguments.
+
2003-05-18 Alexandre Duret-Lutz <adl@gnu.org>
* lib/Autom4te/XFile.pm, lib/config.guess, lib/config.sub,
mostlyclean-aminfo:
-rm -rf automake.aux automake.cm automake.cp automake.cps automake.cv \
- automake.fn automake.ky automake.kys automake.log automake.op \
- automake.ov automake.pg automake.pgs automake.tmp \
- automake.toc automake.tp automake.tps automake.tr automake.vr \
- automake.vrs automake.dvi automake.pdf automake.ps \
- automake.html
+ automake.fn automake.ky automake.kys automake.log \
+ automake.op automake.ov automake.pg automake.pgs \
+ automake.tmp automake.toc automake.tp automake.tps \
+ automake.tr automake.vr automake.vrs automake.dvi \
+ automake.pdf automake.ps automake.html
maintainer-clean-aminfo:
@list='$(INFO_DEPS)'; for i in $$list; do \
info-recursive install install-am install-binSCRIPTS \
install-data install-data-am install-data-recursive \
install-exec install-exec-am install-exec-recursive \
- install-info install-info-am install-info-recursive install-man \
- install-recursive install-strip installcheck installcheck-am \
- installdirs installdirs-am installdirs-recursive \
- maintainer-clean maintainer-clean-aminfo \
+ install-info install-info-am install-info-recursive \
+ install-man install-recursive install-strip installcheck \
+ installcheck-am installdirs installdirs-am \
+ installdirs-recursive maintainer-clean maintainer-clean-aminfo \
maintainer-clean-generic maintainer-clean-recursive \
maintainer-clean-vti mostlyclean mostlyclean-aminfo \
mostlyclean-generic mostlyclean-recursive mostlyclean-vti pdf \
use Automake::Condition qw/TRUE FALSE/;
use Automake::DisjConditions;
use Automake::Version;
+use Automake::Wrap 'makefile_wrap';
use File::Basename;
use Tie::RefHash;
use Carp;
&define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);
# The return value.
- my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
+ my $texiclean = makefile_wrap ("", "\t ", @texi_cleans);
push (@dist_targets, 'dist-info');
################################################################
-# Pretty-print something. HEAD is what should be printed at the
-# beginning of the first line, FILL is what should be printed at the
-# beginning of every subsequent line.
-sub pretty_print_internal
-{
- my ($head, $fill, @values) = @_;
-
- my $column = length ($head);
- my $result = $head;
-
- # Fill length is number of characters. However, each Tab
- # character counts for eight. So we count the number of Tabs and
- # multiply by 7.
- my $fill_length = length ($fill);
- $fill_length += 7 * ($fill =~ tr/\t/\t/d);
-
- foreach (@values)
- {
- # "71" because we also print a space.
- if ($column + length ($_) > 71)
- {
- $result .= " \\\n" . $fill;
- $column = $fill_length;
- }
- $result .= ' ' if $result =~ /\S\z/;
- $result .= $_;
- $column += length ($_) + 1;
- }
-
- $result .= "\n";
- return $result;
-}
-
# Pretty-print something and append to output_rules.
sub pretty_print_rule
{
- $output_rules .= &pretty_print_internal (@_);
+ $output_rules .= &makefile_wrap (@_);
}
if ($var_pretty{$var}{$cond} == VAR_PRETTY)
{
- # Suppress escaped new lines. &pretty_print_internal will
+ # Suppress escaped new lines. &makefile_wrap will
# add them back, maybe at other places.
$val =~ s/\\$//mg;
- $output_vars .= pretty_print_internal ("$str$var $equals",
- "$str\t",
- split (' ' , $val));
+ $output_vars .= makefile_wrap ("$str$var $equals",
+ "$str\t", split (' ' , $val));
}
else # VAR_ASIS
{
Location.pm \
Struct.pm \
Version.pm \
- XFile.pm
+ XFile.pm \
+ Wrap.pm
Location.pm \
Struct.pm \
Version.pm \
- XFile.pm
+ XFile.pm \
+ Wrap.pm
all: all-recursive
uninstall-info: uninstall-info-recursive
-.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
- clean-generic clean-recursive ctags ctags-recursive distclean \
- distclean-generic distclean-recursive distclean-tags distdir \
- dvi dvi-am dvi-recursive html html-am html-recursive info \
- info-am info-recursive install install-am install-data \
- install-data-am install-data-recursive install-dist_perllibDATA \
- install-exec install-exec-am install-exec-recursive \
- install-info install-info-am install-info-recursive install-man \
- install-recursive install-strip installcheck installcheck-am \
- installdirs installdirs-am installdirs-recursive \
- maintainer-clean maintainer-clean-generic \
- maintainer-clean-recursive mostlyclean mostlyclean-generic \
- mostlyclean-recursive pdf pdf-am pdf-recursive ps ps-am \
- ps-recursive tags tags-recursive uninstall uninstall-am \
- uninstall-dist_perllibDATA uninstall-info-am \
- uninstall-info-recursive uninstall-recursive
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
+ clean clean-generic clean-recursive ctags ctags-recursive \
+ distclean distclean-generic distclean-recursive distclean-tags \
+ distdir dvi dvi-am dvi-recursive html html-am html-recursive \
+ info info-am info-recursive install install-am install-data \
+ install-data-am install-data-recursive \
+ install-dist_perllibDATA install-exec install-exec-am \
+ install-exec-recursive install-info install-info-am \
+ install-info-recursive install-man install-recursive \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am installdirs-recursive maintainer-clean \
+ maintainer-clean-generic maintainer-clean-recursive \
+ mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
+ pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \
+ uninstall uninstall-am uninstall-dist_perllibDATA \
+ uninstall-info-am uninstall-info-recursive uninstall-recursive
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
--- /dev/null
+# Copyright (C) 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# 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 the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+package Automake::Wrap;
+
+use strict;
+
+require Exporter;
+use vars '@ISA', '@EXPORT_OK';
+@ISA = qw/Exporter/;
+@EXPORT_OK = qw/wrap makefile_wrap/;
+
+=head1 NAME
+
+Automake::Wrap - a paragraph formater
+
+=head1 SYNOPSIS
+
+ use Automake::Wrap 'wrap', 'makefile_wrap';
+
+ print wrap ($first_ident, $next_ident, $end_of_line, $max_length,
+ @values);
+
+ print makefile_wrap ("VARIABLE = ", " ", @values);
+
+=head1 DESCRIPTION
+
+This modules provide facility to format list of strings. It is
+comparable to Perl's L<Text::Wrap>, however we can't use L<Text::Wrap>
+because some versions will abort when some word to print exceed the
+maximum length allowed. (Ticket #17141, fixed in Perl 5.8.0.)
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+# tab_length ($TXT)
+# -----------------
+# Compute the length of TXT, counting tab characters as 8 characters.
+sub tab_length($)
+{
+ my ($txt) = @_;
+ my $len = length ($txt);
+ $len += 7 * ($txt =~ tr/\t/\t/d);
+ return $len;
+}
+
+=item C<wrap ($head, $fill, $eol, $max_len, @values)>
+
+Format C<@values> as a block of text that starts with C<$head>,
+followed by the strings in C<@values> separated by spaces or by
+C<"$eol\n$fill"> so that the lenght of each line never exceed
+C<$max_len>.
+
+The C<$max_len> contraint is ignored for C<@values> items which
+are too big to fit alone one a line.
+
+The constructed paragraph is C<"\n">-terminated.
+
+=cut
+
+sub wrap($$$$@)
+{
+ my ($head, $fill, $eol, $max_len, @values) = @_;
+
+ my $result = $head;
+ my $column = tab_length ($head);
+
+ my $fill_len = tab_length ($fill);
+ my $eol_len = tab_length ($eol);
+
+ my $not_first_word = 0;
+
+ foreach (@values)
+ {
+ my $len = tab_length ($_);
+
+ # See if the new variable fits on this line.
+ # (The + 1 is for the space we add in front of the value.).
+ if ($column + $len + $eol_len + 1 > $max_len
+ # Do not break before the first word if it does not fit on
+ # the next line anyway.
+ && ($not_first_word || $fill_len + $len + $eol_len + 1 <= $max_len))
+ {
+ # Start a new line.
+ $result .= "$eol\n" . $fill;
+ $column = $fill_len;
+ }
+ elsif ($not_first_word)
+ {
+ # Add a space only if result does not already end
+ # with a space.
+ $_ = " $_" if $result =~ /\S\z/;
+ ++$len;
+ }
+ $result .= $_;
+ $column += $len;
+ $not_first_word = 1;
+ }
+
+ $result .= "\n";
+ return $result;
+}
+
+
+=item C<makefile_wrap ($head, $fill, @values)>
+
+Format C<@values> in a way which is suitable for F<Makefile>s.
+This is comparable to C<wrap>, except C<$eol> is known to
+be C<" \\">, and the maximum length has been hardcoded to C<72>.
+
+A space is appended to C<$head> when this is not already
+the case.
+
+This can be used to format variable definitions or dependency lines.
+
+ makefile_wrap ('VARIABLE =', "\t", @values);
+ makefile_wrap ('rule:', "\t", @dependencies);
+
+=cut
+
+sub makefile_wrap ($$@)
+{
+ my ($head, $fill, @values) = @_;
+ if (@values)
+ {
+ $head .= ' ' if $head =~ /\S\z/;
+ return wrap $head, $fill, " \\", 72, @values;
+ }
+ return "$head\n";
+}
+
+
+1;
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
TESTS = \
Condition.pl \
DisjConditions.pl \
-Version.pl
+Version.pl \
+Wrap.pl
EXTRA_DIST = $(TESTS)
TESTS = \
Condition.pl \
DisjConditions.pl \
-Version.pl
+Version.pl \
+Wrap.pl
EXTRA_DIST = $(TESTS)
all: all-am
--- /dev/null
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake 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 the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+use Automake::Wrap 'wrap';
+
+my $failed = 0;
+
+sub test_wrap
+{
+ my ($in, $exp_out) = @_;
+
+ my $out = &wrap (@$in);
+ if ($out ne $exp_out)
+ {
+ print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
+ ++$failed;
+ }
+}
+
+my @tests = (
+ [["HEAD:", "NEXT:", "CONT", 13, "v" ,"a", "l", "ue", "s", "values"],
+"HEAD:v aCONT
+NEXT:l ueCONT
+NEXT:sCONT
+NEXT:values
+"],
+ [["rule: ", "\t", " \\", 20, "dep1" ,"dep2", "dep3", "dep4", "dep5",
+ "dep06", "dep07", "dep08"],
+"rule: dep1 dep2 \\
+\tdep3 dep4 \\
+\tdep5 dep06 \\
+\tdep07 \\
+\tdep08
+"],
+ [["big header:", "big continuation:", " END", 5, "diag1", "diag2", "diag3"],
+"big header:diag1 END
+big continuation:diag2 END
+big continuation:diag3
+"],
+ [["big header:", "cont: ", " END", 16, "word1", "word2"],
+"big header: END
+cont: word1 END
+cont: word2
+"]);
+
+
+test_wrap (@{$_}) foreach @tests;
+
+exit $failed;
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
uninstall-info: uninstall-info-recursive
-.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
- clean-generic clean-recursive ctags ctags-recursive distclean \
- distclean-generic distclean-recursive distclean-tags distdir \
- dvi dvi-am dvi-recursive html html-am html-recursive info \
- info-am info-recursive install install-am install-data \
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
+ clean clean-generic clean-recursive ctags ctags-recursive \
+ distclean distclean-generic distclean-recursive distclean-tags \
+ distdir dvi dvi-am dvi-recursive html html-am html-recursive \
+ info info-am info-recursive install install-am install-data \
install-data-am install-data-recursive \
install-dist_pkgvdataDATA install-dist_scriptDATA install-exec \
install-exec-am install-exec-recursive install-info \
install-info-am install-info-recursive install-man \
install-recursive install-strip installcheck installcheck-am \
installcheck-local installdirs installdirs-am \
- installdirs-recursive maintainer-clean maintainer-clean-generic \
- maintainer-clean-recursive mostlyclean mostlyclean-generic \
- mostlyclean-recursive pdf pdf-am pdf-recursive ps ps-am \
- ps-recursive tags tags-recursive uninstall uninstall-am \
- uninstall-dist_pkgvdataDATA uninstall-dist_scriptDATA \
- uninstall-info-am uninstall-info-recursive uninstall-recursive
+ installdirs-recursive maintainer-clean \
+ maintainer-clean-generic maintainer-clean-recursive \
+ mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
+ pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \
+ uninstall uninstall-am uninstall-dist_pkgvdataDATA \
+ uninstall-dist_scriptDATA uninstall-info-am \
+ uninstall-info-recursive uninstall-recursive
install-data-hook:
-@set UPDATED 17 May 2003
+@set UPDATED 21 May 2003
@set UPDATED-MONTH May 2003
@set EDITION 1.7a
@set VERSION 1.7a
-@set UPDATED 17 May 2003
+@set UPDATED 21 May 2003
@set UPDATED-MONTH May 2003
@set EDITION 1.7a
@set VERSION 1.7a