]> sourceware.org Git - automake.git/commitdiff
* automake.in ($IGNORE_PATTERN): Improve for multi-line matches.
authorAkim Demaille <akim@epita.fr>
Tue, 8 May 2001 13:12:58 +0000 (13:12 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 8 May 2001 13:12:58 +0000 (13:12 +0000)
($RULE_PATTERN): Use that from `&make_paragraphs'.
($MACRO_PATTERN): Just catch the name of a macro.
($BOGUS_MACRO_PATTERN): Remove.
($ASSIGNMENT_PATTERN): New.
(&file_contents_internal, &make_paragraphs): Adjust.
(&macro_define): Catch bad macro names.
(&cond_stack_endif): Better error message.
(&file_contents_internal): Don't remove backslashes in variable
values.
(&macro_define): Do it for `+=' user variables.
(&define_standard_variables): Use `undef' instead of a dummy
variable.
(&make_paragraph): Be sure not to chop the trail of hash only
lines: adjust the `##' regexp.
(&rule_define): Fix a bug: don't read $1 but $target.
* tests/condincl.test: Strengthen.

ChangeLog
automake.in
tests/condincl.test

index 66f11f9b92b9298ce19a18ad5b5c18ded18a9d89..c41fa933eee56f4f81aab671197c8287f26af6b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2001-05-08  Akim Demaille  <akim@epita.fr>
+
+       * automake.in ($IGNORE_PATTERN): Improve for multi-line matches.
+       ($RULE_PATTERN): Use that from `&make_paragraphs'.
+       ($MACRO_PATTERN): Just catch the name of a macro.
+       ($BOGUS_MACRO_PATTERN): Remove.
+       ($ASSIGNMENT_PATTERN): New.
+       (&file_contents_internal, &make_paragraphs): Adjust.
+       (&macro_define): Catch bad macro names.
+       (&cond_stack_endif): Better error message.
+       (&file_contents_internal): Don't remove backslashes in variable
+       values.
+       (&macro_define): Do it for `+=' user variables.
+       (&define_standard_variables): Use `undef' instead of a dummy
+       variable.
+       (&make_paragraph): Be sure not to chop the trail of hash only
+       lines: adjust the `##' regexp.
+       (&rule_define): Fix a bug: don't read $1 but $target.
+       * tests/condincl.test: Strengthen.
+
 2001-05-08  Akim Demaille  <akim@epita.fr>
 
        * automake.in (Language): Add attributes `Name' and `config_vars'.
index 4b9faaf9048b6b86f4d4b9ec6a1e37f25da14fad..1db97bb640993201dc56d424732d3bc3b2b7bcff 100755 (executable)
@@ -111,17 +111,21 @@ my $am_dir = "@datadir@/@PACKAGE@/am";
 my $pkgdata_dir = "@datadir@/@PACKAGE@";
 
 # String constants.
-my $IGNORE_PATTERN = '^##([^#].*)?$';
+my $IGNORE_PATTERN = '^##([^#\n].*)?\n';
 my $WHITE_PATTERN = '^\s*$';
 my $COMMENT_PATTERN = '^#';
 my $TARGET_PATTERN='[$a-zA-Z_.][-.a-zA-Z0-9_(){}/$]*';
-my $RULE_PATTERN = "^($TARGET_PATTERN) *:([^=].*|)\$";
+# A rule has three parts: a list of targets, a list of dependencies,
+# and optionally actions.
+my $RULE_PATTERN =
+  "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
+
 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)$';
 # Only recognize leading spaces, not leading tabs.  If we recognize
 # leading tabs here then we need to make the reader smarter, because
 # otherwise it will think rules like `foo=bar; \' are errors.
-my $MACRO_PATTERN = '^ *([A-Za-z0-9_@]+)\s*([:+]?)=\s*(.*)$';
-my $BOGUS_MACRO_PATTERN = '^ *([^ \t]*)\s*([:+]?)=\s*(.*)$';
+my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
+my $ASSIGNMENT_PATTERN = '^ *([^ \t]*)\s*([:+]?)=\s*(.*)$';
 # This pattern recognizes a Gnits version id and sets $1 if the
 # release is an alpha release.  We also allow a suffix which can be
 # used to extend the version number with a "fork" identifier.
