data tree FEATURE support white-spaces in "keys" predicate
diff --git a/src/tree_data.c b/src/tree_data.c
index 35d9347..8ca974d 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -479,6 +479,9 @@
ly_keys_parse_next(char **next_key, char **key_name)
{
char *ptr, *ptr2, *val, quot;
+ const char *pref;
+ size_t pref_len, key_len;
+ int have_equal = 0;
ptr = *next_key;
@@ -486,15 +489,40 @@
LY_CHECK_GOTO(ptr[0] != '[', error);
++ptr;
- /* key name */
- ptr2 = strchr(ptr, '=');
- LY_CHECK_GOTO(!ptr2, error);
+ /* skip WS */
+ while (isspace(ptr[0])) {
+ ++ptr;
+ }
- *key_name = ptr;
- ptr2[0] = '\0';
+ /* key name without prefix */
+ LY_CHECK_GOTO(ly_parse_nodeid((const char **)&ptr, &pref, &pref_len, (const char **)key_name, &key_len), error);
+ if (pref) {
+ goto error;
+ }
- /* \0, was '=' */
- ptr = ptr2 + 1;
+ /* terminate it */
+ LY_CHECK_GOTO((ptr[0] != '=') && !isspace(ptr[0]), error);
+ if (ptr[0] == '=') {
+ have_equal = 1;
+ }
+ ptr[0] = '\0';
+ ++ptr;
+
+ if (!have_equal) {
+ /* skip WS */
+ while (isspace(ptr[0])) {
+ ++ptr;
+ }
+
+ /* '=' */
+ LY_CHECK_GOTO(ptr[0] != '=', error);
+ ++ptr;
+ }
+
+ /* skip WS */
+ while (isspace(ptr[0])) {
+ ++ptr;
+ }
/* quote */
LY_CHECK_GOTO((ptr[0] != '\'') && (ptr[0] != '\"'), error);
@@ -510,6 +538,11 @@
/* \0, was quote */
ptr = ptr2 + 1;
+ /* skip WS */
+ while (isspace(ptr[0])) {
+ ++ptr;
+ }
+
/* "]" */
LY_CHECK_GOTO(ptr[0] != ']', error);
++ptr;