git subrepo clone --branch=0.2.5 https://github.com/yaml/libyaml.git deps/libyaml

subrepo:
  subdir:   "deps/libyaml"
  merged:   "2c891fc"
upstream:
  origin:   "https://github.com/yaml/libyaml.git"
  branch:   "0.2.5"
  commit:   "2c891fc"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"
This commit is contained in:
torque 2024-03-05 22:38:36 -08:00
parent ca1fdb053d
commit 11e8fad44e
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
63 changed files with 18605 additions and 0 deletions

29
deps/libyaml/.appveyor.yml vendored Normal file
View File

@ -0,0 +1,29 @@
version: 0.2.5.{build}
image:
- Visual Studio 2015
- Visual Studio 2013
build_script:
#
# CMake based in-source build and tests using Visual Studio
#
# Use 32-bit default generator ("Visual Studio 12 2013" or "Visual Studio 14 2015")
- cmake .
- cmake --build . --config Release --clean-first
- ctest -C Release
#
# Autoconf based in-source build and tests under Cygwin using gcc
#
# 32-bit cygwin build
- C:\cygwin\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure && make && make test && make distclean"
# 64-bit cygwin build
- C:\cygwin64\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure && make && make test && make distclean"
# 32-bit mingw-w64 build
- C:\cygwin\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 && make && make test && make distclean"
# 64-bit mingw-w64 build
- C:\cygwin64\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 && make && make test && make distclean"

59
deps/libyaml/.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: linux/mac
on:
push:
branches: [ '*' ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
compiler:
- gcc
- clang
os:
- ubuntu-latest
- macOS-latest
steps:
- uses: actions/checkout@v2
- run: env | sort
- name: Install software
run: |
if [[ '${{ matrix.os }}' == macOS-latest ]]; then
brew install automake bash coreutils make
echo ::add-path::/usr/local/opt/coreutils/libexec/gnubin
echo ::add-path::/usr/local/opt/make/libexec/gnubin
fi
- name: Fetch branches
run: |
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch --unshallow
- run: ./bootstrap
- run: ./configure
- run: make
- run: make test-all
- run: |
git clean -d -x -f
rm -fr tests/run-test-suite
git worktree prune
- name: Compiler version
run: ${{ matrix.compiler }} --version
env:
CC: ${{ matrix.compiler }}
- run: cmake .
env:
CC: ${{ matrix.compiler }}
- run: make
env:
CC: ${{ matrix.compiler }}
- run: make test

46
deps/libyaml/.gitignore vendored Normal file
View File

@ -0,0 +1,46 @@
*.BAK
*.a
*.cmake
*.dll
*.exe
*.la
*.lo
*.log
*.o
*.pc
*.so
*.trs
*~
.deps/
.libs/
/Testing/
/libtool
CMakeCache.txt
CMakeFiles/
GNUmakefile
Makefile
Makefile.in
/aclocal.m4
/autom4te.cache
/config
config.h*
/config.status
/configure
stamp-h1
!config/config.h.in
/packaging/
/tests/run-dumper
/tests/run-emitter
/tests/run-emitter-test-suite
/tests/run-loader
/tests/run-parser
/tests/run-parser-test-suite
/tests/run-scanner
/tests/example-deconstructor
/tests/example-deconstructor-alt
/tests/example-reformatter
/tests/example-reformatter-alt
/tests/run-test-suite
/tests/test-reader
/tests/test-version
/dist/

12
deps/libyaml/.gitrepo vendored Normal file
View File

@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = https://github.com/yaml/libyaml.git
branch = 0.2.5
commit = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6
parent = 6ebd51756d4760aabd093ae07e093f18641b23ba
method = merge
cmdver = 0.4.6

1
deps/libyaml/.indent.pro vendored Normal file
View File

@ -0,0 +1 @@
-kr -nut -nce -l250

63
deps/libyaml/.makefile vendored Normal file
View File

@ -0,0 +1,63 @@
# This file is used for common development targets that can be done with
# needing the cumbersome bootstrapping process.
#
# You can use it like this:
#
# make -f .makefile indent
#
# If you copy or link this file to `GNUmakefile` then you can just do:
#
# make indent
#
# When copied to `GNUmakefile`, this file is can also be used for bootstrapping
# Makefile targets. Since GNUmakefile is loaded before Makefile, we do the
# bootstrapping tasks need to get a Makefile first, then we use the Makefile to
# make our target.
# Remind user when they are using GNUmakefile:
ifeq ($(lastword $(MAKEFILE_LIST)),GNUmakefile)
$(info *** NOTE: GNUmakefile in use. ***)
endif
MAKE_TARGETS := \
all \
all-am \
all-recursive \
install \
test \
test-all \
test-suite \
# SOURCE_FILES := $(shell find . | grep '\.c$$')
SOURCE_FILES := $(shell find tests/run-test-suite | grep '\.c$$')
ifneq ($(shell which gindent),)
INDENT := gindent
else
INDENT := indent
endif
#
# Proxy make targets:
#
default: all
# Proxy these targets to the real Makefile, after bootstrapping is necessary.
$(MAKE_TARGETS): Makefile
@make -f $< $@
Makefile: Makefile.in
./configure
Makefile.in:
./bootstrap
#
# Development make targets:
#
indent:
$(INDENT) $(SOURCE_FILES)
distclean purge:
git clean -dxf -e GNUmakefile
rm -fr tests/run-test-suite
git worktree prune

28
deps/libyaml/.travis.yml vendored Normal file
View File

@ -0,0 +1,28 @@
language: c
matrix:
include:
- os: linux
compiler: gcc
sudo: required
- os: linux
compiler: clang
sudo: required
- os: osx
compiler: gcc
- os: osx
compiler: clang
before_install:
# Travis branch-specific clone problem workaround:
- git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
- git fetch
- env | sort
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
pip install --user scikit-ci-addons==0.15.0;
ci_addons travis/install_cmake 3.2.0;
fi
script: tests/run-all-tests.sh

160
deps/libyaml/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,160 @@
cmake_minimum_required(VERSION 3.0)
project (yaml C)
set (YAML_VERSION_MAJOR 0)
set (YAML_VERSION_MINOR 2)
set (YAML_VERSION_PATCH 5)
set (YAML_VERSION_STRING "${YAML_VERSION_MAJOR}.${YAML_VERSION_MINOR}.${YAML_VERSION_PATCH}")
option(BUILD_SHARED_LIBS "Build libyaml as a shared library" OFF)
set(YAML_STATIC_LIB_NAME "yaml" CACHE STRING "Base name of static library output")
#
# Output directories for a build tree
#
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
#
# Install relative directories
#
if(NOT DEFINED INSTALL_LIB_DIR)
set(INSTALL_LIB_DIR lib)
endif()
if(NOT DEFINED INSTALL_BIN_DIR)
set(INSTALL_BIN_DIR bin)
endif()
if(NOT DEFINED INSTALL_INCLUDE_DIR)
set(INSTALL_INCLUDE_DIR include)
endif()
if(NOT DEFINED INSTALL_CMAKE_DIR)
set(INSTALL_CMAKE_DIR cmake)
endif()
#
# Build library
#
set(SRCS
src/api.c
src/dumper.c
src/emitter.c
src/loader.c
src/parser.c
src/reader.c
src/scanner.c
src/writer.c
)
set(config_h ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
configure_file(
cmake/config.h.in
${config_h}
)
add_library(yaml ${SRCS})
if(NOT BUILD_SHARED_LIBS)
set_target_properties(yaml
PROPERTIES OUTPUT_NAME ${YAML_STATIC_LIB_NAME}
)
endif()
set_target_properties(yaml
PROPERTIES DEFINE_SYMBOL YAML_DECLARE_EXPORT
)
target_compile_definitions(yaml
PRIVATE HAVE_CONFIG_H
PUBLIC
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:YAML_DECLARE_STATIC>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
)
target_include_directories(yaml PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>
)
#
# Install rules
#
install(
FILES
include/yaml.h
DESTINATION include COMPONENT Development
)
install(
TARGETS yaml
EXPORT yamlTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development
)
#
# Add tests
#
include(CTest) # This module defines BUILD_TESTING option
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
#
# Generate 'yamlConfig.cmake', 'yamlConfigVersion.cmake' and 'yamlTargets.cmake'
#
include(CMakePackageConfigHelpers)
# Configure 'yamlConfig.cmake' for a build tree
set(CONFIG_DIR_CONFIG ${PROJECT_BINARY_DIR})
set(config_file ${PROJECT_BINARY_DIR}/yamlConfig.cmake)
configure_package_config_file(
yamlConfig.cmake.in
${config_file}
INSTALL_DESTINATION ${PROJECT_BINARY_DIR}
PATH_VARS CONFIG_DIR_CONFIG
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Configure 'yamlTargets.cmake' for a build tree
export(TARGETS yaml
FILE ${PROJECT_BINARY_DIR}/yamlTargets.cmake
)
# Configure and install 'yamlConfig.cmake' for an install tree
set(CONFIG_DIR_CONFIG ${INSTALL_CMAKE_DIR})
set(install_config_file ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yamlConfig.cmake )
configure_package_config_file(
yamlConfig.cmake.in
${install_config_file}
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}
PATH_VARS CONFIG_DIR_CONFIG
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES ${install_config_file}
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development
)
# Configure and install 'yamlTargets.cmake' for an install tree
install(EXPORT yamlTargets
FILE yamlTargets.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT Development
)
# Configure 'yamlConfigVersion.cmake' for a build tree
set(config_version_file ${PROJECT_BINARY_DIR}/yamlConfigVersion.cmake)
write_basic_package_version_file(
${config_version_file}
VERSION ${YAML_VERSION_STRING}
COMPATIBILITY AnyNewerVersion
)
# ... and install for an install tree
install(
FILES ${config_version_file}
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development
)

372
deps/libyaml/Changes vendored Normal file
View File

@ -0,0 +1,372 @@
0.2.5 2020-06-01
https://github.com/yaml/libyaml/pull/105
Allow question marks in plain scalars in flow collections
https://github.com/yaml/libyaml/pull/186
Emitter: Don't output trailing space for empty scalar nodes
https://github.com/yaml/libyaml/pull/185
Emitter: Output space after an alias mapping key
https://github.com/yaml/libyaml/pull/187
Add -h and --flow (on|off|keep) to run-*-test-suite
https://github.com/yaml/libyaml/pull/182
Remove unnecessary include and malloc
https://github.com/yaml/libyaml/pull/177
Add specific files back to .gitignore
https://github.com/yaml/libyaml/pull/181
Output error position in run-parser-test-suite.c
https://github.com/yaml/libyaml/pull/191
A couple patches to improve test suite support
0.2.4 2020-04-19
- https://github.com/yaml/libyaml/pull/143
Add packaging/docker-dist to Makefile.am
- https://github.com/yaml/libyaml/pull/174
Fix logic for document end before directive
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

20
deps/libyaml/License vendored Normal file
View File

@ -0,0 +1,20 @@
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
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

54
deps/libyaml/Makefile.am vendored Normal file
View File

@ -0,0 +1,54 @@
## Run `./bootstrap` to generate the "Makefile.in" files in this directory and
## the "$SUBDIRS" subdirectories.
SUBDIRS = include src . tests
EXTRA_DIST = Changes ReadMe.md License CMakeLists.txt doc/doxygen.cfg
LIBYAML_TEST_SUITE_RUN_REPO_DEFAULT := https://github.com/yaml/libyaml
LIBYAML_TEST_SUITE_RUN_REPO ?= $(LIBYAML_TEST_SUITE_RUN_REPO_DEFAULT)
LIBYAML_TEST_SUITE_RUN_BRANCH ?= run-test-suite
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = yaml-0.1.pc
maintainer-clean-local:
rm -f aclocal.m4 config.h.in configure config/*
-find ${builddir} -name Makefile.in -exec rm -f '{}' ';'
distclean-local:
rm -fr tests/run-test-suite packaging
-git worktree prune
.PHONY: bootstrap
bootstrap: maintainer-clean
./bootstrap
./configure
make
test: all
make -C tests check-TESTS
test-suite: tests/run-test-suite all
make -C $< test
test-all: test test-suite
tests/run-test-suite:
ifeq ($(LIBYAML_TEST_SUITE_RUN_REPO),$(LIBYAML_TEST_SUITE_RUN_REPO_DEFAULT))
-git branch --track $(LIBYAML_TEST_SUITE_RUN_BRANCH) origin/$(LIBYAML_TEST_SUITE_RUN_BRANCH)
-git worktree prune
git worktree add $@ $(LIBYAML_TEST_SUITE_RUN_BRANCH)
else
git clone --branch $(LIBYAML_TEST_SUITE_RUN_BRANCH) $(LIBYAML_TEST_SUITE_RUN_REPO) $@
endif
packaging:
-git branch --track $@ origin/$@
git worktree add --force $@ $@
docker-dist: packaging
make -C $</docker libyaml-dist
docker-test-pyyaml: packaging
make -C $</docker test-pyyaml

46
deps/libyaml/ReadMe.md vendored Normal file
View File

@ -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.

89
deps/libyaml/announcement.msg vendored Normal file
View File

@ -0,0 +1,89 @@
From: Tina Müller <post@tinita.de>
To: yaml-core@lists.sourceforge.net
Subject: [ANN] LibYAML-0.2.5: A new release
=========================
Announcing LibYAML-0.2.5
=========================
A new release of LibYAML is now available:
https://github.com/yaml/libyaml/tree/0.2.5
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/187
Add -h and --flow (on|off|keep) to run-*-test-suite
https://github.com/yaml/libyaml/pull/182
Remove unnecessary include and malloc
https://github.com/yaml/libyaml/pull/177
Add specific files back to .gitignore
https://github.com/yaml/libyaml/pull/181
Output error position in run-parser-test-suite.c
https://github.com/yaml/libyaml/pull/105
Allow question marks in plain scalars in flow collections
https://github.com/yaml/libyaml/pull/186
Emitter: Don't output trailing space for empty scalar nodes
https://github.com/yaml/libyaml/pull/185
Emitter: Output space after an alias mapping key
https://github.com/yaml/libyaml/pull/191
A couple patches to improve test suite support
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.3.zip
GitHub repository: https://github.com/yaml/libyaml
Bug tracking: https://github.com/yaml/libyaml/issues
YAML homepage: http://yaml.org/
YAML-core mailing list: http://lists.sourceforge.net/lists/listinfo/yaml-core
About LibYAML
=============
YAML is a data serialization format designed for human readability and
interaction with scripting languages.
LibYAML is a C library for parsing and emitting YAML. LibYAML is the underlying
parser/emitter code for YAML frameworks in many programming languages.
Maintainers
===========
The following people are responsible for maintaining LibYAML:
* Ingy döt Net
and many thanks to all who have contribributed!
See: https://github.com/yaml/libyaml/pulls
Copyright
=========
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.
It is currently maintained by the YAML community.
LibYAML is released under the MIT license.
See the file LICENSE for more details.

3
deps/libyaml/bootstrap vendored Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec autoreconf -fvi

4
deps/libyaml/cmake/config.h.in vendored Normal file
View File

@ -0,0 +1,4 @@
#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@
#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@
#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@
#define YAML_VERSION_STRING "@YAML_VERSION_STRING@"

73
deps/libyaml/configure.ac vendored Normal file
View File

@ -0,0 +1,73 @@
# Run `./bootstrap` to generate the "configure" script.
# Define the package version numbers and the bug reporting link.
m4_define([YAML_MAJOR], 0)
m4_define([YAML_MINOR], 2)
m4_define([YAML_PATCH], 5)
m4_define([YAML_BUGS], [https://github.com/yaml/libyaml/issues/new])
# Define the libtool version numbers; check the Autobook, Section 11.4.
# Bump the libtool version numbers using the following algorithm:
# if (the current interface has not been changed):
# YAML_REVISION += 1
# else:
# YAML_REVISION = 0
# YAML_CURRENT += 1
# if (this release is backward compatible with the previous release):
# YAML_AGE += 1
# else:
# YAML_AGE = 0
m4_define([YAML_RELEASE], 0)
m4_define([YAML_CURRENT], 2)
m4_define([YAML_REVISION], 9)
m4_define([YAML_AGE], 0)
# Initialize autoconf & automake.
AC_PREREQ(2.59)
AC_INIT([yaml], [YAML_MAJOR.YAML_MINOR.YAML_PATCH], [YAML_BUGS])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_HEADERS([include/config.h])
AM_INIT_AUTOMAKE([1.9 foreign])
# Define macro variables for the package version numbers.
AC_DEFINE(YAML_VERSION_MAJOR, YAML_MAJOR, [Define the major version number.])
AC_DEFINE(YAML_VERSION_MINOR, YAML_MINOR, [Define the minor version number.])
AC_DEFINE(YAML_VERSION_PATCH, YAML_PATCH, [Define the patch version number.])
AC_DEFINE(YAML_VERSION_STRING, "YAML_MAJOR.YAML_MINOR.YAML_PATCH", [Define the version string.])
# Define substitutions for the libtool version numbers.
YAML_LT_RELEASE=YAML_RELEASE
YAML_LT_CURRENT=YAML_CURRENT
YAML_LT_REVISION=YAML_REVISION
YAML_LT_AGE=YAML_AGE
AC_SUBST(YAML_LT_RELEASE)
AC_SUBST(YAML_LT_CURRENT)
AC_SUBST(YAML_LT_REVISION)
AC_SUBST(YAML_LT_AGE)
# Note: in order to update checks, run `autoscan` and look through "configure.scan".
# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_CHECK_PROG(DOXYGEN, [doxygen], [true], [false])
AM_CONDITIONAL(DOXYGEN, [test "$DOXYGEN" = true])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
# Define Makefiles.
AC_CONFIG_FILES([yaml-0.1.pc include/Makefile src/Makefile Makefile tests/Makefile])
# Generate the "configure" script.
AC_OUTPUT

222
deps/libyaml/doc/doxygen.cfg vendored Normal file
View File

@ -0,0 +1,222 @@
# Doxyfile 1.4.4
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = $(PACKAGE)
PROJECT_NUMBER = $(VERSION)
OUTPUT_DIRECTORY = $(top_builddir)/doc/
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = $(top_srcdir)/include/
FILE_PATTERNS = *.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 1
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = "YAML_DECLARE(type)=type"
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

17
deps/libyaml/docker/README.mkd vendored Normal file
View File

@ -0,0 +1,17 @@
# LibYAML Dockerfiles
This directory is a collection of dockerfiles that can be used when developing
and testing LibYAML.
The current list is supports:
- Ubuntu 16.04
- Ubuntu 14.04
## Example Usage
```bash
$ docker pull ubuntu
$ docker build -t libyaml-ubuntu:16.04 -f dockerfiles/ubuntu-16.04 .
$ docker run -it libyaml-ubuntu:16.04 make test
```

26
deps/libyaml/docker/alpine-3.7 vendored Normal file
View File

@ -0,0 +1,26 @@
# vim: ft=dockerfile
FROM alpine:3.7
MAINTAINER Ingy döt Net <ingy@ingy.net>
RUN apk update && \
apk add --no-cache \
autoconf \
automake \
build-base \
cmake \
git \
libtool \
perl-dev && \
mkdir /libyaml
COPY . /libyaml/
WORKDIR /libyaml
ENV LD_LIBRARY_PATH=/libyaml/src/.libs
RUN ./bootstrap && \
./configure && \
make && \
make install
CMD ["bash"]

26
deps/libyaml/docker/fedora-25 vendored Normal file
View File

@ -0,0 +1,26 @@
# vim: ft=dockerfile
FROM fedora:25
MAINTAINER Ian Cordasco <graffatcolmingov@gmail.com>
# NOTE(sigmavirus24): We need "perl-core" here for the "prove" binary
# required by the test-all Makefile target
RUN dnf install -y \
automake \
gcc \
git \
make \
libtool \
perl-core && \
mkdir /libyaml
COPY . /libyaml/
WORKDIR /libyaml
ENV LD_LIBRARY_PATH=/libyaml/src/.libs
RUN ./bootstrap && \
./configure && \
make && \
make install
CMD ["bash"]

29
deps/libyaml/docker/ubuntu-14.04 vendored Normal file
View File

@ -0,0 +1,29 @@
# vim: ft=dockerfile
FROM ubuntu:14.04
MAINTAINER Ian Cordasco <graffatcolmingov@gmail.com>
RUN apt-get update && \
apt-get install -y \
software-properties-common \
python-software-properties && \
add-apt-repository ppa:git-core/ppa && \
apt-get update && \
apt-get install -y \
autoconf \
build-essential \
git \
libtool && \
rm -rf /var/lib/apt/lists/* && \
mkdir /libyaml
COPY . /libyaml/
WORKDIR /libyaml
ENV LD_LIBRARY_PATH=/libyaml/src/.libs
RUN ./bootstrap && \
./configure && \
make && \
make install
CMD ["bash"]

24
deps/libyaml/docker/ubuntu-16.04 vendored Normal file
View File

@ -0,0 +1,24 @@
# vim: ft=dockerfile
FROM ubuntu:16.04
MAINTAINER Ian Cordasco <graffatcolmingov@gmail.com>
RUN apt-get update && \
apt-get install -y \
autoconf \
build-essential \
git \
libtool && \
rm -rf /var/lib/apt/lists/* && \
mkdir /libyaml
COPY . /libyaml/
WORKDIR /libyaml
ENV LD_LIBRARY_PATH=/libyaml/src/.libs
RUN ./bootstrap && \
./configure && \
make && \
make install
CMD ["bash"]

10
deps/libyaml/examples/anchors.yaml vendored Normal file
View File

@ -0,0 +1,10 @@
base: &base
name: Everyone has same name
foo: &foo
<<: *base
age: 10
bar: &bar
<<: *base
age: 20

2
deps/libyaml/examples/array.yaml vendored Normal file
View File

@ -0,0 +1,2 @@
- member
- member2

14
deps/libyaml/examples/global-tag.yaml vendored Normal file
View File

@ -0,0 +1,14 @@
%TAG ! tag:clarkevans.com,2002:
--- !shape
# Use the ! handle for presenting
# tag:clarkevans.com,2002:circle
- !circle
center: &ORIGIN {x: 73, y: 129}
radius: 7
- !line
start: *ORIGIN
finish: { x: 89, y: 102 }
- !label
start: *ORIGIN
color: 0xFFEEBB
text: Pretty vector drawing.

1
deps/libyaml/examples/json.yaml vendored Normal file
View File

@ -0,0 +1 @@
{"key": ["value", 3]}

2
deps/libyaml/examples/mapping.yaml vendored Normal file
View File

@ -0,0 +1,2 @@
key: value
other-key: other-value

1
deps/libyaml/examples/numbers.yaml vendored Normal file
View File

@ -0,0 +1 @@
[100, 12.5, -130, 1.3e+9]

7
deps/libyaml/examples/strings.yaml vendored Normal file
View File

@ -0,0 +1,7 @@
unqouted: string
literal-block: |
This entire block of text will be the value of the 'literal-block' key,
with line breaks being preserved.
folded: >
This entire block of text will be the value of 'folded', but this
time, all newlines will be replaced with a single space.

7
deps/libyaml/examples/tags.yaml vendored Normal file
View File

@ -0,0 +1,7 @@
gif_file: !!binary |
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
explicit_string: !!str 0.5
python_tag: !!python/complex '1.0+2.0j'

View File

@ -0,0 +1,3 @@
%YAML 1.1
---
[1, 2, 3]

17
deps/libyaml/include/Makefile.am vendored Normal file
View File

@ -0,0 +1,17 @@
AM_CPPFLAGS = yaml.h
DOXYGEN_CFG = $(top_srcdir)/doc/doxygen.cfg
nobase_include_HEADERS = $(AM_CPPFLAGS)
if DOXYGEN
html: $(AM_CPPFLAGS) $(DOXYGEN_CFG)
PACKAGE=$(PACKAGE) VERSION=$(VERSION) top_srcdir=$(top_srcdir) top_builddir=$(top_builddir) doxygen $(DOXYGEN_CFG)
endif
maintainer-clean-local:
-rm -rf $(top_builddir)/doc/html
dist-hook: html
cp -a $(top_builddir)/doc/html $(top_distdir)/doc

1985
deps/libyaml/include/yaml.h vendored Normal file

File diff suppressed because it is too large Load Diff

4
deps/libyaml/src/Makefile.am vendored Normal file
View File

@ -0,0 +1,4 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -Wall
lib_LTLIBRARIES = libyaml.la
libyaml_la_SOURCES = yaml_private.h api.c reader.c scanner.c parser.c loader.c writer.c emitter.c dumper.c
libyaml_la_LDFLAGS = -no-undefined -release $(YAML_LT_RELEASE) -version-info $(YAML_LT_CURRENT):$(YAML_LT_REVISION):$(YAML_LT_AGE)

1393
deps/libyaml/src/api.c vendored Normal file

File diff suppressed because it is too large Load Diff

394
deps/libyaml/src/dumper.c vendored Normal file
View File

@ -0,0 +1,394 @@
#include "yaml_private.h"
/*
* API functions.
*/
YAML_DECLARE(int)
yaml_emitter_open(yaml_emitter_t *emitter);
YAML_DECLARE(int)
yaml_emitter_close(yaml_emitter_t *emitter);
YAML_DECLARE(int)
yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
/*
* Clean up functions.
*/
static void
yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter);
/*
* Anchor functions.
*/
static void
yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index);
static yaml_char_t *
yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id);
/*
* Serialize functions.
*/
static int
yaml_emitter_dump_node(yaml_emitter_t *emitter, int index);
static int
yaml_emitter_dump_alias(yaml_emitter_t *emitter, yaml_char_t *anchor);
static int
yaml_emitter_dump_scalar(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor);
static int
yaml_emitter_dump_sequence(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor);
static int
yaml_emitter_dump_mapping(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor);
/*
* Issue a STREAM-START event.
*/
YAML_DECLARE(int)
yaml_emitter_open(yaml_emitter_t *emitter)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
assert(emitter); /* Non-NULL emitter object is required. */
assert(!emitter->opened); /* Emitter should not be opened yet. */
STREAM_START_EVENT_INIT(event, YAML_ANY_ENCODING, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) {
return 0;
}
emitter->opened = 1;
return 1;
}
/*
* Issue a STREAM-END event.
*/
YAML_DECLARE(int)
yaml_emitter_close(yaml_emitter_t *emitter)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
assert(emitter); /* Non-NULL emitter object is required. */
assert(emitter->opened); /* Emitter should be opened. */
if (emitter->closed) return 1;
STREAM_END_EVENT_INIT(event, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) {
return 0;
}
emitter->closed = 1;
return 1;
}
/*
* Dump a YAML document.
*/
YAML_DECLARE(int)
yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
assert(emitter); /* Non-NULL emitter object is required. */
assert(document); /* Non-NULL emitter object is expected. */
emitter->document = document;
if (!emitter->opened) {
if (!yaml_emitter_open(emitter)) goto error;
}
if (STACK_EMPTY(emitter, document->nodes)) {
if (!yaml_emitter_close(emitter)) goto error;
yaml_emitter_delete_document_and_anchors(emitter);
return 1;
}
assert(emitter->opened); /* Emitter should be opened. */
emitter->anchors = (yaml_anchors_t*)yaml_malloc(sizeof(*(emitter->anchors))
* (document->nodes.top - document->nodes.start));
if (!emitter->anchors) goto error;
memset(emitter->anchors, 0, sizeof(*(emitter->anchors))
* (document->nodes.top - document->nodes.start));
DOCUMENT_START_EVENT_INIT(event, document->version_directive,
document->tag_directives.start, document->tag_directives.end,
document->start_implicit, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) goto error;
yaml_emitter_anchor_node(emitter, 1);
if (!yaml_emitter_dump_node(emitter, 1)) goto error;
DOCUMENT_END_EVENT_INIT(event, document->end_implicit, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) goto error;
yaml_emitter_delete_document_and_anchors(emitter);
return 1;
error:
yaml_emitter_delete_document_and_anchors(emitter);
return 0;
}
/*
* Clean up the emitter object after a document is dumped.
*/
static void
yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter)
{
int index;
if (!emitter->anchors) {
yaml_document_delete(emitter->document);
emitter->document = NULL;
return;
}
for (index = 0; emitter->document->nodes.start + index
< emitter->document->nodes.top; index ++) {
yaml_node_t node = emitter->document->nodes.start[index];
if (!emitter->anchors[index].serialized) {
yaml_free(node.tag);
if (node.type == YAML_SCALAR_NODE) {
yaml_free(node.data.scalar.value);
}
}
if (node.type == YAML_SEQUENCE_NODE) {
STACK_DEL(emitter, node.data.sequence.items);
}
if (node.type == YAML_MAPPING_NODE) {
STACK_DEL(emitter, node.data.mapping.pairs);
}
}
STACK_DEL(emitter, emitter->document->nodes);
yaml_free(emitter->anchors);
emitter->anchors = NULL;
emitter->last_anchor_id = 0;
emitter->document = NULL;
}
/*
* Check the references of a node and assign the anchor id if needed.
*/
static void
yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index)
{
yaml_node_t *node = emitter->document->nodes.start + index - 1;
yaml_node_item_t *item;
yaml_node_pair_t *pair;
emitter->anchors[index-1].references ++;
if (emitter->anchors[index-1].references == 1) {
switch (node->type) {
case YAML_SEQUENCE_NODE:
for (item = node->data.sequence.items.start;
item < node->data.sequence.items.top; item ++) {
yaml_emitter_anchor_node(emitter, *item);
}
break;
case YAML_MAPPING_NODE:
for (pair = node->data.mapping.pairs.start;
pair < node->data.mapping.pairs.top; pair ++) {
yaml_emitter_anchor_node(emitter, pair->key);
yaml_emitter_anchor_node(emitter, pair->value);
}
break;
default:
break;
}
}
else if (emitter->anchors[index-1].references == 2) {
emitter->anchors[index-1].anchor = (++ emitter->last_anchor_id);
}
}
/*
* Generate a textual representation for an anchor.
*/
#define ANCHOR_TEMPLATE "id%03d"
#define ANCHOR_TEMPLATE_LENGTH 16
static yaml_char_t *
yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id)
{
yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH);
if (!anchor) return NULL;
sprintf((char *)anchor, ANCHOR_TEMPLATE, anchor_id);
return anchor;
}
/*
* Serialize a node.
*/
static int
yaml_emitter_dump_node(yaml_emitter_t *emitter, int index)
{
yaml_node_t *node = emitter->document->nodes.start + index - 1;
int anchor_id = emitter->anchors[index-1].anchor;
yaml_char_t *anchor = NULL;
if (anchor_id) {
anchor = yaml_emitter_generate_anchor(emitter, anchor_id);
if (!anchor) return 0;
}
if (emitter->anchors[index-1].serialized) {
return yaml_emitter_dump_alias(emitter, anchor);
}
emitter->anchors[index-1].serialized = 1;
switch (node->type) {
case YAML_SCALAR_NODE:
return yaml_emitter_dump_scalar(emitter, node, anchor);
case YAML_SEQUENCE_NODE:
return yaml_emitter_dump_sequence(emitter, node, anchor);
case YAML_MAPPING_NODE:
return yaml_emitter_dump_mapping(emitter, node, anchor);
default:
assert(0); /* Could not happen. */
break;
}
return 0; /* Could not happen. */
}
/*
* Serialize an alias.
*/
static int
yaml_emitter_dump_alias(yaml_emitter_t *emitter, yaml_char_t *anchor)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
ALIAS_EVENT_INIT(event, anchor, mark, mark);
return yaml_emitter_emit(emitter, &event);
}
/*
* Serialize a scalar.
*/
static int
yaml_emitter_dump_scalar(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
int plain_implicit = (strcmp((char *)node->tag,
YAML_DEFAULT_SCALAR_TAG) == 0);
int quoted_implicit = (strcmp((char *)node->tag,
YAML_DEFAULT_SCALAR_TAG) == 0);
SCALAR_EVENT_INIT(event, anchor, node->tag, node->data.scalar.value,
node->data.scalar.length, plain_implicit, quoted_implicit,
node->data.scalar.style, mark, mark);
return yaml_emitter_emit(emitter, &event);
}
/*
* Serialize a sequence.
*/
static int
yaml_emitter_dump_sequence(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
int implicit = (strcmp((char *)node->tag, YAML_DEFAULT_SEQUENCE_TAG) == 0);
yaml_node_item_t *item;
SEQUENCE_START_EVENT_INIT(event, anchor, node->tag, implicit,
node->data.sequence.style, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) return 0;
for (item = node->data.sequence.items.start;
item < node->data.sequence.items.top; item ++) {
if (!yaml_emitter_dump_node(emitter, *item)) return 0;
}
SEQUENCE_END_EVENT_INIT(event, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) return 0;
return 1;
}
/*
* Serialize a mapping.
*/
static int
yaml_emitter_dump_mapping(yaml_emitter_t *emitter, yaml_node_t *node,
yaml_char_t *anchor)
{
yaml_event_t event;
yaml_mark_t mark = { 0, 0, 0 };
int implicit = (strcmp((char *)node->tag, YAML_DEFAULT_MAPPING_TAG) == 0);
yaml_node_pair_t *pair;
MAPPING_START_EVENT_INIT(event, anchor, node->tag, implicit,
node->data.mapping.style, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) return 0;
for (pair = node->data.mapping.pairs.start;
pair < node->data.mapping.pairs.top; pair ++) {
if (!yaml_emitter_dump_node(emitter, pair->key)) return 0;
if (!yaml_emitter_dump_node(emitter, pair->value)) return 0;
}
MAPPING_END_EVENT_INIT(event, mark, mark);
if (!yaml_emitter_emit(emitter, &event)) return 0;
return 1;
}

