]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* bin/autom4te.in (&handle_output): Don't use `grep' with side
authorAkim Demaille <akim@epita.fr>
Fri, 10 Aug 2001 07:48:09 +0000 (07:48 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 10 Aug 2001 07:48:09 +0000 (07:48 +0000)
effects.
Suggested by Russ Allbery.

ChangeLog
bin/autom4te.in

index 458bba955f5944ce7262b926fe05222f1c09bb8f..9b36a2c40e13c491365ce51c4d8f2faa13eba9a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-10  Akim Demaille  <akim@epita.fr>
+
+       * bin/autom4te.in (&handle_output): Don't use `grep' with side
+       effects.
+       Suggested by Russ Allbery.
+
 2001-08-10  Ralf Corsepius  <corsepiu@faw.uni-ulm.de>
 
        * lib/autoconf/general.m4 (_AC_OUTPUT_SUBDIRS): Propagate the
index 5c1ffe0dd13e67fe5cc21b9fd4f9f13b303e368d..464edf5e7e260e4c86bd78192be652c0808cb3de 100644 (file)
@@ -552,26 +552,14 @@ sub handle_output ($$)
   verbose "creating $output";
 
   # Load the forbidden/allowed patterns.
-  #
-  # I'm having fun with grep and map, but it's not extremely safe here...
-  # First of all, I still don't understand why I can't use `map' for
-  # instance to get @PATTERNS: `chop' thinks it's in a scalar context
-  # and returns 1 instead of `$_' :(.
-  #
-  # A potential bad bug is that the grep for $forbidden and $allowed
-  # *do modify @PATTERNS!  So when $FORBIDDEN is computed, @PATTERNS
-  # still contains the forbidden patterns, but without the leading
-  # `forbid:'.  So if some use forbids `allow:FOO', @ALLOW will receive
-  # `FOO', which is _bad_.  But since `:' is not valid in macro names,
-  # this is science fiction.
-  #
-  # Still, if someone could teach me how to write this properly... --akim
   handle_traces ($req, "$tmp/patterns",
                 ('m4_pattern_forbid' => 'forbid:$1',
                  'm4_pattern_allow'  => 'allow:$1'));
-  my @patterns = grep { chop } new IO::File ("$tmp/patterns")->getlines;
-  my $forbidden = join ('|', grep { s/^forbid:// } @patterns) || "^\$";
-  my $allowed   = join ('|', grep { s/^allow:// }  @patterns) || "^\$";
+  my @patterns = new IO::File ("$tmp/patterns")->getlines;
+  chomp @patterns;
+  my $forbidden = join ('|', map { /^forbid:(.*)/ } @patterns) || "^\$";
+  my $allowed   = join ('|', map { /^allow:(.*)/  } @patterns) || "^\$";
+
   verbose "forbidden tokens: $forbidden";
   verbose "allowed   tokens: $allowed";