From: Stefano Lattarini Date: Mon, 30 Jul 2012 16:36:18 +0000 (+0200) Subject: [ng] refactor: make '&verbatim' polymorphic in its return value X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c907a303d2f3844ee8b41346f7e3272572a54a4;p=thirdparty%2Fautomake.git [ng] refactor: make '&verbatim' polymorphic in its return value * 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 --- diff --git a/automake.in b/automake.in index 4e6f02c94..a17e07320 100644 --- a/automake.in +++ b/automake.in @@ -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