summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-08-21 09:26:26 +0000
committerAlexey Samsonov <samsonov@google.com>2012-08-21 09:26:26 +0000
commit251134734f71a7e21a7bd17bc7b5821f07c803b2 (patch)
tree48eee00fb9ea1f54e6b71868456540e5c87125d2 /lib/sanitizer_common
parent2bf265b3faf8be1710e9a0441fe9344e105e991c (diff)
downloadcompiler-rt-251134734f71a7e21a7bd17bc7b5821f07c803b2.tar.gz
[Sanitizer] implement internal_strcspn
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common')
-rw-r--r--lib/sanitizer_common/sanitizer_libc.cc9
-rw-r--r--lib/sanitizer_common/sanitizer_libc.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_libc.cc b/lib/sanitizer_common/sanitizer_libc.cc
index c4332423b..6fa05e49d 100644
--- a/lib/sanitizer_common/sanitizer_libc.cc
+++ b/lib/sanitizer_common/sanitizer_libc.cc
@@ -56,6 +56,15 @@ void *internal_memset(void* s, int c, uptr n) {
return s;
}
+uptr internal_strcspn(const char *s, const char *reject) {
+ uptr i;
+ for (i = 0; s[i]; i++) {
+ if (internal_strchr(reject, s[i]) != 0)
+ return i;
+ }
+ return i;
+}
+
char* internal_strdup(const char *s) {
uptr len = internal_strlen(s);
char *s2 = (char*)InternalAlloc(len + 1);
diff --git a/lib/sanitizer_common/sanitizer_libc.h b/lib/sanitizer_common/sanitizer_libc.h
index 8da4286ce..257af2c2f 100644
--- a/lib/sanitizer_common/sanitizer_libc.h
+++ b/lib/sanitizer_common/sanitizer_libc.h
@@ -33,6 +33,7 @@ void *internal_memcpy(void *dest, const void *src, uptr n);
void *internal_memset(void *s, int c, uptr n);
char* internal_strchr(const char *s, int c);
int internal_strcmp(const char *s1, const char *s2);
+uptr internal_strcspn(const char *s, const char *reject);
char *internal_strdup(const char *s);
uptr internal_strlen(const char *s);
char *internal_strncat(char *dst, const char *src, uptr n);