From: Ari Johnson Date: Tue, 9 Jun 2009 22:44:57 +0000 (+0000) Subject: Add apply() X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=b4ce97a145d9297e4d0791266e6bf8935510a427;p=cobramush.git Add apply() --- diff --git a/src/function.c b/src/function.c index bb3bc75..f978a68 100644 --- a/src/function.c +++ b/src/function.c @@ -285,6 +285,7 @@ FUNTAB flist[] = { {"ANDPOWERS", fun_andflags, 2, 2, FN_REG}, {"ANSI", fun_ansi, 2, -2, FN_NOPARSE}, {"APOSS", fun_aposs, 1, 1, FN_REG}, + {"APPLY", fun_apply, 1, 3, FN_REG}, {"ARABIC2ROMAN", fun_arabictoroman, 1, 1, FN_REG}, {"ART", fun_art, 1, 1, FN_REG}, {"ATRLOCK", fun_atrlock, 1, 2, FN_REG}, diff --git a/src/funlist.c b/src/funlist.c index 4a9dab1..f56f215 100644 --- a/src/funlist.c +++ b/src/funlist.c @@ -3503,3 +3503,33 @@ FUNCTION(fun_regrab) if (study) mush_free((Malloc_t) study, "pcre.extra"); } + +FUNCTION(fun_apply) +{ + char sep; + int count; + char *arr[10]; + ufun_attrib ufun; + char rbuff[BUFFER_LEN]; + OOREF_DECL; + + if (!delim_check(buff, bp, nargs, args, 3, &sep)) + return; + + ENTER_OOREF; + + count = list2arr(arr, 10, args[1], sep); + + if (!fetch_ufun_attrib(args[0], executor, &ufun, 1)) { + safe_str(T(ufun.errmess), buff, bp); + LEAVE_OOREF; + return; + } + + call_ufun(&ufun, arr, count, rbuff, executor, enactor, pe_info); + + LEAVE_OOREF; + + safe_str(rbuff, buff, bp); +} + diff --git a/win32/funs.h b/win32/funs.h index 5eefb07..0948d7e 100644 --- a/win32/funs.h +++ b/win32/funs.h @@ -15,6 +15,7 @@ FUNCTION_PROTO(fun_andflags); FUNCTION_PROTO(fun_andlflags); FUNCTION_PROTO(fun_ansi); FUNCTION_PROTO(fun_aposs); +FUNCTION_PROTO(fun_apply); FUNCTION_PROTO(fun_arabictoroman); FUNCTION_PROTO(fun_art); FUNCTION_PROTO(fun_asin);