]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] refactor: make '&verbatim' polymorphic in its return value
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 30 Jul 2012 16:36:18 +0000 (18:36 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jul 2012 02:38:51 +0000 (04:38 +0200)
* automake.in (verbatim): If used in empty context, continue to act
as before, and append the read makefile fragment to '$output_verbatim'.
But if used in scalar or list context, return it instead.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
automake.in

index 4e6f02c94a417bcbb49da6ac8295a8c8874a9cf0..a17e073202e8a708d9b57d14006c955362f0c8ce 100644 (file)
@@ -5823,14 +5823,27 @@ sub almost_verbatim ($%)
 
 # verbatim ($NAME)
 # ----------------
-# Load a "$libdir/am/$NAME.am", strip any '##'-style comment, and append
-# the result to the '$output_verbatim' variable.  No extra parsing or
-# post-processing is done (i.e., recognition of rules declaration or of
-# make variables definitions).
+# Load a "$libdir/am/$NAME.am", stripping any '##'-style comment.  No
+# extra parsing or post-processing is done (i.e., recognition of rules
+# declaration or of make variables definitions).
+# If used in scalar or list context, return the read makefile fragment.
+# While if used in void context, append it to the '$output_verbatim'
+# variable.
 sub verbatim ($)
 {
   my $name = shift;
-  $output_verbatim .= slurp_makefile_fragment ("$libdir/am/$name.am");
+  my $text .= slurp_makefile_fragment ("$libdir/am/$name.am");
+  if (defined wantarray)
+    {
+      # Scalar or list context.
+      return $text;
+    }
+  else
+    {
+      # Void context
+      $output_verbatim .= $text;
+      return;
+    }
 }
 
 # @PARAGRAPHS