File Coverage

File:/tmp/automake/lib/Automake/Channels.pm
Coverage:81.8%

linestmtbrancondsubpodtimecode
1# Copyright (C) 2002, 2004, 2006, 2008, 2010 Free Software Foundation,
2# Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17###############################################################
18# The main copy of this file is in Automake's git repository. #
19# Updates should be sent to automake-patches@gnu.org. #
20###############################################################
21
22package Automake::Channels;
23
24 - 70
=head1 NAME

Automake::Channels - support functions for error and warning management

=head1 SYNOPSIS

  use Automake::Channels;

  # Register a channel to output warnings about unused variables.
  register_channel 'unused', type => 'warning';

  # Register a channel for system errors.
  register_channel 'system', type => 'error', exit_code => 4;

  # Output a message on channel 'unused'.
  msg 'unused', "$file:$line", "unused variable `$var'";

  # Make the 'unused' channel silent.
  setup_channel 'unused', silent => 1;

  # Turn on all channels of type 'warning'.
  setup_channel_type 'warning', silent => 0;

  # Redirect all channels to push messages on a Thread::Queue using
  # the specified serialization key.
  setup_channel_queue $queue, $key;

  # Output a message pending in a Thread::Queue.
  pop_channel_queue $queue;

  # Treat all warnings as errors.
  setup_warnings_as_errors 1, $where;
  # Old way of doing the same:
  $warnings_are_errors = 1;

  # Exit with the greatest exit code encountered so far.
  exit $exit_code;

=head1 DESCRIPTION

This perl module provides support functions for handling diagnostic
channels in programs.  Channels can be registered to convey fatal,
error, warning, or debug messages.  Each channel has various options
(e.g. is the channel silent, should duplicate messages be removed,
etc.) that can also be overridden on a per-message basis.

=cut
71
72
2212
2212
2212
42940
6740
2914
use 5.005;
73
2212
2212
2212
7437
2188
6477
use strict;
74
2212
2212
2212
7492
2048
5036
use Exporter;
75
2212
2212
2212
8387
4548
9617
use Carp;
76
2212
2212
2212
8181
2366
5178
use File::Basename;
77
78
2212
2212
2212
8086
2268
6340
use vars qw (@ISA @EXPORT %channels $me);
79
80@ISA = qw (Exporter);
81@EXPORT = qw ($exit_code $warnings_are_errors
82              &reset_local_duplicates &reset_global_duplicates
83              &register_channel &msg &exists_channel &channel_type
84              &setup_channel &setup_channel_type
85              &setup_warnings_as_errors
86              &dup_channel_setup &drop_channel_setup
87              &buffer_messages &flush_messages
88              &setup_channel_queue &pop_channel_queue
89              US_GLOBAL US_LOCAL
90              UP_NONE UP_TEXT UP_LOC_TEXT);
91
92$me = basename $0;
93
94 - 103
=head2 Global Variables

=over 4

=item C<$exit_code>

The greatest exit code seen so far. C<$exit_code> is updated from
the C<exit_code> options of C<fatal> and C<error> channels.

=cut
104
105
2212
2212
2212
10189
2579
8366
use vars qw ($exit_code);
106$exit_code = 0;
107
108 - 113
=item C<$warnings_are_errors>

Set this variable to 1 if warning messages should be treated as
errors (i.e. if they should update C<$exit_code>).

=cut
114
115
2212
2212
2212
8247
2162
7667
use vars qw ($warnings_are_errors);
116
117$warnings_are_errors = 0;
118my $werror_location = '';
119
120=back
121
122 - 136
=head2 Constants

=over 4

=item C<UP_NONE>, C<UP_TEXT>, C<UP_LOC_TEXT>

Possible values for the C<uniq_part> options.  This selects the part
of the message that should be considered when filtering out duplicates.
If C<UP_LOC_TEXT> is used, the location and the explanation message
are used for filtering.  If C<UP_TEXT> is used, only the explanation
message is used (so the same message will be filtered out if it appears
at different locations).  C<UP_NONE> means that duplicate messages
should be output.

=cut
137
138
2212
2212
2212
8947
3280
14848
use constant UP_NONE => 0;
139
2212
2212
2212
9504
2257
5133
use constant UP_TEXT => 1;
140
2212
2212
2212
9217
2550
5202
use constant UP_LOC_TEXT => 2;
141
142 - 151
=item C<US_LOCAL>, C<US_GLOBAL>

