Skip to content
Permalink
Browse files

Merge pull request #2988 from PhilippGackstatter/rename_keyisdirectbelow

Rename keyIsDirectBelow to keyIsDirectlyBelow
  • Loading branch information...
markus2330 committed Oct 6, 2019
2 parents fa6d959 + 79f4da4 commit dd4daf138e565f58d3b5a1b4c28ccb99e057fef5
@@ -141,6 +141,7 @@ The text below summarizes updates to the [C (and C++)-based libraries](https://w
- `kdbconfig.h` is no longer included in the installed headers. This is because it could cause conflicts with other
`config.h`-type headers from applications. _(Klemens Böswirth)_
- `ksAppendKey`: state that it only fail on memory problems. _(Markus Raab)_
- `keyIsDirectBelow` was renamed to `keyIsDirectlyBelow`. _(Philipp Gackstatter)_

### Opts

@@ -71,7 +71,7 @@ Remove/Refactor/Rename obsolete/not needed methods:
- keyNeedSync
- keyIsBelow
- keyIsBelowOrSame
- keyIsDirectBelow
- keyIsDirectlyBelow
- keyIsInactive
- keyIsBinary
- keyIsString
@@ -109,7 +109,7 @@ int below_a (Key * check)
}
int direct_below_a (Key * check)
{
return keyIsDirectBelow (global_a, check);
return keyIsDirectlyBelow (global_a, check);
}

int sum_helper (Key * check)
@@ -65,7 +65,7 @@ int main (void)
printf ("Found key %s\n", keyName (found));
while ((cur = ksNext (ks)) != 0)
{ /* Iterates over all keys direct below and prints their name */
if (keyIsDirectBelow (found, cur) == 0) break;
if (keyIsDirectlyBelow (found, cur) == 0) break;
printf ("%s\n", keyName (cur));
}

