# # Patch name: function_preserve.patch # Patch version: 2 # Author's name: Kurt Fitzner # Author's email: kfitzner@nexus.v-wave.com # Version of PennMUSH: 1.7.2p26 # Date patch made: Sun Jul 18 17:06:26 1999 # Author is willing to support (yes/no): yes # Patch format: diff -u5 # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # # function_preserve.patch # Global softfunctions (as added with the @function command) do # not preserve setq() registers. This forces you to ulocal from # that command, which then screws up the %@ caller, and whatnot. # This patch adds the /preserve switch to @function. This will # create a global function that does preserve the setq() regs. # This patch will prompt you that one part of it appears that it # has already been applied, if you apply this patch to a mush that # already has the chown+clone_preserve.patch applied to it. In # that case, say 'n' to assume reverse, and 'n' to apply anyway, # and it will work fine. # # The patches to the help files which document the above changes # are included separately, in case you don't like my changes and # want to make your own. # # This patch (or perhaps something like it) is scheduled for # inclusion in PennMUSH 1.7.3. # diff -u5 ../tm/src/SWITCHES src/SWITCHES --- ../tm/src/SWITCHES Sun Jul 18 18:01:30 1999 +++ src/SWITCHES Sun Jul 18 17:06:26 1999 @@ -71,10 +71,11 @@ PANIC PARANOID PLAYERS PORT POSE +PRESERVE PRINT PRIVS PURGE QUICK QUIET diff -u5 ../tm/src/cmds.c src/cmds.c --- ../tm/src/cmds.c Sun Jul 18 18:01:30 1999 +++ src/cmds.c Sun Jul 18 17:16:59 1999 @@ -317,11 +317,11 @@ COMMAND (cmd_function) { if (SW_ISSET(sw, SWITCH_DELETE)) do_function_delete(player, arg_left); else - do_function(player, arg_left, args_right); + do_function(player, arg_left, args_right, SW_ISSET(sw, SWITCH_PRESERVE)); } COMMAND (cmd_gedit) { do_gedit(player, arg_left, args_right); } diff -u5 ../tm/src/command.c src/command.c --- ../tm/src/command.c Sun Jul 18 18:01:30 1999 +++ src/command.c Sun Jul 18 17:52:53 1999 @@ -99,11 +99,11 @@ {"@EUNLOCK", NULL, cmd_eunlock, CMD_T_ANY | CMD_T_NOGAGGED, 0, 0, 0}, {"@FIND", NULL, cmd_find, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_NOGAGGED, 0, 0, 0}, {"@FIRSTEXIT", NULL, cmd_firstexit, CMD_T_ANY, 0, 0, 0}, {"@FIXDB", "LOCATION CONTENTS EXITS NEXT", cmd_fixdb, CMD_T_ANY | CMD_T_EQSPLIT, 0, 0, 0}, {"@FORCE", NULL, cmd_force, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_NOGAGGED, 0, 0, 0}, - {"@FUNCTION", "DELETE", cmd_function, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_NOGAGGED, 0, 0, 0}, + {"@FUNCTION", "DELETE PRESERVE", cmd_function, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_NOGAGGED, 0, 0, 0}, {"@GEDIT", NULL, cmd_edit, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS | CMD_T_RS_NOPARSE | CMD_T_NOGAGGED, 0, 0, 0}, {"@GREP", "LIST PRINT ILIST IPRINT", cmd_grep, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_NOPARSE | CMD_T_NOGAGGED, 0, 0, 0}, {"@HALT", "ALL", cmd_halt, CMD_T_ANY | CMD_T_EQSPLIT, 0, 0, 0}, {"@HIDE", "NO OFF YES ON", cmd_hide, CMD_T_ANY, 0, 0, 0}, {"@KICK", NULL, cmd_kick, CMD_T_ANY, WIZARD, 0, 0}, diff -u5 ../tm/src/function.c src/function.c --- ../tm/src/function.c Sat Apr 3 10:32:18 1999 +++ src/function.c Sun Jul 18 17:49:38 1999 @@ -29,11 +29,11 @@ void do_list_functions _((dbref player)); FUN *func_hash_lookup _((char *name)); void func_hash_insert _((const char *name, FUN *func)); void init_func_hashtab _((void)); char *strip_braces _((const char *str)); -void do_function _((dbref player, char *name, char **argv)); +void do_function _((dbref player, char *name, char **argv, int preserve)); void do_function_delete _((dbref player, char *name)); extern void local_functions _((void)); HASHTAB htab_function; @@ -523,14 +523,15 @@ { /* this function is a dummy. */ } void -do_function(player, name, argv) +do_function(player, name, argv, preserve) dbref player; char *name; char *argv[]; + int preserve; { /* command of format: @function =, * Adds a new user-defined function. */ @@ -557,17 +558,18 @@ if (Global_Funcs(player)) { /* if the player is privileged, display user-def'ed functions * with corresponding dbref number of thing and attribute name. */ notify(player, - "Function Name Dbref # Attrib"); + "Function Name Dbref # Prsv Attrib"); for (fp = (FUN *) hash_firstentry(&htab_function); fp; fp = (FUN *) hash_nextentry(&htab_function)) { if (fp->ftype >= GLOBAL_OFFSET) notify(player, - tprintf("%-32s %6d %s", fp->name, + tprintf("%-32s %6d %s %s", fp->name, userfn_tab[GF_Index(fp->ftype)].thing, + userfn_tab[GF_Index(fp->ftype)].preserve?"Yes":" No", userfn_tab[GF_Index(fp->ftype)].name)); } } else { /* just print out the list of available functions */ safe_str("User functions:", tbuf1, &bp); @@ -637,10 +639,11 @@ fp->ftype = userfn_count + GLOBAL_OFFSET; func_hash_insert(name, (FUN *) fp); /* now add it to the user function table */ userfn_tab[userfn_count].thing = thing; + userfn_tab[userfn_count].preserve = preserve; userfn_tab[userfn_count].name = (char *) strdup(upcasestr(argv[2])); #ifdef MEM_CHECK add_check("userfn_tab.name"); #endif userfn_tab[userfn_count].fn = (char *) strdup(upcasestr(name)); @@ -658,10 +661,11 @@ if ((fp->ftype == FN_REG) || (fp->ftype == FN_NOPARSE)) { notify(player, "You cannot change a built-in function."); return; } userfn_tab[GF_Index(fp->ftype)].thing = thing; + userfn_tab[GF_Index(fp->ftype)].preserve = preserve; mush_free((Malloc_t) userfn_tab[GF_Index(fp->ftype)].name, "userfn_tab.name"); userfn_tab[GF_Index(fp->ftype)].name = (char *) strdup(upcasestr(argv[2])); #ifdef MEM_CHECK Binary files ../tm/src/netmud~ and src/netmud~ differ diff -u5 ../tm/src/parse.c src/parse.c --- ../tm/src/parse.c Fri Apr 2 10:55:15 1999 +++ src/parse.c Sun Jul 18 17:53:50 1999 @@ -768,12 +768,21 @@ safe_str(unparse_dbref(thing), buff, bp); safe_chr('/', buff, bp); safe_str(userfn_tab[GF_Index(fp->ftype)].name, buff, bp); safe_chr(')', buff, bp); } else - do_userfn(buff, bp, thing, attrib, nfargs, fargs, + if (userfn_tab[GF_Index(fp->ftype)].preserve) { + char *preserve[10]; + + save_global_regs("globalufun.save", preserve); + do_userfn(buff, bp, thing, attrib, nfargs, fargs, executor, caller, enactor, pe_info); + restore_global_regs("globalufun.save", preserve); + } else { + do_userfn(buff, bp, thing, attrib, nfargs, fargs, + executor, caller, enactor, pe_info); + } } pe_info->fun_depth--; global_fun_recursions--; } --- ../tm/hdrs/game.h Sun Jul 18 18:24:28 1999 +++ hdrs/game.h Sun Jul 18 17:44:38 1999 @@ -59,11 +59,11 @@ /* From db.c */ extern int db_paranoid_write _((FILE * f, int flag)); /* From eval.c */ extern void do_list_functions _((dbref player)); -extern void do_function _((dbref player, char *name, char **argv)); +extern void do_function _((dbref player, char *name, char **argv, int preserve)); extern void do_function_delete _((dbref player, char *name)); /* From game.c */ extern void do_dump _((dbref player, char *num, int flag)); extern void do_shutdown _((dbref player, int panic_flag)); --- ../tm/hdrs/function.h Fri Apr 2 10:54:29 1999 +++ hdrs/function.h Sun Jul 18 17:09:59 1999 @@ -36,10 +36,11 @@ struct userfn_entry { char *fn; dbref thing; char *name; + int preserve; }; extern USERFN_ENTRY userfn_tab[MAX_GLOBAL_FNS]; extern void do_userfn _((char *buff, char **bp,