Possible values for the C<uniq_scope> options.
Use C<US_GLOBAL> for error messages that should be printed only
once during the execution of the program, C<US_LOCAL> for message that
should be printed only once per file.  (Actually, C<Channels> does not
do this now when files are changed, it relies on you calling
C<reset_local_duplicates> when this happens.)

=cut
152
153# possible values for uniq_scope
154
2212
2212
2212
7995
2101
6321
use constant US_LOCAL => 0;
155
2212
2212
2212
7873
2056
5029
use constant US_GLOBAL => 1;
156
157=back
158
159 - 266
=head2 Options

Channels accept the options described below.  These options can be
passed as a hash to the C<register_channel>, C<setup_channel>, and C<msg>
functions.  The possible keys, with their default value are:

=over

=item C<type =E<gt> 'warning'>

The type of the channel.  One of C<'debug'>, C<'warning'>, C<'error'>, or
C<'fatal'>.  Fatal messages abort the program when they are output.
Error messages update the exit status.  Debug and warning messages are
harmless, except that warnings are treated as errors if
C<$warnings_are_errors> is set.

=item C<exit_code =E<gt> 1>

The value to update C<$exit_code> with when a fatal or error message
is emitted.  C<$exit_code> is also updated for warnings output
when C<$warnings_are_errors> is set.

=item C<file =E<gt> \*STDERR>

The file where the error should be output.

=item C<silent =E<gt> 0>

Whether the channel should be silent.  Use this do disable a
category of warning, for instance.

=item C<ordered =E<gt> 1>

Whether, with multi-threaded execution, the message should be queued
for ordered output.

=item C<uniq_part =E<gt> UP_LOC_TEXT>

The part of the message subject to duplicate filtering.  See the
documentation for the C<UP_NONE>, C<UP_TEXT>, and C<UP_LOC_TEXT>
constants above.

C<uniq_part> can also be set to an arbitrary string that will be used
instead of the message when considering duplicates.

=item C<uniq_scope =E<gt> US_LOCAL>

The scope of duplicate filtering.  See the documentation for the
C<US_LOCAL>, and C<US_GLOBAL> constants above.

=item C<header =E<gt> ''>

A string to prepend to each message emitted through this channel.
With partial messages, only the first part will have C<header>
prepended.

=item C<footer =E<gt> ''>

A string to append to each message emitted through this channel.
With partial messages, only the final part will have C<footer>
appended.

=item C<backtrace =E<gt> 0>

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
267
268
2212
6995
use vars qw (%_default_options %_global_duplicate_messages
269
2212
2212
8062
2359
             %_local_duplicate_messages);
270
271# Default options for a channel.
272%_default_options =
273  (
274   type => 'warning',
275   exit_code => 1,
276   file => \*STDERR,
277   silent => 0,
278   ordered => 1,
279   queue => 0,
280   queue_key => undef,
281   uniq_scope => US_LOCAL,
282   uniq_part => UP_LOC_TEXT,
283   header => '',
284   footer => '',
285   backtrace => 0,
286   partial => 0,
287   );
288
289# Filled with output messages as keys, to detect duplicates.
290# The value associated with each key is the number of occurrences
291# filtered out.
292%_local_duplicate_messages = ();
293%_global_duplicate_messages = ();
294
295sub _reset_duplicates (\%)
296{
297
1322
2866
  my ($ref) = @_;
298
1322
2159
  my $dup = 0;
299
1322
5828
  foreach my $k (keys %$ref)
300    {
301
246
663
      $dup += $ref->{$k};
302    }
303
1322
3111
  %$ref = ();
304
1322
3322
  return $dup;
305}
306
307
308 - 317
=head2 Functions

=over 4

=item C<reset_local_duplicates ()>

Reset local duplicate messages (see C<US_LOCAL>), and
return the number of messages that have been filtered out.

=cut
318
319sub reset_local_duplicates ()
320{
321
1322
1
6641
  return _reset_duplicates %_local_duplicate_messages;
322}
323
324 - 329
=item C<reset_global_duplicates ()>

Reset local duplicate messages (see C<US_GLOBAL>), and
return the number of messages that have been filtered out.

