diff options
author | Er_Maqui <er_maqui@darkbolt.net> | 2015-10-21 14:54:40 +0200 |
---|---|---|
committer | Er_Maqui <er_maqui@darkbolt.net> | 2015-10-21 14:54:40 +0200 |
commit | 198aef7133713b47a4c4fadaac6811c9d3812d19 (patch) | |
tree | 84df335dd0ad350c20f8c2a018b2a7096907b636 /src/common/console.c | |
parent | 6977d6d31b58afc5095c0a59e754f21ea1080054 (diff) | |
parent | 8b198db1e0ccc8209b7bcf54b4df62d4747f75b2 (diff) | |
download | hercules-198aef7133713b47a4c4fadaac6811c9d3812d19.tar.gz hercules-198aef7133713b47a4c4fadaac6811c9d3812d19.tar.bz2 hercules-198aef7133713b47a4c4fadaac6811c9d3812d19.tar.xz hercules-198aef7133713b47a4c4fadaac6811c9d3812d19.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/common/console.c')
-rw-r--r-- | src/common/console.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/common/console.c b/src/common/console.c index c8ca4ae87..477141b48 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -16,7 +16,7 @@ #ifndef MINICORE # include "common/atomic.h" # include "common/ers.h" -# include "common/malloc.h" +# include "common/memmgr.h" # include "common/mutex.h" # include "common/spinlock.h" # include "common/sql.h" @@ -362,7 +362,6 @@ void console_parse_sub(char *line) char *tok; char sublist[CP_CMD_LENGTH * 5]; int i; - unsigned int len = 0; memcpy(bline, line, 200); tok = strtok(line, " "); @@ -375,19 +374,15 @@ void console_parse_sub(char *line) cmd = VECTOR_INDEX(console->input->command_list, i); - len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd); + snprintf(sublist, sizeof(sublist), "%s", cmd->cmd); if (cmd->type == CPET_FUNCTION) { - char *r = NULL; - if( (tok = strtok(NULL, " ")) ) { - r = bline; - r += len + 1; - } - cmd->u.func(r); + tok = strtok(NULL, ""); + cmd->u.func(tok); return; } - while (( tok = strtok(NULL, " ") ) != NULL) { + while ((tok = strtok(NULL, " ")) != NULL) { struct CParseEntry *entry = NULL; Assert_retv(cmd->type == CPET_CATEGORY); @@ -409,17 +404,15 @@ void console_parse_sub(char *line) } entry = VECTOR_INDEX(cmd->u.children, i); if (entry->type == CPET_FUNCTION) { - char *r = NULL; - if ((tok = strtok(NULL, " "))) { - r = bline; - r += len + strlen(entry->cmd) + 1; - } - entry->u.func(r); + tok = strtok(NULL, ""); + entry->u.func(tok); return; } cmd = entry; - len += snprintf(sublist + len,(CP_CMD_LENGTH * 5) - len," %s", cmd->cmd); + + if (strlen(sublist) < sizeof(sublist)-1) + snprintf(sublist+strlen(sublist), sizeof(sublist), " %s", cmd->cmd); } ShowError("Is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist); } |