automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exit on error when whitespace follows trailing backslash


From: Peter Muir
Subject: Exit on error when whitespace follows trailing backslash
Date: Fri, 21 Mar 2003 22:28:04 -0500

PROBLEM

  $make
  Makefile:xxx: *** missing separator.
  Stop.
  $

I was editing a Makefile.am outside of the
Emacs makefile-mode. In a series of
continued lines, I had put a space after a
trailing backslash.

Now this might be a desired behaviour not to
warn or error on trailing space after
backslash, especially when Emacs
makefile-mode will not let one actually add
the space. The problem is that when
debugging the Makefile, automake
hides the problem by splitting up the two
fragments:

Makefile.am:
  foo = q \[:space:] 
  r

Makefile:318: *** missing separator.  Stop.

Makefile:
  ...
  target_alias = 
  foo = q \ 
  subdir = .
  ...
        uninstall-info-am

  r
  # Tell...
  # Other...
  .NOEXPORT:


SOLUTIONS

1. Leave it as it is. Of course it is not
   hard to find the problem so the current
   situation might be acceptable.

2. automake should warn.

3. automake should fail. I took this
   solution.



TEST CASE

I wrote a test case, syntax2.test, that
fails when an automake does not exit with an
error, when a single space follows a
trailing backslash.



MAKE CHECK

...
PASS: syntax.test
FAIL: syntax2.test
...
=====================================
1 of 422 tests failed
(28 tests were not run)
Please report to address@hidden
=====================================



PATCH

I added a function (instead of just a test)
because I did the test twice.


Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1365.2.37
diff -u -u -r1.1365.2.37 automake.in
--- automake.in 14 Mar 2003 21:47:25 -0000      1.1365.2.37
+++ automake.in 22 Mar 2003 03:22:18 -0000
@@ -7838,6 +7838,22 @@
     $var_comment{$var}{$cond} .= $comment;
 }
 
+# &check_line_for_error ($here,$line)
+# -----------------------
+# A blank following a backslash will be removed
+# by generating Makefile.in. Note that a '$'
+# can match the end of string or "\n".
+#  perl -e ' $_ = "\\\n";  /\\$/ && /\\\s+$/ && print "ok"'
+# See tests/syntax2.test.
+sub check_line_for_error ($$)
+{
+    my ($here,$line) = @_;
+    if (defined($line)) 
+    {
+        error $here, "white space following trailing backslash"
+         if ($line =~ /\\[^\S\n]+$/) && ! ($line =~ /$IGNORE_PATTERN/o);
+    }
+}
 
 # &read_am_file ($AMFILE)
 # -----------------------
@@ -7897,6 +7913,7 @@
            last;
        }
        $saw_bk = /\\$/ && ! /$IGNORE_PATTERN/o;
+       &check_line_for_error ("$amfile:$.", $_);
     }
 
     # We save the conditional stack on entry, and then check to make
@@ -8087,6 +8104,7 @@
        }
 
        $saw_bk = $new_saw_bk;
+       &check_line_for_error ($here, $_);
         $_ = $am_file->getline;
     }
 
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.443.2.23
diff -u -u -r1.443.2.23 Makefile.am
--- tests/Makefile.am   14 Mar 2003 21:55:19 -0000      1.443.2.23
+++ tests/Makefile.am   22 Mar 2003 03:22:20 -0000
@@ -403,6 +403,7 @@
 symlink2.test \
 symlink3.test \
 syntax.test \
+syntax2.test \
 tags.test \
 tagsub.test \
 target.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.576.2.36
diff -u -u -r1.576.2.36 Makefile.in
--- tests/Makefile.in   14 Mar 2003 21:55:19 -0000      1.576.2.36
+++ tests/Makefile.in   22 Mar 2003 03:22:20 -0000
@@ -497,6 +497,7 @@
 symlink2.test \
 symlink3.test \
 syntax.test \
+syntax2.test \
 tags.test \
 tagsub.test \
 target.test \
Index: tests/syntax2.test
===================================================================
RCS file: tests/syntax2.test
diff -N tests/syntax2.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/syntax2.test  21 Mar 2003 22:41:55 -0000      1.1.2.1
@@ -0,0 +1,34 @@
+# Copyright (C) 1998, 2001, 2002  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 autoconf; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test for error for bad syntax.
+# GNU make says 'Makefile.am:2: *** missing separator.  Stop.'
+
+
+. ./defs || exit 1
+
+cat > Makefile.am << 'END'
+foo = q \ 
+r
+
+END
+
+$ACLOCAL || exit 1
+$AUTOMAKE && exit 1
+exit 0




MAKE CHECK AFTER PATCH

--- automake.anoncvs.test       2003-03-21 21:14:01.000000000 -0500
+++ automake.anoncvs.patch.test 2003-03-21 22:03:55.000000000 -0500
@@ -428,7 +428,7 @@
 PASS: symlink2.test
 PASS: symlink3.test
 PASS: syntax.test
-FAIL: syntax2.test
+PASS: syntax2.test
 PASS: tags.test
 PASS: tagsub.test
 PASS: target.test
@@ -478,10 +478,9 @@
 PASS: yacc8.test
 PASS: yaccpp.test
 PASS: yaccvpath.test
-=====================================
-1 of 422 tests failed
+=======================================================
+All 422 tests behaved as expected (3 expected failures)
 (28 tests were not run)
-Please report to address@hidden
-=====================================
+=======================================================
 make[2]: Leaving directory `/home/iyhi/src/anonymous_cvs/automake/tests'
 make[1]: Leaving directory `/home/iyhi/src/anonymous_cvs/automake/tests'


-- 
Peter Muir




reply via email to

[Prev in Thread] Current Thread [Next in Thread]