mirror of
https://github.com/samba-team/samba.git
synced 2025-10-25 19:33:18 +03:00
r18850: add strspn() function i ejs
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
72f350ec2c
commit
e8f892bedc
@@ -89,6 +89,22 @@ static int ejs_strstr(MprVarHandle eid, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
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");
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user