if (defined $instdirs{$lib} && $instdirs{$lib} ne $dir)
{
err ($where, "`$lib' is already going to be installed in "
- . "`$instdirs{$lib}'");
+ . "`$instdirs{$lib}'", partial => 1);
err ($liblocations{$lib}, "`$lib' previously declared here");
}
else
conditional_ambiguous_p ($var, $cond, keys %{$var_value{$var}});
if ($message)
{
- msg 'syntax', $where, "$message ...";
+ msg 'syntax', $where, "$message ...", partial => 1;
msg_var ('syntax', $var, "... `$var' previously defined here");
verb (macro_dump ($var));
}
## is legitimate. (This is phony.test.)
# msg ('syntax', $where,
- # "redefinition of `$target'$condmsg...");
+ # "redefinition of `$target'$condmsg...", partial => 1);
# msg_cond_target ('syntax', $cond, $target,
# "... `$target' previously defined here");
}
my $oldsource = $target_source{$target}{$cond};
return () if $source eq $oldsource;
- msg ('syntax', $where, "redefinition of `$target'$condmsg...");
+ msg ('syntax', $where, "redefinition of `$target'$condmsg...",
+ partial => 1);
msg_cond_target ('syntax', $cond, $target,
"... `$target' previously defined here");
return ();
if ($owner == TARGET_USER)
{
# For user rules, just diagnose the ambiguity.
- msg 'syntax', $where, "$message ...";
+ msg 'syntax', $where, "$message ...", partial => 1;
msg_cond_target ('syntax', $ambig_cond, $target,
"... `$target' previously defined here");
return ();
# Warn, because our workaround is meaningless in this case.
if (scalar @conds == 0)
{
- msg 'syntax', $where, "$message ...";
+ msg 'syntax', $where, "$message ...", partial => 1;
msg_cond_target ('syntax', $ambig_cond, $target,
"... `$target' previously defined here");
return ();
Die with a stack backtrace after displaying the message.
+=item C<partial =E<gt> 0>
+
+When set, indicates a partial message that should
+be output along with the next message with C<partial> unset.
+Several partial messages can be stacked this way.
+
+Duplicate filtering will apply to the I<global> message resulting from
+all I<partial> messages, using the options from the last (non-partial)
+message. Linking associated messages is the main reason to use this
+option.
+
+For instance the following messages
+
+ msg 'channel', 'foo:2', 'redefinition of A ...';
+ msg 'channel', 'foo:1', '... A previously defined here';
+ msg 'channel', 'foo:3', 'redefinition of A ...';
+ msg 'channel', 'foo:1', '... A previously defined here';
+
+will result in
+
+ foo:2: redefinition of A ...
+ foo:1: ... A previously defined here
+ foo:3: redefinition of A ...
+
+where the duplicate "I<... A previously defined here>" has been
+filtered out.
+
+Linking these messages using C<partial> as follows will prevent the
+fourth message to disappear.
+
+ msg 'channel', 'foo:2', 'redefinition of A ...', partial => 1;
+ msg 'channel', 'foo:1', '... A previously defined here';
+ msg 'channel', 'foo:3', 'redefinition of A ...', partial => 1;
+ msg 'channel', 'foo:1', '... A previously defined here';
+
+Note that because the stack of C<partial> messages is printed with the
+first non-C<partial> message, most options of C<partial> messages will
+be ignored.
+
=back
=cut
header => '',
footer => '',
backtrace => 0,
+ partial => 0,
);
# Filled with output messages as keys, to detect duplicates.
return '';
}
-# _format_message ($LEADER, $MESSAGE)
-# -----------------------------------
+# _format_sub_message ($LEADER, $MESSAGE)
+# ---------------------------------------
# Split $MESSAGE at new lines and add $LEADER to each line.
-sub _format_message ($$)
+sub _format_sub_message ($$)
{
my ($leader, $message) = @_;
return $leader . join ("\n" . $leader, split ("\n", $message)) . "\n";
}
-# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
-# ----------------------------------------------
-# Format the message, check duplicates, and print it.
-sub _print_message ($$%)
+# _format_message ($LOCATION, $MESSAGE, %OPTIONS)
+# -----------------------------------------------
+# Format the message. Return a string ready to print.
+sub _format_message ($$%)
{
my ($location, $message, %opts) = @_;
-
- return 0 if ($opts{'silent'});
-
- # Format the message.
my $msg = '';
if (ref $location)
{
# If $LOCATION is a reference, assume it's an instance of the
# Automake::Location class and display contexts.
my $loc = $location->get || $me;
- $msg = _format_message ("$loc: ",
- $opts{'header'} . $message . $opts{'footer'});
+ $msg = _format_sub_message ("$loc: ", $opts{'header'}
+ . $message . $opts{'footer'});
for my $pair ($location->get_contexts)
{
- $msg .= _format_message ($pair->[0] . ": ", $pair->[1]);
+ $msg .= _format_sub_message ($pair->[0] . ": ", $pair->[1]);
}
}
else
{
$location ||= $me;
- $msg = _format_message ("$location: ",
- $opts{'header'} . $message . $opts{'footer'});
+ $msg = _format_sub_message ("$location: ", $opts{'header'}
+ . $message . $opts{'footer'});
+ }
+ return $msg;
+}
+
+# Store partial messages here. (See the 'partial' option.)
+use vars qw ($partial);
+$partial = '';
+
+# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
+# ----------------------------------------------
+# Format the message, check duplicates, and print it.
+sub _print_message ($$%)
+{
+ my ($location, $message, %opts) = @_;
+
+ return 0 if ($opts{'silent'});
+
+ my $msg = _format_message ($location, $message, %opts);
+ if ($opts{'partial'})
+ {
+ # Incomplete message. Store, don't print.
+ $partial .= $msg;
+ return;
+ }
+ else
+ {
+ # Prefix with any partial message send so far.
+ $msg = $partial . $msg;
}
# Check for duplicate message if requested.
=cut
-use vars qw (@backlog %buffering);
+use vars qw (@backlog %buffering @chain);
# See buffer_messages() and flush_messages() below.
%buffering = (); # The map of channel types to buffer.