Skip to content

strspn, strcspn, and strpbrk have bugs #50

Open

Description

@ZERICO2005

The current implementations of strspn, strcspn, and strpbrk appear to be incorrect and do not pass the following test cases:

char const * str = "abcdef";
char const * empty = "";

assert(strspn(str, empty) == 0);
assert(strpbrk(str, empty) == NULL);
assert(strcspn(str, empty) == 6);

assert(strcspn(str, "cba") == 0);
assert(strcspn(str, "fed") == 3);
assert(strcspn(str, "eebbeb") == 1);
assert(strcspn(str, "ffaafa") == 0);
assert(strcspn(empty, str) == 0);
assert(strcspn(empty, empty) == 0);

These issues have already been documented here:
CE-Programming/toolchain#646

There are also corrected implementations available in the CE Programming toolchain.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions