From 66198a0174e3b7d53001af5402c336112d36a2b3 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 29 Sep 2002 14:51:25 +0000 Subject: [PATCH] * lib/Automake/Channels.pm (%_default_options): Add 'partial'. (_format_message): Rename as ... (_format_sub_message): ... this. (_format_message): New function, extracted from ... (_print_message): ... here. Honor the 'partial' option. ($partial): New variable. * automake.in (handle_ltlibraries, check_ambiguous_conditional, rule_define): Mark partial messages. --- ChangeLog | 9 +++++ automake.in | 13 ++++--- lib/Automake/Channels.pm | 98 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 97 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ec77b7..e4d8cf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2002-09-29 Alexandre Duret-Lutz + * lib/Automake/Channels.pm (%_default_options): Add 'partial'. + (_format_message): Rename as ... + (_format_sub_message): ... this. + (_format_message): New function, extracted from ... + (_print_message): ... here. Honor the 'partial' option. + ($partial): New variable. + * automake.in (handle_ltlibraries, check_ambiguous_conditional, + rule_define): Mark partial messages. + * automake.in (handle_ltlibraries): Record library locations in %liblocations, and print the previous declaration on error. * tests/libtool6.test: Check that the locations of the two diff --git a/automake.in b/automake.in index 64a2899..d8dda37 100755 --- a/automake.in +++ b/automake.in @@ -3372,7 +3372,7 @@ sub handle_ltlibraries 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 @@ -6144,7 +6144,7 @@ sub check_ambiguous_conditional ($$$) 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)); } @@ -7585,7 +7585,7 @@ sub rule_define ($$$$$) ## 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"); } @@ -7624,7 +7624,8 @@ sub rule_define ($$$$$) 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 (); @@ -7645,7 +7646,7 @@ sub rule_define ($$$$$) 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 (); @@ -7681,7 +7682,7 @@ sub rule_define ($$$$$) # 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 (); diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm index 5b15d2e..37201e8 100644 --- a/lib/Automake/Channels.pm +++ b/lib/Automake/Channels.pm @@ -193,6 +193,45 @@ A string to append to each message emitted through this channel. Die with a stack backtrace after displaying the message. +=item C 0> + +When set, indicates a partial message that should +be output along with the next message with C unset. +Several partial messages can be stacked this way. + +Duplicate filtering will apply to the I message resulting from +all I 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 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 messages is printed with the +first non-C message, most options of C messages will +be ignored. + =back =cut @@ -212,6 +251,7 @@ use vars qw (%_default_options %_global_duplicate_messages header => '', footer => '', backtrace => 0, + partial => 0, ); # Filled with output messages as keys, to detect duplicates. @@ -320,43 +360,67 @@ sub channel_type ($) 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. @@ -454,7 +518,7 @@ both print =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. -- 2.7.4