# # Patch name: AttyIfelse # Patch version: 1 # Author's name: Atuarre Ti Kivikkii # Author's email: atuarre@gz.trekmush.org # Version of PennMUSH: 1.6.10-patch06 # Date patch made: March 13, 1997 # Author is willing to support (yes/no): yes # Patch format: diff -c # # # 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. # # This patch includes the IF, IFTHEN, and IFELSE functions ported to # PennMUSH by Atuarre. The following patch does not include .hlp files, # so here is a brief synopsis of what these patches do: # # IF() is equivalent to T() # IFTHEN(,) is equivalent to SWITCH(T(),1,) # IFELSE(,,) is eqiv to SWITCH(T(),1,,) # # Note like SWITCH, IFHTEN and IFELSE do not parse or unless # condition is met. Also, they internally pass along as $#, # just like switch. # *** ./src/function.c~ Tue May 13 07:42:59 1997 --- ./src/function.c Tue May 13 07:42:59 1997 *************** *** 194,199 {"HOME", fun_home, 1, 1, FN_REG}, {"IDLE", fun_idlesecs, 1, 1, FN_REG}, {"IDLESECS", fun_idlesecs, 1, 1, FN_REG}, {"INC", fun_inc, 1, 1, FN_REG}, {"INDEX", fun_index, 4, 4, FN_REG}, {"INSERT", fun_insert, 3, 4, FN_REG}, --- 194,202 ----- {"HOME", fun_home, 1, 1, FN_REG}, {"IDLE", fun_idlesecs, 1, 1, FN_REG}, {"IDLESECS", fun_idlesecs, 1, 1, FN_REG}, + {"IF", fun_t, 1, 1, FN_REG}, + {"IFELSE", fun_ifelse, 3, 3, FN_NOPARSE}, + {"IFTHEN", fun_ifthen, 2, 2, FN_NOPARSE}, {"INC", fun_inc, 1, 1, FN_REG}, {"INDEX", fun_index, 4, 4, FN_REG}, {"INSERT", fun_insert, 3, 4, FN_REG}, *** ./src/funmisc.c~ Tue May 13 07:48:53 1997 --- ./src/funmisc.c Tue May 13 07:48:53 1997 *************** *** 247,252 } /* ARGSUSED */ FUNCTION(fun_mudname) { safe_str(MUDNAME, buff, bp); --- 247,304 ----- } /* ARGSUSED */ + FUNCTION(fun_ifelse) + { + char mstr[BUFFER_LEN], *dp; + char const *sp; + char *tbuf1; + + dp = mstr; + sp = args[0]; + process_expression(mstr, &dp, &sp, executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + *dp = '\0'; + + if (parse_boolean(mstr)) { + tbuf1 = replace_string("#$", mstr, args[1]); + } else { + tbuf1 = replace_string("#$", mstr, args[2]); + } + + sp = tbuf1; + process_expression(buff, bp, &sp, + executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + mush_free((Malloc_t) tbuf1, "replace_string.buff"); + return; + } + + /* ARGSUSED */ + FUNCTION(fun_ifthen) + { + char mstr[BUFFER_LEN], *dp; + char const *sp; + char *tbuf1; + + dp = mstr; + sp = args[0]; + process_expression(mstr, &dp, &sp, executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + *dp = '\0'; + + if (parse_boolean(mstr)) { + tbuf1 = replace_string("#$", mstr, args[1]); + sp = tbuf1; + process_expression(buff, bp, &sp, + executor, caller, enactor, + PE_DEFAULT, PT_DEFAULT, pe_info); + mush_free((Malloc_t) tbuf1, "replace_string.buff"); + } + + return; + } + + /* ARGSUSED */ FUNCTION(fun_mudname) { safe_str(MUDNAME, buff, bp); *** ./hdrs/function.h~ Tue May 13 07:44:15 1997 --- ./hdrs/function.h Tue May 13 07:44:15 1997 *************** *** 230,235 FUNCTION_PROTO(fun_encrypt); /* funmisc.c */ FUNCTION_PROTO(fun_decrypt); /* funmisc.c */ FUNCTION_PROTO(fun_switch); /* funmisc.c */ FUNCTION_PROTO(fun_mudname); /* funmisc.c */ FUNCTION_PROTO(fun_starttime); /* funmisc.c */ FUNCTION_PROTO(fun_version); /* funmisc.c */ --- 230,237 ----- FUNCTION_PROTO(fun_encrypt); /* funmisc.c */ FUNCTION_PROTO(fun_decrypt); /* funmisc.c */ FUNCTION_PROTO(fun_switch); /* funmisc.c */ + FUNCTION_PROTO(fun_ifelse); /* funmisc.c */ + FUNCTION_PROTO(fun_ifthen); /* funmisc.c */ FUNCTION_PROTO(fun_mudname); /* funmisc.c */ FUNCTION_PROTO(fun_starttime); /* funmisc.c */ FUNCTION_PROTO(fun_version); /* funmisc.c */