# Patch name: XField # Patch version: 1 # Author's name: BlaZe@M*U*S*H # Author's email: Manwe_7@yahoo.co.uk # Version of PennMUSH: 1.7.7p8 # Date patch made: 18 March 2003 # 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. # Adds the lfield() and rfield() functions, which work like ljust(left(...)) and rjust(right(...)) *** funstr.c.old Tue Mar 18 07:20:25 2003 --- funstr.c Tue Mar 18 08:16:15 2003 *************** *** 696,701 **** --- 696,759 ---- free_ansi_string(as); } + FUNCTION(fun_lfield) + { + /* Returns the first X numbers of characters from a string, whilst + * trailing the string with spaces until it reaches X characters. + */ + + int len, arg_len, i; + ansi_string *as; + + if (!is_integer(args[1])) { + safe_str(T(e_int), buff, bp); + return; + } + len = parse_integer(args[1]); + + if (len < 0) { + safe_str(T(e_range), buff, bp); + return; + } + + as = parse_ansi_string(args[0]); + + safe_ansi_string(as,0,len,buff,bp); + for (i = as->len; i < len; i++) + safe_chr(' ',buff,bp); + } + + FUNCTION(fun_rfield) + { + /* Returns the first X numbers of characters from a string, whilst + * prefixing the string with spaces until it reaches X characters. + */ + + int len, arg_len, i; + ansi_string *as; + + if (!is_integer(args[1])) { + safe_str(T(e_int), buff, bp); + return; + } + len = parse_integer(args[1]); + + if (len < 0) { + safe_str(T(e_range), buff, bp); + return; + } + + as = parse_ansi_string(args[0]); + + for (i = as->len; i < len; i++) + safe_chr(' ',buff,bp); + + safe_ansi_string(as,0,len,buff,bp); + + + } + + /* ARGSUSED */ FUNCTION(fun_ljust) { *** function.c.old Tue Mar 18 08:00:21 2003 --- function.c Tue Mar 18 08:03:55 2003 *************** *** 288,293 **** --- 288,294 ---- {"LEFT", fun_left, 2, 2, FN_REG}, {"LEMIT", fun_lemit, 1, -1, FN_REG}, {"LEXITS", fun_lexits, 1, 1, FN_REG}, + {"LFIELD", fun_lfield, 2, 2, FN_REG}, {"LFLAGS", fun_lflags, 0, 1, FN_REG}, {"LINK", fun_link, 2, 2, FN_REG}, {"LIST", fun_list, 1, 1, FN_REG}, *************** *** 398,403 **** --- 399,405 ---- {"RESTARTTIME", fun_restarttime, 0, 0, FN_REG}, {"REVERSE", fun_flip, 1, 1, FN_REG}, {"REVWORDS", fun_revwords, 1, 3, FN_REG}, + {"RFIELD", fun_rfield, 2, 2, FN_REG}, {"RIGHT", fun_right, 2, 2, FN_REG}, {"RJUST", fun_rjust, 2, 3, FN_REG}, {"RLOC", fun_rloc, 2, 2, FN_REG},