# # Patch name: Brackets # Patch version: 1.0 # Author's name: Jason Wilcox # Author's email: jwilcox@ucinet.com # Version of PennMUSH: 1.7.2p11 # Date patch made: 6/9/98 # Author is willing to support (yes/no): yes # Patch format: context diff # # # 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 adds in a function that returns a space seperated list of the # frequency of each of the following characters in this order: [, ], (, ), { # and }. With some minor softcode this can become a great aid in debugging # softcode. keep in mind that this code doesn't parse so brackets([get(me/foo)]) # will do the code on [get(me/foo)] not your foo attribute. *** src/function.c.old Tue Jun 9 12:32:12 1998 --- src/function.c Tue Jun 9 12:48:31 1998 *************** *** 119,124 **** --- 119,125 ---- {"ATRLOCK", fun_atrlock, 1, 2, FN_REG}, {"BEEP", fun_beep, 0, 1, FN_REG}, {"BEFORE", fun_before, 2, 2, FN_REG}, + {"BRACKETS", fun_brackets, 1, 1, FN_NOPARSE}, {"CAND", fun_cand, 2, INT_MAX, FN_NOPARSE}, {"CAPSTR", fun_capstr, 1, -1, FN_REG}, {"CAT", fun_cat, 1, INT_MAX, FN_REG}, *** src/funstr.c.old Tue Jun 9 12:21:07 1998 --- src/funstr.c Tue Jun 9 12:41:56 1998 *************** *** 913,915 **** --- 913,946 ---- safe_str(r, buff, bp); } } + + FUNCTION(fun_brackets) + { + char *str, *rbuff; + int rbrack, lbrack, rbrace, lbrace, lcurl, rcurl; + + lcurl = rcurl = rbrack = lbrack = rbrace = lbrace = 0; + str = args[0]; /* The string to count the brackets in */ + while(*str) + { + switch(*str) + { + case '[': lbrack++; + break; + case ']': rbrack++; + break; + case '(': lbrace++; + break; + case ')': rbrace++; + break; + case '{': lcurl++; + break; + case '}': rcurl++; + break; + default: break; + } + str++; + } + rbuff = tprintf("%d %d %d %d %d %d", lbrack, rbrack, lbrace, rbrace, lcurl, rcurl); + safe_str(rbuff, buff, bp); + } --WwmFnJnmDyWGHa4X--