2358
deps/libyaml/src/emitter.c vendored Normal file

File diff suppressed because it is too large Load Diff

544
deps/libyaml/src/loader.c vendored Normal file
View File

@ -0,0 +1,544 @@
#include "yaml_private.h"
/*
* API functions.
*/
YAML_DECLARE(int)
yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);
/*
* Error handling.
*/
static int
yaml_parser_set_composer_error(yaml_parser_t *parser,
const char *problem, yaml_mark_t problem_mark);
static int
yaml_parser_set_composer_error_context(yaml_parser_t *parser,
const char *context, yaml_mark_t context_mark,
const char *problem, yaml_mark_t problem_mark);
/*
* Alias handling.
*/
static int
yaml_parser_register_anchor(yaml_parser_t *parser,
int index, yaml_char_t *anchor);
/*
* Clean up functions.
*/
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_alias(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 *event,
struct loader_ctx *ctx);
static int
yaml_parser_load_sequence(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 *event,
struct loader_ctx *ctx);
static int
yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
static int
yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
/*
* Load the next document of the stream.
*/
YAML_DECLARE(int)
yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
{
yaml_event_t event;
assert(parser); /* Non-NULL parser object is expected. */
assert(document); /* Non-NULL document object is expected. */
memset(document, 0, sizeof(yaml_document_t));
if (!STACK_INIT(parser, document->nodes, yaml_node_t*))
goto error;
if (!parser->stream_start_produced) {
if (!yaml_parser_parse(parser, &event)) goto error;
assert(event.type == YAML_STREAM_START_EVENT);
/* STREAM-START is expected. */
}
if (parser->stream_end_produced) {
return 1;
}
if (!yaml_parser_parse(parser, &event)) goto error;
if (event.type == YAML_STREAM_END_EVENT) {
return 1;
}
if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*))
goto error;
parser->document = document;
if (!yaml_parser_load_document(parser, &event)) goto error;
yaml_parser_delete_aliases(parser);
parser->document = NULL;
return 1;
error:
yaml_parser_delete_aliases(parser);
yaml_document_delete(document);
parser->document = NULL;
return 0;
}
/*
* Set composer error.
*/
static int
yaml_parser_set_composer_error(yaml_parser_t *parser,
const char *problem, yaml_mark_t problem_mark)
{
parser->error = YAML_COMPOSER_ERROR;
parser->problem = problem;
parser->problem_mark = problem_mark;
return 0;
}
/*
* Set composer error with context.
*/
static int
yaml_parser_set_composer_error_context(yaml_parser_t *parser,
const char *context, yaml_mark_t context_mark,
const char *problem, yaml_mark_t problem_mark)
{
parser->error = YAML_COMPOSER_ERROR;
parser->context = context;
parser->context_mark = context_mark;
parser->problem = problem;
parser->problem_mark = problem_mark;
return 0;
}
/*
* Delete the stack of aliases.
*/
static void
yaml_parser_delete_aliases(yaml_parser_t *parser)
{
while (!STACK_EMPTY(parser, parser->aliases)) {
yaml_free(POP(parser, parser->aliases).anchor);
}
STACK_DEL(parser, parser->aliases);
}
/*
* Compose a document object.
*/
static int
yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event)
{
struct loader_ctx ctx = { NULL, NULL, NULL };
assert(event->type == YAML_DOCUMENT_START_EVENT);
/* DOCUMENT-START is expected. */
parser->document->version_directive
= event->data.document_start.version_directive;
parser->document->tag_directives.start
= event->data.document_start.tag_directives.start;
parser->document->tag_directives.end
= event->data.document_start.tag_directives.end;
parser->document->start_implicit
= event->data.document_start.implicit;
parser->document->start_mark = event->start_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 tree.
*/
static int
yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx)
{
yaml_event_t event;
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;
}
/*
* Add an anchor.
*/
static int
yaml_parser_register_anchor(yaml_parser_t *parser,
int index, yaml_char_t *anchor)
{
yaml_alias_data_t data;
yaml_alias_data_t *alias_data;
if (!anchor) return 1;
data.anchor = anchor;
data.index = index;
data.mark = parser->document->nodes.start[index-1].start_mark;
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 yaml_parser_set_composer_error_context(parser,
"found duplicate anchor; first occurrence",
alias_data->mark, "second occurrence", data.mark);
}
}
if (!PUSH(parser, parser->aliases, data)) {
yaml_free(anchor);
return 0;
}
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 *event,
struct loader_ctx *ctx)
{
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 yaml_parser_load_node_add(parser, ctx, alias_data->index);
}
}
yaml_free(anchor);
return yaml_parser_set_composer_error(parser, "found undefined alias",
event->start_mark);
}
/*
* Compose a scalar node.
*/
static int
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 = event->data.scalar.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!tag || strcmp((char *)tag, "!") == 0) {
yaml_free(tag);
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
if (!tag) goto error;
}
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,
event->data.scalar.anchor)) return 0;
return yaml_parser_load_node_add(parser, ctx, index);
error:
yaml_free(tag);
yaml_free(event->data.scalar.anchor);
yaml_free(event->data.scalar.value);
return 0;
}
/*
* Compose a sequence node.
*/
static int
yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx)
{
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;
yaml_char_t *tag = event->data.sequence_start.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!tag || strcmp((char *)tag, "!") == 0) {
yaml_free(tag);
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
if (!tag) goto error;
}
if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error;
SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
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,
event->data.sequence_start.anchor)) return 0;
if (!yaml_parser_load_node_add(parser, ctx, index)) return 0;
if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0;
if (!PUSH(parser, *ctx, index)) return 0;
return 1;
error:
yaml_free(tag);
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 *event,
struct loader_ctx *ctx)
{
yaml_node_t node;
struct {
yaml_node_pair_t *start;
yaml_node_pair_t *end;
yaml_node_pair_t *top;
} pairs = { NULL, NULL, NULL };
int index;
yaml_char_t *tag = event->data.mapping_start.tag;
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
if (!tag || strcmp((char *)tag, "!") == 0) {
yaml_free(tag);
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
if (!tag) goto error;
}
if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error;
MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
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,
event->data.mapping_start.anchor)) return 0;
if (!yaml_parser_load_node_add(parser, ctx, index)) return 0;
if (!STACK_LIMIT(parser, *ctx, INT_MAX-1)) return 0;
if (!PUSH(parser, *ctx, index)) return 0;
return 1;
error:
yaml_free(tag);
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;
}

