Imported Upstream version 0.2.3 upstream/0.2.3
authorJinWang An <jinwang.an@samsung.com>
Mon, 9 Jan 2023 03:25:25 +0000 (12:25 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 9 Jan 2023 03:25:25 +0000 (12:25 +0900)
16 files changed:
.appveyor.yml [moved from appveyor.yml with 97% similarity]
CMakeLists.txt
Changes [new file with mode: 0644]
License [moved from LICENSE with 96% similarity]
Makefile.am
README [deleted file]
ReadMe.md [new file with mode: 0644]
announcement.msg
configure.ac
include/yaml.h
src/api.c
src/emitter.c
src/loader.c
src/parser.c
src/scanner.c
tests/example-deconstructor-alt.c

similarity index 97%
rename from appveyor.yml
rename to .appveyor.yml
index 8749615..a9092a6 100644 (file)
@@ -1,4 +1,4 @@
-version: 0.2.2.{build}
+version: 0.2.3.{build}
 
 image:
 - Visual Studio 2015
index 9504c3b..72a7f12 100644 (file)
@@ -4,11 +4,11 @@ project (yaml C)
 
 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
diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..a2b40d1
--- /dev/null
+++ b/Changes
@@ -0,0 +1,337 @@
+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
diff --git a/LICENSE b/License
similarity index 96%
rename from LICENSE
rename to License
index e8f8805..3d82c28 100644 (file)
--- a/LICENSE
+++ b/License
@@ -1,4 +1,4 @@
-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
index c0cf7ce..b21549a 100644 (file)
@@ -3,7 +3,7 @@
 
 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
@@ -25,7 +25,7 @@ bootstrap: maintainer-clean
 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
diff --git a/README b/README
deleted file mode 100644 (file)
index 0ac53e5..0000000
--- a/README
+++ /dev/null
@@ -1,32 +0,0 @@
-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.
diff --git a/ReadMe.md b/ReadMe.md
new file mode 100644 (file)
index 0000000..2dfcc44
--- /dev/null
+++ b/ReadMe.md
@@ -0,0 +1,46 @@
+## 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.
index 0885f27..ede0e02 100644 (file)
@@ -1,13 +1,13 @@
-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.
@@ -16,19 +16,21 @@ 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
@@ -36,7 +38,7 @@ 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
 
@@ -69,7 +71,7 @@ See: https://github.com/yaml/libyaml/pulls
 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.
index 7e49151..f64ba13 100644 (file)
@@ -3,7 +3,7 @@
 # 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.
@@ -19,7 +19,7 @@ m4_define([YAML_BUGS], [https://github.com/yaml/libyaml/issues/new])
 #           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.
index c225908..06e5560 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 
 #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)
@@ -552,7 +552,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
  */
 
 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.
@@ -578,8 +578,8 @@ yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
 
 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);
 
@@ -601,7 +601,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
 
 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);
 
 /**
@@ -633,7 +633,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event);
 
 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);
 
 /**
@@ -896,7 +896,7 @@ yaml_document_get_root_node(yaml_document_t *document);
 
 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);
 
 /**
@@ -913,7 +913,7 @@ yaml_document_add_scalar(yaml_document_t *document,
 
 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.
@@ -929,7 +929,7 @@ yaml_document_add_sequence(yaml_document_t *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.
@@ -937,7 +937,7 @@ yaml_document_add_mapping(yaml_document_t *document,
  * @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.
  */
 
@@ -952,7 +952,7 @@ yaml_document_append_sequence_item(yaml_document_t *document,
  * @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.
  */
 
@@ -1205,7 +1205,7 @@ typedef struct yaml_parser_s {
     /** 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. */
@@ -1446,7 +1446,7 @@ yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
  * @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)
@@ -1560,7 +1560,7 @@ typedef struct yaml_emitter_s {
     /** 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. */
@@ -1858,7 +1858,7 @@ YAML_DECLARE(void)
 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).
index e793b08..16f88bd 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -623,10 +623,10 @@ yaml_token_delete(yaml_token_t *token)
  */
 
 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;
@@ -794,7 +794,7 @@ yaml_document_end_event_initialize(yaml_event_t *event, int implicit)
  */
 
 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;
@@ -819,8 +819,8 @@ yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor)
 
 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)
 {
@@ -873,7 +873,7 @@ error:
 
 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 };
@@ -928,7 +928,7 @@ yaml_sequence_end_event_initialize(yaml_event_t *event)
 
 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 };
@@ -1193,7 +1193,7 @@ yaml_document_get_root_node(yaml_document_t *document)
 
 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 {
@@ -1243,7 +1243,7 @@ error:
 
 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;
@@ -1288,7 +1288,7 @@ 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;
index b9392e4..a22c6b1 100644 (file)
@@ -594,6 +594,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
         {
             if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
                 return 0;
+            emitter->open_ended = 0;
             if (!yaml_emitter_write_indent(emitter))
                 return 0;
         }
@@ -644,12 +645,25 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
 
         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;
 
@@ -691,6 +705,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
         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;
         }
@@ -1227,7 +1242,7 @@ yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
 }
 
 /*
- * Write an achor.
+ * Write an anchor.
  */
 
 static int
@@ -1326,7 +1341,10 @@ 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");
     }
@@ -1796,7 +1814,6 @@ yaml_emitter_write_indicator(yaml_emitter_t *emitter,
 
     emitter->whitespace = is_whitespace;
     emitter->indention = (emitter->indention && is_indention);
-    emitter->open_ended = 0;
 
     return 1;
 }
@@ -1939,10 +1956,6 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
 
     emitter->whitespace = 0;
     emitter->indention = 0;
-    if (emitter->root_context)
-    {
-        emitter->open_ended = 1;
-    }
 
     return 1;
 }
index db8501a..dea8ac4 100644 (file)
@@ -38,26 +38,46 @@ static void
 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.
@@ -162,59 +182,78 @@ yaml_parser_delete_aliases(yaml_parser_t *parser)
  */
 
 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;
 }
 
 /*
@@ -253,26 +292,79 @@ yaml_parser_register_anchor(yaml_parser_t *parser,
 }
 
 /*
+ * 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);
 }
 
 /*
@@ -280,11 +372,12 @@ yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event)
  */
 
 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;
 
@@ -294,23 +387,23 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
         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;
 }
 
@@ -319,17 +412,17 @@ error:
  */
 
 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;
 
@@ -342,48 +435,54 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
     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;
@@ -391,8 +490,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
         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;
 
@@ -405,40 +503,42 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
     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
index 1198c73..ec2f8d3 100644 (file)
@@ -1261,7 +1261,10 @@ yaml_parser_process_directives(yaml_parser_t *parser,
                 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;
index ceee749..765f286 100644 (file)
  *          SCALAR("another value",plain)
  *          KEY
  *          SCALAR("a mapping",plain)
+ *          VALUE
  *          BLOCK-MAPPING-START
  *          KEY
  *          SCALAR("key 1",plain)
@@ -3518,12 +3519,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
         {
             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;
                 }
 
index f7b06d6..b29c077 100644 (file)
@@ -635,10 +635,10 @@ main(int argc, char *argv[])
 
                 /* 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>. */