Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/include/microrl/microrl_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ extern "C" {
#define MICRORL_CFG_PROMPT_COLOR MICRORL_COLOR_GREEN
#endif

/**
* \brief Disable the tokenizer to get the full command in the first slot of the argv array
*/
#ifndef MICRORL_CFG_DISABLE_TOKENIZER
#define MICRORL_CFG_DISABLE_TOKENIZER 0
#endif

/**
* \brief Enable it, if you want to use completion functional, also set completion callback in you code.
* Completion functional calls 'copmletion' callback if user press 'TAB'.
Expand Down Expand Up @@ -264,7 +271,7 @@ extern "C" {

#define MICRORL_VERSION_MAJOR 2
#define MICRORL_VERSION_MINOR 6
#define MICRORL_VERSION_PATCH 0
#define MICRORL_VERSION_PATCH 1

#ifdef __cplusplus
}
Expand Down
22 changes: 16 additions & 6 deletions src/microrl/microrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,13 @@ static void prv_terminal_print_line(microrl_t* mrl, int32_t pos, uint8_t reset)
* \param[in,out] idx_ptr: Pointer to the current record
*/
MICRORL_CFG_STATIC_INLINE void prv_hist_next_record(microrl_hist_rbuf_t* rbuf_ptr, size_t* idx_ptr) {
while (rbuf_ptr->ring_buf[++(*idx_ptr)] != '\0') {
do {
++(*idx_ptr);

if (*idx_ptr >= MICRORL_ARRAYSIZE(rbuf_ptr->ring_buf)) {
*idx_ptr -= MICRORL_ARRAYSIZE(rbuf_ptr->ring_buf);
if (rbuf_ptr->ring_buf[*idx_ptr] == '\0') {
break;
}
}
}
} while (rbuf_ptr->ring_buf[*idx_ptr] != '\0');
}

/**
Expand Down Expand Up @@ -480,7 +479,10 @@ static size_t prv_hist_restore_line(microrl_hist_rbuf_t* rbuf_ptr, char* line_st
prv_hist_next_record(rbuf_ptr, &idx);
}

++idx; /* Move position from `\0` marker */
++idx; /* Move position from `\0` marker and take care of wrap-around*/
if (idx >= MICRORL_ARRAYSIZE(rbuf_ptr->ring_buf)) {
idx -= MICRORL_ARRAYSIZE(rbuf_ptr->ring_buf);
}

size_t rec_len = 0;
size_t k = idx;
Expand Down Expand Up @@ -665,7 +667,15 @@ static microrlr_t prv_handle_newline(microrl_t* mrl) {
}
#endif /* MICRORL_CFG_USE_ECHO_OFF */

#if MICRORL_CFG_DISABLE_TOKENIZER
tkn_str_arr[0] = mrl->cmdline_str;
tkn_cnt = 1;
status = microrlOK;
(void)prv_cmdline_buf_split; /*avoid declared but never referenced warning */
#else
status = prv_cmdline_buf_split(mrl, tkn_str_arr, &tkn_cnt, mrl->cmdlen);
#endif /* MICRORL_CFG_DISABLE_TOKENIZER */

if (status == microrlOK) {
#if MICRORL_CFG_USE_COMMAND_HOOKS
int exec_status = 0;
Expand Down