diff options
Diffstat (limited to 'src/console.cpp')
-rw-r--r-- | src/console.cpp | 89 |
1 files changed, 48 insertions, 41 deletions
diff --git a/src/console.cpp b/src/console.cpp index b2882ac2f..59c6c1a48 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -327,52 +327,59 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char if (a_index >= lengthof(aliases) || astream_i >= lengthof(aliasstream)) break; switch (*cmdptr) { - case '\'': // ' will double for "" - aliasstream[astream_i++] = '"'; - break; - case ';': // Cmd seperator, start new command - aliasstream[astream_i] = '\0'; - aliases[++a_index] = &aliasstream[++astream_i]; - cmdptr++; - break; - case '%': // Some or all parameters - cmdptr++; - switch (*cmdptr) { - case '+': { // All parameters seperated: "[param 1]" "[param 2]" - for (i = 0; i != tokencount; i++) { - aliasstream[astream_i++] = '"'; - astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); - aliasstream[astream_i++] = '"'; - aliasstream[astream_i++] = ' '; - } - } break; - case '!': { // Merge the parameters to one: "[param 1] [param 2] [param 3...]" - aliasstream[astream_i++] = '"'; - for (i = 0; i != tokencount; i++) { - astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); - aliasstream[astream_i++] = ' '; - } + case '\'': // ' will double for "" aliasstream[astream_i++] = '"'; + break; - } break; - default: { // One specific parameter: %A = [param 1] %B = [param 2] ... - int param = *cmdptr - 'A'; + case ';': // Cmd seperator, start new command + aliasstream[astream_i] = '\0'; + aliases[++a_index] = &aliasstream[++astream_i]; + cmdptr++; + break; - if (param < 0 || param >= tokencount) { - IConsoleError("too many or wrong amount of parameters passed to alias, aborting"); - IConsolePrintF(CC_WARNING, "Usage of alias '%s': %s", alias->name, alias->cmdline); - return; + case '%': // Some or all parameters + cmdptr++; + switch (*cmdptr) { + case '+': { // All parameters seperated: "[param 1]" "[param 2]" + for (i = 0; i != tokencount; i++) { + aliasstream[astream_i++] = '"'; + astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); + aliasstream[astream_i++] = '"'; + aliasstream[astream_i++] = ' '; + } + break; + } + + case '!': { // Merge the parameters to one: "[param 1] [param 2] [param 3...]" + aliasstream[astream_i++] = '"'; + for (i = 0; i != tokencount; i++) { + astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); + aliasstream[astream_i++] = ' '; + } + aliasstream[astream_i++] = '"'; + break; + } + + default: { // One specific parameter: %A = [param 1] %B = [param 2] ... + int param = *cmdptr - 'A'; + + if (param < 0 || param >= tokencount) { + IConsoleError("too many or wrong amount of parameters passed to alias, aborting"); + IConsolePrintF(CC_WARNING, "Usage of alias '%s': %s", alias->name, alias->cmdline); + return; + } + + aliasstream[astream_i++] = '"'; + astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[param], astream_i); + aliasstream[astream_i++] = '"'; + break; + } } + break; - aliasstream[astream_i++] = '"'; - astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[param], astream_i); - aliasstream[astream_i++] = '"'; - } break; - } break; - - default: - aliasstream[astream_i++] = *cmdptr; - break; + default: + aliasstream[astream_i++] = *cmdptr; + break; } } |