From f590502d640e8f4be5069f96d689f0fec6bc8641 Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Fri, 6 May 2011 17:46:02 -0400 Subject: [PATCH] PennMUSH 1.8.3p11 Author: talvo@talvo.com Date: Fri Dec 4 06:16:53 2009 +0000 Woops. Missed a bit of the u*() refactor. Author: talvo@talvo.com Date: Fri Dec 4 06:04:53 2009 +0000 Fix typo in function.c, some refactoring of u*() function code. Fixes #168 Fixes #167 Fixes #159 --- src/function.c | 10 ++++---- src/funufun.c | 67 ++------------------------------------------------ src/parse.c | 10 ++++---- 3 files changed, 12 insertions(+), 75 deletions(-) diff --git a/src/function.c b/src/function.c index 66f4ff2..179ca95 100644 --- a/src/function.c +++ b/src/function.c @@ -730,11 +730,11 @@ FUNTAB flist[] = { {"TRUNC", fun_trunc, 1, 1, FN_REG}, {"TYPE", fun_type, 1, 1, FN_REG}, {"UCSTR", fun_ucstr, 1, -1, FN_REG}, - {"UDEFAULT", fun_uldefault, 2, 12, FN_NOPARSE}, + {"UDEFAULT", fun_udefault, 2, 12, FN_NOPARSE}, {"UFUN", fun_ufun, 1, 11, FN_REG}, - {"ULAMBDA", fun_ulambda, 1, 11, FN_REG}, - {"ULDEFAULT", fun_uldefault, 1, 12, FN_NOPARSE}, - {"ULOCAL", fun_ulocal, 1, 11, FN_REG}, + {"ULAMBDA", fun_ufun, 1, 11, FN_REG}, + {"ULDEFAULT", fun_udefault, 1, 12, FN_NOPARSE | FN_LOCALIZE}, + {"ULOCAL", fun_ufun, 1, 11, FN_REG | FN_LOCALIZE}, {"UNIQUE", fun_unique, 1, 4, FN_REG}, {"IDLE_TIMES", fun_idle_times, 1, 1, FN_REG}, {"UTCTIME", fun_time, 0, 0, FN_REG}, @@ -1660,7 +1660,7 @@ build_function_report(dbref player, FUN *fp) first = 0; } - if (fp->flags & FN_LOCALIZE) { + if (fp->flags & FN_USERFN) { if (first == 0) safe_strl(", ", 2, tbuf, &tp); safe_str("Userfn", tbuf, &tp); diff --git a/src/funufun.c b/src/funufun.c index bf054a4..20e69fd 100644 --- a/src/funufun.c +++ b/src/funufun.c @@ -185,7 +185,7 @@ FUNCTION(fun_ufun) ENTER_OOREF; - if (!fetch_ufun_attrib(args[0], executor, &ufun, 0)) { + if (!fetch_ufun_attrib(args[0], executor, &ufun, (!strcmp(called_as, "ULAMBDA")))) { safe_str(T(ufun.errmess), buff, bp); LEAVE_OOREF; return; @@ -193,64 +193,10 @@ FUNCTION(fun_ufun) call_ufun(&ufun, args + 1, nargs - 1, rbuff, executor, enactor, pe_info); - safe_str(rbuff, buff, bp); - - LEAVE_OOREF; - - return; -} - -/* ARGSUSED */ -FUNCTION(fun_ulambda) -{ - char rbuff[BUFFER_LEN]; - ufun_attrib ufun; - OOREF_DECL; - - ENTER_OOREF; - - if (!fetch_ufun_attrib(args[0], executor, &ufun, 1)) { - safe_str(T(ufun.errmess), buff, bp); - LEAVE_OOREF; - return; - } - - call_ufun(&ufun, args + 1, nargs - 1, rbuff, executor, enactor, pe_info); - - safe_str(rbuff, buff, bp); - - LEAVE_OOREF; - - return; -} - -/* ARGSUSED */ -FUNCTION(fun_ulocal) -{ - /* Like fun_ufun, but saves the state of the q0-q9 registers - * when called - */ - char *preserve[NUMQ]; - char rbuff[BUFFER_LEN]; - ufun_attrib ufun; - OOREF_DECL; - ENTER_OOREF; - if (!fetch_ufun_attrib(args[0], executor, &ufun, 0)) { - safe_str(T(ufun.errmess), buff, bp); - LEAVE_OOREF; - return; - } - - /* Save global regs */ - save_global_regs("ulocal.save", preserve); - - call_ufun(&ufun, args + 1, nargs - 1, rbuff, executor, enactor, pe_info); safe_str(rbuff, buff, bp); - restore_global_regs("ulocal.save", preserve); - LEAVE_OOREF; return; @@ -261,7 +207,7 @@ FUNCTION(fun_ulocal) * then preserve registers, too. */ /* ARGSUSED */ -FUNCTION(fun_uldefault) +FUNCTION(fun_udefault) { dbref thing; ATTR *attrib; @@ -270,7 +216,6 @@ FUNCTION(fun_uldefault) char mstr[BUFFER_LEN]; char **xargs; int i; - char *preserve[NUMQ]; OOREF_DECL; ENTER_OOREF; @@ -299,12 +244,8 @@ FUNCTION(fun_uldefault) *dp = '\0'; } } - if (called_as[1] == 'L') - save_global_regs("uldefault.save", preserve); do_userfn(buff, bp, thing, attrib, nargs - 2, xargs, executor, caller, enactor, pe_info, 0); - if (called_as[1] == 'L') - restore_global_regs("uldefault.save", preserve); /* Free the xargs */ if (nargs > 2) { @@ -318,12 +259,8 @@ FUNCTION(fun_uldefault) /* We couldn't get it. Evaluate args[1] and return it */ sp = args[1]; - if (called_as[1] == 'L') - save_global_regs("uldefault.save", preserve); process_expression(buff, bp, &sp, executor, caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info); - if (called_as[1] == 'L') - restore_global_regs("uldefault.save", preserve); LEAVE_OOREF; diff --git a/src/parse.c b/src/parse.c index e3334bc..babb4e7 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1513,8 +1513,11 @@ process_expression(char *buff, char **bp, char const **str, safe_str(T(" ARGUMENTS BUT GOT "), buff, bp); safe_integer(nfargs, buff, bp); } else { + char *preserve[NUMQ]; global_fun_recursions++; pe_info->fun_depth++; + if (fp->flags & FN_LOCALIZE) + save_global_regs("@function.save", preserve); if (fp->flags & FN_BUILTIN) { global_fun_invocations++; pe_info->fun_invocations++; @@ -1556,15 +1559,12 @@ process_expression(char *buff, char **bp, char const **str, safe_str(fp->where.ufun->name, buff, bp); safe_chr(')', buff, bp); } else { - char *preserve[NUMQ]; - if (fp->flags & FN_LOCALIZE) - save_global_regs("@function.save", preserve); do_userfn(buff, bp, thing, attrib, nfargs, fargs, executor, caller, enactor, pe_info, PE_USERFN); - if (fp->flags & FN_LOCALIZE) - restore_global_regs("@function.save", preserve); } } + if (fp->flags & FN_LOCALIZE) + restore_global_regs("@function.save", preserve); pe_info->fun_depth--; global_fun_recursions--; } -- 2.30.2