=cut
330
331sub reset_global_duplicates ()
332{
333
0
1
0
  return _reset_duplicates %_global_duplicate_messages;
334}
335
336sub _merge_options (\%%)
337{
338
395611
675823
  my ($hash, %options) = @_;
339
395611
379038
  local $_;
340
341
395611
843578
  foreach (keys %options)
342    {
343
120826
205568
      if (exists $hash->{$_})
344        {
345
120826
265254
          $hash->{$_} = $options{$_}
346        }
347      else
348        {
349
0
0
          confess "unknown option `$_'";
350        }
351    }
352
395611
1131473
  if ($hash->{'ordered'})
353    {
354
73142
161709
      confess "fatal messages cannot be ordered"
355        if $hash->{'type'} eq 'fatal';
356
73142
243157
      confess "backtrace cannot be output on ordered messages"
357        if $hash->{'backtrace'};
358    }
359}
360
361 - 366
=item C<register_channel ($name, [%options])>

Declare channel C<$name>, and override the default options
with those listed in C<%options>.

=cut
367
368sub register_channel ($;%)
369{
370
33180
1
82297
  my ($name, %options) = @_;
371
33180
173677
  my %channel_opts = %_default_options;
372
33180
93421
  _merge_options %channel_opts, %options;
373
33180
100433
  $channels{$name} = \%channel_opts;
374}
375
376 - 380
=item C<exists_channel ($name)>

Returns true iff channel C<$name> has been registered.

=cut
381
382sub exists_channel ($)
383{
384
147
1
348
  my ($name) = @_;
385
147
1251
  return exists $channels{$name};
386}
387
388 - 393
=item C<channel_type ($name)>

Returns the type of channel C<$name> if it has been registered.
Returns the empty string otherwise.

