diff options
author | Derrell Lipman <derrell@samba.org> | 2006-09-23 19:17:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:20:16 -0500 |
commit | 5be2871481af5607d0886a35d2608aabf2de83bc (patch) | |
tree | 6f9843c63a146c82457370e5898b07001c7761dd | |
parent | a8edfd75a6f641afb942d6564670743df8d439d2 (diff) | |
download | samba-5be2871481af5607d0886a35d2608aabf2de83bc.tar.gz samba-5be2871481af5607d0886a35d2608aabf2de83bc.tar.bz2 samba-5be2871481af5607d0886a35d2608aabf2de83bc.zip |
r18850: add strspn() function i ejs
(This used to be commit e8f892bedc65042565442ac802df6eda96388f14)
-rw-r--r-- | source4/scripting/ejs/smbcalls_string.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c index d5884cb00f..403de7ba35 100644 --- a/source4/scripting/ejs/smbcalls_string.c +++ b/source4/scripting/ejs/smbcalls_string.c @@ -91,6 +91,22 @@ static int ejs_strstr(MprVarHandle eid, int argc, char **argv) /* usage: + var s = strspn(string, legal_chars_string); +*/ +static int ejs_strspn(MprVarHandle eid, int argc, char **argv) +{ + int len; + if (argc != 2) { + ejsSetErrorMsg(eid, "strspn invalid arguments"); + return -1; + } + len = strspn(argv[0], argv[1]); + mpr_Return(eid, mprCreateIntegerVar(len)); + return 0; +} + +/* + usage: list = split(".", "a.foo.bar"); list = split(".", "a.foo.bar", count); @@ -493,6 +509,7 @@ static int ejs_string_init(MprVarHandle eid, int argc, struct MprVar **argv) mprSetStringCFunction(obj, "strlower", ejs_strlower); mprSetStringCFunction(obj, "strupper", ejs_strupper); mprSetStringCFunction(obj, "strstr", ejs_strstr); + mprSetStringCFunction(obj, "strspn", ejs_strspn); mprSetCFunction(obj, "split", ejs_split); mprSetCFunction(obj, "join", ejs_join); mprSetCFunction(obj, "sprintf", ejs_sprintf); |