1
  $    ‹      sËÌIUÈË/QHË/ÍKÑã +�©!     "   ˆl–Ãa¾”J_)â€À?pO©‹FÿÄƒh¹ÃÂ      1
  "   	ˆl–Ãa¾”J_)â€Æ�q ©‹FÿÅƒh¹ÄÃ      	1
  "   ˆl–Ãa¾”J_)â‚fà¸ÈÅ£Æƒh¹ÅÄ      unsupported
     ˆ¾Æƒh¹ÅÄ      unsupported
      ˆl–Ãa¾”J_)â�rãNÜiµ1hßÇ0ÆÅ     ˆ¿Çƒh¹ÆÅ      unsupported
  0   ˆl–ßi~”*ClÊiAã-\mÕ1hßÈ„m¿_‹uÐb&=LV[(ÈÇ ?÷     # Copyright (C) 2002-2012 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

###############################################################
# The main copy of this file is in Automake's git repository. #
# Updates should be sent to automake-patches@gnu.org.         #
###############################################################

package Autom4te::Channels;

=head1 NAME

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

=head1 SYNOPSIS

  use Autom4te::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.
  $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

use 5.006;
use strict;
use Exporter;
use Carp;
use File::Basename;

use vars qw (@ISA @EXPORT %channels $me);

@ISA = qw (Exporter);
@EXPORT = qw ($exit_code $warnings_are_errors
	      &reset_local_duplicates &reset_global_duplicates
	      &register_channel &msg &exists_channel &channel_type
	      &setup_channel &setup_channel_type
	      &dup_channel_setup &drop_channel_setup
	      &buffer_messages &flush_messages
	      &setup_channel_queue &pop_channel_queue
	      US_GLOBAL US_LOCAL
	      UP_NONE UP_TEXT UP_LOC_TEXT);

$me = basename $0;

=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

use vars qw ($exit_code);
$exit_code = 0;

=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

use vars qw ($warnings_are_errors);
$warnings_are_errors = 0;

=back

=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 mess