develooper Front page | perl.perl5.porters | Postings from June 2017

Re: RFC: Add new string comparison macros in handy.h

Thread Previous | Thread Next
From:
Ævar Arnfjörð Bjarmason
Date:
June 2, 2017 11:30
Subject:
Re: RFC: Add new string comparison macros in handy.h
Message ID:
CACBZZX7y+=_RvbBAAa3u7G=kCPO4Hf1gi9tYYX=k1g7V9SLWRg@mail.gmail.com
On Thu, May 11, 2017 at 5:22 PM, Karl Williamson
<public@khwilliamson.com> wrote:

>     memSTARTS_WITHs
>             Test if the string buffer "s1" with length "l1" begins with the
>             substring given by the string literal "s2", returning non-zero
> if
>             so (including if the two are identical); zero otherwise. The
>             comparison does not include the final "NUL" of "s2". "s1" does
> not
>             have to be "NUL"-terminated,
>
>                     bool    memSTARTS_WITHs(char* s1, STRLEN l1, char* s2)

I don't have to use these and don't really care, but just a question:
Is there a reason for why the prototype for the the mem* functions
doesn't also pass the STRLEN for the needle as well as the haystack?

Right now the interface only allows the haystack not the needle to
contain \0, which seems like a needless arbitrary limitation for
something that's essentially a fancy strstr() & memmem(). I.e. you
have feature-parity with strstr() (and extra features like "begins
with?"), but not with memmem().

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