Soft'N'Design Software
/
projects
/
morep.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
21ca593
)
correct string parsing for array
author
Mazet Laurent
<laurent.mazet@thalesgroup.com>
Tue, 6 May 2025 15:28:00 +0000
(17:28 +0200)
committer
Mazet Laurent
<laurent.mazet@thalesgroup.com>
Tue, 6 May 2025 15:28:00 +0000
(17:28 +0200)
parse.c
patch
|
blob
|
blame
|
history
diff --git
a/parse.c
b/parse.c
index 27a07f4c75cb4998e781e0cf04c45cf23d93d2e7..e9063ded3923cddc1aa79afb0eb15da2220853da 100644
(file)
--- a/
parse.c
+++ b/
parse.c
@@
-55,7
+55,15
@@
int parse_array (char *str, uint8_t *buffer, int maxlen)
VERBOSE (morep, WARNING, PRINTF ("string too large (%d > %d) for '%s'\n", len, maxlen, str));
len = maxlen;
}
- memcpy (buffer, str + 1, len);
+ int j = 0;
+ for (int i = 1; i < len + 1; i++, j++) {
+ if ((str[i] == '\\') && (str[i + 1] == ' ')) {
+ i++;
+ }
+ buffer[j] = str[i];
+ }
+ len = j;
+ VERBOSE (morep, TRACE, buffer[len] = '\0'; PRINTF ("string[%d]: '%s'\n", len, buffer));
} else {
VERBOSE (morep, ERROR, PRINTF ("incomplet string '%s'\n", str));
}