1375
deps/libyaml/src/parser.c vendored Normal file

File diff suppressed because it is too large Load Diff

469
deps/libyaml/src/reader.c vendored Normal file
View File

@ -0,0 +1,469 @@
#include "yaml_private.h"
/*
* Declarations.
*/
static int
yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
size_t offset, int value);
static int
yaml_parser_update_raw_buffer(yaml_parser_t *parser);
static int
yaml_parser_determine_encoding(yaml_parser_t *parser);
YAML_DECLARE(int)
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
/*
* Set the reader error and return 0.
*/
static int
yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
size_t offset, int value)
{
parser->error = YAML_READER_ERROR;
parser->problem = problem;
parser->problem_offset = offset;
parser->problem_value = value;
return 0;
}
/*
* Byte order marks.
*/
#define BOM_UTF8 "\xef\xbb\xbf"
#define BOM_UTF16LE "\xff\xfe"
#define BOM_UTF16BE "\xfe\xff"
/*
* Determine the input stream encoding by checking the BOM symbol. If no BOM is
* found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
*/
static int
yaml_parser_determine_encoding(yaml_parser_t *parser)
{
/* Ensure that we had enough bytes in the raw buffer. */
while (!parser->eof
&& parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
if (!yaml_parser_update_raw_buffer(parser)) {
return 0;
}
}
/* Determine the encoding. */
if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF16LE, 2)) {
parser->encoding = YAML_UTF16LE_ENCODING;
parser->raw_buffer.pointer += 2;
parser->offset += 2;
}
else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF16BE, 2)) {
parser->encoding = YAML_UTF16BE_ENCODING;
parser->raw_buffer.pointer += 2;
parser->offset += 2;
}
else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 3
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF8, 3)) {
parser->encoding = YAML_UTF8_ENCODING;
parser->raw_buffer.pointer += 3;
parser->offset += 3;
}
else {
parser->encoding = YAML_UTF8_ENCODING;
}
return 1;
}
/*
* Update the raw buffer.
*/
static int
yaml_parser_update_raw_buffer(yaml_parser_t *parser)
{
size_t size_read = 0;
/* Return if the raw buffer is full. */
if (parser->raw_buffer.start == parser->raw_buffer.pointer
&& parser->raw_buffer.last == parser->raw_buffer.end)
return 1;
/* Return on EOF. */
if (parser->eof) return 1;
/* Move the remaining bytes in the raw buffer to the beginning. */
if (parser->raw_buffer.start < parser->raw_buffer.pointer
&& parser->raw_buffer.pointer < parser->raw_buffer.last) {
memmove(parser->raw_buffer.start, parser->raw_buffer.pointer,
parser->raw_buffer.last - parser->raw_buffer.pointer);
}
parser->raw_buffer.last -=
parser->raw_buffer.pointer - parser->raw_buffer.start;
parser->raw_buffer.pointer = parser->raw_buffer.start;
/* Call the read handler to fill the buffer. */
if (!parser->read_handler(parser->read_handler_data, parser->raw_buffer.last,
parser->raw_buffer.end - parser->raw_buffer.last, &size_read)) {
return yaml_parser_set_reader_error(parser, "input error",
parser->offset, -1);
}
parser->raw_buffer.last += size_read;
if (!size_read) {
parser->eof = 1;
}
return 1;
}
/*
* Ensure that the buffer contains at least `length` characters.
* Return 1 on success, 0 on failure.
*
* The length is supposed to be significantly less that the buffer size.
*/
YAML_DECLARE(int)
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
{
int first = 1;
assert(parser->read_handler); /* Read handler must be set. */
/* If the EOF flag is set and the raw buffer is empty, do nothing. */
if (parser->eof && parser->raw_buffer.pointer == parser->raw_buffer.last)
return 1;
/* Return if the buffer contains enough characters. */
if (parser->unread >= length)
return 1;
/* Determine the input encoding if it is not known yet. */
if (!parser->encoding) {
if (!yaml_parser_determine_encoding(parser))
return 0;
}
/* Move the unread characters to the beginning of the buffer. */
if (parser->buffer.start < parser->buffer.pointer
&& parser->buffer.pointer < parser->buffer.last) {
size_t size = parser->buffer.last - parser->buffer.pointer;
memmove(parser->buffer.start, parser->buffer.pointer, size);
parser->buffer.pointer = parser->buffer.start;
parser->buffer.last = parser->buffer.start + size;
}
else if (parser->buffer.pointer == parser->buffer.last) {
parser->buffer.pointer = parser->buffer.start;
parser->buffer.last = parser->buffer.start;
}
/* Fill the buffer until it has enough characters. */
while (parser->unread < length)
{
/* Fill the raw buffer if necessary. */
if (!first || parser->raw_buffer.pointer == parser->raw_buffer.last) {
if (!yaml_parser_update_raw_buffer(parser)) return 0;
}
first = 0;
/* Decode the raw buffer. */
while (parser->raw_buffer.pointer != parser->raw_buffer.last)
{
unsigned int value = 0, value2 = 0;
int incomplete = 0;
unsigned char octet;
unsigned int width = 0;
int low, high;
size_t k;
size_t raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;
/* Decode the next character. */
switch (parser->encoding)
{
case YAML_UTF8_ENCODING:
/*
* Decode a UTF-8 character. Check RFC 3629
* (http://www.ietf.org/rfc/rfc3629.txt) for more details.
*
* The following table (taken from the RFC) is used for
* decoding.
*
* Char. number range | UTF-8 octet sequence
* (hexadecimal) | (binary)
* --------------------+------------------------------------
* 0000 0000-0000 007F | 0xxxxxxx
* 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
* 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
* 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*
* Additionally, the characters in the range 0xD800-0xDFFF
* are prohibited as they are reserved for use with UTF-16
* surrogate pairs.
*/
/* Determine the length of the UTF-8 sequence. */
octet = parser->raw_buffer.pointer[0];
width = (octet & 0x80) == 0x00 ? 1 :
(octet & 0xE0) == 0xC0 ? 2 :
(octet & 0xF0) == 0xE0 ? 3 :
(octet & 0xF8) == 0xF0 ? 4 : 0;
/* Check if the leading octet is valid. */
if (!width)
return yaml_parser_set_reader_error(parser,
"invalid leading UTF-8 octet",
parser->offset, octet);
/* Check if the raw buffer contains an incomplete character. */
if (width > raw_unread) {
if (parser->eof) {
return yaml_parser_set_reader_error(parser,
"incomplete UTF-8 octet sequence",
parser->offset, -1);
}
incomplete = 1;
break;
}
/* Decode the leading octet. */
value = (octet & 0x80) == 0x00 ? octet & 0x7F :
(octet & 0xE0) == 0xC0 ? octet & 0x1F :
(octet & 0xF0) == 0xE0 ? octet & 0x0F :
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
/* Check and decode the trailing octets. */
for (k = 1; k < width; k ++)
{
octet = parser->raw_buffer.pointer[k];
/* Check if the octet is valid. */
if ((octet & 0xC0) != 0x80)
return yaml_parser_set_reader_error(parser,
"invalid trailing UTF-8 octet",
parser->offset+k, octet);
/* Decode the octet. */
value = (value << 6) + (octet & 0x3F);
}
/* Check the length of the sequence against the value. */
if (!((width == 1) ||
(width == 2 && value >= 0x80) ||
(width == 3 && value >= 0x800) ||
(width == 4 && value >= 0x10000)))
return yaml_parser_set_reader_error(parser,
"invalid length of a UTF-8 sequence",
parser->offset, -1);
/* Check the range of the value. */
if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
return yaml_parser_set_reader_error(parser,
"invalid Unicode character",
parser->offset, value);
break;
case YAML_UTF16LE_ENCODING:
case YAML_UTF16BE_ENCODING:
low = (parser->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
high = (parser->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
/*
* The UTF-16 encoding is not as simple as one might
* naively think. Check RFC 2781
* (http://www.ietf.org/rfc/rfc2781.txt).
*
* Normally, two subsequent bytes describe a Unicode
* character. However a special technique (called a
* surrogate pair) is used for specifying character
* values larger than 0xFFFF.
*
* A surrogate pair consists of two pseudo-characters:
* high surrogate area (0xD800-0xDBFF)
* low surrogate area (0xDC00-0xDFFF)
*
* The following formulas are used for decoding
* and encoding characters using surrogate pairs:
*
* U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
* U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
* W1 = 110110yyyyyyyyyy
* W2 = 110111xxxxxxxxxx
*
* where U is the character value, W1 is the high surrogate
* area, W2 is the low surrogate area.
*/
/* Check for incomplete UTF-16 character. */
if (raw_unread < 2) {
if (parser->eof) {
return yaml_parser_set_reader_error(parser,
"incomplete UTF-16 character",
parser->offset, -1);
}
incomplete = 1;
break;
}
/* Get the character. */
value = parser->raw_buffer.pointer[low]
+ (parser->raw_buffer.pointer[high] << 8);
/* Check for unexpected low surrogate area. */
if ((value & 0xFC00) == 0xDC00)
return yaml_parser_set_reader_error(parser,
"unexpected low surrogate area",
parser->offset, value);
/* Check for a high surrogate area. */
if ((value & 0xFC00) == 0xD800) {
width = 4;
/* Check for incomplete surrogate pair. */
if (raw_unread < 4) {
if (parser->eof) {
return yaml_parser_set_reader_error(parser,
"incomplete UTF-16 surrogate pair",
parser->offset, -1);
}
incomplete = 1;
break;
}
/* Get the next character. */
value2 = parser->raw_buffer.pointer[low+2]
+ (parser->raw_buffer.pointer[high+2] << 8);
/* Check for a low surrogate area. */
if ((value2 & 0xFC00) != 0xDC00)
return yaml_parser_set_reader_error(parser,
"expected low surrogate area",
parser->offset+2, value2);
/* Generate the value of the surrogate pair. */
value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF);
}
else {
width = 2;
}
break;
default:
assert(1); /* Impossible. */
}
/* Check if the raw buffer contains enough bytes to form a character. */
if (incomplete) break;
/*
* Check if the character is in the allowed range:
* #x9 | #xA | #xD | [#x20-#x7E] (8 bit)
* | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit)
* | [#x10000-#x10FFFF] (32 bit)
*/
if (! (value == 0x09 || value == 0x0A || value == 0x0D
|| (value >= 0x20 && value <= 0x7E)
|| (value == 0x85) || (value >= 0xA0 && value <= 0xD7FF)
|| (value >= 0xE000 && value <= 0xFFFD)
|| (value >= 0x10000 && value <= 0x10FFFF)))
return yaml_parser_set_reader_error(parser,
"control characters are not allowed",
parser->offset, value);
/* Move the raw pointers. */
parser->raw_buffer.pointer += width;
parser->offset += width;
/* Finally put the character into the buffer. */
/* 0000 0000-0000 007F -> 0xxxxxxx */
if (value <= 0x7F) {
*(parser->buffer.last++) = value;
}
/* 0000 0080-0000 07FF -> 110xxxxx 10xxxxxx */
else if (value <= 0x7FF) {
*(parser->buffer.last++) = 0xC0 + (value >> 6);
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
}
/* 0000 0800-0000 FFFF -> 1110xxxx 10xxxxxx 10xxxxxx */
else if (value <= 0xFFFF) {
*(parser->buffer.last++) = 0xE0 + (value >> 12);
*(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
}
/* 0001 0000-0010 FFFF -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
else {
*(parser->buffer.last++) = 0xF0 + (value >> 18);
*(parser->buffer.last++) = 0x80 + ((value >> 12) & 0x3F);
*(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
}
parser->unread ++;
}
/* On EOF, put NUL into the buffer and return. */
if (parser->eof) {
*(parser->buffer.last++) = '\0';
parser->unread ++;
return 1;
}
}
if (parser->offset >= MAX_FILE_SIZE) {
return yaml_parser_set_reader_error(parser, "input is too long",
parser->offset, -1);
}
return 1;
}

3598
deps/libyaml/src/scanner.c vendored Normal file

File diff suppressed because it is too large Load Diff

141
deps/libyaml/src/writer.c vendored Normal file
View File

@ -0,0 +1,141 @@
#include "yaml_private.h"
/*
* Declarations.
*/
static int
yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem);
YAML_DECLARE(int)
yaml_emitter_flush(yaml_emitter_t *emitter);
/*
* Set the writer error and return 0.
*/
static int
yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem)
{
emitter->error = YAML_WRITER_ERROR;
emitter->problem = problem;
return 0;
}
/*
* Flush the output buffer.
*/
YAML_DECLARE(int)
yaml_emitter_flush(yaml_emitter_t *emitter)
{
int low, high;
assert(emitter); /* Non-NULL emitter object is expected. */
assert(emitter->write_handler); /* Write handler must be set. */
assert(emitter->encoding); /* Output encoding must be set. */
emitter->buffer.last = emitter->buffer.pointer;
emitter->buffer.pointer = emitter->buffer.start;
/* Check if the buffer is empty. */
if (emitter->buffer.start == emitter->buffer.last) {
return 1;
}
/* If the output encoding is UTF-8, we don't need to recode the buffer. */
if (emitter->encoding == YAML_UTF8_ENCODING)
{
if (emitter->write_handler(emitter->write_handler_data,
emitter->buffer.start,
emitter->buffer.last - emitter->buffer.start)) {
emitter->buffer.last = emitter->buffer.start;
emitter->buffer.pointer = emitter->buffer.start;
return 1;
}
else {
return yaml_emitter_set_writer_error(emitter, "write error");
}
}
/* Recode the buffer into the raw buffer. */
low = (emitter->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
high = (emitter->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
while (emitter->buffer.pointer != emitter->buffer.last)
{
unsigned char octet;
unsigned int width;
unsigned int value;
size_t k;
/*
* See the "reader.c" code for more details on UTF-8 encoding. Note
* that we assume that the buffer contains a valid UTF-8 sequence.
*/
/* Read the next UTF-8 character. */
octet = emitter->buffer.pointer[0];
width = (octet & 0x80) == 0x00 ? 1 :
(octet & 0xE0) == 0xC0 ? 2 :
(octet & 0xF0) == 0xE0 ? 3 :
(octet & 0xF8) == 0xF0 ? 4 : 0;
value = (octet & 0x80) == 0x00 ? octet & 0x7F :
(octet & 0xE0) == 0xC0 ? octet & 0x1F :
(octet & 0xF0) == 0xE0 ? octet & 0x0F :
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
for (k = 1; k < width; k ++) {
octet = emitter->buffer.pointer[k];
value = (value << 6) + (octet & 0x3F);
}
emitter->buffer.pointer += width;
/* Write the character. */
if (value < 0x10000)
{
emitter->raw_buffer.last[high] = value >> 8;
emitter->raw_buffer.last[low] = value & 0xFF;
emitter->raw_buffer.last += 2;
}
else
{
/* Write the character using a surrogate pair (check "reader.c"). */
value -= 0x10000;
emitter->raw_buffer.last[high] = 0xD8 + (value >> 18);
emitter->raw_buffer.last[low] = (value >> 10) & 0xFF;
emitter->raw_buffer.last[high+2] = 0xDC + ((value >> 8) & 0xFF);
emitter->raw_buffer.last[low+2] = value & 0xFF;
emitter->raw_buffer.last += 4;
}
}
/* Write the raw buffer. */
if (emitter->write_handler(emitter->write_handler_data,
emitter->raw_buffer.start,
emitter->raw_buffer.last - emitter->raw_buffer.start)) {
emitter->buffer.last = emitter->buffer.start;
emitter->buffer.pointer = emitter->buffer.start;
emitter->raw_buffer.last = emitter->raw_buffer.start;
emitter->raw_buffer.pointer = emitter->raw_buffer.start;
return 1;
}
else {
return yaml_emitter_set_writer_error(emitter, "write error");
}
}

684
deps/libyaml/src/yaml_private.h vendored Normal file
View File

@ -0,0 +1,684 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <yaml.h>
#include <assert.h>
#include <limits.h>
#include <stddef.h>
/*
* Memory management.
*/
YAML_DECLARE(void *)
yaml_malloc(size_t size);
YAML_DECLARE(void *)
yaml_realloc(void *ptr, size_t size);
YAML_DECLARE(void)
yaml_free(void *ptr);
YAML_DECLARE(yaml_char_t *)
yaml_strdup(const yaml_char_t *);
/*
* Reader: Ensure that the buffer contains at least `length` characters.
*/
YAML_DECLARE(int)
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
/*
* Scanner: Ensure that the token stack contains at least one token ready.
*/
YAML_DECLARE(int)
yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
/*
* The size of the input raw buffer.
*/
#define INPUT_RAW_BUFFER_SIZE 16384
/*
* The size of the input buffer.
*
* It should be possible to decode the whole raw buffer.
*/
#define INPUT_BUFFER_SIZE (INPUT_RAW_BUFFER_SIZE*3)
/*
* The size of the output buffer.
*/
#define OUTPUT_BUFFER_SIZE 16384
/*
* The size of the output raw buffer.
*
* It should be possible to encode the whole output buffer.
*/
#define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
/*
* The maximum size of a YAML input file.
* This used to be PTRDIFF_MAX, but that's not entirely portable
* because stdint.h isn't available on all platforms.
* It is not entirely clear why this isn't the maximum value
* that can fit into the parser->offset field.
*/
#define MAX_FILE_SIZE (~(size_t)0 / 2)
/*
* The size of other stacks and queues.
*/
#define INITIAL_STACK_SIZE 16
#define INITIAL_QUEUE_SIZE 16
#define INITIAL_STRING_SIZE 16
/*
* Buffer management.
*/
#define BUFFER_INIT(context,buffer,size) \
(((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \
((buffer).last = (buffer).pointer = (buffer).start, \
(buffer).end = (buffer).start+(size), \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define BUFFER_DEL(context,buffer) \
(yaml_free((buffer).start), \
(buffer).start = (buffer).pointer = (buffer).end = 0)
/*
* String management.
*/
typedef struct {
yaml_char_t *start;
yaml_char_t *end;
yaml_char_t *pointer;
} yaml_string_t;
YAML_DECLARE(int)
yaml_string_extend(yaml_char_t **start,
yaml_char_t **pointer, yaml_char_t **end);
YAML_DECLARE(int)
yaml_string_join(
yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end);
#define NULL_STRING { NULL, NULL, NULL }
#define STRING(string,length) { (string), (string)+(length), (string) }
#define STRING_ASSIGN(value,string,length) \
((value).start = (string), \
(value).end = (string)+(length), \
(value).pointer = (string))
#define STRING_INIT(context,string,size) \
(((string).start = YAML_MALLOC(size)) ? \
((string).pointer = (string).start, \
(string).end = (string).start+(size), \
memset((string).start, 0, (size)), \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define STRING_DEL(context,string) \
(yaml_free((string).start), \
(string).start = (string).pointer = (string).end = 0)
#define STRING_EXTEND(context,string) \
((((string).pointer+5 < (string).end) \
|| yaml_string_extend(&(string).start, \
&(string).pointer, &(string).end)) ? \
1 : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define CLEAR(context,string) \
((string).pointer = (string).start, \
memset((string).start, 0, (string).end-(string).start))
#define JOIN(context,string_a,string_b) \
((yaml_string_join(&(string_a).start, &(string_a).pointer, \
&(string_a).end, &(string_b).start, \
&(string_b).pointer, &(string_b).end)) ? \
((string_b).pointer = (string_b).start, \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
/*
* String check operations.
*/
/*
* Check the octet at the specified position.
*/
#define CHECK_AT(string,octet,offset) \
((string).pointer[offset] == (yaml_char_t)(octet))
/*
* Check the current octet in the buffer.
*/
#define CHECK(string,octet) (CHECK_AT((string),(octet),0))
/*
* Check if the character at the specified position is an alphabetical
* character, a digit, '_', or '-'.
*/
#define IS_ALPHA_AT(string,offset) \
(((string).pointer[offset] >= (yaml_char_t) '0' && \
(string).pointer[offset] <= (yaml_char_t) '9') || \
((string).pointer[offset] >= (yaml_char_t) 'A' && \
(string).pointer[offset] <= (yaml_char_t) 'Z') || \
((string).pointer[offset] >= (yaml_char_t) 'a' && \
(string).pointer[offset] <= (yaml_char_t) 'z') || \
(string).pointer[offset] == '_' || \
(string).pointer[offset] == '-')
#define IS_ALPHA(string) IS_ALPHA_AT((string),0)
/*
* Check if the character at the specified position is a digit.
*/
#define IS_DIGIT_AT(string,offset) \
(((string).pointer[offset] >= (yaml_char_t) '0' && \
(string).pointer[offset] <= (yaml_char_t) '9'))
#define IS_DIGIT(string) IS_DIGIT_AT((string),0)
/*
* Get the value of a digit.
*/
#define AS_DIGIT_AT(string,offset) \
((string).pointer[offset] - (yaml_char_t) '0')
#define AS_DIGIT(string) AS_DIGIT_AT((string),0)
/*
* Check if the character at the specified position is a hex-digit.
*/
#define IS_HEX_AT(string,offset) \
(((string).pointer[offset] >= (yaml_char_t) '0' && \
(string).pointer[offset] <= (yaml_char_t) '9') || \
((string).pointer[offset] >= (yaml_char_t) 'A' && \
(string).pointer[offset] <= (yaml_char_t) 'F') || \
((string).pointer[offset] >= (yaml_char_t) 'a' && \
(string).pointer[offset] <= (yaml_char_t) 'f'))
#define IS_HEX(string) IS_HEX_AT((string),0)
/*
* Get the value of a hex-digit.
*/
#define AS_HEX_AT(string,offset) \
(((string).pointer[offset] >= (yaml_char_t) 'A' && \
(string).pointer[offset] <= (yaml_char_t) 'F') ? \
((string).pointer[offset] - (yaml_char_t) 'A' + 10) : \
((string).pointer[offset] >= (yaml_char_t) 'a' && \
(string).pointer[offset] <= (yaml_char_t) 'f') ? \
((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
((string).pointer[offset] - (yaml_char_t) '0'))
#define AS_HEX(string) AS_HEX_AT((string),0)
/*
* Check if the character is ASCII.
*/
#define IS_ASCII_AT(string,offset) \
((string).pointer[offset] <= (yaml_char_t) '\x7F')
#define IS_ASCII(string) IS_ASCII_AT((string),0)
/*
* Check if the character can be printed unescaped.
*/
#define IS_PRINTABLE_AT(string,offset) \
(((string).pointer[offset] == 0x0A) /* . == #x0A */ \
|| ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \
&& (string).pointer[offset] <= 0x7E) \
|| ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \
&& (string).pointer[offset+1] >= 0xA0) \
|| ((string).pointer[offset] > 0xC2 \
&& (string).pointer[offset] < 0xED) \
|| ((string).pointer[offset] == 0xED \
&& (string).pointer[offset+1] < 0xA0) \
|| ((string).pointer[offset] == 0xEE) \
|| ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \
&& !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \
&& (string).pointer[offset+2] == 0xBF) \
&& !((string).pointer[offset+1] == 0xBF \
&& ((string).pointer[offset+2] == 0xBE \
|| (string).pointer[offset+2] == 0xBF))))
#define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0)
/*
* Check if the character at the specified position is NUL.
*/
#define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset))
#define IS_Z(string) IS_Z_AT((string),0)
/*
* Check if the character at the specified position is BOM.
*/
#define IS_BOM_AT(string,offset) \
(CHECK_AT((string),'\xEF',(offset)) \
&& CHECK_AT((string),'\xBB',(offset)+1) \
&& CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */
#define IS_BOM(string) IS_BOM_AT(string,0)
/*
* Check if the character at the specified position is space.
*/
#define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset))
#define IS_SPACE(string) IS_SPACE_AT((string),0)
/*
* Check if the character at the specified position is tab.
*/
#define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset))
#define IS_TAB(string) IS_TAB_AT((string),0)
/*
* Check if the character at the specified position is blank (space or tab).
*/
#define IS_BLANK_AT(string,offset) \
(IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset)))
#define IS_BLANK(string) IS_BLANK_AT((string),0)
/*
* Check if the character at the specified position is a line break.
*/
#define IS_BREAK_AT(string,offset) \
(CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \
|| CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \
|| (CHECK_AT((string),'\xC2',(offset)) \
&& CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \
|| (CHECK_AT((string),'\xE2',(offset)) \
&& CHECK_AT((string),'\x80',(offset)+1) \
&& CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \
|| (CHECK_AT((string),'\xE2',(offset)) \
&& CHECK_AT((string),'\x80',(offset)+1) \
&& CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */
#define IS_BREAK(string) IS_BREAK_AT((string),0)
#define IS_CRLF_AT(string,offset) \
(CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1))
#define IS_CRLF(string) IS_CRLF_AT((string),0)
/*
* Check if the character is a line break or NUL.
*/
#define IS_BREAKZ_AT(string,offset) \
(IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset)))
#define IS_BREAKZ(string) IS_BREAKZ_AT((string),0)
/*
* Check if the character is a line break, space, or NUL.
*/
#define IS_SPACEZ_AT(string,offset) \
(IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
#define IS_SPACEZ(string) IS_SPACEZ_AT((string),0)
/*
* Check if the character is a line break, space, tab, or NUL.
*/
#define IS_BLANKZ_AT(string,offset) \
(IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
#define IS_BLANKZ(string) IS_BLANKZ_AT((string),0)
/*
* Determine the width of the character.
*/
#define WIDTH_AT(string,offset) \
(((string).pointer[offset] & 0x80) == 0x00 ? 1 : \
((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \
((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \
((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
#define WIDTH(string) WIDTH_AT((string),0)
/*
* Move the string pointer to the next character.
*/
#define MOVE(string) ((string).pointer += WIDTH((string)))
/*
* Copy a character and move the pointers of both strings.
*/
#define COPY(string_a,string_b) \
((*(string_b).pointer & 0x80) == 0x00 ? \
(*((string_a).pointer++) = *((string_b).pointer++)) : \
(*(string_b).pointer & 0xE0) == 0xC0 ? \
(*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++)) : \
(*(string_b).pointer & 0xF0) == 0xE0 ? \
(*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++)) : \
(*(string_b).pointer & 0xF8) == 0xF0 ? \
(*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++), \
*((string_a).pointer++) = *((string_b).pointer++)) : 0)
/*
* Stack and queue management.
*/
YAML_DECLARE(int)
yaml_stack_extend(void **start, void **top, void **end);
YAML_DECLARE(int)
yaml_queue_extend(void **start, void **head, void **tail, void **end);
#define STACK_INIT(context,stack,type) \
(((stack).start = (type)yaml_malloc(INITIAL_STACK_SIZE*sizeof(*(stack).start))) ? \
((stack).top = (stack).start, \
(stack).end = (stack).start+INITIAL_STACK_SIZE, \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define STACK_DEL(context,stack) \
(yaml_free((stack).start), \
(stack).start = (stack).top = (stack).end = 0)
#define STACK_EMPTY(context,stack) \
((stack).start == (stack).top)
#define STACK_LIMIT(context,stack,size) \
((stack).top - (stack).start < (size) ? \
1 : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define PUSH(context,stack,value) \
(((stack).top != (stack).end \
|| yaml_stack_extend((void **)&(stack).start, \
(void **)&(stack).top, (void **)&(stack).end)) ? \
(*((stack).top++) = value, \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define POP(context,stack) \
(*(--(stack).top))
#define QUEUE_INIT(context,queue,size,type) \
(((queue).start = (type)yaml_malloc((size)*sizeof(*(queue).start))) ? \
((queue).head = (queue).tail = (queue).start, \
(queue).end = (queue).start+(size), \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define QUEUE_DEL(context,queue) \
(yaml_free((queue).start), \
(queue).start = (queue).head = (queue).tail = (queue).end = 0)
#define QUEUE_EMPTY(context,queue) \
((queue).head == (queue).tail)
#define ENQUEUE(context,queue,value) \
(((queue).tail != (queue).end \
|| yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
(void **)&(queue).tail, (void **)&(queue).end)) ? \
(*((queue).tail++) = value, \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
#define DEQUEUE(context,queue) \
(*((queue).head++))
#define QUEUE_INSERT(context,queue,index,value) \
(((queue).tail != (queue).end \
|| yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
(void **)&(queue).tail, (void **)&(queue).end)) ? \
(memmove((queue).head+(index)+1,(queue).head+(index), \
((queue).tail-(queue).head-(index))*sizeof(*(queue).start)), \
*((queue).head+(index)) = value, \
(queue).tail++, \
1) : \
((context)->error = YAML_MEMORY_ERROR, \
0))
/*
* Token initializers.
*/
#define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \
(memset(&(token), 0, sizeof(yaml_token_t)), \
(token).type = (token_type), \
(token).start_mark = (token_start_mark), \
(token).end_mark = (token_end_mark))
#define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \
(token).data.stream_start.encoding = (token_encoding))
#define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
#define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \
(token).data.alias.value = (token_value))
#define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \
(token).data.anchor.value = (token_value))
#define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \
(token).data.tag.handle = (token_handle), \
(token).data.tag.suffix = (token_suffix))
#define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \
(token).data.scalar.value = (token_value), \
(token).data.scalar.length = (token_length), \
(token).data.scalar.style = (token_style))
#define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
(token).data.version_directive.major = (token_major), \
(token).data.version_directive.minor = (token_minor))
#define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \
(TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
(token).data.tag_directive.handle = (token_handle), \
(token).data.tag_directive.prefix = (token_prefix))
/*
* Event initializers.
*/
#define EVENT_INIT(event,event_type,event_start_mark,event_end_mark) \
(memset(&(event), 0, sizeof(yaml_event_t)), \
(event).type = (event_type), \
(event).start_mark = (event_start_mark), \
(event).end_mark = (event_end_mark))
#define STREAM_START_EVENT_INIT(event,event_encoding,start_mark,end_mark) \
(EVENT_INIT((event),YAML_STREAM_START_EVENT,(start_mark),(end_mark)), \
(event).data.stream_start.encoding = (event_encoding))
#define STREAM_END_EVENT_INIT(event,start_mark,end_mark) \
(EVENT_INIT((event),YAML_STREAM_END_EVENT,(start_mark),(end_mark)))
#define DOCUMENT_START_EVENT_INIT(event,event_version_directive, \
event_tag_directives_start,event_tag_directives_end,event_implicit,start_mark,end_mark) \
(EVENT_INIT((event),YAML_DOCUMENT_START_EVENT,(start_mark),(end_mark)), \
(event).data.document_start.version_directive = (event_version_directive), \
(event).data.document_start.tag_directives.start = (event_tag_directives_start), \
(event).data.document_start.tag_directives.end = (event_tag_directives_end), \
(event).data.document_start.implicit = (event_implicit))
#define DOCUMENT_END_EVENT_INIT(event,event_implicit,start_mark,end_mark) \
(EVENT_INIT((event),YAML_DOCUMENT_END_EVENT,(start_mark),(end_mark)), \
(event).data.document_end.implicit = (event_implicit))
#define ALIAS_EVENT_INIT(event,event_anchor,start_mark,end_mark) \
(EVENT_INIT((event),YAML_ALIAS_EVENT,(start_mark),(end_mark)), \
(event).data.alias.anchor = (event_anchor))
#define SCALAR_EVENT_INIT(event,event_anchor,event_tag,event_value,event_length, \
event_plain_implicit, event_quoted_implicit,event_style,start_mark,end_mark) \
(EVENT_INIT((event),YAML_SCALAR_EVENT,(start_mark),(end_mark)), \
(event).data.scalar.anchor = (event_anchor), \
(event).data.scalar.tag = (event_tag), \
(event).data.scalar.value = (event_value), \
(event).data.scalar.length = (event_length), \
(event).data.scalar.plain_implicit = (event_plain_implicit), \
(event).data.scalar.quoted_implicit = (event_quoted_implicit), \
(event).data.scalar.style = (event_style))
#define SEQUENCE_START_EVENT_INIT(event,event_anchor,event_tag, \
event_implicit,event_style,start_mark,end_mark) \
(EVENT_INIT((event),YAML_SEQUENCE_START_EVENT,(start_mark),(end_mark)), \
(event).data.sequence_start.anchor = (event_anchor), \
(event).data.sequence_start.tag = (event_tag), \
(event).data.sequence_start.implicit = (event_implicit), \
(event).data.sequence_start.style = (event_style))
#define SEQUENCE_END_EVENT_INIT(event,start_mark,end_mark) \
(EVENT_INIT((event),YAML_SEQUENCE_END_EVENT,(start_mark),(end_mark)))
#define MAPPING_START_EVENT_INIT(event,event_anchor,event_tag, \
event_implicit,event_style,start_mark,end_mark) \
(EVENT_INIT((event),YAML_MAPPING_START_EVENT,(start_mark),(end_mark)), \
(event).data.mapping_start.anchor = (event_anchor), \
(event).data.mapping_start.tag = (event_tag), \
(event).data.mapping_start.implicit = (event_implicit), \
(event).data.mapping_start.style = (event_style))
#define MAPPING_END_EVENT_INIT(event,start_mark,end_mark) \
(EVENT_INIT((event),YAML_MAPPING_END_EVENT,(start_mark),(end_mark)))
/*
* Document initializer.
*/
#define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \
document_version_directive,document_tag_directives_start, \
document_tag_directives_end,document_start_implicit, \
document_end_implicit,document_start_mark,document_end_mark) \
(memset(&(document), 0, sizeof(yaml_document_t)), \
(document).nodes.start = (document_nodes_start), \
(document).nodes.end = (document_nodes_end), \
(document).nodes.top = (document_nodes_start), \
(document).version_directive = (document_version_directive), \
(document).tag_directives.start = (document_tag_directives_start), \
(document).tag_directives.end = (document_tag_directives_end), \
(document).start_implicit = (document_start_implicit), \
(document).end_implicit = (document_end_implicit), \
(document).start_mark = (document_start_mark), \
(document).end_mark = (document_end_mark))
/*
* Node initializers.
*/
#define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \
(memset(&(node), 0, sizeof(yaml_node_t)), \
(node).type = (node_type), \
(node).tag = (node_tag), \
(node).start_mark = (node_start_mark), \
(node).end_mark = (node_end_mark))
#define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \
node_style,start_mark,end_mark) \
(NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \
(node).data.scalar.value = (node_value), \
(node).data.scalar.length = (node_length), \
(node).data.scalar.style = (node_style))
#define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \
node_style,start_mark,end_mark) \
(NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \
(node).data.sequence.items.start = (node_items_start), \
(node).data.sequence.items.end = (node_items_end), \
(node).data.sequence.items.top = (node_items_start), \
(node).data.sequence.style = (node_style))
#define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \
node_style,start_mark,end_mark) \
(NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \
(node).data.mapping.pairs.start = (node_pairs_start), \
(node).data.mapping.pairs.end = (node_pairs_end), \
(node).data.mapping.pairs.top = (node_pairs_start), \
(node).data.mapping.style = (node_style))
/* Strict C compiler warning helpers */
#if defined(__clang__) || defined(__GNUC__)
# define HASATTRIBUTE_UNUSED
#endif
#ifdef HASATTRIBUTE_UNUSED
# define __attribute__unused__ __attribute__((__unused__))
#else
# define __attribute__unused__
#endif
/* Shim arguments are arguments that must be included in your function,
* but serve no purpose inside. Silence compiler warnings. */
#define SHIM(a) /*@unused@*/ a __attribute__unused__
/* UNUSED_PARAM() marks a shim argument in the body to silence compiler warnings */
#ifdef __clang__
# define UNUSED_PARAM(a) (void)(a);
#else
# define UNUSED_PARAM(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
#endif
#define YAML_MALLOC_STATIC(type) (type*)yaml_malloc(sizeof(type))
#define YAML_MALLOC(size) (yaml_char_t *)yaml_malloc(size)

27
deps/libyaml/tests/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,27 @@
function(add_yaml_executable name)
add_executable(${name} ${name}.c)
target_link_libraries(${name} yaml)
endfunction()
foreach(name IN ITEMS
example-deconstructor
example-deconstructor-alt
example-reformatter
example-reformatter-alt
run-dumper
run-emitter
run-emitter-test-suite
run-loader
run-parser
run-parser-test-suite
run-scanner
test-reader
test-version
)
add_yaml_executable(${name})
endforeach()
add_test(NAME version COMMAND test-version)
add_test(NAME reader COMMAND test-reader)

9
deps/libyaml/tests/Makefile.am vendored Normal file
View File

@ -0,0 +1,9 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -Wall
#AM_CFLAGS = -Wno-pointer-sign
LDADD = $(top_builddir)/src/libyaml.la
TESTS = test-version test-reader
check_PROGRAMS = test-version test-reader
noinst_PROGRAMS = run-scanner run-parser run-loader run-emitter run-dumper \
example-reformatter example-reformatter-alt \
example-deconstructor example-deconstructor-alt \
run-parser-test-suite run-emitter-test-suite

63
deps/libyaml/tests/ReadMe.md vendored Normal file
View File

@ -0,0 +1,63 @@
# Testing the Parser and Emitter
There are several programs to test the parser and emitter.
## Parser
echo 'foo: bar' | ./tests/run-parser-test-suite
This will output the parsing events in yaml-test-suite format:
+STR
+DOC
+MAP
=VAL :foo
=VAL :bar
-MAP
-DOC
-STR
For flow style events, you have to enable it with the `--flow` option:
echo '{ foo: bar }' | ./tests/run-parser-test-suite --flow keep
...
+MAP {}
...
In the future, this will be the default.
You can also explicitly disable this style with `--flow off`, or output
flow style always, with `--flow on`.
## Emitter
run-emitter-test-suite takes yaml-test-suite event format and emits YAML.
./tests/run-parser-test-suite ... | ./tests/run-emitter-test-suite
## Options
* `--directive (1.1|1.2)`
Prints a version directive before every document.
* `--flow on`
Will emit the whole document in flow style.
* `--flow off`
Will emit the whole document in block style.
* `--flow keep`
Will emit block/flow style like in the original document.
Example:
```
% echo 'foo: [bar, {x: y}]' |
./tests/run-parser-test-suite --flow keep |
./tests/run-emitter-test-suite --flow keep
foo: [bar, {x: y}]
```

View File

@ -0,0 +1,800 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
int help = 0;
int canonical = 0;
int unicode = 0;
int k;
int done = 0;
yaml_parser_t parser;
yaml_emitter_t emitter;
yaml_event_t input_event;
yaml_document_t output_document;
int root;
/* Clear the objects. */
memset(&parser, 0, sizeof(parser));
memset(&emitter, 0, sizeof(emitter));
memset(&input_event, 0, sizeof(input_event));
memset(&output_document, 0, sizeof(output_document));
/* Analyze command line options. */
for (k = 1; k < argc; k ++)
{
if (strcmp(argv[k], "-h") == 0
|| strcmp(argv[k], "--help") == 0) {
help = 1;
}
else if (strcmp(argv[k], "-c") == 0
|| strcmp(argv[k], "--canonical") == 0) {
canonical = 1;
}
else if (strcmp(argv[k], "-u") == 0
|| strcmp(argv[k], "--unicode") == 0) {
unicode = 1;
}
else {
fprintf(stderr, "Unrecognized option: %s\n"
"Try `%s --help` for more information.\n",
argv[k], argv[0]);
return 1;
}
}
/* Display the help string. */
if (help)
{
printf("%s <input\n"
"or\n%s -h | --help\nDeconstruct a YAML stream\n\nOptions:\n"
"-h, --help\t\tdisplay this help and exit\n"
"-c, --canonical\t\toutput in the canonical YAML format\n"
"-u, --unicode\t\toutput unescaped non-ASCII characters\n",
argv[0], argv[0]);
return 0;
}
/* Initialize the parser and emitter objects. */
if (!yaml_parser_initialize(&parser)) {
fprintf(stderr, "Could not initialize the parser object\n");
return 1;
}
if (!yaml_emitter_initialize(&emitter)) {
yaml_parser_delete(&parser);
fprintf(stderr, "Could not inialize the emitter object\n");
return 1;
}
/* Set the parser parameters. */
yaml_parser_set_input_file(&parser, stdin);
/* Set the emitter parameters. */
yaml_emitter_set_output_file(&emitter, stdout);
yaml_emitter_set_canonical(&emitter, canonical);
yaml_emitter_set_unicode(&emitter, unicode);
/* Create and emit the STREAM-START event. */
if (!yaml_emitter_open(&emitter))
goto emitter_error;
/* Create a output_document object. */
if (!yaml_document_initialize(&output_document, NULL, NULL, NULL, 0, 0))
goto document_error;
/* Create the root sequence. */
root = yaml_document_add_sequence(&output_document, NULL,
YAML_BLOCK_SEQUENCE_STYLE);
if (!root) goto document_error;
/* Loop through the input events. */
while (!done)
{
int properties, key, value, map, seq;
/* Get the next event. */
if (!yaml_parser_parse(&parser, &input_event))
goto parser_error;
/* Check if this is the stream end. */
if (input_event.type == YAML_STREAM_END_EVENT) {
done = 1;
}
/* Create a mapping node and attach it to the root sequence. */
properties = yaml_document_add_mapping(&output_document, NULL,
YAML_BLOCK_MAPPING_STYLE);
if (!properties) goto document_error;
if (!yaml_document_append_sequence_item(&output_document,
root, properties)) goto document_error;
/* Analyze the event. */
switch (input_event.type)
{
case YAML_STREAM_START_EVENT:
/* Add 'type': 'STREAM-START'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"STREAM-START", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'encoding': <encoding>. */
if (input_event.data.stream_start.encoding)
{
yaml_encoding_t encoding
= input_event.data.stream_start.encoding;
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"encoding", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)(encoding == YAML_UTF8_ENCODING ? "utf-8" :
encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" :
encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" :
"unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
break;
case YAML_STREAM_END_EVENT:
/* Add 'type': 'STREAM-END'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"STREAM-END", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
case YAML_DOCUMENT_START_EVENT:
/* Add 'type': 'DOCUMENT-START'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"DOCUMENT-START", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Display the output_document version numbers. */
if (input_event.data.document_start.version_directive)
{
yaml_version_directive_t *version
= input_event.data.document_start.version_directive;
char number[64];
/* Add 'version': {}. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"version", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
map = yaml_document_add_mapping(&output_document, NULL,
YAML_FLOW_MAPPING_STYLE);
if (!map) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, map)) goto document_error;
/* Add 'major': <number>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"major", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
sprintf(number, "%d", version->major);
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_INT_TAG,
(yaml_char_t *)number, -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
/* Add 'minor': <number>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"minor", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
sprintf(number, "%d", version->minor);
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_INT_TAG,
(yaml_char_t *)number, -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
}
/* Display the output_document tag directives. */
if (input_event.data.document_start.tag_directives.start
!= input_event.data.document_start.tag_directives.end)
{
yaml_tag_directive_t *tag;
/* Add 'tags': []. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"tags", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
seq = yaml_document_add_sequence(&output_document, NULL,
YAML_BLOCK_SEQUENCE_STYLE);
if (!seq) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, seq)) goto document_error;
for (tag = input_event.data.document_start.tag_directives.start;
tag != input_event.data.document_start.tag_directives.end;
tag ++)
{
/* Add {}. */
map = yaml_document_add_mapping(&output_document, NULL,
YAML_FLOW_MAPPING_STYLE);
if (!map) goto document_error;
if (!yaml_document_append_sequence_item(&output_document,
seq, map)) goto document_error;
/* Add 'handle': <handle>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"handle", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
tag->handle, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
/* Add 'prefix': <prefix>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"prefix", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
tag->prefix, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
}
}
/* Add 'implicit': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.document_start.implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
case YAML_DOCUMENT_END_EVENT:
/* Add 'type': 'DOCUMENT-END'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"DOCUMENT-END", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'implicit': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.document_end.implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
case YAML_ALIAS_EVENT:
/* Add 'type': 'ALIAS'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"ALIAS", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'anchor': <anchor>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.alias.anchor, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
case YAML_SCALAR_EVENT:
/* Add 'type': 'SCALAR'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"SCALAR", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'anchor': <anchor>. */
if (input_event.data.scalar.anchor)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.scalar.anchor, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'tag': <tag>. */
if (input_event.data.scalar.tag)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.scalar.tag, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'value': <value>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"value", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.scalar.value,
input_event.data.scalar.length,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Display if the scalar tag is implicit. */
/* Add 'implicit': {} */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"version", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
map = yaml_document_add_mapping(&output_document, NULL,
YAML_FLOW_MAPPING_STYLE);
if (!map) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, map)) goto document_error;
/* Add 'plain': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"plain", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.scalar.plain_implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
/* Add 'quoted': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"quoted", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.scalar.quoted_implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
map, key, value)) goto document_error;
/* Display the style information. */
if (input_event.data.scalar.style)
{
yaml_scalar_style_t style = input_event.data.scalar.style;
/* Add 'style': <style>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)(style == YAML_PLAIN_SCALAR_STYLE ? "plain" :
style == YAML_SINGLE_QUOTED_SCALAR_STYLE ?
"single-quoted" :
style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ?
"double-quoted" :
style == YAML_LITERAL_SCALAR_STYLE ? "literal" :
style == YAML_FOLDED_SCALAR_STYLE ? "folded" :
"unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
break;
case YAML_SEQUENCE_START_EVENT:
/* Add 'type': 'SEQUENCE-START'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"SEQUENCE-START", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'anchor': <anchor>. */
if (input_event.data.sequence_start.anchor)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.sequence_start.anchor, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'tag': <tag>. */
if (input_event.data.sequence_start.tag)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.sequence_start.tag, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'implicit': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.sequence_start.implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Display the style information. */
if (input_event.data.sequence_start.style)
{
yaml_sequence_style_t style
= input_event.data.sequence_start.style;
/* Add 'style': <style>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)(style == YAML_BLOCK_SEQUENCE_STYLE ? "block" :
style == YAML_FLOW_SEQUENCE_STYLE ? "flow" :
"unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
break;
case YAML_SEQUENCE_END_EVENT:
/* Add 'type': 'SEQUENCE-END'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"SEQUENCE-END", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
case YAML_MAPPING_START_EVENT:
/* Add 'type': 'MAPPING-START'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"MAPPING-START", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Add 'anchor': <anchor>. */
if (input_event.data.mapping_start.anchor)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.mapping_start.anchor, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'tag': <tag>. */
if (input_event.data.mapping_start.tag)
{
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
input_event.data.mapping_start.tag, -1,
YAML_DOUBLE_QUOTED_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
/* Add 'implicit': <flag>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t *)(input_event.data.mapping_start.implicit ?
"true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
/* Display the style information. */
if (input_event.data.mapping_start.style)
{
yaml_mapping_style_t style
= input_event.data.mapping_start.style;
/* Add 'style': <style>. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)(style == YAML_BLOCK_MAPPING_STYLE ? "block" :
style == YAML_FLOW_MAPPING_STYLE ? "flow" :
"unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
}
break;
case YAML_MAPPING_END_EVENT:
/* Add 'type': 'MAPPING-END'. */
key = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE);
if (!key) goto document_error;
value = yaml_document_add_scalar(&output_document, NULL,
(yaml_char_t *)"MAPPING-END", -1, YAML_PLAIN_SCALAR_STYLE);
if (!value) goto document_error;
if (!yaml_document_append_mapping_pair(&output_document,
properties, key, value)) goto document_error;
break;
default:
/* It couldn't really happen. */
break;
}
/* Delete the event object. */
yaml_event_delete(&input_event);
}
if (!yaml_emitter_dump(&emitter, &output_document))
goto emitter_error;
if (!yaml_emitter_close(&emitter))
goto emitter_error;
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 0;
parser_error:
/* Display a parser error message. */
switch (parser.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for parsing\n");
break;
case YAML_READER_ERROR:
if (parser.problem_value != -1) {
fprintf(stderr, "Reader error: %s: #%X at %zd\n", parser.problem,
parser.problem_value, parser.problem_offset);
}
else {
fprintf(stderr, "Reader error: %s at %zd\n", parser.problem,
parser.problem_offset);
}
break;
case YAML_SCANNER_ERROR:
if (parser.context) {
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n"
"%s at line %lu, column %lu\n", parser.context,
parser.context_mark.line+1, parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
break;
case YAML_PARSER_ERROR:
if (parser.context) {
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n"
"%s at line %lu, column %lu\n", parser.context,
parser.context_mark.line+1, parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_event_delete(&input_event);
yaml_document_delete(&output_document);
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
emitter_error:
/* Display an emitter error message. */
switch (emitter.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for emitting\n");
break;
case YAML_WRITER_ERROR:
fprintf(stderr, "Writer error: %s\n", emitter.problem);
break;
case YAML_EMITTER_ERROR:
fprintf(stderr, "Emitter error: %s\n", emitter.problem);
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_event_delete(&input_event);
yaml_document_delete(&output_document);
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
document_error:
fprintf(stderr, "Memory error: Not enough memory for creating a document\n");
yaml_event_delete(&input_event);
yaml_document_delete(&output_document);
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
}

1127
deps/libyaml/tests/example-deconstructor.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,217 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
int help = 0;
int canonical = 0;
int unicode = 0;
int k;
int done = 0;
yaml_parser_t parser;
yaml_emitter_t emitter;
yaml_document_t document;
/* Clear the objects. */
memset(&parser, 0, sizeof(parser));
memset(&emitter, 0, sizeof(emitter));
memset(&document, 0, sizeof(document));
/* Analyze command line options. */
for (k = 1; k < argc; k ++)
{
if (strcmp(argv[k], "-h") == 0
|| strcmp(argv[k], "--help") == 0) {
help = 1;
}
else if (strcmp(argv[k], "-c") == 0
|| strcmp(argv[k], "--canonical") == 0) {
canonical = 1;
}
else if (strcmp(argv[k], "-u") == 0
|| strcmp(argv[k], "--unicode") == 0) {
unicode = 1;
}
else {
fprintf(stderr, "Unrecognized option: %s\n"
"Try `%s --help` for more information.\n",
argv[k], argv[0]);
return 1;
}
}
/* Display the help string. */
if (help)
{
printf("%s [--canonical] [--unicode] <input >output\n"
"or\n%s -h | --help\nReformat a YAML stream\n\nOptions:\n"
"-h, --help\t\tdisplay this help and exit\n"
"-c, --canonical\t\toutput in the canonical YAML format\n"
"-u, --unicode\t\toutput unescaped non-ASCII characters\n",
argv[0], argv[0]);
return 0;
}
/* Initialize the parser and emitter objects. */
if (!yaml_parser_initialize(&parser))
goto parser_error;
if (!yaml_emitter_initialize(&emitter))
goto emitter_error;
/* Set the parser parameters. */
yaml_parser_set_input_file(&parser, stdin);
/* Set the emitter parameters. */
yaml_emitter_set_output_file(&emitter, stdout);
yaml_emitter_set_canonical(&emitter, canonical);
yaml_emitter_set_unicode(&emitter, unicode);
/* The main loop. */
while (!done)
{
/* Get the next event. */
if (!yaml_parser_load(&parser, &document))
goto parser_error;
/* Check if this is the stream end. */
if (!yaml_document_get_root_node(&document)) {
done = 1;
}
/* Emit the event. */
if (!yaml_emitter_dump(&emitter, &document))
goto emitter_error;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 0;
parser_error:
/* Display a parser error message. */
switch (parser.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for parsing\n");
break;
case YAML_READER_ERROR:
if (parser.problem_value != -1) {
fprintf(stderr, "Reader error: %s: #%X at %zd\n", parser.problem,
parser.problem_value, parser.problem_offset);
}
else {
fprintf(stderr, "Reader error: %s at %lu\n", parser.problem,
parser.problem_offset);
}
break;
case YAML_SCANNER_ERROR:
if (parser.context) {
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n"
"%s at line %lu, column %lu\n", parser.context,
parser.context_mark.line+1, parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
break;
case YAML_PARSER_ERROR:
if (parser.context) {
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n"
"%s at line %lu, column %lu\n", parser.context,
parser.context_mark.line+1, parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
break;
case YAML_COMPOSER_ERROR:
if (parser.context) {
fprintf(stderr, "Composer error: %s at line %lu, column %lu\n"
"%s at line %lu, column %lu\n", parser.context,
parser.context_mark.line+1, parser.context_mark.column+1,
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Composer error: %s at line %lu, column %lu\n",
parser.problem, parser.problem_mark.line+1,
parser.problem_mark.column+1);
}
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
emitter_error:
/* Display an emitter error message. */
switch (emitter.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for emitting\n");
break;
case YAML_WRITER_ERROR:
fprintf(stderr, "Writer error: %s\n", emitter.problem);
break;
case YAML_EMITTER_ERROR:
fprintf(stderr, "Emitter error: %s\n", emitter.problem);
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
}

202
deps/libyaml/tests/example-reformatter.c vendored Normal file
View File

@ -0,0 +1,202 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
int help = 0;
int canonical = 0;
int unicode = 0;
int k;
int done = 0;
yaml_parser_t parser;
yaml_emitter_t emitter;
yaml_event_t event;
/* Clear the objects. */
memset(&parser, 0, sizeof(parser));
memset(&emitter, 0, sizeof(emitter));
memset(&event, 0, sizeof(event));
/* Analyze command line options. */
for (k = 1; k < argc; k ++)
{
if (strcmp(argv[k], "-h") == 0
|| strcmp(argv[k], "--help") == 0) {
help = 1;
}
else if (strcmp(argv[k], "-c") == 0
|| strcmp(argv[k], "--canonical") == 0) {
canonical = 1;
}
else if (strcmp(argv[k], "-u") == 0
|| strcmp(argv[k], "--unicode") == 0) {
unicode = 1;
}
else {
fprintf(stderr, "Unrecognized option: %s\n"
"Try `%s --help` for more information.\n",
argv[k], argv[0]);
return 1;
}
}
/* Display the help string. */
if (help)
{
printf("%s [--canonical] [--unicode] <input >output\n"
"or\n%s -h | --help\nReformat a YAML stream\n\nOptions:\n"
"-h, --help\t\tdisplay this help and exit\n"
"-c, --canonical\t\toutput in the canonical YAML format\n"
"-u, --unicode\t\toutput unescaped non-ASCII characters\n",
argv[0], argv[0]);
return 0;
}
/* Initialize the parser and emitter objects. */
if (!yaml_parser_initialize(&parser))
goto parser_error;
if (!yaml_emitter_initialize(&emitter))
goto emitter_error;
/* Set the parser parameters. */
yaml_parser_set_input_file(&parser, stdin);
/* Set the emitter parameters. */
yaml_emitter_set_output_file(&emitter, stdout);
yaml_emitter_set_canonical(&emitter, canonical);
yaml_emitter_set_unicode(&emitter, unicode);
/* The main loop. */
while (!done)
{
/* Get the next event. */
if (!yaml_parser_parse(&parser, &event))
goto parser_error;
/* Check if this is the stream end. */
if (event.type == YAML_STREAM_END_EVENT) {
done = 1;
}
/* Emit the event. */
if (!yaml_emitter_emit(&emitter, &event))
goto emitter_error;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 0;
parser_error:
/* Display a parser error message. */
switch (parser.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for parsing\n");
break;
case YAML_READER_ERROR:
if (parser.problem_value != -1) {
fprintf(stderr, "Reader error: %s: #%X at %ld\n", parser.problem,
parser.problem_value, (long)parser.problem_offset);
}
else {
fprintf(stderr, "Reader error: %s at %ld\n", parser.problem,
(long)parser.problem_offset);
}
break;
case YAML_SCANNER_ERROR:
if (parser.context) {
fprintf(stderr, "Scanner error: %s at line %d, column %d\n"
"%s at line %d, column %d\n", parser.context,
(int)parser.context_mark.line+1, (int)parser.context_mark.column+1,
parser.problem, (int)parser.problem_mark.line+1,
(int)parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Scanner error: %s at line %d, column %d\n",
parser.problem, (int)parser.problem_mark.line+1,
(int)parser.problem_mark.column+1);
}
break;
case YAML_PARSER_ERROR:
if (parser.context) {
fprintf(stderr, "Parser error: %s at line %d, column %d\n"
"%s at line %d, column %d\n", parser.context,
(int)parser.context_mark.line+1, (int)parser.context_mark.column+1,
parser.problem, (int)parser.problem_mark.line+1,
(int)parser.problem_mark.column+1);
}
else {
fprintf(stderr, "Parser error: %s at line %d, column %d\n",
parser.problem, (int)parser.problem_mark.line+1,
(int)parser.problem_mark.column+1);
}
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
emitter_error:
/* Display an emitter error message. */
switch (emitter.error)
{
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for emitting\n");
break;
case YAML_WRITER_ERROR:
fprintf(stderr, "Writer error: %s\n", emitter.problem);
break;
case YAML_EMITTER_ERROR:
fprintf(stderr, "Emitter error: %s\n", emitter.problem);
break;
default:
/* Couldn't happen. */
fprintf(stderr, "Internal error\n");
break;
}
yaml_parser_delete(&parser);
yaml_emitter_delete(&emitter);
return 1;
}

29
deps/libyaml/tests/run-all-tests.sh vendored Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
set -e
main() {
# Autoconf based in-source build and tests
clean
./bootstrap
./configure
make test-all
# CMake based in-source build and tests
clean
cmake .
make
make test
clean
}
clean() {
git clean -d -x -f
rm -fr tests/run-test-suite
git worktree prune
}
main "$@"

314
deps/libyaml/tests/run-dumper.c vendored Normal file
View File

@ -0,0 +1,314 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
#define BUFFER_SIZE 65536
#define MAX_DOCUMENTS 16
int copy_document(yaml_document_t *document_to, yaml_document_t *document_from)
{
yaml_node_t *node;
yaml_node_item_t *item;
yaml_node_pair_t *pair;
if (!yaml_document_initialize(document_to, document_from->version_directive,
document_from->tag_directives.start,
document_from->tag_directives.end,
document_from->start_implicit, document_from->end_implicit))
return 0;
for (node = document_from->nodes.start;
node < document_from->nodes.top; node ++) {
switch (node->type) {
case YAML_SCALAR_NODE:
if (!yaml_document_add_scalar(document_to, node->tag,
node->data.scalar.value, node->data.scalar.length,
node->data.scalar.style)) goto error;
break;
case YAML_SEQUENCE_NODE:
if (!yaml_document_add_sequence(document_to, node->tag,
node->data.sequence.style)) goto error;
break;
case YAML_MAPPING_NODE:
if (!yaml_document_add_mapping(document_to, node->tag,
node->data.mapping.style)) goto error;
break;
default:
assert(0);
break;
}
}
for (node = document_from->nodes.start;
node < document_from->nodes.top; node ++) {
switch (node->type) {
case YAML_SEQUENCE_NODE:
for (item = node->data.sequence.items.start;
item < node->data.sequence.items.top; item ++) {
if (!yaml_document_append_sequence_item(document_to,
node - document_from->nodes.start + 1,
*item)) goto error;
}
break;
case YAML_MAPPING_NODE:
for (pair = node->data.mapping.pairs.start;
pair < node->data.mapping.pairs.top; pair ++) {
if (!yaml_document_append_mapping_pair(document_to,
node - document_from->nodes.start + 1,
pair->key, pair->value)) goto error;
}
break;
default:
break;
}
}
return 1;
error:
yaml_document_delete(document_to);
return 0;
}
int compare_nodes(yaml_document_t *document1, int index1,
yaml_document_t *document2, int index2, int level)
{
int k;
yaml_node_t *node1;
yaml_node_t *node2;
if (level++ > 1000) return 0;
node1 = yaml_document_get_node(document1, index1);
node2 = yaml_document_get_node(document2, index2);
assert(node1);
assert(node2);
if (node1->type != node2->type)
return 0;
if (strcmp((char *)node1->tag, (char *)node2->tag) != 0) return 0;
switch (node1->type) {
case YAML_SCALAR_NODE:
if (node1->data.scalar.length != node2->data.scalar.length)
return 0;
if (strncmp((char *)node1->data.scalar.value, (char *)node2->data.scalar.value,
node1->data.scalar.length) != 0) return 0;
break;
case YAML_SEQUENCE_NODE:
if ((node1->data.sequence.items.top - node1->data.sequence.items.start) !=
(node2->data.sequence.items.top - node2->data.sequence.items.start))
return 0;
for (k = 0; k < (node1->data.sequence.items.top - node1->data.sequence.items.start); k ++) {
if (!compare_nodes(document1, node1->data.sequence.items.start[k],
document2, node2->data.sequence.items.start[k], level)) return 0;
}
break;
case YAML_MAPPING_NODE:
if ((node1->data.mapping.pairs.top - node1->data.mapping.pairs.start) !=
(node2->data.mapping.pairs.top - node2->data.mapping.pairs.start))
return 0;
for (k = 0; k < (node1->data.mapping.pairs.top - node1->data.mapping.pairs.start); k ++) {
if (!compare_nodes(document1, node1->data.mapping.pairs.start[k].key,
document2, node2->data.mapping.pairs.start[k].key, level)) return 0;
if (!compare_nodes(document1, node1->data.mapping.pairs.start[k].value,
document2, node2->data.mapping.pairs.start[k].value, level)) return 0;
}
break;
default:
assert(0);
break;
}
return 1;
}
int compare_documents(yaml_document_t *document1, yaml_document_t *document2)
{
int k;
if ((document1->version_directive && !document2->version_directive)
|| (!document1->version_directive && document2->version_directive)
|| (document1->version_directive && document2->version_directive
&& (document1->version_directive->major != document2->version_directive->major
|| document1->version_directive->minor != document2->version_directive->minor)))
return 0;
if ((document1->tag_directives.end - document1->tag_directives.start) !=
(document2->tag_directives.end - document2->tag_directives.start))
return 0;
for (k = 0; k < (document1->tag_directives.end - document1->tag_directives.start); k ++) {
if ((strcmp((char *)document1->tag_directives.start[k].handle,
(char *)document2->tag_directives.start[k].handle) != 0)
|| (strcmp((char *)document1->tag_directives.start[k].prefix,
(char *)document2->tag_directives.start[k].prefix) != 0))
return 0;
}
if ((document1->nodes.top - document1->nodes.start) !=
(document2->nodes.top - document2->nodes.start))
return 0;
if (document1->nodes.top != document1->nodes.start) {
if (!compare_nodes(document1, 1, document2, 1, 0))
return 0;
}
return 1;
}
int print_output(char *name, unsigned char *buffer, size_t size, int count)
{
FILE *file;
char data[BUFFER_SIZE];
size_t data_size = 1;
size_t total_size = 0;
if (count >= 0) {
printf("FAILED (at the document #%d)\nSOURCE:\n", count+1);
}
file = fopen(name, "rb");
assert(file);
while (data_size > 0) {
data_size = fread(data, 1, BUFFER_SIZE, file);
assert(!ferror(file));
if (!data_size) break;
assert(fwrite(data, 1, data_size, stdout) == data_size);
total_size += data_size;
if (feof(file)) break;
}
fclose(file);
printf("#### (length: %ld)\n", (long)total_size);
printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size);
return 0;
}
int
main(int argc, char *argv[])
{
int number;
int canonical = 0;
int unicode = 0;
number = 1;
while (number < argc) {
if (strcmp(argv[number], "-c") == 0) {
canonical = 1;
}
else if (strcmp(argv[number], "-u") == 0) {
unicode = 1;
}
else if (argv[number][0] == '-') {
printf("Unknown option: '%s'\n", argv[number]);
return 0;
}
if (argv[number][0] == '-') {
if (number < argc-1) {
memmove(argv+number, argv+number+1, (argc-number-1)*sizeof(char *));
}
argc --;
}
else {
number ++;
}
}
if (argc < 2) {
printf("Usage: %s [-c] [-u] file1.yaml ...\n", argv[0]);
return 0;
}
for (number = 1; number < argc; number ++)
{
FILE *file;
yaml_parser_t parser;
yaml_emitter_t emitter;
yaml_document_t document;
unsigned char buffer[BUFFER_SIZE+1];
size_t written = 0;
yaml_document_t documents[MAX_DOCUMENTS];
size_t document_number = 0;
int done = 0;
int count = 0;
int error = 0;
int k;
memset(buffer, 0, BUFFER_SIZE+1);
memset(documents, 0, MAX_DOCUMENTS*sizeof(yaml_document_t));
printf("[%d] Loading, dumping, and loading again '%s': ", number, argv[number]);
fflush(stdout);
file = fopen(argv[number], "rb");
assert(file);
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
assert(yaml_emitter_initialize(&emitter));
if (canonical) {
yaml_emitter_set_canonical(&emitter, 1);
}
if (unicode) {
yaml_emitter_set_unicode(&emitter, 1);
}
yaml_emitter_set_output_string(&emitter, buffer, BUFFER_SIZE, &written);
yaml_emitter_open(&emitter);
while (!done)
{
if (!yaml_parser_load(&parser, &document)) {
error = 1;
break;
}
done = (!yaml_document_get_root_node(&document));
if (!done) {
assert(document_number < MAX_DOCUMENTS);
assert(copy_document(&(documents[document_number++]), &document));
assert(yaml_emitter_dump(&emitter, &document) ||
(yaml_emitter_flush(&emitter) && print_output(argv[number], buffer, written, count)));
count ++;
}
else {
yaml_document_delete(&document);
}
}
yaml_parser_delete(&parser);
assert(!fclose(file));
yaml_emitter_close(&emitter);
yaml_emitter_delete(&emitter);
if (!error)
{
count = done = 0;
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_string(&parser, buffer, written);
while (!done)
{
assert(yaml_parser_load(&parser, &document) || print_output(argv[number], buffer, written, count));
done = (!yaml_document_get_root_node(&document));
if (!done) {
assert(compare_documents(documents+count, &document) || print_output(argv[number], buffer, written, count));
count ++;
}
yaml_document_delete(&document);
}
yaml_parser_delete(&parser);
}
for (k = 0; k < document_number; k ++) {
yaml_document_delete(documents+k);
}
printf("PASSED (length: %ld)\n", (long)written);
print_output(argv[number], buffer, written, -1);
}
return 0;
}

View File

@ -0,0 +1,290 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "../src/yaml_private.h"
int get_line(FILE * input, char *line);
char *get_anchor(char sigil, char *line, char *anchor);
char *get_tag(char *line, char *tag);
void get_value(char *line, char *value, int *style);
int usage(int ret);
int main(int argc, char *argv[])
{
FILE *input;
yaml_emitter_t emitter;
yaml_event_t event;
yaml_version_directive_t *version_directive = NULL;
int canonical = 0;
int unicode = 0;
char line[1024];
int foundfile = 0;
int i = 0;
int minor = 0;
int flow = -1; /** default no flow style collections */
for (i = 1; i < argc; i++) {
if (strncmp(argv[i], "--help", 6) == 0)
return usage(0);
if (strncmp(argv[i], "-h", 2) == 0)
return usage(0);
if (strncmp(argv[i], "--flow", 6) == 0) {
if (i+1 == argc)
return usage(1);
i++;
if (strncmp(argv[i], "keep", 4) == 0)
flow = 0;
else if (strncmp(argv[i], "on", 2) == 0)
flow = 1;
else if (strncmp(argv[i], "off", 3) == 0)
flow = -1;
else
return usage(1);
}
else if (strncmp(argv[i], "--directive", 11) == 0) {
if (i+1 == argc)
return usage(1);
i++;
if (strncmp(argv[i], "1.1", 3) == 0)
minor = 1;
else if (strncmp(argv[i], "1.2", 3) == 0)
minor = 2;
else
return usage(1);
}
else if (!foundfile) {
input = fopen(argv[i], "rb");
foundfile = 1;
}
}
if (minor) {
version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
version_directive->major = 1;
version_directive->minor = minor;
}
if (!foundfile)
input = stdin;
assert(input);
if (!yaml_emitter_initialize(&emitter)) {
fprintf(stderr, "Could not initalize the emitter object\n");
return 1;
}
yaml_emitter_set_output_file(&emitter, stdout);
yaml_emitter_set_canonical(&emitter, canonical);
yaml_emitter_set_unicode(&emitter, unicode);
while (get_line(input, line)) {
int ok;
char anchor[256];
char tag[256];
int implicit;
int style;
if (strncmp(line, "+STR", 4) == 0) {
ok = yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING);
}
else if (strncmp(line, "-STR", 4) == 0) {
ok = yaml_stream_end_event_initialize(&event);
}
else if (strncmp(line, "+DOC", 4) == 0) {
implicit = strncmp(line+4, " ---", 4) != 0;
ok = yaml_document_start_event_initialize(&event, version_directive, NULL, NULL, implicit);
}
else if (strncmp(line, "-DOC", 4) == 0) {
implicit = strncmp(line+4, " ...", 4) != 0;
ok = yaml_document_end_event_initialize(&event, implicit);
}
else if (strncmp(line, "+MAP", 4) == 0) {
style = YAML_BLOCK_MAPPING_STYLE;
if (flow == 1)
style = YAML_FLOW_MAPPING_STYLE;
else if (flow == 0 && strncmp(line+5, "{}", 2) == 0)
style = YAML_FLOW_MAPPING_STYLE;
ok = yaml_mapping_start_event_initialize(&event, (yaml_char_t *)
get_anchor('&', line, anchor), (yaml_char_t *)
get_tag(line, tag), 0, style);
}
else if (strncmp(line, "-MAP", 4) == 0) {
ok = yaml_mapping_end_event_initialize(&event);
}
else if (strncmp(line, "+SEQ", 4) == 0) {
style = YAML_BLOCK_SEQUENCE_STYLE;
if (flow == 1)
style = YAML_FLOW_MAPPING_STYLE;
else if (flow == 0 && strncmp(line+5, "[]", 2) == 0)
style = YAML_FLOW_SEQUENCE_STYLE;
ok = yaml_sequence_start_event_initialize(&event, (yaml_char_t *)
get_anchor('&', line, anchor), (yaml_char_t *)
get_tag(line, tag), 0, style);
}
else if (strncmp(line, "-SEQ", 4) == 0) {
ok = yaml_sequence_end_event_initialize(&event);
}
else if (strncmp(line, "=VAL", 4) == 0) {
char value[1024];
int style;
get_value(line, value, &style);
implicit = (get_tag(line, tag) == NULL);
ok = yaml_scalar_event_initialize(&event, (yaml_char_t *)
get_anchor('&', line, anchor), (yaml_char_t *) get_tag(line, tag), (yaml_char_t *) value, -1, implicit, implicit, style);
}
else if (strncmp(line, "=ALI", 4) == 0) {
ok = yaml_alias_event_initialize(&event, (yaml_char_t *)
get_anchor('*', line, anchor)
);
}
else {
fprintf(stderr, "Unknown event: '%s'\n", line);
fflush(stdout);
return 1;
}
if (!ok)
goto event_error;
if (!yaml_emitter_emit(&emitter, &event))
goto emitter_error;
}
assert(!fclose(input));
yaml_emitter_delete(&emitter);
fflush(stdout);
return 0;
emitter_error:
switch (emitter.error) {
case YAML_MEMORY_ERROR:
fprintf(stderr, "Memory error: Not enough memory for emitting\n");
break;
case YAML_WRITER_ERROR:
fprintf(stderr, "Writer error: %s\n", emitter.problem);
break;
case YAML_EMITTER_ERROR:
fprintf(stderr, "Emitter error: %s\n", emitter.problem);
break;
default:
/*
* Couldn't happen.
*/
fprintf(stderr, "Internal error\n");
break;
}
yaml_emitter_delete(&emitter);
return 1;
event_error:
fprintf(stderr, "Memory error: Not enough memory for creating an event\n");
yaml_emitter_delete(&emitter);
return 1;
}
int get_line(FILE * input, char *line)
{
char *newline;
if (!fgets(line, 1024 - 1, input))
return 0;
if ((newline = strchr(line, '\n')) == NULL) {
fprintf(stderr, "Line too long: '%s'", line);
abort();
}
*newline = '\0';
return 1;
}
char *get_anchor(char sigil, char *line, char *anchor)
{
char *start;
char *end;
if ((start = strchr(line, sigil)) == NULL)
return NULL;
start++;
if ((end = strchr(start, ' ')) == NULL)
end = line + strlen(line);
memcpy(anchor, start, end - start);
anchor[end - start] = '\0';
return anchor;
}
char *get_tag(char *line, char *tag)
{
char *start;
char *end;
if ((start = strchr(line, '<')) == NULL)
return NULL;
if ((end = strchr(line, '>')) == NULL)
return NULL;
memcpy(tag, start + 1, end - start - 1);
tag[end - start - 1] = '\0';
return tag;
}
void get_value(char *line, char *value, int *style)
{
int i = 0;
char *c;
char *start = NULL;
char *end = line + strlen(line);
for (c = line + 4; c < end; c++) {
if (*c == ' ') {
start = c + 1;
if (*start == ':')
*style = YAML_PLAIN_SCALAR_STYLE;
else if (*start == '\'')
*style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
else if (*start == '"')
*style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
else if (*start == '|')
*style = YAML_LITERAL_SCALAR_STYLE;
else if (*start == '>')
*style = YAML_FOLDED_SCALAR_STYLE;
else {
start = NULL;
continue;
}
start++;
break;
}
}
if (!start)
abort();
for (c = start; c < end; c++) {
if (*c == '\\') {
if (*++c == '\\')
value[i++] = '\\';
else if (*c == '0')
value[i++] = '\0';
else if (*c == 'b')
value[i++] = '\b';
else if (*c == 'n')
value[i++] = '\n';
else if (*c == 'r')
value[i++] = '\r';
else if (*c == 't')
value[i++] = '\t';
else
abort();
}
else
value[i++] = *c;
}
value[i] = '\0';
}
int usage(int ret) {
fprintf(stderr, "Usage: run-emitter-test-suite [--directive (1.1|1.2)] [--flow (on|off|keep)] [<input-file>]\n");
return ret;
}

327
deps/libyaml/tests/run-emitter.c vendored Normal file
View File

@ -0,0 +1,327 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
#define BUFFER_SIZE 65536
#define MAX_EVENTS 1024
int copy_event(yaml_event_t *event_to, yaml_event_t *event_from)
{
switch (event_from->type)
{
case YAML_STREAM_START_EVENT:
return yaml_stream_start_event_initialize(event_to,
event_from->data.stream_start.encoding);
case YAML_STREAM_END_EVENT:
return yaml_stream_end_event_initialize(event_to);
case YAML_DOCUMENT_START_EVENT:
return yaml_document_start_event_initialize(event_to,
event_from->data.document_start.version_directive,
event_from->data.document_start.tag_directives.start,
event_from->data.document_start.tag_directives.end,
event_from->data.document_start.implicit);
case YAML_DOCUMENT_END_EVENT:
return yaml_document_end_event_initialize(event_to,
event_from->data.document_end.implicit);
case YAML_ALIAS_EVENT:
return yaml_alias_event_initialize(event_to,
event_from->data.alias.anchor);
case YAML_SCALAR_EVENT:
return yaml_scalar_event_initialize(event_to,
event_from->data.scalar.anchor,
event_from->data.scalar.tag,
event_from->data.scalar.value,
event_from->data.scalar.length,
event_from->data.scalar.plain_implicit,
event_from->data.scalar.quoted_implicit,
event_from->data.scalar.style);
case YAML_SEQUENCE_START_EVENT:
return yaml_sequence_start_event_initialize(event_to,
event_from->data.sequence_start.anchor,
event_from->data.sequence_start.tag,
event_from->data.sequence_start.implicit,
event_from->data.sequence_start.style);
case YAML_SEQUENCE_END_EVENT:
return yaml_sequence_end_event_initialize(event_to);
case YAML_MAPPING_START_EVENT:
return yaml_mapping_start_event_initialize(event_to,
event_from->data.mapping_start.anchor,
event_from->data.mapping_start.tag,
event_from->data.mapping_start.implicit,
event_from->data.mapping_start.style);
case YAML_MAPPING_END_EVENT:
return yaml_mapping_end_event_initialize(event_to);
default:
assert(1);
}
return 0;
}
int compare_events(yaml_event_t *event1, yaml_event_t *event2)
{
int k;
if (event1->type != event2->type)
return 0;
switch (event1->type)
{
case YAML_STREAM_START_EVENT:
return 1;
/* return (event1->data.stream_start.encoding ==
event2->data.stream_start.encoding); */
case YAML_DOCUMENT_START_EVENT:
if ((event1->data.document_start.version_directive && !event2->data.document_start.version_directive)
|| (!event1->data.document_start.version_directive && event2->data.document_start.version_directive)
|| (event1->data.document_start.version_directive && event2->data.document_start.version_directive
&& (event1->data.document_start.version_directive->major != event2->data.document_start.version_directive->major
|| event1->data.document_start.version_directive->minor != event2->data.document_start.version_directive->minor)))
return 0;
if ((event1->data.document_start.tag_directives.end - event1->data.document_start.tag_directives.start) !=
(event2->data.document_start.tag_directives.end - event2->data.document_start.tag_directives.start))
return 0;
for (k = 0; k < (event1->data.document_start.tag_directives.end - event1->data.document_start.tag_directives.start); k ++) {
if ((strcmp((char *)event1->data.document_start.tag_directives.start[k].handle,
(char *)event2->data.document_start.tag_directives.start[k].handle) != 0)
|| (strcmp((char *)event1->data.document_start.tag_directives.start[k].prefix,
(char *)event2->data.document_start.tag_directives.start[k].prefix) != 0))
return 0;
}
/* if (event1->data.document_start.implicit != event2->data.document_start.implicit)
return 0; */
return 1;
case YAML_DOCUMENT_END_EVENT:
return 1;
/* return (event1->data.document_end.implicit ==
event2->data.document_end.implicit); */
case YAML_ALIAS_EVENT:
return (strcmp((char *)event1->data.alias.anchor,
(char *)event2->data.alias.anchor) == 0);
case YAML_SCALAR_EVENT:
if ((event1->data.scalar.anchor && !event2->data.scalar.anchor)
|| (!event1->data.scalar.anchor && event2->data.scalar.anchor)
|| (event1->data.scalar.anchor && event2->data.scalar.anchor
&& strcmp((char *)event1->data.scalar.anchor,
(char *)event2->data.scalar.anchor) != 0))
return 0;
if ((event1->data.scalar.tag && !event2->data.scalar.tag
&& strcmp((char *)event1->data.scalar.tag, "!") != 0)
|| (!event1->data.scalar.tag && event2->data.scalar.tag
&& strcmp((char *)event2->data.scalar.tag, "!") != 0)
|| (event1->data.scalar.tag && event2->data.scalar.tag
&& strcmp((char *)event1->data.scalar.tag,
(char *)event2->data.scalar.tag) != 0))
return 0;
if ((event1->data.scalar.length != event2->data.scalar.length)
|| memcmp(event1->data.scalar.value, event2->data.scalar.value,
event1->data.scalar.length) != 0)
return 0;
if ((event1->data.scalar.plain_implicit != event2->data.scalar.plain_implicit)
|| (event1->data.scalar.quoted_implicit != event2->data.scalar.quoted_implicit)
/* || (event2->data.scalar.style != event2->data.scalar.style) */)
return 0;
return 1;
case YAML_SEQUENCE_START_EVENT:
if ((event1->data.sequence_start.anchor && !event2->data.sequence_start.anchor)
|| (!event1->data.sequence_start.anchor && event2->data.sequence_start.anchor)
|| (event1->data.sequence_start.anchor && event2->data.sequence_start.anchor
&& strcmp((char *)event1->data.sequence_start.anchor,
(char *)event2->data.sequence_start.anchor) != 0))
return 0;
if ((event1->data.sequence_start.tag && !event2->data.sequence_start.tag)
|| (!event1->data.sequence_start.tag && event2->data.sequence_start.tag)
|| (event1->data.sequence_start.tag && event2->data.sequence_start.tag
&& strcmp((char *)event1->data.sequence_start.tag,
(char *)event2->data.sequence_start.tag) != 0))
return 0;
if ((event1->data.sequence_start.implicit != event2->data.sequence_start.implicit)
/* || (event2->data.sequence_start.style != event2->data.sequence_start.style) */)
return 0;
return 1;
case YAML_MAPPING_START_EVENT:
if ((event1->data.mapping_start.anchor && !event2->data.mapping_start.anchor)
|| (!event1->data.mapping_start.anchor && event2->data.mapping_start.anchor)
|| (event1->data.mapping_start.anchor && event2->data.mapping_start.anchor
&& strcmp((char *)event1->data.mapping_start.anchor,
(char *)event2->data.mapping_start.anchor) != 0))
return 0;
if ((event1->data.mapping_start.tag && !event2->data.mapping_start.tag)
|| (!event1->data.mapping_start.tag && event2->data.mapping_start.tag)
|| (event1->data.mapping_start.tag && event2->data.mapping_start.tag
&& strcmp((char *)event1->data.mapping_start.tag,
(char *)event2->data.mapping_start.tag) != 0))
return 0;
if ((event1->data.mapping_start.implicit != event2->data.mapping_start.implicit)
/* || (event2->data.mapping_start.style != event2->data.mapping_start.style) */)
return 0;
return 1;
default:
return 1;
}
}
int print_output(char *name, unsigned char *buffer, size_t size, int count)
{
FILE *file;
char data[BUFFER_SIZE];
size_t data_size = 1;
size_t total_size = 0;
if (count >= 0) {
printf("FAILED (at the event #%d)\nSOURCE:\n", count+1);
}
file = fopen(name, "rb");
assert(file);
while (data_size > 0) {
data_size = fread(data, 1, BUFFER_SIZE, file);
assert(!ferror(file));
if (!data_size) break;
assert(fwrite(data, 1, data_size, stdout) == data_size);
total_size += data_size;
if (feof(file)) break;
}
fclose(file);
printf("#### (length: %ld)\n", (long)total_size);
printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size);
return 0;
}
int
main(int argc, char *argv[])
{
int number;
int canonical = 0;
int unicode = 0;
number = 1;
while (number < argc) {
if (strcmp(argv[number], "-c") == 0) {
canonical = 1;
}
else if (strcmp(argv[number], "-u") == 0) {
unicode = 1;
}
else if (argv[number][0] == '-') {
printf("Unknown option: '%s'\n", argv[number]);
return 0;
}
if (argv[number][0] == '-') {
if (number < argc-1) {
memmove(argv+number, argv+number+1, (argc-number-1)*sizeof(char *));
}
argc --;
}
else {
number ++;
}
}
if (argc < 2) {
printf("Usage: %s [-c] [-u] file1.yaml ...\n", argv[0]);
return 0;
}
for (number = 1; number < argc; number ++)
{
FILE *file;
yaml_parser_t parser;
yaml_emitter_t emitter;
yaml_event_t event;
unsigned char buffer[BUFFER_SIZE+1];
size_t written = 0;
yaml_event_t events[MAX_EVENTS];
size_t event_number = 0;
int done = 0;
int count = 0;
int error = 0;
int k;
memset(buffer, 0, BUFFER_SIZE+1);
memset(events, 0, MAX_EVENTS*sizeof(yaml_event_t));
printf("[%d] Parsing, emitting, and parsing again '%s': ", number, argv[number]);
fflush(stdout);
file = fopen(argv[number], "rb");
assert(file);
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
assert(yaml_emitter_initialize(&emitter));
if (canonical) {
yaml_emitter_set_canonical(&emitter, 1);
}
if (unicode) {
yaml_emitter_set_unicode(&emitter, 1);
}
yaml_emitter_set_output_string(&emitter, buffer, BUFFER_SIZE, &written);
while (!done)
{
if (!yaml_parser_parse(&parser, &event)) {
error = 1;
break;
}
done = (event.type == YAML_STREAM_END_EVENT);
assert(event_number < MAX_EVENTS);
assert(copy_event(&(events[event_number++]), &event));
assert(yaml_emitter_emit(&emitter, &event) ||
print_output(argv[number], buffer, written, count));
count ++;
}
yaml_parser_delete(&parser);
assert(!fclose(file));
yaml_emitter_delete(&emitter);
if (!error)
{
count = done = 0;
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_string(&parser, buffer, written);
while (!done)
{
assert(yaml_parser_parse(&parser, &event) || print_output(argv[number], buffer, written, count));
done = (event.type == YAML_STREAM_END_EVENT);
assert(compare_events(events+count, &event) || print_output(argv[number], buffer, written, count));
yaml_event_delete(&event);
count ++;
}
yaml_parser_delete(&parser);
}
for (k = 0; k < event_number; k ++) {
yaml_event_delete(events+k);
}
printf("PASSED (length: %ld)\n", (long)written);
print_output(argv[number], buffer, written, -1);
}
return 0;
}

63
deps/libyaml/tests/run-loader.c vendored Normal file
View File

@ -0,0 +1,63 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
int
main(int argc, char *argv[])
{
int number;
if (argc < 2) {
printf("Usage: %s file1.yaml ...\n", argv[0]);
return 0;
}
for (number = 1; number < argc; number ++)
{
FILE *file;
yaml_parser_t parser;
yaml_document_t document;
int done = 0;
int count = 0;
int error = 0;
printf("[%d] Loading '%s': ", number, argv[number]);
fflush(stdout);
file = fopen(argv[number], "rb");
assert(file);
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
while (!done)
{
if (!yaml_parser_load(&parser, &document)) {
error = 1;
break;
}
done = (!yaml_document_get_root_node(&document));
yaml_document_delete(&document);
if (!done) count ++;
}
yaml_parser_delete(&parser);
assert(!fclose(file));
printf("%s (%d documents)\n", (error ? "FAILURE" : "SUCCESS"), count);
}
return 0;
}

View File

@ -0,0 +1,189 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
void print_escaped(yaml_char_t * str, size_t length);
int usage(int ret);
int main(int argc, char *argv[])
{
FILE *input;
yaml_parser_t parser;
yaml_event_t event;
int flow = -1; /** default no flow style collections */
int i = 0;
int foundfile = 0;
for (i = 1; i < argc; i++) {
if (strncmp(argv[i], "--flow", 6) == 0) {
if (i+1 == argc)
return usage(1);
i++;
if (strncmp(argv[i], "keep", 4) == 0)
flow = 0;
else if (strncmp(argv[i], "on", 2) == 0)
flow = 1;
else if (strncmp(argv[i], "off", 3) == 0)
flow = -1;
else
return usage(1);
}
else if (strncmp(argv[i], "--help", 6) == 0)
return usage(0);
else if (strncmp(argv[i], "-h", 2) == 0)
return usage(0);
else if (!foundfile) {
input = fopen(argv[i], "rb");
foundfile = 1;
}
else
return usage(1);
}
if (!foundfile) {
input = stdin;
}
assert(input);
if (!yaml_parser_initialize(&parser)) {
fprintf(stderr, "Could not initialize the parser object\n");
return 1;
}
yaml_parser_set_input_file(&parser, input);
while (1) {
yaml_event_type_t type;
if (!yaml_parser_parse(&parser, &event)) {
if ( parser.problem_mark.line || parser.problem_mark.column ) {
fprintf(stderr, "Parse error: %s\nLine: %lu Column: %lu\n",
parser.problem,
(unsigned long)parser.problem_mark.line + 1,
(unsigned long)parser.problem_mark.column + 1);
}
else {
fprintf(stderr, "Parse error: %s\n", parser.problem);
}
return 1;
}
type = event.type;
if (type == YAML_NO_EVENT)
printf("???\n");
else if (type == YAML_STREAM_START_EVENT)
printf("+STR\n");
else if (type == YAML_STREAM_END_EVENT)
printf("-STR\n");
else if (type == YAML_DOCUMENT_START_EVENT) {
printf("+DOC");
if (!event.data.document_start.implicit)
printf(" ---");
printf("\n");
}
else if (type == YAML_DOCUMENT_END_EVENT) {
printf("-DOC");
if (!event.data.document_end.implicit)
printf(" ...");
printf("\n");
}
else if (type == YAML_MAPPING_START_EVENT) {
printf("+MAP");
if (flow == 0 && event.data.mapping_start.style == YAML_FLOW_MAPPING_STYLE)
printf(" {}");
else if (flow == 1)
printf(" {}");
if (event.data.mapping_start.anchor)
printf(" &%s", event.data.mapping_start.anchor);
if (event.data.mapping_start.tag)
printf(" <%s>", event.data.mapping_start.tag);
printf("\n");
}
else if (type == YAML_MAPPING_END_EVENT)
printf("-MAP\n");
else if (type == YAML_SEQUENCE_START_EVENT) {
printf("+SEQ");
if (flow == 0 && event.data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE)
printf(" []");
else if (flow == 1)
printf(" []");
if (event.data.sequence_start.anchor)
printf(" &%s", event.data.sequence_start.anchor);
if (event.data.sequence_start.tag)
printf(" <%s>", event.data.sequence_start.tag);
printf("\n");
}
else if (type == YAML_SEQUENCE_END_EVENT)
printf("-SEQ\n");
else if (type == YAML_SCALAR_EVENT) {
printf("=VAL");
if (event.data.scalar.anchor)
printf(" &%s", event.data.scalar.anchor);
if (event.data.scalar.tag)
printf(" <%s>", event.data.scalar.tag);
switch (event.data.scalar.style) {
case YAML_PLAIN_SCALAR_STYLE:
printf(" :");
break;
case YAML_SINGLE_QUOTED_SCALAR_STYLE:
printf(" '");
break;
case YAML_DOUBLE_QUOTED_SCALAR_STYLE:
printf(" \"");
break;
case YAML_LITERAL_SCALAR_STYLE:
printf(" |");
break;
case YAML_FOLDED_SCALAR_STYLE:
printf(" >");
break;
case YAML_ANY_SCALAR_STYLE:
abort();
}
print_escaped(event.data.scalar.value, event.data.scalar.length);
printf("\n");
}
else if (type == YAML_ALIAS_EVENT)
printf("=ALI *%s\n", event.data.alias.anchor);
else
abort();
yaml_event_delete(&event);
if (type == YAML_STREAM_END_EVENT)
break;
}
assert(!fclose(input));
yaml_parser_delete(&parser);
fflush(stdout);
return 0;
}
void print_escaped(yaml_char_t * str, size_t length)
{
int i;
char c;
for (i = 0; i < length; i++) {
c = *(str + i);
if (c == '\\')
printf("\\\\");
else if (c == '\0')
printf("\\0");
else if (c == '\b')
printf("\\b");
else if (c == '\n')
printf("\\n");
else if (c == '\r')
printf("\\r");
else if (c == '\t')
printf("\\t");
else
printf("%c", c);
}
}
int usage(int ret) {
fprintf(stderr, "Usage: libyaml-parser [--flow (on|off|keep)] [<input-file>]\n");
return ret;
}

63
deps/libyaml/tests/run-parser.c vendored Normal file
View File

@ -0,0 +1,63 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
int
main(int argc, char *argv[])
{
int number;
if (argc < 2) {
printf("Usage: %s file1.yaml ...\n", argv[0]);
return 0;
}
for (number = 1; number < argc; number ++)
{
FILE *file;
yaml_parser_t parser;
yaml_event_t event;
int done = 0;
int count = 0;
int error = 0;
printf("[%d] Parsing '%s': ", number, argv[number]);
fflush(stdout);
file = fopen(argv[number], "rb");
assert(file);
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
while (!done)
{
if (!yaml_parser_parse(&parser, &event)) {
error = 1;
break;
}
done = (event.type == YAML_STREAM_END_EVENT);
yaml_event_delete(&event);
count ++;
}
yaml_parser_delete(&parser);
assert(!fclose(file));
printf("%s (%d events)\n", (error ? "FAILURE" : "SUCCESS"), count);
}
return 0;
}

63
deps/libyaml/tests/run-scanner.c vendored Normal file
View File

@ -0,0 +1,63 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
int
main(int argc, char *argv[])
{
int number;
if (argc < 2) {
printf("Usage: %s file1.yaml ...\n", argv[0]);
return 0;
}
for (number = 1; number < argc; number ++)
{
FILE *file;
yaml_parser_t parser;
yaml_token_t token;
int done = 0;
int count = 0;
int error = 0;
printf("[%d] Scanning '%s': ", number, argv[number]);
fflush(stdout);
file = fopen(argv[number], "rb");
assert(file);
assert(yaml_parser_initialize(&parser));
yaml_parser_set_input_file(&parser, file);
while (!done)
{
if (!yaml_parser_scan(&parser, &token)) {
error = 1;
break;
}
done = (token.type == YAML_STREAM_END_TOKEN);
yaml_token_delete(&token);
count ++;
}
yaml_parser_delete(&parser);
assert(!fclose(file));
printf("%s (%d tokens)\n", (error ? "FAILURE" : "SUCCESS"), count);
}
return 0;
}

354
deps/libyaml/tests/test-reader.c vendored Normal file
View File

@ -0,0 +1,354 @@
#include <yaml.h>
YAML_DECLARE(int)
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
/*
* Test cases are stolen from
* http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
*/
typedef struct {
char *title;
char *test;
int result;
} test_case;
test_case utf8_sequences[] = {
/* {"title", "test 1|test 2|...|test N!", (0 or 1)}, */
{"a simple test", "'test' is '\xd0\xbf\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb5\xd1\x80\xd0\xba\xd0\xb0' in Russian!", 1},
{"an empty line", "!", 1},
{"u-0 is a control character", "\x00!", 0},
{"u-80 is a control character", "\xc2\x80!", 0},
{"u-800 is valid", "\xe0\xa0\x80!", 1},
{"u-10000 is valid", "\xf0\x90\x80\x80!", 1},
{"5 bytes sequences are not allowed", "\xf8\x88\x80\x80\x80!", 0},
{"6 bytes sequences are not allowed", "\xfc\x84\x80\x80\x80\x80!", 0},
{"u-7f is a control character", "\x7f!", 0},
{"u-7FF is valid", "\xdf\xbf!", 1},
{"u-FFFF is a control character", "\xef\xbf\xbf!", 0},
{"u-1FFFFF is too large", "\xf7\xbf\xbf\xbf!", 0},
{"u-3FFFFFF is 5 bytes", "\xfb\xbf\xbf\xbf\xbf!", 0},
{"u-7FFFFFFF is 6 bytes", "\xfd\xbf\xbf\xbf\xbf\xbf!", 0},
{"u-D7FF", "\xed\x9f\xbf!", 1},
{"u-E000", "\xee\x80\x80!", 1},
{"u-FFFD", "\xef\xbf\xbd!", 1},
{"u-10FFFF", "\xf4\x8f\xbf\xbf!", 1},
{"u-110000", "\xf4\x90\x80\x80!", 0},
{"first continuation byte", "\x80!", 0},
{"last continuation byte", "\xbf!", 0},
{"2 continuation bytes", "\x80\xbf!", 0},
{"3 continuation bytes", "\x80\xbf\x80!", 0},
{"4 continuation bytes", "\x80\xbf\x80\xbf!", 0},
{"5 continuation bytes", "\x80\xbf\x80\xbf\x80!", 0},
{"6 continuation bytes", "\x80\xbf\x80\xbf\x80\xbf!", 0},
{"7 continuation bytes", "\x80\xbf\x80\xbf\x80\xbf\x80!", 0},
{"sequence of all 64 possible continuation bytes",
"\x80|\x81|\x82|\x83|\x84|\x85|\x86|\x87|\x88|\x89|\x8a|\x8b|\x8c|\x8d|\x8e|\x8f|"
"\x90|\x91|\x92|\x93|\x94|\x95|\x96|\x97|\x98|\x99|\x9a|\x9b|\x9c|\x9d|\x9e|\x9f|"
"\xa0|\xa1|\xa2|\xa3|\xa4|\xa5|\xa6|\xa7|\xa8|\xa9|\xaa|\xab|\xac|\xad|\xae|\xaf|"
"\xb0|\xb1|\xb2|\xb3|\xb4|\xb5|\xb6|\xb7|\xb8|\xb9|\xba|\xbb|\xbc|\xbd|\xbe|\xbf!", 0},
{"32 first bytes of 2-byte sequences {0xc0-0xdf}",
"\xc0 |\xc1 |\xc2 |\xc3 |\xc4 |\xc5 |\xc6 |\xc7 |\xc8 |\xc9 |\xca |\xcb |\xcc |\xcd |\xce |\xcf |"
"\xd0 |\xd1 |\xd2 |\xd3 |\xd4 |\xd5 |\xd6 |\xd7 |\xd8 |\xd9 |\xda |\xdb |\xdc |\xdd |\xde |\xdf !", 0},
{"16 first bytes of 3-byte sequences {0xe0-0xef}",
"\xe0 |\xe1 |\xe2 |\xe3 |\xe4 |\xe5 |\xe6 |\xe7 |\xe8 |\xe9 |\xea |\xeb |\xec |\xed |\xee |\xef !", 0},
{"8 first bytes of 4-byte sequences {0xf0-0xf7}", "\xf0 |\xf1 |\xf2 |\xf3 |\xf4 |\xf5 |\xf6 |\xf7 !", 0},
{"4 first bytes of 5-byte sequences {0xf8-0xfb}", "\xf8 |\xf9 |\xfa |\xfb !", 0},
{"2 first bytes of 6-byte sequences {0xfc-0xfd}", "\xfc |\xfd !", 0},
{"sequences with last byte missing {u-0}",
"\xc0|\xe0\x80|\xf0\x80\x80|\xf8\x80\x80\x80|\xfc\x80\x80\x80\x80!", 0},
{"sequences with last byte missing {u-...FF}",
"\xdf|\xef\xbf|\xf7\xbf\xbf|\xfb\xbf\xbf\xbf|\xfd\xbf\xbf\xbf\xbf!", 0},
{"impossible bytes", "\xfe|\xff|\xfe\xfe\xff\xff!", 0},
{"overlong sequences {u-2f}",
"\xc0\xaf|\xe0\x80\xaf|\xf0\x80\x80\xaf|\xf8\x80\x80\x80\xaf|\xfc\x80\x80\x80\x80\xaf!", 0},
{"maximum overlong sequences",
"\xc1\xbf|\xe0\x9f\xbf|\xf0\x8f\xbf\xbf|\xf8\x87\xbf\xbf\xbf|\xfc\x83\xbf\xbf\xbf\xbf!", 0},
{"overlong representation of the NUL character",
"\xc0\x80|\xe0\x80\x80|\xf0\x80\x80\x80|\xf8\x80\x80\x80\x80|\xfc\x80\x80\x80\x80\x80!", 0},
{"single UTF-16 surrogates",
"\xed\xa0\x80|\xed\xad\xbf|\xed\xae\x80|\xed\xaf\xbf|\xed\xb0\x80|\xed\xbe\x80|\xed\xbf\xbf!", 0},
{"paired UTF-16 surrogates",
"\xed\xa0\x80\xed\xb0\x80|\xed\xa0\x80\xed\xbf\xbf|\xed\xad\xbf\xed\xb0\x80|"
"\xed\xad\xbf\xed\xbf\xbf|\xed\xae\x80\xed\xb0\x80|\xed\xae\x80\xed\xbf\xbf|"
"\xed\xaf\xbf\xed\xb0\x80|\xed\xaf\xbf\xed\xbf\xbf!", 0},
{"other illegal code positions", "\xef\xbf\xbe|\xef\xbf\xbf!", 0},
{NULL, NULL, 0}
};
test_case boms[] = {
/* {"title", "test!", lenth}, */
{"no bom (utf-8)", "Hi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82!", 13},
{"bom (utf-8)", "\xef\xbb\xbfHi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82!", 13},
{"bom (utf-16-le)", "\xff\xfeH\x00i\x00 \x00i\x00s\x00 \x00\x1f\x04@\x04""8\x04""2\x04""5\x04""B\x04!", 13},
{"bom (utf-16-be)", "\xfe\xff\x00H\x00i\x00 \x00i\x00s\x00 \x04\x1f\x04@\x04""8\x04""2\x04""5\x04""B!", 13},
{NULL, NULL, 0}
};
char *bom_original = "Hi is \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82";
int check_utf8_sequences(void)
{
yaml_parser_t parser;
int failed = 0;
int k;
printf("checking utf-8 sequences...\n");
for (k = 0; utf8_sequences[k].test; k++) {
char *title = utf8_sequences[k].title;
int check = utf8_sequences[k].result;
int result;
char *start = utf8_sequences[k].test;
char *end = start;
printf("\t%s:\n", title);
while(1) {
while (*end != '|' && *end != '!') end++;
yaml_parser_initialize(&parser);
yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start);
result = yaml_parser_update_buffer(&parser, end-start);
if (result != check) {
printf("\t\t- ");
failed ++;
}
else {
printf("\t\t+ ");
}
if (!parser.error) {
printf("(no error)\n");
}
else if (parser.error == YAML_READER_ERROR) {
if (parser.problem_value != -1) {
printf("(reader error: %s: #%X at %ld)\n",
parser.problem, parser.problem_value, (long)parser.problem_offset);
}
else {
printf("(reader error: %s at %ld)\n",
parser.problem, (long)parser.problem_offset);
}
}
if (*end == '!') break;
start = ++end;
yaml_parser_delete(&parser);
};
printf("\n");
}
printf("checking utf-8 sequences: %d fail(s)\n", failed);
return failed;
}
int check_boms(void)
{
yaml_parser_t parser;
int failed = 0;
int k;
printf("checking boms...\n");
for (k = 0; boms[k].test; k++) {
char *title = boms[k].title;
int check = boms[k].result;
int result;
char *start = boms[k].test;
char *end = start;
while (*end != '!') end++;
printf("\t%s: ", title);
yaml_parser_initialize(&parser);
yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start);
result = yaml_parser_update_buffer(&parser, end-start);
if (!result) {
printf("- (reader error: %s at %ld)\n", parser.problem, (long)parser.problem_offset);
failed++;
}
else {
if (parser.unread != check) {
printf("- (length=%ld while expected length=%d)\n", (long)parser.unread, check);
failed++;
}
else if (memcmp(parser.buffer.start, bom_original, check) != 0) {
printf("- (value '%s' does not equal to the original value '%s')\n", parser.buffer.start, bom_original);
failed++;
}
else {
printf("+\n");
}
}
yaml_parser_delete(&parser);
}
printf("checking boms: %d fail(s)\n", failed);
return failed;
}
#define LONG 100000
int check_long_utf8(void)
{
yaml_parser_t parser;
int k = 0;
int j;
int failed = 0;
unsigned char ch0, ch1;
unsigned char *buffer = (unsigned char *)malloc(3+LONG*2);
assert(buffer);
printf("checking a long utf8 sequence...\n");
buffer[k++] = '\xef';
buffer[k++] = '\xbb';
buffer[k++] = '\xbf';
for (j = 0; j < LONG; j ++) {
if (j % 2) {
buffer[k++] = '\xd0';
buffer[k++] = '\x90';
}
else {
buffer[k++] = '\xd0';
buffer[k++] = '\xaf';
}
}
yaml_parser_initialize(&parser);
yaml_parser_set_input_string(&parser, buffer, 3+LONG*2);
for (k = 0; k < LONG; k++) {
if (!parser.unread) {
if (!yaml_parser_update_buffer(&parser, 1)) {
printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset);
failed = 1;
break;
}
}
if (!parser.unread) {
printf("\tnot enough characters at %d\n", k);
failed = 1;
break;
}
if (k % 2) {
ch0 = '\xd0';
ch1 = '\x90';
}
else {
ch0 = '\xd0';
ch1 = '\xaf';
}
if (parser.buffer.pointer[0] != ch0 || parser.buffer.pointer[1] != ch1) {
printf("\tincorrect UTF-8 sequence: %X %X instead of %X %X\n",
(int)parser.buffer.pointer[0], (int)parser.buffer.pointer[1],
(int)ch0, (int)ch1);
failed = 1;
break;
}
parser.buffer.pointer += 2;
parser.unread -= 1;
}
if (!failed) {
if (!yaml_parser_update_buffer(&parser, 1)) {
printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset);
failed = 1;
}
else if (parser.buffer.pointer[0] != '\0') {
printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread);
failed = 1;
}
}
yaml_parser_delete(&parser);
free(buffer);
printf("checking a long utf8 sequence: %d fail(s)\n", failed);
return failed;
}
int check_long_utf16(void)
{
yaml_parser_t parser;
int k = 0;
int j;
int failed = 0;
unsigned char ch0, ch1;
unsigned char *buffer = (unsigned char *)malloc(2+LONG*2);
assert(buffer);
printf("checking a long utf16 sequence...\n");
buffer[k++] = '\xff';
buffer[k++] = '\xfe';
for (j = 0; j < LONG; j ++) {
if (j % 2) {
buffer[k++] = '\x10';
buffer[k++] = '\x04';
}
else {
buffer[k++] = '/';
buffer[k++] = '\x04';
}
}
yaml_parser_initialize(&parser);
yaml_parser_set_input_string(&parser, buffer, 2+LONG*2);
for (k = 0; k < LONG; k++) {
if (!parser.unread) {
if (!yaml_parser_update_buffer(&parser, 1)) {
printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset);
failed = 1;
break;
}
}
if (!parser.unread) {
printf("\tnot enough characters at %d\n", k);
failed = 1;
break;
}
if (k % 2) {
ch0 = '\xd0';
ch1 = '\x90';
}
else {
ch0 = '\xd0';
ch1 = '\xaf';
}
if (parser.buffer.pointer[0] != ch0 || parser.buffer.pointer[1] != ch1) {
printf("\tincorrect UTF-8 sequence: %X %X instead of %X %X\n",
(int)parser.buffer.pointer[0], (int)parser.buffer.pointer[1],
(int)ch0, (int)ch1);
failed = 1;
break;
}
parser.buffer.pointer += 2;
parser.unread -= 1;
}
if (!failed) {
if (!yaml_parser_update_buffer(&parser, 1)) {
printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset);
failed = 1;
}
else if (parser.buffer.pointer[0] != '\0') {
printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread);
failed = 1;
}
}
yaml_parser_delete(&parser);
free(buffer);
printf("checking a long utf16 sequence: %d fail(s)\n", failed);
return failed;
}
int
main(void)
{
return check_utf8_sequences() + check_boms() + check_long_utf8() + check_long_utf16();
}

29
deps/libyaml/tests/test-version.c vendored Normal file
View File

@ -0,0 +1,29 @@
#include <yaml.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
int
main(void)
{
int major = -1;
int minor = -1;
int patch = -1;
char buf[64];
yaml_get_version(&major, &minor, &patch);
sprintf(buf, "%d.%d.%d", major, minor, patch);
assert(strcmp(buf, yaml_get_version_string()) == 0);
/* Print structure sizes. */
printf("sizeof(token) = %ld\n", (long)sizeof(yaml_token_t));
printf("sizeof(event) = %ld\n", (long)sizeof(yaml_event_t));
printf("sizeof(parser) = %ld\n", (long)sizeof(yaml_parser_t));
return 0;
}

10
deps/libyaml/yaml-0.1.pc.in vendored Normal file
View File

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
libdir=@libdir@
Name: LibYAML
Description: Library to parse and emit YAML
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lyaml

16
deps/libyaml/yamlConfig.cmake.in vendored Normal file
View File

@ -0,0 +1,16 @@
# Config file for the yaml library.
#
# It defines the following variables:
# yaml_LIBRARIES - libraries to link against
@PACKAGE_INIT@
set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake")
if(NOT yaml_TARGETS_IMPORTED)
set(yaml_TARGETS_IMPORTED 1)
include(${yaml_TARGETS})
endif()
set(yaml_LIBRARIES yaml)