svn commit: r298163 - in vendor/libucl/libucl-0.8.0: . include lua python python/src src tests tests/basic tests/schema utils

Baptiste Daroussin bapt at FreeBSD.org
Sun Apr 17 21:26:57 UTC 2016


Author: bapt
Date: Sun Apr 17 21:26:55 2016
New Revision: 298163
URL: https://svnweb.freebsd.org/changeset/base/298163

Log:
  tag import of libucl 0.8.0

Added:
  vendor/libucl/libucl-0.8.0/
     - copied from r294088, vendor/libucl/dist/
  vendor/libucl/libucl-0.8.0/tests/basic/escapes.in
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/escapes.in
  vendor/libucl/libucl-0.8.0/tests/basic/escapes.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/escapes.res
  vendor/libucl/libucl-0.8.0/tests/basic/load.in
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/load.in
  vendor/libucl/libucl-0.8.0/tests/basic/load.inc
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/load.inc
  vendor/libucl/libucl-0.8.0/tests/basic/load.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/load.res
Replaced:
  vendor/libucl/libucl-0.8.0/ChangeLog.md
     - copied unchanged from r298162, vendor/libucl/dist/ChangeLog.md
  vendor/libucl/libucl-0.8.0/Makefile.am
     - copied unchanged from r298162, vendor/libucl/dist/Makefile.am
  vendor/libucl/libucl-0.8.0/README.md
     - copied unchanged from r298162, vendor/libucl/dist/README.md
  vendor/libucl/libucl-0.8.0/configure.ac
     - copied unchanged from r298162, vendor/libucl/dist/configure.ac
  vendor/libucl/libucl-0.8.0/include/ucl++.h
     - copied unchanged from r298162, vendor/libucl/dist/include/ucl++.h
  vendor/libucl/libucl-0.8.0/include/ucl.h
     - copied unchanged from r298162, vendor/libucl/dist/include/ucl.h
  vendor/libucl/libucl-0.8.0/lua/lua_ucl.c
     - copied unchanged from r298162, vendor/libucl/dist/lua/lua_ucl.c
  vendor/libucl/libucl-0.8.0/python/src/uclmodule.c
     - copied unchanged from r298162, vendor/libucl/dist/python/src/uclmodule.c
  vendor/libucl/libucl-0.8.0/python/test_uclmodule.py
     - copied unchanged from r298162, vendor/libucl/dist/python/test_uclmodule.py
  vendor/libucl/libucl-0.8.0/src/ucl_emitter.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_emitter.c
  vendor/libucl/libucl-0.8.0/src/ucl_emitter_streamline.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_emitter_streamline.c
  vendor/libucl/libucl-0.8.0/src/ucl_hash.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_hash.c
  vendor/libucl/libucl-0.8.0/src/ucl_hash.h
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_hash.h
  vendor/libucl/libucl-0.8.0/src/ucl_internal.h
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_internal.h
  vendor/libucl/libucl-0.8.0/src/ucl_msgpack.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_msgpack.c
  vendor/libucl/libucl-0.8.0/src/ucl_parser.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_parser.c
  vendor/libucl/libucl-0.8.0/src/ucl_schema.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_schema.c
  vendor/libucl/libucl-0.8.0/src/ucl_sexp.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_sexp.c
  vendor/libucl/libucl-0.8.0/src/ucl_util.c
     - copied unchanged from r298162, vendor/libucl/dist/src/ucl_util.c
  vendor/libucl/libucl-0.8.0/tests/basic.test
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic.test
  vendor/libucl/libucl-0.8.0/tests/basic/18.in
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/18.in
  vendor/libucl/libucl-0.8.0/tests/basic/18.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/18.res
  vendor/libucl/libucl-0.8.0/tests/basic/2.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/2.res
  vendor/libucl/libucl-0.8.0/tests/basic/9.in
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/9.in
  vendor/libucl/libucl-0.8.0/tests/basic/9.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/basic/9.res
  vendor/libucl/libucl-0.8.0/tests/generate.res
     - copied unchanged from r298162, vendor/libucl/dist/tests/generate.res
  vendor/libucl/libucl-0.8.0/tests/schema.test
     - copied unchanged from r298162, vendor/libucl/dist/tests/schema.test
  vendor/libucl/libucl-0.8.0/tests/schema/definitions.json
     - copied unchanged from r298162, vendor/libucl/dist/tests/schema/definitions.json
  vendor/libucl/libucl-0.8.0/tests/schema/ref.json
     - copied unchanged from r298162, vendor/libucl/dist/tests/schema/ref.json
  vendor/libucl/libucl-0.8.0/tests/schema/refRemote.json
     - copied unchanged from r298162, vendor/libucl/dist/tests/schema/refRemote.json
  vendor/libucl/libucl-0.8.0/tests/test_basic.c
     - copied unchanged from r298162, vendor/libucl/dist/tests/test_basic.c
  vendor/libucl/libucl-0.8.0/tests/test_generate.c
     - copied unchanged from r298162, vendor/libucl/dist/tests/test_generate.c
  vendor/libucl/libucl-0.8.0/tests/test_msgpack.c
     - copied unchanged from r298162, vendor/libucl/dist/tests/test_msgpack.c
  vendor/libucl/libucl-0.8.0/tests/test_schema.c
     - copied unchanged from r298162, vendor/libucl/dist/tests/test_schema.c
  vendor/libucl/libucl-0.8.0/utils/objdump.c
     - copied unchanged from r298162, vendor/libucl/dist/utils/objdump.c

