Skip to content

Commit a5c6739

Browse files
committed
Merge branch 'develop'
2 parents 45b1d75 + aea252d commit a5c6739

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3-
## v1.0.0
3+
## Develop
4+
5+
- Fix wrong parsing of command names
46

7+
## v1.0.0
58

9+
- Initial release

lwshell/src/lwshell/lwshell.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
#include "lwshell/lwshell.h"
3636

3737
/* Default characters */
38-
#define LWSHELL_ASCII_NULL 0x00 /*!< Null character */
39-
#define LWSHELL_ASCII_BACKSPACE 0x08 /*!< Backspace */
40-
#define LWSHELL_ASCII_LF 0x0A /*!< Line feed */
41-
#define LWSHELL_ASCII_CR 0x0D /*!< Carriage return */
42-
#define LWSHELL_ASCII_DEL 0x7F /*!< Delete character */
43-
#define LWSHELL_ASCII_SPACE 0x20 /*!< Space character */
38+
#define LWSHELL_ASCII_NULL 0x00/*!< Null character */
39+
#define LWSHELL_ASCII_BACKSPACE 0x08/*!< Backspace */
40+
#define LWSHELL_ASCII_LF 0x0A/*!< Line feed */
41+
#define LWSHELL_ASCII_CR 0x0D/*!< Carriage return */
42+
#define LWSHELL_ASCII_DEL 0x7F/*!< Delete character */
43+
#define LWSHELL_ASCII_SPACE 0x20/*!< Space character */
4444

4545
#if LWSHELL_CFG_USE_OUTPUT
4646
#define LW_OUTPUT(lw, str) do { if ((lw)->out_fn != NULL && (str) != NULL) { (lw)->out_fn((str), (lw)); }} while (0)
@@ -121,7 +121,7 @@ prv_parse_input(lwshell_t* lw) {
121121
/* Check if it starts with quote to handle escapes */
122122
if (*str == '"') {
123123
++str;
124-
lw->argv[lw->argc++] = str; /* Set start of argument after quotes */
124+
lw->argv[lw->argc++] = str; /* Set start of argument after quotes */
125125

126126
/* Process until end of quote */
127127
while (*str != '\0') {
@@ -139,10 +139,10 @@ prv_parse_input(lwshell_t* lw) {
139139
}
140140
}
141141
} else {
142-
lw->argv[lw->argc++] = str; /* Set start of argument directly on character */
142+
lw->argv[lw->argc++] = str; /* Set start of argument directly on character */
143143
while ((*str != ' ' && *str != '\0')) {
144-
if (*str == '"') { /* Quote should not be here... */
145-
*str = '\0'; /* ...add NULL termination to end token */
144+
if (*str == '"') { /* Quote should not be here... */
145+
*str = '\0'; /* ...add NULL termination to end token */
146146
}
147147
++str;
148148
}
@@ -161,7 +161,8 @@ prv_parse_input(lwshell_t* lw) {
161161
lwshell_cmd_t* c = NULL;
162162
/* Process all commands */
163163
for (size_t i = 0; i < cmds_cnt; ++i) {
164-
if (strncmp(cmds[i].name, lw->argv[0], strlen(lw->argv[0])) == 0) {
164+
if (strlen(lw->argv[0]) == strlen(cmds[i].name)
165+
&& strncmp(cmds[i].name, lw->argv[0], strlen(lw->argv[0])) == 0) {
165166
c = &cmds[i];
166167
break;
167168
}

0 commit comments

Comments
 (0)