automake
[Top][All Lists]
Advanced

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

124-patterns.patch


From: Akim Demaille
Subject: 124-patterns.patch
Date: Fri, 13 Apr 2001 22:58:57 +0200

Still of closer of the merge between read_am_file and
file_contents_internal.

Yep, there is a `print STDERR;' below, but I realizd too late :(
Removed in the next patch.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * 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.

Index: automake.in
--- automake.in Tue, 10 Apr 2001 22:26:59 +0200 akim (am/f/39_automake.i 1.263 
755)
+++ automake.in Fri, 13 Apr 2001 01:53:48 +0200 akim (am/f/39_automake.i 1.263 
755)
@@ -102,17 +102,21 @@ sub finish ($)
 my $am_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 = '^ *(address@hidden)\s*([:+]?)=\s*(.*)$';
-my $BOGUS_MACRO_PATTERN = '^ *([^ \t]*)\s*([:+]?)=\s*(.*)$';
+my $MACRO_PATTERN = 'address@hidden';
+my $ASSIGNMENT_PATTERN = '^ *([^ \t]*)\s*([:+]?)=\s*(.*)$';
 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?';
 my $IF_PATTERN =          '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
 my $ELSE_PATTERN =   '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
@@ -2123,10 +2127,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");
        }
     }

@@ -5333,7 +5337,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;
     }

@@ -5408,6 +5412,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
@@ -5431,6 +5438,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})
     {
@@ -5989,7 +6001,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";
     }
 }
@@ -6140,7 +6152,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"
@@ -6219,7 +6231,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 = '';
@@ -6307,13 +6318,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;
@@ -6339,6 +6346,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, $.)
@@ -6402,7 +6410,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,
@@ -6498,30 +6506,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,
+      "s/$IGNORE_PATTERN//gm;"
+       . transform (%transform,

-                     'LIBTOOL'      => defined $configure_vars{'LIBTOOL'})
+                    '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';

@@ -6542,12 +6548,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;
@@ -6595,11 +6595,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 = '';
@@ -6707,7 +6702,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: tests/condincl.test
--- tests/condincl.test Sat, 13 Jan 2001 18:11:09 +0100 akim (am/e/1_condincl.t 
1.1 775)
+++ tests/condincl.test Fri, 13 Apr 2001 01:22:31 +0200 akim (am/e/1_condincl.t 
1.1 775)
@@ -22,4 +22,7 @@
 $AUTOMAKE || exit 1

 grep '^target' Makefile.in && exit 1
+
+grep 'address@hidden@target' Makefile.in || exit 1
+
 exit 0



reply via email to

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