Copied: vendor/libucl/libucl-0.8.0/ChangeLog.md (from r298162, vendor/libucl/dist/ChangeLog.md)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libucl/libucl-0.8.0/ChangeLog.md	Sun Apr 17 21:26:55 2016	(r298163, copy of r298162, vendor/libucl/dist/ChangeLog.md)
@@ -0,0 +1,67 @@
+# Version history
+
+## Libucl 0.5
+
+- Streamline emitter has been added, so it is now possible to output partial `ucl` objects
+- Emitter now is more flexible due to emitter_context structure
+
+### 0.5.1
+- Fixed number of bugs and memory leaks
+
+### 0.5.2
+
+- Allow userdata objects to be emitted and destructed
+- Use userdata objects to store lua function references
+
+### Libucl 0.6
+
+- Reworked macro interface
+
+### Libucl 0.6.1
+
+- Various utilities fixes
+
+### Libucl 0.7.0
+
+- Move to klib library from uthash to reduce memory overhead and increase performance
+
+### Libucl 0.7.1
+
+- Added safe iterators API
+
+### Libucl 0.7.2
+
+- Fixed serious bugs in schema and arrays iteration
+
+### Libucl 0.7.3
+
+- Fixed a bug with macroes that come after an empty object
+- Fixed a bug in include processing when an incorrect variable has been destroyed (use-after-free)
+
+### Libucl 0.8.0
+
+- Allow to save comments and macros when parsing UCL documents
+- C++ API
+- Python bindings (by Eitan Adler)
+- Add msgpack support for parser and emitter
+- Add Canonical S-expressions parser for libucl
+- CLI interface for parsing and validation (by Maxim Ignatenko)
+- Implement include with priority
+- Add 'nested' functionality to .include macro (by Allan Jude)
+- Allow searching an array of paths for includes (by Allan Jude)
+- Add new .load macro (by Allan Jude)
+- Implement .inherit macro (#100)
+- Add merge strategies
+- Add schema validation to lua API
+- Add support for external references to schema validation
+- Add coveralls integration to libucl
+- Implement tests for 80% of libucl code lines
+- Fix tonns of minor and major bugs
+- Improve documentation
+- Rework function names to the common conventions (old names are preserved for backwards compatibility)
+- Add Coverity scan integration
+- Add fuzz tests
+
+**Incompatible changes**:
+
+- `ucl_object_emit_full` now accepts additional argument `comments` that could be used to emit comments with UCL output
\ No newline at end of file

Copied: vendor/libucl/libucl-0.8.0/Makefile.am (from r298162, vendor/libucl/dist/Makefile.am)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libucl/libucl-0.8.0/Makefile.am	Sun Apr 17 21:26:55 2016	(r298163, copy of r298162, vendor/libucl/dist/Makefile.am)
@@ -0,0 +1,81 @@
+ACLOCAL_AMFLAGS = -I m4
+EXTRA_DIST = uthash klib README.md
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libucl.pc
+
+if LUA_SUB
+  LUA_SUBDIR = lua
+endif
+
+COVERAGE_INFO_FILE = $(top_builddir)/coverage.info
+COVERAGE_REPORT_DIR = $(top_builddir)/coverage
+
+.PHONY = coverage-requirement-check clean-coverage-report
+
+coverage-requirement-check:
+	@if test ! -e $(GCOV); then \
+		echo "Cannot find $(GCOV). Please install gcov."; \
+		exit 1; \
+	fi
+
+coverage: coverage-requirement-check clean-coverage coverage-build coverage-check coverage-report
+	@echo "Please execute 'make clean' before 'make' or 'make check' to remove instrumented object files(compiled with -O0 etc.). Note that 'make clean' also remove coverage data."
+
+coverage-build: coverage-requirement-check
+	@if test `find $(top_builddir) -name "*.gcno" | wc -l` -eq 0; then \
+		echo "Start to remove old non-instrumented object files..."; \
+		$(MAKE) $(AM_MAKEFLAGS) clean; \
+		echo "Successfully removed old non-instrumented object files."; \
+	fi
+	@echo "Start to build libraries with coverage options..."
+	$(MAKE) $(AM_MAKEFLAGS) \
+		CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTFLAGS)" \
+		CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTFLAGS)" \
+		LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)" \
+		LIBS="$(LIBS) $(COVERAGE_LIBS)"
+	@echo "Successfully built libraries with coverage options."
+
+coverage-check: coverage-requirement-check
+	@echo "Start to run tests with instrumented libraries..."
+	$(MAKE) $(AM_MAKEFLAGS) check \
+		CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTFLAGS)" \
+		CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTFLAGS)" \
+		LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)" \
+		LIBS="$(LIBS) $(COVERAGE_LIBS)"
+	@echo "Successfully run tests with instrumented libraries."
+
+coverage-lcov: coverage-check coverage-requirement-check
+	$(LCOV) --capture \
+		--directory "$(top_builddir)/" \
+		--output-file $(COVERAGE_INFO_FILE) \
+		--gcov-tool $(GCOV) \
+		--compat-libtool --checksum
+	$(LCOV) --extract $(COVERAGE_INFO_FILE) `pwd`/src/ucl_\* \
+		--output-file $(COVERAGE_INFO_FILE)
+
+coverage-report: coverage-lcov
+	@echo "Start to create coverage reports..."
+	$(GENHTML) --prefix "$(top_srcdir)" \
+		--output-directory $(COVERAGE_REPORT_DIR) \
+		--title $(PACKAGE_NAME) \
+		--legend --show-details \
+		$(GENHTML_OPTIONS) \
+		$(COVERAGE_INFO_FILE)
+	@echo "Successfully created coverage reports into $(COVERAGE_REPORT_DIR) directory."
+
+clean-coverage-report:
+	-rm -rf $(COVERAGE_INFO_FILE)
+	-rm -rf $(COVERAGE_REPORT_DIR)
+
+clean-coverage: clean-coverage-report
+	-$(LCOV) --gcov-tool $(GCOV) --zerocounters --directory $(top_builddir)
+	@if xargs --version 2>/dev/null; then \
+		find $(top_builddir) -name "*.gcno" | xargs --no-run-if-empty rm; \
+	else \
+		find $(top_builddir) -name "*.gcno" | xargs rm; \
+	fi
+
+clean-local: clean-coverage
+
+SUBDIRS = src tests utils doc $(LUA_SUBDIR)

Copied: vendor/libucl/libucl-0.8.0/README.md (from r298162, vendor/libucl/dist/README.md)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libucl/libucl-0.8.0/README.md	Sun Apr 17 21:26:55 2016	(r298163, copy of r298162, vendor/libucl/dist/README.md)
@@ -0,0 +1,382 @@
+# LIBUCL
+
+[![Build Status](https://travis-ci.org/vstakhov/libucl.svg?branch=master)](https://travis-ci.org/vstakhov/libucl)[![Coverity](https://scan.coverity.com/projects/4138/badge.svg)](https://scan.coverity.com/projects/4138)[![Coverage Status](https://coveralls.io/repos/github/vstakhov/libucl/badge.svg?branch=master)](https://coveralls.io/github/vstakhov/libucl?branch=master)
+
+**Table of Contents**  *generated with [DocToc](http://doctoc.herokuapp.com/)*
+
+- [Introduction](#introduction)
+- [Basic structure](#basic-structure)
+- [Improvements to the json notation](#improvements-to-the-json-notation)
+	- [General syntax sugar](#general-syntax-sugar)
+	- [Automatic arrays creation](#automatic-arrays-creation)
+	- [Named keys hierarchy](#named-keys-hierarchy)
+	- [Convenient numbers and booleans](#convenient-numbers-and-booleans)
+- [General improvements](#general-improvements)
+	- [Commments](#commments)
+	- [Macros support](#macros-support)
+	- [Variables support](#variables-support)
+	- [Multiline strings](#multiline-strings)
+- [Emitter](#emitter)
+- [Validation](#validation)
+- [Performance](#performance)
+- [Conclusion](#conclusion)
+
+## Introduction 
+
+This document describes the main features and principles of the configuration
+language called `UCL` - universal configuration language.
+
+If you are looking for the libucl API documentation you can find it at [this page](doc/api.md).
+
+## Basic structure
+
+UCL is heavily infused by `nginx` configuration as the example of a convenient configuration
+system. However, UCL is fully compatible with `JSON` format and is able to parse json files.
+For example, you can write the same configuration in the following ways:
+
+* in nginx like:
+
+```nginx
+param = value;
+section {
+    param = value;
+    param1 = value1;
+    flag = true;
+    number = 10k;
+    time = 0.2s;
+    string = "something";
+    subsection {
+        host = {
+            host = "hostname"; 
+            port = 900;
+        }
+        host = {
+            host = "hostname";
+            port = 901;
+        }
+    }
+}
+```
+
+* or in JSON:
+
+```json
+{
+    "param": "value",
+    "param1": "value1",
+    "flag": true,
+    "subsection": {
+        "host": [
+        {
+            "host": "hostname",
+            "port": 900
+        },
+        {
+            "host": "hostname",
+            "port": 901
+        }
+        ]
+    }
+}
+```
+
+## Improvements to the json notation.
+
+There are various things that make ucl configuration more convenient for editing than strict json:
+
+### General syntax sugar
+
+* Braces are not necessary to enclose a top object: it is automatically treated as an object:
+
+```json
+"key": "value"
+```
+is equal to:
+```json
+{"key": "value"}
+```
+
+* There is no requirement of quotes for strings and keys, moreover, `:` may be replaced `=` or even be skipped for objects:
+
+```nginx
+key = value;
+section {
+    key = value;
+}
+```
+is equal to:
+```json
+{
+    "key": "value",
+    "section": {
+        "key": "value"
+    }
+}
+```
+
+* No commas mess: you can safely place a comma or semicolon for the last element in an array or an object:
+
+```json
+{
+    "key1": "value",
+    "key2": "value",
+}
+```
+### Automatic arrays creation
+
+* Non-unique keys in an object are allowed and are automatically converted to the arrays internally:
+
+```json
+{
+    "key": "value1",
+    "key": "value2"
+}
+```
+is converted to:
+```json
+{
+    "key": ["value1", "value2"]
+}
+```
+
+### Named keys hierarchy
+
+UCL accepts named keys and organize them into objects hierarchy internally. Here is an example of this process:
+```nginx
+section "blah" {
+	key = value;
+}
+section foo {
+	key = value;
+}
+```
+
+is converted to the following object:
+
+```nginx
+section {
+	blah {
+		key = value;
+	}
+	foo {
+		key = value;
+	}
+}
+```
+    
+Plain definitions may be more complex and contain more than a single level of nested objects:
+   
+```nginx
+section "blah" "foo" {
+	key = value;
+}
+```
+
+is presented as:
+
+```nginx    
+section {
+	blah {
+		foo {
+			key = value;
+		}
+	}
+}
+```
+
+### Convenient numbers and booleans
+
+* Numbers can have suffixes to specify standard multipliers:
+    + `[kKmMgG]` - standard 10 base multipliers (so `1k` is translated to 1000)
+    + `[kKmMgG]b` - 2 power multipliers (so `1kb` is translated to 1024)
+    + `[s|min|d|w|y]` - time multipliers, all time values are translated to float number of seconds, for example `10min` is translated to 600.0 and `10ms` is translated to 0.01
+* Hexadecimal integers can be used by `0x` prefix, for example `key = 0xff`. However, floating point values can use decimal base only.
+* Booleans can be specified as `true` or `yes` or `on` and `false` or `no` or `off`.
+* It is still possible to treat numbers and booleans as strings by enclosing them in double quotes.
+
+## General improvements
+
+### Commments
+
+UCL supports different style of comments:
+
+* single line: `#` 
+* multiline: `/* ... */`
+
+Multiline comments may be nested:
+```c
+# Sample single line comment
+/* 
+ some comment
+ /* nested comment */
+ end of comment
+*/
+```
+
+### Macros support
+
+UCL supports external macros both multiline and single line ones:
+```nginx
+.macro "sometext";
+.macro {
+    Some long text
+    ....
+};
+```
+
+Moreover, each macro can accept an optional list of arguments in braces. These
+arguments themselves are the UCL object that is parsed and passed to a macro as
+options:
+
+```nginx
+.macro(param=value) "something";
+.macro(param={key=value}) "something";
+.macro(.include "params.conf") "something";
+.macro(#this is multiline macro
+param = [value1, value2]) "something";
+.macro(key="()") "something";
+```
+
+UCL also provide a convenient `include` macro to load content from another files
+to the current UCL object. This macro accepts either path to file:
+
+```nginx
+.include "/full/path.conf"
+.include "./relative/path.conf"
+.include "${CURDIR}/path.conf"
+```
+
+or URL (if ucl is built with url support provided by either `libcurl` or `libfetch`):
+
+	.include "http://example.com/file.conf"
+
+`.include` macro supports a set of options:
+
+* `try` (default: **false**) - if this option is `true` than UCL treats errors on loading of
+this file as non-fatal. For example, such a file can be absent but it won't stop the parsing
+of the top-level document.
+* `sign` (default: **false**) - if this option is `true` UCL loads and checks the signature for
+a file from path named `<FILEPATH>.sig`. Trusted public keys should be provided for UCL API after
+parser is created but before any configurations are parsed.
+* `glob` (default: **false**) - if this option is `true` UCL treats the filename as GLOB pattern and load
+all files that matches the specified pattern (normally the format of patterns is defined in `glob` manual page
+for your operating system). This option is meaningless for URL includes.
+* `url` (default: **true**) - allow URL includes.
+* `path` (default: empty) - A UCL_ARRAY of directories to search for the include file.
+Search ends after the first patch, unless `glob` is true, then all matches are included.
+* `prefix` (default false) - Put included contents inside an object, instead
+of loading them into the root. If no `key` is provided, one is automatically generated based on each files basename()
+* `key` (default: <empty string>) - Key to load contents of include into. If
+the key already exists, it must be the correct type
+* `target` (default: object) - Specify if the `prefix` `key` should be an
+object or an array.
+* `priority` (default: 0) - specify priority for the include (see below).
+* `duplicate` (default: 'append') - specify policy of duplicates resolving:
+	- `append` - default strategy, if we have new object of higher priority then it replaces old one, if we have new object with less priority it is ignored completely, and if we have two duplicate objects with the same priority then we have a multi-value key (implicit array)
+	- `merge` - if we have object or array, then new keys are merged inside, if we have a plain object then an implicit array is formed (regardeless of priorities)
+	- `error` - create error on duplicate keys and stop parsing
+	- `rewrite` - always rewrite an old value with new one (ignoring priorities)
+
+Priorities are used by UCL parser to manage the policy of objects rewriting during including other files
+as following:
+
+* If we have two objects with the same priority then we form an implicit array
+* If a new object has bigger priority then we overwrite an old one
+* If a new object has lower priority then we ignore it
+
+By default, the priority of top-level object is set to zero (lowest priority). Currently,
+you can define up to 16 priorities (from 0 to 15). Includes with bigger priorities will
+rewrite keys from the objects with lower priorities as specified by the policy.
+
+### Variables support
+
+UCL supports variables in input. Variables are registered by a user of the UCL parser and can be presented in the following forms:
+
+* `${VARIABLE}`
+* `$VARIABLE`
+
+UCL currently does not support nested variables. To escape variables one could use double dollar signs:
+
+* `$${VARIABLE}` is converted to `${VARIABLE}`
+* `$$VARIABLE` is converted to `$VARIABLE`
+
+However, if no valid variables are found in a string, no expansion will be performed (and `$$` thus remains unchanged). This may be a subject
+to change in future libucl releases.
+
+### Multiline strings
+
+UCL can handle multiline strings as well as single line ones. It uses shell/perl like notation for such objects:
+```
+key = <<EOD
+some text
+splitted to
+lines
+EOD
+```
+
+In this example `key` will be interpreted as the following string: `some text\nsplitted to\nlines`.
+Here are some rules for this syntax:
+
+* Multiline terminator must start just after `<<` symbols and it must consist of capital letters only (e.g. `<<eof` or `<< EOF` won't work);
+* Terminator must end with a single newline character (and no spaces are allowed between terminator and newline character);
+* To finish multiline string you need to include a terminator string just after newline and followed by a newline (no spaces or other characters are allowed as well);
+* The initial and the final newlines are not inserted to the resulting string, but you can still specify newlines at the begin and at the end of a value, for example:
+
+```
+key <<EOD
+
+some
+text
+
+EOD
+```
+
+## Emitter
+
+Each UCL object can be serialized to one of the three supported formats:
+
+* `JSON` - canonic json notation (with spaces indented structure);
+* `Compacted JSON` - compact json notation (without spaces or newlines);
+* `Configuration` - nginx like notation;
+* `YAML` - yaml inlined notation.
+
+## Validation
+
+UCL allows validation of objects. It uses the same schema that is used for json: [json schema v4](http://json-schema.org). UCL supports the full set of json schema with the exception of remote references. This feature is unlikely useful for configuration objects. Of course, a schema definition can be in UCL format instead of JSON that simplifies schemas writing. Moreover, since UCL supports multiple values for keys in an object it is possible to specify generic integer constraints `maxValues` and `minValues` to define the limits of values count in a single key. UCL currently is not absolutely strict about validation schemas themselves, therefore UCL users should supply valid schemas (as it is defined in json-schema draft v4) to ensure that the input objects are validated properly.
+
+## Performance
+
+Are UCL parser and emitter fast enough? Well, there are some numbers.
+I got a 19Mb file that consist of ~700 thousands lines of json (obtained via
+http://www.json-generator.com/). Then I checked jansson library that performs json
+parsing and emitting and compared it with UCL. Here are results:
+
+```
+jansson: parsed json in 1.3899 seconds
+jansson: emitted object in 0.2609 seconds
+
+ucl: parsed input in 0.6649 seconds
+ucl: emitted config in 0.2423 seconds
+ucl: emitted json in 0.2329 seconds
+ucl: emitted compact json in 0.1811 seconds
+ucl: emitted yaml in 0.2489 seconds
+```
+
+So far, UCL seems to be significantly faster than jansson on parsing and slightly faster on emitting. Moreover,
+UCL compiled with optimizations (-O3) performs significantly faster:
+```
+ucl: parsed input in 0.3002 seconds
+ucl: emitted config in 0.1174 seconds
+ucl: emitted json in 0.1174 seconds
+ucl: emitted compact json in 0.0991 seconds
+ucl: emitted yaml in 0.1354 seconds
+```
+
+You can do your own benchmarks by running `make check` in libucl top directory.
+
+## Conclusion
+
+UCL has clear design that should be very convenient for reading and writing. At the same time it is compatible with
+JSON language and therefore can be used as a simple JSON parser. Macroes logic provides an ability to extend configuration
+language (for example by including some lua code) and comments allows to disable or enable the parts of a configuration
+quickly.

Copied: vendor/libucl/libucl-0.8.0/configure.ac (from r298162, vendor/libucl/dist/configure.ac)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libucl/libucl-0.8.0/configure.ac	Sun Apr 17 21:26:55 2016	(r298163, copy of r298162, vendor/libucl/dist/configure.ac)
@@ -0,0 +1,187 @@
+m4_define([maj_ver], [0])
+m4_define([med_ver], [8])
+m4_define([min_ver], [0])
+m4_define([so_version], [6:0:0])
+m4_define([ucl_version], [maj_ver.med_ver.min_ver])
+
+AC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl])
+AC_CONFIG_SRCDIR([configure.ac])
+AM_INIT_AUTOMAKE([1.11 foreign -Wall -Wportability no-dist-gzip dist-xz])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+UCL_VERSION=ucl_version
+SO_VERSION=so_version
+
+AC_SUBST(UCL_VERSION)
+AC_SUBST(SO_VERSION)
+
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+AM_PROG_AR
+LT_INIT
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_HEADERS([config.h])
+
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+AC_CHECK_HEADERS_ONCE([fcntl.h unistd.h])
+AC_TYPE_OFF_T
+AC_FUNC_MMAP
+AC_CHECK_HEADERS_ONCE([fcntl.h])
+AC_CHECK_HEADERS_ONCE([sys/types.h])
+AC_CHECK_HEADERS_ONCE([sys/stat.h])
+AC_CHECK_HEADERS_ONCE([sys/param.h])
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
+AC_CHECK_HEADERS_ONCE([stdlib.h])
+AC_CHECK_HEADERS_ONCE([stddef.h])
+AC_CHECK_HEADERS_ONCE([stdarg.h])
+AC_CHECK_HEADERS_ONCE([stdbool.h])
+AC_CHECK_HEADERS_ONCE([stdint.h])
+AC_CHECK_HEADERS_ONCE([string.h])
+AC_CHECK_HEADERS_ONCE([unistd.h])
+AC_CHECK_HEADERS_ONCE([ctype.h])
+AC_CHECK_HEADERS_ONCE([errno.h])
+AC_CHECK_HEADERS_ONCE([limits.h])
+AC_CHECK_HEADERS_ONCE([libgen.h])
+AC_CHECK_HEADERS_ONCE([stdio.h])
+AC_CHECK_HEADERS_ONCE([float.h])
+AC_CHECK_HEADERS_ONCE([math.h])
+AC_CHECK_HEADERS_ONCE([endian.h sys/endian.h machine/endian.h])
+
+dnl Example of default-disabled feature
+AC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], 
+	[Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [],
+	[enable_urls=no])
+AC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], 
+	[Enable regex checking for schema @<:@default=yes@:>@]), [],
+	[enable_regex=yes])
+AC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures],
+	[Enable signatures check (requires openssl) @<:@default=no@:>@]), [],
+	[enable_signatures=no])
+AC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua],
+	[Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [],
+	[enable_lua=no])
+AC_ARG_ENABLE([utils],
+	AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]),
+	[case "${enableval}" in
+  		yes) utils=true ;;
+  		no)  utils=false ;;
+  		*) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;;
+	esac],[utils=false])
+AM_CONDITIONAL([UTILS], [test x$utils = xtrue])
+
+AS_IF([test "x$enable_signatures" = "xyes"], [
+	AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [
+		AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).])
+		LIBCRYPTO_LIB="-lcrypto"
+		LIBS_EXTRA="${LIBS_EXTRA} -lcrypto"
+		], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])])
+])
+AC_SUBST(LIBCRYPTO_LIB)
+AC_PATH_PROG(PANDOC, pandoc, [/non/existent])
+
+AC_SEARCH_LIBS([clock_gettime], [rt], [], [
+	AC_CHECK_HEADER([mach/mach_time.h], [
+		AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin])
+	], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])])
+])
+AC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])])
+
+AS_IF([test "x$enable_regex" = "xyes"], [
+	AC_CHECK_HEADER([regex.h], [
+		AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.])
+		AC_SEARCH_LIBS([regexec], [regex], [
+			AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [
+				LIBREGEX_LIB="-lregex"
+				LIBS_EXTRA="${LIBS_EXTRA} -lregex"
+				]
+			)], 
+			[AC_MSG_ERROR([unable to find the regexec() function])])],
+			[AC_MSG_ERROR([unable to find the regex.h header])
+		],
+		[#include <sys/types.h>])
+])
+AC_SUBST(LIBREGEX_LIB)
+
+AS_IF([test "x$enable_lua" = "xyes"], [
+	AX_PROG_LUA([5.1], [], [
+		AX_LUA_HEADERS([
+			AX_LUA_LIBS([
+				AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.])
+				with_lua="yes"
+			], [AC_MSG_ERROR([unable to find the lua libraries])
+			])
+		], [AC_MSG_ERROR([unable to find the lua header files])
+		])
+	], [AC_MSG_ERROR([unable to find the lua interpreter])])
+], [with_lua="no"])
+
+AM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"])
+
+AS_IF([test "x$enable_urls" = "xyes"], [
+	AC_CHECK_HEADER([fetch.h], [
+		AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.])
+		AC_CHECK_LIB(fetch, fetchXGet, [
+			AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).])
+			LIBFETCH_LIBS="-lfetch"
+			have_libfetch="yes"
+			LIBS_EXTRA="${LIBS_EXTRA} -lfetch"
+		])
+	], [],[
+	#include <stdio.h>
+	#ifdef HAVE_SYS_PARAM_H
+	#include <sys/param.h>
+	#endif
+	])
+	AC_SUBST(LIBFETCH_LIBS)
+
+	AS_IF([ test "x$have_libfetch" != "xyes"], [
+		dnl Fallback to libcurl
+		PKG_CHECK_MODULES([CURL], [libcurl], [
+			AC_DEFINE(CURL_FOUND, 1, [Use libcurl])
+			LIBS_EXTRA="${LIBS_EXTRA} -lcurl"],
+		[AC_MSG_ERROR([unable to find neither libfetch nor libcurl])])
+	])
+	AC_SUBST(CURL_FOUND)
+	AC_SUBST(CURL_LIBS)
+	AC_SUBST(CURL_CFLAGS)
+])
+
+AC_SUBST(LIBS_EXTRA)
+
+AC_MSG_CHECKING(for GCC atomic builtins)
+AC_LINK_IFELSE([
+	AC_LANG_SOURCE([[
+		int main() {
+			volatile unsigned long val = 1;
+			__sync_synchronize();
+			__sync_val_compare_and_swap(&val, 1, 0);
+			__sync_add_and_fetch(&val, 1);
+			__sync_sub_and_fetch(&val, 1);
+			return 0;
+		}
+	]])
+],
+[
+	AC_MSG_RESULT([yes])
+	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics])
+],
+[
+	AC_MSG_RESULT([no])
+	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics])
+	AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing])
+])
+
+AX_CODE_COVERAGE
+
+AC_CONFIG_FILES(Makefile \
+	src/Makefile \
+	lua/Makefile
+	tests/Makefile \
+	utils/Makefile \
+	doc/Makefile \
+	lua/libucl.rockspec \
+	libucl.pc)
+AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
+AC_OUTPUT

