Merge branch 'develop' into feature/add_tests_#5

This commit is contained in:
prozessorkern 2019-07-28 22:50:23 +02:00
commit fc8a34dd1c
2 changed files with 18 additions and 6 deletions

View File

@ -193,6 +193,7 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
{ {
shellmatta_cmd_t *cmd; shellmatta_cmd_t *cmd;
uint8_t cmdExecuted = 0u; uint8_t cmdExecuted = 0u;
uint32_t cmdLen;
shellmatta_retCode_t ret = SHELLMATTA_OK; shellmatta_retCode_t ret = SHELLMATTA_OK;
shellmatta_instance_t *inst = (shellmatta_instance_t*)handle; shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
@ -225,16 +226,27 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
history_storeCmd(inst); history_storeCmd(inst);
history_reset(inst); history_reset(inst);
/** -# determine the cmd len (chars until first space or \0 is found */
cmdLen = 0u;
while( (cmdLen < inst->inputCount)
&& (' ' != inst->buffer[cmdLen])
&& ('\0' != inst->buffer[cmdLen]))
{
cmdLen ++;
}
/** -# search for a matching command */ /** -# search for a matching command */
while (NULL != cmd) while (NULL != cmd)
{ {
/* only compare the length of the command -1 (to avoid comparing the \0 */ /** -# compare command string and length */
if ( (0 == strncmp( inst->buffer, if ( ((0 == strncmp( inst->buffer,
cmd->cmd, cmd->cmd,
strlen(cmd->cmd))) cmdLen))
|| (0 == strncmp( inst->buffer, && (cmdLen == strlen(cmd->cmd)))
|| ((0 == strncmp( inst->buffer,
cmd->cmdAlias, cmd->cmdAlias,
strlen(cmd->cmdAlias)))) cmdLen))
&& (cmdLen == strlen(cmd->cmdAlias))))
{ {
inst->write("\r\n", 2u); inst->write("\r\n", 2u);

View File

@ -145,7 +145,7 @@ void utils_forwardCursor(shellmatta_instance_t *inst, uint32_t length)
char terminalCmd[16]; char terminalCmd[16];
size_t size; size_t size;
length = SHELLMATTA_MAX (length, (inst->inputCount - inst->cursor)); length = SHELLMATTA_MIN (length, (inst->inputCount - inst->cursor));
if (length > 0u) if (length > 0u)
{ {
terminalCmd[0] = '\e'; terminalCmd[0] = '\e';