summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-09-23 19:17:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:16 -0500
commit5be2871481af5607d0886a35d2608aabf2de83bc (patch)
tree6f9843c63a146c82457370e5898b07001c7761dd /source4
parenta8edfd75a6f641afb942d6564670743df8d439d2 (diff)
downloadsamba-5be2871481af5607d0886a35d2608aabf2de83bc.tar.gz
samba-5be2871481af5607d0886a35d2608aabf2de83bc.tar.bz2
samba-5be2871481af5607d0886a35d2608aabf2de83bc.zip
r18850: add strspn() function i ejs
(This used to be commit e8f892bedc65042565442ac802df6eda96388f14)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/ejs/smbcalls_string.c17
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);