Bug 15973 - glibc should provide strnspn() and strncspn()
Summary: glibc should provide strnspn() and strncspn()
Status: RESOLVED WONTFIX
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-21 17:19 UTC by Ondrej Oprala
Modified: 2014-06-13 13:05 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Oprala 2013-09-21 17:19:17 UTC
Strspn should have an 'n'-variant similar to its string-handling siblings.
Comment 1 Ondrej Bilka 2013-09-21 17:27:59 UTC
On Sat, Sep 21, 2013 at 05:19:17PM +0000, ooprala at redhat dot com wrote:
> 
> Strspn should have an 'n'-variant similar to its string-handling siblings.
> 
What are use cases where it is needed?
Comment 2 Rich Felker 2013-09-22 05:19:56 UTC
Why should more nonstandard functions with no precedent be added? At the very least, a usage case for where it's important to have such a function and have a highly optimized implementation in libc (as opposed to a trivial implementation in the application that needs it) should be provided before this is even considered.
Comment 3 paxdiablo 2014-01-30 04:34:57 UTC
Have to agree with Rich here, strspn is mandated by ISO C but I cannot find the n-variant in either ISO or POSIX.

It will need a very good reason for being added, beyond programmers who can't write safe code without the crutch of so-called safe functions :-)
Comment 4 Florian Weimer 2014-06-13 12:47:27 UTC
The existing strspn function isn't even such a great model for an API.  In most cases, it would be beneficial to pre-compile the pattern.  I don't think it makes sense to add more interfaces with the same issue.
Comment 5 Florian Weimer 2014-06-13 12:48:04 UTC
The existing strspn function isn't even such a great model for an API.  In most cases, it would be beneficial to pre-compile the pattern.  I don't think it makes sense to add more interfaces with the same issue.
Comment 6 Ondrej Bilka 2014-06-13 13:05:03 UTC
On Fri, Jun 13, 2014 at 12:48:04PM +0000, fweimer at redhat dot com wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=15973
> 
> Florian Weimer <fweimer at redhat dot com> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |fweimer at redhat dot com
> 
> --- Comment #5 from Florian Weimer <fweimer at redhat dot com> ---
> The existing strspn function isn't even such a great model for an API.  In most
> cases, it would be beneficial to pre-compile the pattern.  I don't think it
> makes sense to add more interfaces with the same issue.
> 
You could do caching on-line but it is not on my priority list.