projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow string arguments to be quote within "".
[bertos.git]
/
bertos
/
mware
/
parser.c
diff --git
a/bertos/mware/parser.c
b/bertos/mware/parser.c
index 217cc6c113420b8610d54309e2bee286645a2cad..2197d8482391b8616ab23fcb755078440ece50c0 100644
(file)
--- a/
bertos/mware/parser.c
+++ b/
bertos/mware/parser.c
@@
-89,17
+89,31
@@
DECLARE_HASHTABLE_STATIC(commands, CONFIG_MAX_COMMANDS_NUMBER, get_key_from_comm
* \return True if a word was extracted, false if we got to the end
* of the string without extracting any word.
*/
* \return True if a word was extracted, false if we got to the end
* of the string without extracting any word.
*/
-
static
bool get_word(const char **begin, const char **end)
+bool get_word(const char **begin, const char **end)
{
const char *cur = *end;
{
const char *cur = *end;
+ bool open_quote = false;
while ((*cur == ' ' || *cur == '\t') && *cur)
++cur;
while ((*cur == ' ' || *cur == '\t') && *cur)
++cur;
+ if (*cur == '"')
+ open_quote = true;
+
*begin = cur;
*begin = cur;
- while ((*cur != ' ' && *cur != '\t') && *cur)
+ if (open_quote)
+ {
++cur;
++cur;
+ while (*cur != '"' && *cur)
+ ++cur;
+ if (*cur != '"')
+ return false;
+ ++cur;
+ }
+ else
+ while ((*cur != ' ' && *cur != '\t') && *cur)
+ ++cur;
*end = cur;
*end = cur;
@@
-139,6
+153,12
@@
static bool parseArgs(const char *fmt, const char *input, parms argv[])
case 's':
(*argv).str.p = begin;
(*argv).str.sz = end - begin;
case 's':
(*argv).str.p = begin;
(*argv).str.sz = end - begin;
+ /* Remove the quotes from argument */
+ if (*begin == '"' && *(end - 1) == '"')
+ {
+ (*argv).str.p += 1;
+ (*argv).str.sz -= 2;
+ }
argv++;
break;
argv++;
break;