diff --git a/src/plugins/ccode/README.md b/src/plugins/ccode/README.md index 0a265217ab6..e00e5b48553 100644 --- a/src/plugins/ccode/README.md +++ b/src/plugins/ccode/README.md @@ -32,7 +32,7 @@ sudo kdb mount config.tcl user/tests/ccode tcl ccode base64 kdb set user/tests/ccode/multiline "`printf 'one\ntwo\nthree'`" # By default the plugin uses `\n` to escape newline characters grep 'multiline' `kdb file user/tests/ccode/multiline` | sed 's/[[:space:]]*//' -#> user/tests/ccode/multiline = one\ntwo\nthree +#> multiline = one\ntwo\nthree # The `ccode` plugin escapes and unescapes the data. The `tcl` plugin # returns the unescaped values. diff --git a/src/plugins/tcl/CMakeLists.txt b/src/plugins/tcl/CMakeLists.txt index b3da34ebf76..e8f820a30d4 100644 --- a/src/plugins/tcl/CMakeLists.txt +++ b/src/plugins/tcl/CMakeLists.txt @@ -14,4 +14,5 @@ add_plugin (tcl action.cpp printer.hpp printer.cpp + LINK_ELEKTRA elektra-ease TEST_README) diff --git a/src/plugins/tcl/README.md b/src/plugins/tcl/README.md index bd70022af67..c55690eeca8 100644 --- a/src/plugins/tcl/README.md +++ b/src/plugins/tcl/README.md @@ -49,7 +49,7 @@ kdb getmeta user/tests/tcl/key comment kdb export user/tests/tcl tcl #> { #> { -#> user/tests/tcl/key = value +#> key = value #> { #> comment = Thiskeycontainsexampledata. #> } diff --git a/src/plugins/tcl/action.cpp b/src/plugins/tcl/action.cpp index ce335833413..8aee09eee4c 100644 --- a/src/plugins/tcl/action.cpp +++ b/src/plugins/tcl/action.cpp @@ -19,6 +19,8 @@ #include "action.hpp" +#include + using namespace std; namespace elektra @@ -26,7 +28,7 @@ namespace elektra using namespace kdb; -void serialise (ostream & ofs, KeySet & output) +void serialise (ostream & ofs, KeySet & output, Key & parent) { ofs << '{' << endl; @@ -34,7 +36,8 @@ void serialise (ostream & ofs, KeySet & output) while (Key k = output.next ()) { ofs << "\t{" << endl; - ofs << "\t\t" << k.getName () << " = " << k.getString () << endl; + string const name = elektraKeyGetRelativeName (*k, *parent); + ofs << "\t\t" << name << " = " << k.getString () << endl; k.rewindMeta (); while (const Key m = k.nextMeta ()) { @@ -47,7 +50,7 @@ void serialise (ostream & ofs, KeySet & output) ofs << '}' << endl; } -void unserialise (istream & in, KeySet & input) +void unserialise (istream & in, KeySet & input, Key & parent) { namespace qi = boost::spirit::qi; @@ -57,7 +60,7 @@ void unserialise (istream & in, KeySet & input) boost::spirit::istream_iterator begin (in); boost::spirit::istream_iterator end; - Action p (input); + Action p (input, parent); if (!boost::spirit::qi::phrase_parse (begin, end, p, space)) { diff --git a/src/plugins/tcl/action.hpp b/src/plugins/tcl/action.hpp index d30539014ec..a29f91e32e9 100644 --- a/src/plugins/tcl/action.hpp +++ b/src/plugins/tcl/action.hpp @@ -35,7 +35,7 @@ namespace unicode = boost::spirit::standard; template struct Action : qi::grammar { - Action (kdb::KeySet & ks) : Action::base_type (query), p (ks) + Action (kdb::KeySet & ks, kdb::Key & parent) : Action::base_type (query), p (ks, parent) { query = '{' >> *(pair) > '}'; pair = '{' >> key > '=' >> val >> *('{' >> metakey > '=' >> metaval > '}') > '}'; diff --git a/src/plugins/tcl/printer.cpp b/src/plugins/tcl/printer.cpp index 5675789670e..bba166ac2fd 100644 --- a/src/plugins/tcl/printer.cpp +++ b/src/plugins/tcl/printer.cpp @@ -20,7 +20,7 @@ using namespace kdb; namespace elektra { -Printer::Printer (KeySet & ks) : nr_keys (0), nr_meta (0), current (ks) +Printer::Printer (KeySet & ks, Key & parentKey) : nr_keys (0), nr_meta (0), current (ks), parent (parentKey) { } @@ -30,7 +30,9 @@ void Printer::add_key (std::vector const & c) keyname = s; - Key k (keyname, KEY_END); + Key k (parent.getName (), KEY_END); + k.addName (keyname); + current.append (k); // cout << "current key is: " << current.current().getName() << endl; diff --git a/src/plugins/tcl/printer.hpp b/src/plugins/tcl/printer.hpp index e1ba68f0e00..5a12bbba1dd 100644 --- a/src/plugins/tcl/printer.hpp +++ b/src/plugins/tcl/printer.hpp @@ -23,11 +23,12 @@ struct Printer int nr_meta; kdb::KeySet & current; + kdb::Key & parent; std::string keyname; std::string metaname; - Printer (kdb::KeySet & ks); + Printer (kdb::KeySet & ks, kdb::Key & parent); void add_key (std::vector const & c); void add_val (std::vector const & c); diff --git a/src/plugins/tcl/tcl.cpp b/src/plugins/tcl/tcl.cpp index 3e30d7b685e..b6af21892f8 100644 --- a/src/plugins/tcl/tcl.cpp +++ b/src/plugins/tcl/tcl.cpp @@ -61,7 +61,7 @@ int elektraTclGet (Plugin *, KeySet * returned, Key * parentKey) int ret = 0; try { - elektra::unserialise (in, input); + elektra::unserialise (in, input, parent); } catch (boost::spirit::qi::expectation_failure const & e) { @@ -100,7 +100,7 @@ int elektraTclSet (Plugin *, KeySet * returned, Key * parentKey) kdb::KeySet output (returned); - elektra::serialise (ofs, output); + elektra::serialise (ofs, output, parent); parent.release (); output.release (); diff --git a/src/plugins/tcl/tcl.hpp b/src/plugins/tcl/tcl.hpp index 1003f43ce96..ce74fce14c4 100644 --- a/src/plugins/tcl/tcl.hpp +++ b/src/plugins/tcl/tcl.hpp @@ -18,8 +18,8 @@ namespace elektra { -void serialise (std::ostream & os, kdb::KeySet & output); -void unserialise (std::istream & os, kdb::KeySet & output); +void serialise (std::ostream & os, kdb::KeySet & output, kdb::Key & parent); +void unserialise (std::istream & os, kdb::KeySet & output, kdb::Key & parent); } // namespace elektra extern "C" {