Skip to content
Permalink
Browse files

Rename new occurences of keyIsDirectBelow

  • Loading branch information...
PhilippGackstatter committed Oct 7, 2019
1 parent 76a624e commit 9de4226516a5f123350e729bb3e05ceaa5a7697e
@@ -187,7 +187,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global

while ((cur = ksNext (elektraConfig)) != 0)
{
if (keyIsDirectBelow (root, cur) == 1)
if (keyIsDirectlyBelow (root, cur) == 1)
{
// direct below root key
KeySet * cut = ksCut (elektraConfig, cur);
@@ -61,7 +61,7 @@ int mountOpen (KDB * kdb, KeySet * config, KeySet * modules, Key * errorKey)
int ret = 0;
while ((cur = ksNext (config)) != 0)
{
if (keyIsDirectBelow (root, cur) == 1)
if (keyIsDirectlyBelow (root, cur) == 1)
{
KeySet * cut = ksCut (config, cur);
Backend * backend = backendOpen (cut, modules, kdb->global, errorKey);
@@ -398,7 +398,7 @@ int mountGlobals (KDB * kdb, KeySet * keys, KeySet * modules, Key * errorKey)
while ((cur = ksNext (global)) != NULL)
{
// the cutpoints for the plugin configs are always directly below the "root", ignore everything else
if (keyIsDirectBelow (root, cur) != 1) continue;
if (keyIsDirectlyBelow (root, cur) != 1) continue;

char * placement = elektraStrDup (keyBaseName (cur));

@@ -432,7 +432,7 @@ int mountGlobals (KDB * kdb, KeySet * keys, KeySet * modules, Key * errorKey)
Key * curSubPosition;
while ((curSubPosition = ksNext (subPositions)) != NULL)
{
if (keyIsDirectBelow (placementKey, curSubPosition) != 1) continue;
if (keyIsDirectlyBelow (placementKey, curSubPosition) != 1) continue;
const char * subPlacement = keyBaseName (curSubPosition);

for (GlobalpluginSubPositions j = 0; j < NR_GLOBAL_SUBPOSITIONS; ++j)
@@ -155,7 +155,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen

while ((cur = ksNext (config)) != 0)
{
if (keyIsDirectBelow (root, cur) == 1)
if (keyIsDirectlyBelow (root, cur) == 1)
{
char * pluginName = 0;
char * referenceName = 0;
@@ -635,7 +635,7 @@ static int csvWrite (KeySet * returned, Key * parentKey, KeySet * exportKS, Key
ksRewind (returned);
while ((cur = ksNext (returned)) != NULL)
{
if (keyIsDirectBelow (parentKey, cur) != 1) continue;
if (keyIsDirectlyBelow (parentKey, cur) != 1) continue;
colCounter = 0;
if (useHeader)
{
@@ -299,7 +299,7 @@ int elektraHexcodeOpen (Plugin * handle, Key * key ELEKTRA_UNUSED)
while ((cur = ksNext (config)) != 0)
{
/* ignore all keys not direct below */
if (keyIsDirectBelow (root, cur) == 1)
if (keyIsDirectlyBelow (root, cur) == 1)
{
/* ignore invalid size */
if (keyGetBaseNameSize (cur) != 3) continue;
@@ -101,7 +101,7 @@ static int listParseConfiguration (Placements * placements, KeySet * config)
int rc = 0;
while ((cur = ksNext (cutKS)) != NULL)
{
if (keyIsDirectBelow (key, cur) != 1)
if (keyIsDirectlyBelow (key, cur) != 1)
{
continue;
}
@@ -119,39 +119,39 @@ static void test_directbelow (void)

keySetName (k1, "user");
keySetName (k2, "user/a");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system");
keySetName (k2, "system/a");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "user");
keySetName (k2, "user/longer_name");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system");
keySetName (k2, "system/longer_name");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "user/a");
keySetName (k2, "user/a/a");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system/a");
keySetName (k2, "system/a/a");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system/a\\/a");
keySetName (k2, "system/a\\/a/a");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system/a\\/a\\/a");
keySetName (k2, "system/a\\/a\\/a/b");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");

keySetName (k1, "system/a\\/a\\/a");
keySetName (k2, "system/a\\/a\\/a/b");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be direct below");


keyDel (k1);
@@ -167,7 +167,7 @@ static void test_below (void)
keySetName (k1, "user/tests/simple");
keySetName (k2, "user/tests/simple/below");
succeed_if (keyCmp (k1, k2) == 0 || keyIsBelow (k1, k2) == 1, "should be below");
succeed_if (keyIsDirectBelow (k1, k2) == 1, "should be below");
succeed_if (keyIsDirectlyBelow (k1, k2) == 1, "should be below");

keySetName (k1, "user");
keySetName (k2, "user/a/a");
@@ -210,21 +210,21 @@ static void test_examples (void)

keySetName (key, "user/key/folder");
keySetName (check, "user/key/folder/child");
succeed_if (keyIsDirectBelow (key, check) == 1, "should be direct below");
succeed_if (keyIsDirectlyBelow (key, check) == 1, "should be direct below");

keySetName (key, "user/key/folder");
keySetName (check, "user/key/folder/any/depth/deeper/grand-child");
succeed_if (keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 1, "should be below (but not direct)");
succeed_if (keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 1, "should be below (but not direct)");
succeed_if (keyIsBelow (key, check) == 1, "should be below");
succeed_if (keyCmp (key, check) == 0 || keyIsBelow (key, check) == 1, "should be the same or below");

keySetName (key, "user/key/folder");
keySetName (check, "user/notsame/folder");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "key is not below");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "key is not below");

keySetName (key, "user/key/folder");
keySetName (check, "system/notsame/folder");
int has_no_rel = keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
int has_no_rel = keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
succeed_if (has_no_rel == 1, "not in the same namespace");

keyDel (key);
@@ -239,22 +239,22 @@ static void test_hierarchy (void)

keySetName (key, "user/key/folder/key");
keySetName (check, "user/other/folder/key");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "should be same");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "should be same");

keySetName (key, "system/key/folder/key");
keySetName (check, "system/other/folder/key");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "should be same");
succeed_if (keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0, "should be same");

keySetName (key, "user/key/folder/key");
keySetName (check, "system/other/folder/key");

int has_no_rel = keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
int has_no_rel = keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
succeed_if (has_no_rel == 1, "should be different (1)");

keySetName (key, "system/key/folder/key");
keySetName (check, "user/other/folder/key");

has_no_rel = keyCmp (key, check) != 0 && keyIsDirectBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
has_no_rel = keyCmp (key, check) != 0 && keyIsDirectlyBelow (key, check) == 0 && keyIsBelow (key, check) == 0;
succeed_if (has_no_rel == 1, "should be different (2)");
keyDel (key);
keyDel (check);

0 comments on commit 9de4226

Please sign in to comment.
You can’t perform that action at this time.