@@ -2265,10 +2269,10 @@ sub check_canonical_spelling
     {
        foreach my $xt (@suffixes)
        {
-           &am_line_error ($name . $xt,
-                           "invalid variable `" . $name . $xt
-                           . "'; should be `" . $xname . $xt . "'")
-               if &variable_defined ($name . $xt);
+           &am_line_error ("$name$xt",
+                           "invalid variable `$name$xt'; "
+                           . "should be `$xname$xt'")
+               if &variable_defined ("$name$xt");
        }
     }
 
@@ -5634,7 +5638,7 @@ sub cond_stack_endif ($$$)
 
   if (! @cond_stack)
     {
-      &am_file_error ($where, "endif without if");
+      &am_file_error ($where, "endif without if: $negate$cond");
       return;
     }
 
@@ -5709,6 +5713,9 @@ sub macro_define ($$$$$$)
 {
   my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
 
+  am_file_error ($where, "bad macro name `$var'")
+    if $var !~ /$MACRO_PATTERN/o;
+
   $cond ||= 'TRUE';
 
   # An Automake variable must be consistently defined with the same
@@ -5732,6 +5739,11 @@ sub macro_define ($$$$$$)
     }
   $var_type{$var} = $type;
 
+  # When adding, since we rewrite, don't try to preserve the
+  # Automake continuation backslashes.
+  $value =~ s/\\$//mg
+    if $type eq '+' && $var_is_am;
+
   # Differentiate the first assignment (including with `+=').
   if ($type eq '+' && defined $var_value{$var}{$cond})
     {
@@ -6304,7 +6316,7 @@ sub variable_output ($@)
       my $val = $var_value{$var}{$cond};
       my $equals = $var_type{$var} eq ':' ? ':=' : '=';
       my $output_var = "$var $equals $val";
-      $output_var =~ s/^/&make_condition ($cond)/meg;
+      $output_var =~ s/^/make_condition ($cond)/meg;
       $output_vars .= $output_var . "\n";
     }
 }
@@ -6455,7 +6467,7 @@ sub rule_define ($$$$)
 
   # Check the rule for being a suffix rule. If so, store in a hash.
 
-  if ((my ($source_suffix, $object_suffix)) = ($1 =~ $SUFFIX_RULE_PATTERN))
+  if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
   {
     $suffix_rules{$source_suffix} = $object_suffix;
     print "Sources ending in .$source_suffix become .$object_suffix\n"
@@ -6534,7 +6546,6 @@ sub read_am_file
 
     my $saw_bk = 0;
     my $was_rule = 0;
-    my $is_ok_macro;
     my $last_var_name = '';
     my $last_var_type = '';
     my $last_var_value = '';
@@ -6622,13 +6633,9 @@ sub read_am_file
             $output_trailer .= $_;
            $comment = $spacing = '';
        }
