]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* automake.in (read_am_file): Define variable containing long
authorAlexandre Duret-Lutz <adl@gnu.org>
Sat, 12 Feb 2005 11:42:25 +0000 (11:42 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sat, 12 Feb 2005 11:42:25 +0000 (11:42 +0000)
lines as VAR_PRETTY to work around tools with limited input width.
* tests/longlin2.test: New file.
* tests/Makefile.am (TESTS): Add it.
Report from Albert Chin.

ChangeLog
automake.in
tests/Makefile.am
tests/Makefile.in
tests/longlin2.test [new file with mode: 0755]

index 9ad3f2a3928c20242cbda5618b8e548a7583d9f5..ee44f88b8e43d5e0af950b8044a31a8e8cc0e86b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-02-12  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * automake.in (read_am_file): Define variable containing long
+       lines as VAR_PRETTY to work around tools with limited input width.
+       * tests/longlin2.test: New file.
+       * tests/Makefile.am (TESTS): Add it.
+       Report from Albert Chin.
+
 2005-02-09  Alexandre Duret-Lutz  <adl@gnu.org>
 
        Fix for PR automake/447:
index 7501d74a9053cb0f928ded2c0d330a624e792f83..103cf98087ad0adbd9ab0552c53e69411f37f4ff 100755 (executable)
@@ -5925,6 +5925,7 @@ sub read_am_file ($$)
     my $comment = '';
     my $blank = 0;
     my $saw_bk = 0;
+    my $var_look = VAR_ASIS;
 
     use constant IN_VAR_DEF => 0;
     use constant IN_RULE_DEF => 1;
@@ -6093,21 +6094,35 @@ sub read_am_file ($$)
            $last_var_value = $3;
            $last_where = $where->clone;
            if ($3 ne '' && substr ($3, -1) eq "\\")
-           {
+             {
                # We preserve the `\' because otherwise the long lines
                # that are generated will be truncated by broken
                # `sed's.
                $last_var_value = $3 . "\n";
-           }
+             }
+           # Normally we try to output variable definitions in the
+           # same format they were input.  However, POSIX compliant
+           # systems are not required to support lines longer than
+           # 2048 bytes (most notably, some sed implementation are
+           # limited to 4000 bytes, and sed is used by config.status
+           # to rewrite Makefile.in into Makefile).  Moreover nobody
+           # would really write such long lines by hand since it is
+           # hardly maintainable.  So if a line is longer that 1000
+           # bytes (an arbitrary limit), assume it has been
+           # automatically generated by some tools, and flatten the
+           # variable definition.  Otherwise, keep the variable as it
+           # as been input.
+           $var_look = VAR_PRETTY if length ($last_var_value) >= 1000;
 
            if (!/\\$/)
              {
                Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
                                            $last_var_type, $cond,
                                            $last_var_value, $comment,
-                                           $last_where, VAR_ASIS)
+                                           $last_where, $var_look)
                  if $cond != FALSE;
                $comment = $spacing = '';
+               $var_look = VAR_ASIS;
              }
        }
         elsif (/$INCLUDE_PATTERN/o)
index 80779b6f0afe4cadb64a4c44a6a7684493441166..14f3ab39def410d1ff42c4d91cb2981993aa22fd 100644 (file)
@@ -321,6 +321,7 @@ lisp6.test \
 listval.test \
 location.test \
 longline.test \
+longlin2.test \
 ltcond.test \
 ltcond2.test \
 ltconv.test \
index 837565d63ba0fdce3db0d324a9432464fa3c9934..2bc7a32a3f1e564f458a9c866788f9faa103916f 100644 (file)
@@ -441,6 +441,7 @@ lisp6.test \
 listval.test \
 location.test \
 longline.test \
+longlin2.test \
 ltcond.test \
 ltcond2.test \
 ltconv.test \
diff --git a/tests/longlin2.test b/tests/longlin2.test
new file mode 100755 (executable)
index 0000000..ec1eee2
--- /dev/null
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2005  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.
+
+# Long lines should be wrapped.
+# Report from Albert Chin.
+
+. ./defs || exit 1
+
+set -e
+
+n=1
+files=
+match=
+while test $n -le 100
+do
+  files="$files filename$n"
+  match="..........$match"
+  n=`expr $n + 1`
+done
+files2=`echo "$files" | sed s/filename/filenameb/g`
+
+cat >Makefile.am <<EOF
+FOO = $files $files2 \
+  grepme
+EOF
+
+# The `FOO = ...' line is 2293-byte long.  More than what a POSIX
+# conforment system is expected to support.
+
+# (It's OK if grep truncates the long line.)
+grep $match Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep $match Makefile.in && exit 1
+grep 'filenameb100 grepme' Makefile.in