=cut
394
395sub channel_type ($)
396{
397
147
1
418
  my ($name) = @_;
398
147
440
  return $channels{$name}{'type'} if exists_channel $name;
399
2
8
  return '';
400}
401
402# _format_sub_message ($LEADER, $MESSAGE)
403# ---------------------------------------
404# Split $MESSAGE at new lines and add $LEADER to each line.
405sub _format_sub_message ($$)
406{
407
1201
3240
  my ($leader, $message) = @_;
408
1201
6432
  return $leader . join ("\n" . $leader, split ("\n", $message)) . "\n";
409}
410
411# Store partial messages here. (See the 'partial' option.)
412
2212
2212
2212
9672
2551
7162
use vars qw ($partial);
413$partial = '';
414
415# _format_message ($LOCATION, $MESSAGE, %OPTIONS)
416# -----------------------------------------------
417# Format the message. Return a string ready to print.
418sub _format_message ($$%)
419{
420
1170
5640
  my ($location, $message, %opts) = @_;
421
1170
6324
  my $msg = ($partial eq '' ? $opts{'header'} : '') . $message
422            . ($opts{'partial'} ? '' : $opts{'footer'});
423
1170
2781
  if (ref $location)
424    {
425      # If $LOCATION is a reference, assume it's an instance of the
426      # Automake::Location class and display contexts.
427
408
1217
      my $loc = $location->get || $me;
428
408
1489
      $msg = _format_sub_message ("$loc: ", $msg);
429
408
1433
      for my $pair ($location->get_contexts)
430        {
431
31
91
          $msg .= _format_sub_message ($pair->[0] . ": ", $pair->[1]);
432        }
433    }
434  else
435    {
436
762
1865
      $location ||= $me;
437
762
2867
      $msg = _format_sub_message ("$location: ", $msg);
438    }
439
1170
4108
  return $msg;
440}
441
442# _enqueue ($QUEUE, $KEY, $UNIQ_SCOPE, $TO_FILTER, $MSG, $FILE)
443# -------------------------------------------------------------
444# Push message on a queue, to be processed by another thread.
445sub _enqueue ($$$$$$)
446{
447
0
0
  my ($queue, $key, $uniq_scope, $to_filter, $msg, $file) = @_;
448
0
0
  $queue->enqueue ($key, $msg, $to_filter, $uniq_scope);
449
0
0
  confess "message queuing works only for STDERR"
450    if $file ne \*STDERR;
451}
452
453# _dequeue ($QUEUE)
454# -----------------
455# Pop a message from a queue, and print, similarly to how
456# _print_message would do it. Return 0 if the queue is
457# empty. Note that the key has already been dequeued.
458sub _dequeue ($)
459{
460
0
0
  my ($queue) = @_;
461
0
0
  my $msg = $queue->dequeue || return 0;
462
0
0
  my $to_filter = $queue->dequeue;
463
0
0
  my $uniq_scope = $queue->dequeue;
464
0
0
  my $file = \*STDERR;
465
466
0
0
  if ($to_filter ne '')
467    {
468      # Do we want local or global uniqueness?
469
0
0
      my $dups;
470
0
0
      if ($uniq_scope == US_LOCAL)
471        {
472
0
0
          $dups = \%_local_duplicate_messages;
473        }
474      elsif ($uniq_scope == US_GLOBAL)
475        {
476
0
0
          $dups = \%_global_duplicate_messages;
477        }
478      else
479        {
480
0
0
          confess "unknown value for uniq_scope: " . $uniq_scope;
481        }
482
483      # Update the hash of messages.
484
0
0
      if (exists $dups->{$to_filter})
485        {
486
0
0
          ++$dups->{$to_filter};
487
0
0
          return 1;
488        }
489      else
490        {
491
0
0
          $dups->{$to_filter} = 0;
492        }
493    }
494
0
0
  print $file $msg;
495
0
0
  return 1;
496}
497
498
499# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
500# ----------------------------------------------
501# Format the message, check duplicates, and print it.
502sub _print_message ($$%)
503{
504
312808
1238570
  my ($location, $message, %opts) = @_;
505
506
312808
1912058
  return 0 if ($opts{'silent'});
507
508
1170
5698
  my $msg = _format_message ($location, $message, %opts);
509
1170
3660
  if ($opts{'partial'})
510    {
511      # Incomplete message. Store, don't print.
512
54
120
      $partial .= $msg;
513
54
299
      return;
514    }
515  else
516    {
517      # Prefix with any partial message send so far.
518
1116
1883
      $msg = $partial . $msg;
519
1116
2448
      $partial = '';
520    }
521
522
1116
5452
  msg ('note', $werror_location, 'warnings are treated as errors',
523       uniq_scope => US_GLOBAL)
524    if ($opts{'type'} eq 'warning' && $warnings_are_errors);
525
526  # Check for duplicate message if requested.
527
1116
1326
  my $to_filter;
528
1116
3968
  if ($opts{'uniq_part'} ne UP_NONE)
529    {
530      # Which part of the error should we match?
531
897
4383
      if ($opts{'uniq_part'} eq UP_TEXT)
532        {
533
0
0
          $to_filter = $message;
534        }
535      elsif ($opts{'uniq_part'} eq UP_LOC_TEXT)
536        {
537
895
1396
          $to_filter = $msg;
538        }
539      else
540        {
541
2
4
          $to_filter = $opts{'uniq_part'};
542        }
543
544      # Do we want local or global uniqueness?
545
897
1018
      my $dups;
546
897
2774
      if ($opts{'uniq_scope'} == US_LOCAL)
547        {
548
634
1383
          $dups = \%_local_duplicate_messages;
549        }
550      elsif ($opts{'uniq_scope'} == US_GLOBAL)
551        {
552
263
475
          $dups = \%_global_duplicate_messages;
553        }
554      else
555        {
556
0
0
          confess "unknown value for uniq_scope: " . $opts{'uniq_scope'};
557        }
558
559      # Update the hash of messages.
560
897
2771
      if (exists $dups->{$to_filter})
561        {
562
114
332
          ++$dups->{$to_filter};
563
114
671
          return 0;
564        }
565      else
566        {
567
783
2594
          $dups->{$to_filter} = 0;
568        }
569    }
570
1002
1767
  my $file = $opts{'file'};
571
1002
6668
  if ($opts{'ordered'} && $opts{'queue'})
572    {
573
0
0
      _enqueue ($opts{'queue'}, $opts{'queue_key'}, $opts{'uniq_scope'},
574                $to_filter, $msg, $file);
575    }
576  else
577    {
578
1002
665163
      print $file $msg;
579    }
580
1002
4907
  return 1;
581}
582
583 - 626
=item C<msg ($channel, $location, $message, [%options])>