-       elsif (($is_ok_macro = /$MACRO_PATTERN/o)
-              || /$BOGUS_MACRO_PATTERN/o)
+       elsif (/$ASSIGNMENT_PATTERN/o)
        {
-           # Error if bogus.
-           &am_line_error ($., "bad macro name `$last_var_name'")
-               if ! $is_ok_macro;
-
+           print STDERR;
            # Found a macro definition.
            $was_rule = 0;
            $last_var_name = $1;
@@ -6654,6 +6661,7 @@ sub read_am_file
                $var_comment{$last_var_name} .= "$comment";
                $comment = $spacing = '';
 
+               print STDERR "$last_var_name => $last_var_value\n";
                macro_define ($last_var_name, 0,
                              $last_var_type, $cond,
                              $last_var_value, $.)
@@ -6717,7 +6725,7 @@ sub read_am_file
 sub define_standard_variables
 {
     my $saved_output_vars = $output_vars;
-    my ($comments, $variables, $rules) =
+    my ($comments, undef, $rules) =
       &file_contents_internal (1, "$am_dir/header-vars.am",
                     ('BUILD'    => $seen_canonical == $AC_CANONICAL_SYSTEM,
                      'HOST'     => $seen_canonical,
@@ -6813,30 +6821,28 @@ sub make_paragraphs ($%)
     # Complete %transform with global options and make it a Perl
     # $command.
     my $command =
-      # We don't use IGNORE_PATTERN because it contains $ which
-      # prevents us from matching the end of line.
-      "s/##([^#\n].*)?\\n//gmo;"
-       . &transform (%transform,
-
-                     'CYGNUS'          => $cygnus_mode,
-                     'MAINTAINER-MODE'
-                     => $seen_maint_mode ? '@MAINTAINER_MODE_TRUE@' : '',
-
-                     'SHAR'        => $options{'dist-shar'} || 0,
-                     'BZIP2'       => $options{'dist-bzip2'} || 0,
-                     'ZIP'         => $options{'dist-zip'} || 0,
-                     'COMPRESS'    => $options{'dist-tarZ'} || 0,
-
-                     'INSTALL-INFO' => !$options{'no-installinfo'},
-                     'INSTALL-MAN'  => !$options{'no-installman'},
-                     'CK-NEWS'      => $options{'check-news'} || 0,
-
-                     'SUBDIRS'      => &variable_defined ('SUBDIRS'),
-                     'TOPDIR'       => backname ($relative_dir),
-                     'TOPDIR_P'     => $relative_dir eq '.',
-                     'CONFIGURE-AC' => $configure_ac,
-
-                     'LIBTOOL'      => defined $configure_vars{'LIBTOOL'})
+      "s/$IGNORE_PATTERN//gm;"
+       . transform (%transform,
+
+                    'CYGNUS'          => $cygnus_mode,
+                    'MAINTAINER-MODE'
+                    => $seen_maint_mode ? '@MAINTAINER_MODE_TRUE@' : '',
+
+                    'SHAR'        => $options{'dist-shar'} || 0,
+                    'BZIP2'       => $options{'dist-bzip2'} || 0,
+                    'ZIP'         => $options{'dist-zip'} || 0,
+                    'COMPRESS'    => $options{'dist-tarZ'} || 0,
+
+                    'INSTALL-INFO' => !$options{'no-installinfo'},
+                    'INSTALL-MAN'  => !$options{'no-installman'},
+                    'CK-NEWS'      => $options{'check-news'} || 0,
+
+                    'SUBDIRS'      => &variable_defined ('SUBDIRS'),
+                    'TOPDIR'       => backname ($relative_dir),
+                    'TOPDIR_P'     => $relative_dir eq '.',
+                    'CONFIGURE-AC' => $configure_ac,
+
+                    'LIBTOOL'      => defined $configure_vars{'LIBTOOL'})
          # We don't need more than two consecutive new-lines.
          . 's/\n{3,}/\n\n/g';
 
@@ -6857,12 +6863,6 @@ sub make_paragraphs ($%)
     $fc_file->close;
     my $content = $_;
 
-    # A rule has three parts: a list of targets, a list of dependencies,
-    # and optionally actions.
-    my $RULE_PATTERN =
-      "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
-
-
     # Split at unescaped new lines.
     my @lines = split (/(?<!\\)\n/, $content);
     my @res;
@@ -6910,11 +6910,6 @@ sub file_contents_internal ($%)
 {
     my ($is_am, $file, %transform) = @_;
 
-    # A rule has three parts: a list of targets, a list of dependencies,
-    # and optionally actions.
-    my $RULE_PATTERN =
-      "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
-
     my $result_vars = '';
     my $result_rules = '';
     my $comment = '';
@@ -7021,7 +7016,7 @@ sub file_contents_internal ($%)
                }
            }
        }
-       elsif (/$MACRO_PATTERN/mso)
+       elsif (/$ASSIGNMENT_PATTERN/mso)
        {
            my ($var, $type, $val) = ($1, $2, $3);
            &prog_error ("$file:$.: macro `$var' with trailing backslash")
index 5e95f64ab2a650433d05907a16b5cc8252ca8a64..0dfb451f105d636ab83d5f283ec94f75deea6380 100755 (executable)
@@ -22,4 +22,7 @@ END
 $AUTOMAKE || exit 1
 
 grep '^target' Makefile.in && exit 1
+
+grep '^@TOBE_TRUE@target' Makefile.in || exit 1
+
 exit 0
This page took 0.047362 seconds and 5 git commands to generate.