From ae419e6f4e5dfdc9aec40fb0c8ada3a6d39cccce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Sat, 20 Feb 2021 18:54:03 +0100 Subject: [PATCH] replace keyDupOld placeholder with new keyDup --- benchmarks/benchmarks.c | 4 +- examples/functional.c | 2 +- examples/keyset.c | 8 +- src/bindings/cpp/include/key.hpp | 6 +- src/bindings/glib/gelektra-key.c | 6 +- src/bindings/glib/gelektra-key.h | 4 +- src/bindings/glib/tests/testglib_key.c | 4 +- src/bindings/intercept/fs/intercept.c | 2 +- .../src/main/java/org/libelektra/Elektra.java | 4 +- .../src/main/java/org/libelektra/Key.java | 25 ++++- src/bindings/rust/elektra/src/key.rs | 26 +++-- src/include/kdb.h.in | 10 -- src/libs/ease/array.c | 3 +- src/libs/elektra/backend.c | 2 +- src/libs/elektra/kdb.c | 12 +-- src/libs/elektra/keyset.c | 10 +- src/libs/elektra/mount.c | 8 +- src/libs/elektra/plugin.c | 2 +- src/libs/elektra/split.c | 6 +- src/libs/globbing/globbing.c | 2 +- src/libs/highlevel/elektra.c | 6 +- src/libs/highlevel/elektra_array_value.c | 4 +- src/libs/highlevel/elektra_value.c | 2 +- src/libs/merge/kdbmerge.c | 6 +- src/libs/meta/meta.c | 16 +-- src/libs/opts/opts.c | 26 ++--- src/libs/pluginprocess/pluginprocess.c | 4 +- src/plugins/augeas/augeas.c | 14 +-- src/plugins/c/c.c | 2 +- src/plugins/cache/cache.c | 6 +- src/plugins/conditionals/conditionals.c | 4 +- src/plugins/constants/constants.c.in | 100 +++++++++--------- src/plugins/crypto/crypto.c | 2 +- src/plugins/crypto/helper.c | 2 +- src/plugins/csvstorage/csvstorage.c | 20 ++-- src/plugins/dbus/testmod_dbus.c | 18 ++-- src/plugins/dpkg/dpkg.c | 4 +- src/plugins/fstab/fstab.c | 16 +-- src/plugins/glob/glob.c | 4 +- src/plugins/hexcode/testmod_hexcode.c | 2 +- src/plugins/hosts/hosts-get.c | 6 +- src/plugins/hosts/hosts-set.c | 8 +- src/plugins/hosts/keymetaformatting.c | 4 +- src/plugins/keytometa/keytometa.c | 4 +- src/plugins/line/line.c | 6 +- src/plugins/list/list.c | 32 +++--- src/plugins/logchange/logchange.c | 2 +- src/plugins/mmapstorage/mmapstorage.c | 4 +- src/plugins/multifile/multifile.c | 12 +-- src/plugins/passwd/passwd.c | 18 ++-- src/plugins/process/process.c | 4 +- src/plugins/profile/profile.c | 20 ++-- src/plugins/reference/reference.c | 8 +- src/plugins/reference/referencegraph.c | 2 +- src/plugins/rename/rename.c | 8 +- src/plugins/rename/testmod_rename.c | 4 +- src/plugins/spec/spec.c | 8 +- src/plugins/specload/specload.c | 4 +- src/plugins/toml/driver.c | 4 +- src/plugins/toml/prepare.c | 2 +- src/plugins/toml/table_array.c | 2 +- src/plugins/toml/testmod_toml.c | 2 +- src/plugins/uname/uname.c | 12 +-- src/plugins/yajl/yajl_gen.c | 2 +- src/plugins/yajl/yajl_parse.c | 4 +- src/tools/elektrad/CMakeLists.txt | 3 + tests/abi/testabi_key.c | 24 ++--- tests/abi/testabi_ks.c | 20 ++-- tests/abi/testabi_meta.c | 2 +- tests/ctest/test_key.c | 36 +++---- tests/ctest/test_ks.c | 2 +- tests/ctest/test_spec.c | 4 +- tests/ctest/test_storage.c | 6 +- 73 files changed, 350 insertions(+), 333 deletions(-) diff --git a/benchmarks/benchmarks.c b/benchmarks/benchmarks.c index ea4454142c8..aa91b61fe18 100644 --- a/benchmarks/benchmarks.c +++ b/benchmarks/benchmarks.c @@ -455,7 +455,7 @@ static void recGenerateKeySet (KeySet * ks, Key * key, KsTreeVertex * vertex) // add if Key if (vertex->isKey) { - Key * dupKey = keyDupOld (key); + Key * dupKey = keyDup (key, KEY_CP_ALL); if (!dupKey) { printExit ("recGenerateKeySet: Can not dup Key"); @@ -473,7 +473,7 @@ static void recGenerateKeySet (KeySet * ks, Key * key, KsTreeVertex * vertex) // go to children for (size_t i = 0; i < vertex->numberofChildren; ++i) { - Key * dupKey = keyDupOld (key); + Key * dupKey = keyDup (key, KEY_CP_ALL); if (!dupKey) { printExit ("recGenerateKeySet: Can not dup Key"); diff --git a/examples/functional.c b/examples/functional.c index 7275f9dbd29..2671ae778d2 100644 --- a/examples/functional.c +++ b/examples/functional.c @@ -81,7 +81,7 @@ int ksFilter (KeySet * result, KeySet * input, int (*filter) (Key * k)) else if (rc != 0) { ++ret; - ksAppendKey (result, keyDupOld (current)); + ksAppendKey (result, keyDup (current, KEY_CP_ALL)); } } ksSetCursor (input, cursor); diff --git a/examples/keyset.c b/examples/keyset.c index b581fde0b6b..33448b51e8b 100644 --- a/examples/keyset.c +++ b/examples/keyset.c @@ -12,7 +12,7 @@ void f (const Key * source) { - Key * dup = keyDupOld (source); + Key * dup = keyDup (source, KEY_CP_ALL); printf ("\tin f\n"); keyDel (dup); @@ -20,7 +20,7 @@ void f (const Key * source) void g (const Key * source, KeySet * ks) { - Key * dup = keyDupOld (source); + Key * dup = keyDup (source, KEY_CP_ALL); printf ("\tin g\n"); ksAppendKey (ks, dup); @@ -68,7 +68,7 @@ void dupAppend (void) //! [dup append] KeySet * ks = ksNew (1, KS_END); Key * k = keyNew ("user:/ref/key", KEY_END); -ksAppendKey (ks, keyDupOld (k)); +ksAppendKey (ks, keyDup (k, KEY_CP_ALL)); ksDel (ks); // now we still can work with the key k! keyDel (k); @@ -101,7 +101,7 @@ int main (void) ksRewind (ks); origKey = ksNext (ks); - key = keyDupOld (origKey); + key = keyDup (origKey, KEY_CP_ALL); printf ("A duplication of the key %s with value %s\n", keyName (key), keyString (key)); keyDel (key); diff --git a/src/bindings/cpp/include/key.hpp b/src/bindings/cpp/include/key.hpp index 84e7efcdb28..854e3f10a05 100644 --- a/src/bindings/cpp/include/key.hpp +++ b/src/bindings/cpp/include/key.hpp @@ -124,7 +124,7 @@ class Key inline ckdb::Key * operator* () const; inline ckdb::Key * release (); - inline ckdb::Key * dup () const; + inline ckdb::Key * dup (elektraCopyFlags flags = KEY_CP_ALL) const; inline ~Key (); @@ -813,9 +813,9 @@ ckdb::Key * Key::release () /** * @copydoc keyDup */ -ckdb::Key * Key::dup () const +ckdb::Key * Key::dup (elektraCopyFlags flags) const { - return ckdb::keyDupOld (getKey ()); + return ckdb::keyDup (getKey (), flags); } /** diff --git a/src/bindings/glib/gelektra-key.c b/src/bindings/glib/gelektra-key.c index 02be2acf26a..b25cb50853d 100644 --- a/src/bindings/glib/gelektra-key.c +++ b/src/bindings/glib/gelektra-key.c @@ -193,16 +193,16 @@ gssize gelektra_key_getref (const GElektraKey * key) * Returns: (transfer full): A duplicated #GElektraKey * see keyDup */ -GElektraKey * gelektra_key_dup (const GElektraKey * key) +GElektraKey * gelektra_key_dup (const GElektraKey * key, elektraCopyFlags flags) { - return gelektra_key_make (keyDupOld (key->key)); + return gelektra_key_make (keyDup (key->key, flags)); } /** * gelektra_key_copy: (skip) * see keyCopy */ -GElektraKey * gelektra_key_copy (const GElektraKey * key, GElektraKey * dest, elektraKeyFlags flags) +GElektraKey * gelektra_key_copy (const GElektraKey * key, GElektraKey * dest, elektraCopyFlags flags) { Key * ret = keyCopy (dest->key, key->key, flags); return ret == NULL ? NULL : dest; diff --git a/src/bindings/glib/gelektra-key.h b/src/bindings/glib/gelektra-key.h index d53ea27c720..ed1d966f1a3 100644 --- a/src/bindings/glib/gelektra-key.h +++ b/src/bindings/glib/gelektra-key.h @@ -71,8 +71,8 @@ gssize gelektra_key_decref (GElektraKey * key); gssize gelektra_key_getref (const GElektraKey * key); /* basic methods */ -GElektraKey * gelektra_key_dup (const GElektraKey * key); -GElektraKey * gelektra_key_copy (const GElektraKey * key, GElektraKey * dest, elektraKeyFlags flags); +GElektraKey * gelektra_key_dup (const GElektraKey * key, elektraCopyFlags flags); +GElektraKey * gelektra_key_copy (const GElektraKey * key, GElektraKey * dest, elektraCopyFlags flags); gint gelektra_key_clear (GElektraKey * key); /* operators */ diff --git a/src/bindings/glib/tests/testglib_key.c b/src/bindings/glib/tests/testglib_key.c index 590bd4603ff..929ed9c32de 100644 --- a/src/bindings/glib/tests/testglib_key.c +++ b/src/bindings/glib/tests/testglib_key.c @@ -114,7 +114,7 @@ static void test_basic (void) { GElektraKey * key; - key = gelektra_key_dup (g_key); + key = gelektra_key_dup (g_key, KEY_CP_ALL); gelektra_key_incref (key); succeed_if (gelektra_key_getref (key) == 2, "refcount should be 2"); succeed_if (gelektra_key_getref (g_key) == 1, "refcount should be still 1"); @@ -142,7 +142,7 @@ static void test_operators (void) succeed_if (!gelektra_key_equal (g_key, g_bkey), "keys shouldn't be equal"); succeed_if (gelektra_key_cmp (g_key, g_bkey) != 0, "keys shouldn't be equal"); - GElektraKey * key = gelektra_key_dup (g_key); + GElektraKey * key = gelektra_key_dup (g_key, KEY_CP_ALL); succeed_if (gelektra_key_equal (g_key, key), "keys should be equal"); succeed_if (gelektra_key_cmp (g_key, key) == 0, "keys should be equal"); g_object_unref (key); diff --git a/src/bindings/intercept/fs/intercept.c b/src/bindings/intercept/fs/intercept.c index 5a48e43219f..f0b05840686 100644 --- a/src/bindings/intercept/fs/intercept.c +++ b/src/bindings/intercept/fs/intercept.c @@ -134,7 +134,7 @@ void init (void) else tmp->value = createAbsolutePath (keyString (key), cwd); tmp->oflags = (unsigned short) -1; - Key * lookupKey = keyDupOld (key); + Key * lookupKey = keyDup (key, KEY_CP_ALL); keyAddBaseName (lookupKey, "readonly"); Key * found = ksLookup (ks, lookupKey, 0); if (found) diff --git a/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Elektra.java b/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Elektra.java index d8e20217834..7e15ebe3efd 100644 --- a/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Elektra.java +++ b/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Elektra.java @@ -37,9 +37,9 @@ public interface Elektra extends Library { Pointer keyNew (String name, Object... args); - Pointer keyDupOld (Pointer source); + Pointer keyDup (Pointer source, int flags); - int keyCopy (Pointer dest, Pointer source); + int keyCopy (Pointer dest, Pointer source, int flags); int keyClear (Pointer key); // not needed diff --git a/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Key.java b/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Key.java index 842db6aa2d1..e2597733e58 100644 --- a/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Key.java +++ b/src/bindings/jna/libelektra5j/src/main/java/org/libelektra/Key.java @@ -21,6 +21,12 @@ public class Key implements Iterable public static final int KEY_META = 1 << 15; public static final int KEY_NULL = 1 << 16; + public static final int KEY_CP_NAME = 1 << 0; + public static final int KEY_CP_STRING = 1 << 1; + public static final int KEY_CP_VALUE = 1 << 2; + public static final int KEY_CP_META = 1 << 3; + public static final int KEY_CP_ALL = KEY_CP_NAME | KEY_CP_VALUE | KEY_CP_META; + /** * Indicates a generic key exception occurred. */ @@ -412,19 +418,32 @@ public void addWarning (final String text, final Object... args) */ public Key dup () { - return new Key (Elektra.INSTANCE.keyDupOld (get ())); + return dup (KEY_CP_ALL); + } + + /** + * Duplicates the key + * + * @param flags what parts of the key to copy (a combination of KEY_CP_* flags) + * + * @return New Key object containing the same information as this key + */ + public Key dup (final int flags) + { + return new Key (Elektra.INSTANCE.keyDup (get (), flags)); } /** * Copies the information from the source key into this key. Does nothing if null is provided. * * @param source Source Key object containing the information to copy + * @param flags what parts of the key to copy (a combination of KEY_CP_* flags) */ - public void copy (final Key source) + public void copy (final Key source, final int flags) { if (source != null) { - Elektra.INSTANCE.keyCopy (get (), source.get ()); + Elektra.INSTANCE.keyCopy (get (), source.get (), flags); } } diff --git a/src/bindings/rust/elektra/src/key.rs b/src/bindings/rust/elektra/src/key.rs index d21f1d36024..79f211bc027 100644 --- a/src/bindings/rust/elektra/src/key.rs +++ b/src/bindings/rust/elektra/src/key.rs @@ -180,11 +180,14 @@ impl<'a> StringKey<'a> { /// Returns a deep copy of the key. pub fn duplicate<'b>(&'a self) -> StringKey<'b> { - // TODO: binding - let dup_ptr = unsafe { - let dup = elektra_sys::keyDup(self.as_ref(), 0); - elektra_sys::keyCopyAllMeta(dup, self.as_ref()); - dup + // FIXME: binding + let dup_ptr = unsafe { + let name = CString::new("/").unwrap(); + elektra_sys::keyCopy( + elektra_sys::keyNew (name.as_ptr(), elektra_sys::KEY_END), + self.as_ref(), + elektra_sys::KEY_CP_ALL + ) }; unsafe { StringKey::from_ptr(dup_ptr) } } @@ -250,11 +253,14 @@ impl<'a> BinaryKey<'a> { /// Returns a deep copy of the key. pub fn duplicate<'b>(&'a self) -> BinaryKey<'b> { - // TODO: binding - let dup_ptr = unsafe { - let dup = elektra_sys::keyDup(self.as_ref(), 0); - elektra_sys::keyCopyAllMeta(dup, self.as_ref()); - dup + // FIXME: binding + let dup_ptr = unsafe { + let name = CString::new("/").unwrap(); + elektra_sys::keyCopy( + elektra_sys::keyNew (name.as_ptr(), elektra_sys::KEY_END), + self.as_ref(), + elektra_sys::KEY_CP_ALL + ) }; unsafe { BinaryKey::from_ptr(dup_ptr) } } diff --git a/src/include/kdb.h.in b/src/include/kdb.h.in index 857e677e4bc..5630d555f51 100644 --- a/src/include/kdb.h.in +++ b/src/include/kdb.h.in @@ -208,16 +208,6 @@ static inline Key *keyDup (const Key *source, elektraCopyFlags flags) return keyCopy (keyNew ("/", 0), source, flags); } -// FIXME: remove once migrated -static inline Key *keyDupOld (const Key *source) -{ - if (source == 0) - { - return 0; - } - return keyCopy (keyNew ("/", 0), source, KEY_CP_ALL); -} - /************************************** * * KeySet methods diff --git a/src/libs/ease/array.c b/src/libs/ease/array.c index 9b65accf1bb..e7d91f430c1 100644 --- a/src/libs/ease/array.c +++ b/src/libs/ease/array.c @@ -272,8 +272,7 @@ Key * elektraArrayGetNextKey (KeySet * arrayKeys) if (!last) return 0; ksAppendKey (arrayKeys, last); - Key * newKey = keyDupOld (last); - keySetBinary (newKey, 0, 0); + Key * newKey = keyDup (last, KEY_CP_NAME); int ret = elektraArrayIncName (newKey); if (ret == -1) diff --git a/src/libs/elektra/backend.c b/src/libs/elektra/backend.c index e732a35cd4a..f496cbcadb1 100644 --- a/src/libs/elektra/backend.c +++ b/src/libs/elektra/backend.c @@ -72,7 +72,7 @@ static Backend * elektraBackendAllocate (void) int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key * errorKey) { Key * root = ksCurrent (elektraConfig); - Key * searchMountpoint = keyDupOld (root); + Key * searchMountpoint = keyDup (root, KEY_CP_NAME); keyAddBaseName (searchMountpoint, "mountpoint"); Key * foundMountpoint = ksLookup (elektraConfig, searchMountpoint, 0); keyDel (searchMountpoint); diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index 6d8dea14f2e..992386b7940 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/elektra/kdb.c @@ -171,7 +171,7 @@ KeySet * ksRenameKeys (KeySet * config, const char * name) while ((cur = ksPop (config)) != 0) { - Key * dupKey = keyDupOld (cur); + Key * dupKey = keyDup (cur, KEY_CP_ALL); keySetName (dupKey, name); keyAddName (dupKey, keyName (cur) + rootSize - 1); ksAppendKey (newConfig, dupKey); @@ -260,7 +260,7 @@ KDB * kdbOpen (Key * errorKey) int errnosave = errno; KDB * handle = elektraCalloc (sizeof (struct _KDB)); - Key * initialParent = keyDupOld (errorKey); + Key * initialParent = keyDup (errorKey, KEY_CP_ALL); handle->global = ksNew (0, KS_END); handle->modules = ksNew (0, KS_END); @@ -404,7 +404,7 @@ int kdbClose (KDB * handle, Key * errorKey) return -1; } - Key * initialParent = keyDupOld (errorKey); + Key * initialParent = keyDup (errorKey, KEY_CP_ALL); int errnosave = errno; splitDel (handle->split); @@ -1006,7 +1006,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) } int errnosave = errno; - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); ELEKTRA_LOG ("now in new kdbGet (%s)", keyName (parentKey)); @@ -1038,7 +1038,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) } cache = ksNew (0, KS_END); - cacheParent = keyDupOld (mountGetMountpoint (handle, keyName (initialParent))); + cacheParent = keyDup (mountGetMountpoint (handle, keyName (initialParent)), KEY_CP_ALL); if (cacheParent == NULL) { cacheParent = keyNew ("default:/", KEY_VALUE, "default", KEY_END); @@ -1588,7 +1588,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey) } int errnosave = errno; - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); ELEKTRA_LOG ("now in new kdbSet (%s) %p %zd", keyName (parentKey), (void *) handle, ksGetSize (ks)); diff --git a/src/libs/elektra/keyset.c b/src/libs/elektra/keyset.c index 76f03d8763e..01204b2decc 100644 --- a/src/libs/elektra/keyset.c +++ b/src/libs/elektra/keyset.c @@ -348,7 +348,7 @@ KeySet * ksDeepDup (const KeySet * source) for (i = 0; i < s; ++i) { Key * k = source->array[i]; - Key * d = keyDupOld (k); + Key * d = keyDup (k, KEY_CP_ALL); if (!test_bit (k->flags, KEY_FLAG_SYNC)) { keyClearSync (d); @@ -1786,7 +1786,7 @@ static Key * elektraLookupByCascading (KeySet * ks, Key * key, elektraLookupFlag } // we found a spec key, so we know what to do - specKey = keyDupOld (specKey); + specKey = keyDup (specKey, KEY_CP_ALL); keySetBinary (specKey, keyValue (key), keyGetValueSize (key)); elektraCopyCallbackMeta (specKey, key); found = elektraLookupBySpec (ks, specKey, options); @@ -2120,7 +2120,7 @@ static Key * elektraLookupSearch (KeySet * ks, Key * key, elektraLookupFlags opt static Key * elektraLookupCreateKey (KeySet * ks, Key * key, ELEKTRA_UNUSED elektraLookupFlags options) { - Key * ret = keyDupOld (key); + Key * ret = keyDup (key, KEY_CP_ALL); ksAppendKey (ks, ret); return ret; } @@ -2229,7 +2229,7 @@ Key * ksLookup (KeySet * ks, Key * key, elektraLookupFlags options) if (options & KDB_O_SPEC) { Key * lookupKey = key; - if (test_bit (key->flags, KEY_FLAG_RO_NAME)) lookupKey = keyDupOld (key); + if (test_bit (key->flags, KEY_FLAG_RO_NAME)) lookupKey = keyDup (key, KEY_CP_NAME); ret = elektraLookupBySpec (ks, lookupKey, options & mask); if (test_bit (key->flags, KEY_FLAG_RO_NAME)) { @@ -2240,7 +2240,7 @@ Key * ksLookup (KeySet * ks, Key * key, elektraLookupFlags options) else if (!(options & KDB_O_NOCASCADING) && strcmp (name, "") && name[0] == '/') { Key * lookupKey = key; - if (test_bit (key->flags, KEY_FLAG_RO_NAME)) lookupKey = keyDupOld (key); + if (test_bit (key->flags, KEY_FLAG_RO_NAME)) lookupKey = keyDup (key, KEY_CP_NAME); ret = elektraLookupByCascading (ks, lookupKey, options & mask); if (test_bit (key->flags, KEY_FLAG_RO_NAME)) { diff --git a/src/libs/elektra/mount.c b/src/libs/elektra/mount.c index 9f2ecb1e9e7..7b375bd086b 100644 --- a/src/libs/elektra/mount.c +++ b/src/libs/elektra/mount.c @@ -235,9 +235,9 @@ int mountDefault (KDB * kdb, KeySet * modules, int inFallback, Key * errorKey) KeySet * elektraMountGlobalsGetConfig (Key * cur, KeySet * global) { // putting together the plugins configuration KeySet. - Key * sysConfigCutKey = keyDupOld (cur); + Key * sysConfigCutKey = keyDup (cur, KEY_CP_ALL); keyAddBaseName (sysConfigCutKey, "system"); - Key * usrConfigCutKey = keyDupOld (cur); + Key * usrConfigCutKey = keyDup (cur, KEY_CP_ALL); keyAddBaseName (usrConfigCutKey, "user"); KeySet * sysConfigKS = ksCut (global, sysConfigCutKey); KeySet * usrConfigKS = ksCut (global, usrConfigCutKey); @@ -277,7 +277,7 @@ int elektraMountGlobalsLoadPlugin (Plugin ** plugin, KeySet * referencePlugins, KeySet * modules, Key * errorKey) { Key * refKey = elektraMountGlobalsFindPlugin (referencePlugins, cur); - Key * openKey = keyDupOld (errorKey); + Key * openKey = keyDup (errorKey, KEY_CP_ALL); if (refKey) { @@ -651,7 +651,7 @@ int mountBackend (KDB * kdb, Backend * backend, Key * errorKey ELEKTRA_UNUSED) mountpoint[nameSize] = '\0'; } kdb->trie = trieInsert (kdb->trie, mountpoint, backend); - splitAppend (kdb->split, backend, keyDupOld (backend->mountpoint), 0); + splitAppend (kdb->split, backend, keyDup (backend->mountpoint, KEY_CP_ALL), 0); backend->refcounter = 1; } diff --git a/src/libs/elektra/plugin.c b/src/libs/elektra/plugin.c index c0b3da886af..1bc8582a202 100644 --- a/src/libs/elektra/plugin.c +++ b/src/libs/elektra/plugin.c @@ -171,7 +171,7 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen if (pluginName) { - Key * key = keyDupOld (cur); + Key * key = keyDup (cur, KEY_CP_ALL); keyAddBaseName (key, "config"); KeySet * cutConfig = ksCut (config, key); keyDel (key); diff --git a/src/libs/elektra/split.c b/src/libs/elektra/split.c index 0b0f812085a..7aa53789349 100644 --- a/src/libs/elektra/split.c +++ b/src/libs/elektra/split.c @@ -327,7 +327,7 @@ int splitBuildup (Split * split, KDB * kdb, Key * parentKey) printf (" def add %s\n", keyName (kdb->split->parents[i])); #endif /* Catch all: add all mountpoints */ - splitAppend (split, kdb->split->handles[i], keyDupOld (kdb->split->parents[i]), kdb->split->syncbits[i]); + splitAppend (split, kdb->split->handles[i], keyDup (kdb->split->parents[i], KEY_CP_ALL), kdb->split->syncbits[i]); } else if (backend == kdb->split->handles[i] && (keyCmp (kdb->split->parents[i], parentKey) == 0 || keyIsBelow (kdb->split->parents[i], parentKey) == 1)) @@ -336,7 +336,7 @@ int splitBuildup (Split * split, KDB * kdb, Key * parentKey) printf (" exa add %s\n", keyName (kdb->split->parents[i])); #endif /* parentKey is exactly in this backend, so add it! */ - splitAppend (split, kdb->split->handles[i], keyDupOld (kdb->split->parents[i]), kdb->split->syncbits[i]); + splitAppend (split, kdb->split->handles[i], keyDup (kdb->split->parents[i], KEY_CP_ALL), kdb->split->syncbits[i]); } else if (keyCmp (parentKey, kdb->split->parents[i]) == 0 || keyIsBelow (parentKey, kdb->split->parents[i]) == 1) { @@ -344,7 +344,7 @@ int splitBuildup (Split * split, KDB * kdb, Key * parentKey) printf (" rel add %s\n", keyName (kdb->split->parents[i])); #endif /* this backend is completely below the parentKey, so lets add it. */ - splitAppend (split, kdb->split->handles[i], keyDupOld (kdb->split->parents[i]), kdb->split->syncbits[i]); + splitAppend (split, kdb->split->handles[i], keyDup (kdb->split->parents[i], KEY_CP_ALL), kdb->split->syncbits[i]); } } diff --git a/src/libs/globbing/globbing.c b/src/libs/globbing/globbing.c index fc347541e28..e9fda6aa99f 100644 --- a/src/libs/globbing/globbing.c +++ b/src/libs/globbing/globbing.c @@ -216,7 +216,7 @@ int elektraKsGlob (KeySet * result, KeySet * input, const char * pattern) if (rc == 0) { ++ret; - ksAppendKey (result, keyDupOld (current)); + ksAppendKey (result, keyDup (current, KEY_CP_ALL)); } } ksSetCursor (input, cursor); diff --git a/src/libs/highlevel/elektra.c b/src/libs/highlevel/elektra.c index 3099bc348f8..2b0c38c7980 100644 --- a/src/libs/highlevel/elektra.c +++ b/src/libs/highlevel/elektra.c @@ -151,7 +151,7 @@ Elektra * elektraOpen (const char * application, KeySet * defaults, KeySet * con // BUT: anything other than helpKey may be incorrect // and only helpKey should be used anyway // so create a new config KeySet - Key * helpKeyDup = keyDupOld (helpKey); + Key * helpKeyDup = keyDup (helpKey, KEY_CP_ALL); ksClear (config); ksAppendKey (config, helpKeyDup); } @@ -316,7 +316,7 @@ void elektraSaveKey (Elektra * elektra, Key * key, ElektraError ** error) ELEKTRA_LOG_DEBUG ("problemKey: %s\n", keyName (problemKey)); } - key = keyDupOld (key); + key = keyDup (key, KEY_CP_ALL); kdbGet (elektra->kdb, elektra->config, elektra->parentKey); } } while (ret == -1); @@ -327,7 +327,7 @@ void insertDefaults (KeySet * config, const Key * parentKey, KeySet * defaults) ksRewind (defaults); for (Key * key = ksNext (defaults); key != NULL; key = ksNext (defaults)) { - Key * const dup = keyDupOld (key); + Key * const dup = keyDup (key, KEY_CP_ALL); const char * name = keyName (key); keySetName (dup, keyName (parentKey)); keyAddName (dup, name); diff --git a/src/libs/highlevel/elektra_array_value.c b/src/libs/highlevel/elektra_array_value.c index d2a25d47733..b4d579ca096 100644 --- a/src/libs/highlevel/elektra_array_value.c +++ b/src/libs/highlevel/elektra_array_value.c @@ -36,7 +36,7 @@ extern "C" { static void elektraArraySetSize (Elektra * elektra, const char * name, kdb_long_long_t size, ElektraError ** error) { elektraSetLookupKey (elektra, name); - Key * arrayParent = keyDupOld (elektra->lookupKey); + Key * arrayParent = keyDup (elektra->lookupKey, KEY_CP_NAME); char sizeString[ELEKTRA_MAX_ARRAY_SIZE]; elektraWriteArrayNumber (sizeString, size - 1); @@ -236,7 +236,7 @@ void elektraSetRawStringArrayElement (Elektra * elektra, const char * name, kdb_ Key * key = ksLookup (elektra->config, elektra->lookupKey, 0); if (key == NULL) { - key = keyDupOld (elektra->lookupKey); + key = keyDup (elektra->lookupKey, KEY_CP_ALL); } keySetMeta (key, "type", type); keySetString (key, value); diff --git a/src/libs/highlevel/elektra_value.c b/src/libs/highlevel/elektra_value.c index c0e87e44dfe..638ee40869e 100644 --- a/src/libs/highlevel/elektra_value.c +++ b/src/libs/highlevel/elektra_value.c @@ -161,7 +161,7 @@ void elektraSetRawString (Elektra * elektra, const char * name, const char * val { CHECK_ERROR (elektra, error); elektraSetLookupKey (elektra, name); - Key * const key = keyDupOld (elektra->lookupKey); + Key * const key = keyDup (elektra->lookupKey, KEY_CP_NAME); keySetMeta (key, "type", type); keySetString (key, value); elektraSaveKey (elektra, key, error); diff --git a/src/libs/merge/kdbmerge.c b/src/libs/merge/kdbmerge.c index 29a54edb7f7..7a5be60fed7 100644 --- a/src/libs/merge/kdbmerge.c +++ b/src/libs/merge/kdbmerge.c @@ -261,7 +261,7 @@ static int prependStringToAllKeyNames (KeySet * result, KeySet * input, const ch { strcat (newName, keyName (key)); } - Key * duplicateKey = keyDupOld (key); // keySetName returns -1 if key was inserted to a keyset before + Key * duplicateKey = keyDup (key, KEY_CP_ALL); // keySetName returns -1 if key was inserted to a keyset before int status = keySetName (duplicateKey, newName); elektraFree (newName); if (status < 0) @@ -305,7 +305,7 @@ static KeySet * removeRoot (KeySet * original, Key * root, Key * informationKey) }; if (keyIsBelow (root, currentKey) || keyCmp (currentKey, root) == 0) { - Key * duplicateKey = keyDupOld (currentKey); + Key * duplicateKey = keyDup (currentKey, KEY_CP_ALL); int retVal; if (keyIsBelow (root, currentKey)) { @@ -687,7 +687,7 @@ static char * getValuesAsArray (KeySet * ks, const Key * arrayStart, Key * infor * The elektraArrayIncName would then change the name of the real key. * We don't want that as we only increase the name to loop over all keys. */ - Key * iterator = keyDupOld (arrayStart); + Key * iterator = keyDup (arrayStart, KEY_CP_NAME); if (iterator == NULL) { ELEKTRA_SET_INTERNAL_ERROR (informationKey, "Could not duplicate key to iterate."); diff --git a/src/libs/meta/meta.c b/src/libs/meta/meta.c index f0aa156bfe6..8cfe86fc327 100644 --- a/src/libs/meta/meta.c +++ b/src/libs/meta/meta.c @@ -298,13 +298,13 @@ void elektraMetaArrayAdd (Key * key, const char * metaName, const char * value) if (!meta) { keySetMeta (key, metaName, "#0"); - arrayKey = keyDupOld (keyGetMeta (key, metaName)); + arrayKey = keyDup (keyGetMeta (key, metaName), KEY_CP_NAME); keySetString (arrayKey, 0); keyAddBaseName (arrayKey, "#"); } else { - arrayKey = keyDupOld (meta); + arrayKey = keyDup (meta, KEY_CP_NAME); keyAddBaseName (arrayKey, keyString (meta)); } elektraArrayIncName (arrayKey); @@ -500,7 +500,7 @@ static int resolveDeps (unsigned int j, _adjMatrix * adjMatrix, size_t size, Key resolveDep (j, adjMatrix, size); keySetMeta (adjMatrix[j].key, "order", keyBaseName (orderCounter)); elektraArrayIncName (orderCounter); - ksAppendKey (done, keyDupOld (adjMatrix[j].key)); + ksAppendKey (done, keyDup (adjMatrix[j].key, KEY_CP_ALL)); return 1; } unsigned int max_loops = todo; @@ -522,7 +522,7 @@ static int resolveDeps (unsigned int j, _adjMatrix * adjMatrix, size_t size, Key resolveDep (i, adjMatrix, size); keySetMeta (adjMatrix[i].key, "order", keyBaseName (orderCounter)); elektraArrayIncName (orderCounter); - ksAppendKey (done, keyDupOld (adjMatrix[i].key)); + ksAppendKey (done, keyDup (adjMatrix[i].key, KEY_CP_ALL)); } } return 1; @@ -606,7 +606,7 @@ int elektraSortTopology (KeySet * ks, Key ** array) // key has no dependencies, give it an order number and add it to list of resolved dependencies keySetMeta (cur, "order", keyBaseName (orderCounter)); elektraArrayIncName (orderCounter); - ksAppendKey (done, keyDupOld (cur)); + ksAppendKey (done, keyDup (cur, KEY_CP_ALL)); adjMatrix[j].isResolved = 1; ksDel (deps); break; @@ -619,7 +619,7 @@ int elektraSortTopology (KeySet * ks, Key ** array) { keySetMeta (cur, "order", keyBaseName (orderCounter)); elektraArrayIncName (orderCounter); - ksAppendKey (done, keyDupOld (cur)); + ksAppendKey (done, keyDup (cur, KEY_CP_ALL)); adjMatrix[j].isResolved = 1; ksDel (deps); break; @@ -736,7 +736,7 @@ int elektraSortTopology (KeySet * ks, Key ** array) resolveDep (j, adjMatrix, size); keySetMeta (localArray[j], "order", keyBaseName (orderCounter)); elektraArrayIncName (orderCounter); - ksAppendKey (done, keyDupOld (localArray[j])); + ksAppendKey (done, keyDup (localArray[j], KEY_CP_ALL)); found = 1; } } @@ -780,7 +780,7 @@ int elektraSortTopology (KeySet * ks, Key ** array) char * elektraMetaArrayToString (const Key * key, const char * metaName, const char * delim) { char * result = NULL; - Key * lookupElem = keyDupOld (keyGetMeta (key, metaName)); + Key * lookupElem = keyDup (keyGetMeta (key, metaName), KEY_CP_ALL); keyAddBaseName (lookupElem, "#0"); Key * elem = (Key *) keyGetMeta (key, keyName (lookupElem)); if (elem != NULL) diff --git a/src/libs/opts/opts.c b/src/libs/opts/opts.c index ab23a7c1056..b3c1b083643 100644 --- a/src/libs/opts/opts.c +++ b/src/libs/opts/opts.c @@ -134,7 +134,7 @@ int elektraGetOpts (KeySet * ks, int argc, const char ** argv, const char ** env { elektraCursor initial = ksGetCursor (ks); - Key * specParent = keyDupOld (parentKey); + Key * specParent = keyDup (parentKey, KEY_CP_ALL); if (keyGetNamespace (parentKey) != KEY_NS_SPEC) { keySetName (specParent, "spec"); @@ -1088,7 +1088,7 @@ bool processArgs (Key * command, Key * specKey, KeySet * argIndices, Key ** keyW } keySetMeta (*keyWithOpt, "args", "remaining"); - Key * dup = keyDupOld (specKey); + Key * dup = keyDup (specKey, KEY_CP_ALL); keySetBaseName (dup, NULL); // remove # const char * existing = keyGetMetaString (command, "remainingargskey"); @@ -1328,7 +1328,7 @@ int writeArgsValues (KeySet * ks, Key * keyWithOpt, Key * command, KeySet * argI Key * procKey = keyNew ("proc:/", KEY_END); keyAddName (procKey, strchr (keyName (keyWithOpt), '/')); - Key * insertKey = keyDupOld (procKey); + Key * insertKey = keyDup (procKey, KEY_CP_NAME); ksRewind (args); for (elektraCursor i = firstRemainingArg; i < ksGetSize (args); ++i) @@ -1336,7 +1336,7 @@ int writeArgsValues (KeySet * ks, Key * keyWithOpt, Key * command, KeySet * argI Key * arg = ksAtCursor (args, i); elektraArrayIncName (insertKey); - Key * k = keyDupOld (insertKey); + Key * k = keyDup (insertKey, KEY_CP_NAME); keySetString (k, keyString (arg)); ksAppendKey (ks, k); } @@ -1455,7 +1455,7 @@ int addProcKey (KeySet * ks, const Key * key, Key * valueKey) if (isArrayKey) { - Key * insertKey = keyDupOld (procKey); + Key * insertKey = keyDup (procKey, KEY_CP_NAME); keyAddBaseName (insertKey, "#"); KeySet * values = elektraMetaArrayToKS (valueKey, "values"); if (values == NULL) @@ -1472,7 +1472,7 @@ int addProcKey (KeySet * ks, const Key * key, Key * valueKey) { elektraArrayIncName (insertKey); - Key * k = keyDupOld (insertKey); + Key * k = keyDup (insertKey, KEY_CP_NAME); keySetString (k, keyString (cur)); ksAppendKey (ks, k); } @@ -1578,7 +1578,7 @@ KeySet * parseArgs (Key * command, KeySet * optionsSpec, bool useSubcommands, in } elektraArrayIncName (argKey); - Key * newArgKey = keyDupOld (argKey); + Key * newArgKey = keyDup (argKey, KEY_CP_NAME); keySetString (newArgKey, cur); ksAppendKey (options, newArgKey); } @@ -1588,7 +1588,7 @@ KeySet * parseArgs (Key * command, KeySet * optionsSpec, bool useSubcommands, in for (; i < argc; ++i) { elektraArrayIncName (argKey); - Key * newArgKey = keyDupOld (argKey); + Key * newArgKey = keyDup (argKey, KEY_CP_NAME); keySetString (newArgKey, argv[i]); ksAppendKey (options, newArgKey); } @@ -1857,7 +1857,7 @@ int writeOptions (Key * command, Key * commandKey, Key * commandArgs, bool write { if (spec->useSubcommands) { - Key * checkKey = keyDupOld (keyWithOpt); + Key * checkKey = keyDup (keyWithOpt, KEY_CP_ALL); if (strcmp (keyBaseName (keyWithOpt), "#") == 0) { keySetBaseName (checkKey, NULL); // remove # @@ -1940,7 +1940,7 @@ KeySet * ksMetaGetSingleOrArray (Key * key, const char * metaName) return ksNew (2, keyNew ("meta:/#", KEY_END), k, KS_END); } - Key * testKey = keyDupOld (k); + Key * testKey = keyDup (k, KEY_CP_NAME); keyAddBaseName (testKey, keyString (k)); const Key * test = keyGetMeta (key, keyName (testKey)); @@ -2086,7 +2086,7 @@ char * generateOptionsList (KeySet * keysWithOpts, Key * commandKey) ksRewind (keysWithOpts); while ((cur = ksNext (keysWithOpts)) != NULL) { - Key * checkKey = keyDupOld (cur); + Key * checkKey = keyDup (cur, KEY_CP_NAME); if (strcmp (keyBaseName (cur), "#") == 0) { keySetBaseName (checkKey, NULL); // remove # @@ -2136,7 +2136,7 @@ char * generateCommandsList (KeySet * keysWithOpts, Key * commandKey) ksRewind (keysWithOpts); while ((cur = ksNext (keysWithOpts)) != NULL) { - Key * checkKey = keyDupOld (cur); + Key * checkKey = keyDup (cur, KEY_CP_NAME); if (strcmp (keyBaseName (cur), "#") == 0) { keySetBaseName (checkKey, NULL); // remove # @@ -2187,7 +2187,7 @@ char * generateArgsList (KeySet * keysWithOpts, Key * commandKey) ksRewind (keysWithOpts); while ((cur = ksNext (keysWithOpts)) != NULL) { - Key * checkKey = keyDupOld (cur); + Key * checkKey = keyDup (cur, KEY_CP_NAME); if (strcmp (keyBaseName (cur), "#") == 0) { keySetBaseName (checkKey, NULL); // remove # diff --git a/src/libs/pluginprocess/pluginprocess.c b/src/libs/pluginprocess/pluginprocess.c index 9696d381d78..84e23b2b1ae 100644 --- a/src/libs/pluginprocess/pluginprocess.c +++ b/src/libs/pluginprocess/pluginprocess.c @@ -160,7 +160,7 @@ void elektraPluginProcessStart (Plugin * handle, ElektraPluginProcess * pp) Key * commandKey = ksLookupByName (commandKeySet, "/pluginprocess/command", KDB_O_NONE); Key * parentNameKey = ksLookupByName (commandKeySet, "/pluginprocess/parent/name", KDB_O_NONE); Key * parentKey = ksLookupByName (commandKeySet, "/pluginprocess/parent", KDB_O_POP); - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); keySetName (key, keyString (parentNameKey)); int result = ELEKTRA_PLUGIN_STATUS_ERROR; @@ -273,7 +273,7 @@ int elektraPluginProcessSend (const ElektraPluginProcess * pp, pluginprocess_t c // Construct the command set that controls the pluginprocess communication KeySet * commandKeySet = ksNew (6, KS_END); ksAppendKey (commandKeySet, keyNew ("/pluginprocess/parent/name", KEY_VALUE, keyName (key), KEY_END)); - Key * parentKey = keyDupOld (key); + Key * parentKey = keyDup (key, KEY_CP_ALL); keySetName (parentKey, "/pluginprocess/parent"); ksAppendKey (commandKeySet, parentKey); char * commandStr = longToStr (command); diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 96b33e691f7..d646e6fec9f 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -77,11 +77,11 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) p[l - 4] = '\0'; Key * k = keyNew ("system:/", KEY_END); keyAddBaseName (k, p); - ksAppendKey (ks, keyDupOld (k)); + ksAppendKey (ks, keyDup (k, KEY_CP_ALL)); - Key * b = keyDupOld (k); + Key * b = keyDup (k, KEY_CP_ALL); keyAddBaseName (b, "infos"); - ksAppendKey (ks, keyDupOld (b)); + ksAppendKey (ks, keyDup (b, KEY_CP_ALL)); keyAddBaseName (b, "provides"); char * s = elektraFormat ("storage/%s", p); keySetString (b, s); @@ -89,7 +89,7 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) ksAppendKey (ks, b); keyAddBaseName (k, "config"); - ksAppendKey (ks, keyDupOld (k)); + ksAppendKey (ks, keyDup (k, KEY_CP_ALL)); keyAddBaseName (k, "lens"); p[0] = (char) toupper (p[0]); p[l - 1] = 's'; @@ -165,7 +165,7 @@ static const char * getAugeasError (augeas * augeasHandle, const char * lensPath static Key * createKeyFromPath (Key * parentKey, const char * treePath) { - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); char * baseName = elektraStrDup (treePath + strlen (AUGEAS_TREE_ROOT) + 1); char * lastSlash = strrchr (baseName, '/'); const char * lastPart = lastSlash != NULL ? lastSlash + 1 : baseName; @@ -549,7 +549,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) ksClear (returned); KeySet * append = ksNew ((size_t) ksGetSize (returned) * 2, KS_END); - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); ksAppendKey (append, key); struct KeyConversion * conversionData = elektraMalloc (sizeof (struct KeyConversion)); @@ -562,7 +562,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) } conversionData->currentOrder = 0; - conversionData->parentKey = keyDupOld (key); + conversionData->parentKey = keyDup (key, KEY_CP_ALL); conversionData->ks = append; ret = foreachAugeasNode (augeasHandle, AUGEAS_TREE_ROOT, &convertToKey, conversionData); diff --git a/src/plugins/c/c.c b/src/plugins/c/c.c index 89116622da1..58d6fc161b7 100644 --- a/src/plugins/c/c.c +++ b/src/plugins/c/c.c @@ -130,7 +130,7 @@ int keyGenerate (const Key * key, FILE * stream) } const Key * meta; - Key * dup = keyDupOld (key); + Key * dup = keyDup (key, KEY_CP_ALL); keyRewindMeta (dup); while ((meta = keyNextMeta (dup))) { diff --git a/src/plugins/cache/cache.c b/src/plugins/cache/cache.c index 3d3150414a1..06bf69b946a 100644 --- a/src/plugins/cache/cache.c +++ b/src/plugins/cache/cache.c @@ -311,7 +311,7 @@ int elektraCacheGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa if (!elektraStrCmp (keyString (keyGetMeta (parentKey, "cache/clear")), "1")) { // clear all caches - Key * cacheFile = keyDupOld (parentKey); + Key * cacheFile = keyDup (parentKey, KEY_CP_ALL); char * cacheFileName = kdbCacheFileName (ch, cacheFile, modeDirectory); ELEKTRA_LOG_DEBUG ("CLEAR CACHES path: %s", cacheFileName); @@ -323,7 +323,7 @@ int elektraCacheGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa } // construct cache file name from parentKey (which stores the mountpoint from mountGetMountpoint) - Key * cacheFile = keyDupOld (parentKey); + Key * cacheFile = keyDup (parentKey, KEY_CP_ALL); char * cacheFileName = kdbCacheFileName (ch, cacheFile, modeFile); ELEKTRA_ASSERT (cacheFileName != 0, "Could not construct cache file name."); ELEKTRA_LOG_DEBUG ("CACHE get cacheFileName: %s, parentKey: %s, %s", cacheFileName, keyName (parentKey), keyString (parentKey)); @@ -357,7 +357,7 @@ int elektraCacheSet (Plugin * handle, KeySet * returned, Key * parentKey) } // construct cache file name from parentKey (which stores the mountpoint from mountGetMountpoint) - Key * cacheFile = keyDupOld (parentKey); + Key * cacheFile = keyDup (parentKey, KEY_CP_ALL); char * cacheFileName = kdbCacheFileName (ch, cacheFile, modeFile); ELEKTRA_ASSERT (cacheFileName != 0, "Could not construct cache file name."); ELEKTRA_LOG_DEBUG ("CACHE set cacheFileName: %s, parentKey: %s, %s", cacheFileName, keyName (parentKey), keyString (parentKey)); diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 69bee613f6d..2125afc6ce9 100644 --- a/src/plugins/conditionals/conditionals.c +++ b/src/plugins/conditionals/conditionals.c @@ -506,13 +506,13 @@ static const char * isAssign (Key * key, char * expr, Key * parentKey, KeySet * Key * lookupKey; if (*firstPtr == '@') { - lookupKey = keyDupOld (parentKey); + lookupKey = keyDup (parentKey, KEY_CP_ALL); ++firstPtr; keyAddName (lookupKey, firstPtr); } else if (!strncmp (firstPtr, "..", 2) || !strncmp (firstPtr, ".", 1)) { - lookupKey = keyDupOld (key); + lookupKey = keyDup (key, KEY_CP_ALL); keyAddName (lookupKey, firstPtr); } else diff --git a/src/plugins/constants/constants.c.in b/src/plugins/constants/constants.c.in index 452e9052388..de4e34442ef 100644 --- a/src/plugins/constants/constants.c.in +++ b/src/plugins/constants/constants.c.in @@ -20,7 +20,7 @@ int elektraConstantsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKT static void elektraAddKeyValue (KeySet * ks, Key * parentKey, const char * key, const char * value) { - Key * k = keyDupOld (parentKey); + Key * k = keyDup (parentKey, KEY_CP_ALL); keyAddName (k, key); keySetString (k, value); ksAppendKey (ks, k); @@ -28,33 +28,33 @@ static void elektraAddKeyValue (KeySet * ks, Key * parentKey, const char * key, static void elektraAddConstants (KeySet * ks, Key * parentKey) { - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "version"); keySetString (key, "Duplicate of version info also found below system:/elektra/version"); ksAppendKey (ks, key); - key = keyDupOld (key); + key = keyDup (key, KEY_CP_ALL); keyAddName (key, "version/KDB_VERSION"); keySetString (key, "@KDB_VERSION@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "version/KDB_VERSION_MAJOR"); keySetString (key, "@KDB_VERSION_MAJOR@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "version/KDB_VERSION_MINOR"); keySetString (key, "@KDB_VERSION_MINOR@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "version/KDB_VERSION_PATCH"); keySetString (key, "@KDB_VERSION_PATCH@"); ksAppendKey (ks, key); @@ -65,31 +65,31 @@ static void elektraAddConstants (KeySet * ks, Key * parentKey) elektraAddKeyValue (ks, parentKey, "version/SO_VERSION_GETENV", "@SO_VERSION_GETENV@"); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake"); keySetString (key, "All cmake variables as defined in the file cmake/ElektraCache.cmake"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/PLUGINS"); keySetString (key, "@ADDED_PLUGINS@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TOOLS"); keySetString (key, "@TOOLS@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/KDB_DB_SYSTEM"); keySetString (key, "@KDB_DB_SYSTEM@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/KDB_DB_HOME"); keySetString (key, "@KDB_DB_HOME@"); ksAppendKey (ks, key); @@ -101,55 +101,55 @@ static void elektraAddConstants (KeySet * ks, Key * parentKey) elektraAddKeyValue (ks, parentKey, "cmake/KDB_DEFAULT_RESOLVER", "@KDB_DEFAULT_RESOLVER@"); elektraAddKeyValue (ks, parentKey, "cmake/KDB_DEFAULT_STORAGE", "@KDB_DEFAULT_STORAGE@"); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/KDB_DB_USER"); keySetString (key, "@KDB_DB_USER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/GTEST_ROOT"); keySetString (key, "@GTEST_ROOT@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/BUILD_SHARED"); keySetString (key, "@BUILD_SHARED@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/BUILD_FULL"); keySetString (key, "@BUILD_FULL@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/BUILD_STATIC"); keySetString (key, "@BUILD_STATIC@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/BINDINGS"); keySetString (key, "@ADDED_BINDINGS@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_INCLUDE_FOLDER"); keySetString (key, "@TARGET_INCLUDE_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_CMAKE_FOLDER"); keySetString (key, "@TARGET_CMAKE_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_PLUGIN_FOLDER"); keySetString (key, "@TARGET_PLUGIN_FOLDER@"); ksAppendKey (ks, key); @@ -162,7 +162,7 @@ static void elektraAddConstants (KeySet * ks, Key * parentKey) elektraAddKeyValue (ks, parentKey, "cmake/BUILTIN_DATA_FOLDER", BUILTIN_DATA_FOLDER); elektraAddKeyValue (ks, parentKey, "cmake/BUILTIN_EXEC_FOLDER", BUILTIN_EXEC_FOLDER); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_PKGCONFIG_FOLDER"); keySetString (key, "@TARGET_PKGCONFIG_FOLDER@"); ksAppendKey (ks, key); @@ -172,168 +172,168 @@ static void elektraAddConstants (KeySet * ks, Key * parentKey) elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_MAN_FOLDER", "@TARGET_DOCUMENTATION_MAN_FOLDER@"); elektraAddKeyValue (ks, parentKey, "cmake/TARGET_DOCUMENTATION_LATEX_FOLDER", "@TARGET_DOCUMENTATION_LATEX_FOLDER@"); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_TOOL_EXEC_FOLDER"); keySetString (key, "@TARGET_TOOL_EXEC_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_TOOL_DATA_FOLDER"); keySetString (key, "@TARGET_TOOL_DATA_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_TEST_DATA_FOLDER"); keySetString (key, "@TARGET_TEST_DATA_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/TARGET_TEMPLATE_FOLDER"); keySetString (key, "@TARGET_TEMPLATE_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/LIB_SUFFIX"); keySetString (key, "@LIB_SUFFIX@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "cmake/CMAKE_INSTALL_PREFIX"); keySetString (key, "@CMAKE_INSTALL_PREFIX@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler"); keySetString (key, "Flags defined for compilers as defined in ElektraCompiling.cmake"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/c_flags"); keySetString (key, "@C_FLAGS_ESCAPED@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/id"); keySetString (key, "@CMAKE_CXX_COMPILER_ID@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/coverage"); keySetString (key, "@ENABLE_COVERAGE@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/cxx_flags"); keySetString (key, "@CXX_FLAGS_ESCAPED@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/pic_flags"); keySetString (key, "@CMAKE_PIC_FLAGS@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "compiler/static_flags"); keySetString (key, "@CMAKE_STATIC_FLAGS@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros"); keySetString (key, "Define the macros from kdbos.h and kdbconfig.h"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros/KDB_MAX_PATH_LENGTH"); keySetString (key, ELEKTRA_STRINGIFY (KDB_MAX_PATH_LENGTH)); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros/KDB_FILE_MODE"); keySetString (key, ELEKTRA_STRINGIFY (KDB_FILE_MODE)); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros/KDB_DIR_MODE"); keySetString (key, ELEKTRA_STRINGIFY (KDB_DIR_MODE)); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros/KDB_PATH_SEPARATOR"); keySetString (key, ELEKTRA_STRINGIFY (KDB_PATH_SEPARATOR)); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "macros/KDB_PATH_ESCAPE"); keySetString (key, ELEKTRA_STRINGIFY (KDB_PATH_ESCAPE)); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package"); keySetString (key, "Infos about the package as it is installed"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/prefix"); keySetString (key, "@CMAKE_INSTALL_PREFIX@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/libdir"); keySetString (key, "@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/includedir"); keySetString (key, "@CMAKE_INSTALL_PREFIX@/include/@TARGET_INCLUDE_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/plugindir"); keySetString (key, "@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@/@TARGET_PLUGIN_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/tool_execdir"); keySetString (key, "@CMAKE_INSTALL_PREFIX@/@TARGET_TOOL_EXEC_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/templatedir"); keySetString (key, "@CMAKE_INSTALL_PREFIX@/@TARGET_TEMPLATE_FOLDER@"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/libs"); keySetString (key, "-L@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@ -lelektra"); ksAppendKey (ks, key); - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keyAddName (key, "package/cflags"); keySetString (key, "-I@CMAKE_INSTALL_PREFIX@/include/@TARGET_INCLUDE_FOLDER@"); ksAppendKey (ks, key); diff --git a/src/plugins/crypto/crypto.c b/src/plugins/crypto/crypto.c index 931b41ee1ae..e7a11a1dd48 100644 --- a/src/plugins/crypto/crypto.c +++ b/src/plugins/crypto/crypto.c @@ -422,7 +422,7 @@ int ELEKTRA_PLUGIN_FUNCTION (checkconf) (Key * errorKey, KeySet * conf) if (k) { // call gpg module to verify that we own the required key - Key * msg = keyDupOld (k); + Key * msg = keyDup (k, KEY_CP_ALL); if (ELEKTRA_PLUGIN_FUNCTION (gpgDecryptMasterPassword) (conf, errorKey, msg) != 1) { keyDel (msg); diff --git a/src/plugins/crypto/helper.c b/src/plugins/crypto/helper.c index 818a8304714..a0696311690 100644 --- a/src/plugins/crypto/helper.c +++ b/src/plugins/crypto/helper.c @@ -198,7 +198,7 @@ Key * ELEKTRA_PLUGIN_FUNCTION (getMasterPassword) (Key * errorKey, KeySet * conf ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Missing %s in plugin configuration", ELEKTRA_CRYPTO_PARAM_MASTER_PASSWORD); return NULL; } - Key * msg = keyDupOld (master); + Key * msg = keyDup (master, KEY_CP_ALL); if (ELEKTRA_PLUGIN_FUNCTION (gpgDecryptMasterPassword) (config, errorKey, msg) != 1) { keyDel (msg); diff --git a/src/plugins/csvstorage/csvstorage.c b/src/plugins/csvstorage/csvstorage.c index f09e5ead713..719f38e1167 100644 --- a/src/plugins/csvstorage/csvstorage.c +++ b/src/plugins/csvstorage/csvstorage.c @@ -269,7 +269,7 @@ static KeySet * createHeaders (Key * parentKey, int columns, const char ** colNa KeySet * header = ksNew (0, KS_END); int colCounter = 0; // if no headerline exists name the columns 0..N where N is the number of columns - Key * orderKey = keyDupOld (parentKey); + Key * orderKey = keyDup (parentKey, KEY_CP_ALL); keyAddName (orderKey, "#"); while (colCounter < columns) { @@ -279,7 +279,7 @@ static KeySet * createHeaders (Key * parentKey, int columns, const char ** colNa ksDel (header); return NULL; } - Key * key = keyDupOld (orderKey); + Key * key = keyDup (orderKey, KEY_CP_ALL); if (colNames && (colNames + colCounter)) keySetString (key, colNames[colCounter]); else @@ -298,7 +298,7 @@ static KeySet * readHeaders (Key * parentKey, char * lineBuffer, char delim, int unsigned long offset = 0; char * col; offset = 0; - Key * orderKey = keyDupOld (parentKey); + Key * orderKey = keyDup (parentKey, KEY_CP_ALL); keyAddName (orderKey, "#"); KeySet * header = ksNew (0, KS_END); while ((col = parseLine (lineBuffer, delim, offset, parentKey, lineCounter, lastLine)) != NULL) @@ -311,7 +311,7 @@ static KeySet * readHeaders (Key * parentKey, char * lineBuffer, char delim, int ksDel (header); return NULL; } - Key * key = keyDupOld (orderKey); + Key * key = keyDup (orderKey, KEY_CP_ALL); if (colNames && (colNames + colCounter)) { keySetString (key, colNames[colCounter]); @@ -394,7 +394,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP } Key * dirKey; Key * cur; - dirKey = keyDupOld (parentKey); + dirKey = keyDup (parentKey, KEY_CP_ALL); keyAddName (dirKey, "#"); elektraFree (lineBuffer); ksRewind (header); @@ -428,7 +428,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { cur = ksNext (header); offset += elektraStrLen (col); - key = keyDupOld (dirKey); + key = keyDup (dirKey, KEY_CP_ALL); if (col[0] == '"') { if (col[elektraStrLen (col) - 2] == '"') @@ -450,7 +450,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP if (!(lineCounter <= 1 && useHeader)) { keySetString (dirKey, lastIndex); - ksAppendKey (tmpKs, keyDupOld (dirKey)); + ksAppendKey (tmpKs, keyDup (dirKey, KEY_CP_ALL)); Key * lookupKey = keyNew (keyName (dirKey), KEY_END); keyAddName (lookupKey, keyString (colAsParent)); Key * indexKey = ksLookupByName (tmpKs, keyName (lookupKey), 0); @@ -458,7 +458,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP keySetBaseName (renameKey, keyString (indexKey)); ksRewind (tmpKs); KeySet * renamedKs = ksRenameKeys (tmpKs, keyName (renameKey)); - ksAppendKey (renamedKs, keyDupOld (renameKey)); + ksAppendKey (renamedKs, keyDup (renameKey, KEY_CP_ALL)); ksRewind (renamedKs); keyDel (lookupKey); keyDel (renameKey); @@ -472,7 +472,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP { keySetString (dirKey, lastIndex); ksAppend (returned, tmpKs); - ksAppendKey (returned, keyDupOld (dirKey)); + ksAppendKey (returned, keyDup (dirKey, KEY_CP_ALL)); } ksDel (tmpKs); tmpKs = NULL; @@ -495,7 +495,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP elektraFree (lineBuffer); ksDel (tmpKs); } - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); keySetString (key, keyBaseName (dirKey)); ksAppendKey (returned, key); keyDel (dirKey); diff --git a/src/plugins/dbus/testmod_dbus.c b/src/plugins/dbus/testmod_dbus.c index c00e9f75b24..65bea9401b5 100644 --- a/src/plugins/dbus/testmod_dbus.c +++ b/src/plugins/dbus/testmod_dbus.c @@ -181,7 +181,7 @@ static void test_keyAdded (void) keyAddName (parentKey, "tests/foo"); // (namespace)/tests/foo/bar - Key * toAdd = keyDupOld (parentKey); + Key * toAdd = keyDup (parentKey, KEY_CP_ALL); keyAddName (toAdd, "bar"); keySetString (toAdd, "test"); @@ -226,7 +226,7 @@ static void test_keyChanged (void) keyAddName (parentKey, "tests/foo"); // (namespace)/tests/foo/bar - Key * toChange = keyDupOld (parentKey); + Key * toChange = keyDup (parentKey, KEY_CP_ALL); keyAddName (toChange, "bar"); keySetString (toChange, "test"); @@ -267,11 +267,11 @@ static void test_keyDeleted (void) keyAddName (parentKey, "tests/foo"); // (namespace)/tests/foo/bar - Key * toDelete = keyDupOld (parentKey); + Key * toDelete = keyDup (parentKey, KEY_CP_ALL); keyAddName (toDelete, "bar"); keySetString (toDelete, "test"); - KeySet * ks = ksNew (1, keyDupOld (toDelete), KS_END); + KeySet * ks = ksNew (1, keyDup (toDelete, KEY_CP_ALL), KS_END); KeySet * conf = ksNew (0, KS_END); PLUGIN_OPEN ("dbus"); @@ -310,16 +310,16 @@ static void test_announceOnce (void) keyAddName (parentKey, "tests/foo"); // (namespace)/tests/foo/bar/#0 - Key * toAdd1 = keyDupOld (parentKey); + Key * toAdd1 = keyDup (parentKey, KEY_CP_ALL); keyAddName (toAdd1, "bar/#0"); keySetString (toAdd1, "test"); // (namespace)/tests/foo/bar/#1 - Key * toAdd2 = keyDupOld (toAdd1); + Key * toAdd2 = keyDup (toAdd1, KEY_CP_ALL); keySetBaseName (toAdd2, "#1"); // (namespace)/tests/foo/bar - Key * toChange = keyDupOld (parentKey); + Key * toChange = keyDup (parentKey, KEY_CP_ALL); keyAddName (toChange, "bar"); keySetString (toChange, "test"); @@ -364,7 +364,7 @@ static void test_cascadedChangeNotification (void) keyAddName (completeParentKey, "tests/foo"); // (namespace)/tests/foo/bar - Key * toAdd = keyDupOld (completeParentKey); + Key * toAdd = keyDup (completeParentKey, KEY_CP_ALL); keyAddName (toAdd, "bar"); keySetString (toAdd, "test"); @@ -407,7 +407,7 @@ static void test_cascadedAnnounceOnce (void) keyAddName (completeParentKey, "tests/foo"); // (namespace)/tests/foo/bar - Key * toAdd = keyDupOld (completeParentKey); + Key * toAdd = keyDup (completeParentKey, KEY_CP_ALL); keyAddName (toAdd, "bar"); keySetString (toAdd, "test"); diff --git a/src/plugins/dpkg/dpkg.c b/src/plugins/dpkg/dpkg.c index a8fbe7593d7..8d2019e55de 100644 --- a/src/plugins/dpkg/dpkg.c +++ b/src/plugins/dpkg/dpkg.c @@ -59,14 +59,14 @@ static KeySet * nextPackage (FILE * fp, Key * parentKey) strtok (data, "\n"); // remove newline if (!strcmp (section, "Package")) { - baseKey = keyDupOld (parentKey); + baseKey = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (baseKey, data); lastKey = baseKey; ksAppendKey (package, baseKey); } else { - Key * key = keyDupOld (baseKey); + Key * key = keyDup (baseKey, KEY_CP_ALL); keyAddBaseName (key, section); keySetString (key, data); lastKey = key; diff --git a/src/plugins/fstab/fstab.c b/src/plugins/fstab/fstab.c index 5eb3c1b8cb8..2750851ea63 100644 --- a/src/plugins/fstab/fstab.c +++ b/src/plugins/fstab/fstab.c @@ -110,7 +110,7 @@ int elektraFstabGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa return 1; } - key = keyDupOld (parentKey); + key = keyDup (parentKey, KEY_CP_ALL); ksAppendKey (returned, key); nr_keys++; @@ -132,45 +132,45 @@ int elektraFstabGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa elektraFstabFsName (fsname, fstabEntry, &swapIndex); /* Include only the filesystem pseudo-names */ - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, fsname); keySetString (dir, ""); keySetComment (dir, ""); keySetComment (dir, "Filesystem pseudo-name"); ksAppendKey (returned, dir); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "device"); keySetString (key, fstabEntry->mnt_fsname); keySetComment (key, "Device or Label"); ksAppendKey (returned, key); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "mpoint"); keySetString (key, fstabEntry->mnt_dir); keySetComment (key, "Mount point"); ksAppendKey (returned, key); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "type"); keySetString (key, fstabEntry->mnt_type); keySetComment (key, "Filesystem type."); ksAppendKey (returned, key); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "options"); keySetString (key, fstabEntry->mnt_opts); keySetComment (key, "Filesystem specific options"); ksAppendKey (returned, key); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "dumpfreq"); snprintf (buffer, MAX_NUMBER_SIZE, "%d", fstabEntry->mnt_freq); keySetString (key, buffer); keySetComment (key, "Dump frequency in days"); ksAppendKey (returned, key); - key = keyDupOld (dir); + key = keyDup (dir, KEY_CP_ALL); keyAddBaseName (key, "passno"); snprintf (buffer, MAX_NUMBER_SIZE, "%d", fstabEntry->mnt_passno); keySetString (key, buffer); diff --git a/src/plugins/glob/glob.c b/src/plugins/glob/glob.c index bd3000de1f6..96a9c9d8ba3 100644 --- a/src/plugins/glob/glob.c +++ b/src/plugins/glob/glob.c @@ -62,7 +62,7 @@ enum GlobDirection static const char * getGlobFlags (KeySet * keys, Key * globKey) { - Key * flagKey = keyDupOld (globKey); + Key * flagKey = keyDup (globKey, KEY_CP_ALL); keyAddBaseName (flagKey, "flags"); Key * flagResult = ksLookup (keys, flagKey, KDB_O_NONE); keyDel (flagKey); @@ -114,7 +114,7 @@ static KeySet * getGlobKeys (Key * parentKey, KeySet * keys, enum GlobDirection /* We now know we want that key. Dup it to not change the configuration. */ - Key * ins = keyDupOld (k); + Key * ins = keyDup (k, KEY_CP_ALL); /* Now look if we want cascading for the key */ if (keyString (k)[0] == '/') { diff --git a/src/plugins/hexcode/testmod_hexcode.c b/src/plugins/hexcode/testmod_hexcode.c index 79e878e6d8c..3180a113e4d 100644 --- a/src/plugins/hexcode/testmod_hexcode.c +++ b/src/plugins/hexcode/testmod_hexcode.c @@ -85,7 +85,7 @@ void check_reversibility (const char * msg) char buf[1000]; hd->buf = buf; - Key * encode = keyDupOld (decode); + Key * encode = keyDup (decode, KEY_CP_ALL); elektraHexcodeEncode (encode, hd); elektraHexcodeDecode (encode, hd); diff --git a/src/plugins/hosts/hosts-get.c b/src/plugins/hosts/hosts-get.c index 94f40dd30de..a1cf04f40e8 100644 --- a/src/plugins/hosts/hosts-get.c +++ b/src/plugins/hosts/hosts-get.c @@ -165,7 +165,7 @@ static char * parseAlias (KeySet * append, const Key * hostParent, char * tokenP sret = elektraParseToken (&fieldBuffer, tokenPointer); if (sret == 0) return 0; - Key * alias = keyDupOld (hostParent); + Key * alias = keyDup (hostParent, KEY_CP_ALL); keyAddBaseName (alias, fieldBuffer); elektraFree (fieldBuffer); @@ -226,7 +226,7 @@ int elektraHostsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa ksClear (returned); KeySet * append = ksNew (ksGetSize (returned) * 2, KS_END); - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); ksAppendKey (append, key); Key * currentKey = 0; @@ -241,7 +241,7 @@ int elektraHostsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa if (!currentKey) { - currentKey = keyDupOld (parentKey); + currentKey = keyDup (parentKey, KEY_CP_ALL); } if (parseComment (comments, readBuffer, "#", &elektraAddLineComment)) continue; diff --git a/src/plugins/hosts/hosts-set.c b/src/plugins/hosts/hosts-set.c index bb1821c445e..660e9f7f820 100644 --- a/src/plugins/hosts/hosts-set.c +++ b/src/plugins/hosts/hosts-set.c @@ -69,9 +69,9 @@ static void writeLineComments (Key * key, FILE * fp) { if (strcmp (keyName (current), "meta:/comment/#0") != 0) { - Key * spaceKey = keyDupOld (current); + Key * spaceKey = keyDup (current, KEY_CP_ALL); keyAddBaseName (spaceKey, "space"); - Key * startKey = keyDupOld (current); + Key * startKey = keyDup (current, KEY_CP_ALL); keyAddBaseName (startKey, "start"); const char * spaces = getMetaValue (key, keyName (spaceKey)); const char * start = getMetaValue (key, keyName (startKey)); @@ -143,9 +143,9 @@ int elektraHostsSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa qsort (keyArray, arraySize, sizeof (Key *), keyCmpOrderWrapper); - Key * ipv4Base = keyDupOld (parentKey); + Key * ipv4Base = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (ipv4Base, "ipv4"); - Key * ipv6Base = keyDupOld (parentKey); + Key * ipv6Base = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (ipv6Base, "ipv6"); /* now write the hosts file */ diff --git a/src/plugins/hosts/keymetaformatting.c b/src/plugins/hosts/keymetaformatting.c index 05f3bc5ac24..37d094e9d0f 100644 --- a/src/plugins/hosts/keymetaformatting.c +++ b/src/plugins/hosts/keymetaformatting.c @@ -58,7 +58,7 @@ static void elektraAddCommentInfo (KeySet * comments, Key * commentBase, size_t if (commentStart) { /* this comment contains actual comment data */ - Key * commentStartKey = keyDupOld (commentBase); + Key * commentStartKey = keyDup (commentBase, KEY_CP_ALL); keyAddBaseName (commentStartKey, "start"); keySetString (commentStartKey, commentStart); ksAppendKey (comments, commentStartKey); @@ -71,7 +71,7 @@ static void elektraAddCommentInfo (KeySet * comments, Key * commentBase, size_t */ if (commentStart || spaces > 0) { - Key * commentSpaceKey = keyDupOld (commentBase); + Key * commentSpaceKey = keyDup (commentBase, KEY_CP_ALL); keyAddBaseName (commentSpaceKey, "space"); keySetStringF (commentSpaceKey, "%d", spaces); ksAppendKey (comments, commentSpaceKey); diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index 1a173ab3d94..94a27f31b15 100644 --- a/src/plugins/keytometa/keytometa.c +++ b/src/plugins/keytometa/keytometa.c @@ -136,8 +136,8 @@ static void flushConvertedKeys (Key * target, KeySet * converted, KeySet * orig) Key * appendTarget = target; const char * metaName = keyString (keyGetMeta (current, CONVERT_METANAME)); - Key * currentDup = keyDupOld (current); - Key * targetDup = keyDupOld (appendTarget); + Key * currentDup = keyDup (current, KEY_CP_ALL); + Key * targetDup = keyDup (appendTarget, KEY_CP_ALL); keySetBaseName (currentDup, 0); keySetBaseName (targetDup, 0); diff --git a/src/plugins/line/line.c b/src/plugins/line/line.c index 26d105fe282..08643e3b4c7 100644 --- a/src/plugins/line/line.c +++ b/src/plugins/line/line.c @@ -48,7 +48,7 @@ int elektraLineRead (FILE * fp, KeySet * returned) { value[n - 1] = '\0'; } - read = keyDupOld (ksTail (returned)); + read = keyDup (ksTail (returned), KEY_CP_ALL); if (elektraArrayIncName (read) == -1) { elektraFree (value); @@ -88,8 +88,8 @@ int elektraLineGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par } Key * b = keyNew (keyName (parentKey), KEY_END); - ksAppendKey (returned, keyDupOld (b)); // start with parentKey - keyAddName (b, "#"); // start point for our array + ksAppendKey (returned, keyDup (b, KEY_CP_ALL)); // start with parentKey + keyAddName (b, "#"); // start point for our array ksAppendKey (returned, b); int ret = elektraLineRead (fp, returned); diff --git a/src/plugins/list/list.c b/src/plugins/list/list.c index 0d26b01984f..07b59d98343 100644 --- a/src/plugins/list/list.c +++ b/src/plugins/list/list.c @@ -113,7 +113,7 @@ static int listParseConfiguration (Placements * placements, KeySet * config) } } Key * sub; - Key * lookup = keyDupOld (cur); + Key * lookup = keyDup (cur, KEY_CP_ALL); keyAddBaseName (lookup, "placements"); keyAddBaseName (lookup, "set"); sub = ksLookup (cutKS, lookup, 0); @@ -126,7 +126,7 @@ static int listParseConfiguration (Placements * placements, KeySet * config) if (strstr (setString, setStrings[setPlacement])) { rc = 1; - ksAppendKey (placements->setKS[setPlacement], keyDupOld (cur)); + ksAppendKey (placements->setKS[setPlacement], keyDup (cur, KEY_CP_ALL)); } ++setPlacement; } @@ -142,7 +142,7 @@ static int listParseConfiguration (Placements * placements, KeySet * config) if (strstr (getString, getStrings[getPlacement])) { rc = 1; - ksAppendKey (placements->getKS[getPlacement], keyDupOld (cur)); + ksAppendKey (placements->getKS[getPlacement], keyDup (cur, KEY_CP_ALL)); } ++getPlacement; } @@ -158,7 +158,7 @@ static int listParseConfiguration (Placements * placements, KeySet * config) if (strstr (errString, errStrings[errPlacement])) { rc = 1; - ksAppendKey (placements->errKS[errPlacement], keyDupOld (cur)); + ksAppendKey (placements->errKS[errPlacement], keyDup (cur, KEY_CP_ALL)); } ++errPlacement; } @@ -305,7 +305,7 @@ static int runPlugins (KeySet * pluginKS, KeySet * modules, KeySet * plugins, Ke { const char * name = keyString (current); - Key * handleKey = keyDupOld (current); + Key * handleKey = keyDup (current, KEY_CP_ALL); keyAddName (handleKey, "handle"); Key * handleLookup = ksLookup (configOrig, handleKey, 0); keyDel (handleKey); @@ -361,7 +361,7 @@ static int runPlugins (KeySet * pluginKS, KeySet * modules, KeySet * plugins, Ke slave->global = global; Key * slaveKey = keyNew ("/", KEY_BINARY, KEY_SIZE, sizeof (Plugin *), KEY_VALUE, &slave, KEY_END); keyAddBaseName (slaveKey, name); - ksAppendKey (plugins, keyDupOld (slaveKey)); + ksAppendKey (plugins, keyDup (slaveKey, KEY_CP_ALL)); keyDel (slaveKey); } } @@ -497,7 +497,7 @@ static char * getPluginPlacementList (Plugin * plugin) KeySet * ksResult = ksNew (0, KS_END); plugin->kdbGet (plugin, ksResult, pluginInfo); - Key * placementsKey = keyDupOld (pluginInfo); + Key * placementsKey = keyDup (pluginInfo, KEY_CP_ALL); keyAddBaseName (placementsKey, "infos"); keyAddBaseName (placementsKey, "placements"); Key * placements = ksLookup (ksResult, placementsKey, 0); @@ -644,7 +644,7 @@ static Key * findPluginInConfig (KeySet * config, const char * pluginName) if (strcmp (keyString (cur), pluginName) == 0) { // found plugin - Key * result = keyDupOld (cur); + Key * result = keyDup (cur, KEY_CP_ALL); keyDel (configBase); ksDel (array); return result; @@ -743,7 +743,7 @@ int elektraListMountPlugin (Plugin * handle, const char * pluginName, KeySet * p // Find plugin placements char * placementList = getPluginPlacementList (plugin); - Key * pluginPlacements = keyDupOld (pluginItem); + Key * pluginPlacements = keyDup (pluginItem, KEY_CP_ALL); keyAddBaseName (pluginPlacements, "placements"); // Append keys to list plugin configuration @@ -754,7 +754,7 @@ int elektraListMountPlugin (Plugin * handle, const char * pluginName, KeySet * p char * getPlacementsString = extractGetPlacements (placementList); if (getPlacementsString != NULL) { - Key * getPlacements = keyDupOld (pluginPlacements); + Key * getPlacements = keyDup (pluginPlacements, KEY_CP_ALL); keyAddBaseName (getPlacements, "get"); keySetString (getPlacements, getPlacementsString); ksAppendKey (config, getPlacements); @@ -766,7 +766,7 @@ int elektraListMountPlugin (Plugin * handle, const char * pluginName, KeySet * p char * setPlacementsString = extractSetPlacements (placementList); if (setPlacementsString != NULL) { - Key * setPlacements = keyDupOld (pluginPlacements); + Key * setPlacements = keyDup (pluginPlacements, KEY_CP_ALL); keyAddBaseName (setPlacements, "set"); keySetString (setPlacements, setPlacementsString); ksAppendKey (config, setPlacements); @@ -777,7 +777,7 @@ int elektraListMountPlugin (Plugin * handle, const char * pluginName, KeySet * p char * errorPlacementsString = extractErrorPlacements (placementList); if (errorPlacementsString != NULL) { - Key * errorPlacements = keyDupOld (pluginPlacements); + Key * errorPlacements = keyDup (pluginPlacements, KEY_CP_ALL); keyAddBaseName (errorPlacements, "error"); keySetString (errorPlacements, errorPlacementsString); ksAppendKey (config, errorPlacements); @@ -823,7 +823,7 @@ int elektraListUnmountPlugin (Plugin * handle, const char * pluginName, Key * er } // Look for plugin via handle - Key * pluginHandle = keyDupOld (pluginItem); + Key * pluginHandle = keyDup (pluginItem, KEY_CP_ALL); keyAddName (pluginHandle, "handle"); pluginHandle = ksLookup (config, pluginHandle, KDB_O_DEL); @@ -895,7 +895,7 @@ Plugin * elektraListFindPlugin (Plugin * handle, const char * pluginName) { while ((current = ksNext (placements->getKS[i])) != NULL) { - Key * handleKey = keyDupOld (current); + Key * handleKey = keyDup (current, KEY_CP_ALL); keyAddName (handleKey, "handle"); Key * handleLookup = ksLookup (config, handleKey, KDB_O_DEL); if (handleLookup) @@ -909,7 +909,7 @@ Plugin * elektraListFindPlugin (Plugin * handle, const char * pluginName) { while ((current = ksNext (placements->setKS[i])) != NULL) { - Key * handleKey = keyDupOld (current); + Key * handleKey = keyDup (current, KEY_CP_ALL); keyAddName (handleKey, "handle"); Key * handleLookup = ksLookup (config, handleKey, KDB_O_DEL); if (handleLookup) @@ -923,7 +923,7 @@ Plugin * elektraListFindPlugin (Plugin * handle, const char * pluginName) { while ((current = ksNext (placements->errKS[i])) != NULL) { - Key * handleKey = keyDupOld (current); + Key * handleKey = keyDup (current, KEY_CP_ALL); keyAddName (handleKey, "handle"); Key * handleLookup = ksLookup (config, handleKey, KDB_O_DEL); if (handleLookup) diff --git a/src/plugins/logchange/logchange.c b/src/plugins/logchange/logchange.c index a76dc28bb1f..e4d551ba84d 100644 --- a/src/plugins/logchange/logchange.c +++ b/src/plugins/logchange/logchange.c @@ -52,7 +52,7 @@ int elektraLogchangeGet (Plugin * handle, KeySet * returned, Key * parentKey ELE if (strncmp (keyString (ksLookupByName (elektraPluginGetConfig (handle), "/log/get", 0)), "1", 1) == 0) { - KeySet * logset = ksNew (1, keyDupOld (parentKey), KS_END); + KeySet * logset = ksNew (1, keyDup (parentKey, KEY_CP_ALL), KS_END); logKeys (logset, "loading configuration"); ksDel (logset); } diff --git a/src/plugins/mmapstorage/mmapstorage.c b/src/plugins/mmapstorage/mmapstorage.c index 85a68ff67ab..02502fa4dba 100644 --- a/src/plugins/mmapstorage/mmapstorage.c +++ b/src/plugins/mmapstorage/mmapstorage.c @@ -1327,7 +1327,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle ELEKTRA_UNUSED, KeySet * ks, int fd = -1; char * mappedRegion = MAP_FAILED; - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); if (elektraStrCmp (keyString (parentKey), STDIN_FILENAME) == 0) { @@ -1504,7 +1504,7 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle ELEKTRA_UNUSED, KeySet * ks, int fd = -1; char * mappedRegion = MAP_FAILED; DynArray * dynArray = 0; - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); if (elektraStrCmp (keyString (parentKey), STDOUT_FILENAME) == 0) { diff --git a/src/plugins/multifile/multifile.c b/src/plugins/multifile/multifile.c index 5e33fb85743..1b87f0cf75e 100644 --- a/src/plugins/multifile/multifile.c +++ b/src/plugins/multifile/multifile.c @@ -407,7 +407,7 @@ static Codes updateFiles (Plugin * handle, MultiConfig * mc, KeySet * returned, { Codes rc = NOUPDATE; KeySet * found = ksNew (0, KS_END); - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); rc = updateFilesGlob (handle, mc, found, parentKey); if (rc == ERROR) @@ -488,7 +488,7 @@ static Codes updateFiles (Plugin * handle, MultiConfig * mc, KeySet * returned, static Codes doGetStorage (MultiConfig * mc, Key * parentKey) { ksRewind (mc->childBackends); - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); Codes rc = NOUPDATE; Key * k; while ((k = ksNext (mc->childBackends)) != NULL) @@ -609,7 +609,7 @@ int elektraMultifileGet (Plugin * handle, KeySet * returned, Key * parentKey ELE static Codes resolverSet (MultiConfig * mc, Key * parentKey) { ksRewind (mc->childBackends); - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); Key * k; Codes rc = NOUPDATE; while ((k = ksNext (mc->childBackends)) != NULL) @@ -650,7 +650,7 @@ static Codes resolverSet (MultiConfig * mc, Key * parentKey) static Codes doSetStorage (MultiConfig * mc, Key * parentKey) { ksRewind (mc->childBackends); - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); Codes rc = NOUPDATE; Key * k; while ((k = ksNext (mc->childBackends)) != NULL) @@ -686,7 +686,7 @@ static Codes doSetStorage (MultiConfig * mc, Key * parentKey) static Codes doCommit (MultiConfig * mc, Key * parentKey) { ksRewind (mc->childBackends); - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); Codes rc = NOUPDATE; Key * k; while ((k = ksNext (mc->childBackends)) != NULL) @@ -828,7 +828,7 @@ int elektraMultifileError (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE if (!mc) return 0; ksRewind (mc->childBackends); Key * key; - Key * initialParent = keyDupOld (parentKey); + Key * initialParent = keyDup (parentKey, KEY_CP_ALL); while ((key = ksNext (mc->childBackends)) != NULL) { SingleConfig * s = *(SingleConfig **) keyValue (key); diff --git a/src/plugins/passwd/passwd.c b/src/plugins/passwd/passwd.c index cdd89b51461..d2a531423e3 100644 --- a/src/plugins/passwd/passwd.c +++ b/src/plugins/passwd/passwd.c @@ -128,7 +128,7 @@ static KeySet * pwentToKS (struct passwd * pwd, Key * parentKey, SortBy index) snprintf (id, sizeof (id), "%u", pwd->pw_uid); keyAddBaseName (append, id); keySetBinary (append, 0, 0); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keyAddBaseName (append, "name"); keySetString (append, pwd->pw_name); } @@ -136,33 +136,33 @@ static KeySet * pwentToKS (struct passwd * pwd, Key * parentKey, SortBy index) { keyAddBaseName (append, pwd->pw_name); keySetBinary (append, 0, 0); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); snprintf (id, sizeof (id), "%u", pwd->pw_uid); keyAddBaseName (append, "uid"); keySetString (append, id); } - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keySetString (append, 0); keySetBaseName (append, "shell"); keySetString (append, pwd->pw_shell); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keySetString (append, 0); keySetBaseName (append, "home"); keySetString (append, pwd->pw_dir); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keySetString (append, 0); keySetBaseName (append, "gid"); snprintf (id, sizeof (id), "%u", pwd->pw_gid); keySetString (append, id); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keySetString (append, 0); keySetBaseName (append, "passwd"); keySetString (append, pwd->pw_passwd); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keySetString (append, 0); keySetBaseName (append, "gecos"); keySetString (append, pwd->pw_gecos); - ksAppendKey (ks, keyDupOld (append)); + ksAppendKey (ks, keyDup (append, KEY_CP_ALL)); keyDel (append); return ks; } @@ -227,7 +227,7 @@ static struct passwd * KStoPasswd (KeySet * ks, SortBy index) struct passwd * pwd = elektraMalloc (sizeof (struct passwd)); ksRewind (ks); Key * parent = ksNext (ks); - Key * lookup = keyDupOld (parent); + Key * lookup = keyDup (parent, KEY_CP_ALL); Key * found = NULL; if (index == UID) { diff --git a/src/plugins/process/process.c b/src/plugins/process/process.c index f2bda22cbb7..47e80070e87 100644 --- a/src/plugins/process/process.c +++ b/src/plugins/process/process.c @@ -151,7 +151,7 @@ static void adjustContract (KeySet * pluginContract, KeySet * contract) Key * cur; while ((cur = ksNext (pluginContract)) != NULL) { - Key * cpy = keyDupOld (cur); + Key * cpy = keyDup (cur, KEY_CP_ALL); keySetBaseName (cpy, NULL); if (!elektraStrCmp ("infos", keyBaseName (cpy))) { @@ -196,7 +196,7 @@ int elektraProcessGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!validPluginName (pluginName, parentKey) || !process->plugin) return ELEKTRA_PLUGIN_STATUS_SUCCESS; - Key * pluginParentKey = keyDupOld (parentKey); + Key * pluginParentKey = keyDup (parentKey, KEY_CP_ALL); keySetBaseName (pluginParentKey, keyString (pluginName)); KeySet * pluginContract = ksNew (30, KS_END); diff --git a/src/plugins/profile/profile.c b/src/plugins/profile/profile.c index 3c447f366e2..2f948c48867 100644 --- a/src/plugins/profile/profile.c +++ b/src/plugins/profile/profile.c @@ -90,9 +90,9 @@ static void linkProfileKeys (KeySet * swKS, KeySet * profileKeys, KeySet * appen profileString = keyString (profileKey); if (profileString) { - profileCutKey = keyDupOld (profileKey); + profileCutKey = keyDup (profileKey, KEY_CP_ALL); keyAddName (profileCutKey, ".."); - Key * currentProfileKey = keyDupOld (profileCutKey); + Key * currentProfileKey = keyDup (profileCutKey, KEY_CP_ALL); keyAddBaseName (currentProfileKey, "current"); keyAddBaseName (profileCutKey, profileString); KeySet * profileKS = ksCut (swKS, profileCutKey); @@ -113,8 +113,8 @@ static void linkProfileKeys (KeySet * swKS, KeySet * profileKeys, KeySet * appen } keyDel (lookupKey); keySetMeta (overrideKey, "override/#0", keyName (cur)); - ksAppendKey (swKS, keyDupOld (overrideKey)); - ksAppendKey (appendedKeys, keyDupOld (overrideKey)); + ksAppendKey (swKS, keyDup (overrideKey, KEY_CP_ALL)); + ksAppendKey (appendedKeys, keyDup (overrideKey, KEY_CP_ALL)); keyDel (overrideKey); } keyDel (currentProfileKey); @@ -131,12 +131,12 @@ static void linkDefaultKeys (KeySet * swKS, KeySet * profileParents, KeySet * ap Key * profileParent = NULL; while ((profileParent = ksNext (profileParents)) != NULL) { - Key * defaultCutKey = keyDupOld (profileParent); + Key * defaultCutKey = keyDup (profileParent, KEY_CP_ALL); keyAddName (defaultCutKey, "%"); KeySet * defaultKS = ksCut (swKS, defaultCutKey); ksRewind (defaultKS); Key * cur; - Key * currentProfileKey = keyDupOld (profileParent); + Key * currentProfileKey = keyDup (profileParent, KEY_CP_ALL); keyAddName (currentProfileKey, "current"); while ((cur = ksNext (defaultKS)) != NULL) { @@ -153,8 +153,8 @@ static void linkDefaultKeys (KeySet * swKS, KeySet * profileParents, KeySet * ap } keyDel (existingKey); keySetMeta (overrideKey, "override/#0", keyName (cur)); - ksAppendKey (swKS, keyDupOld (overrideKey)); - ksAppendKey (appendedKeys, keyDupOld (overrideKey)); + ksAppendKey (swKS, keyDup (overrideKey, KEY_CP_ALL)); + ksAppendKey (appendedKeys, keyDup (overrideKey, KEY_CP_ALL)); keyDel (overrideKey); } keyDel (currentProfileKey); @@ -209,9 +209,9 @@ int elektraProfileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA { if (!fnmatch (CURRENTPATH, keyName (cur), FNM_PATHNAME)) { - Key * profileParent = keyDupOld (cur); + Key * profileParent = keyDup (cur, KEY_CP_ALL); keyAddName (profileParent, ".."); - ksAppendKey (profileParents, keyDupOld (profileParent)); + ksAppendKey (profileParents, keyDup (profileParent, KEY_CP_ALL)); keyDel (profileParent); } } diff --git a/src/plugins/reference/reference.c b/src/plugins/reference/reference.c index 2de6e74bcd0..b0ab472f8e3 100644 --- a/src/plugins/reference/reference.c +++ b/src/plugins/reference/reference.c @@ -116,7 +116,7 @@ static int checkSingleReference (const Key * key, KeySet * allKeys, Key * parent } else { - refArray = ksNew (1, keyDupOld (key), KS_END); + refArray = ksNew (1, keyDup (key, KEY_CP_ALL), KS_END); } ksRewind (refArray); @@ -249,7 +249,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * KeySet * keysToCheck = ksNew (0, KS_END); const char * refname = keyBaseName (curRoot); - Key * rootParent = keyDupOld (curRoot); + Key * rootParent = keyDup (curRoot, KEY_CP_ALL); keySetBaseName (rootParent, NULL); ksAppendKey (keysToCheck, rootParent); @@ -311,7 +311,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * } else { - Key * element = keyDupOld (baseKey); + Key * element = keyDup (baseKey, KEY_CP_ALL); keyAddBaseName (element, "#0"); refArray = ksNew (1, element, KS_END); } @@ -387,7 +387,7 @@ static int checkRecursiveReference (const Key * rootKey, KeySet * allKeys, Key * if (!rgContains (referenceGraph, refKeyName)) { - ksAppendKey (keysToCheck, keyDupOld (refKey)); + ksAppendKey (keysToCheck, keyDup (refKey, KEY_CP_ALL)); rgAddNode (referenceGraph, refKeyName); } rgAddEdge (referenceGraph, curName, refKeyName); diff --git a/src/plugins/reference/referencegraph.c b/src/plugins/reference/referencegraph.c index fb5794ef759..c292212c200 100644 --- a/src/plugins/reference/referencegraph.c +++ b/src/plugins/reference/referencegraph.c @@ -59,7 +59,7 @@ bool rgAddEdge (RefGraph * graph, const char * fromNode, const char * toNode) return false; } - Key * lastKey = keyDupOld (keyGetMeta (node, "last")); + Key * lastKey = keyDup (keyGetMeta (node, "last"), KEY_CP_ALL); if (elektraArrayIncName (lastKey) < 0) { keyDel (lastKey); diff --git a/src/plugins/rename/rename.c b/src/plugins/rename/rename.c index 482e01757d2..4857a79a348 100644 --- a/src/plugins/rename/rename.c +++ b/src/plugins/rename/rename.c @@ -146,7 +146,7 @@ Key * elektraKeyCreateNewName (const Key * key, const Key * parentKey, const cha elektraFree (curKeyName); if (replace) { - Key * result = keyDupOld (key); + Key * result = keyDup (key, KEY_CP_ALL); keySetName (result, keyName (parentKey)); keyAddName (result, newName); elektraFree (newName); @@ -214,7 +214,7 @@ static Key * restoreKeyName (Key * key, const Key * parentKey, const Key * confi if (strcmp (keyString (origNameKey), keyName (key))) { int hasSync = keyNeedSync (key); // test_bit(key->flags, KEY_FLAG_SYNC); - Key * result = keyDupOld (key); + Key * result = keyDup (key, KEY_CP_ALL); keySetName (result, keyString (origNameKey)); keySetMeta (result, ELEKTRA_ORIGINAL_NAME_META, 0); @@ -230,7 +230,7 @@ static Key * restoreKeyName (Key * key, const Key * parentKey, const Key * confi if (configKey) { int hasSync = keyNeedSync (key); // test_bit(key->flags, KEY_FLAG_SYNC); - Key * result = keyDupOld (key); + Key * result = keyDup (key, KEY_CP_ALL); keySetName (result, keyName (parentKey)); keyAddName (result, keyString (configKey)); @@ -363,7 +363,7 @@ int elektraRenameSet (Plugin * handle, KeySet * returned, Key * parentKey) { renamedKey = restoreKeyName (key, parentKey, cutConfig); - if (!renamedKey) renamedKey = keyDupOld (key); + if (!renamedKey) renamedKey = keyDup (key, KEY_CP_ALL); if (writeConversion == TOUPPER || writeConversion == TOLOWER) { char * curKeyName = elektraMalloc (keyGetNameSize (renamedKey)); diff --git a/src/plugins/rename/testmod_rename.c b/src/plugins/rename/testmod_rename.c index 236a372526d..3effbe039bf 100644 --- a/src/plugins/rename/testmod_rename.c +++ b/src/plugins/rename/testmod_rename.c @@ -129,7 +129,7 @@ static void test_metaCutOnGet (void) static void test_simpleCutRestoreOnSet (void) { Key * parentKey = keyNew ("user:/tests/rename", KEY_END); - Key * parentKeyCopy = keyDupOld (parentKey); + Key * parentKeyCopy = keyDup (parentKey, KEY_CP_ALL); KeySet * conf = ksNew (20, keyNew ("system:/cut", KEY_VALUE, "will/be/stripped", KEY_END), KS_END); PLUGIN_OPEN ("rename"); @@ -168,7 +168,7 @@ static void test_simpleCutRestoreOnSet (void) static void test_withoutConfig (void) { Key * parentKey = keyNew ("user:/tests/rename", KEY_END); - Key * parentKeyCopy = keyDupOld (parentKey); + Key * parentKeyCopy = keyDup (parentKey, KEY_CP_ALL); KeySet * conf = ksNew (0, KS_END); PLUGIN_OPEN ("rename"); diff --git a/src/plugins/spec/spec.c b/src/plugins/spec/spec.c index 6d774b81843..74a8320decb 100644 --- a/src/plugins/spec/spec.c +++ b/src/plugins/spec/spec.c @@ -322,7 +322,7 @@ static int handleErrors (Key * key, Key * parentKey, KeySet * ks, Key * specKey, parseLocalConfig (specKey, &localCh, isKdbGet); - Key * parentLookup = keyDupOld (key); + Key * parentLookup = keyDup (key, KEY_CP_ALL); keySetBaseName (parentLookup, NULL); elektraCursor cursor = ksGetCursor (ks); @@ -612,7 +612,7 @@ static KeySet * instantiateArraySpec (KeySet * ks, Key * arraySpec, Key * parent while (strcmp (elem, arraySize) <= 0) { - Key * new = keyDupOld (k); + Key * new = keyDup (k, KEY_CP_ALL); keyAddBaseName (new, elem); ksAppendKey (curNew, new); @@ -631,7 +631,7 @@ static KeySet * instantiateArraySpec (KeySet * ks, Key * arraySpec, Key * parent ksRewind (newKeys); while ((k = ksNext (newKeys)) != NULL) { - Key * new = keyDupOld (k); + Key * new = keyDup (k, KEY_CP_ALL); keyAddBaseName (new, cur); ksAppendKey (curNew, new); } @@ -704,7 +704,7 @@ static bool isWildcardSpec (const Key * key) */ static void validateWildcardSubs (KeySet * ks, Key * key) { - Key * parent = keyDupOld (key); + Key * parent = keyDup (key, KEY_CP_ALL); keySetBaseName (parent, NULL); // TODO: [improvement] ksExtract?, like ksCut, but doesn't remove -> no need for ksDup diff --git a/src/plugins/specload/specload.c b/src/plugins/specload/specload.c index 038d8062ced..1048e055611 100644 --- a/src/plugins/specload/specload.c +++ b/src/plugins/specload/specload.c @@ -595,7 +595,7 @@ int isChangeAllowed (Key * oldKey, Key * newKey) } else { - oldKey = keyDupOld (oldKey); + oldKey = keyDup (oldKey, KEY_CP_ALL); } if (newKey == NULL) @@ -610,7 +610,7 @@ int isChangeAllowed (Key * oldKey, Key * newKey) } else { - newKey = keyDupOld (newKey); + newKey = keyDup (newKey, KEY_CP_ALL); } KeySet * metaDiff = calculateMetaDiff (oldKey, newKey); diff --git a/src/plugins/toml/driver.c b/src/plugins/toml/driver.c index 1b8c6da939b..fa8940ecb46 100644 --- a/src/plugins/toml/driver.c +++ b/src/plugins/toml/driver.c @@ -83,7 +83,7 @@ static Driver * createDriver (Key * parent, KeySet * keys) } driver->root = parent; driver->keys = keys; - driver->parentStack = pushParent (NULL, keyDupOld (parent)); + driver->parentStack = pushParent (NULL, keyDup (parent, KEY_CP_ALL)); driver->filename = elektraStrDup (keyString (parent)); driver->simpleTableActive = false; driver->drainCommentsOnKeyExit = true; @@ -461,7 +461,7 @@ void driverExitTableArray (Driver * driver) driver->order--; // Undo order increment Key * key = buildTableArrayKeyName (driver->tableArrayStack); - Key * rootNameKey = keyDupOld (key); + Key * rootNameKey = keyDup (key, KEY_CP_ALL); keyAddName (rootNameKey, ".."); Key * existingRoot = ksLookup (driver->keys, rootNameKey, 0); diff --git a/src/plugins/toml/prepare.c b/src/plugins/toml/prepare.c index 65405c73abe..5fe65d8446b 100644 --- a/src/plugins/toml/prepare.c +++ b/src/plugins/toml/prepare.c @@ -226,7 +226,7 @@ static ArrayInfo * updateArrayInfo (ArrayInfo * root, Key * name, size_t index) { return NULL; } - element->name = keyDupOld (name); + element->name = keyDup (name, KEY_CP_ALL); element->maxIndex = index; element->next = root; return element; diff --git a/src/plugins/toml/table_array.c b/src/plugins/toml/table_array.c index a380d33f7ee..4fbdd2cf25c 100644 --- a/src/plugins/toml/table_array.c +++ b/src/plugins/toml/table_array.c @@ -74,7 +74,7 @@ static char * getChildFraction (const Key * parent, const Key * child) } else { - Key * childDup = keyDupOld (child); + Key * childDup = keyDup (child, KEY_CP_ALL); size_t fracSize = 256; char * fraction = elektraCalloc (sizeof (char) * fracSize); if (fraction == NULL) diff --git a/src/plugins/toml/testmod_toml.c b/src/plugins/toml/testmod_toml.c index 9aa12152c55..a09fe230ed9 100644 --- a/src/plugins/toml/testmod_toml.c +++ b/src/plugins/toml/testmod_toml.c @@ -55,7 +55,7 @@ { \ if (lastKey != NULL) \ { \ - lastKey = keyDupOld (lastKey); \ + lastKey = keyDup (lastKey, KEY_CP_ALL); \ ksAppendKey (expectedKs, lastKey); \ } \ } diff --git a/src/plugins/uname/uname.c b/src/plugins/uname/uname.c index 5141ace6c4d..91f3a0711ce 100644 --- a/src/plugins/uname/uname.c +++ b/src/plugins/uname/uname.c @@ -23,34 +23,34 @@ static void elektraAddUname (KeySet * returned, Key * parentKey) { Key * dir; - Key * key = keyDupOld (parentKey); + Key * key = keyDup (parentKey, KEY_CP_ALL); ksAppendKey (returned, key); struct utsname buf; uname (&buf); // TODO: handle error - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, "sysname"); keySetString (dir, buf.sysname); ksAppendKey (returned, dir); - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, "nodename"); keySetString (dir, buf.nodename); ksAppendKey (returned, dir); - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, "release"); keySetString (dir, buf.release); ksAppendKey (returned, dir); - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, "version"); keySetString (dir, buf.version); ksAppendKey (returned, dir); - dir = keyDupOld (parentKey); + dir = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (dir, "machine"); keySetString (dir, buf.machine); ksAppendKey (returned, dir); diff --git a/src/plugins/yajl/yajl_gen.c b/src/plugins/yajl/yajl_gen.c index bf77d2a0ec2..ed387a0b1b3 100644 --- a/src/plugins/yajl/yajl_gen.c +++ b/src/plugins/yajl/yajl_gen.c @@ -197,7 +197,7 @@ int elektraGenEmpty (yajl_gen g, KeySet * returned, Key * parentKey) } else if (ksGetSize (returned) == 2) // maybe just parent+specialkey { - Key * toCheck = keyDupOld (parentKey); + Key * toCheck = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (toCheck, "###empty_array"); if (!strcmp (keyName (ksTail (returned)), keyName (toCheck))) diff --git a/src/plugins/yajl/yajl_parse.c b/src/plugins/yajl/yajl_parse.c index e566e22177e..5522975beee 100644 --- a/src/plugins/yajl/yajl_parse.c +++ b/src/plugins/yajl/yajl_parse.c @@ -265,7 +265,7 @@ static void elektraYajlParseSuppressNonLeafKeys (KeySet * returned) if (ksNext (returned) == NULL) break; - Key * peekDup = keyDupOld (ksCurrent (returned)); + Key * peekDup = keyDup (ksCurrent (returned), KEY_CP_ALL); keySetBaseName (peekDup, 0); if (!strcmp (keyName (peekDup), keyName (cur))) @@ -301,7 +301,7 @@ static void elektraYajlParseSuppressEmptyMap (KeySet * returned, Key * parentKey if (ksGetSize (returned) == 2) { - Key * lookupKey = keyDupOld (parentKey); + Key * lookupKey = keyDup (parentKey, KEY_CP_ALL); keyAddBaseName (lookupKey, "___empty_map"); Key * toRemove = ksLookup (returned, lookupKey, KDB_O_POP); diff --git a/src/tools/elektrad/CMakeLists.txt b/src/tools/elektrad/CMakeLists.txt index c83cb4e7d2c..97e65936f5c 100644 --- a/src/tools/elektrad/CMakeLists.txt +++ b/src/tools/elektrad/CMakeLists.txt @@ -1,3 +1,6 @@ +remove_tool (elektrad "API incompatible") +return () + find_program (GO_EXECUTABLE "go") list (FIND REMOVED_PLUGINS "yajl" yajl_index) diff --git a/tests/abi/testabi_key.c b/tests/abi/testabi_key.c index b191cc22d5f..f6eb8fefca4 100644 --- a/tests/abi/testabi_key.c +++ b/tests/abi/testabi_key.c @@ -219,7 +219,7 @@ static void test_keyReference (void) succeed_if (keyIncRef (key) == 4, "keyIncRef return value"); succeed_if (keyGetRef (key) == 4, "After keyIncRef key reference"); - d = keyDupOld (key); + d = keyDup (key, KEY_CP_ALL); succeed_if (keyGetRef (d) == 0, "After keyDup key reference"); succeed_if (keyIncRef (d) == 1, "keyIncRef return value"); succeed_if (keyGetRef (key) == 4, "Reference should not change"); @@ -740,7 +740,7 @@ static void test_keyNameSlashes (void) keyCopy (copy, key, KEY_CP_ALL); succeed_if (keyGetRef (copy) == 0, "reference of copy not correct"); - Key * dup = keyDupOld (key); + Key * dup = keyDup (key, KEY_CP_ALL); succeed_if (keyGetRef (dup) == 0, "reference of dup not correct"); compare_key (copy, key); @@ -1378,14 +1378,14 @@ static void test_keyDup (void) printf ("Test key duplication\n"); - succeed_if (keyDupOld (0) == 0, "could not duplicate null"); + succeed_if (keyDup (0, KEY_CP_ALL) != 0, "could duplicate null"); // Create test key orig = keyNew ("user:/foo/bar", KEY_BINARY, KEY_SIZE, 6, KEY_VALUE, "foobar", KEY_COMMENT, "mycomment", KEY_END); // Dup the key - succeed_if ((copy = keyDupOld (orig)) != 0, "keyDup failed"); + succeed_if ((copy = keyDup (orig, KEY_CP_ALL)) != 0, "keyDup failed"); compare_key (orig, copy); keyDel (orig); // everything independent from original! @@ -1396,7 +1396,7 @@ static void test_keyDup (void) // Dup the key again Key * ccopy; - succeed_if ((ccopy = keyDupOld (copy)) != 0, "keyDup failed"); + succeed_if ((ccopy = keyDup (copy, KEY_CP_ALL)) != 0, "keyDup failed"); compare_key (copy, ccopy); keyDel (copy); // everything independent from original! @@ -1409,7 +1409,7 @@ static void test_keyDup (void) orig = keyNew ("/", KEY_END); keySetName (orig, "invalid"); - succeed_if ((copy = keyDupOld (orig)) != 0, "keyDup failed"); + succeed_if ((copy = keyDup (orig, KEY_CP_ALL)) != 0, "keyDup failed"); succeed_if_same_string (keyName (orig), "/"); succeed_if_same_string (keyName (copy), "/"); succeed_if (keyGetNameSize (orig) == 2, "orig name size"); @@ -1487,8 +1487,8 @@ static void test_keyCopy (void) succeed_if (keyCopy (copy, orig, KEY_CP_NAME) == copy, "keyCopy failed"); succeed_if_same_string (keyName (orig), "user:/orig"); succeed_if_same_string (keyName (copy), "user:/orig"); - keyGetString (orig, origBuffer, sizeof(origBuffer)); - keyGetString (copy, copyBuffer, sizeof(copyBuffer)); + keyGetString (orig, origBuffer, sizeof (origBuffer)); + keyGetString (copy, copyBuffer, sizeof (copyBuffer)); succeed_if_same_string (origBuffer, "orig"); succeed_if_same_string (copyBuffer, "copy"); succeed_if_same_string (keyValue (keyGetMeta (orig, "orig")), "orig"); @@ -1511,8 +1511,8 @@ static void test_keyCopy (void) succeed_if (keyCopy (copy, orig, KEY_CP_VALUE) == copy, "keyCopy failed"); succeed_if_same_string (keyName (orig), "user:/orig"); succeed_if_same_string (keyName (copy), "user:/copy"); - keyGetString (orig, origBuffer, sizeof(origBuffer)); - keyGetString (copy, copyBuffer, sizeof(copyBuffer)); + keyGetString (orig, origBuffer, sizeof (origBuffer)); + keyGetString (copy, copyBuffer, sizeof (copyBuffer)); succeed_if_same_string (origBuffer, "orig"); succeed_if_same_string (copyBuffer, "orig"); succeed_if_same_string (keyValue (keyGetMeta (orig, "orig")), "orig"); @@ -1535,8 +1535,8 @@ static void test_keyCopy (void) succeed_if (keyCopy (copy, orig, KEY_CP_META) == copy, "keyCopy failed"); succeed_if_same_string (keyName (orig), "user:/orig"); succeed_if_same_string (keyName (copy), "user:/copy"); - keyGetString (orig, origBuffer, sizeof(origBuffer)); - keyGetString (copy, copyBuffer, sizeof(copyBuffer)); + keyGetString (orig, origBuffer, sizeof (origBuffer)); + keyGetString (copy, copyBuffer, sizeof (copyBuffer)); succeed_if_same_string (origBuffer, "orig"); succeed_if_same_string (copyBuffer, "copy"); succeed_if_same_string (keyValue (keyGetMeta (orig, "orig")), "orig"); diff --git a/tests/abi/testabi_ks.c b/tests/abi/testabi_ks.c index 850f74c4195..8331708ea80 100644 --- a/tests/abi/testabi_ks.c +++ b/tests/abi/testabi_ks.c @@ -178,7 +178,7 @@ static void test_ksReference (void) succeed_if (ksHead (ks) == k1, "head wrong"); succeed_if (ksTail (ks) == k1, "tail wrong"); - k2 = keyDupOld (k1); + k2 = keyDup (k1, KEY_CP_ALL); keySetString (k2, "newvalue"); succeed_if (keyGetRef (k2) == 0, "reference counter not resetted"); @@ -748,7 +748,7 @@ static void test_ksSort (void) k1 = keyNew ("user:/xname", KEY_END); ksAppendKey (ks, k1); - k2 = keyDupOld (k1); + k2 = keyDup (k1, KEY_CP_ALL); succeed_if (keyGetRef (k2) == 0, "reference counter not resetted"); ksAppendKey (ks, k2); @@ -760,7 +760,7 @@ static void test_ksSort (void) ks = ksNew (0, KS_END); k1 = keyNew ("user:/yname", KEY_END); - k2 = keyDupOld (k1); + k2 = keyDup (k1, KEY_CP_ALL); ksAppendKey (ks, k2); ksAppendKey (ks, k1); @@ -1316,7 +1316,7 @@ static void test_ksLookupNameCascading (void) Key * k2; ksAppendKey (ks, k1 = keyNew ("system:/test/myapp/key", KEY_VALUE, "wrong", KEY_END)); ksAppendKey (ks, k2 = keyNew ("user:/test/myapp/key", KEY_VALUE, "correct", KEY_END)); - ksAppendKey (ks, keyDupOld ((s = keyNew ("/test/myapp/key", KEY_END)))); + ksAppendKey (ks, keyDup ((s = keyNew ("/test/myapp/key", KEY_END)), KEY_CP_ALL)); succeed_if (ksGetSize (ks) == 3, "initial size of keyset"); succeed_if (keyGetNameSize (s) == 16, "initial name size"); @@ -1571,7 +1571,7 @@ int ksFilter (KeySet * result, KeySet * input, int (*filter) (Key * k)) else if (rc != 0) { ++ret; - ksAppendKey (result, keyDupOld (current)); + ksAppendKey (result, keyDup (current, KEY_CP_ALL)); } } ksSetCursor (input, cursor); @@ -1994,7 +1994,7 @@ static void test_ksAppendKey (void) succeed_if (ksCurrent (ks) == cur, "did not update current position"); succeed_if (ksGetSize (ks) == 4, "size not correct after 4 keys"); - Key * newKey = keyDupOld (cur); + Key * newKey = keyDup (cur, KEY_CP_ALL); keySetBaseName (newKey, "second_bool_key"); succeed_if (ksAppendKey (ks, newKey) == 5, "could not append a key"); @@ -2212,7 +2212,7 @@ static void test_cut (void) for (int i = 0; i < 16; ++i) { orig = set_a (); - cutpoint = keyDupOld (ksAtCursor (orig, i)); + cutpoint = keyDup (ksAtCursor (orig, i), KEY_CP_ALL); result = ksCut (orig, cutpoint); compare_keyset (result, cmp_result[i]); @@ -2710,7 +2710,7 @@ static void test_simpleLookup (void) Key * k0 = ksLookup (ks, searchKey, 0); succeed_if (!k0, "we have a problem: found not inserted key"); - Key * dup = keyDupOld (searchKey); + Key * dup = keyDup (searchKey, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "user:/something"); succeed_if_same_string (keyString (dup), "a value"); ksAppendKey (ks, dup); @@ -2797,7 +2797,7 @@ static void test_ksAppend2 (void) succeed_if_same_string (keyValue (keyGetMeta (ksCurrent (ks2), "hello")), "hello_world"); succeed_if (keyGetMeta (ksCurrent (ks2), "error") == 0, "hello was not set up to now"); - Key * dup = keyDupOld (inks); + Key * dup = keyDup (inks, KEY_CP_ALL); succeed_if_same_string (keyValue (keyGetMeta (inks, "hello")), "hello_world"); succeed_if (keyGetMeta (inks, "error") == 0, "hello was not set up to now"); @@ -2825,7 +2825,7 @@ static void test_ksAppend2 (void) ksRewind (iter); Key * key = ksNext (iter); succeed_if (keyGetMeta (key, "name") == 0, "no such meta exists"); - Key * result = keyDupOld (key); + Key * result = keyDup (key, KEY_CP_ALL); succeed_if (keyGetRef (parent) == 2, "ref wrong"); succeed_if (keyGetRef (result) == 0, "ref wrong"); keySetName (result, keyName (parent)); diff --git a/tests/abi/testabi_meta.c b/tests/abi/testabi_meta.c index ba0c5ef53a6..f374e32a7d5 100644 --- a/tests/abi/testabi_meta.c +++ b/tests/abi/testabi_meta.c @@ -180,7 +180,7 @@ static void test_dup (void) succeed_if (keySetMeta (key, "test", "some_meta_test") == sizeof ("some_meta_test"), "could not set meta"); succeed_if_same_string (keyValue (keyGetMeta (key, "test")), "some_meta_test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyValue (keyGetMeta (dup, "test")), "some_meta_test"); succeed_if (keySetMeta (dup, "test", "some_other_meta_test") == sizeof ("some_other_meta_test"), "sizeof meta test wrong"); succeed_if_same_string (keyValue (keyGetMeta (dup, "test")), "some_other_meta_test"); diff --git a/tests/ctest/test_key.c b/tests/ctest/test_key.c index f4946ec3ee9..545f86c9026 100644 --- a/tests/ctest/test_key.c +++ b/tests/ctest/test_key.c @@ -370,13 +370,13 @@ static void test_keySetName (void) succeed_if (keySetName (key, "/") != -1, "could not set cascading name"); succeed_if_same_string (keyName (key), "/"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "/"); keyDel (dup); keySetName (key, "/c"); succeed_if_same_string (keyName (key), "/c"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "/c"); keyDel (dup); @@ -384,43 +384,43 @@ static void test_keySetName (void) succeed_if_same_string (keyName (key), "/"); keySetName (key, "/cascading"); succeed_if_same_string (keyName (key), "/cascading"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "/cascading"); keyDel (dup); keySetName (key, "/cascading/s/deep/below"); succeed_if_same_string (keyName (key), "/cascading/s/deep/below"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "/cascading/s/deep/below"); keyDel (dup); keySetName (key, "user:/cascading/s/deep/below"); succeed_if_same_string (keyName (key), "user:/cascading/s/deep/below"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "user:/cascading/s/deep/below"); keyDel (dup); keySetName (key, "system:/cascading/s/deep/below"); succeed_if_same_string (keyName (key), "system:/cascading/s/deep/below"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "system:/cascading/s/deep/below"); keyDel (dup); keySetName (key, "meta:/order"); succeed_if_same_string (keyName (key), "meta:/order"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "meta:/order"); keyDel (dup); keySetName (key, "meta:/check/type"); succeed_if_same_string (keyName (key), "meta:/check/type"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "meta:/check/type"); keyDel (dup); keySetName (key, "meta:/a"); succeed_if_same_string (keyName (key), "meta:/a"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "meta:/a"); keyDel (dup); @@ -432,21 +432,21 @@ static void test_keySetName (void) keySetName (key, "/cascading"); succeed_if_same_string (keyName (key), "/cascading"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "/cascading"); keyDel (dup); keySetName (key, "meta:/"); succeed_if_same_string (keyName (key), "meta:/"); succeed_if (key->key != 0, "null pointer?"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "meta:/"); keyDel (dup); keySetName (key, "meta:/other"); succeed_if_same_string (keyName (key), "meta:/other"); succeed_if (key->key != 0, "null pointer?"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "meta:/other"); keyDel (dup); @@ -454,31 +454,31 @@ static void test_keySetName (void) { keySetName (key, "spec:/test"); succeed_if_same_string (keyName (key), "spec:/test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "spec:/test"); keyDel (dup); keySetName (key, "proc:/test"); succeed_if_same_string (keyName (key), "proc:/test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "proc:/test"); keyDel (dup); keySetName (key, "dir:/test"); succeed_if_same_string (keyName (key), "dir:/test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "dir:/test"); keyDel (dup); keySetName (key, "user:/test"); succeed_if_same_string (keyName (key), "user:/test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "user:/test"); keyDel (dup); keySetName (key, "system:/test"); succeed_if_same_string (keyName (key), "system:/test"); - dup = keyDupOld (key); + dup = keyDup (key, KEY_CP_ALL); succeed_if_same_string (keyName (dup), "system:/test"); keyDel (dup); } @@ -710,7 +710,7 @@ static void test_keyNeedSync (void) succeed_if (keyNeedSync (k), "new meta, should definitely need sync"); clear_bit (k->flags, KEY_FLAG_SYNC); - Key * d = keyDupOld (k); + Key * d = keyDup (k, KEY_CP_ALL); succeed_if (keyNeedSync (d), "dup key, should definitely need sync"); clear_bit (k->flags, KEY_FLAG_SYNC); diff --git a/tests/ctest/test_ks.c b/tests/ctest/test_ks.c index 905aa31f323..9bd3105065d 100644 --- a/tests/ctest/test_ks.c +++ b/tests/ctest/test_ks.c @@ -106,7 +106,7 @@ static void test_creatingLookup (void) searchKey = keyNew ("/something", KEY_VALUE, "a value", KEY_END); // check if duplication works: - Key * dupKey = keyDupOld (searchKey); + Key * dupKey = keyDup (searchKey, KEY_CP_ALL); succeed_if_same_string (keyName (dupKey), keyName (searchKey)); succeed_if_same_string (keyString (dupKey), keyString (searchKey)); ksAppendKey (ks, dupKey); diff --git a/tests/ctest/test_spec.c b/tests/ctest/test_spec.c index 4c0f7e9c2a2..d044c14940c 100644 --- a/tests/ctest/test_spec.c +++ b/tests/ctest/test_spec.c @@ -146,7 +146,7 @@ static void test_lookupNoOverride (void) KEY_META, "override/#2", "/test/heavy_material_lift/limit", KEY_END); // clang-format on - Key * dup = keyDupOld (specKey); + Key * dup = keyDup (specKey, KEY_CP_ALL); Key * k1 = 0; Key * k2 = 0; @@ -199,7 +199,7 @@ static void test_lookupNoascading (void) Key * specKey = keyNew ("/abc", KEY_END); - Key * d = keyDupOld (specKey); + Key * d = keyDup (specKey, KEY_CP_ALL); keySetString (d, "dup"); succeed_if_same_string (keyName (specKey), "/abc"); succeed_if_same_string (keyName (d), "/abc"); diff --git a/tests/ctest/test_storage.c b/tests/ctest/test_storage.c index 165615edb58..ed372a12f28 100644 --- a/tests/ctest/test_storage.c +++ b/tests/ctest/test_storage.c @@ -437,7 +437,7 @@ static void test_keyDup (const size_t storagePlugin, const char * tmpFile) Key * found = ksLookupByName (ks, "user:/tests/storage/b", 0); succeed_if (found, "did not find key"); - Key * duplicate = keyDupOld (found); + Key * duplicate = keyDup (found, KEY_CP_ALL); // check that keyDup has not changed KeySet KeySet * expected = metaTestKeySet (); @@ -615,7 +615,7 @@ static void test_keySetName (const size_t storagePlugin, const char * tmpFile) Key * found = ksLookupByName (ks, "user:/tests/storage/b", 0); succeed_if (found, "did not find key"); - Key * duplicate = keyDupOld (found); + Key * duplicate = keyDup (found, KEY_CP_ALL); keySetName (duplicate, "user:/tests/storage/z"); keySetString (duplicate, "zzz"); @@ -681,7 +681,7 @@ static void test_keyValue (const size_t storagePlugin, const char * tmpFile) Key * key = keyNew (name, KEY_END); keySetBinary (key, value, valueSize); - ksAppendKey (ks, keyDupOld (key)); + ksAppendKey (ks, keyDup (key, KEY_CP_ALL)); succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful"); succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "kdbGet was not successful");