Emit a message on C<$channel>, overriding some options of the channel with
those specified in C<%options>.  Obviously C<$channel> must have been
registered with C<register_channel>.

C<$message> is the text of the message, and C<$location> is a location
associated to the message.

For instance to complain about some unused variable C<mumble>
declared at line 10 in F<foo.c>, one could do:

  msg 'unused', 'foo.c:10', "unused variable `mumble'";

If channel C<unused> is not silent (and if this message is not a duplicate),
the following would be output:

  foo.c:10: unused variable `mumble'

C<$location> can also be an instance of C<Automake::Location>.  In this
case, the stack of contexts will be displayed in addition.

If C<$message> contains newline characters, C<$location> is prepended
to each line.  For instance,

  msg 'error', 'somewhere', "1st line\n2nd line";

becomes

  somewhere: 1st line
  somewhere: 2nd line

If C<$location> is an empty string, it is replaced by the name of the
program.  Actually, if you don't use C<%options>, you can even
elide the empty C<$location>.  Thus

  msg 'fatal', '', 'fatal error';
  msg 'fatal', 'fatal error';

both print

  progname: fatal error

=cut
627
628
629
2212
2212
2212
9738
3495
8500
use vars qw (@backlog %buffering);
630
631# See buffer_messages() and flush_messages() below.
632%buffering = (); # The map of channel types to buffer.
633@backlog = (); # The buffer of messages.
634
635sub msg ($$;$%)
636{
637
312915
1
595071
  my ($channel, $location, $message, %options) = @_;
638
639
312915
575871
  if (! defined $message)
640    {
641
62
103
      $message = $location;
642
62
96
      $location = '';
643    }
644
645
312915
640305
  confess "unknown channel $channel" unless exists $channels{$channel};
646
647
312915
312915
305854
1763590
  my %opts = %{$channels{$channel}};
648
312915
888064
  _merge_options (%opts, %options);
649
650
312915
684513
  if (exists $buffering{$opts{'type'}})
651    {
652
107
369
      push @backlog, [$channel, $location->clone, $message, %options];
653
107
437
      return;
654    }
655
656  # Print the message if needed.
657
312808
918402
  if (_print_message ($location, $message, %opts))
658    {
659      # Adjust exit status.
660
1002
13254
      if ($opts{'type'} eq 'error'
661          || $opts{'type'} eq 'fatal'
662          || ($opts{'type'} eq 'warning' && $warnings_are_errors))
663        {
664
383
1462
          my $es = $opts{'exit_code'};
665
383
1482
          $exit_code = $es if $es > $exit_code;
666        }
667
668      # Die on fatal messages.
669
1002
2488
      confess if $opts{'backtrace'};
670
994
7014
      if ($opts{'type'} eq 'fatal')
671        {
672          # flush messages explicitly here, needed in worker threads.
673
35
411
          STDERR->flush;
674
35
83
          exit $exit_code;
675        }
676    }
677}
678
679
680 - 684
=item C<setup_channel ($channel, %options)>

Override the options of C<$channel> with those specified by C<%options>.

=cut
685
686sub setup_channel ($%)
687{
688
49516
1
103077
  my ($name, %opts) = @_;
689
49516
100858
  confess "unknown channel $name" unless exists $channels{$name};
690
49516
49516
50941
128268
  _merge_options %{$channels{$name}}, %opts;
691}
692
693 - 698
=item C<setup_channel_type ($type, %options)>

Override the options of any channel of type C<$type>
with those specified by C<%options>.

=cut
699
700sub setup_channel_type ($%)
701{
702
7749
1
34936
  my ($type, %opts) = @_;
703
7749
30894
  foreach my $channel (keys %channels)
704    {
705
116235
342522
      setup_channel $channel, %opts
706        if $channels{$channel}{'type'} eq $type;
707    }
708}
709
710 - 715
=item C<setup_warnings_as_errors ($enable, $where)>

Set this variable to 1 if warning messages should be treated as
errors (i.e. if they should update C<$exit_code>).

=cut
716
717sub setup_warnings_as_errors ($$)
718{
719
2137
1
5647
  my ($enable, $where) = @_;
720
2137
3976
  $warnings_are_errors = $enable;
721
2137
5522
  $werror_location = $where;
722}
723
724 - 737
=item C<dup_channel_setup ()>, C<drop_channel_setup ()>

Sometimes it is necessary to make temporary modifications to channels.
For instance one may want to disable a warning while processing a
particular file, and then restore the initial setup.  These two
functions make it easy: C<dup_channel_setup ()> saves a copy of the
current configuration for later restoration by
C<drop_channel_setup ()>.

You can think of this as a stack of configurations whose first entry
is the active one.  C<dup_channel_setup ()> duplicates the first
entry, while C<drop_channel_setup ()> just deletes it.

=cut
738
739
2212
2212
2212
9568
3007
8847
use vars qw (@_saved_channels @_saved_werrors @_saved_werror_location);
740@_saved_channels = ();
741@_saved_werrors = ();
742@_saved_werror_location = ();
743
744sub dup_channel_setup ()
745{
746
1322
1
2035
  my %channels_copy;
747
1322
15273
  foreach my $k1 (keys %channels)
748    {
749
19830
19830
19540
146560
      $channels_copy{$k1} = {%{$channels{$k1}}};
750    }
751
1322
4886
  push @_saved_channels, \%channels_copy;
752
1322
3368
  push @_saved_werrors, $warnings_are_errors;
753
1322
4107
  push @_saved_werror_location, $werror_location;
754}
755
756sub drop_channel_setup ()
757{
758
1321
1
4117
  my $saved = pop @_saved_channels;
759
1321
49859
  %channels = %$saved;
760
1321
7216
  $warnings_are_errors = pop @_saved_werrors;
761
1321
10746
  $werror_location = pop @_saved_werror_location;
762}
763
764 - 784
=item C<buffer_messages (@types)>, C<flush_messages ()>

By default, when C<msg> is called, messages are processed immediately.

Sometimes it is necessary to delay the output of messages.
For instance you might want to make diagnostics before
channels have been completely configured.

After C<buffer_messages(@types)> has been called, messages sent with
C<msg> to a channel whose type is listed in C<@types> will be stored in a
list for later processing.

This backlog of messages is processed when C<flush_messages> is
called, with the current channel options (not the options in effect,
at the time of C<msg>).  So for instance, if some channel was silenced
in the meantime, messages to this channel will not be printed.

C<flush_messages> cancels the effect of C<buffer_messages>.  Following
calls to C<msg> are processed immediately as usual.

=cut
785
786sub buffer_messages (@)
787{
788
1322
1
3780
  foreach my $type (@_)
789    {
790
1322
6144
      $buffering{$type} = 1;
791    }
792}
793
794sub flush_messages ()
795{
796
1321
1
3628
  %buffering = ();
797
1321
4728
  foreach my $args (@backlog)
798    {
799
107
218
      &msg (@$args);
800    }
801
1321
3403
  @backlog = ();
802}
803
804 - 809
=item C<setup_channel_queue ($queue, $key)>

Set the queue to fill for each channel that is ordered,
and the key to use for serialization.

=cut
810sub setup_channel_queue ($$)
811{
812
0
1
  my ($queue, $key) = @_;
813
0
  foreach my $channel (keys %channels)
814    {
815
0
      setup_channel $channel, queue => $queue, queue_key => $key
816        if $channels{$channel}{'ordered'};
817    }
818}
819
820 - 824
=item C<pop_channel_queue ($queue)>

pop a message off the $queue; the key has already been popped.

=cut
825sub pop_channel_queue ($)
826{
827
0
1
  my ($queue) = @_;
828
0
  return _dequeue ($queue);
829}
830
831=back
832
833 - 841
=head1 SEE ALSO

L<Automake::Location>

=head1 HISTORY

Written by Alexandre Duret-Lutz E<lt>F<adl@gnu.org>E<gt>.

=cut
842
8431;
844
845### Setup "GNU" style for perl-mode and cperl-mode.
846## Local Variables:
847## perl-indent-level: 2
848## perl-continued-statement-offset: 2
849## perl-continued-brace-offset: 0
850## perl-brace-offset: 0
851## perl-brace-imaginary-offset: 0
852## perl-label-offset: -2
853## cperl-indent-level: 2
854## cperl-brace-offset: 0
855## cperl-continued-brace-offset: 0
856## cperl-label-offset: -2
857## cperl-extra-newline-before-brace: t
858## cperl-merge-trailing-else: nil
859## cperl-continued-statement-offset: 2
860## End: