Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

TOML storage plugin #3292

Merged
merged 190 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
598c80c
toml: setting plugin up
bauhaus93 Oct 7, 2019
b1ba555
toml: Created basic README
bauhaus93 Oct 7, 2019
b281217
toml: Further setup
bauhaus93 Oct 9, 2019
3da5e79
toml: changes in driver, parser
bauhaus93 Oct 10, 2019
b4c2951
toml: Some grammar fixes, Simple table key gen
bauhaus93 Oct 11, 2019
7020821
toml: Added arrays
bauhaus93 Oct 11, 2019
131c144
toml: Working on array tables
bauhaus93 Oct 11, 2019
15f66be
toml: Further table array implementation
bauhaus93 Oct 11, 2019
0ad56f9
toml: Work on table arrays
bauhaus93 Oct 12, 2019
065ca8d
toml: Finally found a decent table array solution
bauhaus93 Oct 13, 2019
6c9be90
toml: fixed table array meta key, improved tests
bauhaus93 Oct 13, 2019
b6debd6
toml: Fixed missing KEY_END
bauhaus93 Oct 18, 2019
1d56e06
toml: Added inline tables, restructured tests
bauhaus93 Oct 18, 2019
4649ad2
toml: Added empty inline table
bauhaus93 Oct 18, 2019
914f530
toml: Added test for table arrays with tables
bauhaus93 Oct 18, 2019
1336e19
toml: Added tests for multiline values in inline tables
bauhaus93 Oct 18, 2019
c186d6c
toml: Added test cases for comments
bauhaus93 Oct 18, 2019
0e33d79
toml: Working on comments
bauhaus93 Oct 19, 2019
17a1317
toml: Further work on comments
bauhaus93 Oct 19, 2019
067a534
toml: Added comments for arrays
bauhaus93 Oct 19, 2019
1117df0
toml: Added trailing comments
bauhaus93 Oct 19, 2019
e86526f
toml: Fixed keygen in table array, fixed tests
bauhaus93 Oct 19, 2019
f2f3897
toml: Fixed comment test
bauhaus93 Oct 20, 2019
640a9a3
toml: changed recognition of tables
bauhaus93 Oct 20, 2019
dc520c8
toml: Fixed on testcase, simplified table array driver function
bauhaus93 Oct 20, 2019
ec1a800
toml: Fixed table array key emission, fixed test
bauhaus93 Oct 20, 2019
2a067c8
toml: Added more clear exitKey function
bauhaus93 Oct 20, 2019
1966426
toml: Added check/error on duplicate key names
bauhaus93 Oct 20, 2019
d97a9a7
toml: Lexer now propagates errors to driver
bauhaus93 Oct 20, 2019
e7ab73f
toml: Working on date validation
bauhaus93 Oct 20, 2019
c87b0bb
toml: Fixed incorrect simple table keygen
bauhaus93 Oct 21, 2019
932e559
toml: Last error now saved in driver
bauhaus93 Oct 21, 2019
bfb268b
toml: Added tests for utf8
bauhaus93 Oct 21, 2019
27501b6
toml: Added tests for multiline strings
bauhaus93 Oct 21, 2019
f41f0bb
toml: Disallowed leading commas in inline tables
bauhaus93 Oct 21, 2019
86b4753
toml: Further datetime validation
bauhaus93 Oct 21, 2019
8204bf4
toml: Fixed some compiler warnings
bauhaus93 Oct 21, 2019
1f8316a
toml: Working on array parsing
bauhaus93 Oct 21, 2019
0356645
toml: Working on trailing commas in arrays
bauhaus93 Oct 22, 2019
bc2d2c4
toml: Trailing array comma solved
bauhaus93 Oct 22, 2019
502a79a
toml: Some cleanup
bauhaus93 Oct 22, 2019
ed051f0
toml: Adding order metakey. Tests must be adapted
bauhaus93 Oct 24, 2019
0185454
toml: Reformatted code
bauhaus93 Oct 24, 2019
06a7636
toml: Fixing tests with order metakey
bauhaus93 Oct 24, 2019
4c1b687
toml: Fixed last tests for order
bauhaus93 Oct 25, 2019
3e4cb49
toml: Code restructuration
bauhaus93 Oct 25, 2019
72598b4
toml: Moved table array function into own file
bauhaus93 Oct 25, 2019
65c356a
toml: Changes in lastScalar functions
bauhaus93 Oct 25, 2019
d330744
toml: Fixed reduce/reduce conflict
bauhaus93 Oct 25, 2019
d019d96
toml: Fixed empty table array index
bauhaus93 Oct 25, 2019
edfe49e
toml: Undone table array index change.
bauhaus93 Oct 25, 2019
54aef59
toml: Added some basic tests
bauhaus93 Oct 25, 2019
b4996d1
toml: Changes in error handling.
bauhaus93 Oct 25, 2019
dd513f5
toml: Found correct error emission
bauhaus93 Oct 26, 2019
ba922ea
toml: Added infrastructure for testing errors
bauhaus93 Oct 26, 2019
3899dea
toml: Added negative tests
bauhaus93 Oct 26, 2019
477313d
toml: Fixes in lexing/parsing
bauhaus93 Oct 26, 2019
b48993a
toml: Reformatted code
bauhaus93 Oct 26, 2019
c5ba685
toml: Fixed segfault due to previous changes
bauhaus93 Oct 26, 2019
e522377
toml: Working on value translations
bauhaus93 Oct 28, 2019
f19b767
toml: Replaced some mallocs, added checks for failed allocation
bauhaus93 Oct 28, 2019
c6b1e91
toml: Replaced mallocs/frees in lexer
bauhaus93 Oct 28, 2019
84e7d14
toml: Added checks for NULL scalars
bauhaus93 Oct 28, 2019
1fbbe16
toml: Added test case for float as key, fixed bug
bauhaus93 Oct 28, 2019
cc98987
toml: Added unicode escape tests, fixed unicode escaping
bauhaus93 Oct 28, 2019
fc72492
toml: Added 'check/type' and 'origvalue' metakeys
bauhaus93 Oct 29, 2019
cb697fb
toml: Reformatted lexer, parser
bauhaus93 Oct 29, 2019
4eb5f4e
toml: Redone reading of strings in lexer. Lexer now includes string q…
bauhaus93 Oct 29, 2019
3395037
toml: Replaced strlen,strcmp,strdup with elektras equivalents
bauhaus93 Oct 29, 2019
6b76f50
toml: Replaced asserts with elektra equivalent
bauhaus93 Oct 29, 2019
2dc6f91
toml: Fixing memleaks
bauhaus93 Oct 29, 2019
d5623f2
toml: Fixed another memleak
bauhaus93 Oct 29, 2019
7ec423c
toml: Moved utf8/unicode stuff into own file
bauhaus93 Oct 30, 2019
c97eee9
toml: Started working on writing
bauhaus93 Nov 15, 2019
03275b8
toml: Further work on writing
bauhaus93 Nov 16, 2019
766cf98
toml: Reworked some write code
bauhaus93 Nov 16, 2019
7157a92
toml: Basic array writing done
bauhaus93 Nov 16, 2019
3bd0940
toml: Work done on basic simple table writing
bauhaus93 Nov 16, 2019
49a05d5
toml: Working on handling of empty table array elements
bauhaus93 Nov 16, 2019
115b1c7
toml: basic table array write done
bauhaus93 Nov 17, 2019
35aceba
toml: added basic inline table writing
bauhaus93 Nov 17, 2019
7a7610f
toml: Started on comment writing
bauhaus93 Nov 17, 2019
0f59255
toml: Further work on comment writing
bauhaus93 Nov 17, 2019
8cf4908
toml: added comment writing to arrays
bauhaus93 Nov 17, 2019
741ae19
toml: moved some functions
bauhaus93 Nov 17, 2019
876ff4a
toml: added writing of document ending comments
bauhaus93 Nov 17, 2019
5d1605a
toml: Working on whitespace preservation
bauhaus93 Nov 17, 2019
5997374
toml: adapting grammar for whitespaces
bauhaus93 Nov 17, 2019
4519e29
toml: Further grammar adaption
bauhaus93 Nov 18, 2019
ee35d08
toml: Comment leading spaces now preserved.
bauhaus93 Nov 18, 2019
1dac0f7
toml: Some fixes to get error msg printed
bauhaus93 Nov 18, 2019
2949bc1
toml: trying some fixes
bauhaus93 Nov 18, 2019
e99e7a7
toml: Small changes
bauhaus93 Nov 19, 2019
528efdc
toml: various fixes for reading/writing
bauhaus93 Nov 20, 2019
11c1b2b
toml: added check for writing floats
bauhaus93 Nov 20, 2019
7e5d8de
toml: update readme
bauhaus93 Nov 20, 2019
e47c2b3
toml: working on getting tests running again
bauhaus93 Nov 20, 2019
aed173e
toml: tests running again
bauhaus93 Nov 21, 2019
b1aa559
toml: Now supporting null keys
bauhaus93 Nov 21, 2019
d0a6c69
toml: updated readme
bauhaus93 Nov 21, 2019
3f031c2
toml: Fixes in writing
bauhaus93 Nov 21, 2019
4c942dd
toml: Working on array writing
bauhaus93 Nov 22, 2019
cc4ab58
toml: fixed some array writing
bauhaus93 Nov 22, 2019
cb54dd9
toml: added date checking on write
bauhaus93 Nov 22, 2019
fe68e3d
toml: adding tests for writeReads
bauhaus93 Nov 22, 2019
42d793a
toml: reformatted some code
bauhaus93 Nov 22, 2019
4a229b9
toml: now using order on write
bauhaus93 Nov 22, 2019
c43a771
toml: No longer emitting type metakeys, fixed nested arrays
bauhaus93 Nov 23, 2019
7c8fa1c
toml: Small change in assertion
bauhaus93 Nov 23, 2019
c53456f
toml: removde unused var
bauhaus93 Nov 24, 2019
ef4d7cf
toml: Removed unused var
bauhaus93 Nov 24, 2019
ab1c73e
toml: fixed order
bauhaus93 Nov 24, 2019
c06c108
toml: another fix in order, fixed tests
bauhaus93 Nov 24, 2019
a06d33a
toml: removed some printfs
bauhaus93 Nov 24, 2019
d08987f
toml: replaced usage of keyRel
bauhaus93 Nov 24, 2019
532d183
toml: fixed some comment preservation
bauhaus93 Nov 24, 2019
a87fb97
toml: Fixed boolean writing (now priortized over plain number)
bauhaus93 Nov 24, 2019
422e8ca
toml: fixed boolean being written too deliberate
bauhaus93 Nov 24, 2019
55a9941
toml: removed some file emission
bauhaus93 Nov 24, 2019
c0c5357
toml: fixed type function
bauhaus93 Nov 24, 2019
1fcea7c
scripts: Flex now installed in Dockerfiles
bauhaus93 Nov 26, 2019
e68ddab
toml: Fixed space restoration
bauhaus93 Nov 26, 2019
5ff0a2c
toml: Fixed table writing
bauhaus93 Nov 26, 2019
d51baee
toml: replaced occurences of old keyRel
bauhaus93 Nov 28, 2019
830ad2f
toml: Fixed old usage of ELEKTRA_SET_OUT_OF_MEMORY_ERROR
bauhaus93 Nov 28, 2019
40d6840
toml: Fixed bison CMake options
bauhaus93 Nov 28, 2019
e099428
toml: various fixes
bauhaus93 Nov 28, 2019
1a96d61
toml: Proper multiline string write handling, moved tests
bauhaus93 Nov 29, 2019
4c99f79
toml: Fixed illegal newlines in strings
bauhaus93 Nov 29, 2019
2b15bc3
toml: Fixed lexer state between yylex calls
bauhaus93 Nov 29, 2019
4ee0e9c
toml: Added doc concerning strings
bauhaus93 Nov 29, 2019
0a5a5c2
toml: Some restructuration in errors
bauhaus93 Nov 30, 2019
417cca1
toml: added directoryvalue, base64, null plugins to needs
bauhaus93 Nov 30, 2019
41a91ca
toml: Removed old handling of null keys
bauhaus93 Nov 30, 2019
826bde3
toml: Working on sorting of array elements
bauhaus93 Nov 30, 2019
d173c23
toml: Further work on sorting array elements
bauhaus93 Dec 1, 2019
3270997
toml: Further array sorting work
bauhaus93 Dec 2, 2019
88cb985
toml: table array elements now sorted by order
bauhaus93 Dec 3, 2019
40a40e9
toml: Some tweaks, maybe will change sorting now
bauhaus93 Dec 3, 2019
d339501
toml: Rewrote writing process
bauhaus93 Dec 4, 2019
5635372
toml: Added wr tests for comments. Fixed comment error.
bauhaus93 Dec 5, 2019
5117311
toml: Added tests for simple table/table array interaction
bauhaus93 Dec 5, 2019
2a5ae0a
toml: Added wr test for inline tables in arrays
bauhaus93 Dec 6, 2019
e61a5b0
toml: Added test for alternating array/inline table
bauhaus93 Dec 6, 2019
bb6c4c5
toml: Moved function from node to util, removed some printfs
bauhaus93 Dec 6, 2019
b3f9fca
toml: Added tomltype to METADATA.ini
bauhaus93 Dec 6, 2019
58d748e
toml: Added doc, fixed possible ordering messup
bauhaus93 Dec 6, 2019
d844990
toml: Fixed some doc
bauhaus93 Dec 6, 2019
60ebda7
toml: Removed some printfs
bauhaus93 Dec 6, 2019
2dd2e72
toml: Small Readme change, added missing include
bauhaus93 Dec 10, 2019
8725c96
toml: Added doc for table array
bauhaus93 Dec 10, 2019
cd241c1
toml: Added doc for three source files
bauhaus93 Dec 10, 2019
d365427
toml: Removed unused function
bauhaus93 Jan 16, 2020
316c44b
toml: Reformatted README
bauhaus93 Jan 16, 2020
b08a9b4
toml: Reformatted README with script
bauhaus93 Jan 16, 2020
908cccc
toml: Reformatted CMakeLists
bauhaus93 Jan 16, 2020
e7e0749
toml: Removed some memleaks
bauhaus93 Jan 17, 2020
3bb4fe9
toml: Fixed memleak
bauhaus93 Jan 17, 2020
27fc2d9
toml: Fixed memleaks
bauhaus93 Jan 17, 2020
6b3071a
toml: Reformatted source files
bauhaus93 Jan 18, 2020
65731a7
toml: Fixed some implicit conversions
bauhaus93 Jan 18, 2020
1e07a08
man: Updated man pages
bauhaus93 Jan 31, 2020
ba10bb4
toml: Set minimum requirements for flex
bauhaus93 Jan 31, 2020
dfd4e3b
toml: Replaced lexer restart, removed unused test
bauhaus93 May 7, 2020
67e9c49
libs: Fixed #3274
bauhaus93 May 7, 2020
92be541
libs: Reformatted code
bauhaus93 May 7, 2020
bf10a82
Update scripts/docker/debian/stretch/Dockerfile
mpranj May 7, 2020
fcedc17
Update scripts/docker/debian/buster/Dockerfile
mpranj May 7, 2020
f188fbf
Update scripts/docker/debian/sid/Dockerfile
mpranj May 7, 2020
000fe2a
Update scripts/docker/debian/stretch/Dockerfile
mpranj May 7, 2020
fc809cc
toml: Added memleak status
bauhaus93 Jul 27, 2020
bd122c9
toml: reformatted code
bauhaus93 Jun 9, 2020
7bf1600
toml: Probably fixed the remaining memleak
bauhaus93 Jun 13, 2020
b8f3e8a
toml: Fixed implicit call
bauhaus93 Jun 13, 2020
86b82d7
toml: Some README additions
bauhaus93 Jul 27, 2020
0c0e8d2
toml: Fixed incorrect example
bauhaus93 Aug 27, 2020
10cf736
toml: Added doc for inline tables and arrays
bauhaus93 Aug 27, 2020
b3e4624
toml: Replaced cursor_t occurences with elektraCursor
bauhaus93 Aug 27, 2020
6ca02dd
toml: Fixed array indices not getting updated
bauhaus93 Aug 27, 2020
2fcaef2
toml: Fixed writing of incomplete comment info.
bauhaus93 Aug 29, 2020
7fd8a62
toml: Added documentation
bauhaus93 Aug 30, 2020
81bf64d
toml: Fixed readme, added release note
bauhaus93 Aug 31, 2020
33028df
toml: Fixed README
bauhaus93 Aug 31, 2020
a8ae3d6
toml: Another README restyle
bauhaus93 Aug 31, 2020
a0f9585
scripts: Added Flex to cirrus/travis targets.
bauhaus93 Sep 1, 2020
3326d32
toml: Added homebrew flex handler in cmake
bauhaus93 Sep 1, 2020
66cbf47
docker: updated fedora dockerfile with flex/bison.
bauhaus93 Sep 1, 2020
ee9b9cd
toml: Fixed error in table array comments.
bauhaus93 Sep 2, 2020
95a6bbf
Update scripts/docker/cirrus/fedora/Dockerfile
bauhaus93 Sep 2, 2020
100a34d
Update scripts/docker/cirrus/fedora/Dockerfile
bauhaus93 Sep 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bsd_task:
pkg install -y
bison
cmake
flex
git
libgit2
ninja
Expand Down Expand Up @@ -125,6 +126,7 @@ mac_task:
brew install dbus
brew install discount
brew install doxygen
brew install flex
brew install glib
brew install go
brew install gpgme
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ matrix:
- bison
- dbus
- discount
- flex
- gpgme
- libev
- libgcrypt
Expand Down
11 changes: 11 additions & 0 deletions doc/METADATA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1314,3 +1314,14 @@ status = implemented
usedby/plugins = cache
type = boolean
description = tells the cache plugin to remove all cache files during the next `kdbGet` in a safe way.

