-version: 0.2.2.{build}
+version: 0.2.3.{build}
image:
- Visual Studio 2015
set (YAML_VERSION_MAJOR 0)
set (YAML_VERSION_MINOR 2)
-set (YAML_VERSION_PATCH 2)
+set (YAML_VERSION_PATCH 3)
set (YAML_VERSION_STRING "${YAML_VERSION_MAJOR}.${YAML_VERSION_MINOR}.${YAML_VERSION_PATCH}")
option(BUILD_SHARED_LIBS "Build libyaml as a shared library" OFF)
-option(YAML_STATIC_LIB_NAME "base name of static library output" yaml)
+set(YAML_STATIC_LIB_NAME "yaml" CACHE STRING "Base name of static library output")
#
# Output directories for a build tree
--- /dev/null
+0.2.3 2020-04-11
+
+ - https://github.com/yaml/libyaml/pull/130
+ Fixed typo.
+
+ - https://github.com/yaml/libyaml/pull/144
+ Fix typo in comment
+
+ - https://github.com/yaml/libyaml/pull/140
+ Use pointer to const for strings that aren't/shouldn't be modified
+
+ - https://github.com/yaml/libyaml/pull/128
+ Squash a couple of warnings in example-deconstructor-alt
+
+ - https://github.com/yaml/libyaml/pull/151
+ Fix spelling for error message
+
+ - https://github.com/yaml/libyaml/pull/161
+ Make appveyor config be a hidden file
+
+ - https://github.com/yaml/libyaml/pull/159
+ Add CHANGES file
+
+ - https://github.com/yaml/libyaml/pull/160
+ Always output document end before directive (YAML 1.2 compatibility)
+
+ - https://github.com/yaml/libyaml/pull/162
+ Output document end marker after open ended scalars
+
+ - https://github.com/yaml/libyaml/pull/157
+ change cmake target name from libOFF.a to libyaml.a
+
+ - https://github.com/yaml/libyaml/pull/155
+ include/yaml.h: fix comments
+
+ - https://github.com/yaml/libyaml/pull/169
+ Fixed missing token in example
+
+ - https://github.com/yaml/libyaml/pull/127
+ Avoid recursion in the document loader.
+
+ - https://github.com/yaml/libyaml/pull/172
+ Support %YAML 1.2 directives
+
+ - https://github.com/yaml/libyaml/pull/66
+ Change dllexport controlling macro to use _WIN32
+
+0.2.2 2019-03-12
+
+ - https://github.com/yaml/libyaml/pull/95
+ build: do not install config.h
+
+ - https://github.com/yaml/libyaml/pull/97
+ appveyor.yml: fix Release build
+
+ - https://github.com/yaml/libyaml/pull/103
+ Remove unused code in yaml_document_delete
+
+ - https://github.com/yaml/libyaml/pull/104
+ Allow colons in plain scalars inside flow collections
+
+ - https://github.com/yaml/libyaml/pull/109
+ Fix comparison in tests/run-emitter.c
+
+ - https://github.com/yaml/libyaml/pull/117
+ Fix typo error
+
+ - https://github.com/yaml/libyaml/pull/119
+ The closing single quote needs to be indented...
+
+ - https://github.com/yaml/libyaml/pull/121
+ fix token name typos in comments
+
+ - https://github.com/yaml/libyaml/pull/122
+ Revert removing of open_ended after top level plain scalar
+
+ - https://github.com/yaml/libyaml/pull/125
+ Cherry-picks from PR 27
+
+ - https://github.com/yaml/libyaml/pull/135
+ Windows/C89 compatibility
+
+ - https://github.com/yaml/libyaml/pull/136
+ allow override of Windows static lib name
+
+0.2.1 2018-06-24
+
+ - https://github.com/yaml/libyaml/pull/10
+ Support static and dynamic libraries
+
+ - https://github.com/yaml/libyaml/pull/12
+ Use .gitignore instead of .hgignore
+
+ - https://github.com/yaml/libyaml/pull/13
+ Add support for `make test` and travis
+
+ - https://github.com/yaml/libyaml/pull/14
+ Dockerfile for testing
+
+ - https://github.com/yaml/libyaml/pull/15
+ Apply old fix for `\/` that is not in master.
+
+ - https://github.com/yaml/libyaml/pull/17
+ Update license to include all years until now.
+
+ - https://github.com/yaml/libyaml/pull/18
+ Port bug fix from Perl binding
+
+ - https://github.com/yaml/libyaml/pull/22
+ Fix misspell: preceed
+
+ - https://github.com/yaml/libyaml/pull/23
+ Removed trailing-whitespaces
+
+ - https://github.com/yaml/libyaml/pull/24
+ Fix typo
+
+ - https://github.com/yaml/libyaml/pull/25
+ added an examples directory with a few yaml examples
+
+ - https://github.com/yaml/libyaml/pull/26
+ Added missing Cflags path in pkg-config file
+
+ - https://github.com/yaml/libyaml/pull/31
+ add unit tests to cmake configuration
+
+ - https://github.com/yaml/libyaml/pull/32
+ Include an example of a custom tag from Python
+
+ - https://github.com/yaml/libyaml/pull/33
+ Include an example of a %YAML tag
+
+ - https://github.com/yaml/libyaml/pull/34
+ Added an example of using a global tag
+
+ - https://github.com/yaml/libyaml/pull/36
+ Fix -Wformat compilation errors in tests
+
+ - https://github.com/yaml/libyaml/pull/37
+ Update bug report URL in LibYAML
+
+ - https://github.com/yaml/libyaml/pull/38
+ Use AM_CPPFLAGS since autotools deprecated INCLUDE
+
+ - https://github.com/yaml/libyaml/pull/39
+ Update bug report URL in README
+
+ - https://github.com/yaml/libyaml/pull/41
+ Add travis and Makefile support for libyaml-test
+
+ - https://github.com/yaml/libyaml/pull/43
+ Add Dockerfile for Fedora 25
+
+ - https://github.com/yaml/libyaml/pull/44
+ WIP: Enable all warnings (-Wall) in libyaml and tests
+
+ - https://github.com/yaml/libyaml/pull/45
+ Fix typo
+
+ - https://github.com/yaml/libyaml/pull/47
+ Move travis script guts to separate file
+
+ - https://github.com/yaml/libyaml/pull/48
+ `yaml/libyaml-test` should become part of `yaml/libyaml`
+
+ - https://github.com/yaml/libyaml/pull/50
+ Add a GNUMakefile for immediate make targets
+
+ - https://github.com/yaml/libyaml/pull/53
+ Switch from test blacklist to whitelist
+
+ - https://github.com/yaml/libyaml/pull/55
+ Update defs for MingGW support on Windows
+
+ - https://github.com/yaml/libyaml/pull/58
+ Improve CMakeLists
+
+ - https://github.com/yaml/libyaml/pull/64
+ README: Update libyaml link
+
+ - https://github.com/yaml/libyaml/pull/69
+ Skip 5 tests in libyaml-emitter.list
+
+ - https://github.com/yaml/libyaml/pull/74
+ Forbid escaped singlequote in doublequotes
+
+ - https://github.com/yaml/libyaml/pull/76
+ Rewrite make test-suite
+
+ - https://github.com/yaml/libyaml/pull/77
+ Undefined PTRDIFF_MAX on HP-UX
+
+ - https://github.com/yaml/libyaml/pull/78
+ Fixed most compiler warnings -Wall -Wextra
+
+ - https://github.com/yaml/libyaml/pull/82
+ Move yaml-test-suite integration onto a separate branch.
+
+ - https://github.com/yaml/libyaml/pull/86
+ Fix problems in CI failures (travis and semaphore)
+
+ - https://github.com/yaml/libyaml/pull/87
+ appveyor.yml: add mingw-w64 builds
+
+ - https://github.com/yaml/libyaml/pull/88
+ add -no-undefined to src/Makefile.am
+
+ - https://github.com/yaml/libyaml/pull/89
+ Added alpine linux testing to dockerfiles
+
+ - https://github.com/yaml/libyaml/pull/93
+ remove need for PTRDIFF_MAX
+
+ - https://github.com/yaml/libyaml/pull/94
+ .gitignore: major cleanup
+
+ - https://github.com/yaml/libyaml/pull/120
+ Fix doc.
+
+0.1.7 2016-08-27
+
+ - Fixed segfault in yaml_string_write_handler.
+
+ - Fixed invalid simple key assertion.
+
+ - Fixed error handling in some examples (thank to Mathias Svensson).
+
+ - Removed obsolete VS project files.
+
+0.1.6 2014-03-26
+
+ - https://github.com/yaml/libyaml/commit/d1003a9
+ Fixed heap overflow in yaml_parser_scan_uri_escapes (Thanks
+ Ivan Fratric of the Google Security Team).
+
+ - https://github.com/yaml/libyaml/commit/662f4be
+ Added tag 0.1.5 for changeset a5142b24428b
+
+0.1.5 2014-02-03
+
+ - https://github.com/yaml/libyaml/commit/303b455
+ Manually define PTRDIFF_MAX for VS C compiler.
+
+ - https://github.com/yaml/libyaml/commit/1ef1171
+ Forgot to set the error state.
+
+ - https://github.com/yaml/libyaml/commit/c9479c7
+ Limit input size to SIZE_MAX/2.
+
+ - https://github.com/yaml/libyaml/commit/c201bf6
+ Guard against overflows in indent and flow_level.
+
+ - https://github.com/yaml/libyaml/commit/bb8ab82
+ Added .hgignore.
+
+ - https://github.com/yaml/libyaml/commit/2d94fc5
+ Prevent node index overflow (Reported by Florian Weimer).
+
+ - https://github.com/yaml/libyaml/commit/df33f25
+ Bumped the version number.
+
+ - https://github.com/yaml/libyaml/commit/f56726b
+ Fixed invalid size_t->int cast (Thank to Florian Weimer).
+
+ - https://github.com/yaml/libyaml/commit/01e8dad
+ Added a basic CMake project.
+
+ - https://github.com/yaml/libyaml/commit/f54fc40
+ Added tag 0.1.4 for changeset 3e6507fa0c26
+
+0.1.4 2012-12-24
+
+ - Fixed a bug that prevented an empty mapping being used as a simple key
+ (thank to spitzak(at)rhythm(dot)com).
+
+ - Fixed pointer overflow when calculating the position of a potential
+ simple key (thank to ppelletier(at)oblong(dot)com).
+
+ - Fixed yaml.dll not exporting any symbols
+ (thank to pxn11432(at)nifty(dot)com).
+
+ - Added pkg-config support (thank to rainwoodman(at)gmail(dot)com).
+
+0.1.3 2009-08-29
+
+ - This release fixes non-standard structure initialization and
+ a streaming-related issue.
+
+0.1.2 2008-12-27
+
+ - Minor bugfix release
+
+0.1.1 2006-08-01
+
+ - https://github.com/yaml/libyaml/commit/5e52c31
+ Fixed a problem when the DOCUMENT-END event is not emitted until
+ the beginning of the next document is available. Fixed #51.
+ Thanks edward(at)sweetbytes.net for the bug report.
+
+ - https://github.com/yaml/libyaml/commit/dd71484
+ Add project files for Visual Studio 2003.
+
+ - https://github.com/yaml/libyaml/commit/ce8a93e
+ Fix the example_deconstructor project.
+
+ - https://github.com/yaml/libyaml/commit/c9b74de
+ Eliminate some warnings and add more doxygen definitions.
+
+ - https://github.com/yaml/libyaml/commit/0122490
+ Undefine the NDEBUG directive for the test programs.
+
+ - https://github.com/yaml/libyaml/commit/071329a
+ Fix a bug in the emitter introduced while fixing warnings for VC6.
+
+ - https://github.com/yaml/libyaml/commit/6f6bbb8
+ Add VC6 projects for the test executables.
+
+ - https://github.com/yaml/libyaml/commit/0174ed6
+ Add win32 fixes and project files for VC6.
+
+ - https://github.com/yaml/libyaml/commit/e27a3c8
+ Add functions for constructing, parsing and emitting YAML documents.
+
+ - https://github.com/yaml/libyaml/commit/a907bf8
+ Add `const` qualifier for `yaml_parser_set_input_string` parameter `input`.
+
+ - https://github.com/yaml/libyaml/commit/c83b67a
+ Force a new line at the end of the input stream even if there
+ are no a new line character. This fixes a nasty bug when libyaml hangs on
+ documents like `[[[[`. Thanks ciaranm for reporting the bug.
+
+ - https://github.com/yaml/libyaml/commit/609cce0
+ Older versions of gcc do not know about -Wno-pointer-sign.
+
+0.0.1 2006-08-01
+
+ - Initial release
-Copyright (c) 2017-2019 Ingy döt Net
+Copyright (c) 2017-2020 Ingy döt Net
Copyright (c) 2006-2016 Kirill Simonov
Permission is hereby granted, free of charge, to any person obtaining a copy of
SUBDIRS = include src . tests
-EXTRA_DIST = README LICENSE CMakeLists.txt doc/doxygen.cfg
+EXTRA_DIST = Changes ReadMe.md License CMakeLists.txt doc/doxygen.cfg
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = yaml-0.1.pc
test: all
make -C tests check-TESTS
-test-suite: tests/run-test-suite
+test-suite: tests/run-test-suite all
make -C $< test
test-all: test test-suite
+++ /dev/null
-LibYAML - A C library for parsing and emitting YAML.
-
-To build and install the library, run:
-$ ./configure
-$ make
-# make install
-
-If you checked the source code from the Git repository, run
-$ ./bootstrap
-$ ./configure
-$ make
-# make install
-
-For more information, check the LibYAML homepage:
-'https://github.com/yaml/libyaml'.
-
-Discuss LibYAML with the maintainers in IRC #libyaml irc.freenode.net.
-
-You may also use the YAML-Core mailing list:
-'http://lists.sourceforge.net/lists/listinfo/yaml-core'.
-
-Submit bug reports and feature requests to the LibYAML bug tracker:
-'https://github.com/yaml/libyaml/issues/new'.
-
-This project was developed for Python Software Foundation as a part of Google
-Summer of Code under the mentorship of Clark Evans.
-
-The LibYAML module was written by Kirill Simonov <xi@resolvent.net>.
-It is currently maintained by the YAML community.
-
-LibYAML is released under the MIT license.
-See the file LICENSE for more details.
--- /dev/null
+## LibYAML - A C library for parsing and emitting YAML.
+
+To build and install the library, run:
+
+ $ ./configure
+ $ make
+ # make install
+
+Required packages:
+
+- gcc
+- libtool
+- make
+
+If you checked the source code from the Git repository, run
+
+ $ ./bootstrap
+ $ ./configure
+ $ make
+ # make install
+
+Required packages:
+
+- autoconf
+- libtool
+- make
+
+For more information, check the [LibYAML
+homepage](https://github.com/yaml/libyaml).
+
+Discuss LibYAML with the maintainers in IRC #libyaml irc.freenode.net.
+
+You may also use the [YAML-Core mailing
+list](http://lists.sourceforge.net/lists/listinfo/yaml-core).
+
+Submit bug reports and feature requests to the [LibYAML bug
+tracker](https://github.com/yaml/libyaml/issues/new).
+
+This project was developed for Python Software Foundation as a part of Google
+Summer of Code under the mentorship of Clark Evans.
+
+The LibYAML module was written by Kirill Simonov <xi@resolvent.net>.
+It is currently maintained by the YAML community.
+
+LibYAML is released under the MIT license.
+See the file LICENSE for more details.
-From: Ingy döt Net <ingy@ingy.net>
+From: Tina Müller <post@tinita.de>
To: yaml-core@lists.sourceforge.net
-Subject: [ANN] LibYAML-0.2.2: A new release
+Subject: [ANN] LibYAML-0.2.3: A new release
=========================
- Announcing LibYAML-0.2.2
+ Announcing LibYAML-0.2.3
=========================
A new release of LibYAML is now available:
-https://github.com/yaml/libyaml/tree/0.2.2
+https://github.com/yaml/libyaml/tree/0.2.3
The LibYAML project is now maintained by the YAML community. Planning happens
on the #yaml-dev and #libyaml IRC channels on irc.freenode.net.
Changes
=======
-* https://github.com/yaml/libyaml/pull/95 -- build: do not install config.h
-* https://github.com/yaml/libyaml/pull/97 -- appveyor.yml: fix Release build
-* https://github.com/yaml/libyaml/pull/103 -- Remove unused code in yaml_document_delete
-* https://github.com/yaml/libyaml/pull/104 -- Allow colons in plain scalars inside flow collections
-* https://github.com/yaml/libyaml/pull/109 -- Fix comparison in tests/run-emitter.c
-* https://github.com/yaml/libyaml/pull/117 -- Fix typo error
-* https://github.com/yaml/libyaml/pull/119 -- The closing single quote needs to be indented...
-* https://github.com/yaml/libyaml/pull/121 -- fix token name typos in comments
-* https://github.com/yaml/libyaml/pull/122 -- Revert removing of open_ended after top level plain scalar
-* https://github.com/yaml/libyaml/pull/125 -- Cherry-picks from PR 27
-* https://github.com/yaml/libyaml/pull/135 -- Windows/C89 compatibility
-* https://github.com/yaml/libyaml/pull/136 -- allow override of Windows static lib name
-
+- https://github.com/yaml/libyaml/pull/66 -- Change dllexport controlling macro to use _WIN32
+- https://github.com/yaml/libyaml/pull/127 -- Avoid recursion in the document loader.
+- https://github.com/yaml/libyaml/pull/128 -- Squash a couple of warnings in example-deconstructor-alt
+- https://github.com/yaml/libyaml/pull/130 -- Fixed typo.
+- https://github.com/yaml/libyaml/pull/140 -- Use pointer to const for strings that aren't/shouldn't be modified
+- https://github.com/yaml/libyaml/pull/144 -- Fix typo in comment
+- https://github.com/yaml/libyaml/pull/151 -- Fix spelling for error message
+- https://github.com/yaml/libyaml/pull/155 -- include/yaml.h: fix comments
+- https://github.com/yaml/libyaml/pull/157 -- change cmake target name from libOFF.a to libyaml.a
+- https://github.com/yaml/libyaml/pull/159 -- Add CHANGES file
+- https://github.com/yaml/libyaml/pull/160 -- Always output document end before directive (YAML 1.2 compatibility)
+- https://github.com/yaml/libyaml/pull/161 -- Make appveyor config be a hidden file
+- https://github.com/yaml/libyaml/pull/162 -- Output document end marker after open ended scalars
+- https://github.com/yaml/libyaml/pull/169 -- Fixed missing token in example
+- https://github.com/yaml/libyaml/pull/172 -- Support %YAML 1.2 directives
Resources
LibYAML IRC Channel: #libyaml on irc.freenode.net
LibYAML homepage: https://github.com/yaml/libyaml
-Source download: https://github.com/yaml/libyaml/archive/dist-0.2.2.zip
+Source download: https://github.com/yaml/libyaml/archive/dist-0.2.3.zip
GitHub repository: https://github.com/yaml/libyaml
Bug tracking: https://github.com/yaml/libyaml/issues
Copyright
=========
-Copyright (c) 2017-2019 Ingy döt Net <ingy@ingy.net>
+Copyright (c) 2017-2020 Ingy döt Net <ingy@ingy.net>
Copyright (c) 2006-2016 Kirill Simonov <xi@resolvent.net>
The LibYAML module was written by Kirill Simonov.
# Define the package version numbers and the bug reporting link.
m4_define([YAML_MAJOR], 0)
m4_define([YAML_MINOR], 2)
-m4_define([YAML_PATCH], 2)
+m4_define([YAML_PATCH], 3)
m4_define([YAML_BUGS], [https://github.com/yaml/libyaml/issues/new])
# Define the libtool version numbers; check the Autobook, Section 11.4.
# YAML_AGE = 0
m4_define([YAML_RELEASE], 0)
m4_define([YAML_CURRENT], 2)
-m4_define([YAML_REVISION], 6)
+m4_define([YAML_REVISION], 7)
m4_define([YAML_AGE], 0)
# Initialize autoconf & automake.
#if defined(__MINGW32__)
# define YAML_DECLARE(type) type
-#elif defined(WIN32)
+#elif defined(_WIN32)
# if defined(YAML_DECLARE_STATIC)
# define YAML_DECLARE(type) type
# elif defined(YAML_DECLARE_EXPORT)
*/
YAML_DECLARE(int)
-yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
+yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor);
/**
* Create a SCALAR event.
YAML_DECLARE(int)
yaml_scalar_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag,
- yaml_char_t *value, int length,
+ const yaml_char_t *anchor, const yaml_char_t *tag,
+ const yaml_char_t *value, int length,
int plain_implicit, int quoted_implicit,
yaml_scalar_style_t style);
YAML_DECLARE(int)
yaml_sequence_start_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
yaml_sequence_style_t style);
/**
YAML_DECLARE(int)
yaml_mapping_start_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
yaml_mapping_style_t style);
/**
YAML_DECLARE(int)
yaml_document_add_scalar(yaml_document_t *document,
- yaml_char_t *tag, yaml_char_t *value, int length,
+ const yaml_char_t *tag, const yaml_char_t *value, int length,
yaml_scalar_style_t style);
/**
YAML_DECLARE(int)
yaml_document_add_sequence(yaml_document_t *document,
- yaml_char_t *tag, yaml_sequence_style_t style);
+ const yaml_char_t *tag, yaml_sequence_style_t style);
/**
* Create a MAPPING node and attach it to the document.
YAML_DECLARE(int)
yaml_document_add_mapping(yaml_document_t *document,
- yaml_char_t *tag, yaml_mapping_style_t style);
+ const yaml_char_t *tag, yaml_mapping_style_t style);
/**
* Add an item to a SEQUENCE node.
* @param[in,out] document A document object.
* @param[in] sequence The sequence node id.
* @param[in] item The item node id.
-*
+ *
* @returns @c 1 if the function succeeded, @c 0 on error.
*/
* @param[in] mapping The mapping node id.
* @param[in] key The key node id.
* @param[in] value The value node id.
-*
+ *
* @returns @c 1 if the function succeeded, @c 0 on error.
*/
/** The number of tokens fetched from the queue. */
size_t tokens_parsed;
- /* Does the tokens queue contain a token ready for dequeueing. */
+ /** Does the tokens queue contain a token ready for dequeueing. */
int token_available;
/** The indentation levels stack. */
* @param[in,out] parser A parser object.
* @param[out] document An empty document object.
*
- * @return @c 1 if the function succeeded, @c 0 on error.
+ * @returns @c 1 if the function succeeded, @c 0 on error.
*/
YAML_DECLARE(int)
/** Write handler. */
yaml_write_handler_t *write_handler;
- /** A pointer for passing to the white handler. */
+ /** A pointer for passing to the write handler. */
void *write_handler_data;
/** Standard (string or file) output data. */
yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
/**
- * Set the intendation increment.
+ * Set the indentation increment.
*
* @param[in,out] emitter An emitter object.
* @param[in] indent The indentation increment (1 < . < 10).
*/
static int
-yaml_check_utf8(yaml_char_t *start, size_t length)
+yaml_check_utf8(const yaml_char_t *start, size_t length)
{
- yaml_char_t *end = start+length;
- yaml_char_t *pointer = start;
+ const yaml_char_t *end = start+length;
+ const yaml_char_t *pointer = start;
while (pointer < end) {
unsigned char octet;
*/
YAML_DECLARE(int)
-yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor)
+yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor)
{
yaml_mark_t mark = { 0, 0, 0 };
yaml_char_t *anchor_copy = NULL;
YAML_DECLARE(int)
yaml_scalar_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag,
- yaml_char_t *value, int length,
+ const yaml_char_t *anchor, const yaml_char_t *tag,
+ const yaml_char_t *value, int length,
int plain_implicit, int quoted_implicit,
yaml_scalar_style_t style)
{
YAML_DECLARE(int)
yaml_sequence_start_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
yaml_sequence_style_t style)
{
yaml_mark_t mark = { 0, 0, 0 };
YAML_DECLARE(int)
yaml_mapping_start_event_initialize(yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
yaml_mapping_style_t style)
{
yaml_mark_t mark = { 0, 0, 0 };
YAML_DECLARE(int)
yaml_document_add_scalar(yaml_document_t *document,
- yaml_char_t *tag, yaml_char_t *value, int length,
+ const yaml_char_t *tag, const yaml_char_t *value, int length,
yaml_scalar_style_t style)
{
struct {
YAML_DECLARE(int)
yaml_document_add_sequence(yaml_document_t *document,
- yaml_char_t *tag, yaml_sequence_style_t style)
+ const yaml_char_t *tag, yaml_sequence_style_t style)
{
struct {
yaml_error_type_t error;
YAML_DECLARE(int)
yaml_document_add_mapping(yaml_document_t *document,
- yaml_char_t *tag, yaml_mapping_style_t style)
+ const yaml_char_t *tag, yaml_mapping_style_t style)
{
struct {
yaml_error_type_t error;
{
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
return 0;
+ emitter->open_ended = 0;
if (!yaml_emitter_write_indent(emitter))
return 0;
}
emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
+ emitter->open_ended = 0;
return 1;
}
else if (event->type == YAML_STREAM_END_EVENT)
{
+ /**
+ * This can happen if a block scalar with trailing empty lines
+ * is at the end of the stream
+ */
+ if (emitter->open_ended)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ emitter->open_ended = 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
if (!yaml_emitter_flush(emitter))
return 0;
if (!event->data.document_end.implicit) {
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
return 0;
+ emitter->open_ended = 0;
if (!yaml_emitter_write_indent(emitter))
return 0;
}
}
/*
- * Write an achor.
+ * Write an anchor.
*/
static int
yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
yaml_version_directive_t version_directive)
{
- if (version_directive.major != 1 || version_directive.minor != 1) {
+ if (version_directive.major != 1 || (
+ version_directive.minor != 1
+ && version_directive.minor != 2
+ )) {
return yaml_emitter_set_emitter_error(emitter,
"incompatible %YAML directive");
}
emitter->whitespace = is_whitespace;
emitter->indention = (emitter->indention && is_indention);
- emitter->open_ended = 0;
return 1;
}
emitter->whitespace = 0;
emitter->indention = 0;
- if (emitter->root_context)
- {
- emitter->open_ended = 1;
- }
return 1;
}
yaml_parser_delete_aliases(yaml_parser_t *parser);
/*
+ * Document loading context.
+ */
+struct loader_ctx {
+ int *start;
+ int *end;
+ int *top;
+};
+
+/*
* Composer functions.
*/
+static int
+yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx);
+
+static int
+yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event);
static int
-yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
static int
-yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
static int
-yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
static int
-yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
static int
-yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
static int
-yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event);
+yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx);
/*
* Load the next document of the stream.
*/
static int
-yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event)
{
- yaml_event_t event;
+ struct loader_ctx ctx = { NULL, NULL, NULL };
- assert(first_event->type == YAML_DOCUMENT_START_EVENT);
+ assert(event->type == YAML_DOCUMENT_START_EVENT);
/* DOCUMENT-START is expected. */
parser->document->version_directive
- = first_event->data.document_start.version_directive;
+ = event->data.document_start.version_directive;
parser->document->tag_directives.start
- = first_event->data.document_start.tag_directives.start;
+ = event->data.document_start.tag_directives.start;
parser->document->tag_directives.end
- = first_event->data.document_start.tag_directives.end;
+ = event->data.document_start.tag_directives.end;
parser->document->start_implicit
- = first_event->data.document_start.implicit;
- parser->document->start_mark = first_event->start_mark;
-
- if (!yaml_parser_parse(parser, &event)) return 0;
-
- if (!yaml_parser_load_node(parser, &event)) return 0;
-
- if (!yaml_parser_parse(parser, &event)) return 0;
- assert(event.type == YAML_DOCUMENT_END_EVENT);
- /* DOCUMENT-END is expected. */
+ = event->data.document_start.implicit;
+ parser->document->start_mark = event->start_mark;
- parser->document->end_implicit = event.data.document_end.implicit;
- parser->document->end_mark = event.end_mark;
+ if (!STACK_INIT(parser, ctx, int*)) return 0;
+ if (!yaml_parser_load_nodes(parser, &ctx)) {
+ STACK_DEL(parser, ctx);
+ return 0;
+ }
+ STACK_DEL(parser, ctx);
return 1;
}
/*
- * Compose a node.
+ * Compose a node tree.
*/
static int
-yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx)
{
- switch (first_event->type) {
- case YAML_ALIAS_EVENT:
- return yaml_parser_load_alias(parser, first_event);
- case YAML_SCALAR_EVENT:
- return yaml_parser_load_scalar(parser, first_event);
- case YAML_SEQUENCE_START_EVENT:
- return yaml_parser_load_sequence(parser, first_event);
- case YAML_MAPPING_START_EVENT:
- return yaml_parser_load_mapping(parser, first_event);
- default:
- assert(0); /* Could not happen. */
- return 0;
- }
+ yaml_event_t event;
- return 0;
+ do {
+ if (!yaml_parser_parse(parser, &event)) return 0;
+
+ switch (event.type) {
+ case YAML_ALIAS_EVENT:
+ if (!yaml_parser_load_alias(parser, &event, ctx)) return 0;
+ break;
+ case YAML_SCALAR_EVENT:
+ if (!yaml_parser_load_scalar(parser, &event, ctx)) return 0;
+ break;
+ case YAML_SEQUENCE_START_EVENT:
+ if (!yaml_parser_load_sequence(parser, &event, ctx)) return 0;
+ break;
+ case YAML_SEQUENCE_END_EVENT:
+ if (!yaml_parser_load_sequence_end(parser, &event, ctx))
+ return 0;
+ break;
+ case YAML_MAPPING_START_EVENT:
+ if (!yaml_parser_load_mapping(parser, &event, ctx)) return 0;
+ break;
+ case YAML_MAPPING_END_EVENT:
+ if (!yaml_parser_load_mapping_end(parser, &event, ctx))
+ return 0;
+ break;
+ default:
+ assert(0); /* Could not happen. */
+ return 0;
+ case YAML_DOCUMENT_END_EVENT:
+ break;
+ }
+ } while (event.type != YAML_DOCUMENT_END_EVENT);
+
+ parser->document->end_implicit = event.data.document_end.implicit;
+ parser->document->end_mark = event.end_mark;
+
+ return 1;
}
/*
}
/*
+ * Compose node into its parent in the stree.
+ */
+
+static int
+yaml_parser_load_node_add(yaml_parser_t *parser, struct loader_ctx *ctx,
+ int index)
+{
+ struct yaml_node_s *parent;
+ int parent_index;
+
+ if (STACK_EMPTY(parser, *ctx)) {
+ /* This is the root node, there's no tree to add it to. */
+ return 1;
+ }
+
+ parent_index = *((*ctx).top - 1);
+ parent = &parser->document->nodes.start[parent_index-1];
+
+ switch (parent->type) {
+ case YAML_SEQUENCE_NODE:
+ if (!STACK_LIMIT(parser, parent->data.sequence.items, INT_MAX-1))
+ return 0;
+ if (!PUSH(parser, parent->data.sequence.items, index))
+ return 0;
+ break;
+ case YAML_MAPPING_NODE: {
+ yaml_node_pair_t pair;
+ if (!STACK_EMPTY(parser, parent->data.mapping.pairs)) {
+ yaml_node_pair_t *p = parent->data.mapping.pairs.top - 1;
+ if (p->key != 0 && p->value == 0) {
+ p->value = index;
+ break;
+ }
+ }
+
+ pair.key = index;
+ pair.value = 0;
+ if (!STACK_LIMIT(parser, parent->data.mapping.pairs, INT_MAX-1))
+ return 0;
+ if (!PUSH(parser, parent->data.mapping.pairs, pair))
+ return 0;
+
+ break;
+ }
+ default:
+ assert(0); /* Could not happen. */
+ return 0;
+ }
+ return 1;
+}
+
+/*
* Compose a node corresponding to an alias.
*/
static int
-yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
{
- yaml_char_t *anchor = first_event->data.alias.anchor;
+ yaml_char_t *anchor = event->data.alias.anchor;
yaml_alias_data_t *alias_data;
for (alias_data = parser->aliases.start;
alias_data != parser->aliases.top; alias_data ++) {
if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
yaml_free(anchor);
- return alias_data->index;
+ return yaml_parser_load_node_add(parser, ctx, alias_data->index);
}
}
yaml_free(anchor);
return yaml_parser_set_composer_error(parser, "found undefined alias",
- first_event->start_mark);
+ event->start_mark);
}
/*
*/
static int
-yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
{
yaml_node_t node;
int index;
- yaml_char_t *tag = first_event->data.scalar.tag;
+ yaml_char_t *tag = event->data.scalar.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!tag) goto error;
}
- SCALAR_NODE_INIT(node, tag, first_event->data.scalar.value,
- first_event->data.scalar.length, first_event->data.scalar.style,
- first_event->start_mark, first_event->end_mark);
+ SCALAR_NODE_INIT(node, tag, event->data.scalar.value,
+ event->data.scalar.length, event->data.scalar.style,
+ event->start_mark, event->end_mark);
if (!PUSH(parser, parser->document->nodes, node)) goto error;
index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
- first_event->data.scalar.anchor)) return 0;
+ event->data.scalar.anchor)) return 0;
- return index;
+ return yaml_parser_load_node_add(parser, ctx, index);
error:
yaml_free(tag);
- yaml_free(first_event->data.scalar.anchor);
- yaml_free(first_event->data.scalar.value);
+ yaml_free(event->data.scalar.anchor);
+ yaml_free(event->data.scalar.value);
return 0;
}
*/
static int
-yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
{
- yaml_event_t event;
yaml_node_t node;
struct {
yaml_node_item_t *start;
yaml_node_item_t *end;
yaml_node_item_t *top;
} items = { NULL, NULL, NULL };
- int index, item_index;
- yaml_char_t *tag = first_event->data.sequence_start.tag;
+ int index;
+ yaml_char_t *tag = event->data.sequence_start.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error;
SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
- first_event->data.sequence_start.style,
- first_event->start_mark, first_event->end_mark);
+ event->data.sequence_start.style,
+ event->start_mark, event->end_mark);
if (!PUSH(parser, parser->document->nodes, node)) goto error;
index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
- first_event->data.sequence_start.anchor)) return 0;
-
- if (!yaml_parser_parse(parser, &event)) return 0;
-
- while (event.type != YAML_SEQUENCE_END_EVENT) {
- if (!STACK_LIMIT(parser,
- parser->document->nodes.start[index-1].data.sequence.items,
- INT_MAX-1)) return 0;
- item_index = yaml_parser_load_node(parser, &event);
- if (!item_index) return 0;
- if (!PUSH(parser,
- parser->document->nodes.start[index-1].data.sequence.items,
- item_index)) return 0;
- if (!yaml_parser_parse(parser, &event)) return 0;
- }
+ event->data.sequence_start.anchor)) return 0;
+
+ if (!yaml_parser_load_node_add(parser, ctx, index)) return 0;
- parser->document->nodes.start[index-1].end_mark = event.end_mark;
+ if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0;
+ if (!PUSH(parser, *ctx, index)) return 0;
- return index;
+ return 1;
error:
yaml_free(tag);
- yaml_free(first_event->data.sequence_start.anchor);
+ yaml_free(event->data.sequence_start.anchor);
return 0;
}
+static int
+yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
+{
+ int index;
+
+ assert(((*ctx).top - (*ctx).start) > 0);
+
+ index = *((*ctx).top - 1);
+ assert(parser->document->nodes.start[index-1].type == YAML_SEQUENCE_NODE);
+ parser->document->nodes.start[index-1].end_mark = event->end_mark;
+
+ (void)POP(parser, *ctx);
+
+ return 1;
+}
+
/*
* Compose a mapping node.
*/
static int
-yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
+yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
{
- yaml_event_t event;
yaml_node_t node;
struct {
yaml_node_pair_t *start;
yaml_node_pair_t *top;
} pairs = { NULL, NULL, NULL };
int index;
- yaml_node_pair_t pair;
- yaml_char_t *tag = first_event->data.mapping_start.tag;
+ yaml_char_t *tag = event->data.mapping_start.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error;
MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
- first_event->data.mapping_start.style,
- first_event->start_mark, first_event->end_mark);
+ event->data.mapping_start.style,
+ event->start_mark, event->end_mark);
if (!PUSH(parser, parser->document->nodes, node)) goto error;
index = parser->document->nodes.top - parser->document->nodes.start;
if (!yaml_parser_register_anchor(parser, index,
- first_event->data.mapping_start.anchor)) return 0;
+ event->data.mapping_start.anchor)) return 0;
- if (!yaml_parser_parse(parser, &event)) return 0;
-
- while (event.type != YAML_MAPPING_END_EVENT) {
- if (!STACK_LIMIT(parser,
- parser->document->nodes.start[index-1].data.mapping.pairs,
- INT_MAX-1)) return 0;
- pair.key = yaml_parser_load_node(parser, &event);
- if (!pair.key) return 0;
- if (!yaml_parser_parse(parser, &event)) return 0;
- pair.value = yaml_parser_load_node(parser, &event);
- if (!pair.value) return 0;
- if (!PUSH(parser,
- parser->document->nodes.start[index-1].data.mapping.pairs,
- pair)) return 0;
- if (!yaml_parser_parse(parser, &event)) return 0;
- }
+ if (!yaml_parser_load_node_add(parser, ctx, index)) return 0;
- parser->document->nodes.start[index-1].end_mark = event.end_mark;
+ if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0;
+ if (!PUSH(parser, *ctx, index)) return 0;
- return index;
+ return 1;
error:
yaml_free(tag);
- yaml_free(first_event->data.mapping_start.anchor);
+ yaml_free(event->data.mapping_start.anchor);
return 0;
}
+static int
+yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event,
+ struct loader_ctx *ctx)
+{
+ int index;
+
+ assert(((*ctx).top - (*ctx).start) > 0);
+
+ index = *((*ctx).top - 1);
+ assert(parser->document->nodes.start[index-1].type == YAML_MAPPING_NODE);
+ parser->document->nodes.start[index-1].end_mark = event->end_mark;
+
+ (void)POP(parser, *ctx);
+
+ return 1;
+}
\ No newline at end of file
goto error;
}
if (token->data.version_directive.major != 1
- || token->data.version_directive.minor != 1) {
+ || (
+ token->data.version_directive.minor != 1
+ && token->data.version_directive.minor != 2
+ )) {
yaml_parser_set_parser_error(parser,
"found incompatible YAML document", token->start_mark);
goto error;
* SCALAR("another value",plain)
* KEY
* SCALAR("a mapping",plain)
+ * VALUE
* BLOCK-MAPPING-START
* KEY
* SCALAR("key 1",plain)
{
if (IS_BLANK(parser->buffer))
{
- /* Check for tab character that abuse indentation. */
+ /* Check for tab characters that abuse indentation. */
if (leading_blanks && (int)parser->mark.column < indent
&& IS_TAB(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found a tab character that violate indentation");
+ start_mark, "found a tab character that violates indentation");
goto error;
}
/* Display the style information. */
- if (input_event.data.sequence_start.style)
+ if (input_event.data.mapping_start.style)
{
- yaml_sequence_style_t style
- = (yaml_sequence_style_t) input_event.data.mapping_start.style;
+ yaml_mapping_style_t style
+ = input_event.data.mapping_start.style;
/* Add 'style': <style>. */