From 936449ad66f8caec5e6e2085350fc937856b92d5 Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Sat, 11 Jul 2015 16:44:18 +0000 Subject: [PATCH] Fixed function strcmp, added new functions git-svn-id: svn://kolibrios.org@5574 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/lib/strings.h | 47 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index 640b331284..7e5834190f 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -1,4 +1,6 @@ //------------------------------------------------------------------------------ +// strspn(dword text1,text2) --- example: strspn("12 year","1234567890") -> return 2 +// strpbrk(dword text1,text2) --- example: strpbrk("this test", " ckfi") -> return "is test" // strcmp( ESI, EDI) // strlen( EDI) // strcpy( EDI, ESI) --- 0 if == @@ -37,6 +39,48 @@ inline fastcall signed int strcmp( ESI, EDI) } */ +int strspn(dword text1,text2) +{ + dword beg; + char s1,s2; + int ret; + ret = 0; + beg = text2; + do { + s1 = ESBYTE[text1]; + text2 = beg; + do { + s2 = ESBYTE[text2]; + if(s1==s2) + { + if(!s2)break; + $inc ret + break; + } + else $inc text2 + } while(s2); + $inc text1 + } while(s1); + return ret; +} + +dword strpbrk(dword text1,text2) +{ + char s,ss; + dword beg; + beg = text2; + do { + s = ESBYTE[text1]; + text2 = beg; + do { + ss = ESBYTE[text2]; + if(ss==s) return text1; + $inc text2 + } while(ss); + $inc text1 + } while(s); + return text1; +} inline fastcall signed int strncmp( ESI, EDI, ECX) { @@ -84,8 +128,7 @@ signed int strcmp(dword text1, text2) if(s1==0) return 0; } else { - - return -1; + return s1-s2; } $inc text1 $inc text2