From 2fd3e0ed8062f3b5748e5cbafbd5d3435fe725a0 Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Tue, 25 May 2004 13:38:36 +0000 Subject: Cleanup, new strspn function svn-id: r13869 --- backends/PalmOS/Src/missing/_string.cpp | 29 ++++++++++++++++++----------- backends/PalmOS/Src/missing/string.h | 11 ++++++----- 2 files changed, 24 insertions(+), 16 deletions(-) (limited to 'backends/PalmOS') diff --git a/backends/PalmOS/Src/missing/_string.cpp b/backends/PalmOS/Src/missing/_string.cpp index 0b7b3720a0..191185dddf 100644 --- a/backends/PalmOS/Src/missing/_string.cpp +++ b/backends/PalmOS/Src/missing/_string.cpp @@ -21,7 +21,7 @@ */ #include "string.h" -/////////////////////////////////////////////////////////////////////////////// + void *memchr(const void *s, int c, UInt32 n) { UInt32 chr; for(chr = 0; chr < n;chr++,((UInt8 *)s)++) @@ -29,9 +29,20 @@ void *memchr(const void *s, int c, UInt32 n) { return (void *)s; return NULL; -} -/////////////////////////////////////////////////////////////////////////////// -Char *StrTokNext; +} + +UInt32 strspn(const char *s1, const char *s2) { + UInt32 chr = 0; + + while ( chr < strlen(s1) && + strchr(s2, s1[chr]) ) + chr++; + + return chr; +} + +static Char *StrTokNext = NULL; + Char *strtok(Char *str, const Char *sep) { Char *position = NULL, *found, @@ -73,7 +84,7 @@ Char *strtok(Char *str, const Char *sep) { return str; } -/////////////////////////////////////////////////////////////////////////////// + Char *strpbrk(const Char *s1, const Char *s2) { Char *found; UInt32 n; @@ -86,7 +97,7 @@ Char *strpbrk(const Char *s1, const Char *s2) { return NULL; } -/////////////////////////////////////////////////////////////////////////////// + Char *strrchr(const Char *s, int c) { UInt32 chr; UInt32 n = StrLen(s); @@ -97,7 +108,7 @@ Char *strrchr(const Char *s, int c) { return NULL; } -/////////////////////////////////////////////////////////////////////////////// + Char *strdup(const Char *s1) { Char* buf = (Char *)MemPtrNew(StrLen(s1)+1); @@ -106,7 +117,3 @@ Char *strdup(const Char *s1) { return buf; } -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// diff --git a/backends/PalmOS/Src/missing/string.h b/backends/PalmOS/Src/missing/string.h index 1ff04f8180..ecb362c382 100644 --- a/backends/PalmOS/Src/missing/string.h +++ b/backends/PalmOS/Src/missing/string.h @@ -38,10 +38,11 @@ #define strncmp StrNCompare #define strstr StrStr -void *memchr(const void *s, int c, UInt32 n); -Char *strtok(Char *str, const Char *sep); -Char *strrchr(const Char *s, int c); -Char *strdup(const Char *strSource); -Char *strpbrk(const Char *s1, const Char *s2); +void *memchr (const void *s, int c, UInt32 n); +Char *strtok (Char *str, const Char *sep); +Char *strrchr (const Char *s, int c); +Char *strdup (const Char *strSource); +Char *strpbrk (const Char *s1, const Char *s2); +UInt32 strspn (const char *s1, const char *s2); #define StrTok strtok \ No newline at end of file -- cgit v1.2.3