Re: RTEMS | cpukit/shell supports using the tab key to auto-complete commands (!495)
Gedare Bloom (@gedare)
gitlab at rtems.org
Tue Jun 10 15:14:25 UTC 2025
Gedare Bloom started a new discussion on cpukit/libmisc/shell/shell.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/495#note_123325
> + * Find the boundaries of the current word in a command line
> + */
> +static void rtems_shell_find_word_bounds(char *line, int col, char **word_start, int *word_len) {
> + *word_start = line + col;
> + while (*word_start > line && !isspace((unsigned char)*(*word_start - 1))) {
> + (*word_start)--;
> + }
> + *word_len = (line + col) - *word_start;
> +}
> +
> +/* Calculate the common prefix length between two strings */
> +static int rtems_shell_calculate_common_prefix(const char *str1, const char *str2, int start_pos, int current_common_len) {
> + int i;
> + int max_len = current_common_len;
> +
> + for (i = start_pos; i < current_common_len && i < strlen(str2); i++) {
should not call `strlen` in a loop. calculate it before the loop.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/495#note_123325
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250610/e2ecbb89/attachment-0001.htm>
More information about the bugs
mailing list