[Top][All Lists]

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


From: Akim Demaille
Subject: 125-better-file-contents.patch
Date: Fri, 13 Apr 2001 22:59:02 +0200

Still getting closer to what Tom doesn't want: the read_am_file
removal.  I would be lying if I pretended that this removal was easy:
pretty many weaknesses in file_contents weaknesses are uncovered by
the test suite when you replace read_am_file with file_contents.

But I'm very confident.

I should also confess that I now no longer understand very well why I
introduced &make_paragraphs, instead of working line by line.  More
precisely, I have problems with keeping line numbers sync'ed in error
messages.  I understand fairly well this is a good service to provide
to the user, but it's somewhat in opposition with the most (in my own
definition of the word) natural implementation of file_contents.

To be absolutely honest, there is one reason why I'd like to use
make_paragraph: make it understand there are paragraphs Automake
should not try to understand.  For instance, I am not very satisfied
with else.test which checks the error message provided by automake on:

        ifeq ("${APACHE_DIR_IS_SRC}","yes")
        SUBDIRS = java
        SUBDIRS = c java

The test is expecting automake to complain about an `else with an if'
(as ifeq is meaningless to automake, but else is caught).  But in a
perfect automake, we should have a means to tell it ``you just don't
understand what ifeq is, just consider this as an opaque paragraph you
don't understand''.

That's the original motivation for the paragraph concept: a means to
describe things automake cannot understand.

Sure the net result is that the novice will no longer be warned that
toying with SUBDIRS like this is not supported.  But that's a bias
introduced by the test itself; in the general philosophy where the
user is always right, and automake always wrong, the latter cannot
know what happens in such a paragraph.

I am not imagining weirdy situations: I know for sure there are some
GNU Make paragraphs Jim uses in his Fetish projects, which are
rejected by automake.

Of course, an alternative would be to have

        ifeq ("${APACHE_DIR_IS_SRC}","yes")
        SUBDIRS = java
        SUBDIRS = c java
        end verbatim

but I don't know what people would like most...

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * (&file_contents_internal): Apply the @cond_stack to
        the rules and assignments.
        Don't rely on `$.' as it's biased by &make_paragraphs.
        Don't remove backslashes in variable values.

--- Fri, 13 Apr 2001 02:01:05 +0200 akim (am/f/39_automake.i 1.264 
+++ Fri, 13 Apr 2001 22:36:07 +0200 akim (am/f/39_automake.i 1.264 
@@ -6608,7 +6608,6 @@ sub file_contents_internal ($%)

     foreach (make_paragraphs ($file, %transform))
         # Sanity checks.
        &am_file_error ($file, "blank line following trailing backslash:\n$_")
          if /\\$/;
@@ -6694,18 +6693,20 @@ sub file_contents_internal ($%)
                  if (!defined $targets{$targets}
                      && $cond ne 'FALSE')
+                     $paragraph =~ s/^/make_condition (@cond_stack)/gme;
                      $result_rules .= "$spacing$comment$paragraph\n";
-                     rule_define ($targets, $is_am, $cond, $.);
+                     rule_define ($targets, $is_am, $cond, $file);
                  $comment = $spacing = '';
        elsif (/$ASSIGNMENT_PATTERN/mso)
            my ($var, $type, $val) = ($1, $2, $3);
-           &prog_error ("$file:$.: macro `$var' with trailing backslash")
+           &am_file_error ($file, "macro `$var' with trailing backslash")
              if /\\$/;;

            # Accumulating variables must not be output.
@@ -6713,9 +6714,7 @@ sub file_contents_internal ($%)
              if (!defined $var_comment{$var}
                  || substr ($var_comment{$var}, -1) ne "\n");
            $var_comment{$var} .= "$comment";
-           # Strip the continuation backslashes.
-           $val =~ s/\\$//mg;
-           macro_define ($var, $is_am, $type, $cond, $val, $.)
+           macro_define ($var, $is_am, $type, $cond, $val, $file)
              if $cond ne 'FALSE';
            push (@var_list, $var);

@@ -6734,6 +6733,7 @@ sub file_contents_internal ($%)
            # or some part of a rule cut by an if/endif.
            if ($cond ne 'FALSE')
+               s/^/make_condition (@cond_stack)/gme;
                $result_rules .= "$spacing$comment$_\n";
            $comment = $spacing = '';

reply via email to

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