From f69c37fcffd7683d5a495d88bc93d679d771eeda Mon Sep 17 00:00:00 2001 From: Rick Bird Date: Fri, 25 Mar 2011 17:19:25 -0400 Subject: [PATCH] PennMUSH Incorporation 182p4 * Useless variable in real_unparse() removed. Reported by Taladan. [SW] * case() would replace #$ in the default argument, contrary to the help file. Reported by Talvo. [SW] * Memory leak in grep(). [SW] * Quotes can be around the player name on the login screen always, instead of just when player_name_spaces was on. Suggested by Dan Widdis. [SW] * '{think foo} bar' exhibited odd behavior. [GM] --- hdrs/parse.h | 8 ++++---- src/command.c | 2 +- src/funmisc.c | 12 ++++++++---- src/parse.c | 4 ++-- src/rob.c | 8 ++++---- src/wiz.c | 16 ++++++++++------ 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hdrs/parse.h b/hdrs/parse.h index df0bc10..ac3f36a 100644 --- a/hdrs/parse.h +++ b/hdrs/parse.h @@ -52,7 +52,7 @@ extern dbref parse_objid(char const *str); -/* The following routines all take varoius arguments, and return +/* The following routines all take various arguments, and return * string representations of same. The string representations * are stored in static buffers, so the next call to each function * will destroy any old string that was there. @@ -67,7 +67,7 @@ char *unparse_number(NVAL num); char *unparse_types(int type); /* The following routines all take strings as arguments, and return - * true iff the string is a valid representation of the appropriate type. + * true if the string is a valid representation of the appropriate type. */ int is_dbref(char const *str); int is_objid(char const *str); @@ -206,7 +206,7 @@ int process_expression(char *buff, char **bp, char const **str, * and PE_FUNCTION_CHECK must be active for function evaluation to occur. * * PE_FUNCTION_MANDATORY causes an error to be reported if a function call - * is attempted for a non-existant function. Otherwise, the function call + * is attempted for a non-existent function. Otherwise, the function call * is not evaluated, but rather treated as normal text. * * PE_LITERAL prevents { and [ from being recognized and causing recursion. @@ -233,7 +233,7 @@ int process_expression(char *buff, char **bp, char const **str, /* These represent '\0', '}', ']', ')', ',', ';', '=', and ' ', respectively. * If the character corresponding to a set flag is encountered, then * process_expression() will exit, with *str pointing at the terminating - * charater. '\0' is always a terminating character. + * character. '\0' is always a terminating character. * * PT_DEFAULT, below, is provided as syntactic sugar. */ diff --git a/src/command.c b/src/command.c index 0f85646..3196b39 100644 --- a/src/command.c +++ b/src/command.c @@ -994,7 +994,7 @@ command_parse(dbref player, dbref cause, dbref realcause, char *string, int from cmd = command_find("ATTRIB_SET"); } else { c = command; - while ((*c) && (*c != '/') && (*c != ' ')) + while ((*c) && (*c != '/')) c++; b = *c; *c = '\0'; diff --git a/src/funmisc.c b/src/funmisc.c index 7d68ba5..4d0fee1 100644 --- a/src/funmisc.c +++ b/src/funmisc.c @@ -293,7 +293,7 @@ FUNCTION(fun_switch) int j, per; char mstr[BUFFER_LEN], pstr[BUFFER_LEN], *dp; char const *sp; - char *tbuf1; + char *tbuf1 = NULL; int first = 1, found = 0, exact = 0; if (strstr(called_as, "ALL")) @@ -343,11 +343,15 @@ FUNCTION(fun_switch) if (!(nargs & 1) && !found) { /* Default case */ - tbuf1 = replace_string("#$", mstr, args[nargs - 1]); - sp = tbuf1; + if (!exact) { + tbuf1 = replace_string("#$", mstr, args[nargs - 1]); + sp = tbuf1; + } else + sp = args[nargs - 1]; process_expression(buff, bp, &sp, executor, caller, enactor, PE_DEFAULT, PT_DEFAULT, pe_info); - mush_free((Malloc_t) tbuf1, "replace_string.buff"); + if (!exact) + mush_free((Malloc_t) tbuf1, "replace_string.buff"); } } diff --git a/src/parse.c b/src/parse.c index 63ff7fd..89b8d25 100644 --- a/src/parse.c +++ b/src/parse.c @@ -250,8 +250,8 @@ is_dbref(char const *str) * by a : and at least one digit, and nothing else. * In regex: ^#-?\d+(:\d+)?$ * \param str string to check. - * \retval 1 string is a dbref. - * \retval 0 string is not a dbref. + * \retval 1 string is an objid + * \retval 0 string is not an objid. */ int is_objid(char const *str) diff --git a/src/rob.c b/src/rob.c index 8ec3eb7..24cb53f 100644 --- a/src/rob.c +++ b/src/rob.c @@ -309,8 +309,8 @@ do_buy(dbref player, char *item, char *from, int price) a = atr_get(vendor, "PRICELIST"); if (!a) continue; - strncpy(prices,atr_value(a),BUFFER_LEN); - prices[BUFFER_LEN-1] = '\0'; + strncpy(prices, atr_value(a), BUFFER_LEN); + prices[BUFFER_LEN - 1] = '\0'; upcasestr(prices); count = list2arr(r, BUFFER_LEN / 2, prices, ' '); if (!count) @@ -437,7 +437,7 @@ do_give_to(dbref player, char *arg, int silent) notify(player, T("Did you want to give something *to* someone?")); return; } - while ((s > arg) && isspace(*(s - 1))) { + while ((s > arg) && isspace((unsigned char) *(s - 1))) { s--; } if (s == arg) { @@ -447,7 +447,7 @@ do_give_to(dbref player, char *arg, int silent) *s++ = '\0'; s = (char *) string_match(s, "TO "); s += 3; - while (*s && isspace(*s)) + while (*s && isspace((unsigned char) *s)) s++; if (!*s) { notify(player, T("Give to whom?")); diff --git a/src/wiz.c b/src/wiz.c index 5379258..6d74e96 100644 --- a/src/wiz.c +++ b/src/wiz.c @@ -1761,8 +1761,9 @@ fill_search_spec(dbref player, const char *owner, int nargs, const char **args, restriction = args[n + 1]; /* A special old-timey kludge */ if (class && !*class && restriction && *restriction) { - if (isdigit(*restriction) || ((*restriction == '#') && *(restriction + 1) - && isdigit(*(restriction + 1)))) { + if (isdigit((unsigned char) *restriction) + || ((*restriction == '#') && *(restriction + 1) + && isdigit((unsigned char) *(restriction + 1)))) { size_t offset = 0; if (*restriction == '#') offset = 1; @@ -1774,16 +1775,19 @@ fill_search_spec(dbref player, const char *owner, int nargs, const char **args, } if (!class || !*class || !restriction) continue; - if (isdigit(*class) || - ((*class == '#') && *(class + 1) && isdigit(*(class + 1)))) { + if (isdigit((unsigned char) *class) || + ((*class == '#') && *(class + 1) + && isdigit((unsigned char) *(class + 1)))) { + size_t offset = 0; if (*class == '#') offset = 1; spec->low = parse_integer(class + offset); if (!GoodObject(spec->low)) spec->low = 0; - if (isdigit(*restriction) || ((*restriction == '#') && *(restriction + 1) - && isdigit(*(restriction + 1)))) { + if (isdigit((unsigned char) *restriction) + || ((*restriction == '#') && *(restriction + 1) + && isdigit((unsigned char) *(restriction + 1)))) { offset = 0; if (*restriction == '#') offset = 1; -- 2.30.2