| 416 | } |
| 417 | |
| 418 | static void shell_push_history(struct finsh_shell *shell) |
| 419 | { |
| 420 | if (shell->line_position != 0) |
| 421 | { |
| 422 | /* push history */ |
| 423 | if (shell->history_count >= FINSH_HISTORY_LINES) |
| 424 | { |
| 425 | /* if current cmd is same as last cmd, don't push */ |
| 426 | if (memcmp(&shell->cmd_history[FINSH_HISTORY_LINES - 1], shell->line, FINSH_CMD_SIZE)) |
| 427 | { |
| 428 | /* move history */ |
| 429 | int index; |
| 430 | for (index = 0; index < FINSH_HISTORY_LINES - 1; index ++) |
| 431 | { |
| 432 | rt_memcpy(&shell->cmd_history[index][0], |
| 433 | &shell->cmd_history[index + 1][0], FINSH_CMD_SIZE); |
| 434 | } |
| 435 | rt_memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE); |
| 436 | rt_memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position); |
| 437 | |
| 438 | /* it's the maximum history */ |
| 439 | shell->history_count = FINSH_HISTORY_LINES; |
| 440 | } |
| 441 | } |
| 442 | else |
| 443 | { |
| 444 | /* if current cmd is same as last cmd, don't push */ |
| 445 | if (shell->history_count == 0 || memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, FINSH_CMD_SIZE)) |
| 446 | { |
| 447 | shell->current_history = shell->history_count; |
| 448 | rt_memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); |
| 449 | rt_memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position); |
| 450 | |
| 451 | /* increase count and set current history position */ |
| 452 | shell->history_count ++; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | shell->current_history = shell->history_count; |
| 457 | } |
| 458 | #endif |
| 459 | |
| 460 | #if defined(FINSH_USING_WORD_OPERATION) |
no test coverage detected