diff options
Diffstat (limited to 'xc/test/xsuite/port/strspn.c')
-rw-r--r-- | xc/test/xsuite/port/strspn.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/xc/test/xsuite/port/strspn.c b/xc/test/xsuite/port/strspn.c new file mode 100644 index 000000000..238a0979a --- /dev/null +++ b/xc/test/xsuite/port/strspn.c @@ -0,0 +1,50 @@ +/* $XConsortium$ */ +/* + * returns the number of contiguous characters from the beginning + * of str that are in set. + * + * A simple emulation provided for (eg BSD) systems that do not provide + * this routine. + */ +int +strspn(str, set) +char *str; +char *set; +{ +char *cp, *sp; + + for (cp = str; *cp; cp++) { + for (sp = set; *sp && *cp != *sp; sp++) + ; + + if (*sp == '\0') + break; + + } + return(cp - str); +} + +/* + * returns the number of contiguous characters from the beginning + * of str that are not in set. + * + * A simple emulation provided for (eg BSD) systems that do not provide + * this routine. + */ +int +strcspn(str, set) +char *str; +char *set; +{ +char *cp, *sp; + + for (cp = str; *cp; cp++) { + for (sp = set; *sp && *cp != *sp; sp++) + ; + + if (*sp != '\0') + break; + + } + return(cp - str); +} |