develooper Front page | perl.perl5.porters | Postings from February 2011

Re: [perl #84680] POSIX::isdigit() returns 1 for the empty string

Thread Previous | Thread Next
From:
Steve Peters
Date:
February 25, 2011 05:32
Subject:
Re: [perl #84680] POSIX::isdigit() returns 1 for the empty string
Message ID:
AANLkTinnaQCpGwrVcM8bzODr=PNb3uiOcBSu-a008SuR@mail.gmail.com
On Fri, Feb 25, 2011 at 1:02 AM, Mark Overmeer <mark@overmeer.net> wrote:

> * Steve Peters (steve@fisharerojo.org) [110225 04:05]:
> > On Tue, Feb 22, 2011 at 10:27 AM, Robert Lang <perlbug-followup@perl.org
> >wrote:
> > > $ perl -MPOSIX -e 'print isdigit(""), "\n"'
>
> > Thanks for the report.  I do have a fix ready for this, but before I
> commit
> > this, this technically effects all the ifXXX() functions.  Also, in the
> > ext/POSIX/t/posix.t we have...
>
> The change in C is simple, of course, but it will break existing
> implementations. This is a flaw in the docs, not in the code.
>

Occasionally, people depend on the behavior of bugs, like people that
depending on Carp being accidentally pulled in with "use warnings".  That
makes it no less of a bug to be fixed.  As the behavior of the function is
not documented regarding what happens when an empty string or undef is
passed in, we still have room to define it.  I'll be sure to add the
documentation fix as well.

Also, looking into the history of the code, it did at one time do exactly
what Linux did when passed an empty string.  It core dumped.

Steve Peters
steve@fisharerojo.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About