automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Channels.pm: I'm confused


From: Alexandre Duret-Lutz
Subject: Re: Channels.pm: I'm confused
Date: 20 Aug 2003 11:21:41 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2.93

>>> "Akim" == Akim Demaille <address@hidden> writes:

[...]

 Akim> I meant to apply the appended patch, but it breaks autom4te (and I
 Akim> guess other bin/ members, but that's the first one).  The problem is
 Akim> that there are several of your ChannelDefs functions that support
 Akim> several prototypes (w/ or w/o location) like this:

 Akim> sub fatal ($;$%)
 Akim> {
 Akim> my ($where, $msg, %opts) = @_;
 Akim> msg ('fatal', $where, $msg, %opts);
 Akim> }

[...]

 >> Autom4te::Channels::msg('fatal','/usr/local/bin/m4 failed with exit status: 
 >> 1','exit_code',1,'undef') called at 
 >> /home/akim/src/ace/lib/Autom4te/ChannelDefs.pm line 219

 Akim> The line above shows the 'undef' that was inserted by fatal since its
 Akim> invocation is:

 >> Autom4te::ChannelDefs::fatal('/usr/local/bin/m4 failed with exit status: 
 >> 1','exit_code',1) called at /home/akim/src/ace/lib/Autom4te/FileUtils.pm 
 >> line 196
 >> Autom4te::FileUtils::handle_exec_errors('/usr/local/bin/m4 
 >> --nesting-limit=1024 --include=/home/akim/s...') called at 
 >> /home/akim/src/ace/lib/Autom4te/FileUtils.pm line 250

This looks like a bug in handle_exec_errors.  The call to fatal() should
read 

           fatal ('', "$command failed with exit status: $status",
                  exit_code => $status);

not

           fatal ("$command failed with exit status: $status",
                  exit_code => $status);


[...]

 Akim> Note that fatal looks weird: the documentation says that $where is
 Akim> optional, but the code above seems to says that it is $msg which is
 Akim> optional...

fatal() supports three call styles

  fatal ($MESSAGE)
  fatal ($LOCATION, $MESSAGE)
  fatal ($LOCATION, $MESSAGE, %OPTIONS)

hence the ($;$%) prototype.  msg will make the difference and
decide wether the first argument really is a message or a
location.  

  fatal ($MESSAGE, %OPTIONS)

is not supported presently.  (It seems we could support this
by rewriting fatal() as msg('fatal', @_), and checking in
msg() whether $#_ is odd or even.)

FWIW, somewhere in the Channel::msg documentation there is 

| 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

but obviously I forgot about it when I wrote handle_exec_errors. 
-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]