MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / msh_split

Function msh_split

components/finsh/msh.c:152–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150#endif /* MSH_USING_BUILT_IN_COMMANDS */
151
152static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
153{
154 char *ptr;
155 rt_size_t position;
156 rt_size_t argc;
157 rt_size_t i;
158
159 ptr = cmd;
160 position = 0;
161 argc = 0;
162
163 while (position < length)
164 {
165 /* strip bank and tab */
166 while ((*ptr == ' ' || *ptr == '\t') && position < length)
167 {
168 *ptr = '\0';
169 ptr ++;
170 position ++;
171 }
172
173 if (argc >= FINSH_ARG_MAX)
174 {
175 rt_kprintf("Too many args ! We only Use:\n");
176 for (i = 0; i < argc; i++)
177 {
178 rt_kprintf("%s ", argv[i]);
179 }
180 rt_kprintf("\n");
181 break;
182 }
183
184 if (position >= length) break;
185
186 /* handle string */
187 if (*ptr == '"')
188 {
189 ptr ++;
190 position ++;
191 argv[argc] = ptr;
192 argc ++;
193
194 /* skip this string */
195 while (*ptr != '"' && position < length)
196 {
197 if (*ptr == '\\')
198 {
199 if (*(ptr + 1) == '"')
200 {
201 ptr ++;
202 position ++;
203 }
204 }
205 ptr ++;
206 position ++;
207 }
208 if (position >= length) break;
209

Callers 2

_msh_exec_cmdFunction · 0.85
_msh_exec_lwpFunction · 0.85

Calls 1

rt_kprintfFunction · 0.85

Tested by

no test coverage detected