[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: Automake::Conditional
From: |
Alexandre Duret-Lutz |
Subject: |
Re: FYI: Automake::Conditional |
Date: |
08 Oct 2002 19:38:01 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>> "Akim" == Akim Demaille <address@hidden> writes:
[...]
>> + # Catch some common programming errors:
>> + # - A conditional passed to new
>> + confess "`$cond' is a reference, expected a string" if ref $cond;
>> + # - A conditional passed as a string to new
>> + confess "`$cond' doesn't look like a condition" if $cond =~ /::/;
Akim> ``Common programming errors'' :) :) :) How many time did you make it
Akim> this weekend?
More than I'd confess...
>> +# Undocumented, shouldn't be needed out of this class.
>> +sub has ($$)
>> +{
>> + my ($self, $cond) = @_;
>> + if (exists $self->{'hash'}{$cond})
>> + {
>> + return $self->{'hash'}{$cond};
Akim> Is this really what you mean? What if `$self->{'hash'}{$cond}' is
Akim> `undef'? Wouldn't returning 1 be safer?
>> + }
>> + return 0;
>> +}
Getting `undef' is impossible (or it's a bug); but, yes, this
code is utterly stupid. I've installed the following patch.
2002-10-08 Alexandre Duret-Lutz <address@hidden>
* lib/Automake/Conditional.pm (has): Simplify.
Index: lib/Automake/Conditional.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Conditional.pm,v
retrieving revision 1.1
diff -u -r1.1 Conditional.pm
--- lib/Automake/Conditional.pm 7 Oct 2002 09:23:32 -0000 1.1
+++ lib/Automake/Conditional.pm 8 Oct 2002 17:35:51 -0000
@@ -36,7 +36,7 @@
# "COND1 and not COND2 and not COND3".
my $both = $cond->merge ($other);
- # Likewise, but using a list of atomica conditional strings
+ # Likewise, but using a list of atomic conditional strings
my $both2 = $cond->merge_conds ("COND3_FALSE");
# Return the list of conditions ("COND1_TRUE", "COND2_FALSE"):
@@ -231,11 +231,7 @@
sub has ($$)
{
my ($self, $cond) = @_;
- if (exists $self->{'hash'}{$cond})
- {
- return $self->{'hash'}{$cond};
- }
- return 0;
+ return exists $self->{'hash'}{$cond};
}
=item C<$cond-E<gt>false>
[...]
Akim> Can't we imagine having this modules (.pm) embed their own minitest
Akim> suite? And be able to `run' them to exec the test suite?
This would be nice! Maybe we should look how this is done in Perl itself.
--
Alexandre Duret-Lutz