Copied: vendor/libucl/libucl-0.8.0/include/ucl++.h (from r298162, vendor/libucl/dist/include/ucl++.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/libucl/libucl-0.8.0/include/ucl++.h	Sun Apr 17 21:26:55 2016	(r298163, copy of r298162, vendor/libucl/dist/include/ucl++.h)
@@ -0,0 +1,444 @@
+/*
+ * Copyright (c) 2015, Vsevolod Stakhov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *	 * Redistributions of source code must retain the above copyright
+ *	   notice, this list of conditions and the following disclaimer.
+ *	 * Redistributions in binary form must reproduce the above copyright
+ *	   notice, this list of conditions and the following disclaimer in the
+ *	   documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+#include <string>
+#include <memory>
+#include <iostream>
+
+#include "ucl.h"
+
+// C++11 API inspired by json11: https://github.com/dropbox/json11/
+
+namespace ucl {
+
+struct ucl_map_construct_t { };
+constexpr ucl_map_construct_t ucl_map_construct = ucl_map_construct_t();
+struct ucl_array_construct_t { };
+constexpr ucl_array_construct_t ucl_array_construct = ucl_array_construct_t();
+
+class Ucl final {
+private:
+
+	struct ucl_deleter {
+		void operator() (ucl_object_t *obj) {
+			ucl_object_unref (obj);
+		}
+	};
+
+	static int
+	append_char (unsigned char c, size_t nchars, void *ud)
+	{
+		std::string *out = reinterpret_cast<std::string *>(ud);
+
+		out->append (nchars, (char)c);
+
+		return nchars;
+	}
+	static int
+	append_len (unsigned const char *str, size_t len, void *ud)
+	{
+		std::string *out = reinterpret_cast<std::string *>(ud);
+
+		out->append ((const char *)str, len);
+
+		return len;
+	}
+	static int
+	append_int (int64_t elt, void *ud)
+	{
+		std::string *out = reinterpret_cast<std::string *>(ud);
+		auto nstr = std::to_string (elt);
+
+		out->append (nstr);
+
+		return nstr.size ();
+	}
+	static int
+	append_double (double elt, void *ud)
+	{
+		std::string *out = reinterpret_cast<std::string *>(ud);
+		auto nstr = std::to_string (elt);
+
+		out->append (nstr);
+
+		return nstr.size ();
+	}
+
+	static struct ucl_emitter_functions default_emit_funcs()
+	{
+		struct ucl_emitter_functions func = {
+			Ucl::append_char,
+			Ucl::append_len,
+			Ucl::append_int,
+			Ucl::append_double,
+			nullptr,
+			nullptr
+		};
+
+		return func;
+	};
+
+	std::unique_ptr<ucl_object_t, ucl_deleter> obj;
+
+public:
+	class const_iterator {
+	private:
+		struct ucl_iter_deleter {
+			void operator() (ucl_object_iter_t it) {
+				ucl_object_iterate_free (it);
+			}
+		};
+		std::shared_ptr<void> it;
+		std::unique_ptr<Ucl> cur;
+	public:
+		typedef std::forward_iterator_tag iterator_category;
+
+		const_iterator(const Ucl &obj) {
+			it = std::shared_ptr<void>(ucl_object_iterate_new (obj.obj.get()),
+					ucl_iter_deleter());
+			cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true)));
+			if (!*cur) {
+				it.reset ();
+				cur.reset ();
+			}
+		}
+
+		const_iterator() {}
+		const_iterator(const const_iterator &other) = delete;
+		const_iterator(const_iterator &&other) = default;
+		~const_iterator() {}
+
+		const_iterator& operator=(const const_iterator &other) = delete;
+		const_iterator& operator=(const_iterator &&other) = default;
+
+		bool operator==(const const_iterator &other) const
+		{
+			if (cur && other.cur) {
+				return cur->obj.get() == other.cur->obj.get();
+			}
+
+			return !cur && !other.cur;
+		}
+
+		bool operator!=(const const_iterator &other) const
+		{
+			return !(*this == other);
+		}
+
+		const_iterator& operator++()
+		{
+			if (it) {
+				cur.reset (new Ucl(ucl_object_iterate_safe (it.get(), true)));
+			}
+
+			if (!*cur) {
+				it.reset ();
+				cur.reset ();
+			}
+
+			return *this;
+		}
+
+		const Ucl& operator*() const
+		{
+			return *cur;
+		}
+		const Ucl* operator->() const
+		{
+			return cur.get();
+		}
+	};
+
+	// We grab ownership if get non-const ucl_object_t
+	Ucl(ucl_object_t *other) {
+		obj.reset (other);
+	}
+
+	// Shared ownership
+	Ucl(const ucl_object_t *other) {
+		obj.reset (ucl_object_ref (other));
+	}
+
+	Ucl(const Ucl &other) {
+		obj.reset (ucl_object_ref (other.obj.get()));
+	}
+
+	Ucl(Ucl &&other) {
+		obj.swap (other.obj);
+	}
+
+	Ucl() noexcept {
+		obj.reset (ucl_object_typed_new (UCL_NULL));
+	}
+	Ucl(std::nullptr_t) noexcept {
+		obj.reset (ucl_object_typed_new (UCL_NULL));
+	}
+	Ucl(double value) {
+		obj.reset (ucl_object_typed_new (UCL_FLOAT));
+		obj->value.dv = value;
+	}
+	Ucl(int64_t value) {
+		obj.reset (ucl_object_typed_new (UCL_INT));
+		obj->value.iv = value;
+	}
+	Ucl(bool value) {
+		obj.reset (ucl_object_typed_new (UCL_BOOLEAN));
+		obj->value.iv = static_cast<int64_t>(value);
+	}
+	Ucl(const std::string &value) {
+		obj.reset (ucl_object_fromstring_common (value.data (), value.size (),
+				UCL_STRING_RAW));
+	}
+	Ucl(const char * value) {
+		obj.reset (ucl_object_fromstring_common (value, 0, UCL_STRING_RAW));
+	}
+
+	// Implicit constructor: anything with a to_json() function.
+	template <class T, class = decltype(&T::to_ucl)>
+	Ucl(const T & t) : Ucl(t.to_ucl()) {}
+
+	// Implicit constructor: map-like objects (std::map, std::unordered_map, etc)
+	template <class M, typename std::enable_if<
+		std::is_constructible<std::string, typename M::key_type>::value
+		&& std::is_constructible<Ucl, typename M::mapped_type>::value,
+		int>::type = 0>
+	Ucl(const M & m) {
+		obj.reset (ucl_object_typed_new (UCL_OBJECT));
+		auto cobj = obj.get ();
+
+		for (const auto &e : m) {
+			ucl_object_insert_key (cobj, ucl_object_ref (e.second.obj.get()),
+					e.first.data (), e.first.size (), true);
+		}
+	}
+
+	// Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc)
+	template <class V, typename std::enable_if<
+		std::is_constructible<Ucl, typename V::value_type>::value,
+		int>::type = 0>
+	Ucl(const V & v) {
+		obj.reset (ucl_object_typed_new (UCL_ARRAY));
+		auto cobj = obj.get ();
+
+		for (const auto &e : v) {
+			ucl_array_append (cobj, ucl_object_ref (e.obj.get()));
+		}
+	}
+
+	ucl_type_t type () const {
+		if (obj) {
+			return ucl_object_type (obj.get ());
+		}
+		return UCL_NULL;
+	}
+
+	const std::string key () const {
+		std::string res;
+
+		if (obj->key) {
+			res.assign (obj->key, obj->keylen);
+		}
+
+		return res;
+	}
+
+	double number_value (const double default_val = 0.0) const

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-vendor mailing list