Skip to content

Commit

Permalink
Merge pull request #2701 from PhilippGackstatter/yajl_array_dirdata
Browse files Browse the repository at this point in the history
Yajl: Remove additional dirdata entry in arrays
  • Loading branch information
markus2330 committed May 19, 2019
2 parents 27b31c2 + b214db1 commit 4a3c163
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion doc/news/_preparation_next_release.md
Expand Up @@ -84,12 +84,14 @@ The following section lists news about the [modules](https://www.libelektra.org/

### YAJL

- The plugin no allows setting a value to the mountpoint. This is represented as a top level value in JSON if no other key is present. _(Philipp Gackstatter)_
- The plugin now allows setting a value to the mountpoint. This is represented as a top level value in JSON if no other key is present. _(Philipp Gackstatter)_

- The plugin no longer lists empty parent keys with `kdb ls`. _(Philipp Gackstatter)_

- The plugin signifies arrays with the metakey array according to the [array decision](../../doc/decisions/array.md). _(Philipp Gackstatter)_

- The plugin no longer produces additional `___dirdata` entries for empty array keys. See also issue [#2477](https://github.com/ElektraInitiative/libelektra/issues/2477). _(Philipp Gackstatter)_

### YAMBi

- [YAMBi](https://www.libelektra.org/plugins/yambi) is now able detect multiple syntax errors in a file. _(René Schwaiger)_
Expand Down
1 change: 0 additions & 1 deletion src/plugins/yajl/README.md
Expand Up @@ -135,7 +135,6 @@ kdb file /tests/yajl | xargs cat
#> "key": "value",
#> "number": 1337,
#> "piggy": [
#> "___dirdata: ",
#> "straw",
#> "sticks",
#> "bricks"
Expand Down
11 changes: 9 additions & 2 deletions src/plugins/yajl/testmod_yajl.c
Expand Up @@ -188,6 +188,7 @@ KeySet *getArrayKeys(void)
KeySet *ks = ksNew(30,
keyNew("user/tests/yajl/array",
KEY_META, "array", "#_12",
KEY_META, "binary", "",
KEY_END),
keyNew("user/tests/yajl/array/#0",
KEY_VALUE, "true",
Expand Down Expand Up @@ -257,7 +258,10 @@ KeySet *getArrayKeys(void)
KeySet *getOpenICCKeys(void)
{
KeySet *ks = ksNew(60,
keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera", KEY_META, "array", "#1", KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera",
KEY_META, "array", "#1",
KEY_META, "binary", "",
KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera/#0/prefix",
KEY_VALUE, "EXIF_",
KEY_END),
Expand Down Expand Up @@ -307,7 +311,10 @@ keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera/#1/expire_date",
// keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera/#1/automatic_assignment",
keyNew("user/tests/yajl/org/freedesktop/openicc/device/camera/#1/automatic_assigment",
KEY_VALUE, "1", KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/monitor", KEY_META, "array", "#1", KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/monitor",
KEY_META, "array", "#1",
KEY_META, "binary", "",
KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/monitor/#0/prefix",
KEY_VALUE, "EDID_", KEY_END),
keyNew("user/tests/yajl/org/freedesktop/openicc/device/monitor/#0/EDID_mnft_id",
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/yajl/yajl_parse.c
Expand Up @@ -251,7 +251,7 @@ static int elektraYajlParseStartArray (void * ctx)
}

/**
* @brief Remove all non-leaf keys
* @brief Remove all non-leaf keys except for arrays
*
* @param returned to remove the keys from
*/
Expand All @@ -278,6 +278,11 @@ static void elektraYajlParseSuppressNonLeafKeys (KeySet * returned)
keyDel (ksLookup (returned, cur, KDB_O_POP));
ksSetCursor (returned, cursor);
}
else
{
// Set array key to NULL to avoid empty ___dirdata entries
keySetBinary (cur, NULL, 0);
}
}

keyDel (peekDup);
Expand Down

0 comments on commit 4a3c163

Please sign in to comment.