@@ -1723,11 +1723,11 @@ inline bool Key::isBelowOrSame (const Key & k) const
* @param k the other key
* @return true if our key is direct below k
*
* @copydoc keyIsDirectBelow
* @copydoc keyIsDirectlyBelow
*/
inline bool Key::isDirectBelow (const Key & k) const
{
int ret = ckdb::keyIsDirectBelow (k.getKey (), key);
int ret = ckdb::keyIsDirectlyBelow (k.getKey (), key);
if (ret == -1) return false;
return ret;
}
@@ -514,5 +514,5 @@ gboolean gelektra_key_isbeloworsame (const GElektraKey * key, const GElektraKey

gboolean gelektra_key_isdirectbelow (const GElektraKey * key, const GElektraKey * other)
{
return keyIsDirectBelow (other->key, key->key);
return keyIsDirectlyBelow (other->key, key->key);
}
@@ -126,7 +126,7 @@ void init (void)
ksNext (ks); // skip head
while ((key = ksNext (ks)) != NULL)
{
if (!keyIsDirectBelow (parentKey, key)) continue;
if (!keyIsDirectlyBelow (parentKey, key)) continue;
Node * tmp = calloc (1, sizeof (Node));
tmp->key = createAbsolutePath (keyBaseName (key), cwd);
if (!strcmp (keyString (key), ""))
@@ -77,7 +77,7 @@

int keyIsBelowOrSame(Pointer key, Pointer check);

int keyIsDirectBelow(Pointer key, Pointer check);
int keyIsDirectlyBelow(Pointer key, Pointer check);

int keyIsInactive(Pointer key);

@@ -577,7 +577,7 @@ public boolean isDirectBelow(final Key other) {
if (other == null) {
throw new IllegalArgumentException("other should be a key, not null");
}
return Elektra.INSTANCE.keyIsDirectBelow(other.get(), get()) == 1;
return Elektra.INSTANCE.keyIsDirectlyBelow(other.get(), get()) == 1;
}

/**
@@ -260,7 +260,7 @@ public void test_keyIsBelowOrSame_shouldPass() {
}

@Test
public void test_keyIsDirectBelow_shouldPass() {
public void test_keyIsDirectlyBelow_shouldPass() {
final Key key = Key.create(KEY_10_NAME, KEY_10_VALUE);
final Key key2 = Key.create(KEY_11_NAME, KEY_11_VALUE);
final Key key3 = Key.create(KEY_12_NAME, KEY_12_VALUE);
@@ -219,16 +219,16 @@ pub trait ReadableKey: AsRef<elektra_sys::Key> + PartialEq + Eq + PartialOrd + O
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let key = StringKey::new("user/sw/app")?;
/// let key2 = StringKey::new("user/sw/app/key")?;
/// assert!(key2.is_direct_below(&key));
/// assert!(key2.is_directly_below(&key));
/// #
/// # Ok(())
/// # }
/// ```
fn is_direct_below(&self, other: &Self) -> bool
fn is_directly_below(&self, other: &Self) -> bool
where
Self: Sized,
{
unsafe { elektra_sys::keyIsDirectBelow(other.as_ref(), self.as_ref()) == 1 }
unsafe { elektra_sys::keyIsDirectlyBelow(other.as_ref(), self.as_ref()) == 1 }
}

/// Returns true if the key is inactive.
@@ -164,7 +164,7 @@ int keyNeedSync(const Key *key);

int keyIsBelow(const Key *key, const Key *check);
int keyIsBelowOrSame(const Key *key, const Key *check);
int keyIsDirectBelow(const Key *key, const Key *check);
int keyIsDirectlyBelow(const Key *key, const Key *check);

int keyIsInactive(const Key *key);

@@ -202,7 +202,7 @@ int elektraArrayDecName (Key * key)
static int arrayFilter (const Key * key, void * argument)
{
const Key * arrayParent = (const Key *) argument;
return keyIsDirectBelow (arrayParent, key) && elektraArrayValidateName (key) > 0;
return keyIsDirectlyBelow (arrayParent, key) && elektraArrayValidateName (key) > 0;
}


@@ -208,7 +208,7 @@ int keyIsUser (const Key * key)
* @retval 1 if check is below key
* @retval 0 if it is not below or if it is the same key
* @retval -1 if key or check is null
* @see keySetName(), keyGetName(), keyIsDirectBelow()
* @see keySetName(), keyGetName(), keyIsDirectlyBelow()
* @ingroup keytest
*
*/
@@ -309,7 +309,7 @@ does not return true, because there is only an indirect relation
* @ingroup keytest
*
*/
int keyIsDirectBelow (const Key * key, const Key * check)
int keyIsDirectlyBelow (const Key * key, const Key * check)
{
if (key == NULL || check == NULL)
{
@@ -480,7 +480,7 @@ int keyRel (const Key * key, const Key * check)
if (!key->key || !check->key) return -1;

if (!keyCmp (key, check)) return 0;
if (keyIsDirectBelow (key, check)) return 1;
if (keyIsDirectlyBelow (key, check)) return 1;
if (keyIsBelow (key, check)) return 2;
if (keyIsUser (key) && keyIsUser (check)) return -3;
if (keyIsSystem (key) && keyIsSystem (check)) return -3;
@@ -75,7 +75,7 @@ libelektra_0.8 {
keyIsBelow;
keyIsBelowOrSame;
keyIsBinary;
keyIsDirectBelow;
keyIsDirectlyBelow;
keyIsInactive;
keyIsString;
keyName;
@@ -103,8 +103,8 @@ static KeySet * getGlobKeys (Key * parentKey, KeySet * keys, enum GlobDirection
while ((k = ksNext (keys)) != 0)
{
/* use only glob keys for the current direction */
if (keyIsDirectBelow (userGlobConfig, k) || keyIsDirectBelow (systemGlobConfig, k) ||
keyIsDirectBelow (userDirGlobConfig, k) || keyIsDirectBelow (systemDirGlobConfig, k))
if (keyIsDirectlyBelow (userGlobConfig, k) || keyIsDirectlyBelow (systemGlobConfig, k) ||
keyIsDirectlyBelow (userDirGlobConfig, k) || keyIsDirectlyBelow (systemDirGlobConfig, k))
{
keySetMeta (k, "glob/flags", getGlobFlags (keys, k));

@@ -157,7 +157,7 @@ int elektraHostsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa
Key * key = keyArray[i];

/* only process canonical name keys */
if (!keyIsDirectBelow (ipv4Base, key) && !keyIsDirectBelow (ipv6Base, key)) continue;
if (!keyIsDirectlyBelow (ipv4Base, key) && !keyIsDirectlyBelow (ipv6Base, key)) continue;

writeLineComments (key, fp);
writeHostsEntry (key, returned, fp);
@@ -1028,7 +1028,7 @@ void arrayHandler (Key * parentKey, Key * newKey, Key * cur, Key * sectionKey, K
keySetMeta (newKey, "internal/ini/key/last", 0);
keySetMeta (newKey, "internal/ini/key/number", 0);
}
else if (keyIsDirectBelow (parentKey, newKey))
else if (keyIsDirectlyBelow (parentKey, newKey))
{
if (!hasGlobalRoot (parentKey, newKS))
{
@@ -1056,7 +1056,7 @@ void insertIntoKS (Key * parentKey, Key * cur, KeySet * newKS, IniPluginConfig *
if (!keyGetMeta (cur, "internal/ini/section") && !keyIsBinary (cur))
{
keyAddName (sectionKey, "..");
if (keyIsDirectBelow (parentKey, cur))
if (keyIsDirectlyBelow (parentKey, cur))
{
if (!hasGlobalRoot (parentKey, newKS))
{
@@ -305,7 +305,7 @@ static int writeKS (KeySet * returned, Key * parentKey, SortBy index)
ksRewind (returned);
while ((cur = ksNext (returned)) != NULL)
{
if (!keyIsDirectBelow (parentKey, cur)) continue;
if (!keyIsDirectlyBelow (parentKey, cur)) continue;
KeySet * cutKS = ksCut (returned, cur);
struct passwd * pwd = KStoPasswd (cutKS, index);
if (validatepwent (pwd) == -1)
@@ -227,7 +227,7 @@ static int filterAlternatives (const Key * key, void * argument)
const char * metaValue = metaKey != NULL ? keyString (metaKey) : NULL;

const Key * referenceParent = (const Key *) argument;
return metaValue != NULL && keyIsDirectBelow (referenceParent, key) && strcmp (metaValue, CHECK_REFERNCE_VALUE_ALTERNATIVE) == 0;
return metaValue != NULL && keyIsDirectlyBelow (referenceParent, key) && strcmp (metaValue, CHECK_REFERNCE_VALUE_ALTERNATIVE) == 0;
}

static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * parentKey)
@@ -700,7 +700,7 @@ static void validateWildcardSubs (KeySet * ks, Key * key)
Key * cur;
while ((cur = ksNext (subKeys)) != NULL)
{
if (keyIsDirectBelow (parent, cur))
if (keyIsDirectlyBelow (parent, cur))
{
if (elektraArrayValidateBaseNameString (keyBaseName (cur)) > 0)
{

0 comments on commit dd4daf1

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