[tomltype]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if it is directly integrated in the types of Elektra (type, enum, array) and only for the tables there is some internal/toml/type or we even add the "tables" to standardtypes. I would prefer the name "section" though (similar to array as extra meta-data).

status = implemented
usedby/plugins = toml
type = enum
simpletable
tablearray
inlinetable
descriptions = Tells the TOML plugin, which kind of TOML structure a key represents. When reading a TOML file, the plugin sets this metakey when encountering a TOML structure.
On writing, it is used for writing the structure back into a TOML file.
No metakey inference is done on writing, it's either set by a previous read of a TOML file or set explicitly by the user.
3 changes: 3 additions & 0 deletions doc/man/man7/elektra-plugins.7
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ passwd \fIpasswd/\fR for passwd files
specload \fIspecload/\fR calls an external application to request its specification, depends on quickdump \fIquickdump/\fR
.
.IP "\(bu" 4
toml \fItoml/\fR reads and writes data using a parser generated by Flex \fIhttps://github\.com/westes/flex\fR and Bison \fIhttps://www\.gnu\.org/software/bison\fR
.
.IP "\(bu" 4
yamlcpp \fIyamlcpp/\fR reads and writes data in the YAML \fIhttp://www\.yaml\.org\fR format using yaml\-cpp \fIhttps://github\.com/jbeder/yaml\-cpp\fR
.
.IP "\(bu" 4
Expand Down
6 changes: 2 additions & 4 deletions doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ The following section lists news about the [modules](https://www.libelektra.org/
- <<TODO>>
- <<TODO>>

### <<Plugin2>>
### TOML

- <<TODO>>
- <<TODO>>
- <<TODO>>
- Added the TOML plugin, which can read and write TOML files using flex and bison. _(Jakob Fischer)_

### <<Plugin3>>

Expand Down
1 change: 1 addition & 0 deletions scripts/docker/alpine/3.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN apk update \
curl \
diffutils \
file \
flex \
git \
gtest-dev \
ninja \
Expand Down
3 changes: 2 additions & 1 deletion scripts/docker/cirrus/fedora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ FROM fedora:32

RUN dnf upgrade -y && dnf install -y \
augeas-devel \
bison \
boost-devel \
cmake \
curl \
dbus-devel \
diffutils \
file \
findutils \
flex \
gcc-c++ \
git \
glib2 \
Expand Down Expand Up @@ -49,4 +51,3 @@ RUN mkdir -p ${GTEST_ROOT} \
-L https://github.com/google/googletest/archive/${GTEST_VER}.tar.gz \
&& tar -zxvf gtest.tar.gz --strip-components=1 -C ${GTEST_ROOT} \
&& rm gtest.tar.gz

2 changes: 2 additions & 0 deletions scripts/docker/debian/buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN apt-get update \
automake \
autotools-dev \
bison \
flex \
mpranj marked this conversation as resolved.
Show resolved Hide resolved
libc6-dbg \
build-essential \
cmake \
curl \
Expand Down
2 changes: 2 additions & 0 deletions scripts/docker/debian/sid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN apt-get update && apt-get -y install \
default-jdk \
dh-lua \
ed \
flex \
mpranj marked this conversation as resolved.
Show resolved Hide resolved
libc6-dbg \
gawk \
git \
gnupg2 \
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/debian/stretch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ RUN apt-get update \
dnsutils \
virtualenv \
bison \
flex \
mpranj marked this conversation as resolved.
Show resolved Hide resolved
uuid-dev \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -172,4 +173,3 @@ RUN virtualenv "${COVERALLS_VIRTUALENV_PATH}" \
&& pip install cpp-coveralls \
&& deactivate
ENV PATH="${PATH}:${COVERALLS_VIRTUALENV_PATH}/bin"

1 change: 1 addition & 0 deletions scripts/docker/ubuntu/disco/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN apt-get update && apt-get -y install \
cmake \
curl \
ed \
flex \
git \
googletest \
libantlr4-runtime-dev \
Expand Down
2 changes: 1 addition & 1 deletion scripts/vagrant/ubuntu/artful32/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y upgrade
apt-get -y install curl build-essential autotools-dev automake cmake pkg-config doxygen graphviz bison ruby-dev python-dev python3-dev liblua5.2-dev tclcl-dev libaugeas-dev libyajl-dev libgit2-dev libboost-all-dev libssl-dev libcurl4-gnutls-dev libdbus-1-dev libpcre3-dev libpcre++-dev checkinstall vim valgrind clang-5.0 clang-format-5.0 htop zlib1g-dev git openjdk-8-jdk python-pip locales bison libpython3-dev liblua5.3-dev libxerces-c-dev swig
apt-get -y install curl build-essential autotools-dev automake cmake pkg-config doxygen graphviz bison flex ruby-dev python-dev python3-dev liblua5.2-dev tclcl-dev libaugeas-dev libyajl-dev libgit2-dev libboost-all-dev libssl-dev libcurl4-gnutls-dev libdbus-1-dev libpcre3-dev libpcre++-dev checkinstall vim valgrind clang-5.0 clang-format-5.0 htop zlib1g-dev git openjdk-8-jdk python-pip locales bison libpython3-dev liblua5.3-dev libxerces-c-dev swig

pip install cmake-format[yaml]==0.6.3

Expand Down
43 changes: 25 additions & 18 deletions src/libs/meta/meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,31 +873,38 @@ int keySetCTime (Key * key, time_t ctime)
int elektraKeyCmpOrder (const Key * ka, const Key * kb)
{

if (!ka && !kb) return 0;

if (ka && !kb) return 1;
if (ka == NULL && kb == NULL)
{
return 0;
}

if (!ka && kb) return -1;
if (ka != NULL && kb == NULL)
{
return 1;
}

int aorder = -1;
int border = -1;
if (ka == NULL && kb != NULL)
{
return -1;
}

const Key * kam = keyGetMeta (ka, "order");
const Key * kbm = keyGetMeta (kb, "order");

if (kam) aorder = atoi (keyString (kam));
if (kbm) border = atoi (keyString (kbm));

if (aorder > 0 && border > 0) return aorder - border;

if (aorder < 0 && border < 0) return 0;

if (aorder < 0 && border >= 0) return -1;

if (aorder >= 0 && border < 0) return 1;
if (kam == NULL && kbm == NULL)
{
return 0;
}
if (kam != NULL && kbm == NULL)
{
return 1;
}
if (kam == NULL && kbm != NULL)
{
return -1;
}

/* cannot happen anyway */
return 0;
return atoi (keyString (kam)) - atoi (keyString (kbm));
}


Expand Down
1 change: 1 addition & 0 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ productive use:
- [mozprefs](mozprefs/) for Mozilla preference files
- [passwd](passwd/) for passwd files
- [specload](specload/) calls an external application to request its specification, depends on [quickdump](quickdump/)
- [toml](toml/) reads and writes data using a parser generated by [Flex](https://github.com/westes/flex) and [Bison](https://www.gnu.org/software/bison)
- [yamlcpp](yamlcpp/) reads and writes data in the [YAML][] format using [yaml-cpp](https://github.com/jbeder/yaml-cpp)
- [yanlr](yanlr/) reads data using a parser generated by [ANTLR](http://www.antlr.org)

Expand Down
152 changes: 152 additions & 0 deletions src/plugins/toml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
function (check_dependencies)
set (
FOUND_DEPENDENCIES
FALSE
PARENT_SCOPE)

set (USE_HOMEBREW_FLEX ${APPLE} AND EXISTS /usr/local/opt/flex)
if (USE_HOMEBREW_FLEX)
list (APPEND CMAKE_PREFIX_PATH "/usr/local/opt/flex")
endif (USE_HOMEBREW_FLEX)
find_package (FLEX 2.6.2 QUIET)

set (USE_HOMEBREW_BISON ${APPLE} AND EXISTS /usr/local/opt/bison)
if (USE_HOMEBREW_BISON)
list (APPEND CMAKE_PREFIX_PATH "/usr/local/opt/bison")
endif (USE_HOMEBREW_BISON)
find_package (BISON 3 QUIET)

if ((NOT FLEX_FOUND) AND (NOT BISON_FOUND))
set (
FAILURE_MESSAGE
"Flex and Bison could not be found"
PARENT_SCOPE)
return ()
endif ((NOT FLEX_FOUND) AND (NOT BISON_FOUND))
if (NOT FLEX_FOUND)
set (
FAILURE_MESSAGE
"Flex could not be found"
PARENT_SCOPE)
return ()
endif (NOT FLEX_FOUND)
if (NOT BISON_FOUND)
set (
FAILURE_MESSAGE
"Bison could not be found"
PARENT_SCOPE)
return ()
endif (NOT BISON_FOUND)

set (
FOUND_DEPENDENCIES
TRUE
PARENT_SCOPE)
endfunction (check_dependencies)

function (generate_code)
set (
GENERATED_CODE
FALSE
PARENT_SCOPE)

flex_target (TOMLScanner ${CMAKE_CURRENT_SOURCE_DIR}/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c)
bison_target (TOMLParser ${CMAKE_CURRENT_SOURCE_DIR}/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c VERBOSE bison_verbose.txt)
add_flex_bison_dependency (TOMLScanner TOMLParser)

if ((NOT FLEX_TOMLScanner_DEFINED) AND (NOT BISON_TOMLParser_DEFINED))
set (
FAILURE_MESSAGE
"Flex and Bison code could not be generated"
PARENT_SCOPE)
return ()
endif ((NOT FLEX_TOMLScanner_DEFINED) AND (NOT BISON_TOMLParser_DEFINED))
if (NOT FLEX_TOMLScanner_DEFINED)
set (
FAILURE_MESSAGE
"Flex code could not be generated"
PARENT_SCOPE)
return ()
endif (NOT FLEX_TOMLScanner_DEFINED)
if (NOT BISON_TOMLParser_DEFINED)
set (
FAILURE_MESSAGE
"Bison code could not be generated"
PARENT_SCOPE)
return ()
endif (NOT BISON_TOMLParser_DEFINED)

set (
FLEX_OUTPUT_SOURCE
${FLEX_TOMLScanner_OUTPUTS}
PARENT_SCOPE)
set (
FLEX_OUTPUT_HEADER
${FLEX_TOMLScanner_OUTPUT_HEADER}
PARENT_SCOPE)
set (
BISON_OUTPUT_SOURCE
${BISON_TOMLParser_OUTPUT_SOURCE}
PARENT_SCOPE)
set (
BISON_OUTPUT_HEADER
${BISON_TOMLParser_OUTPUT_HEADER}
PARENT_SCOPE)

set (
GENERATED_CODE
TRUE
PARENT_SCOPE)

endfunction (generate_code)

if (DEPENDENCY_PHASE)

check_dependencies ()
if (NOT FOUND_DEPENDENCIES)
remove_plugin (toml ${FAILURE_MESSAGE})
else (NOT FOUND_DEPENDENCIES)
generate_code ()
if (NOT GENERATED_CODE)
remove_plugin (toml ${FAILURE_MESSAGE})
endif (NOT GENERATED_CODE)
endif (NOT FOUND_DEPENDENCIES)

set (
SOURCE_FILES
toml.h
toml.c
driver.h
driver.c
scalar.h
scalar.c
table_array.h
table_array.c
comment_list.h
comment_list.c
codepoint.h
codepoint.c
utility.h
utility.c
write.h
write.c
node.h
node.c
prepare.c
prepare.h
type.h
type.c
error.h
error.c
${FLEX_OUTPUT_HEADER}
${FLEX_OUTPUT_SOURCE}
${BISON_OUTPUT_HEADER}
${BISON_OUTPUT_SOURCE})

endif (DEPENDENCY_PHASE)

add_plugin (
toml ADD_TEST INSTALL_TEST_DATA
LINK_ELEKTRA elektra-meta
SOURCES ${SOURCE_FILES}
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
Loading