Make some string ops bounded and fix bug in editor toggle command (#54)

* Replace a few strcat/sprintf instances with bounded variants

Also cleaned up the whitespace in the parse_edit_action function as it was
not consistent.

Fix bug in editor format command introduced in earlier commit

* Fix bug in editor toggle command when an escaped @ is in the buffer

Previously, toggling between @ and \t would always try to convert
@ to \t, even if already toggled, iff an escaped @ was present in the
buffer (i.e. '@@').
This commit is contained in:
Kevin Fischer
2018-07-16 04:17:45 -05:00
committed by wyld-sw
parent 14855c273a
commit b27003e881
3 changed files with 151 additions and 141 deletions

View File

@@ -470,14 +470,14 @@ static void script_syntax_highlighting(struct descriptor_data *d, char *string)
for (cmd = 0; *complete_cmd_info[cmd].command != '\n'; cmd++) {
if (complete_cmd_info[cmd].command_pointer == do_action) {
char replace_social[MAX_INPUT_LENGTH];
sprintf(replace_social, "\tc%s\tn", complete_cmd_info[cmd].command);
snprintf(replace_social, MAX_INPUT_LENGTH, "\tc%s\tn", complete_cmd_info[cmd].command);
line = str_replace(line, complete_cmd_info[cmd].command, replace_social);
}
}
}
strcat(buffer, line);
strcat(buffer, "\tn\r\n");
strncat(buffer, line, sizeof(buffer) - strlen(buffer) - 1);
strncat(buffer, "\tn\r\n", sizeof(buffer) - strlen(buffer) - 1);
}
page_string(d, buffer, TRUE);