aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:40 +0300
commit5d50718e66d9c037dc587a0211110b7d25a66185 (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /contrib/libs
parenta6a92afe03e02795227d2641b49819b687f088f8 (diff)
downloadydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs')
-rw-r--r--contrib/libs/cctz/tzdata/factory.cpp4
-rwxr-xr-xcontrib/libs/cctz/tzdata/update_tzdata.py12
-rw-r--r--contrib/libs/curl/lib/curl_config.h6
-rw-r--r--contrib/libs/curl/ya.make14
-rw-r--r--contrib/libs/cxxsupp/builtins/ya.make14
-rw-r--r--contrib/libs/cxxsupp/libcxx/glibcxx_eh_cxx17.cpp34
-rwxr-xr-xcontrib/libs/cxxsupp/libcxx/import6
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__config34
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__debug4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__hash_table2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__locale2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__string2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__support/solaris/wchar.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__threading_support4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__tree8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/algorithm4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/atomic44
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/barrier4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/bit4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/chrono16
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/cmath4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/complex4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/ctime4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/deque6
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/functional74
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/iterator12
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/type_traits12
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/ext/hash_map10
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/ext/hash_set2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/forward_list2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/future14
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/inttypes.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/ios30
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/istream364
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/list88
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/locale2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/locale.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/map4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/memory8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/mutex12
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/numeric16
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/optional2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/queue20
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/random2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/regex8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/set2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/span22
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/sstream86
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/stack10
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/string110
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/tuple10
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/type_traits4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/typeinfo22
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/unordered_map24
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/unordered_set12
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/use_ansi.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/variant8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/vector10
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/wctype.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/atomic.cpp6
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/chrono.cpp6
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/debug.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp18
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h10
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp14
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/refstring.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/ios.cpp10
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/iostream.cpp4
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/locale.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/mutex.cpp4
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/new.cpp14
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/optional.cpp4
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/string.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/solaris/xlocale.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp12
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/ya.make42
-rw-r--r--contrib/libs/cxxsupp/libcxxabi/src/demangle/ItaniumDemangle.h240
-rw-r--r--contrib/libs/cxxsupp/openmp/ya.make2
-rw-r--r--contrib/libs/cxxsupp/ya.make2
-rwxr-xr-xcontrib/libs/libc_compat/update.sh10
-rw-r--r--contrib/libs/libiconv/dynamic/ya.make30
-rw-r--r--contrib/libs/libiconv/static/ya.make56
-rw-r--r--contrib/libs/libiconv/ya.make30
-rw-r--r--contrib/libs/libidn/dynamic/ya.make20
-rw-r--r--contrib/libs/libidn/static/ya.make84
-rw-r--r--contrib/libs/libidn/ya.make26
-rw-r--r--contrib/libs/llvm12/include/llvm/Config/config-android.h6
-rw-r--r--contrib/libs/lz4/generated/lz4_ns.h2
-rw-r--r--contrib/libs/openssl/crypto/ya.make100
-rw-r--r--contrib/libs/openssl/include/openssl/opensslconf.h4
-rw-r--r--contrib/libs/openssl/ya.make20
-rw-r--r--contrib/libs/protoc/ya.make6
-rw-r--r--contrib/libs/ya.make32
-rw-r--r--contrib/libs/yaml/License36
-rw-r--r--contrib/libs/yaml/include/yaml.h3906
-rw-r--r--contrib/libs/yaml/src/api.c2698
-rw-r--r--contrib/libs/yaml/src/config.h2
-rw-r--r--contrib/libs/yaml/src/dumper.c782
-rw-r--r--contrib/libs/yaml/src/emitter.c4596
-rw-r--r--contrib/libs/yaml/src/loader.c672
-rw-r--r--contrib/libs/yaml/src/parser.c2720
-rw-r--r--contrib/libs/yaml/src/reader.c928
-rw-r--r--contrib/libs/yaml/src/scanner.c7042
-rw-r--r--contrib/libs/yaml/src/writer.c280
-rw-r--r--contrib/libs/yaml/src/yaml_private.h1266
-rw-r--r--contrib/libs/yaml/ya.make40
-rw-r--r--contrib/libs/zlib/ya.make2
110 files changed, 13526 insertions, 13526 deletions
diff --git a/contrib/libs/cctz/tzdata/factory.cpp b/contrib/libs/cctz/tzdata/factory.cpp
index f3d244a379..5a4b4a27b6 100644
--- a/contrib/libs/cctz/tzdata/factory.cpp
+++ b/contrib/libs/cctz/tzdata/factory.cpp
@@ -4,7 +4,7 @@
#include <util/generic/string.h>
#include <util/stream/str.h>
-#include <util/string/builder.h>
+#include <util/string/builder.h>
namespace cctz_extension {
namespace {
@@ -21,7 +21,7 @@ namespace cctz_extension {
static std::unique_ptr<cctz::ZoneInfoSource> LoadZone(const std::string& zoneName) {
TString resourceName = TStringBuilder() << "/cctz/tzdata/"sv << zoneName;
TString tzData;
- if (!NResource::FindExact(resourceName, &tzData)) {
+ if (!NResource::FindExact(resourceName, &tzData)) {
return nullptr;
}
return std::unique_ptr<cctz::ZoneInfoSource>(new TZoneInfoSource(std::move(tzData)));
diff --git a/contrib/libs/cctz/tzdata/update_tzdata.py b/contrib/libs/cctz/tzdata/update_tzdata.py
index 40ae7578ad..9c3cd07352 100755
--- a/contrib/libs/cctz/tzdata/update_tzdata.py
+++ b/contrib/libs/cctz/tzdata/update_tzdata.py
@@ -37,11 +37,11 @@ def create_cmakelists(zoneinfo_dir):
with open(os.path.join(generated_dir, tz_hash), 'w') as f:
f.write(tz_content)
- yamake_template = (
- 'RESOURCE(\n'
- '{}\n'
- ')'
- )
+ yamake_template = (
+ 'RESOURCE(\n'
+ '{}\n'
+ ')'
+ )
resources = '\n'.join(' generated/{} /cctz/tzdata/{}'.format(tz_hash, tz_name) for tz_name, tz_hash in sorted(tz_to_hash.iteritems()))
all_hashes = set(tz_to_hash.values())
@@ -51,7 +51,7 @@ def create_cmakelists(zoneinfo_dir):
subprocess.check_call(['svn', cmd, '--force', fn])
with open('ya.make.resources', 'w') as f:
- print >>f, yamake_template.format(resources)
+ print >>f, yamake_template.format(resources)
def get_latest_iana_version():
index_html = urllib2.urlopen('http://www.iana.org/time-zones').read()
diff --git a/contrib/libs/curl/lib/curl_config.h b/contrib/libs/curl/lib/curl_config.h
index f1304e4bf2..e58dec7079 100644
--- a/contrib/libs/curl/lib/curl_config.h
+++ b/contrib/libs/curl/lib/curl_config.h
@@ -25,7 +25,7 @@
// Do not misrepresent host on Android and iOS.
#undef OS
#define OS "arcadia"
-
+
// c-ares resolver is known to be buggy.
//
// There is no way to configure it properly without a JVM on Android,
@@ -39,7 +39,7 @@
//
//
// On Linux it caches /etc/resolv.conf contents and does not invalidate it properly
-
+
#if defined(ARCADIA_CURL_DNS_RESOLVER_ARES)
#define USE_ARES
#elif defined(ARCADIA_CURL_DNS_RESOLVER_MULTITHREADED)
@@ -64,4 +64,4 @@
#endif
#else
#error "No dns resolver is specified or resolver specification is wrong"
-#endif
+#endif
diff --git a/contrib/libs/curl/ya.make b/contrib/libs/curl/ya.make
index 27679394bb..00027df424 100644
--- a/contrib/libs/curl/ya.make
+++ b/contrib/libs/curl/ya.make
@@ -33,13 +33,13 @@ ADDINCL(
)
IF (NOT OS_WINDOWS)
- PEERDIR(
+ PEERDIR(
contrib/libs/nghttp2
- )
-ENDIF()
-
+ )
+ENDIF()
+
NO_COMPILER_WARNINGS()
-
+
NO_RUNTIME()
IF (MAPSMOBI_BUILD_TARGET)
@@ -47,8 +47,8 @@ IF (MAPSMOBI_BUILD_TARGET)
CFLAGS(
-DMAPSMOBI_BUILD
)
-ENDIF()
-
+ENDIF()
+
DEFAULT(ARCADIA_CURL_DNS_RESOLVER ARES)
CFLAGS(
diff --git a/contrib/libs/cxxsupp/builtins/ya.make b/contrib/libs/cxxsupp/builtins/ya.make
index 6e988c13e3..d2c319c927 100644
--- a/contrib/libs/cxxsupp/builtins/ya.make
+++ b/contrib/libs/cxxsupp/builtins/ya.make
@@ -116,11 +116,11 @@ IF (OS_DARWIN OR OS_IOS)
)
ENDIF()
-IF (ARCH_ARM)
- SRCS(
- clear_cache.c
- multc3.c
- )
-ENDIF()
-
+IF (ARCH_ARM)
+ SRCS(
+ clear_cache.c
+ multc3.c
+ )
+ENDIF()
+
END()
diff --git a/contrib/libs/cxxsupp/libcxx/glibcxx_eh_cxx17.cpp b/contrib/libs/cxxsupp/libcxx/glibcxx_eh_cxx17.cpp
index cc2bd0d223..5e5ad083ba 100644
--- a/contrib/libs/cxxsupp/libcxx/glibcxx_eh_cxx17.cpp
+++ b/contrib/libs/cxxsupp/libcxx/glibcxx_eh_cxx17.cpp
@@ -1,17 +1,17 @@
-#include <cxxabi.h>
-
-/**
- * libc++ expects std::uncaught_exceptions() to be provided by C++ runtime library.
- *
- * GCC versions prior to GCC 6 did not provide this function yet, but it can be
- * implemented using its API.
- *
- * This implementation should cover ubuntu-12, ubuntu-14, ubuntu-16.
- */
-
-namespace std {
- int uncaught_exceptions() noexcept {
- const auto* globals{__cxxabiv1::__cxa_get_globals()};
- return static_cast<int>(globals->uncaughtExceptions);
- }
-}
+#include <cxxabi.h>
+
+/**
+ * libc++ expects std::uncaught_exceptions() to be provided by C++ runtime library.
+ *
+ * GCC versions prior to GCC 6 did not provide this function yet, but it can be
+ * implemented using its API.
+ *
+ * This implementation should cover ubuntu-12, ubuntu-14, ubuntu-16.
+ */
+
+namespace std {
+ int uncaught_exceptions() noexcept {
+ const auto* globals{__cxxabiv1::__cxa_get_globals()};
+ return static_cast<int>(globals->uncaughtExceptions);
+ }
+}
diff --git a/contrib/libs/cxxsupp/libcxx/import b/contrib/libs/cxxsupp/libcxx/import
index 60f276b136..9b93145897 100755
--- a/contrib/libs/cxxsupp/libcxx/import
+++ b/contrib/libs/cxxsupp/libcxx/import
@@ -17,6 +17,6 @@ cp libcxx/LICENSE.TXT ../LICENSE.TXT
cd ..
rm -rf tmp
rm src/CMakeLists.txt include/CMakeLists.txt
-
-# Fix tabs and trailing spaces
-find -type f | xargs sed -e 's/\t/ /g' -e 's/ *$//' -i
+
+# Fix tabs and trailing spaces
+find -type f | xargs sed -e 's/\t/ /g' -e 's/ *$//' -i
diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config
index 723053f7d6..bdc54b92d1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__config
+++ b/contrib/libs/cxxsupp/libcxx/include/__config
@@ -418,8 +418,8 @@
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
# define _LIBCPP_HAS_ALIGNED_ALLOC
-# define _LIBCPP_HAS_TIMESPEC_GET
-# endif
+# define _LIBCPP_HAS_TIMESPEC_GET
+# endif
# endif // __APPLE__
#endif
#endif // __has_attribute(using_if_exists)
@@ -441,7 +441,7 @@
#endif
#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
(!defined(__arm__) || __ARM_ARCH_7K__ >= 2)
-# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
#endif
#if __has_feature(cxx_alignas)
@@ -458,7 +458,7 @@ typedef __char32_t char32_t;
#endif
#if !__has_feature(cxx_exceptions)
-# define _LIBCPP_NO_EXCEPTIONS
+# define _LIBCPP_NO_EXCEPTIONS
#endif
#if !(__has_feature(cxx_strong_enums))
@@ -521,7 +521,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_NORETURN __attribute__((noreturn))
#if !defined(__EXCEPTIONS)
-# define _LIBCPP_NO_EXCEPTIONS
+# define _LIBCPP_NO_EXCEPTIONS
#endif
#if !defined(__SANITIZE_ADDRESS__)
@@ -633,8 +633,8 @@ typedef __char32_t char32_t;
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
# else
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
# endif
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
@@ -901,12 +901,12 @@ typedef unsigned int char32_t;
#if !defined(_LIBCPP_DEBUG)
# define _LIBCPP_DEBUG_LEVEL 0
#elif _LIBCPP_DEBUG == 0
-# define _LIBCPP_DEBUG_LEVEL 1
-#elif _LIBCPP_DEBUG == 1
-# define _LIBCPP_DEBUG_LEVEL 2
-#else
-# error Supported values for _LIBCPP_DEBUG are 0 and 1
-#endif
+# define _LIBCPP_DEBUG_LEVEL 1
+#elif _LIBCPP_DEBUG == 1
+# define _LIBCPP_DEBUG_LEVEL 2
+#else
+# error Supported values for _LIBCPP_DEBUG are 0 and 1
+#endif
// Libc++ allows disabling extern template instantiation declarations by
// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
@@ -1096,10 +1096,10 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
# define _LIBCPP_NO_RTTI
#elif defined(__GNUC__) && !defined(__GXX_RTTI)
-# define _LIBCPP_NO_RTTI
-#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
-# define _LIBCPP_NO_RTTI
-#endif
+# define _LIBCPP_NO_RTTI
+#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
+# define _LIBCPP_NO_RTTI
+#endif
#ifndef _LIBCPP_WEAK
#define _LIBCPP_WEAK __attribute__((__weak__))
diff --git a/contrib/libs/cxxsupp/libcxx/include/__debug b/contrib/libs/cxxsupp/libcxx/include/__debug
index 3acd97da29..771e431632 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__debug
+++ b/contrib/libs/cxxsupp/libcxx/include/__debug
@@ -34,7 +34,7 @@
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#elif _LIBCPP_DEBUG_LEVEL == 2
-# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
+# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#else
# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
@@ -221,7 +221,7 @@ public:
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
- return ::new (__mem) _C_node<_Cont>(__c, __next);
+ return ::new (__mem) _C_node<_Cont>(__c, __next);
}
template <class _Cont>
diff --git a/contrib/libs/cxxsupp/libcxx/include/__hash_table b/contrib/libs/cxxsupp/libcxx/include/__hash_table
index 30ae07aab9..bd97027c1a 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__hash_table
+++ b/contrib/libs/cxxsupp/libcxx/include/__hash_table
@@ -38,7 +38,7 @@ template <class _Tp>
struct __is_hash_value_type_imp : false_type {};
template <class _Key, class _Value>
-struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {};
+struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {};
template <class ..._Args>
struct __is_hash_value_type : false_type {};
diff --git a/contrib/libs/cxxsupp/libcxx/include/__locale b/contrib/libs/cxxsupp/libcxx/include/__locale
index 153aa812d4..38cb7a6f39 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__locale
+++ b/contrib/libs/cxxsupp/libcxx/include/__locale
@@ -96,7 +96,7 @@ struct __libcpp_locale_guard {
__setlocale(__locale_all);
free(__locale_all);
}
- _configthreadlocale(__status);
+ _configthreadlocale(__status);
}
static const char* __setlocale(const char* __locale) {
const char* __new_locale = setlocale(LC_ALL, __locale);
diff --git a/contrib/libs/cxxsupp/libcxx/include/__string b/contrib/libs/cxxsupp/libcxx/include/__string
index b1a209d7bf..7074a73538 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__string
+++ b/contrib/libs/cxxsupp/libcxx/include/__string
@@ -626,7 +626,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
return __libcpp_is_constant_evaluated()
? _VSTD::__copy_constexpr(__s1, __s2, __n)
: __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n);
- }
+ }
static _LIBCPP_CONSTEXPR_AFTER_CXX17
char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
index 4a6b86a068..15b8386dd3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h
@@ -125,7 +125,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
}
return str_size;
-}
+}
#ifdef __cplusplus
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/solaris/wchar.h b/contrib/libs/cxxsupp/libcxx/include/__support/solaris/wchar.h
index 9dc9ac3f00..f01fd743a2 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__support/solaris/wchar.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__support/solaris/wchar.h
@@ -26,7 +26,7 @@
#define wctype sun_wctype
#define _WCHAR_T 1
#include_next "wchar.h"
-#undef iswalpha
+#undef iswalpha
#undef iswupper
#undef iswlower
#undef iswdigit
diff --git a/contrib/libs/cxxsupp/libcxx/include/__threading_support b/contrib/libs/cxxsupp/libcxx/include/__threading_support
index f07b79841e..9b0de00dfc 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__threading_support
+++ b/contrib/libs/cxxsupp/libcxx/include/__threading_support
@@ -83,7 +83,7 @@ typedef pthread_cond_t __libcpp_condvar_t;
#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
// Semaphore
typedef sem_t __libcpp_semaphore_t;
-# define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX
+# define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX
#endif
// Execute once
@@ -94,7 +94,7 @@ typedef pthread_once_t __libcpp_exec_once_flag;
#if defined(__MVS__)
typedef unsigned long long __libcpp_thread_id;
#else
- typedef pthread_t __libcpp_thread_id;
+ typedef pthread_t __libcpp_thread_id;
#endif
// Thread
diff --git a/contrib/libs/cxxsupp/libcxx/include/__tree b/contrib/libs/cxxsupp/libcxx/include/__tree
index fd5b429ea5..f3f2e8d15f 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__tree
+++ b/contrib/libs/cxxsupp/libcxx/include/__tree
@@ -539,7 +539,7 @@ template <class _Tp>
struct __is_tree_value_type_imp : false_type {};
template <class _Key, class _Value>
-struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
+struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
template <class ..._Args>
struct __is_tree_value_type : false_type {};
@@ -1638,7 +1638,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _Fo
for (; __cache.__get() != nullptr && __first != __last; ++__first) {
if (__node_assign_unique(*__first, __cache.__get()).second)
__cache.__advance();
- }
+ }
}
for (; __first != __last; ++__first)
__insert_unique(*__first);
@@ -2251,7 +2251,7 @@ __tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _
__begin_node() = __r.__ptr_;
--size();
_VSTD::__tree_remove(__end_node()->__left_,
- static_cast<__node_base_pointer>(__ptr));
+ static_cast<__node_base_pointer>(__ptr));
return __r;
}
@@ -2727,7 +2727,7 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
}
--size();
_VSTD::__tree_remove(__end_node()->__left_,
- static_cast<__node_base_pointer>(__np));
+ static_cast<__node_base_pointer>(__np));
return __node_holder(__np, _Dp(__node_alloc(), true));
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/algorithm b/contrib/libs/cxxsupp/libcxx/include/algorithm
index 307c740247..3fe0c8c1c9 100644
--- a/contrib/libs/cxxsupp/libcxx/include/algorithm
+++ b/contrib/libs/cxxsupp/libcxx/include/algorithm
@@ -563,10 +563,10 @@ template<class T, class Compare>
min(initializer_list<T> t, Compare comp);
template<class T>
- constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
template<class T, class Compare>
- constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
template <class ForwardIterator>
constexpr ForwardIterator // constexpr in C++14
diff --git a/contrib/libs/cxxsupp/libcxx/include/atomic b/contrib/libs/cxxsupp/libcxx/include/atomic
index c9fec104ef..992c745961 100644
--- a/contrib/libs/cxxsupp/libcxx/include/atomic
+++ b/contrib/libs/cxxsupp/libcxx/include/atomic
@@ -23,10 +23,10 @@ namespace std
#define __cpp_lib_atomic_lock_free_type_aliases
#define __cpp_lib_atomic_wait
- // order and consistency
+ // order and consistency
enum memory_order: unspecified // enum class in C++20
- {
+ {
relaxed,
consume, // load-consume
acquire, // load-acquire
@@ -532,13 +532,13 @@ template <class T>
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-# error <atomic> is not supported on this single threaded system
+# error <atomic> is not supported on this single threaded system
#endif
#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
-# error <atomic> is not implemented
+# error <atomic> is not implemented
#endif
#ifdef kill_dependency
-# error C++ standard library is incompatible with <stdatomic.h>
+# error C++ standard library is incompatible with <stdatomic.h>
#endif
#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
@@ -613,7 +613,7 @@ static_assert((is_same<underlying_type<memory_order>::type, __memory_order_under
"unexpected underlying type for std::memory_order");
#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || \
- defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
+ defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
// the default operator= in an object is not volatile, a byte-by-byte copy
@@ -696,7 +696,7 @@ void __cxx_atomic_signal_fence(memory_order __order) {
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
void __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
- memory_order __order) {
+ memory_order __order) {
__atomic_store(&__a->__a_value, &__val,
__to_gcc_order(__order));
}
@@ -704,7 +704,7 @@ void __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
- memory_order __order) {
+ memory_order __order) {
__atomic_store(&__a->__a_value, &__val,
__to_gcc_order(__order));
}
@@ -712,7 +712,7 @@ void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a,
- memory_order __order) {
+ memory_order __order) {
_Tp __ret;
__atomic_load(&__a->__a_value, &__ret,
__to_gcc_order(__order));
@@ -731,7 +731,7 @@ _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __ord
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Tp __value, memory_order __order) {
+ _Tp __value, memory_order __order) {
_Tp __ret;
__atomic_exchange(&__a->__a_value, &__value, &__ret,
__to_gcc_order(__order));
@@ -741,7 +741,7 @@ _Tp __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value,
- memory_order __order) {
+ memory_order __order) {
_Tp __ret;
__atomic_exchange(&__a->__a_value, &__value, &__ret,
__to_gcc_order(__order));
@@ -808,7 +808,7 @@ struct __skip_amt<_Tp[n]> { };
template <typename _Tp, typename _Td>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Td __delta, memory_order __order) {
+ _Td __delta, memory_order __order) {
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
__to_gcc_order(__order));
}
@@ -816,7 +816,7 @@ _Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp, typename _Td>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
- memory_order __order) {
+ memory_order __order) {
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
__to_gcc_order(__order));
}
@@ -824,7 +824,7 @@ _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
template <typename _Tp, typename _Td>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Td __delta, memory_order __order) {
+ _Td __delta, memory_order __order) {
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
__to_gcc_order(__order));
}
@@ -832,7 +832,7 @@ _Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp, typename _Td>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
- memory_order __order) {
+ memory_order __order) {
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
__to_gcc_order(__order));
}
@@ -840,7 +840,7 @@ _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Tp __pattern, memory_order __order) {
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_and(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -848,7 +848,7 @@ _Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a,
- _Tp __pattern, memory_order __order) {
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_and(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -856,7 +856,7 @@ _Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Tp __pattern, memory_order __order) {
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_or(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -864,7 +864,7 @@ _Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
- memory_order __order) {
+ memory_order __order) {
return __atomic_fetch_or(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -872,7 +872,7 @@ _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a,
- _Tp __pattern, memory_order __order) {
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_xor(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -880,7 +880,7 @@ _Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a,
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
- memory_order __order) {
+ memory_order __order) {
return __atomic_fetch_xor(&__a->__a_value, __pattern,
__to_gcc_order(__order));
}
@@ -928,7 +928,7 @@ void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {
#pragma warning ( pop )
#endif
-template<class _Tp>
+template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {
__c11_atomic_init(&__a->__a_value, __val);
diff --git a/contrib/libs/cxxsupp/libcxx/include/barrier b/contrib/libs/cxxsupp/libcxx/include/barrier
index eda9433a4b..c40a1e43f3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/barrier
+++ b/contrib/libs/cxxsupp/libcxx/include/barrier
@@ -308,11 +308,11 @@ public:
{
__b.wait(_VSTD::move(__phase));
}
- _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait()
{
wait(arrive());
- }
+ }
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
diff --git a/contrib/libs/cxxsupp/libcxx/include/bit b/contrib/libs/cxxsupp/libcxx/include/bit
index 5da3eaf788..eab67977a1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/bit
+++ b/contrib/libs/cxxsupp/libcxx/include/bit
@@ -219,7 +219,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool __has_single_bit(_Tp __t) _NOEXCEPT
{
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type");
- return __t != 0 && (((__t & (__t - 1)) == 0));
+ return __t != 0 && (((__t & (__t - 1)) == 0));
}
#if _LIBCPP_STD_VER > 17
@@ -261,7 +261,7 @@ _LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
countr_zero(_Tp __t) noexcept
{
- return __countr_zero(__t);
+ return __countr_zero(__t);
}
template<class _Tp>
diff --git a/contrib/libs/cxxsupp/libcxx/include/chrono b/contrib/libs/cxxsupp/libcxx/include/chrono
index 45c7a495a8..db186a4fba 100644
--- a/contrib/libs/cxxsupp/libcxx/include/chrono
+++ b/contrib/libs/cxxsupp/libcxx/include/chrono
@@ -1972,7 +1972,7 @@ bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
inline constexpr
weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
-inline constexpr
+inline constexpr
weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
@@ -2283,7 +2283,7 @@ public:
year_month_day() = default;
inline constexpr year_month_day(
const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __y{__yval}, __m{__mval}, __d{__dval} {}
+ : __y{__yval}, __m{__mval}, __d{__dval} {}
constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
inline constexpr year_month_day(const sys_days& __sysd) noexcept
: year_month_day(__from_days(__sysd.time_since_epoch())) {}
@@ -2538,7 +2538,7 @@ inline constexpr year_month_day_last& year_month_day_last::operator+=(const year
inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
- : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+ : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
inline constexpr bool year_month_day::ok() const noexcept
{
@@ -2594,7 +2594,7 @@ year_month_weekday year_month_weekday::__from_days(days __d) noexcept
const sys_days __sysd{__d};
const chrono::weekday __wd = chrono::weekday(__sysd);
const year_month_day __ymd = year_month_day(__sysd);
- return year_month_weekday{__ymd.year(), __ymd.month(),
+ return year_month_weekday{__ymd.year(), __ymd.month(),
__wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
}
@@ -2686,9 +2686,9 @@ public:
inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
-
+
constexpr days __to_days() const noexcept;
-
+
};
inline constexpr
@@ -2726,7 +2726,7 @@ year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& _
inline constexpr
year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
+{ return year(__rhs) / __lhs; }
inline constexpr
@@ -2916,7 +2916,7 @@ inline namespace literals
{
return chrono::day(static_cast<unsigned>(__d));
}
-
+
constexpr chrono::year operator ""y(unsigned long long __y) noexcept
{
return chrono::year(static_cast<int>(__y));
diff --git a/contrib/libs/cxxsupp/libcxx/include/cmath b/contrib/libs/cxxsupp/libcxx/include/cmath
index a2a7dde190..e14905c57c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/cmath
+++ b/contrib/libs/cxxsupp/libcxx/include/cmath
@@ -622,9 +622,9 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
if (__t == 1) return __b;
const _Fp __x = __a + __t * (__b - __a);
if ((__t > 1) == (__b > __a))
- return __b < __x ? __x : __b;
+ return __b < __x ? __x : __b;
else
- return __x < __b ? __x : __b;
+ return __x < __b ? __x : __b;
}
constexpr float
diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex
index 01c072c800..e4c59193bc 100644
--- a/contrib/libs/cxxsupp/libcxx/include/complex
+++ b/contrib/libs/cxxsupp/libcxx/include/complex
@@ -1447,10 +1447,10 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
}
#endif // !_LIBCPP_HAS_NO_LOCALIZATION
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
// Literal suffix for complex number literals [complex.literals]
inline namespace literals
-{
+{
inline namespace complex_literals
{
constexpr complex<long double> operator""il(long double __im)
diff --git a/contrib/libs/cxxsupp/libcxx/include/ctime b/contrib/libs/cxxsupp/libcxx/include/ctime
index 6034bf2185..816618f6a3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/ctime
+++ b/contrib/libs/cxxsupp/libcxx/include/ctime
@@ -18,7 +18,7 @@ Macros:
NULL
CLOCKS_PER_SEC
TIME_UTC // C++17
-
+
namespace std
{
@@ -29,7 +29,7 @@ Types:
time_t
tm
timespec // C++17
-
+
clock_t clock();
double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr);
diff --git a/contrib/libs/cxxsupp/libcxx/include/deque b/contrib/libs/cxxsupp/libcxx/include/deque
index 8108abecd9..67cd6654f1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/deque
+++ b/contrib/libs/cxxsupp/libcxx/include/deque
@@ -2889,7 +2889,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
__alloc_traits::destroy(__a, _VSTD::addressof(*__b));
__base::size() -= __n;
__base::__start_ += __n;
- while (__maybe_remove_front_spare()) {
+ while (__maybe_remove_front_spare()) {
}
}
else
@@ -2898,7 +2898,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
for (iterator __e = __base::end(); __i != __e; ++__i)
__alloc_traits::destroy(__a, _VSTD::addressof(*__i));
__base::size() -= __n;
- while (__maybe_remove_back_spare()) {
+ while (__maybe_remove_back_spare()) {
}
}
}
@@ -2919,7 +2919,7 @@ deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
for (iterator __p = __b + __pos; __p != __e; ++__p)
__alloc_traits::destroy(__a, _VSTD::addressof(*__p));
__base::size() -= __n;
- while (__maybe_remove_back_spare()) {
+ while (__maybe_remove_back_spare()) {
}
}
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/functional b/contrib/libs/cxxsupp/libcxx/include/experimental/functional
index 5d28714566..e3220e16ca 100644
--- a/contrib/libs/cxxsupp/libcxx/include/experimental/functional
+++ b/contrib/libs/cxxsupp/libcxx/include/experimental/functional
@@ -113,7 +113,7 @@ template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
class _LIBCPP_TEMPLATE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
- default_searcher(_ForwardIterator __f, _ForwardIterator __l,
+ default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
@@ -152,12 +152,12 @@ public: // TODO private:
const _Value __default_value_;
std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
-
+
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
: __default_value_(__default), __table(__sz, __hf, __pred) {}
-
+
_LIBCPP_INLINE_VISIBILITY
void insert(const key_type &__key, value_type __val)
{
@@ -172,7 +172,7 @@ public:
}
};
-
+
// Special case small numeric values; use an array
template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
@@ -190,7 +190,7 @@ public:
{
std::fill_n(__table.begin(), __table.size(), __default);
}
-
+
_LIBCPP_INLINE_VISIBILITY
void insert(key_type __key, value_type __val)
{
@@ -205,8 +205,8 @@ public:
};
-template <class _RandomAccessIterator1,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
private:
@@ -218,9 +218,9 @@ private:
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
> skip_table_type;
-
+
public:
- boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
@@ -233,13 +233,13 @@ public:
this->__build_suffix_table ( __first_, __last_, __pred_ );
}
-
+
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
- typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+ typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
@@ -251,10 +251,10 @@ public:
if ( __pattern_length_ > _VSTD::distance(__f, __l))
return make_pair(__l, __l);
- // Do the search
+ // Do the search
return this->__search(__f, __l);
}
-
+
public: // TODO private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
@@ -271,7 +271,7 @@ public: // TODO private:
const _RandomAccessIterator2 __last = __l - __pattern_length_;
const skip_table_type & __skip = *__skip_.get();
const vector<difference_type> & __suffix = *__suffix_.get();
-
+
while (__cur <= __last)
{
@@ -283,7 +283,7 @@ public: // TODO private:
if ( __j == 0 )
return make_pair(__cur, __cur + __pattern_length_);
}
-
+
// Since we didn't match, figure out how far to skip forward
difference_type __k = __skip[__cur [ __j - 1 ]];
difference_type __m = __j - __k - 1;
@@ -292,7 +292,7 @@ public: // TODO private:
else
__cur += __suffix[ __j ];
}
-
+
return make_pair(__l, __l); // We didn't find anything
}
@@ -301,21 +301,21 @@ public: // TODO private:
void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix )
{
const size_t __count = _VSTD::distance(__f, __l);
-
+
__prefix[0] = 0;
size_t __k = 0;
for ( size_t __i = 1; __i < __count; ++__i )
{
while ( __k > 0 && !__pred ( __f[__k], __f[__i] ))
__k = __prefix [ __k - 1 ];
-
+
if ( __pred ( __f[__k], __f[__i] ))
__k++;
__prefix [ __i ] = __k;
}
}
- void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_BinaryPredicate __pred)
{
const size_t __count = _VSTD::distance(__f, __l);
@@ -323,19 +323,19 @@ public: // TODO private:
if (__count > 0)
{
vector<value_type> __scratch(__count);
-
+
__compute_bm_prefix(__f, __l, __pred, __scratch);
for ( size_t __i = 0; __i <= __count; __i++ )
__suffix[__i] = __count - __scratch[__count-1];
-
+
typedef reverse_iterator<_RandomAccessIterator1> _RevIter;
__compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch);
-
+
for ( size_t __i = 0; __i < __count; __i++ )
{
const size_t __j = __count - __scratch[__i];
const difference_type __k = __i - __scratch[__i] + 1;
-
+
if (__suffix[__j] > __k)
__suffix[__j] = __k;
}
@@ -344,20 +344,20 @@ public: // TODO private:
};
-template<class _RandomAccessIterator,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
+template<class _RandomAccessIterator,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
-make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
+make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
}
// boyer-moore-horspool
-template <class _RandomAccessIterator1,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
private:
@@ -371,7 +371,7 @@ private:
> skip_table_type;
public:
- boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
+ boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
@@ -385,13 +385,13 @@ public:
__skip_->insert(*__f, __pattern_length_ - 1 - __i);
}
}
-
+
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
- typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
+ typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
@@ -403,10 +403,10 @@ public:
if ( __pattern_length_ > _VSTD::distance(__f, __l))
return make_pair(__l, __l);
- // Do the search
+ // Do the search
return this->__search(__f, __l);
}
-
+
private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
@@ -434,17 +434,17 @@ private:
}
__cur += __skip[__cur[__pattern_length_-1]];
}
-
+
return make_pair(__l, __l);
}
};
-template<class _RandomAccessIterator,
- class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
+template<class _RandomAccessIterator,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
-make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
+make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/iterator b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator
index 43f1bd8d7a..09ea2cbcc7 100644
--- a/contrib/libs/cxxsupp/libcxx/include/experimental/iterator
+++ b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator
@@ -26,19 +26,19 @@ namespace std {
typedef void difference_type;
typedef void pointer;
typedef void reference;
-
+
ostream_joiner(ostream_type& s, const DelimT& delimiter);
ostream_joiner(ostream_type& s, DelimT&& delimiter);
- template<typename T>
+ template<typename T>
ostream_joiner& operator=(const T& value);
ostream_joiner& operator*() noexcept;
ostream_joiner& operator++() noexcept;
ostream_joiner& operator++(int) noexcept;
private:
- ostream_type* out_stream; // exposition only
- DelimT delim; // exposition only
+ ostream_type* out_stream; // exposition only
+ DelimT delim; // exposition only
bool first_element; // exposition only
};
@@ -78,11 +78,11 @@ public:
ostream_joiner(ostream_type& __os, _Delim&& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
-
+
ostream_joiner(ostream_type& __os, const _Delim& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
-
+
template<typename _Tp>
ostream_joiner& operator=(const _Tp& __v)
{
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits
index a5e554b34a..ea1335f96a 100644
--- a/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits
+++ b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits
@@ -60,7 +60,7 @@ inline namespace fundamentals_v1 {
using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>;
template <class To, template<class...> class Op, class... Args>
constexpr bool is_detected_convertible_v
- = is_detected_convertible<To, Op, Args...>::value;
+ = is_detected_convertible<To, Op, Args...>::value;
} // namespace fundamentals_v1
} // namespace experimental
@@ -106,9 +106,9 @@ using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
template <class...> using void_t = void;
struct nonesuch : private __nat { // make nonesuch "not an aggregate"
- ~nonesuch() = delete;
- nonesuch (nonesuch const&) = delete;
- void operator=(nonesuch const&) = delete;
+ ~nonesuch() = delete;
+ nonesuch (nonesuch const&) = delete;
+ void operator=(nonesuch const&) = delete;
};
template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
@@ -123,7 +123,7 @@ struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
using type = _Op<_Args...>;
};
-
+
template <template<class...> class _Op, class... _Args>
using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
template <template<class...> class _Op, class... _Args>
@@ -144,7 +144,7 @@ template <class Expected, template<class...> class _Op, class... _Args>
template <class To, template<class...> class _Op, class... _Args>
using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>;
template <class To, template<class...> class _Op, class... _Args>
- _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
+ _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
_LIBCPP_END_NAMESPACE_LFTS
diff --git a/contrib/libs/cxxsupp/libcxx/include/ext/hash_map b/contrib/libs/cxxsupp/libcxx/include/ext/hash_map
index 067f4a1ada..60e32b09e3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/ext/hash_map
+++ b/contrib/libs/cxxsupp/libcxx/include/ext/hash_map
@@ -46,10 +46,10 @@ public:
template <class InputIterator>
hash_map(InputIterator f, InputIterator l);
template <class InputIterator>
- hash_map(InputIterator f, InputIterator l,
+ hash_map(InputIterator f, InputIterator l,
size_type n, const hasher& hf = hasher(),
- const key_equal& eql = key_equal(),
- const allocator_type& a = allocator_type());
+ const key_equal& eql = key_equal(),
+ const allocator_type& a = allocator_type());
hash_map(const hash_map&);
~hash_map();
hash_map& operator=(const hash_map&);
@@ -395,10 +395,10 @@ public:
return __t;
}
- friend _LIBCPP_INLINE_VISIBILITY
+ friend _LIBCPP_INLINE_VISIBILITY
bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ == __y.__i_;}
- friend _LIBCPP_INLINE_VISIBILITY
+ friend _LIBCPP_INLINE_VISIBILITY
bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ != __y.__i_;}
diff --git a/contrib/libs/cxxsupp/libcxx/include/ext/hash_set b/contrib/libs/cxxsupp/libcxx/include/ext/hash_set
index d1fecdd111..af3f9c5de0 100644
--- a/contrib/libs/cxxsupp/libcxx/include/ext/hash_set
+++ b/contrib/libs/cxxsupp/libcxx/include/ext/hash_set
@@ -607,7 +607,7 @@ template <class _InputIterator>
inline
void
hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
- _InputIterator __last)
+ _InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_multi(*__first);
diff --git a/contrib/libs/cxxsupp/libcxx/include/forward_list b/contrib/libs/cxxsupp/libcxx/include/forward_list
index 4273c2750b..3454a784a1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/forward_list
+++ b/contrib/libs/cxxsupp/libcxx/include/forward_list
@@ -604,7 +604,7 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
- _VSTD::__swap_allocator(__alloc(), __x.__alloc(),
+ _VSTD::__swap_allocator(__alloc(), __x.__alloc(),
integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
using _VSTD::swap;
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
diff --git a/contrib/libs/cxxsupp/libcxx/include/future b/contrib/libs/cxxsupp/libcxx/include/future
index 4761a1747d..89acdba62b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/future
+++ b/contrib/libs/cxxsupp/libcxx/include/future
@@ -628,10 +628,10 @@ protected:
public:
template <class _Arg>
- void set_value(_Arg&& __arg);
+ void set_value(_Arg&& __arg);
template <class _Arg>
- void set_value_at_thread_exit(_Arg&& __arg);
+ void set_value_at_thread_exit(_Arg&& __arg);
_Rp move();
typename add_lvalue_reference<_Rp>::type copy();
@@ -1887,7 +1887,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -1898,7 +1898,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -2016,7 +2016,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -2027,11 +2027,11 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
- >
+ >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
diff --git a/contrib/libs/cxxsupp/libcxx/include/inttypes.h b/contrib/libs/cxxsupp/libcxx/include/inttypes.h
index 9b6e8eb4f1..6f8021263e 100644
--- a/contrib/libs/cxxsupp/libcxx/include/inttypes.h
+++ b/contrib/libs/cxxsupp/libcxx/include/inttypes.h
@@ -248,7 +248,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
# define __STDC_FORMAT_MACROS
#endif
-#ifdef _LIBCPP_COMPILER_MSVC
+#ifdef _LIBCPP_COMPILER_MSVC
#include _LIBCPP_UCRT_INCLUDE(inttypes.h)
#else
#include_next <inttypes.h>
diff --git a/contrib/libs/cxxsupp/libcxx/include/ios b/contrib/libs/cxxsupp/libcxx/include/ios
index 555d34f4fe..c9230d6a94 100644
--- a/contrib/libs/cxxsupp/libcxx/include/ios
+++ b/contrib/libs/cxxsupp/libcxx/include/ios
@@ -202,8 +202,8 @@ enum class io_errc
};
concept_map ErrorCodeEnum<io_errc> { };
-error_code make_error_code(io_errc e) noexcept;
-error_condition make_error_condition(io_errc e) noexcept;
+error_code make_error_code(io_errc e) noexcept;
+error_condition make_error_condition(io_errc e) noexcept;
storage-class-specifier const error_category& iostream_category() noexcept;
} // std
@@ -635,45 +635,45 @@ public:
virtual ~basic_ios();
// 27.5.4.2 Members:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
basic_ios& copyfmt(const basic_ios& __rhs);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type fill() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type fill(char_type __ch);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
locale imbue(const locale& __loc);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char narrow(char_type __c, char __dfault) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type widen(char __c) const;
protected:
_LIBCPP_INLINE_VISIBILITY
basic_ios() {// purposefully does no initialization
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void init(basic_streambuf<char_type, traits_type>* __sb);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void move(basic_ios& __rhs);
_LIBCPP_INLINE_VISIBILITY
void move(basic_ios&& __rhs) {move(__rhs);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void swap(basic_ios& __rhs) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
private:
basic_ostream<char_type, traits_type>* __tie_;
diff --git a/contrib/libs/cxxsupp/libcxx/include/istream b/contrib/libs/cxxsupp/libcxx/include/istream
index bf8c066dc6..6fb296f820 100644
--- a/contrib/libs/cxxsupp/libcxx/include/istream
+++ b/contrib/libs/cxxsupp/libcxx/include/istream
@@ -359,16 +359,16 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
if (__s)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
@@ -468,8 +468,8 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
if (__s)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
@@ -488,18 +488,18 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
else
{
__n = static_cast<_Tp>(__temp);
- }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
}
- catch (...)
- {
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
__is.setstate(__state);
}
@@ -526,9 +526,9 @@ basic_istream<_CharT, _Traits>&
__input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
{
ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
- {
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -554,9 +554,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
if (__s == __p)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
@@ -635,9 +635,9 @@ basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
{
ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
- {
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -648,9 +648,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
else
__c = _Traits::to_char_type(__i);
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
@@ -686,38 +686,38 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
{
ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
- sentry __s(*this, true);
- if (__s)
- {
- if (__sb)
+ sentry __s(*this, true);
+ if (__s)
+ {
+ if (__sb)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- while (true)
+#endif // _LIBCPP_NO_EXCEPTIONS
+ while (true)
{
- typename traits_type::int_type __i = this->rdbuf()->sgetc();
- if (traits_type::eq_int_type(__i, _Traits::eof()))
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, _Traits::eof()))
{
__state |= ios_base::eofbit;
- break;
+ break;
}
- if (traits_type::eq_int_type(
- __sb->sputc(traits_type::to_char_type(__i)),
- traits_type::eof()))
- break;
- ++__gc_;
- this->rdbuf()->sbumpc();
- }
- if (__gc_ == 0)
+ if (traits_type::eq_int_type(
+ __sb->sputc(traits_type::to_char_type(__i)),
+ traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
+ }
+ if (__gc_ == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
- if (__gc_ == 0)
+ if (__gc_ == 0)
__state |= ios_base::failbit;
this->__setstate_nothrow(__state);
@@ -725,11 +725,11 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
- }
- else
- {
+ }
+ else
+ {
__state |= ios_base::failbit;
}
this->setstate(__state);
@@ -744,9 +744,9 @@ basic_istream<_CharT, _Traits>::get()
ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
int_type __r = traits_type::eof();
- sentry __s(*this, true);
- if (__s)
- {
+ sentry __s(*this, true);
+ if (__s)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -757,9 +757,9 @@ basic_istream<_CharT, _Traits>::get()
else
__gc_ = 1;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
this->__setstate_nothrow(this->rdstate() | ios_base::badbit);
if (this->exceptions() & ios_base::badbit)
{
@@ -778,10 +778,10 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
{
ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
- sentry __sen(*this, true);
- if (__sen)
- {
- if (__n > 0)
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+ if (__n > 0)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
@@ -805,22 +805,22 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
if (__gc_ == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
+ }
catch (...)
{
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
- if (__n > 0)
- *__s = char_type();
+ if (__n > 0)
+ *__s = char_type();
throw;
- }
+ }
}
#endif
}
else
- {
+ {
__state |= ios_base::failbit;
}
@@ -840,41 +840,41 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
{
ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
- sentry __sen(*this, true);
- if (__sen)
- {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
+ {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
#endif // _LIBCPP_NO_EXCEPTIONS
- while (true)
+ while (true)
{
- typename traits_type::int_type __i = this->rdbuf()->sgetc();
- if (traits_type::eq_int_type(__i, traits_type::eof()))
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
{
__state |= ios_base::eofbit;
- break;
+ break;
}
- char_type __ch = traits_type::to_char_type(__i);
- if (traits_type::eq(__ch, __dlm))
- break;
- if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
- break;
- ++__gc_;
- this->rdbuf()->sbumpc();
- }
+ char_type __ch = traits_type::to_char_type(__i);
+ if (traits_type::eq(__ch, __dlm))
+ break;
+ if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
+ }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
// according to the spec, exceptions here are caught but not rethrown
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
- if (__gc_ == 0)
+ if (__gc_ == 0)
__state |= ios_base::failbit;
this->setstate(__state);
- }
+ }
return *this;
}
@@ -888,8 +888,8 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
while (true)
{
@@ -916,20 +916,20 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
++__gc_;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
- if (__n > 0)
- *__s = char_type();
+ if (__n > 0)
+ *__s = char_type();
if (__gc_ == 0)
__state |= ios_base::failbit;
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
}
if (__n > 0)
@@ -950,8 +950,8 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (__n == numeric_limits<streamsize>::max())
{
@@ -984,16 +984,16 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
}
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1011,23 +1011,23 @@ basic_istream<_CharT, _Traits>::peek()
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
__r = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
__state |= ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1044,23 +1044,23 @@ basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
__gc_ = this->rdbuf()->sgetn(__s, __n);
if (__gc_ != __n)
__state |= ios_base::failbit | ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
}
else
@@ -1081,8 +1081,8 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
streamsize __c = this->rdbuf()->in_avail();
switch (__c)
@@ -1100,16 +1100,16 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
break;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
}
else
@@ -1131,22 +1131,22 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
}
else
@@ -1168,22 +1168,22 @@ basic_istream<_CharT, _Traits>::unget()
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
}
else
@@ -1204,8 +1204,8 @@ basic_istream<_CharT, _Traits>::sync()
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr)
return -1;
@@ -1215,16 +1215,16 @@ basic_istream<_CharT, _Traits>::sync()
return -1;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1241,21 +1241,21 @@ basic_istream<_CharT, _Traits>::tellg()
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
- __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
+ __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1272,22 +1272,22 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1304,22 +1304,22 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
if (this->exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
@@ -1335,8 +1335,8 @@ ws(basic_istream<_CharT, _Traits>& __is)
if (__sen)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
while (true)
@@ -1352,16 +1352,16 @@ ws(basic_istream<_CharT, _Traits>& __is)
__is.rdbuf()->sbumpc();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
{
throw;
}
- }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
__is.setstate(__state);
}
@@ -1445,9 +1445,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
- {
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -1479,9 +1479,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
if (__c == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
@@ -1501,9 +1501,9 @@ getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
- if (__sen)
- {
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+ if (__sen)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -1532,9 +1532,9 @@ getline(basic_istream<_CharT, _Traits>& __is,
if (__extr == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
@@ -1580,9 +1580,9 @@ basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
ios_base::iostate __state = ios_base::goodbit;
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
- {
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
+ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -1611,9 +1611,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
if (_Size > 0 && __c == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ }
+ catch (...)
+ {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
if (__is.exceptions() & ios_base::badbit)
diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list
index 8c6c95a04a..71406c6743 100644
--- a/contrib/libs/cxxsupp/libcxx/include/list
+++ b/contrib/libs/cxxsupp/libcxx/include/list
@@ -2021,22 +2021,22 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__c.__sz() = 0;
#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- --__ip;
- iterator* __i = static_cast<iterator*>((*__ip)->__i_);
- if (__i->__ptr_ != __c.__end_as_link())
- {
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
- }
+ --__ip;
+ iterator* __i = static_cast<iterator*>((*__ip)->__i_);
+ if (__i->__ptr_ != __c.__end_as_link())
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
- __db->unlock();
+ __db->unlock();
}
#endif
}
@@ -2066,22 +2066,22 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
++base::__sz();
#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- --__ip;
- iterator* __j = static_cast<iterator*>((*__ip)->__i_);
- if (__j->__ptr_ == __f)
- {
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
- }
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ if (__j->__ptr_ == __f)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
- __db->unlock();
+ __db->unlock();
}
#endif
}
@@ -2125,26 +2125,26 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
__link_nodes(__p.__ptr_, __first, __last);
#if _LIBCPP_DEBUG_LEVEL == 2
if (&__c != this) {
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- --__ip;
- iterator* __j = static_cast<iterator*>((*__ip)->__i_);
- for (__link_pointer __k = __f.__ptr_;
- __k != __l.__ptr_; __k = __k->__next_)
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ for (__link_pointer __k = __f.__ptr_;
+ __k != __l.__ptr_; __k = __k->__next_)
{
- if (__j->__ptr_ == __k)
- {
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
- }
+ if (__j->__ptr_ == __k)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
}
- __db->unlock();
+ __db->unlock();
}
#endif
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale
index 29fc1acd27..242790a9d4 100644
--- a/contrib/libs/cxxsupp/libcxx/include/locale
+++ b/contrib/libs/cxxsupp/libcxx/include/locale
@@ -891,7 +891,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
typedef typename numpunct<_CharT>::string_type string_type;
const string_type __names[2] = {__np.truename(), __np.falsename()};
const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,
- __ct, __err);
+ __ct, __err);
__v = __i == __names;
return __b;
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/locale.h b/contrib/libs/cxxsupp/libcxx/include/locale.h
index f3f0eccacf..52c452001d 100644
--- a/contrib/libs/cxxsupp/libcxx/include/locale.h
+++ b/contrib/libs/cxxsupp/libcxx/include/locale.h
@@ -40,7 +40,7 @@ Functions:
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
+# pragma GCC system_header
#endif
#ifdef _LIBCPP_COMPILER_MSVC
diff --git a/contrib/libs/cxxsupp/libcxx/include/map b/contrib/libs/cxxsupp/libcxx/include/map
index 4ecf3954d1..c78a7ee31a 100644
--- a/contrib/libs/cxxsupp/libcxx/include/map
+++ b/contrib/libs/cxxsupp/libcxx/include/map
@@ -1301,7 +1301,7 @@ public:
__r->__get_value().second = _VSTD::forward<_Vp>(__v);
return __r;
- }
+ }
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY iterator insert_or_assign(const_iterator __h,
@@ -1314,7 +1314,7 @@ public:
__r->__get_value().second = _VSTD::forward<_Vp>(__v);
return __r;
- }
+ }
#endif // _LIBCPP_STD_VER > 14
diff --git a/contrib/libs/cxxsupp/libcxx/include/memory b/contrib/libs/cxxsupp/libcxx/include/memory
index 0633f1fc3a..1975092ba0 100644
--- a/contrib/libs/cxxsupp/libcxx/include/memory
+++ b/contrib/libs/cxxsupp/libcxx/include/memory
@@ -122,7 +122,7 @@ public:
typedef typename add_lvalue_reference<const T>::type
const_reference; // deprecated in C++17, removed in C++20
- typedef T value_type;
+ typedef T value_type;
template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
@@ -342,7 +342,7 @@ public:
pointer release() noexcept;
void reset(pointer p = pointer()) noexcept;
void reset(nullptr_t) noexcept;
- template <class U> void reset(U) = delete;
+ template <class U> void reset(U) = delete;
void swap(unique_ptr& u) noexcept;
};
@@ -567,7 +567,7 @@ template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
template<class T> struct owner_less;
template<class T>
-struct owner_less<shared_ptr<T> >
+struct owner_less<shared_ptr<T> >
: binary_function<shared_ptr<T>, shared_ptr<T>, bool>
{
typedef bool result_type;
@@ -577,7 +577,7 @@ struct owner_less<shared_ptr<T> >
};
template<class T>
-struct owner_less<weak_ptr<T> >
+struct owner_less<weak_ptr<T> >
: binary_function<weak_ptr<T>, weak_ptr<T>, bool>
{
typedef bool result_type;
diff --git a/contrib/libs/cxxsupp/libcxx/include/mutex b/contrib/libs/cxxsupp/libcxx/include/mutex
index a2edfa4240..e815dda502 100644
--- a/contrib/libs/cxxsupp/libcxx/include/mutex
+++ b/contrib/libs/cxxsupp/libcxx/include/mutex
@@ -580,14 +580,14 @@ struct _LIBCPP_TEMPLATE_VIS once_flag
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
once_flag() _NOEXCEPT : __state_(0) {}
-
+
#if defined(_LIBCPP_ABI_MICROSOFT)
- typedef uintptr_t _State_type;
+ typedef uintptr_t _State_type;
#else
- typedef unsigned long _State_type;
+ typedef unsigned long _State_type;
#endif
-
+
private:
once_flag(const once_flag&); // = delete;
once_flag& operator=(const once_flag&); // = delete;
@@ -668,10 +668,10 @@ __call_once_proxy(void* __vp)
#ifdef _LIBCPP_ABI_MICROSOFT
_LIBCPP_FUNC_VIS void __call_once(volatile atomic<once_flag::_State_type>&, void*,
- void (*)(void*));
+ void (*)(void*));
#else
_LIBCPP_FUNC_VIS void __call_once(volatile once_flag::_State_type&, void*,
- void (*)(void*));
+ void (*)(void*));
#endif
#ifndef _LIBCPP_CXX03_LANG
diff --git a/contrib/libs/cxxsupp/libcxx/include/numeric b/contrib/libs/cxxsupp/libcxx/include/numeric
index e4ab8e70f0..8ea7ecc375 100644
--- a/contrib/libs/cxxsupp/libcxx/include/numeric
+++ b/contrib/libs/cxxsupp/libcxx/include/numeric
@@ -368,7 +368,7 @@ _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
for (; __first != __last; ++__first, (void) ++__result) {
__init = __b(__init, *__first);
*__result = __init;
- }
+ }
return __result;
}
@@ -382,7 +382,7 @@ _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
*__result++ = __init;
if (++__first != __last)
return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
- }
+ }
return __result;
}
@@ -442,7 +442,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
*__result++ = __init;
if (++__first != __last)
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
- }
+ }
return __result;
}
@@ -513,9 +513,9 @@ struct __ct_abs<_Result, _Source, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept
{
- if (__t >= 0) return __t;
- if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
- return -__t;
+ if (__t >= 0) return __t;
+ if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
+ return -__t;
}
};
@@ -614,8 +614,8 @@ _LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<is_floating_point_v<_Fp>, _Fp>
midpoint(_Fp __a, _Fp __b) noexcept
{
- constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
- constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
+ constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
+ constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible
(__a + __b)/2 : // always correctly rounded
__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
diff --git a/contrib/libs/cxxsupp/libcxx/include/optional b/contrib/libs/cxxsupp/libcxx/include/optional
index a99ccae0e9..0f6d233051 100644
--- a/contrib/libs/cxxsupp/libcxx/include/optional
+++ b/contrib/libs/cxxsupp/libcxx/include/optional
@@ -321,7 +321,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
#if _LIBCPP_STD_VER > 17
_VSTD::construct_at(_VSTD::addressof(this->__val_), _VSTD::forward<_Args>(__args)...);
#else
- ::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
+ ::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
#endif
this->__engaged_ = true;
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/queue b/contrib/libs/cxxsupp/libcxx/include/queue
index 834115900e..cbd07140a7 100644
--- a/contrib/libs/cxxsupp/libcxx/include/queue
+++ b/contrib/libs/cxxsupp/libcxx/include/queue
@@ -70,8 +70,8 @@ public:
template<class Container>
queue(Container) -> queue<typename Container::value_type, Container>; // C++17
-
-template<class Container, class Allocator>
+
+template<class Container, class Allocator>
queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
template <class T, class Container>
@@ -170,13 +170,13 @@ public:
template <class Compare, class Container>
priority_queue(Compare, Container)
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
-
-template<class InputIterator,
+
+template<class InputIterator,
class Compare = less<iter-value-type<InputIterator>>,
class Container = vector<iter-value-type<InputIterator>>>
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
-> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
-
+
template<class Compare, class Container, class Allocator>
priority_queue(Compare, Container, Allocator)
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
@@ -364,7 +364,7 @@ template<class _Container,
>
queue(_Container)
-> queue<typename _Container::value_type, _Container>;
-
+
template<class _Container,
class _Alloc,
class = enable_if_t<!__is_allocator<_Container>::value>,
@@ -592,8 +592,8 @@ template <class _Compare,
>
priority_queue(_Compare, _Container)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
-
-template<class _InputIterator,
+
+template<class _InputIterator,
class _Compare = less<__iter_value_type<_InputIterator>>,
class _Container = vector<__iter_value_type<_InputIterator>>,
class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
@@ -602,8 +602,8 @@ template<class _InputIterator,
>
priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
-> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
-
-template<class _Compare,
+
+template<class _Compare,
class _Container,
class _Alloc,
class = enable_if_t<!__is_allocator<_Compare>::value>,
diff --git a/contrib/libs/cxxsupp/libcxx/include/random b/contrib/libs/cxxsupp/libcxx/include/random
index e7ca4a9aa8..1320250897 100644
--- a/contrib/libs/cxxsupp/libcxx/include/random
+++ b/contrib/libs/cxxsupp/libcxx/include/random
@@ -6701,7 +6701,7 @@ public:
template<class _UnaryOperation>
param_type(size_t __nw, result_type __xmin, result_type __xmax,
_UnaryOperation __fw);
- param_type(param_type const&) = default;
+ param_type(param_type const&) = default;
param_type & operator=(const param_type& __rhs);
_LIBCPP_INLINE_VISIBILITY
diff --git a/contrib/libs/cxxsupp/libcxx/include/regex b/contrib/libs/cxxsupp/libcxx/include/regex
index a75e04fea1..c0d1edac5e 100644
--- a/contrib/libs/cxxsupp/libcxx/include/regex
+++ b/contrib/libs/cxxsupp/libcxx/include/regex
@@ -171,14 +171,14 @@ public:
// assign:
basic_regex& assign(const basic_regex& that);
basic_regex& assign(basic_regex&& that) noexcept;
- basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+ basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
template <class string_traits, class A>
basic_regex& assign(const basic_string<charT, string_traits, A>& s,
- flag_type f = regex_constants::ECMAScript);
+ flag_type f = regex_constants::ECMAScript);
template <class InputIterator>
basic_regex& assign(InputIterator first, InputIterator last,
- flag_type f = regex_constants::ECMAScript);
+ flag_type f = regex_constants::ECMAScript);
basic_regex& assign(initializer_list<charT>, flag_type f = regex_constants::ECMAScript);
// const operations:
@@ -702,7 +702,7 @@ typedef regex_iterator<string::const_iterator> sregex_iterator;
typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
template <class BidirectionalIterator,
- class charT = typename iterator_traits<BidirectionalIterator>::value_type,
+ class charT = typename iterator_traits<BidirectionalIterator>::value_type,
class traits = regex_traits<charT>>
class regex_token_iterator
{
diff --git a/contrib/libs/cxxsupp/libcxx/include/set b/contrib/libs/cxxsupp/libcxx/include/set
index 6354765c10..46b515ba53 100644
--- a/contrib/libs/cxxsupp/libcxx/include/set
+++ b/contrib/libs/cxxsupp/libcxx/include/set
@@ -156,7 +156,7 @@ public:
const_iterator find(const K& x) const; // C++14
template<typename K>
- size_type count(const K& x) const; // C++14
+ size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
bool contains(const key_type& x) const; // C++20
diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span
index eb1aff44c0..5d57bd693c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/span
+++ b/contrib/libs/cxxsupp/libcxx/include/span
@@ -104,7 +104,7 @@ public:
constexpr reverse_iterator rend() const noexcept;
private:
- pointer data_; // exposition only
+ pointer data_; // exposition only
size_type size_; // exposition only
};
@@ -321,7 +321,7 @@ public:
template <size_t _Count>
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, _Count> first() const noexcept
+ constexpr span<element_type, _Count> first() const noexcept
{
static_assert(_Count <= _Extent, "Count out of range in span::first()");
return span<element_type, _Count>{data(), _Count};
@@ -329,7 +329,7 @@ public:
template <size_t _Count>
_LIBCPP_INLINE_VISIBILITY
- constexpr span<element_type, _Count> last() const noexcept
+ constexpr span<element_type, _Count> last() const noexcept
{
static_assert(_Count <= _Extent, "Count out of range in span::last()");
return span<element_type, _Count>{data() + size() - _Count, _Count};
@@ -351,7 +351,7 @@ public:
template <size_t _Offset, size_t _Count = dynamic_extent>
_LIBCPP_INLINE_VISIBILITY
- constexpr auto subspan() const noexcept
+ constexpr auto subspan() const noexcept
-> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
{
static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()");
@@ -376,7 +376,7 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; }
_LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
+ _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
@@ -469,17 +469,17 @@ public:
template <size_t _Sz>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
+ constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
template <class _OtherElementType, size_t _Sz,
enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+ constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
template <class _OtherElementType, size_t _Sz,
enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr>
_LIBCPP_INLINE_VISIBILITY
- constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
+ constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
#if !defined(_LIBCPP_HAS_NO_RANGES)
template <__span_compatible_range<element_type> _Range>
@@ -562,7 +562,7 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }
_LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
+ _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
@@ -596,7 +596,7 @@ public:
inline _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept;
private:
- pointer __data;
+ pointer __data;
size_type __size;
};
@@ -621,7 +621,7 @@ template <class _Tp, size_t _Extent>
_LIBCPP_INLINE_VISIBILITY
auto as_bytes(span<_Tp, _Extent> __s) noexcept
-> decltype(__s.__as_bytes())
-{ return __s.__as_bytes(); }
+{ return __s.__as_bytes(); }
template <class _Tp, size_t _Extent>
_LIBCPP_INLINE_VISIBILITY
diff --git a/contrib/libs/cxxsupp/libcxx/include/sstream b/contrib/libs/cxxsupp/libcxx/include/sstream
index a130aa97d7..fbe5ffcab4 100644
--- a/contrib/libs/cxxsupp/libcxx/include/sstream
+++ b/contrib/libs/cxxsupp/libcxx/include/sstream
@@ -256,7 +256,7 @@ protected:
virtual pos_type seekpos(pos_type __sp,
ios_base::openmode __wch = ios_base::in | ios_base::out) {
return seekoff(__sp, ios_base::beg, __wch);
- }
+ }
};
template <class _CharT, class _Traits, class _Allocator>
@@ -656,31 +656,31 @@ public:
basic_istringstream(basic_istringstream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
, __sb_(_VSTD::move(__rhs.__sb_))
- {
- basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
- }
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
// 27.8.2.2 Assign and swap:
basic_istringstream& operator=(basic_istringstream&& __rhs) {
- basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
- }
+ basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
void swap(basic_istringstream& __rhs) {
- basic_istream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
- }
+ basic_istream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
// 27.8.2.3 Members:
_LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
- }
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
_LIBCPP_INLINE_VISIBILITY
string_type str() const {
- return __sb_.str();
- }
+ return __sb_.str();
+ }
_LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s) {
__sb_.str(__s);
@@ -736,32 +736,32 @@ public:
basic_ostringstream(basic_ostringstream&& __rhs)
: basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs))
, __sb_(_VSTD::move(__rhs.__sb_))
- {
- basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
- }
+ {
+ basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
// 27.8.2.2 Assign and swap:
basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
- basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
- }
+ basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
void swap(basic_ostringstream& __rhs) {
- basic_ostream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
- }
+ basic_ostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
// 27.8.2.3 Members:
_LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
- }
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
_LIBCPP_INLINE_VISIBILITY
string_type str() const {
- return __sb_.str();
- }
+ return __sb_.str();
+ }
_LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s) {
__sb_.str(__s);
@@ -817,31 +817,31 @@ public:
basic_stringstream(basic_stringstream&& __rhs)
: basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs))
, __sb_(_VSTD::move(__rhs.__sb_))
- {
- basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
- }
+ {
+ basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+ }
// 27.8.2.2 Assign and swap:
basic_stringstream& operator=(basic_stringstream&& __rhs) {
- basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
- __sb_ = _VSTD::move(__rhs.__sb_);
- return *this;
- }
+ basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+ __sb_ = _VSTD::move(__rhs.__sb_);
+ return *this;
+ }
_LIBCPP_INLINE_VISIBILITY
void swap(basic_stringstream& __rhs) {
- basic_iostream<char_type, traits_type>::swap(__rhs);
- __sb_.swap(__rhs.__sb_);
- }
+ basic_iostream<char_type, traits_type>::swap(__rhs);
+ __sb_.swap(__rhs.__sb_);
+ }
// 27.8.2.3 Members:
_LIBCPP_INLINE_VISIBILITY
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
- return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
- }
+ return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+ }
_LIBCPP_INLINE_VISIBILITY
string_type str() const {
- return __sb_.str();
- }
+ return __sb_.str();
+ }
_LIBCPP_INLINE_VISIBILITY
void str(const string_type& __s) {
__sb_.str(__s);
diff --git a/contrib/libs/cxxsupp/libcxx/include/stack b/contrib/libs/cxxsupp/libcxx/include/stack
index 866fbd6b83..436993c6f3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/stack
+++ b/contrib/libs/cxxsupp/libcxx/include/stack
@@ -62,8 +62,8 @@ public:
template<class Container>
stack(Container) -> stack<typename Container::value_type, Container>; // C++17
-
-template<class Container, class Allocator>
+
+template<class Container, class Allocator>
stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
template <class T, class Container>
@@ -120,7 +120,7 @@ public:
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
static_assert((is_same<_Tp, value_type>::value), "" );
-
+
protected:
container_type c;
@@ -237,12 +237,12 @@ template<class _Container,
>
stack(_Container)
-> stack<typename _Container::value_type, _Container>;
-
+
template<class _Container,
class _Alloc,
class = enable_if_t<!__is_allocator<_Container>::value>,
class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
- >
+ >
stack(_Container, _Alloc)
-> stack<typename _Container::value_type, _Container>;
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string
index 1a951b9d25..4f3309fea9 100644
--- a/contrib/libs/cxxsupp/libcxx/include/string
+++ b/contrib/libs/cxxsupp/libcxx/include/string
@@ -880,7 +880,7 @@ public:
template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
basic_string(const _Tp& __t, size_type __pos, size_type __n,
- const allocator_type& __a = allocator_type());
+ const allocator_type& __a = allocator_type());
template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
!__is_same_uncvref<_Tp, basic_string>::value> >
@@ -2379,18 +2379,18 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::__assign_external(
const value_type* __s, size_type __n) {
- size_type __cap = capacity();
+ size_type __cap = capacity();
if (__cap >= __n) {
- value_type* __p = _VSTD::__to_address(__get_pointer());
- traits_type::move(__p, __s, __n);
- traits_type::assign(__p[__n], value_type());
- __set_size(__n);
- __invalidate_iterators_past(__n);
+ value_type* __p = _VSTD::__to_address(__get_pointer());
+ traits_type::move(__p, __s, __n);
+ traits_type::assign(__p[__n], value_type());
+ __set_size(__n);
+ __invalidate_iterators_past(__n);
} else {
- size_type __sz = size();
- __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
- }
- return *this;
+ size_type __sz = size();
+ __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
+ }
+ return *this;
}
template <class _CharT, class _Traits, class _Allocator>
@@ -2495,7 +2495,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
}
#endif
}
- __move_assign_alloc(__str);
+ __move_assign_alloc(__str);
__r_.first() = __str.__r_.first();
__str.__set_short_size(0);
traits_type::assign(__str.__get_short_pointer()[0], value_type());
@@ -3219,7 +3219,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
} else {
__erase_external_with_move(__pos, __n);
}
- return *this;
+ return *this;
}
template <class _CharT, class _Traits, class _Allocator>
@@ -3386,55 +3386,55 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
size_type __cap = capacity();
size_type __sz = size();
- pointer __new_data, __p;
- bool __was_long, __now_long;
+ pointer __new_data, __p;
+ bool __was_long, __now_long;
if (__target_capacity == __min_cap - 1)
- {
- __was_long = true;
- __now_long = false;
- __new_data = __get_short_pointer();
- __p = __get_long_pointer();
- }
- else
- {
- if (__target_capacity > __cap)
- __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
+ {
+ __was_long = true;
+ __now_long = false;
+ __new_data = __get_short_pointer();
+ __p = __get_long_pointer();
+ }
+ else
+ {
+ if (__target_capacity > __cap)
+ __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
else
{
- #ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ #ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
#endif // _LIBCPP_NO_EXCEPTIONS
__new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
- #ifndef _LIBCPP_NO_EXCEPTIONS
+ #ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ return;
}
- catch (...)
- {
- return;
- }
- #else // _LIBCPP_NO_EXCEPTIONS
- if (__new_data == nullptr)
- return;
+ #else // _LIBCPP_NO_EXCEPTIONS
+ if (__new_data == nullptr)
+ return;
#endif // _LIBCPP_NO_EXCEPTIONS
}
- __now_long = true;
- __was_long = __is_long();
- __p = __get_pointer();
- }
- traits_type::copy(_VSTD::__to_address(__new_data),
- _VSTD::__to_address(__p), size()+1);
- if (__was_long)
- __alloc_traits::deallocate(__alloc(), __p, __cap+1);
- if (__now_long)
- {
+ __now_long = true;
+ __was_long = __is_long();
+ __p = __get_pointer();
+ }
+ traits_type::copy(_VSTD::__to_address(__new_data),
+ _VSTD::__to_address(__p), size()+1);
+ if (__was_long)
+ __alloc_traits::deallocate(__alloc(), __p, __cap+1);
+ if (__now_long)
+ {
__set_long_cap(__target_capacity+1);
- __set_long_size(__sz);
- __set_long_pointer(__new_data);
+ __set_long_size(__sz);
+ __set_long_pointer(__new_data);
}
- else
- __set_short_size(__sz);
- __invalidate_all_iterators();
-}
+ else
+ __set_short_size(__sz);
+ __invalidate_all_iterators();
+}
template <class _CharT, class _Traits, class _Allocator>
inline
@@ -4458,8 +4458,8 @@ _LIBCPP_FUNC_VIS wstring to_wstring(long double __val);
template<class _CharT, class _Traits, class _Allocator>
_LIBCPP_TEMPLATE_DATA_VIS
-const typename basic_string<_CharT, _Traits, _Allocator>::size_type
- basic_string<_CharT, _Traits, _Allocator>::npos;
+const typename basic_string<_CharT, _Traits, _Allocator>::size_type
+ basic_string<_CharT, _Traits, _Allocator>::npos;
template <class _CharT, class _Allocator>
struct _LIBCPP_TEMPLATE_VIS
@@ -4507,7 +4507,7 @@ getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str);
#if _LIBCPP_STD_VER > 17
-template <class _CharT, class _Traits, class _Allocator, class _Up>
+template <class _CharT, class _Traits, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_string<_CharT, _Traits, _Allocator>::size_type
erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
@@ -4516,7 +4516,7 @@ inline _LIBCPP_INLINE_VISIBILITY
return __old_size - __str.size();
}
-template <class _CharT, class _Traits, class _Allocator, class _Predicate>
+template <class _CharT, class _Traits, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_string<_CharT, _Traits, _Allocator>::size_type
erase_if(basic_string<_CharT, _Traits, _Allocator>& __str,
diff --git a/contrib/libs/cxxsupp/libcxx/include/tuple b/contrib/libs/cxxsupp/libcxx/include/tuple
index 714d289b84..9b127953b3 100644
--- a/contrib/libs/cxxsupp/libcxx/include/tuple
+++ b/contrib/libs/cxxsupp/libcxx/include/tuple
@@ -308,7 +308,7 @@ public:
_And<
_IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
is_constructible<_Hp, _Tp>
- >::value
+ >::value
>
>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -1202,8 +1202,8 @@ template <class _T1, class ..._Args>
struct __find_exactly_one_checked {
static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
static constexpr size_t value = __find_detail::__find_idx(0, __matches);
- static_assert(value != __not_found, "type not found in type list" );
- static_assert(value != __ambiguous, "type occurs more than once in type list");
+ static_assert(value != __not_found, "type not found in type list" );
+ static_assert(value != __ambiguous, "type occurs more than once in type list");
};
template <class _T1>
@@ -1489,7 +1489,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
{
return _VSTD::forward_as_tuple(
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
- _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
+ _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
@@ -1507,7 +1507,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
_VSTD::forward_as_tuple(
- _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+ _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
_VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/type_traits b/contrib/libs/cxxsupp/libcxx/include/type_traits
index 258fdcc667..8c91522074 100644
--- a/contrib/libs/cxxsupp/libcxx/include/type_traits
+++ b/contrib/libs/cxxsupp/libcxx/include/type_traits
@@ -160,7 +160,7 @@ namespace std
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
struct aligned_storage;
template <size_t Len, class... Types> struct aligned_union;
- template <class T> struct remove_cvref; // C++20
+ template <class T> struct remove_cvref; // C++20
template <class T> struct decay;
template <class... T> struct common_type;
@@ -4188,7 +4188,7 @@ struct __can_extract_key
__extract_key_fail_tag>::type {};
template <class _Pair, class _Key, class _First, class _Second>
-struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
: conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
__extract_key_first_tag, __extract_key_fail_tag>::type {};
diff --git a/contrib/libs/cxxsupp/libcxx/include/typeinfo b/contrib/libs/cxxsupp/libcxx/include/typeinfo
index e8908cb91d..80c938646b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/typeinfo
+++ b/contrib/libs/cxxsupp/libcxx/include/typeinfo
@@ -279,7 +279,7 @@ struct __type_info_implementations {
static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
return !(__lhs & __non_unique_rtti_bit::value);
}
- };
+ };
typedef
#if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
@@ -296,10 +296,10 @@ struct __type_info_implementations {
class _LIBCPP_EXCEPTION_ABI type_info
{
- type_info& operator=(const type_info&);
- type_info(const type_info&);
+ type_info& operator=(const type_info&);
+ type_info(const type_info&);
- protected:
+ protected:
typedef __type_info_implementations::__impl __impl;
__impl::__type_name_t __type_name;
@@ -354,10 +354,10 @@ public:
return "std::bad_cast";
}
#else
- bad_cast() _NOEXCEPT;
- bad_cast(const bad_cast&) _NOEXCEPT = default;
- virtual ~bad_cast() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ bad_cast() _NOEXCEPT;
+ bad_cast(const bad_cast&) _NOEXCEPT = default;
+ virtual ~bad_cast() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
#endif
};
@@ -373,9 +373,9 @@ public:
return "std::bad_typeid";
}
#else
- bad_typeid() _NOEXCEPT;
- virtual ~bad_typeid() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ bad_typeid() _NOEXCEPT;
+ virtual ~bad_typeid() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
#endif
};
diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map
index 8d95bee83d..417180a530 100644
--- a/contrib/libs/cxxsupp/libcxx/include/unordered_map
+++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map
@@ -79,12 +79,12 @@ public:
unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
: unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14
template <class InputIterator>
- unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
+ unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(f, l, n, hf, key_equal(), a) {} // C++14
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
: unordered_map(il, n, hasher(), key_equal(), a) {} // C++14
- unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
+ unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(il, n, hf, key_equal(), a) {} // C++14
~unordered_map();
@@ -290,12 +290,12 @@ public:
unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
: unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14
template <class InputIterator>
- unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
+ unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14
unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
: unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14
- unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
+ unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_multimap(il, n, hf, key_equal(), a) {} // C++14
~unordered_multimap();
@@ -937,11 +937,11 @@ public:
"Invalid allocator::value_type");
private:
- typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
- __value_type>::type __allocator_type;
+ __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1034,14 +1034,14 @@ public:
: unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
- unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
+ unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
_LIBCPP_INLINE_VISIBILITY
unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_map(__il, __n, hasher(), key_equal(), __a) {}
_LIBCPP_INLINE_VISIBILITY
- unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_map(__il, __n, __hf, key_equal(), __a) {}
#endif
@@ -1871,11 +1871,11 @@ public:
"Invalid allocator::value_type");
private:
- typedef __hash_value_type<key_type, mapped_type> __value_type;
+ typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
- __value_type>::type __allocator_type;
+ __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1966,14 +1966,14 @@ public:
: unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
- unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
+ unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
_LIBCPP_INLINE_VISIBILITY
unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
: unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
_LIBCPP_INLINE_VISIBILITY
- unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+ unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const allocator_type& __a)
: unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set
index 25432030bf..5856e4bc40 100644
--- a/contrib/libs/cxxsupp/libcxx/include/unordered_set
+++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set
@@ -75,7 +75,7 @@ public:
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
template <class InputIterator>
- unordered_set(InputIterator f, InputIterator l, size_type n,
+ unordered_set(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const allocator_type& a); // C++14
unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
unordered_set(initializer_list<value_type> il, size_type n,
@@ -255,7 +255,7 @@ public:
unordered_multiset(InputIterator f, InputIterator l, size_type n,
const hasher& hf, const allocator_type& a); // C++14
unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
- unordered_multiset(initializer_list<value_type> il, size_type n,
+ unordered_multiset(initializer_list<value_type> il, size_type n,
const hasher& hf, const allocator_type& a); // C++14
~unordered_multiset();
unordered_multiset& operator=(const unordered_multiset&);
@@ -481,11 +481,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
inline _LIBCPP_INLINE_VISIBILITY
- unordered_set(_InputIterator __first, _InputIterator __last,
+ unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n, const allocator_type& __a)
: unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
template <class _InputIterator>
- unordered_set(_InputIterator __first, _InputIterator __last,
+ unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
#endif
@@ -511,7 +511,7 @@ public:
const allocator_type& __a)
: unordered_set(__il, __n, hasher(), key_equal(), __a) {}
inline _LIBCPP_INLINE_VISIBILITY
- unordered_set(initializer_list<value_type> __il, size_type __n,
+ unordered_set(initializer_list<value_type> __il, size_type __n,
const hasher& __hf, const allocator_type& __a)
: unordered_set(__il, __n, __hf, key_equal(), __a) {}
#endif
@@ -1177,7 +1177,7 @@ public:
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
inline _LIBCPP_INLINE_VISIBILITY
- unordered_multiset(_InputIterator __first, _InputIterator __last,
+ unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n, const allocator_type& __a)
: unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
template <class _InputIterator>
diff --git a/contrib/libs/cxxsupp/libcxx/include/use_ansi.h b/contrib/libs/cxxsupp/libcxx/include/use_ansi.h
index 5e58ddbf7a..2b6f36d4ef 100644
--- a/contrib/libs/cxxsupp/libcxx/include/use_ansi.h
+++ b/contrib/libs/cxxsupp/libcxx/include/use_ansi.h
@@ -1,3 +1,3 @@
-// Empty header to prevent MSVC one from inclusion.
-// This MSVC header adds Microsoft STL to the linker arguments
+// Empty header to prevent MSVC one from inclusion.
+// This MSVC header adds Microsoft STL to the linker arguments
// which causes conflicts with libc++. \ No newline at end of file
diff --git a/contrib/libs/cxxsupp/libcxx/include/variant b/contrib/libs/cxxsupp/libcxx/include/variant
index fb3ca8c220..972c18a811 100644
--- a/contrib/libs/cxxsupp/libcxx/include/variant
+++ b/contrib/libs/cxxsupp/libcxx/include/variant
@@ -814,7 +814,7 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
template <class... _Types> \
class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, \
- destructible_trait> \
+ destructible_trait> \
: public __base<destructible_trait, _Types...> { \
using __base_type = __base<destructible_trait, _Types...>; \
using __index_t = typename __base_type::__index_t; \
@@ -902,8 +902,8 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;
#define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \
move_constructor) \
template <class... _Types> \
- class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
- move_constructible_trait> \
+ class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \
+ move_constructible_trait> \
: public __ctor<__traits<_Types...>> { \
using __base_type = __ctor<__traits<_Types...>>; \
\
@@ -1247,7 +1247,7 @@ struct __make_overloads_imp<__tuple_indices<_Idx...>, _Types... > {
using _Apply _LIBCPP_NODEBUG = __all_overloads<__overload<_Types, _Idx>...>;
};
-template <class ..._Types>
+template <class ..._Types>
using _MakeOverloads _LIBCPP_NODEBUG = typename __make_overloads_imp<
__make_indices_imp<_Sizeof<_Types...>::value, 0>, _Types...>::_Apply;
diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector
index 3aa03b949d..c02253c751 100644
--- a/contrib/libs/cxxsupp/libcxx/include/vector
+++ b/contrib/libs/cxxsupp/libcxx/include/vector
@@ -496,8 +496,8 @@ public:
typedef typename __base::pointer iterator;
typedef typename __base::const_pointer const_iterator;
#else
- typedef __wrap_iter<pointer> iterator;
- typedef __wrap_iter<const_pointer> const_iterator;
+ typedef __wrap_iter<pointer> iterator;
+ typedef __wrap_iter<const_pointer> const_iterator;
#endif
typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -921,7 +921,7 @@ private:
struct _ConstructTransaction {
explicit _ConstructTransaction(vector &__v, size_type __n)
- : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
+ : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
#ifndef _LIBCPP_HAS_NO_ASAN
__v_.__annotate_increase(__n);
#endif
@@ -938,7 +938,7 @@ private:
vector &__v_;
pointer __pos_;
const_pointer const __new_end_;
-
+
private:
_ConstructTransaction(_ConstructTransaction const&) = delete;
_ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
@@ -1085,7 +1085,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
_ConstructTransaction __tx(*this, __n);
const_pointer __new_end = __tx.__new_end_;
for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x);
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x);
}
}
diff --git a/contrib/libs/cxxsupp/libcxx/include/wctype.h b/contrib/libs/cxxsupp/libcxx/include/wctype.h
index 43a79f203d..e6f813b8b1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/wctype.h
+++ b/contrib/libs/cxxsupp/libcxx/include/wctype.h
@@ -68,7 +68,7 @@ wctrans_t wctrans(const char* property);
// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists
// will fail because it does not refer to the same declaration.
#if __has_include_next(<wctype.h>)
-# include_next <wctype.h>
+# include_next <wctype.h>
# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
#endif
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
index db7fb0dabe..9ae1fb5199 100644
--- a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
@@ -51,11 +51,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,
- uint32_t timeout); /* timeout is specified in microseconds */
+ uint32_t timeout); /* timeout is specified in microseconds */
extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
-#define UL_COMPARE_AND_WAIT 1
-#define ULF_WAKE_ALL 0x00000100
+#define UL_COMPARE_AND_WAIT 1
+#define ULF_WAKE_ALL 0x00000100
static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
__cxx_contention_t __val)
diff --git a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
index 80fbadbab3..b18e4f7cb9 100644
--- a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
@@ -244,9 +244,9 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
static LARGE_INTEGER
__QueryPerformanceFrequency()
{
- LARGE_INTEGER val;
- (void) QueryPerformanceFrequency(&val);
- return val;
+ LARGE_INTEGER val;
+ (void) QueryPerformanceFrequency(&val);
+ return val;
}
static steady_clock::time_point __libcpp_steady_clock_now() {
diff --git a/contrib/libs/cxxsupp/libcxx/src/debug.cpp b/contrib/libs/cxxsupp/libcxx/src/debug.cpp
index 307030eb77..dd5963fcce 100644
--- a/contrib/libs/cxxsupp/libcxx/src/debug.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/debug.cpp
@@ -200,7 +200,7 @@ __libcpp_db::__insert_c(void* __c, __libcpp_db::_InsertConstruct *__fn)
__c_node* p = __cbeg_[hc];
void *buf = malloc(sizeof(__c_node));
if (buf == nullptr)
- __throw_bad_alloc();
+ __throw_bad_alloc();
__cbeg_[hc] = __fn(buf, __c, p);
++__csz_;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
index 8ae51419dd..a098dd163b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
@@ -153,16 +153,16 @@ public:
bool assign() {
if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L".."))
return false;
- // FIXME: Cache more of this
- //directory_entry::__cached_data cdata;
- //cdata.__type_ = get_file_type(__data_);
- //cdata.__size_ = get_file_size(__data_);
- //cdata.__write_time_ = get_write_time(__data_);
- __entry_.__assign_iter_entry(
- __root_ / __data_.cFileName,
+ // FIXME: Cache more of this
+ //directory_entry::__cached_data cdata;
+ //cdata.__type_ = get_file_type(__data_);
+ //cdata.__size_ = get_file_size(__data_);
+ //cdata.__write_time_ = get_write_time(__data_);
+ __entry_.__assign_iter_entry(
+ __root_ / __data_.cFileName,
directory_entry::__create_iter_result(detail::get_file_type(__data_)));
- return true;
- }
+ return true;
+ }
private:
error_code close() noexcept {
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h
index 4068f285c7..a5f5749783 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h
@@ -19,11 +19,11 @@
#include "filesystem"
#if !defined(_LIBCPP_WIN32API)
-# include <unistd.h>
-# include <sys/stat.h>
-# include <sys/statvfs.h>
-# include <sys/time.h> // for ::utimes as used in __last_write_time
-# include <fcntl.h> /* values for fchmodat */
+# include <unistd.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <sys/time.h> // for ::utimes as used in __last_write_time
+# include <fcntl.h> /* values for fchmodat */
#endif
#include "../include/apple_availability.h"
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
index ee1e7c55e3..63593be223 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
@@ -24,18 +24,18 @@
# define NOMINMAX
# include <windows.h>
#else
-# include <unistd.h>
-# include <sys/stat.h>
-# include <sys/statvfs.h>
+# include <unistd.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
#endif
#include <time.h>
#include <fcntl.h> /* values for fchmodat */
#if __has_include(<sys/sendfile.h>)
-# include <sys/sendfile.h>
+# include <sys/sendfile.h>
# define _LIBCPP_FILESYSTEM_USE_SENDFILE
#elif defined(__APPLE__) || __has_include(<copyfile.h>)
-# include <copyfile.h>
+# include <copyfile.h>
# define _LIBCPP_FILESYSTEM_USE_COPYFILE
#else
# include "fstream"
@@ -43,11 +43,11 @@
#endif
#if !defined(CLOCK_REALTIME) && !defined(_LIBCPP_WIN32API)
-# include <sys/time.h> // for gettimeofday and timeval
+# include <sys/time.h> // for gettimeofday and timeval
#endif
#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
-# pragma comment(lib, "rt")
+# pragma comment(lib, "rt")
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
index f2ce0b6508..3edd240a5d 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
@@ -34,8 +34,8 @@
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
-# include <dlfcn.h>
-# include <mach-o/dyld.h>
+# include <dlfcn.h>
+# include <mach-o/dyld.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.cpp
index fd2cefc61e..a8a99015a9 100644
--- a/contrib/libs/cxxsupp/libcxx/src/ios.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/ios.cpp
@@ -145,11 +145,11 @@ int ios_base::__xindex_ = 0;
template <typename _Tp>
static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
{ // Precondition: __req_size > __current_cap
- const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
- if (__req_size < mx/2)
- return _VSTD::max(2 * __current_cap, __req_size);
- else
- return mx;
+ const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
+ if (__req_size < mx/2)
+ return _VSTD::max(2 * __current_cap, __req_size);
+ else
+ return mx;
}
int
diff --git a/contrib/libs/cxxsupp/libcxx/src/iostream.cpp b/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
index 05f2efe54c..5c1f5ed9ee 100644
--- a/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
@@ -156,8 +156,8 @@ static void force_locale_initialization() {
class DoIOSInit {
public:
- DoIOSInit();
- ~DoIOSInit();
+ DoIOSInit();
+ ~DoIOSInit();
};
DoIOSInit::DoIOSInit()
diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp
index a989b5e716..42b5641b43 100644
--- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp
@@ -4761,7 +4761,7 @@ __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
{
// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
// we always have at least a single entry in [__g, __g_end); the end of the input sequence
- if (__grouping.size() != 0 && __g_end - __g > 1)
+ if (__grouping.size() != 0 && __g_end - __g > 1)
{
reverse(__g, __g_end);
const char* __ig = __grouping.data();
diff --git a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
index 2701f5b33f..124d59bc64 100644
--- a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
@@ -204,10 +204,10 @@ _LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
#ifdef _LIBCPP_ABI_MICROSOFT
void __call_once(volatile std::atomic<once_flag::_State_type>& flag, void* arg,
- void (*func)(void*))
+ void (*func)(void*))
#else
void __call_once(volatile once_flag::_State_type& flag, void* arg,
- void (*func)(void*))
+ void (*func)(void*))
#endif
{
#if defined(_LIBCPP_HAS_NO_THREADS)
diff --git a/contrib/libs/cxxsupp/libcxx/src/new.cpp b/contrib/libs/cxxsupp/libcxx/src/new.cpp
index 2cc06b9e9a..85afe3039e 100644
--- a/contrib/libs/cxxsupp/libcxx/src/new.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/new.cpp
@@ -12,15 +12,15 @@
#if defined(_LIBCPP_ABI_MICROSOFT)
# if !defined(_LIBCPP_ABI_VCRUNTIME)
-# include "support/runtime/new_handler_fallback.ipp"
-# endif
+# include "support/runtime/new_handler_fallback.ipp"
+# endif
#elif defined(LIBCXX_BUILDING_LIBCXXABI)
-# include <cxxabi.h>
+# include <cxxabi.h>
#elif defined(LIBCXX_BUILDING_LIBCXXRT)
-# include <cxxabi.h>
-# include "support/runtime/new_handler_fallback.ipp"
+# include <cxxabi.h>
+# include "support/runtime/new_handler_fallback.ipp"
#elif defined(__GLIBCXX__)
- // nothing to do
+ // nothing to do
#else
# include "support/runtime/new_handler_fallback.ipp"
#endif
@@ -129,7 +129,7 @@ _LIBCPP_WEAK
void
operator delete(void* ptr) noexcept
{
- ::free(ptr);
+ ::free(ptr);
}
_LIBCPP_WEAK
diff --git a/contrib/libs/cxxsupp/libcxx/src/optional.cpp b/contrib/libs/cxxsupp/libcxx/src/optional.cpp
index 81660f9f4b..39405bec12 100644
--- a/contrib/libs/cxxsupp/libcxx/src/optional.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/optional.cpp
@@ -31,9 +31,9 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optiona
: public std::logic_error
{
public:
- bad_optional_access() : std::logic_error("Bad optional Access") {}
+ bad_optional_access() : std::logic_error("Bad optional Access") {}
-// Get the key function ~bad_optional_access() into the dylib
+// Get the key function ~bad_optional_access() into the dylib
virtual ~bad_optional_access() noexcept;
};
diff --git a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp
index 71f3c98886..f8f335f34a 100644
--- a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp
@@ -11,7 +11,7 @@
#include "string"
#include "system_error"
-
+
#ifdef _LIBCPP_ABI_VCRUNTIME
#include "support/runtime/stdexcept_vcruntime.ipp"
#else
diff --git a/contrib/libs/cxxsupp/libcxx/src/string.cpp b/contrib/libs/cxxsupp/libcxx/src/string.cpp
index 083b828df4..c8dae34272 100644
--- a/contrib/libs/cxxsupp/libcxx/src/string.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/string.cpp
@@ -193,7 +193,7 @@ as_integer( const string& func, const wstring& s, size_t* idx, int base )
// as_float
-template<typename V, typename S, typename F>
+template<typename V, typename S, typename F>
inline
V
as_float_helper(const string& func, const S& str, size_t* idx, F f )
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/solaris/xlocale.cpp b/contrib/libs/cxxsupp/libcxx/src/support/solaris/xlocale.cpp
index e570201954..d25adcd21d 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/solaris/xlocale.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/solaris/xlocale.cpp
@@ -25,7 +25,7 @@ int iswxdigit_l(wint_t __c, locale_t __l) {
// FIXME: This disregards the locale, which is Very Wrong
#define vsnprintf_l(__s, __n, __l, __format, __va) \
- vsnprintf(__s, __n, __format, __va)
+ vsnprintf(__s, __n, __format, __va)
int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
{
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
index 5c2f19fd84..11702a788b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
@@ -42,13 +42,13 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
return count;
}
-// Returns >= 0: the number of wide characters found in the
-// multi byte sequence src (of src_size_bytes), that fit in the buffer dst
+// Returns >= 0: the number of wide characters found in the
+// multi byte sequence src (of src_size_bytes), that fit in the buffer dst
// (of max_dest_chars elements size). The count returned excludes the
-// null terminator. When dst is NULL, no characters are copied
+// null terminator. When dst is NULL, no characters are copied
// and no "out" parameters are updated.
// Returns (size_t) -1: an incomplete sequence encountered.
-// Leaves *src pointing the next character to convert or NULL
+// Leaves *src pointing the next character to convert or NULL
// if a null character was converted from *src.
size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps )
@@ -105,7 +105,7 @@ size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
// Returns >= 0: the number of bytes in the sequence
// converted from *src, excluding the null terminator.
// Returns size_t(-1) if an error occurs, also sets errno.
-// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst
+// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst
// and no "out" parameters are updated.
size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps )
@@ -134,7 +134,7 @@ size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps);
else
result = wcrtomb_s( &char_size, NULL, 0, c, ps);
- // If result is zero there is no error and char_size contains the
+ // If result is zero there is no error and char_size contains the
// size of the multi-byte-sequence converted.
// Otherwise result indicates an errno type error.
if ( result == no_error ) {
diff --git a/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp b/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
index 9da74c9e3b..baace5643c 100644
--- a/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
@@ -49,7 +49,7 @@ size_t std::type_info::hash_code() const noexcept {
#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && \
!defined(LIBCXX_BUILDING_LIBCXXRT) && \
!defined(__GLIBCXX__) && \
- !defined(_LIBCPP_ABI_VCRUNTIME)) || \
+ !defined(_LIBCPP_ABI_VCRUNTIME)) || \
defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
std::type_info::~type_info()
{
diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make
index 961b31241d..15403fe6d5 100644
--- a/contrib/libs/cxxsupp/libcxx/ya.make
+++ b/contrib/libs/cxxsupp/libcxx/ya.make
@@ -56,16 +56,16 @@ ELSEIF (OS_IOS)
contrib/libs/cxxsupp/builtins
)
ELSEIF (CLANG OR MUSL OR OS_DARWIN OR USE_LTO)
- IF (ARCH_ARM7)
- # XXX: libcxxrt support for ARM is currently broken
- DEFAULT(CXX_RT "glibcxx_static")
+ IF (ARCH_ARM7)
+ # XXX: libcxxrt support for ARM is currently broken
+ DEFAULT(CXX_RT "glibcxx_static")
# ARM7 OS_SDK has old libstdc++ without aligned allocation support
CFLAGS(
GLOBAL -fno-aligned-new
)
- ELSE()
- DEFAULT(CXX_RT "libcxxrt")
- ENDIF()
+ ELSE()
+ DEFAULT(CXX_RT "libcxxrt")
+ ENDIF()
IF (MUSL)
PEERDIR(
contrib/libs/musl/include
@@ -118,8 +118,8 @@ ENDIF()
DEFAULT(CXX_RT "default")
-DISABLE(NEED_GLIBCXX_CXX17_SHIMS)
-
+DISABLE(NEED_GLIBCXX_CXX17_SHIMS)
+
IF (CXX_RT == "libcxxrt")
PEERDIR(
contrib/libs/cxxsupp/libcxxabi-parts
@@ -132,9 +132,9 @@ IF (CXX_RT == "libcxxrt")
CFLAGS(
GLOBAL -DLIBCXX_BUILDING_LIBCXXRT
)
- # These builtins are equivalent to clang -rtlib=compiler_rt and
- # are needed by potentially any code generated by clang.
- # With glibcxx runtime, builtins are provided by libgcc
+ # These builtins are equivalent to clang -rtlib=compiler_rt and
+ # are needed by potentially any code generated by clang.
+ # With glibcxx runtime, builtins are provided by libgcc
ELSEIF (CXX_RT == "glibcxx" OR CXX_RT == "glibcxx_static")
LDFLAGS(
-Wl,-Bstatic
@@ -142,9 +142,9 @@ ELSEIF (CXX_RT == "glibcxx" OR CXX_RT == "glibcxx_static")
-lgcc
-lgcc_eh
-Wl,-Bdynamic
- )
+ )
CXXFLAGS(-D__GLIBCXX__=1)
- ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
+ ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
CFLAGS(
GLOBAL -DLIBCXX_BUILDING_LIBGCC
)
@@ -157,7 +157,7 @@ ELSEIF (CXX_RT == "glibcxx_dynamic")
CFLAGS(
GLOBAL -DLIBCXX_BUILDING_LIBGCC
)
- ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
+ ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
ELSEIF (CXX_RT == "glibcxx_driver")
CXXFLAGS(-D__GLIBCXX__=1)
ELSEIF (CXX_RT == "default")
@@ -166,17 +166,17 @@ ELSE()
MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: ${CXX_RT}")
ENDIF()
-IF (NEED_GLIBCXX_CXX17_SHIMS)
- IF (GCC)
- # Assume GCC is bundled with a modern enough version of C++ runtime
+IF (NEED_GLIBCXX_CXX17_SHIMS)
+ IF (GCC)
+ # Assume GCC is bundled with a modern enough version of C++ runtime
ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16")
- # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete
+ # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete
SRCS(
glibcxx_eh_cxx17.cpp
)
- ENDIF()
-ENDIF()
-
+ ENDIF()
+ENDIF()
+
NO_UTIL()
NO_RUNTIME()
diff --git a/contrib/libs/cxxsupp/libcxxabi/src/demangle/ItaniumDemangle.h b/contrib/libs/cxxsupp/libcxxabi/src/demangle/ItaniumDemangle.h
index 677ce6b24e..85e1511346 100644
--- a/contrib/libs/cxxsupp/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/contrib/libs/cxxsupp/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -111,125 +111,125 @@
DEMANGLE_NAMESPACE_BEGIN
template <class T, size_t N> class PODSmallVector {
- static_assert(std::is_pod<T>::value,
- "T is required to be a plain old data type");
-
+ static_assert(std::is_pod<T>::value,
+ "T is required to be a plain old data type");
+
T *First = nullptr;
T *Last = nullptr;
T *Cap = nullptr;
- T Inline[N] = {0};
-
- bool isInline() const { return First == Inline; }
-
- void clearInline() {
- First = Inline;
- Last = Inline;
- Cap = Inline + N;
- }
-
- void reserve(size_t NewCap) {
- size_t S = size();
- if (isInline()) {
+ T Inline[N] = {0};
+
+ bool isInline() const { return First == Inline; }
+
+ void clearInline() {
+ First = Inline;
+ Last = Inline;
+ Cap = Inline + N;
+ }
+
+ void reserve(size_t NewCap) {
+ size_t S = size();
+ if (isInline()) {
auto *Tmp = static_cast<T *>(std::malloc(NewCap * sizeof(T)));
- if (Tmp == nullptr)
- std::terminate();
- std::copy(First, Last, Tmp);
- First = Tmp;
- } else {
+ if (Tmp == nullptr)
+ std::terminate();
+ std::copy(First, Last, Tmp);
+ First = Tmp;
+ } else {
First = static_cast<T *>(std::realloc(First, NewCap * sizeof(T)));
- if (First == nullptr)
- std::terminate();
- }
- Last = First + S;
- Cap = First + NewCap;
- }
-
-public:
- PODSmallVector() : First(Inline), Last(First), Cap(Inline + N) {}
-
+ if (First == nullptr)
+ std::terminate();
+ }
+ Last = First + S;
+ Cap = First + NewCap;
+ }
+
+public:
+ PODSmallVector() : First(Inline), Last(First), Cap(Inline + N) {}
+
PODSmallVector(const PODSmallVector &) = delete;
PODSmallVector &operator=(const PODSmallVector &) = delete;
-
+
PODSmallVector(PODSmallVector &&Other) : PODSmallVector() {
- if (Other.isInline()) {
- std::copy(Other.begin(), Other.end(), First);
- Last = First + Other.size();
- Other.clear();
- return;
- }
-
- First = Other.First;
- Last = Other.Last;
- Cap = Other.Cap;
- Other.clearInline();
- }
-
+ if (Other.isInline()) {
+ std::copy(Other.begin(), Other.end(), First);
+ Last = First + Other.size();
+ Other.clear();
+ return;
+ }
+
+ First = Other.First;
+ Last = Other.Last;
+ Cap = Other.Cap;
+ Other.clearInline();
+ }
+
PODSmallVector &operator=(PODSmallVector &&Other) {
- if (Other.isInline()) {
- if (!isInline()) {
- std::free(First);
- clearInline();
- }
- std::copy(Other.begin(), Other.end(), First);
- Last = First + Other.size();
- Other.clear();
- return *this;
- }
-
- if (isInline()) {
- First = Other.First;
- Last = Other.Last;
- Cap = Other.Cap;
- Other.clearInline();
- return *this;
- }
-
- std::swap(First, Other.First);
- std::swap(Last, Other.Last);
- std::swap(Cap, Other.Cap);
- Other.clear();
- return *this;
- }
-
+ if (Other.isInline()) {
+ if (!isInline()) {
+ std::free(First);
+ clearInline();
+ }
+ std::copy(Other.begin(), Other.end(), First);
+ Last = First + Other.size();
+ Other.clear();
+ return *this;
+ }
+
+ if (isInline()) {
+ First = Other.First;
+ Last = Other.Last;
+ Cap = Other.Cap;
+ Other.clearInline();
+ return *this;
+ }
+
+ std::swap(First, Other.First);
+ std::swap(Last, Other.Last);
+ std::swap(Cap, Other.Cap);
+ Other.clear();
+ return *this;
+ }
+
// NOLINTNEXTLINE(readability-identifier-naming)
void push_back(const T &Elem) {
- if (Last == Cap)
- reserve(size() * 2);
- *Last++ = Elem;
- }
-
+ if (Last == Cap)
+ reserve(size() * 2);
+ *Last++ = Elem;
+ }
+
// NOLINTNEXTLINE(readability-identifier-naming)
- void pop_back() {
- assert(Last != First && "Popping empty vector!");
- --Last;
- }
-
- void dropBack(size_t Index) {
- assert(Index <= size() && "dropBack() can't expand!");
- Last = First + Index;
- }
-
+ void pop_back() {
+ assert(Last != First && "Popping empty vector!");
+ --Last;
+ }
+
+ void dropBack(size_t Index) {
+ assert(Index <= size() && "dropBack() can't expand!");
+ Last = First + Index;
+ }
+
T *begin() { return First; }
T *end() { return Last; }
-
- bool empty() const { return First == Last; }
- size_t size() const { return static_cast<size_t>(Last - First); }
+
+ bool empty() const { return First == Last; }
+ size_t size() const { return static_cast<size_t>(Last - First); }
T &back() {
- assert(Last != First && "Calling back() on empty vector!");
- return *(Last - 1);
- }
+ assert(Last != First && "Calling back() on empty vector!");
+ return *(Last - 1);
+ }
T &operator[](size_t Index) {
- assert(Index < size() && "Invalid access!");
- return *(begin() + Index);
- }
- void clear() { Last = First; }
-
- ~PODSmallVector() {
- if (!isInline())
- std::free(First);
- }
-};
-
+ assert(Index < size() && "Invalid access!");
+ return *(begin() + Index);
+ }
+ void clear() { Last = First; }
+
+ ~PODSmallVector() {
+ if (!isInline())
+ std::free(First);
+ }
+};
+
// Base class of all AST nodes. The AST is built by the parser, then is
// traversed by the printLeft/Right functions to produce a demangled string.
class Node {
@@ -648,14 +648,14 @@ class ReferenceType : public Node {
// Dig through any refs to refs, collapsing the ReferenceTypes as we go. The
// rule here is rvalue ref to rvalue ref collapses to a rvalue ref, and any
// other combination collapses to a lvalue ref.
- //
+ //
// A combination of a TemplateForwardReference and a back-ref Substitution
- // from an ill-formed string may have created a cycle; use cycle detection to
- // avoid looping forever.
+ // from an ill-formed string may have created a cycle; use cycle detection to
+ // avoid looping forever.
std::pair<ReferenceKind, const Node *> collapse(OutputBuffer &OB) const {
auto SoFar = std::make_pair(RK, Pointee);
- // Track the chain of nodes for the Floyd's 'tortoise and hare'
- // cycle-detection algorithm, since getSyntaxNode(S) is impure
+ // Track the chain of nodes for the Floyd's 'tortoise and hare'
+ // cycle-detection algorithm, since getSyntaxNode(S) is impure
PODSmallVector<const Node *, 8> Prev;
for (;;) {
const Node *SN = SoFar.second->getSyntaxNode(OB);
@@ -664,14 +664,14 @@ class ReferenceType : public Node {
auto *RT = static_cast<const ReferenceType *>(SN);
SoFar.second = RT->Pointee;
SoFar.first = std::min(SoFar.first, RT->RK);
-
- // The middle of Prev is the 'slow' pointer moving at half speed
- Prev.push_back(SoFar.second);
- if (Prev.size() > 1 && SoFar.second == Prev[(Prev.size() - 1) / 2]) {
- // Cycle detected
- SoFar.second = nullptr;
- break;
- }
+
+ // The middle of Prev is the 'slow' pointer moving at half speed
+ Prev.push_back(SoFar.second);
+ if (Prev.size() > 1 && SoFar.second == Prev[(Prev.size() - 1) / 2]) {
+ // Cycle detected
+ SoFar.second = nullptr;
+ break;
+ }
}
return SoFar;
}
@@ -692,8 +692,8 @@ public:
return;
SwapAndRestore<bool> SavePrinting(Printing, true);
std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);
- if (!Collapsed.second)
- return;
+ if (!Collapsed.second)
+ return;
Collapsed.second->printLeft(OB);
if (Collapsed.second->hasArray(OB))
OB += " ";
@@ -707,8 +707,8 @@ public:
return;
SwapAndRestore<bool> SavePrinting(Printing, true);
std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);
- if (!Collapsed.second)
- return;
+ if (!Collapsed.second)
+ return;
if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
OB += ")";
Collapsed.second->printRight(OB);
diff --git a/contrib/libs/cxxsupp/openmp/ya.make b/contrib/libs/cxxsupp/openmp/ya.make
index d95c6bfa39..2c64468375 100644
--- a/contrib/libs/cxxsupp/openmp/ya.make
+++ b/contrib/libs/cxxsupp/openmp/ya.make
@@ -35,7 +35,7 @@ IF (SANITIZER_TYPE == memory)
)
ENDIF()
-COMPILE_C_AS_CXX()
+COMPILE_C_AS_CXX()
CXXFLAGS(-fno-exceptions)
diff --git a/contrib/libs/cxxsupp/ya.make b/contrib/libs/cxxsupp/ya.make
index 65176002ad..6cd299ac8a 100644
--- a/contrib/libs/cxxsupp/ya.make
+++ b/contrib/libs/cxxsupp/ya.make
@@ -26,7 +26,7 @@ ENDIF()
END()
RECURSE(
- libcxx
+ libcxx
libcxxabi
libcxxrt
)
diff --git a/contrib/libs/libc_compat/update.sh b/contrib/libs/libc_compat/update.sh
index 4c055b8b06..4cee160904 100755
--- a/contrib/libs/libc_compat/update.sh
+++ b/contrib/libs/libc_compat/update.sh
@@ -38,11 +38,11 @@ curl "https://raw.githubusercontent.com/openbsd/src/master/lib/libc/stdlib/reall
> "collate.h"
> "stdlib.h"
> "unistd.h"
-
-mkdir -p include/uchar
-curl "https://git.musl-libc.org/cgit/musl/plain/include/uchar.h" --output "include/uchar/uchar.h"
-# TODO: provide c16rtomb, mbrtoc16, c32rtomb, mbrtoc32 implementations for uchar
-# if any code actually needs them
+
+mkdir -p include/uchar
+curl "https://git.musl-libc.org/cgit/musl/plain/include/uchar.h" --output "include/uchar/uchar.h"
+# TODO: provide c16rtomb, mbrtoc16, c32rtomb, mbrtoc32 implementations for uchar
+# if any code actually needs them
mkdir -p include/random/sys
curl "https://git.musl-libc.org/cgit/musl/plain/include/sys/random.h" --output "include/random/sys/random.h"
diff --git a/contrib/libs/libiconv/dynamic/ya.make b/contrib/libs/libiconv/dynamic/ya.make
index 3e6c9f29d8..f3a979206c 100644
--- a/contrib/libs/libiconv/dynamic/ya.make
+++ b/contrib/libs/libiconv/dynamic/ya.make
@@ -1,24 +1,24 @@
DYNAMIC_LIBRARY(iconv)
-
+
OWNER(
g:contrib g:cpp-contrib
)
-
-VERSION(1.13)
-
-LICENSE(
- LGPL-2.0-only
- LGPL-2.0-or-later
-)
-
-LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
-
+
+VERSION(1.13)
+
+LICENSE(
+ LGPL-2.0-only
+ LGPL-2.0-or-later
+)
+
+LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
+
PROVIDES(libiconv)
-NO_RUNTIME()
-
+NO_RUNTIME()
+
EXPORTS_SCRIPT(libiconv.exports)
-
+
DYNAMIC_LIBRARY_FROM(contrib/libs/libiconv/static)
-END()
+END()
diff --git a/contrib/libs/libiconv/static/ya.make b/contrib/libs/libiconv/static/ya.make
index b11aef6f17..83009f7ed9 100644
--- a/contrib/libs/libiconv/static/ya.make
+++ b/contrib/libs/libiconv/static/ya.make
@@ -1,35 +1,35 @@
-OWNER(
- g:contrib
- g:cpp-contrib
-)
-
-LIBRARY()
-
-VERSION(1.13)
-
-LICENSE(
+OWNER(
+ g:contrib
+ g:cpp-contrib
+)
+
+LIBRARY()
+
+VERSION(1.13)
+
+LICENSE(
LGPL-2.0-only AND
- LGPL-2.0-or-later
-)
+ LGPL-2.0-or-later
+)
+
+LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
-LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
-
PROVIDES(libiconv)
-NO_RUNTIME()
-
-NO_COMPILER_WARNINGS()
-
-IF (ARCADIA_ICONV_NOCJK)
+NO_RUNTIME()
+
+NO_COMPILER_WARNINGS()
+
+IF (ARCADIA_ICONV_NOCJK)
CFLAGS(
-DARCADIA_ICONV_NOCJK
)
-ENDIF()
-
-SRCDIR(contrib/libs/libiconv)
-
-SRCS(
- iconv.c
-)
-
-END()
+ENDIF()
+
+SRCDIR(contrib/libs/libiconv)
+
+SRCS(
+ iconv.c
+)
+
+END()
diff --git a/contrib/libs/libiconv/ya.make b/contrib/libs/libiconv/ya.make
index 693908c78d..e7c4e35e4c 100644
--- a/contrib/libs/libiconv/ya.make
+++ b/contrib/libs/libiconv/ya.make
@@ -3,29 +3,29 @@ OWNER(
g:cpp-contrib
)
-LIBRARY()
-
+LIBRARY()
+
VERSION(1.13)
LICENSE(Service-Dll-Harness)
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
NO_RUNTIME()
-IF (USE_DYNAMIC_ICONV)
- PEERDIR(
- contrib/libs/libiconv/dynamic
+IF (USE_DYNAMIC_ICONV)
+ PEERDIR(
+ contrib/libs/libiconv/dynamic
+ )
+ELSE()
+ PEERDIR(
+ contrib/libs/libiconv/static
)
-ELSE()
- PEERDIR(
- contrib/libs/libiconv/static
- )
ENDIF()
-END()
+END()
-RECURSE(
- dynamic
- static
-)
+RECURSE(
+ dynamic
+ static
+)
diff --git a/contrib/libs/libidn/dynamic/ya.make b/contrib/libs/libidn/dynamic/ya.make
index f33f4ad69c..c307c1950f 100644
--- a/contrib/libs/libidn/dynamic/ya.make
+++ b/contrib/libs/libidn/dynamic/ya.make
@@ -4,19 +4,19 @@ OWNER(
)
DYNAMIC_LIBRARY(idn)
-
+
VERSION(1.9)
-LICENSE(
- Custom-Punycode
- Ietf
- LGPL-2.0-or-later
- LGPL-2.1-only
- LGPL-2.1-or-later
-)
+LICENSE(
+ Custom-Punycode
+ Ietf
+ LGPL-2.0-or-later
+ LGPL-2.1-only
+ LGPL-2.1-or-later
+)
+
+LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
-LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
-
VERSION(1.9)
PROVIDES(libidn)
diff --git a/contrib/libs/libidn/static/ya.make b/contrib/libs/libidn/static/ya.make
index de3988f8bd..a927d7918e 100644
--- a/contrib/libs/libidn/static/ya.make
+++ b/contrib/libs/libidn/static/ya.make
@@ -1,8 +1,8 @@
-OWNER(
- g:contrib
- g:cpp-contrib
-)
-
+OWNER(
+ g:contrib
+ g:cpp-contrib
+)
+
LIBRARY()
LICENSE(
@@ -13,7 +13,7 @@ LICENSE(
LGPL-2.1-or-later
)
-LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
+LICENSE_TEXTS(../.yandex_meta/licenses.list.txt)
VERSION(1.9)
@@ -23,50 +23,50 @@ NO_RUNTIME()
NO_COMPILER_WARNINGS()
-ADDINCL(
- contrib/libs/libidn
-)
+ADDINCL(
+ contrib/libs/libidn
+)
-CFLAGS(
- -DHAVE_CONFIG_H
-)
+CFLAGS(
+ -DHAVE_CONFIG_H
+)
-IF (OS_WINDOWS)
- CFLAGS(
- -DLIBIDN_EXPORTS
+IF (OS_WINDOWS)
+ CFLAGS(
+ -DLIBIDN_EXPORTS
)
-ENDIF()
+ENDIF()
-IF (OS_ANDROID)
+IF (OS_ANDROID)
CFLAGS(
- -DHAVE_LOCALE_H=1
+ -DHAVE_LOCALE_H=1
)
ENDIF()
-SRCDIR(contrib/libs/libidn)
+SRCDIR(contrib/libs/libidn)
-SRCS(
- idn-free.c
- idna.c
- nfkc.c
- pr29.c
- profiles.c
- punycode.c
- rfc3454.c
- strerror-idna.c
- strerror-pr29.c
- strerror-punycode.c
- strerror-stringprep.c
- strerror-tld.c
- stringprep.c
- tld.c
- tlds.c
- toutf8.c
- version.c
- strverscmp.c
- striconv.c
- c-strcasecmp.c
- c-ctype.c
-)
+SRCS(
+ idn-free.c
+ idna.c
+ nfkc.c
+ pr29.c
+ profiles.c
+ punycode.c
+ rfc3454.c
+ strerror-idna.c
+ strerror-pr29.c
+ strerror-punycode.c
+ strerror-stringprep.c
+ strerror-tld.c
+ stringprep.c
+ tld.c
+ tlds.c
+ toutf8.c
+ version.c
+ strverscmp.c
+ striconv.c
+ c-strcasecmp.c
+ c-ctype.c
+)
END()
diff --git a/contrib/libs/libidn/ya.make b/contrib/libs/libidn/ya.make
index 5e50e9e245..678a813caa 100644
--- a/contrib/libs/libidn/ya.make
+++ b/contrib/libs/libidn/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- g:contrib
- g:cpp-contrib
-)
-
+OWNER(
+ g:contrib
+ g:cpp-contrib
+)
+
LIBRARY()
LICENSE(Service-Dll-Harness)
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
@@ -17,19 +17,19 @@ NO_RUNTIME()
NO_COMPILER_WARNINGS()
-IF (USE_DYNAMIC_IDN)
+IF (USE_DYNAMIC_IDN)
PEERDIR(
contrib/libs/libidn/dynamic
)
ELSE()
- PEERDIR(
- contrib/libs/libidn/static
+ PEERDIR(
+ contrib/libs/libidn/static
)
ENDIF()
END()
-RECURSE(
- dynamic
- static
-)
+RECURSE(
+ dynamic
+ static
+)
diff --git a/contrib/libs/llvm12/include/llvm/Config/config-android.h b/contrib/libs/llvm12/include/llvm/Config/config-android.h
index d6cfd4f30c..3dfe68c951 100644
--- a/contrib/libs/llvm12/include/llvm/Config/config-android.h
+++ b/contrib/libs/llvm12/include/llvm/Config/config-android.h
@@ -1,7 +1,7 @@
#pragma once
-
-#include "config-linux.h"
-
+
+#include "config-linux.h"
+
#undef HAVE_BACKTRACE
#undef HAVE_PTHREAD_GETNAME_NP
#undef HAVE_PTHREAD_SETNAME_NP
diff --git a/contrib/libs/lz4/generated/lz4_ns.h b/contrib/libs/lz4/generated/lz4_ns.h
index e53d70960d..2dfbbf8ccc 100644
--- a/contrib/libs/lz4/generated/lz4_ns.h
+++ b/contrib/libs/lz4/generated/lz4_ns.h
@@ -13,7 +13,7 @@ namespace LZ4_NAMESPACE {
#include "../lz4.c"
struct TLZ4Methods ytbl = {
- LZ4_compress_default,
+ LZ4_compress_default,
};
}
diff --git a/contrib/libs/openssl/crypto/ya.make b/contrib/libs/openssl/crypto/ya.make
index d9d44d9370..3acfb0cac7 100644
--- a/contrib/libs/openssl/crypto/ya.make
+++ b/contrib/libs/openssl/crypto/ya.make
@@ -31,16 +31,16 @@ ADDINCL(
contrib/libs/openssl/include
)
-IF (OS_LINUX)
- IF (ARCH_ARM64)
- SET(LINUX_ARM64 yes)
+IF (OS_LINUX)
+ IF (ARCH_ARM64)
+ SET(LINUX_ARM64 yes)
ELSEIF (ARCH_ARM7)
- SET(LINUX_ARMV7 yes)
+ SET(LINUX_ARMV7 yes)
ELSEIF (ARCH_X86_64)
- SET(LINUX_X86_64 yes)
- ENDIF()
-ENDIF()
-
+ SET(LINUX_X86_64 yes)
+ ENDIF()
+ENDIF()
+
IF (OS_IOS)
IF (ARCH_ARM64)
SET(IOS_ARM64 yes)
@@ -110,7 +110,7 @@ IF (NOT IOS_I386 AND NOT ANDROID_I686 AND NOT WINDOWS_I686)
)
ENDIF()
-IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7)
+IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7)
CFLAGS(
-DVPAES_ASM
)
@@ -845,7 +845,7 @@ IF (NOT IOS_ARM64 AND NOT IOS_ARMV7)
)
ENDIF()
-IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7)
+IF (NOT IOS_ARMV7 AND NOT ANDROID_ARMV7 AND NOT LINUX_ARMV7)
SRCS(
aes/aes_core.c
)
@@ -936,50 +936,50 @@ IF (OS_DARWIN AND ARCH_ARM64)
)
ENDIF()
-IF (OS_LINUX AND ARCH_ARM7)
- IF (CLANG)
+IF (OS_LINUX AND ARCH_ARM7)
+ IF (CLANG)
# XXX: This is a workarond for 'out of range immediate fixup value'
- # error with clang integrated assembler:
- # https://github.com/openssl/openssl/issues/7878
+ # error with clang integrated assembler:
+ # https://github.com/openssl/openssl/issues/7878
CFLAGS(
-mno-thumb
)
- ENDIF()
- CFLAGS(
- -DOPENSSL_PIC
- -DOPENSSL_BN_ASM_GF2m
- -DAES_ASM
- -DBSAES_ASM
- -DGHASH_ASM
- )
- SRCS(
- ../asm/android/arm/crypto/ec/ecp_nistz256-armv4.S
- ../asm/android/arm/crypto/poly1305/poly1305-armv4.S
- ../asm/android/arm/crypto/armv4cpuid.S
- ../asm/android/arm/crypto/bn/armv4-mont.S
- ../asm/android/arm/crypto/bn/armv4-gf2m.S
- ../asm/android/arm/crypto/aes/aes-armv4.S
- ../asm/android/arm/crypto/aes/bsaes-armv7.S
- ../asm/android/arm/crypto/aes/aesv8-armx.S
- ../asm/android/arm/crypto/sha/keccak1600-armv4.S
- ../asm/android/arm/crypto/sha/sha256-armv4.S
- ../asm/android/arm/crypto/sha/sha512-armv4.S
- ../asm/android/arm/crypto/sha/sha1-armv4-large.S
- ../asm/android/arm/crypto/chacha/chacha-armv4.S
- ../asm/android/arm/crypto/modes/ghashv8-armx.S
- ../asm/android/arm/crypto/modes/ghash-armv4.S
- armcap.c
- bn/bn_asm.c
- camellia/camellia.c
- camellia/cmll_cbc.c
- dso/dso_dlfcn.c
- rand/rand_vms.c
- rc4/rc4_enc.c
- rc4/rc4_skey.c
- whrlpool/wp_block.c
- )
-ENDIF()
-
+ ENDIF()
+ CFLAGS(
+ -DOPENSSL_PIC
+ -DOPENSSL_BN_ASM_GF2m
+ -DAES_ASM
+ -DBSAES_ASM
+ -DGHASH_ASM
+ )
+ SRCS(
+ ../asm/android/arm/crypto/ec/ecp_nistz256-armv4.S
+ ../asm/android/arm/crypto/poly1305/poly1305-armv4.S
+ ../asm/android/arm/crypto/armv4cpuid.S
+ ../asm/android/arm/crypto/bn/armv4-mont.S
+ ../asm/android/arm/crypto/bn/armv4-gf2m.S
+ ../asm/android/arm/crypto/aes/aes-armv4.S
+ ../asm/android/arm/crypto/aes/bsaes-armv7.S
+ ../asm/android/arm/crypto/aes/aesv8-armx.S
+ ../asm/android/arm/crypto/sha/keccak1600-armv4.S
+ ../asm/android/arm/crypto/sha/sha256-armv4.S
+ ../asm/android/arm/crypto/sha/sha512-armv4.S
+ ../asm/android/arm/crypto/sha/sha1-armv4-large.S
+ ../asm/android/arm/crypto/chacha/chacha-armv4.S
+ ../asm/android/arm/crypto/modes/ghashv8-armx.S
+ ../asm/android/arm/crypto/modes/ghash-armv4.S
+ armcap.c
+ bn/bn_asm.c
+ camellia/camellia.c
+ camellia/cmll_cbc.c
+ dso/dso_dlfcn.c
+ rand/rand_vms.c
+ rc4/rc4_enc.c
+ rc4/rc4_skey.c
+ whrlpool/wp_block.c
+ )
+ENDIF()
+
IF (OS_LINUX AND ARCH_AARCH64)
SRCS(
../asm/aarch64/crypto/aes/aesv8-armx.S
diff --git a/contrib/libs/openssl/include/openssl/opensslconf.h b/contrib/libs/openssl/include/openssl/opensslconf.h
index 73af98ae42..ecc930a39f 100644
--- a/contrib/libs/openssl/include/openssl/opensslconf.h
+++ b/contrib/libs/openssl/include/openssl/opensslconf.h
@@ -20,8 +20,8 @@
# include "opensslconf-android-arm.h"
#elif defined(__linux__) && defined(__aarch64__)
# include "opensslconf-linux_aarch64.h"
-#elif defined(__linux__) && defined(__arm__)
-# include "opensslconf-linux_arm.h"
+#elif defined(__linux__) && defined(__arm__)
+# include "opensslconf-linux_arm.h"
#elif defined(_MSC_VER) && defined(_M_X64)
# include "opensslconf-win-x86_64.h"
#elif defined(_MSC_VER) && defined(_M_IX86)
diff --git a/contrib/libs/openssl/ya.make b/contrib/libs/openssl/ya.make
index 68f24fee46..060d069785 100644
--- a/contrib/libs/openssl/ya.make
+++ b/contrib/libs/openssl/ya.make
@@ -28,16 +28,16 @@ ADDINCL(
contrib/libs/openssl
)
-IF (OS_LINUX)
- IF (ARCH_ARM64)
- SET(LINUX_ARM64 yes)
+IF (OS_LINUX)
+ IF (ARCH_ARM64)
+ SET(LINUX_ARM64 yes)
ELSEIF (ARCH_ARM7)
- SET(LINUX_ARMV7 yes)
+ SET(LINUX_ARMV7 yes)
ELSEIF (ARCH_X86_64)
- SET(LINUX_X86_64 yes)
- ENDIF()
-ENDIF()
-
+ SET(LINUX_X86_64 yes)
+ ENDIF()
+ENDIF()
+
IF (OS_IOS)
IF (ARCH_ARM64)
SET(IOS_ARM64 yes)
@@ -225,7 +225,7 @@ SRCS(
ssl/tls_srp.c
)
-IF (NOT IOS_ARMV7 AND NOT LINUX_ARMV7)
+IF (NOT IOS_ARMV7 AND NOT LINUX_ARMV7)
CFLAGS(
-DVPAES_ASM
)
@@ -238,7 +238,7 @@ IF (NOT IOS_ARM64 AND NOT IOS_ARMV7)
)
ENDIF()
-IF (OS_LINUX AND ARCH_ARM7 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64 OR OS_LINUX AND ARCH_PPC64LE)
+IF (OS_LINUX AND ARCH_ARM7 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64 OR OS_LINUX AND ARCH_PPC64LE)
SRCS(
engines/e_afalg.c
)
diff --git a/contrib/libs/protoc/ya.make b/contrib/libs/protoc/ya.make
index 00f230bb41..af6a52de35 100644
--- a/contrib/libs/protoc/ya.make
+++ b/contrib/libs/protoc/ya.make
@@ -24,9 +24,9 @@ PEERDIR(
contrib/libs/protobuf
)
-ADDINCL(
- GLOBAL contrib/libs/protoc/src
-)
+ADDINCL(
+ GLOBAL contrib/libs/protoc/src
+)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/ya.make b/contrib/libs/ya.make
index af922adcc3..9c4640fdcf 100644
--- a/contrib/libs/ya.make
+++ b/contrib/libs/ya.make
@@ -9,10 +9,10 @@ RECURSE(
apache
apr
apr-util
- asio
+ asio
asmlib
authparser
- avs-device-sdk
+ avs-device-sdk
aws-sdk-cpp
backtrace
base64
@@ -20,8 +20,8 @@ RECURSE(
bdb/ut
benchmark
bento4
- bluez-clean-headers
- breakpad
+ bluez-clean-headers
+ breakpad
brotli
c-ares
cairo
@@ -153,12 +153,12 @@ RECURSE(
libgit2
libgraphqlparser
libheif
- libical
+ libical
libiconv
libidn
libidn2
libjpeg-turbo
- libjwt
+ libjwt
liblinear
libm
libmagic
@@ -173,7 +173,7 @@ RECURSE(
libpng
libpq
libpqxx
- libpsl
+ libpsl
libraw
librdkafka
librosa-cpp
@@ -224,12 +224,12 @@ RECURSE(
metrohash
mimalloc
minilzo
- minizip
+ minizip
mlir11
mms
mongo-c-driver
mongo-cxx-driver
- msgpack
+ msgpack
muparser
muparser/tests
musl
@@ -272,7 +272,7 @@ RECURSE(
#pire/ut
pixman
poco
- portaudio
+ portaudio
porto_api
proj
protobuf
@@ -337,9 +337,9 @@ RECURSE(
tf-2.4/sample_python
tf-2.4/tensorflow/python
thrax
- tinyalsa
+ tinyalsa
tlsh
- trace_viewer
+ trace_viewer
tralics
tree_sitter
uatraits
@@ -351,7 +351,7 @@ RECURSE(
vmaf
wapiti
webrtc
- websocketpp
+ websocketpp
woff2
xdelta3
xmlsec
@@ -359,7 +359,7 @@ RECURSE(
xxhash
xz
yajl
- yaml
+ yaml
yaml-cpp
zeromq
zlib
@@ -402,8 +402,8 @@ IF (OS_LINUX)
libnetfilter_log
libnetfilter_conntrack
openmpi
- sdbus-cpp
- systemd
+ sdbus-cpp
+ systemd
uuid
virtiofsd
)
diff --git a/contrib/libs/yaml/License b/contrib/libs/yaml/License
index 97d5ed5837..3d82c281ee 100644
--- a/contrib/libs/yaml/License
+++ b/contrib/libs/yaml/License
@@ -1,20 +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.
+
+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.
diff --git a/contrib/libs/yaml/include/yaml.h b/contrib/libs/yaml/include/yaml.h
index bc3696f6b3..7ccd5ed97a 100644
--- a/contrib/libs/yaml/include/yaml.h
+++ b/contrib/libs/yaml/include/yaml.h
@@ -1,1531 +1,1531 @@
-/**
- * @file yaml.h
- * @brief Public interface for libyaml.
- *
- * Include the header file with the code:
- * @code
- * #include <yaml.h>
- * @endcode
- */
-
-#ifndef YAML_H
-#define YAML_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-/**
- * @defgroup export Export Definitions
- * @{
- */
-
-/** The public API declaration. */
-
-#define YAML_DECLARE_STATIC
-
+/**
+ * @file yaml.h
+ * @brief Public interface for libyaml.
+ *
+ * Include the header file with the code:
+ * @code
+ * #include <yaml.h>
+ * @endcode
+ */
+
+#ifndef YAML_H
+#define YAML_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/**
+ * @defgroup export Export Definitions
+ * @{
+ */
+
+/** The public API declaration. */
+
+#define YAML_DECLARE_STATIC
+
#if defined(__MINGW32__)
# define YAML_DECLARE(type) type
#elif defined(_WIN32)
-# if defined(YAML_DECLARE_STATIC)
-# define YAML_DECLARE(type) type
-# elif defined(YAML_DECLARE_EXPORT)
-# define YAML_DECLARE(type) __declspec(dllexport) type
-# else
-# define YAML_DECLARE(type) __declspec(dllimport) type
-# endif
-#else
-# define YAML_DECLARE(type) type
-#endif
-
-/** @} */
-
-/**
- * @defgroup version Version Information
- * @{
- */
-
-/**
- * Get the library version as a string.
- *
- * @returns The function returns the pointer to a static string of the form
- * @c "X.Y.Z", where @c X is the major version number, @c Y is a minor version
- * number, and @c Z is the patch version number.
- */
-
-YAML_DECLARE(const char *)
-yaml_get_version_string(void);
-
-/**
- * Get the library version numbers.
- *
- * @param[out] major Major version number.
- * @param[out] minor Minor version number.
- * @param[out] patch Patch version number.
- */
-
-YAML_DECLARE(void)
-yaml_get_version(int *major, int *minor, int *patch);
-
-/** @} */
-
-/**
- * @defgroup basic Basic Types
- * @{
- */
-
-/** The character type (UTF-8 octet). */
-typedef unsigned char yaml_char_t;
-
-/** The version directive data. */
-typedef struct yaml_version_directive_s {
- /** The major version number. */
- int major;
- /** The minor version number. */
- int minor;
-} yaml_version_directive_t;
-
-/** The tag directive data. */
-typedef struct yaml_tag_directive_s {
- /** The tag handle. */
- yaml_char_t *handle;
- /** The tag prefix. */
- yaml_char_t *prefix;
-} yaml_tag_directive_t;
-
-/** The stream encoding. */
-typedef enum yaml_encoding_e {
- /** Let the parser choose the encoding. */
- YAML_ANY_ENCODING,
- /** The default UTF-8 encoding. */
- YAML_UTF8_ENCODING,
- /** The UTF-16-LE encoding with BOM. */
- YAML_UTF16LE_ENCODING,
- /** The UTF-16-BE encoding with BOM. */
- YAML_UTF16BE_ENCODING
-} yaml_encoding_t;
-
-/** Line break types. */
-
-typedef enum yaml_break_e {
- /** Let the parser choose the break type. */
- YAML_ANY_BREAK,
- /** Use CR for line breaks (Mac style). */
- YAML_CR_BREAK,
- /** Use LN for line breaks (Unix style). */
- YAML_LN_BREAK,
- /** Use CR LN for line breaks (DOS style). */
- YAML_CRLN_BREAK
-} yaml_break_t;
-
-/** Many bad things could happen with the parser and emitter. */
-typedef enum yaml_error_type_e {
- /** No error is produced. */
- YAML_NO_ERROR,
-
- /** Cannot allocate or reallocate a block of memory. */
- YAML_MEMORY_ERROR,
-
- /** Cannot read or decode the input stream. */
- YAML_READER_ERROR,
- /** Cannot scan the input stream. */
- YAML_SCANNER_ERROR,
- /** Cannot parse the input stream. */
- YAML_PARSER_ERROR,
- /** Cannot compose a YAML document. */
- YAML_COMPOSER_ERROR,
-
- /** Cannot write to the output stream. */
- YAML_WRITER_ERROR,
- /** Cannot emit a YAML stream. */
- YAML_EMITTER_ERROR
-} yaml_error_type_t;
-
-/** The pointer position. */
-typedef struct yaml_mark_s {
- /** The position index. */
- size_t index;
-
- /** The position line. */
- size_t line;
-
- /** The position column. */
- size_t column;
-} yaml_mark_t;
-
-/** @} */
-
-/**
- * @defgroup styles Node Styles
- * @{
- */
-
-/** Scalar styles. */
-typedef enum yaml_scalar_style_e {
- /** Let the emitter choose the style. */
- YAML_ANY_SCALAR_STYLE,
-
- /** The plain scalar style. */
- YAML_PLAIN_SCALAR_STYLE,
-
- /** The single-quoted scalar style. */
- YAML_SINGLE_QUOTED_SCALAR_STYLE,
- /** The double-quoted scalar style. */
- YAML_DOUBLE_QUOTED_SCALAR_STYLE,
-
- /** The literal scalar style. */
- YAML_LITERAL_SCALAR_STYLE,
- /** The folded scalar style. */
- YAML_FOLDED_SCALAR_STYLE
-} yaml_scalar_style_t;
-
-/** Sequence styles. */
-typedef enum yaml_sequence_style_e {
- /** Let the emitter choose the style. */
- YAML_ANY_SEQUENCE_STYLE,
-
- /** The block sequence style. */
- YAML_BLOCK_SEQUENCE_STYLE,
- /** The flow sequence style. */
- YAML_FLOW_SEQUENCE_STYLE
-} yaml_sequence_style_t;
-
-/** Mapping styles. */
-typedef enum yaml_mapping_style_e {
- /** Let the emitter choose the style. */
- YAML_ANY_MAPPING_STYLE,
-
- /** The block mapping style. */
- YAML_BLOCK_MAPPING_STYLE,
- /** The flow mapping style. */
- YAML_FLOW_MAPPING_STYLE
-/* YAML_FLOW_SET_MAPPING_STYLE */
-} yaml_mapping_style_t;
-
-/** @} */
-
-/**
- * @defgroup tokens Tokens
- * @{
- */
-
-/** Token types. */
-typedef enum yaml_token_type_e {
- /** An empty token. */
- YAML_NO_TOKEN,
-
- /** A STREAM-START token. */
- YAML_STREAM_START_TOKEN,
- /** A STREAM-END token. */
- YAML_STREAM_END_TOKEN,
-
- /** A VERSION-DIRECTIVE token. */
- YAML_VERSION_DIRECTIVE_TOKEN,
- /** A TAG-DIRECTIVE token. */
- YAML_TAG_DIRECTIVE_TOKEN,
- /** A DOCUMENT-START token. */
- YAML_DOCUMENT_START_TOKEN,
- /** A DOCUMENT-END token. */
- YAML_DOCUMENT_END_TOKEN,
-
- /** A BLOCK-SEQUENCE-START token. */
- YAML_BLOCK_SEQUENCE_START_TOKEN,
+# if defined(YAML_DECLARE_STATIC)
+# define YAML_DECLARE(type) type
+# elif defined(YAML_DECLARE_EXPORT)
+# define YAML_DECLARE(type) __declspec(dllexport) type
+# else
+# define YAML_DECLARE(type) __declspec(dllimport) type
+# endif
+#else
+# define YAML_DECLARE(type) type
+#endif
+
+/** @} */
+
+/**
+ * @defgroup version Version Information
+ * @{
+ */
+
+/**
+ * Get the library version as a string.
+ *
+ * @returns The function returns the pointer to a static string of the form
+ * @c "X.Y.Z", where @c X is the major version number, @c Y is a minor version
+ * number, and @c Z is the patch version number.
+ */
+
+YAML_DECLARE(const char *)
+yaml_get_version_string(void);
+
+/**
+ * Get the library version numbers.
+ *
+ * @param[out] major Major version number.
+ * @param[out] minor Minor version number.
+ * @param[out] patch Patch version number.
+ */
+
+YAML_DECLARE(void)
+yaml_get_version(int *major, int *minor, int *patch);
+
+/** @} */
+
+/**
+ * @defgroup basic Basic Types
+ * @{
+ */
+
+/** The character type (UTF-8 octet). */
+typedef unsigned char yaml_char_t;
+
+/** The version directive data. */
+typedef struct yaml_version_directive_s {
+ /** The major version number. */
+ int major;
+ /** The minor version number. */
+ int minor;
+} yaml_version_directive_t;
+
+/** The tag directive data. */
+typedef struct yaml_tag_directive_s {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag prefix. */
+ yaml_char_t *prefix;
+} yaml_tag_directive_t;
+
+/** The stream encoding. */
+typedef enum yaml_encoding_e {
+ /** Let the parser choose the encoding. */
+ YAML_ANY_ENCODING,
+ /** The default UTF-8 encoding. */
+ YAML_UTF8_ENCODING,
+ /** The UTF-16-LE encoding with BOM. */
+ YAML_UTF16LE_ENCODING,
+ /** The UTF-16-BE encoding with BOM. */
+ YAML_UTF16BE_ENCODING
+} yaml_encoding_t;
+
+/** Line break types. */
+
+typedef enum yaml_break_e {
+ /** Let the parser choose the break type. */
+ YAML_ANY_BREAK,
+ /** Use CR for line breaks (Mac style). */
+ YAML_CR_BREAK,
+ /** Use LN for line breaks (Unix style). */
+ YAML_LN_BREAK,
+ /** Use CR LN for line breaks (DOS style). */
+ YAML_CRLN_BREAK
+} yaml_break_t;
+
+/** Many bad things could happen with the parser and emitter. */
+typedef enum yaml_error_type_e {
+ /** No error is produced. */
+ YAML_NO_ERROR,
+
+ /** Cannot allocate or reallocate a block of memory. */
+ YAML_MEMORY_ERROR,
+
+ /** Cannot read or decode the input stream. */
+ YAML_READER_ERROR,
+ /** Cannot scan the input stream. */
+ YAML_SCANNER_ERROR,
+ /** Cannot parse the input stream. */
+ YAML_PARSER_ERROR,
+ /** Cannot compose a YAML document. */
+ YAML_COMPOSER_ERROR,
+
+ /** Cannot write to the output stream. */
+ YAML_WRITER_ERROR,
+ /** Cannot emit a YAML stream. */
+ YAML_EMITTER_ERROR
+} yaml_error_type_t;
+
+/** The pointer position. */
+typedef struct yaml_mark_s {
+ /** The position index. */
+ size_t index;
+
+ /** The position line. */
+ size_t line;
+
+ /** The position column. */
+ size_t column;
+} yaml_mark_t;
+
+/** @} */
+
+/**
+ * @defgroup styles Node Styles
+ * @{
+ */
+
+/** Scalar styles. */
+typedef enum yaml_scalar_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_SCALAR_STYLE,
+
+ /** The plain scalar style. */
+ YAML_PLAIN_SCALAR_STYLE,
+
+ /** The single-quoted scalar style. */
+ YAML_SINGLE_QUOTED_SCALAR_STYLE,
+ /** The double-quoted scalar style. */
+ YAML_DOUBLE_QUOTED_SCALAR_STYLE,
+
+ /** The literal scalar style. */
+ YAML_LITERAL_SCALAR_STYLE,
+ /** The folded scalar style. */
+ YAML_FOLDED_SCALAR_STYLE
+} yaml_scalar_style_t;
+
+/** Sequence styles. */
+typedef enum yaml_sequence_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_SEQUENCE_STYLE,
+
+ /** The block sequence style. */
+ YAML_BLOCK_SEQUENCE_STYLE,
+ /** The flow sequence style. */
+ YAML_FLOW_SEQUENCE_STYLE
+} yaml_sequence_style_t;
+
+/** Mapping styles. */
+typedef enum yaml_mapping_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_MAPPING_STYLE,
+
+ /** The block mapping style. */
+ YAML_BLOCK_MAPPING_STYLE,
+ /** The flow mapping style. */
+ YAML_FLOW_MAPPING_STYLE
+/* YAML_FLOW_SET_MAPPING_STYLE */
+} yaml_mapping_style_t;
+
+/** @} */
+
+/**
+ * @defgroup tokens Tokens
+ * @{
+ */
+
+/** Token types. */
+typedef enum yaml_token_type_e {
+ /** An empty token. */
+ YAML_NO_TOKEN,
+
+ /** A STREAM-START token. */
+ YAML_STREAM_START_TOKEN,
+ /** A STREAM-END token. */
+ YAML_STREAM_END_TOKEN,
+
+ /** A VERSION-DIRECTIVE token. */
+ YAML_VERSION_DIRECTIVE_TOKEN,
+ /** A TAG-DIRECTIVE token. */
+ YAML_TAG_DIRECTIVE_TOKEN,
+ /** A DOCUMENT-START token. */
+ YAML_DOCUMENT_START_TOKEN,
+ /** A DOCUMENT-END token. */
+ YAML_DOCUMENT_END_TOKEN,
+
+ /** A BLOCK-SEQUENCE-START token. */
+ YAML_BLOCK_SEQUENCE_START_TOKEN,
/** A BLOCK-MAPPING-START token. */
- YAML_BLOCK_MAPPING_START_TOKEN,
- /** A BLOCK-END token. */
- YAML_BLOCK_END_TOKEN,
-
- /** A FLOW-SEQUENCE-START token. */
- YAML_FLOW_SEQUENCE_START_TOKEN,
- /** A FLOW-SEQUENCE-END token. */
- YAML_FLOW_SEQUENCE_END_TOKEN,
- /** A FLOW-MAPPING-START token. */
- YAML_FLOW_MAPPING_START_TOKEN,
- /** A FLOW-MAPPING-END token. */
- YAML_FLOW_MAPPING_END_TOKEN,
-
- /** A BLOCK-ENTRY token. */
- YAML_BLOCK_ENTRY_TOKEN,
- /** A FLOW-ENTRY token. */
- YAML_FLOW_ENTRY_TOKEN,
- /** A KEY token. */
- YAML_KEY_TOKEN,
- /** A VALUE token. */
- YAML_VALUE_TOKEN,
-
- /** An ALIAS token. */
- YAML_ALIAS_TOKEN,
- /** An ANCHOR token. */
- YAML_ANCHOR_TOKEN,
- /** A TAG token. */
- YAML_TAG_TOKEN,
- /** A SCALAR token. */
- YAML_SCALAR_TOKEN
-} yaml_token_type_t;
-
-/** The token structure. */
-typedef struct yaml_token_s {
-
- /** The token type. */
- yaml_token_type_t type;
-
- /** The token data. */
- union {
-
- /** The stream start (for @c YAML_STREAM_START_TOKEN). */
- struct {
- /** The stream encoding. */
- yaml_encoding_t encoding;
- } stream_start;
-
- /** The alias (for @c YAML_ALIAS_TOKEN). */
- struct {
- /** The alias value. */
- yaml_char_t *value;
- } alias;
-
- /** The anchor (for @c YAML_ANCHOR_TOKEN). */
- struct {
- /** The anchor value. */
- yaml_char_t *value;
- } anchor;
-
- /** The tag (for @c YAML_TAG_TOKEN). */
- struct {
- /** The tag handle. */
- yaml_char_t *handle;
- /** The tag suffix. */
- yaml_char_t *suffix;
- } tag;
-
- /** The scalar value (for @c YAML_SCALAR_TOKEN). */
- struct {
- /** The scalar value. */
- yaml_char_t *value;
- /** The length of the scalar value. */
- size_t length;
- /** The scalar style. */
- yaml_scalar_style_t style;
- } scalar;
-
- /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
- struct {
- /** The major version number. */
- int major;
- /** The minor version number. */
- int minor;
- } version_directive;
-
- /** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
- struct {
- /** The tag handle. */
- yaml_char_t *handle;
- /** The tag prefix. */
- yaml_char_t *prefix;
- } tag_directive;
-
- } data;
-
- /** The beginning of the token. */
- yaml_mark_t start_mark;
- /** The end of the token. */
- yaml_mark_t end_mark;
-
-} yaml_token_t;
-
-/**
- * Free any memory allocated for a token object.
- *
- * @param[in,out] token A token object.
- */
-
-YAML_DECLARE(void)
-yaml_token_delete(yaml_token_t *token);
-
-/** @} */
-
-/**
- * @defgroup events Events
- * @{
- */
-
-/** Event types. */
-typedef enum yaml_event_type_e {
- /** An empty event. */
- YAML_NO_EVENT,
-
- /** A STREAM-START event. */
- YAML_STREAM_START_EVENT,
- /** A STREAM-END event. */
- YAML_STREAM_END_EVENT,
-
- /** A DOCUMENT-START event. */
- YAML_DOCUMENT_START_EVENT,
- /** A DOCUMENT-END event. */
- YAML_DOCUMENT_END_EVENT,
-
- /** An ALIAS event. */
- YAML_ALIAS_EVENT,
- /** A SCALAR event. */
- YAML_SCALAR_EVENT,
-
- /** A SEQUENCE-START event. */
- YAML_SEQUENCE_START_EVENT,
- /** A SEQUENCE-END event. */
- YAML_SEQUENCE_END_EVENT,
-
- /** A MAPPING-START event. */
- YAML_MAPPING_START_EVENT,
- /** A MAPPING-END event. */
- YAML_MAPPING_END_EVENT
-} yaml_event_type_t;
-
-/** The event structure. */
-typedef struct yaml_event_s {
-
- /** The event type. */
- yaml_event_type_t type;
-
- /** The event data. */
- union {
+ YAML_BLOCK_MAPPING_START_TOKEN,
+ /** A BLOCK-END token. */
+ YAML_BLOCK_END_TOKEN,
+
+ /** A FLOW-SEQUENCE-START token. */
+ YAML_FLOW_SEQUENCE_START_TOKEN,
+ /** A FLOW-SEQUENCE-END token. */
+ YAML_FLOW_SEQUENCE_END_TOKEN,
+ /** A FLOW-MAPPING-START token. */
+ YAML_FLOW_MAPPING_START_TOKEN,
+ /** A FLOW-MAPPING-END token. */
+ YAML_FLOW_MAPPING_END_TOKEN,
+
+ /** A BLOCK-ENTRY token. */
+ YAML_BLOCK_ENTRY_TOKEN,
+ /** A FLOW-ENTRY token. */
+ YAML_FLOW_ENTRY_TOKEN,
+ /** A KEY token. */
+ YAML_KEY_TOKEN,
+ /** A VALUE token. */
+ YAML_VALUE_TOKEN,
+
+ /** An ALIAS token. */
+ YAML_ALIAS_TOKEN,
+ /** An ANCHOR token. */
+ YAML_ANCHOR_TOKEN,
+ /** A TAG token. */
+ YAML_TAG_TOKEN,
+ /** A SCALAR token. */
+ YAML_SCALAR_TOKEN
+} yaml_token_type_t;
+
+/** The token structure. */
+typedef struct yaml_token_s {
+
+ /** The token type. */
+ yaml_token_type_t type;
+
+ /** The token data. */
+ union {
+
+ /** The stream start (for @c YAML_STREAM_START_TOKEN). */
+ struct {
+ /** The stream encoding. */
+ yaml_encoding_t encoding;
+ } stream_start;
+
+ /** The alias (for @c YAML_ALIAS_TOKEN). */
+ struct {
+ /** The alias value. */
+ yaml_char_t *value;
+ } alias;
+
+ /** The anchor (for @c YAML_ANCHOR_TOKEN). */
+ struct {
+ /** The anchor value. */
+ yaml_char_t *value;
+ } anchor;
+
+ /** The tag (for @c YAML_TAG_TOKEN). */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag suffix. */
+ yaml_char_t *suffix;
+ } tag;
+
+ /** The scalar value (for @c YAML_SCALAR_TOKEN). */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
+ struct {
+ /** The major version number. */
+ int major;
+ /** The minor version number. */
+ int minor;
+ } version_directive;
+
+ /** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag prefix. */
+ yaml_char_t *prefix;
+ } tag_directive;
+
+ } data;
+
+ /** The beginning of the token. */
+ yaml_mark_t start_mark;
+ /** The end of the token. */
+ yaml_mark_t end_mark;
+
+} yaml_token_t;
+
+/**
+ * Free any memory allocated for a token object.
+ *
+ * @param[in,out] token A token object.
+ */
+
+YAML_DECLARE(void)
+yaml_token_delete(yaml_token_t *token);
+
+/** @} */
+
+/**
+ * @defgroup events Events
+ * @{
+ */
+
+/** Event types. */
+typedef enum yaml_event_type_e {
+ /** An empty event. */
+ YAML_NO_EVENT,
+
+ /** A STREAM-START event. */
+ YAML_STREAM_START_EVENT,
+ /** A STREAM-END event. */
+ YAML_STREAM_END_EVENT,
+
+ /** A DOCUMENT-START event. */
+ YAML_DOCUMENT_START_EVENT,
+ /** A DOCUMENT-END event. */
+ YAML_DOCUMENT_END_EVENT,
+
+ /** An ALIAS event. */
+ YAML_ALIAS_EVENT,
+ /** A SCALAR event. */
+ YAML_SCALAR_EVENT,
+
+ /** A SEQUENCE-START event. */
+ YAML_SEQUENCE_START_EVENT,
+ /** A SEQUENCE-END event. */
+ YAML_SEQUENCE_END_EVENT,
+
+ /** A MAPPING-START event. */
+ YAML_MAPPING_START_EVENT,
+ /** A MAPPING-END event. */
+ YAML_MAPPING_END_EVENT
+} yaml_event_type_t;
+
+/** The event structure. */
+typedef struct yaml_event_s {
+
+ /** The event type. */
+ yaml_event_type_t type;
+
+ /** The event data. */
+ union {
- /** The stream parameters (for @c YAML_STREAM_START_EVENT). */
- struct {
- /** The document encoding. */
- yaml_encoding_t encoding;
- } stream_start;
-
- /** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
- struct {
- /** The version directive. */
- yaml_version_directive_t *version_directive;
-
- /** The list of tag directives. */
- struct {
- /** The beginning of the tag directives list. */
- yaml_tag_directive_t *start;
- /** The end of the tag directives list. */
- yaml_tag_directive_t *end;
- } tag_directives;
-
- /** Is the document indicator implicit? */
- int implicit;
- } document_start;
-
- /** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
- struct {
- /** Is the document end indicator implicit? */
- int implicit;
- } document_end;
-
- /** The alias parameters (for @c YAML_ALIAS_EVENT). */
- struct {
- /** The anchor. */
- yaml_char_t *anchor;
- } alias;
-
- /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
- struct {
- /** The anchor. */
- yaml_char_t *anchor;
- /** The tag. */
- yaml_char_t *tag;
- /** The scalar value. */
- yaml_char_t *value;
- /** The length of the scalar value. */
- size_t length;
- /** Is the tag optional for the plain style? */
- int plain_implicit;
- /** Is the tag optional for any non-plain style? */
- int quoted_implicit;
- /** The scalar style. */
- yaml_scalar_style_t style;
- } scalar;
-
- /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
- struct {
- /** The anchor. */
- yaml_char_t *anchor;
- /** The tag. */
- yaml_char_t *tag;
- /** Is the tag optional? */
- int implicit;
- /** The sequence style. */
- yaml_sequence_style_t style;
- } sequence_start;
-
- /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
- struct {
- /** The anchor. */
- yaml_char_t *anchor;
- /** The tag. */
- yaml_char_t *tag;
- /** Is the tag optional? */
- int implicit;
- /** The mapping style. */
- yaml_mapping_style_t style;
- } mapping_start;
-
- } data;
-
- /** The beginning of the event. */
- yaml_mark_t start_mark;
- /** The end of the event. */
- yaml_mark_t end_mark;
-
-} yaml_event_t;
-
-/**
- * Create the STREAM-START event.
- *
- * @param[out] event An empty event object.
- * @param[in] encoding The stream encoding.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_stream_start_event_initialize(yaml_event_t *event,
- yaml_encoding_t encoding);
-
-/**
- * Create the STREAM-END event.
- *
- * @param[out] event An empty event object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_stream_end_event_initialize(yaml_event_t *event);
-
-/**
- * Create the DOCUMENT-START event.
- *
- * The @a implicit argument is considered as a stylistic parameter and may be
- * ignored by the emitter.
- *
- * @param[out] event An empty event object.
- * @param[in] version_directive The %YAML directive value or
- * @c NULL.
- * @param[in] tag_directives_start The beginning of the %TAG
- * directives list.
- * @param[in] tag_directives_end The end of the %TAG directives
- * list.
- * @param[in] implicit If the document start indicator is
- * implicit.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_start_event_initialize(yaml_event_t *event,
- yaml_version_directive_t *version_directive,
- yaml_tag_directive_t *tag_directives_start,
- yaml_tag_directive_t *tag_directives_end,
- int implicit);
-
-/**
- * Create the DOCUMENT-END event.
- *
- * The @a implicit argument is considered as a stylistic parameter and may be
- * ignored by the emitter.
- *
- * @param[out] event An empty event object.
- * @param[in] implicit If the document end indicator is implicit.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
-
-/**
- * Create an ALIAS event.
- *
- * @param[out] event An empty event object.
- * @param[in] anchor The anchor value.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
+ /** The stream parameters (for @c YAML_STREAM_START_EVENT). */
+ struct {
+ /** The document encoding. */
+ yaml_encoding_t encoding;
+ } stream_start;
+
+ /** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
+ struct {
+ /** The version directive. */
+ yaml_version_directive_t *version_directive;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the tag directives list. */
+ yaml_tag_directive_t *start;
+ /** The end of the tag directives list. */
+ yaml_tag_directive_t *end;
+ } tag_directives;
+
+ /** Is the document indicator implicit? */
+ int implicit;
+ } document_start;
+
+ /** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
+ struct {
+ /** Is the document end indicator implicit? */
+ int implicit;
+ } document_end;
+
+ /** The alias parameters (for @c YAML_ALIAS_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ } alias;
+
+ /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** Is the tag optional for the plain style? */
+ int plain_implicit;
+ /** Is the tag optional for any non-plain style? */
+ int quoted_implicit;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** Is the tag optional? */
+ int implicit;
+ /** The sequence style. */
+ yaml_sequence_style_t style;
+ } sequence_start;
+
+ /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** Is the tag optional? */
+ int implicit;
+ /** The mapping style. */
+ yaml_mapping_style_t style;
+ } mapping_start;
+
+ } data;
+
+ /** The beginning of the event. */
+ yaml_mark_t start_mark;
+ /** The end of the event. */
+ yaml_mark_t end_mark;
+
+} yaml_event_t;
+
+/**
+ * Create the STREAM-START event.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] encoding The stream encoding.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_start_event_initialize(yaml_event_t *event,
+ yaml_encoding_t encoding);
+
+/**
+ * Create the STREAM-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Create the DOCUMENT-START event.
+ *
+ * The @a implicit argument is considered as a stylistic parameter and may be
+ * ignored by the emitter.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] version_directive The %YAML directive value or
+ * @c NULL.
+ * @param[in] tag_directives_start The beginning of the %TAG
+ * directives list.
+ * @param[in] tag_directives_end The end of the %TAG directives
+ * list.
+ * @param[in] implicit If the document start indicator is
+ * implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_start_event_initialize(yaml_event_t *event,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int implicit);
+
+/**
+ * Create the DOCUMENT-END event.
+ *
+ * The @a implicit argument is considered as a stylistic parameter and may be
+ * ignored by the emitter.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] implicit If the document end indicator is implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
+
+/**
+ * Create an ALIAS event.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The anchor value.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor);
-
-/**
- * Create a SCALAR event.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * Either the @a tag attribute or one of the @a plain_implicit and
- * @a quoted_implicit flags must be set.
- *
- * @param[out] event An empty event object.
- * @param[in] anchor The scalar anchor or @c NULL.
- * @param[in] tag The scalar tag or @c NULL.
- * @param[in] value The scalar value.
- * @param[in] length The length of the scalar value.
- * @param[in] plain_implicit If the tag may be omitted for the plain
- * style.
- * @param[in] quoted_implicit If the tag may be omitted for any
- * non-plain style.
- * @param[in] style The scalar style.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_scalar_event_initialize(yaml_event_t *event,
+
+/**
+ * Create a SCALAR event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or one of the @a plain_implicit and
+ * @a quoted_implicit flags must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The scalar anchor or @c NULL.
+ * @param[in] tag The scalar tag or @c NULL.
+ * @param[in] value The scalar value.
+ * @param[in] length The length of the scalar value.
+ * @param[in] plain_implicit If the tag may be omitted for the plain
+ * style.
+ * @param[in] quoted_implicit If the tag may be omitted for any
+ * non-plain style.
+ * @param[in] style The scalar style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_scalar_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag,
const yaml_char_t *value, int length,
- int plain_implicit, int quoted_implicit,
- yaml_scalar_style_t style);
-
-/**
- * Create a SEQUENCE-START event.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * Either the @a tag attribute or the @a implicit flag must be set.
- *
- * @param[out] event An empty event object.
- * @param[in] anchor The sequence anchor or @c NULL.
- * @param[in] tag The sequence tag or @c NULL.
- * @param[in] implicit If the tag may be omitted.
- * @param[in] style The sequence style.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_sequence_start_event_initialize(yaml_event_t *event,
+ int plain_implicit, int quoted_implicit,
+ yaml_scalar_style_t style);
+
+/**
+ * Create a SEQUENCE-START event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or the @a implicit flag must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The sequence anchor or @c NULL.
+ * @param[in] tag The sequence tag or @c NULL.
+ * @param[in] implicit If the tag may be omitted.
+ * @param[in] style The sequence style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_start_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
- yaml_sequence_style_t style);
-
-/**
- * Create a SEQUENCE-END event.
- *
- * @param[out] event An empty event object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_sequence_end_event_initialize(yaml_event_t *event);
-
-/**
- * Create a MAPPING-START event.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * Either the @a tag attribute or the @a implicit flag must be set.
- *
- * @param[out] event An empty event object.
- * @param[in] anchor The mapping anchor or @c NULL.
- * @param[in] tag The mapping tag or @c NULL.
- * @param[in] implicit If the tag may be omitted.
- * @param[in] style The mapping style.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_mapping_start_event_initialize(yaml_event_t *event,
+ yaml_sequence_style_t style);
+
+/**
+ * Create a SEQUENCE-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Create a MAPPING-START event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or the @a implicit flag must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The mapping anchor or @c NULL.
+ * @param[in] tag The mapping tag or @c NULL.
+ * @param[in] implicit If the tag may be omitted.
+ * @param[in] style The mapping style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_start_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
- yaml_mapping_style_t style);
-
-/**
- * Create a MAPPING-END event.
- *
- * @param[out] event An empty event object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_mapping_end_event_initialize(yaml_event_t *event);
-
-/**
- * Free any memory allocated for an event object.
- *
- * @param[in,out] event An event object.
- */
-
-YAML_DECLARE(void)
-yaml_event_delete(yaml_event_t *event);
-
-/** @} */
-
-/**
- * @defgroup nodes Nodes
- * @{
- */
-
-/** The tag @c !!null with the only possible value: @c null. */
-#define YAML_NULL_TAG "tag:yaml.org,2002:null"
+ yaml_mapping_style_t style);
+
+/**
+ * Create a MAPPING-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Free any memory allocated for an event object.
+ *
+ * @param[in,out] event An event object.
+ */
+
+YAML_DECLARE(void)
+yaml_event_delete(yaml_event_t *event);
+
+/** @} */
+
+/**
+ * @defgroup nodes Nodes
+ * @{
+ */
+
+/** The tag @c !!null with the only possible value: @c null. */
+#define YAML_NULL_TAG "tag:yaml.org,2002:null"
/** The tag @c !!bool with the values: @c true and @c false. */
-#define YAML_BOOL_TAG "tag:yaml.org,2002:bool"
-/** The tag @c !!str for string values. */
-#define YAML_STR_TAG "tag:yaml.org,2002:str"
-/** The tag @c !!int for integer values. */
-#define YAML_INT_TAG "tag:yaml.org,2002:int"
-/** The tag @c !!float for float values. */
-#define YAML_FLOAT_TAG "tag:yaml.org,2002:float"
-/** The tag @c !!timestamp for date and time values. */
-#define YAML_TIMESTAMP_TAG "tag:yaml.org,2002:timestamp"
-
-/** The tag @c !!seq is used to denote sequences. */
-#define YAML_SEQ_TAG "tag:yaml.org,2002:seq"
-/** The tag @c !!map is used to denote mapping. */
-#define YAML_MAP_TAG "tag:yaml.org,2002:map"
-
-/** The default scalar tag is @c !!str. */
-#define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG
-/** The default sequence tag is @c !!seq. */
-#define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG
-/** The default mapping tag is @c !!map. */
-#define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG
-
-/** Node types. */
-typedef enum yaml_node_type_e {
- /** An empty node. */
- YAML_NO_NODE,
-
- /** A scalar node. */
- YAML_SCALAR_NODE,
- /** A sequence node. */
- YAML_SEQUENCE_NODE,
- /** A mapping node. */
- YAML_MAPPING_NODE
-} yaml_node_type_t;
-
-/** The forward definition of a document node structure. */
-typedef struct yaml_node_s yaml_node_t;
-
-/** An element of a sequence node. */
-typedef int yaml_node_item_t;
-
-/** An element of a mapping node. */
-typedef struct yaml_node_pair_s {
- /** The key of the element. */
- int key;
- /** The value of the element. */
- int value;
-} yaml_node_pair_t;
-
-/** The node structure. */
-struct yaml_node_s {
-
- /** The node type. */
- yaml_node_type_t type;
-
- /** The node tag. */
- yaml_char_t *tag;
-
- /** The node data. */
- union {
+#define YAML_BOOL_TAG "tag:yaml.org,2002:bool"
+/** The tag @c !!str for string values. */
+#define YAML_STR_TAG "tag:yaml.org,2002:str"
+/** The tag @c !!int for integer values. */
+#define YAML_INT_TAG "tag:yaml.org,2002:int"
+/** The tag @c !!float for float values. */
+#define YAML_FLOAT_TAG "tag:yaml.org,2002:float"
+/** The tag @c !!timestamp for date and time values. */
+#define YAML_TIMESTAMP_TAG "tag:yaml.org,2002:timestamp"
+
+/** The tag @c !!seq is used to denote sequences. */
+#define YAML_SEQ_TAG "tag:yaml.org,2002:seq"
+/** The tag @c !!map is used to denote mapping. */
+#define YAML_MAP_TAG "tag:yaml.org,2002:map"
+
+/** The default scalar tag is @c !!str. */
+#define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG
+/** The default sequence tag is @c !!seq. */
+#define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG
+/** The default mapping tag is @c !!map. */
+#define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG
+
+/** Node types. */
+typedef enum yaml_node_type_e {
+ /** An empty node. */
+ YAML_NO_NODE,
+
+ /** A scalar node. */
+ YAML_SCALAR_NODE,
+ /** A sequence node. */
+ YAML_SEQUENCE_NODE,
+ /** A mapping node. */
+ YAML_MAPPING_NODE
+} yaml_node_type_t;
+
+/** The forward definition of a document node structure. */
+typedef struct yaml_node_s yaml_node_t;
+
+/** An element of a sequence node. */
+typedef int yaml_node_item_t;
+
+/** An element of a mapping node. */
+typedef struct yaml_node_pair_s {
+ /** The key of the element. */
+ int key;
+ /** The value of the element. */
+ int value;
+} yaml_node_pair_t;
+
+/** The node structure. */
+struct yaml_node_s {
+
+ /** The node type. */
+ yaml_node_type_t type;
+
+ /** The node tag. */
+ yaml_char_t *tag;
+
+ /** The node data. */
+ union {
- /** The scalar parameters (for @c YAML_SCALAR_NODE). */
- struct {
- /** The scalar value. */
- yaml_char_t *value;
- /** The length of the scalar value. */
- size_t length;
- /** The scalar style. */
- yaml_scalar_style_t style;
- } scalar;
-
- /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */
- struct {
- /** The stack of sequence items. */
- struct {
- /** The beginning of the stack. */
- yaml_node_item_t *start;
- /** The end of the stack. */
- yaml_node_item_t *end;
- /** The top of the stack. */
- yaml_node_item_t *top;
- } items;
- /** The sequence style. */
- yaml_sequence_style_t style;
- } sequence;
-
- /** The mapping parameters (for @c YAML_MAPPING_NODE). */
- struct {
- /** The stack of mapping pairs (key, value). */
- struct {
- /** The beginning of the stack. */
- yaml_node_pair_t *start;
- /** The end of the stack. */
- yaml_node_pair_t *end;
- /** The top of the stack. */
- yaml_node_pair_t *top;
- } pairs;
- /** The mapping style. */
- yaml_mapping_style_t style;
- } mapping;
-
- } data;
-
- /** The beginning of the node. */
- yaml_mark_t start_mark;
- /** The end of the node. */
- yaml_mark_t end_mark;
-
-};
-
-/** The document structure. */
-typedef struct yaml_document_s {
-
- /** The document nodes. */
- struct {
- /** The beginning of the stack. */
- yaml_node_t *start;
- /** The end of the stack. */
- yaml_node_t *end;
- /** The top of the stack. */
- yaml_node_t *top;
- } nodes;
-
- /** The version directive. */
- yaml_version_directive_t *version_directive;
-
- /** The list of tag directives. */
- struct {
- /** The beginning of the tag directives list. */
- yaml_tag_directive_t *start;
- /** The end of the tag directives list. */
- yaml_tag_directive_t *end;
- } tag_directives;
-
- /** Is the document start indicator implicit? */
- int start_implicit;
- /** Is the document end indicator implicit? */
- int end_implicit;
-
- /** The beginning of the document. */
- yaml_mark_t start_mark;
- /** The end of the document. */
- yaml_mark_t end_mark;
-
-} yaml_document_t;
-
-/**
- * Create a YAML document.
- *
- * @param[out] document An empty document object.
- * @param[in] version_directive The %YAML directive value or
- * @c NULL.
- * @param[in] tag_directives_start The beginning of the %TAG
- * directives list.
- * @param[in] tag_directives_end The end of the %TAG directives
- * list.
- * @param[in] start_implicit If the document start indicator is
- * implicit.
- * @param[in] end_implicit If the document end indicator is
- * implicit.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_initialize(yaml_document_t *document,
- yaml_version_directive_t *version_directive,
- yaml_tag_directive_t *tag_directives_start,
- yaml_tag_directive_t *tag_directives_end,
- int start_implicit, int end_implicit);
-
-/**
- * Delete a YAML document and all its nodes.
- *
- * @param[in,out] document A document object.
- */
-
-YAML_DECLARE(void)
-yaml_document_delete(yaml_document_t *document);
-
-/**
- * Get a node of a YAML document.
- *
- * The pointer returned by this function is valid until any of the functions
- * modifying the documents are called.
- *
- * @param[in] document A document object.
- * @param[in] index The node id.
- *
- * @returns the node objct or @c NULL if @c node_id is out of range.
- */
-
-YAML_DECLARE(yaml_node_t *)
-yaml_document_get_node(yaml_document_t *document, int index);
-
-/**
- * Get the root of a YAML document node.
- *
- * The root object is the first object added to the document.
- *
- * The pointer returned by this function is valid until any of the functions
- * modifying the documents are called.
- *
- * An empty document produced by the parser signifies the end of a YAML
- * stream.
- *
- * @param[in] document A document object.
- *
- * @returns the node object or @c NULL if the document is empty.
- */
-
-YAML_DECLARE(yaml_node_t *)
-yaml_document_get_root_node(yaml_document_t *document);
-
-/**
- * Create a SCALAR node and attach it to the document.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * @param[in,out] document A document object.
- * @param[in] tag The scalar tag.
- * @param[in] value The scalar value.
- * @param[in] length The length of the scalar value.
- * @param[in] style The scalar style.
- *
- * @returns the node id or @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_scalar(yaml_document_t *document,
+ /** The scalar parameters (for @c YAML_SCALAR_NODE). */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */
+ struct {
+ /** The stack of sequence items. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_item_t *start;
+ /** The end of the stack. */
+ yaml_node_item_t *end;
+ /** The top of the stack. */
+ yaml_node_item_t *top;
+ } items;
+ /** The sequence style. */
+ yaml_sequence_style_t style;
+ } sequence;
+
+ /** The mapping parameters (for @c YAML_MAPPING_NODE). */
+ struct {
+ /** The stack of mapping pairs (key, value). */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_pair_t *start;
+ /** The end of the stack. */
+ yaml_node_pair_t *end;
+ /** The top of the stack. */
+ yaml_node_pair_t *top;
+ } pairs;
+ /** The mapping style. */
+ yaml_mapping_style_t style;
+ } mapping;
+
+ } data;
+
+ /** The beginning of the node. */
+ yaml_mark_t start_mark;
+ /** The end of the node. */
+ yaml_mark_t end_mark;
+
+};
+
+/** The document structure. */
+typedef struct yaml_document_s {
+
+ /** The document nodes. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_t *start;
+ /** The end of the stack. */
+ yaml_node_t *end;
+ /** The top of the stack. */
+ yaml_node_t *top;
+ } nodes;
+
+ /** The version directive. */
+ yaml_version_directive_t *version_directive;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the tag directives list. */
+ yaml_tag_directive_t *start;
+ /** The end of the tag directives list. */
+ yaml_tag_directive_t *end;
+ } tag_directives;
+
+ /** Is the document start indicator implicit? */
+ int start_implicit;
+ /** Is the document end indicator implicit? */
+ int end_implicit;
+
+ /** The beginning of the document. */
+ yaml_mark_t start_mark;
+ /** The end of the document. */
+ yaml_mark_t end_mark;
+
+} yaml_document_t;
+
+/**
+ * Create a YAML document.
+ *
+ * @param[out] document An empty document object.
+ * @param[in] version_directive The %YAML directive value or
+ * @c NULL.
+ * @param[in] tag_directives_start The beginning of the %TAG
+ * directives list.
+ * @param[in] tag_directives_end The end of the %TAG directives
+ * list.
+ * @param[in] start_implicit If the document start indicator is
+ * implicit.
+ * @param[in] end_implicit If the document end indicator is
+ * implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_initialize(yaml_document_t *document,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int start_implicit, int end_implicit);
+
+/**
+ * Delete a YAML document and all its nodes.
+ *
+ * @param[in,out] document A document object.
+ */
+
+YAML_DECLARE(void)
+yaml_document_delete(yaml_document_t *document);
+
+/**
+ * Get a node of a YAML document.
+ *
+ * The pointer returned by this function is valid until any of the functions
+ * modifying the documents are called.
+ *
+ * @param[in] document A document object.
+ * @param[in] index The node id.
+ *
+ * @returns the node objct or @c NULL if @c node_id is out of range.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_node(yaml_document_t *document, int index);
+
+/**
+ * Get the root of a YAML document node.
+ *
+ * The root object is the first object added to the document.
+ *
+ * The pointer returned by this function is valid until any of the functions
+ * modifying the documents are called.
+ *
+ * An empty document produced by the parser signifies the end of a YAML
+ * stream.
+ *
+ * @param[in] document A document object.
+ *
+ * @returns the node object or @c NULL if the document is empty.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_root_node(yaml_document_t *document);
+
+/**
+ * Create a SCALAR node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The scalar tag.
+ * @param[in] value The scalar value.
+ * @param[in] length The length of the scalar value.
+ * @param[in] style The scalar style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_scalar(yaml_document_t *document,
const yaml_char_t *tag, const yaml_char_t *value, int length,
- yaml_scalar_style_t style);
-
-/**
- * Create a SEQUENCE node and attach it to the document.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * @param[in,out] document A document object.
- * @param[in] tag The sequence tag.
- * @param[in] style The sequence style.
- *
- * @returns the node id or @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_sequence(yaml_document_t *document,
+ yaml_scalar_style_t style);
+
+/**
+ * Create a SEQUENCE node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The sequence tag.
+ * @param[in] style The sequence style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_sequence(yaml_document_t *document,
const yaml_char_t *tag, yaml_sequence_style_t style);
-
-/**
- * Create a MAPPING node and attach it to the document.
- *
- * The @a style argument may be ignored by the emitter.
- *
- * @param[in,out] document A document object.
- * @param[in] tag The sequence tag.
- * @param[in] style The sequence style.
- *
- * @returns the node id or @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_mapping(yaml_document_t *document,
+
+/**
+ * Create a MAPPING node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The sequence tag.
+ * @param[in] style The sequence style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_mapping(yaml_document_t *document,
const yaml_char_t *tag, yaml_mapping_style_t style);
-
-/**
- * Add an item to a SEQUENCE node.
- *
- * @param[in,out] document A document object.
- * @param[in] sequence The sequence node id.
- * @param[in] item The item node id.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_append_sequence_item(yaml_document_t *document,
- int sequence, int item);
-
-/**
- * Add a pair of a key and a value to a MAPPING node.
- *
- * @param[in,out] document A document object.
- * @param[in] mapping The mapping node id.
- * @param[in] key The key node id.
- * @param[in] value The value node id.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_document_append_mapping_pair(yaml_document_t *document,
- int mapping, int key, int value);
-
-/** @} */
-
-/**
- * @defgroup parser Parser Definitions
- * @{
- */
-
-/**
- * The prototype of a read handler.
- *
- * The read handler is called when the parser needs to read more bytes from the
- * source. The handler should write not more than @a size bytes to the @a
- * buffer. The number of written bytes should be set to the @a length variable.
- *
- * @param[in,out] data A pointer to an application data specified by
- * yaml_parser_set_input().
- * @param[out] buffer The buffer to write the data from the source.
- * @param[in] size The size of the buffer.
- * @param[out] size_read The actual number of bytes read from the source.
- *
- * @returns On success, the handler should return @c 1. If the handler failed,
- * the returned value should be @c 0. On EOF, the handler should set the
- * @a size_read to @c 0 and return @c 1.
- */
-
-typedef int yaml_read_handler_t(void *data, unsigned char *buffer, size_t size,
- size_t *size_read);
-
-/**
- * This structure holds information about a potential simple key.
- */
-
-typedef struct yaml_simple_key_s {
- /** Is a simple key possible? */
- int possible;
-
- /** Is a simple key required? */
- int required;
-
- /** The number of the token. */
- size_t token_number;
-
- /** The position mark. */
- yaml_mark_t mark;
-} yaml_simple_key_t;
-
-/**
- * The states of the parser.
- */
-typedef enum yaml_parser_state_e {
- /** Expect STREAM-START. */
- YAML_PARSE_STREAM_START_STATE,
- /** Expect the beginning of an implicit document. */
- YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
- /** Expect DOCUMENT-START. */
- YAML_PARSE_DOCUMENT_START_STATE,
- /** Expect the content of a document. */
- YAML_PARSE_DOCUMENT_CONTENT_STATE,
- /** Expect DOCUMENT-END. */
- YAML_PARSE_DOCUMENT_END_STATE,
-
- /** Expect a block node. */
- YAML_PARSE_BLOCK_NODE_STATE,
- /** Expect a block node or indentless sequence. */
- YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE,
- /** Expect a flow node. */
- YAML_PARSE_FLOW_NODE_STATE,
- /** Expect the first entry of a block sequence. */
- YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
- /** Expect an entry of a block sequence. */
- YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
-
- /** Expect an entry of an indentless sequence. */
- YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
- /** Expect the first key of a block mapping. */
- YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
- /** Expect a block mapping key. */
- YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
- /** Expect a block mapping value. */
- YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
- /** Expect the first entry of a flow sequence. */
- YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
-
- /** Expect an entry of a flow sequence. */
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
- /** Expect a key of an ordered mapping. */
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
- /** Expect a value of an ordered mapping. */
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE,
- /** Expect the and of an ordered mapping entry. */
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
- /** Expect the first key of a flow mapping. */
- YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
- /** Expect a key of a flow mapping. */
-
- YAML_PARSE_FLOW_MAPPING_KEY_STATE,
- /** Expect a value of a flow mapping. */
- YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
- /** Expect an empty value of a flow mapping. */
- YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE,
- /** Expect nothing. */
- YAML_PARSE_END_STATE
-} yaml_parser_state_t;
-
-/**
- * This structure holds aliases data.
- */
-
-typedef struct yaml_alias_data_s {
- /** The anchor. */
- yaml_char_t *anchor;
- /** The node id. */
- int index;
- /** The anchor mark. */
- yaml_mark_t mark;
-} yaml_alias_data_t;
-
-/**
- * The parser structure.
- *
- * All members are internal. Manage the structure using the @c yaml_parser_
- * family of functions.
- */
-
-typedef struct yaml_parser_s {
-
- /**
- * @name Error handling
- * @{
- */
-
- /** Error type. */
- yaml_error_type_t error;
- /** Error description. */
- const char *problem;
- /** The byte about which the problem occured. */
- size_t problem_offset;
- /** The problematic value (@c -1 is none). */
- int problem_value;
- /** The problem position. */
- yaml_mark_t problem_mark;
- /** The error context. */
- const char *context;
- /** The context position. */
- yaml_mark_t context_mark;
-
- /**
- * @}
- */
-
- /**
- * @name Reader stuff
- * @{
- */
-
- /** Read handler. */
- yaml_read_handler_t *read_handler;
-
- /** A pointer for passing to the read handler. */
- void *read_handler_data;
-
- /** Standard (string or file) input data. */
- union {
- /** String input data. */
- struct {
- /** The string start pointer. */
- const unsigned char *start;
- /** The string end pointer. */
- const unsigned char *end;
- /** The string current position. */
- const unsigned char *current;
- } string;
-
- /** File input data. */
- FILE *file;
- } input;
-
- /** EOF flag */
- int eof;
-
- /** The working buffer. */
- struct {
- /** The beginning of the buffer. */
- yaml_char_t *start;
- /** The end of the buffer. */
- yaml_char_t *end;
- /** The current position of the buffer. */
- yaml_char_t *pointer;
- /** The last filled position of the buffer. */
- yaml_char_t *last;
- } buffer;
-
- /* The number of unread characters in the buffer. */
- size_t unread;
-
- /** The raw buffer. */
- struct {
- /** The beginning of the buffer. */
- unsigned char *start;
- /** The end of the buffer. */
- unsigned char *end;
- /** The current position of the buffer. */
- unsigned char *pointer;
- /** The last filled position of the buffer. */
- unsigned char *last;
- } raw_buffer;
-
- /** The input encoding. */
- yaml_encoding_t encoding;
-
- /** The offset of the current position (in bytes). */
- size_t offset;
-
- /** The mark of the current position. */
- yaml_mark_t mark;
-
- /**
- * @}
- */
-
- /**
- * @name Scanner stuff
- * @{
- */
-
- /** Have we started to scan the input stream? */
- int stream_start_produced;
-
- /** Have we reached the end of the input stream? */
- int stream_end_produced;
-
- /** The number of unclosed '[' and '{' indicators. */
- int flow_level;
-
- /** The tokens queue. */
- struct {
- /** The beginning of the tokens queue. */
- yaml_token_t *start;
- /** The end of the tokens queue. */
- yaml_token_t *end;
- /** The head of the tokens queue. */
- yaml_token_t *head;
- /** The tail of the tokens queue. */
- yaml_token_t *tail;
- } tokens;
-
- /** The number of tokens fetched from the queue. */
- size_t tokens_parsed;
-
+
+/**
+ * Add an item to a SEQUENCE node.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] sequence The sequence node id.
+ * @param[in] item The item node id.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_sequence_item(yaml_document_t *document,
+ int sequence, int item);
+
+/**
+ * Add a pair of a key and a value to a MAPPING node.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] mapping The mapping node id.
+ * @param[in] key The key node id.
+ * @param[in] value The value node id.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_mapping_pair(yaml_document_t *document,
+ int mapping, int key, int value);
+
+/** @} */
+
+/**
+ * @defgroup parser Parser Definitions
+ * @{
+ */
+
+/**
+ * The prototype of a read handler.
+ *
+ * The read handler is called when the parser needs to read more bytes from the
+ * source. The handler should write not more than @a size bytes to the @a
+ * buffer. The number of written bytes should be set to the @a length variable.
+ *
+ * @param[in,out] data A pointer to an application data specified by
+ * yaml_parser_set_input().
+ * @param[out] buffer The buffer to write the data from the source.
+ * @param[in] size The size of the buffer.
+ * @param[out] size_read The actual number of bytes read from the source.
+ *
+ * @returns On success, the handler should return @c 1. If the handler failed,
+ * the returned value should be @c 0. On EOF, the handler should set the
+ * @a size_read to @c 0 and return @c 1.
+ */
+
+typedef int yaml_read_handler_t(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read);
+
+/**
+ * This structure holds information about a potential simple key.
+ */
+
+typedef struct yaml_simple_key_s {
+ /** Is a simple key possible? */
+ int possible;
+
+ /** Is a simple key required? */
+ int required;
+
+ /** The number of the token. */
+ size_t token_number;
+
+ /** The position mark. */
+ yaml_mark_t mark;
+} yaml_simple_key_t;
+
+/**
+ * The states of the parser.
+ */
+typedef enum yaml_parser_state_e {
+ /** Expect STREAM-START. */
+ YAML_PARSE_STREAM_START_STATE,
+ /** Expect the beginning of an implicit document. */
+ YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
+ /** Expect DOCUMENT-START. */
+ YAML_PARSE_DOCUMENT_START_STATE,
+ /** Expect the content of a document. */
+ YAML_PARSE_DOCUMENT_CONTENT_STATE,
+ /** Expect DOCUMENT-END. */
+ YAML_PARSE_DOCUMENT_END_STATE,
+
+ /** Expect a block node. */
+ YAML_PARSE_BLOCK_NODE_STATE,
+ /** Expect a block node or indentless sequence. */
+ YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE,
+ /** Expect a flow node. */
+ YAML_PARSE_FLOW_NODE_STATE,
+ /** Expect the first entry of a block sequence. */
+ YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
+ /** Expect an entry of a block sequence. */
+ YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
+
+ /** Expect an entry of an indentless sequence. */
+ YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
+ /** Expect the first key of a block mapping. */
+ YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
+ /** Expect a block mapping key. */
+ YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
+ /** Expect a block mapping value. */
+ YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
+ /** Expect the first entry of a flow sequence. */
+ YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
+
+ /** Expect an entry of a flow sequence. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
+ /** Expect a key of an ordered mapping. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
+ /** Expect a value of an ordered mapping. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE,
+ /** Expect the and of an ordered mapping entry. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
+ /** Expect the first key of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
+ /** Expect a key of a flow mapping. */
+
+ YAML_PARSE_FLOW_MAPPING_KEY_STATE,
+ /** Expect a value of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
+ /** Expect an empty value of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE,
+ /** Expect nothing. */
+ YAML_PARSE_END_STATE
+} yaml_parser_state_t;
+
+/**
+ * This structure holds aliases data.
+ */
+
+typedef struct yaml_alias_data_s {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The node id. */
+ int index;
+ /** The anchor mark. */
+ yaml_mark_t mark;
+} yaml_alias_data_t;
+
+/**
+ * The parser structure.
+ *
+ * All members are internal. Manage the structure using the @c yaml_parser_
+ * family of functions.
+ */
+
+typedef struct yaml_parser_s {
+
+ /**
+ * @name Error handling
+ * @{
+ */
+
+ /** Error type. */
+ yaml_error_type_t error;
+ /** Error description. */
+ const char *problem;
+ /** The byte about which the problem occured. */
+ size_t problem_offset;
+ /** The problematic value (@c -1 is none). */
+ int problem_value;
+ /** The problem position. */
+ yaml_mark_t problem_mark;
+ /** The error context. */
+ const char *context;
+ /** The context position. */
+ yaml_mark_t context_mark;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Reader stuff
+ * @{
+ */
+
+ /** Read handler. */
+ yaml_read_handler_t *read_handler;
+
+ /** A pointer for passing to the read handler. */
+ void *read_handler_data;
+
+ /** Standard (string or file) input data. */
+ union {
+ /** String input data. */
+ struct {
+ /** The string start pointer. */
+ const unsigned char *start;
+ /** The string end pointer. */
+ const unsigned char *end;
+ /** The string current position. */
+ const unsigned char *current;
+ } string;
+
+ /** File input data. */
+ FILE *file;
+ } input;
+
+ /** EOF flag */
+ int eof;
+
+ /** The working buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ yaml_char_t *start;
+ /** The end of the buffer. */
+ yaml_char_t *end;
+ /** The current position of the buffer. */
+ yaml_char_t *pointer;
+ /** The last filled position of the buffer. */
+ yaml_char_t *last;
+ } buffer;
+
+ /* The number of unread characters in the buffer. */
+ size_t unread;
+
+ /** The raw buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ unsigned char *start;
+ /** The end of the buffer. */
+ unsigned char *end;
+ /** The current position of the buffer. */
+ unsigned char *pointer;
+ /** The last filled position of the buffer. */
+ unsigned char *last;
+ } raw_buffer;
+
+ /** The input encoding. */
+ yaml_encoding_t encoding;
+
+ /** The offset of the current position (in bytes). */
+ size_t offset;
+
+ /** The mark of the current position. */
+ yaml_mark_t mark;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Scanner stuff
+ * @{
+ */
+
+ /** Have we started to scan the input stream? */
+ int stream_start_produced;
+
+ /** Have we reached the end of the input stream? */
+ int stream_end_produced;
+
+ /** The number of unclosed '[' and '{' indicators. */
+ int flow_level;
+
+ /** The tokens queue. */
+ struct {
+ /** The beginning of the tokens queue. */
+ yaml_token_t *start;
+ /** The end of the tokens queue. */
+ yaml_token_t *end;
+ /** The head of the tokens queue. */
+ yaml_token_t *head;
+ /** The tail of the tokens queue. */
+ yaml_token_t *tail;
+ } tokens;
+
+ /** The number of tokens fetched from the queue. */
+ size_t tokens_parsed;
+
/** Does the tokens queue contain a token ready for dequeueing. */
- int token_available;
-
- /** The indentation levels stack. */
- struct {
- /** The beginning of the stack. */
- int *start;
- /** The end of the stack. */
- int *end;
- /** The top of the stack. */
- int *top;
- } indents;
-
- /** The current indentation level. */
- int indent;
-
- /** May a simple key occur at the current position? */
- int simple_key_allowed;
-
- /** The stack of simple keys. */
- struct {
- /** The beginning of the stack. */
- yaml_simple_key_t *start;
- /** The end of the stack. */
- yaml_simple_key_t *end;
- /** The top of the stack. */
- yaml_simple_key_t *top;
- } simple_keys;
-
- /**
- * @}
- */
-
- /**
- * @name Parser stuff
- * @{
- */
-
- /** The parser states stack. */
- struct {
- /** The beginning of the stack. */
- yaml_parser_state_t *start;
- /** The end of the stack. */
- yaml_parser_state_t *end;
- /** The top of the stack. */
- yaml_parser_state_t *top;
- } states;
-
- /** The current parser state. */
- yaml_parser_state_t state;
-
- /** The stack of marks. */
- struct {
- /** The beginning of the stack. */
- yaml_mark_t *start;
- /** The end of the stack. */
- yaml_mark_t *end;
- /** The top of the stack. */
- yaml_mark_t *top;
- } marks;
-
- /** The list of TAG directives. */
- struct {
- /** The beginning of the list. */
- yaml_tag_directive_t *start;
- /** The end of the list. */
- yaml_tag_directive_t *end;
- /** The top of the list. */
- yaml_tag_directive_t *top;
- } tag_directives;
-
- /**
- * @}
- */
-
- /**
- * @name Dumper stuff
- * @{
- */
-
- /** The alias data. */
- struct {
- /** The beginning of the list. */
- yaml_alias_data_t *start;
- /** The end of the list. */
- yaml_alias_data_t *end;
- /** The top of the list. */
- yaml_alias_data_t *top;
- } aliases;
-
- /** The currently parsed document. */
- yaml_document_t *document;
-
- /**
- * @}
- */
-
-} yaml_parser_t;
-
-/**
- * Initialize a parser.
- *
- * This function creates a new parser object. An application is responsible
- * for destroying the object using the yaml_parser_delete() function.
- *
- * @param[out] parser An empty parser object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_parser_initialize(yaml_parser_t *parser);
-
-/**
- * Destroy a parser.
- *
- * @param[in,out] parser A parser object.
- */
-
-YAML_DECLARE(void)
-yaml_parser_delete(yaml_parser_t *parser);
-
-/**
- * Set a string input.
- *
- * Note that the @a input pointer must be valid while the @a parser object
- * exists. The application is responsible for destroing @a input after
- * destroying the @a parser.
- *
- * @param[in,out] parser A parser object.
- * @param[in] input A source data.
- * @param[in] size The length of the source data in bytes.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input_string(yaml_parser_t *parser,
- const unsigned char *input, size_t size);
-
-/**
- * Set a file input.
- *
- * @a file should be a file object open for reading. The application is
- * responsible for closing the @a file.
- *
- * @param[in,out] parser A parser object.
- * @param[in] file An open file.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file);
-
-/**
- * Set a generic input handler.
- *
- * @param[in,out] parser A parser object.
- * @param[in] handler A read handler.
- * @param[in] data Any application data for passing to the read
- * handler.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input(yaml_parser_t *parser,
- yaml_read_handler_t *handler, void *data);
-
-/**
- * Set the source encoding.
- *
- * @param[in,out] parser A parser object.
- * @param[in] encoding The source encoding.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding);
-
-/**
- * Scan the input stream and produce the next token.
- *
- * Call the function subsequently to produce a sequence of tokens corresponding
- * to the input stream. The initial token has the type
- * @c YAML_STREAM_START_TOKEN while the ending token has the type
- * @c YAML_STREAM_END_TOKEN.
- *
- * An application is responsible for freeing any buffers associated with the
- * produced token object using the @c yaml_token_delete function.
- *
- * An application must not alternate the calls of yaml_parser_scan() with the
- * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break
- * the parser.
- *
- * @param[in,out] parser A parser object.
- * @param[out] token An empty token object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
-
-/**
- * Parse the input stream and produce the next parsing event.
- *
- * Call the function subsequently to produce a sequence of events corresponding
- * to the input stream. The initial event has the type
- * @c YAML_STREAM_START_EVENT while the ending event has the type
- * @c YAML_STREAM_END_EVENT.
- *
- * An application is responsible for freeing any buffers associated with the
- * produced event object using the yaml_event_delete() function.
- *
- * An application must not alternate the calls of yaml_parser_parse() with the
- * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the
- * parser.
- *
- * @param[in,out] parser A parser object.
- * @param[out] event An empty event object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
-
-/**
- * Parse the input stream and produce the next YAML document.
- *
- * Call this function subsequently to produce a sequence of documents
- * constituting the input stream.
- *
- * If the produced document has no root node, it means that the document
- * end has been reached.
- *
- * An application is responsible for freeing any data associated with the
- * produced document object using the yaml_document_delete() function.
- *
- * An application must not alternate the calls of yaml_parser_load() with the
- * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break
- * the parser.
- *
- * @param[in,out] parser A parser object.
- * @param[out] document An empty document object.
- *
+ int token_available;
+
+ /** The indentation levels stack. */
+ struct {
+ /** The beginning of the stack. */
+ int *start;
+ /** The end of the stack. */
+ int *end;
+ /** The top of the stack. */
+ int *top;
+ } indents;
+
+ /** The current indentation level. */
+ int indent;
+
+ /** May a simple key occur at the current position? */
+ int simple_key_allowed;
+
+ /** The stack of simple keys. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_simple_key_t *start;
+ /** The end of the stack. */
+ yaml_simple_key_t *end;
+ /** The top of the stack. */
+ yaml_simple_key_t *top;
+ } simple_keys;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Parser stuff
+ * @{
+ */
+
+ /** The parser states stack. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_parser_state_t *start;
+ /** The end of the stack. */
+ yaml_parser_state_t *end;
+ /** The top of the stack. */
+ yaml_parser_state_t *top;
+ } states;
+
+ /** The current parser state. */
+ yaml_parser_state_t state;
+
+ /** The stack of marks. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_mark_t *start;
+ /** The end of the stack. */
+ yaml_mark_t *end;
+ /** The top of the stack. */
+ yaml_mark_t *top;
+ } marks;
+
+ /** The list of TAG directives. */
+ struct {
+ /** The beginning of the list. */
+ yaml_tag_directive_t *start;
+ /** The end of the list. */
+ yaml_tag_directive_t *end;
+ /** The top of the list. */
+ yaml_tag_directive_t *top;
+ } tag_directives;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Dumper stuff
+ * @{
+ */
+
+ /** The alias data. */
+ struct {
+ /** The beginning of the list. */
+ yaml_alias_data_t *start;
+ /** The end of the list. */
+ yaml_alias_data_t *end;
+ /** The top of the list. */
+ yaml_alias_data_t *top;
+ } aliases;
+
+ /** The currently parsed document. */
+ yaml_document_t *document;
+
+ /**
+ * @}
+ */
+
+} yaml_parser_t;
+
+/**
+ * Initialize a parser.
+ *
+ * This function creates a new parser object. An application is responsible
+ * for destroying the object using the yaml_parser_delete() function.
+ *
+ * @param[out] parser An empty parser object.
+ *
* @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);
-
-/** @} */
-
-/**
- * @defgroup emitter Emitter Definitions
- * @{
- */
-
-/**
- * The prototype of a write handler.
- *
- * The write handler is called when the emitter needs to flush the accumulated
- * characters to the output. The handler should write @a size bytes of the
- * @a buffer to the output.
- *
- * @param[in,out] data A pointer to an application data specified by
- * yaml_emitter_set_output().
- * @param[in] buffer The buffer with bytes to be written.
- * @param[in] size The size of the buffer.
- *
- * @returns On success, the handler should return @c 1. If the handler failed,
- * the returned value should be @c 0.
- */
-
-typedef int yaml_write_handler_t(void *data, unsigned char *buffer, size_t size);
-
-/** The emitter states. */
-typedef enum yaml_emitter_state_e {
- /** Expect STREAM-START. */
- YAML_EMIT_STREAM_START_STATE,
- /** Expect the first DOCUMENT-START or STREAM-END. */
- YAML_EMIT_FIRST_DOCUMENT_START_STATE,
- /** Expect DOCUMENT-START or STREAM-END. */
- YAML_EMIT_DOCUMENT_START_STATE,
- /** Expect the content of a document. */
- YAML_EMIT_DOCUMENT_CONTENT_STATE,
- /** Expect DOCUMENT-END. */
- YAML_EMIT_DOCUMENT_END_STATE,
-
- /** Expect the first item of a flow sequence. */
- YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
- /** Expect an item of a flow sequence. */
- YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
- /** Expect the first key of a flow mapping. */
- YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
- /** Expect a key of a flow mapping. */
- YAML_EMIT_FLOW_MAPPING_KEY_STATE,
- /** Expect a value for a simple key of a flow mapping. */
- YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
-
- /** Expect a value of a flow mapping. */
- YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
- /** Expect the first item of a block sequence. */
- YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
- /** Expect an item of a block sequence. */
- YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
- /** Expect the first key of a block mapping. */
- YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
- /** Expect the key of a block mapping. */
- YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
-
- /** Expect a value for a simple key of a block mapping. */
- YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
- /** Expect a value of a block mapping. */
- YAML_EMIT_BLOCK_MAPPING_VALUE_STATE,
- /** Expect nothing. */
- YAML_EMIT_END_STATE
-} yaml_emitter_state_t;
-
+ */
+
+YAML_DECLARE(int)
+yaml_parser_initialize(yaml_parser_t *parser);
+
+/**
+ * Destroy a parser.
+ *
+ * @param[in,out] parser A parser object.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_delete(yaml_parser_t *parser);
+
+/**
+ * Set a string input.
+ *
+ * Note that the @a input pointer must be valid while the @a parser object
+ * exists. The application is responsible for destroing @a input after
+ * destroying the @a parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] input A source data.
+ * @param[in] size The length of the source data in bytes.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_string(yaml_parser_t *parser,
+ const unsigned char *input, size_t size);
+
+/**
+ * Set a file input.
+ *
+ * @a file should be a file object open for reading. The application is
+ * responsible for closing the @a file.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] file An open file.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file);
+
+/**
+ * Set a generic input handler.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] handler A read handler.
+ * @param[in] data Any application data for passing to the read
+ * handler.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input(yaml_parser_t *parser,
+ yaml_read_handler_t *handler, void *data);
+
+/**
+ * Set the source encoding.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] encoding The source encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding);
+
+/**
+ * Scan the input stream and produce the next token.
+ *
+ * Call the function subsequently to produce a sequence of tokens corresponding
+ * to the input stream. The initial token has the type
+ * @c YAML_STREAM_START_TOKEN while the ending token has the type
+ * @c YAML_STREAM_END_TOKEN.
+ *
+ * An application is responsible for freeing any buffers associated with the
+ * produced token object using the @c yaml_token_delete function.
+ *
+ * An application must not alternate the calls of yaml_parser_scan() with the
+ * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break
+ * the parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] token An empty token object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
+
+/**
+ * Parse the input stream and produce the next parsing event.
+ *
+ * Call the function subsequently to produce a sequence of events corresponding
+ * to the input stream. The initial event has the type
+ * @c YAML_STREAM_START_EVENT while the ending event has the type
+ * @c YAML_STREAM_END_EVENT.
+ *
+ * An application is responsible for freeing any buffers associated with the
+ * produced event object using the yaml_event_delete() function.
+ *
+ * An application must not alternate the calls of yaml_parser_parse() with the
+ * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the
+ * parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
+
+/**
+ * Parse the input stream and produce the next YAML document.
+ *
+ * Call this function subsequently to produce a sequence of documents
+ * constituting the input stream.
+ *
+ * If the produced document has no root node, it means that the document
+ * end has been reached.
+ *
+ * An application is responsible for freeing any data associated with the
+ * produced document object using the yaml_document_delete() function.
+ *
+ * An application must not alternate the calls of yaml_parser_load() with the
+ * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break
+ * the parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] document An empty document object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);
+
+/** @} */
+
+/**
+ * @defgroup emitter Emitter Definitions
+ * @{
+ */
+
+/**
+ * The prototype of a write handler.
+ *
+ * The write handler is called when the emitter needs to flush the accumulated
+ * characters to the output. The handler should write @a size bytes of the
+ * @a buffer to the output.
+ *
+ * @param[in,out] data A pointer to an application data specified by
+ * yaml_emitter_set_output().
+ * @param[in] buffer The buffer with bytes to be written.
+ * @param[in] size The size of the buffer.
+ *
+ * @returns On success, the handler should return @c 1. If the handler failed,
+ * the returned value should be @c 0.
+ */
+
+typedef int yaml_write_handler_t(void *data, unsigned char *buffer, size_t size);
+
+/** The emitter states. */
+typedef enum yaml_emitter_state_e {
+ /** Expect STREAM-START. */
+ YAML_EMIT_STREAM_START_STATE,
+ /** Expect the first DOCUMENT-START or STREAM-END. */
+ YAML_EMIT_FIRST_DOCUMENT_START_STATE,
+ /** Expect DOCUMENT-START or STREAM-END. */
+ YAML_EMIT_DOCUMENT_START_STATE,
+ /** Expect the content of a document. */
+ YAML_EMIT_DOCUMENT_CONTENT_STATE,
+ /** Expect DOCUMENT-END. */
+ YAML_EMIT_DOCUMENT_END_STATE,
+
+ /** Expect the first item of a flow sequence. */
+ YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
+ /** Expect an item of a flow sequence. */
+ YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
+ /** Expect the first key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
+ /** Expect a key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_KEY_STATE,
+ /** Expect a value for a simple key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
+
+ /** Expect a value of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
+ /** Expect the first item of a block sequence. */
+ YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
+ /** Expect an item of a block sequence. */
+ YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
+ /** Expect the first key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
+ /** Expect the key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
+
+ /** Expect a value for a simple key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
+ /** Expect a value of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_VALUE_STATE,
+ /** Expect nothing. */
+ YAML_EMIT_END_STATE
+} yaml_emitter_state_t;
+
/* This is needed for C++ */
@@ -1538,450 +1538,450 @@ typedef struct yaml_anchors_s {
int serialized;
} yaml_anchors_t;
-/**
- * The emitter structure.
- *
- * All members are internal. Manage the structure using the @c yaml_emitter_
- * family of functions.
- */
-
-typedef struct yaml_emitter_s {
-
- /**
- * @name Error handling
- * @{
- */
-
- /** Error type. */
- yaml_error_type_t error;
- /** Error description. */
- const char *problem;
-
- /**
- * @}
- */
-
- /**
- * @name Writer stuff
- * @{
- */
-
- /** Write handler. */
- yaml_write_handler_t *write_handler;
-
+/**
+ * The emitter structure.
+ *
+ * All members are internal. Manage the structure using the @c yaml_emitter_
+ * family of functions.
+ */
+
+typedef struct yaml_emitter_s {
+
+ /**
+ * @name Error handling
+ * @{
+ */
+
+ /** Error type. */
+ yaml_error_type_t error;
+ /** Error description. */
+ const char *problem;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Writer stuff
+ * @{
+ */
+
+ /** Write handler. */
+ yaml_write_handler_t *write_handler;
+
/** A pointer for passing to the write handler. */
- void *write_handler_data;
-
- /** Standard (string or file) output data. */
- union {
- /** String output data. */
- struct {
- /** The buffer pointer. */
- unsigned char *buffer;
- /** The buffer size. */
- size_t size;
- /** The number of written bytes. */
- size_t *size_written;
- } string;
-
- /** File output data. */
- FILE *file;
- } output;
-
- /** The working buffer. */
- struct {
- /** The beginning of the buffer. */
- yaml_char_t *start;
- /** The end of the buffer. */
- yaml_char_t *end;
- /** The current position of the buffer. */
- yaml_char_t *pointer;
- /** The last filled position of the buffer. */
- yaml_char_t *last;
- } buffer;
-
- /** The raw buffer. */
- struct {
- /** The beginning of the buffer. */
- unsigned char *start;
- /** The end of the buffer. */
- unsigned char *end;
- /** The current position of the buffer. */
- unsigned char *pointer;
- /** The last filled position of the buffer. */
- unsigned char *last;
- } raw_buffer;
-
- /** The stream encoding. */
- yaml_encoding_t encoding;
-
- /**
- * @}
- */
-
- /**
- * @name Emitter stuff
- * @{
- */
-
- /** If the output is in the canonical style? */
- int canonical;
- /** The number of indentation spaces. */
- int best_indent;
- /** The preferred width of the output lines. */
- int best_width;
- /** Allow unescaped non-ASCII characters? */
- int unicode;
- /** The preferred line break. */
- yaml_break_t line_break;
-
- /** The stack of states. */
- struct {
- /** The beginning of the stack. */
- yaml_emitter_state_t *start;
- /** The end of the stack. */
- yaml_emitter_state_t *end;
- /** The top of the stack. */
- yaml_emitter_state_t *top;
- } states;
-
- /** The current emitter state. */
- yaml_emitter_state_t state;
-
- /** The event queue. */
- struct {
- /** The beginning of the event queue. */
- yaml_event_t *start;
- /** The end of the event queue. */
- yaml_event_t *end;
- /** The head of the event queue. */
- yaml_event_t *head;
- /** The tail of the event queue. */
- yaml_event_t *tail;
- } events;
-
- /** The stack of indentation levels. */
- struct {
- /** The beginning of the stack. */
- int *start;
- /** The end of the stack. */
- int *end;
- /** The top of the stack. */
- int *top;
- } indents;
-
- /** The list of tag directives. */
- struct {
- /** The beginning of the list. */
- yaml_tag_directive_t *start;
- /** The end of the list. */
- yaml_tag_directive_t *end;
- /** The top of the list. */
- yaml_tag_directive_t *top;
- } tag_directives;
-
- /** The current indentation level. */
- int indent;
-
- /** The current flow level. */
- int flow_level;
-
- /** Is it the document root context? */
- int root_context;
- /** Is it a sequence context? */
- int sequence_context;
- /** Is it a mapping context? */
- int mapping_context;
- /** Is it a simple mapping key context? */
- int simple_key_context;
-
- /** The current line. */
- int line;
- /** The current column. */
- int column;
- /** If the last character was a whitespace? */
- int whitespace;
- /** If the last character was an indentation character (' ', '-', '?', ':')? */
- int indention;
- /** If an explicit document end is required? */
- int open_ended;
-
- /** Anchor analysis. */
- struct {
- /** The anchor value. */
- yaml_char_t *anchor;
- /** The anchor length. */
- size_t anchor_length;
- /** Is it an alias? */
- int alias;
- } anchor_data;
-
- /** Tag analysis. */
- struct {
- /** The tag handle. */
- yaml_char_t *handle;
- /** The tag handle length. */
- size_t handle_length;
- /** The tag suffix. */
- yaml_char_t *suffix;
- /** The tag suffix length. */
- size_t suffix_length;
- } tag_data;
-
- /** Scalar analysis. */
- struct {
- /** The scalar value. */
- yaml_char_t *value;
- /** The scalar length. */
- size_t length;
- /** Does the scalar contain line breaks? */
- int multiline;
- /** Can the scalar be expessed in the flow plain style? */
- int flow_plain_allowed;
- /** Can the scalar be expressed in the block plain style? */
- int block_plain_allowed;
- /** Can the scalar be expressed in the single quoted style? */
- int single_quoted_allowed;
- /** Can the scalar be expressed in the literal or folded styles? */
- int block_allowed;
- /** The output style. */
- yaml_scalar_style_t style;
- } scalar_data;
-
- /**
- * @}
- */
-
- /**
- * @name Dumper stuff
- * @{
- */
-
- /** If the stream was already opened? */
- int opened;
- /** If the stream was already closed? */
- int closed;
-
- /** The information associated with the document nodes. */
+ void *write_handler_data;
+
+ /** Standard (string or file) output data. */
+ union {
+ /** String output data. */
+ struct {
+ /** The buffer pointer. */
+ unsigned char *buffer;
+ /** The buffer size. */
+ size_t size;
+ /** The number of written bytes. */
+ size_t *size_written;
+ } string;
+
+ /** File output data. */
+ FILE *file;
+ } output;
+
+ /** The working buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ yaml_char_t *start;
+ /** The end of the buffer. */
+ yaml_char_t *end;
+ /** The current position of the buffer. */
+ yaml_char_t *pointer;
+ /** The last filled position of the buffer. */
+ yaml_char_t *last;
+ } buffer;
+
+ /** The raw buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ unsigned char *start;
+ /** The end of the buffer. */
+ unsigned char *end;
+ /** The current position of the buffer. */
+ unsigned char *pointer;
+ /** The last filled position of the buffer. */
+ unsigned char *last;
+ } raw_buffer;
+
+ /** The stream encoding. */
+ yaml_encoding_t encoding;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Emitter stuff
+ * @{
+ */
+
+ /** If the output is in the canonical style? */
+ int canonical;
+ /** The number of indentation spaces. */
+ int best_indent;
+ /** The preferred width of the output lines. */
+ int best_width;
+ /** Allow unescaped non-ASCII characters? */
+ int unicode;
+ /** The preferred line break. */
+ yaml_break_t line_break;
+
+ /** The stack of states. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_emitter_state_t *start;
+ /** The end of the stack. */
+ yaml_emitter_state_t *end;
+ /** The top of the stack. */
+ yaml_emitter_state_t *top;
+ } states;
+
+ /** The current emitter state. */
+ yaml_emitter_state_t state;
+
+ /** The event queue. */
+ struct {
+ /** The beginning of the event queue. */
+ yaml_event_t *start;
+ /** The end of the event queue. */
+ yaml_event_t *end;
+ /** The head of the event queue. */
+ yaml_event_t *head;
+ /** The tail of the event queue. */
+ yaml_event_t *tail;
+ } events;
+
+ /** The stack of indentation levels. */
+ struct {
+ /** The beginning of the stack. */
+ int *start;
+ /** The end of the stack. */
+ int *end;
+ /** The top of the stack. */
+ int *top;
+ } indents;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the list. */
+ yaml_tag_directive_t *start;
+ /** The end of the list. */
+ yaml_tag_directive_t *end;
+ /** The top of the list. */
+ yaml_tag_directive_t *top;
+ } tag_directives;
+
+ /** The current indentation level. */
+ int indent;
+
+ /** The current flow level. */
+ int flow_level;
+
+ /** Is it the document root context? */
+ int root_context;
+ /** Is it a sequence context? */
+ int sequence_context;
+ /** Is it a mapping context? */
+ int mapping_context;
+ /** Is it a simple mapping key context? */
+ int simple_key_context;
+
+ /** The current line. */
+ int line;
+ /** The current column. */
+ int column;
+ /** If the last character was a whitespace? */
+ int whitespace;
+ /** If the last character was an indentation character (' ', '-', '?', ':')? */
+ int indention;
+ /** If an explicit document end is required? */
+ int open_ended;
+
+ /** Anchor analysis. */
+ struct {
+ /** The anchor value. */
+ yaml_char_t *anchor;
+ /** The anchor length. */
+ size_t anchor_length;
+ /** Is it an alias? */
+ int alias;
+ } anchor_data;
+
+ /** Tag analysis. */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag handle length. */
+ size_t handle_length;
+ /** The tag suffix. */
+ yaml_char_t *suffix;
+ /** The tag suffix length. */
+ size_t suffix_length;
+ } tag_data;
+
+ /** Scalar analysis. */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The scalar length. */
+ size_t length;
+ /** Does the scalar contain line breaks? */
+ int multiline;
+ /** Can the scalar be expessed in the flow plain style? */
+ int flow_plain_allowed;
+ /** Can the scalar be expressed in the block plain style? */
+ int block_plain_allowed;
+ /** Can the scalar be expressed in the single quoted style? */
+ int single_quoted_allowed;
+ /** Can the scalar be expressed in the literal or folded styles? */
+ int block_allowed;
+ /** The output style. */
+ yaml_scalar_style_t style;
+ } scalar_data;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Dumper stuff
+ * @{
+ */
+
+ /** If the stream was already opened? */
+ int opened;
+ /** If the stream was already closed? */
+ int closed;
+
+ /** The information associated with the document nodes. */
yaml_anchors_t *anchors;
-
- /** The last assigned anchor id. */
- int last_anchor_id;
-
- /** The currently emitted document. */
- yaml_document_t *document;
-
- /**
- * @}
- */
-
-} yaml_emitter_t;
-
-/**
- * Initialize an emitter.
- *
- * This function creates a new emitter object. An application is responsible
- * for destroying the object using the yaml_emitter_delete() function.
- *
- * @param[out] emitter An empty parser object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_initialize(yaml_emitter_t *emitter);
-
-/**
- * Destroy an emitter.
- *
- * @param[in,out] emitter An emitter object.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_delete(yaml_emitter_t *emitter);
-
-/**
- * Set a string output.
- *
- * The emitter will write the output characters to the @a output buffer of the
- * size @a size. The emitter will set @a size_written to the number of written
- * bytes. If the buffer is smaller than required, the emitter produces the
- * YAML_WRITE_ERROR error.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] output An output buffer.
- * @param[in] size The buffer size.
- * @param[in] size_written The pointer to save the number of written
- * bytes.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output_string(yaml_emitter_t *emitter,
- unsigned char *output, size_t size, size_t *size_written);
-
-/**
- * Set a file output.
- *
- * @a file should be a file object open for writing. The application is
- * responsible for closing the @a file.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] file An open file.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file);
-
-/**
- * Set a generic output handler.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] handler A write handler.
- * @param[in] data Any application data for passing to the write
- * handler.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output(yaml_emitter_t *emitter,
- yaml_write_handler_t *handler, void *data);
-
-/**
- * Set the output encoding.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] encoding The output encoding.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding);
-
-/**
- * Set if the output should be in the "canonical" format as in the YAML
- * specification.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] canonical If the output is canonical.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
-
-/**
+
+ /** The last assigned anchor id. */
+ int last_anchor_id;
+
+ /** The currently emitted document. */
+ yaml_document_t *document;
+
+ /**
+ * @}
+ */
+
+} yaml_emitter_t;
+
+/**
+ * Initialize an emitter.
+ *
+ * This function creates a new emitter object. An application is responsible
+ * for destroying the object using the yaml_emitter_delete() function.
+ *
+ * @param[out] emitter An empty parser object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_initialize(yaml_emitter_t *emitter);
+
+/**
+ * Destroy an emitter.
+ *
+ * @param[in,out] emitter An emitter object.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_delete(yaml_emitter_t *emitter);
+
+/**
+ * Set a string output.
+ *
+ * The emitter will write the output characters to the @a output buffer of the
+ * size @a size. The emitter will set @a size_written to the number of written
+ * bytes. If the buffer is smaller than required, the emitter produces the
+ * YAML_WRITE_ERROR error.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] output An output buffer.
+ * @param[in] size The buffer size.
+ * @param[in] size_written The pointer to save the number of written
+ * bytes.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_string(yaml_emitter_t *emitter,
+ unsigned char *output, size_t size, size_t *size_written);
+
+/**
+ * Set a file output.
+ *
+ * @a file should be a file object open for writing. The application is
+ * responsible for closing the @a file.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] file An open file.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file);
+
+/**
+ * Set a generic output handler.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] handler A write handler.
+ * @param[in] data Any application data for passing to the write
+ * handler.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output(yaml_emitter_t *emitter,
+ yaml_write_handler_t *handler, void *data);
+
+/**
+ * Set the output encoding.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] encoding The output encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding);
+
+/**
+ * Set if the output should be in the "canonical" format as in the YAML
+ * specification.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] canonical If the output is canonical.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
+
+/**
* Set the indentation increment.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] indent The indentation increment (1 < . < 10).
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent);
-
-/**
- * Set the preferred line width. @c -1 means unlimited.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] width The preferred line width.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_width(yaml_emitter_t *emitter, int width);
-
-/**
- * Set if unescaped non-ASCII characters are allowed.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] unicode If unescaped Unicode characters are allowed.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode);
-
-/**
- * Set the preferred line break.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in] line_break The preferred line break.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break);
-
-/**
- * Emit an event.
- *
- * The event object may be generated using the yaml_parser_parse() function.
- * The emitter takes the responsibility for the event object and destroys its
- * content after it is emitted. The event object is destroyed even if the
- * function fails.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in,out] event An event object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
-
-/**
- * Start a YAML stream.
- *
- * This function should be used before yaml_emitter_dump() is called.
- *
- * @param[in,out] emitter An emitter object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_open(yaml_emitter_t *emitter);
-
-/**
- * Finish a YAML stream.
- *
- * This function should be used after yaml_emitter_dump() is called.
- *
- * @param[in,out] emitter An emitter object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_close(yaml_emitter_t *emitter);
-
-/**
- * Emit a YAML document.
- *
- * The documen object may be generated using the yaml_parser_load() function
- * or the yaml_document_initialize() function. The emitter takes the
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] indent The indentation increment (1 < . < 10).
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent);
+
+/**
+ * Set the preferred line width. @c -1 means unlimited.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] width The preferred line width.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_width(yaml_emitter_t *emitter, int width);
+
+/**
+ * Set if unescaped non-ASCII characters are allowed.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] unicode If unescaped Unicode characters are allowed.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode);
+
+/**
+ * Set the preferred line break.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] line_break The preferred line break.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break);
+
+/**
+ * Emit an event.
+ *
+ * The event object may be generated using the yaml_parser_parse() function.
+ * The emitter takes the responsibility for the event object and destroys its
+ * content after it is emitted. The event object is destroyed even if the
+ * function fails.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in,out] event An event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/**
+ * Start a YAML stream.
+ *
+ * This function should be used before yaml_emitter_dump() is called.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_open(yaml_emitter_t *emitter);
+
+/**
+ * Finish a YAML stream.
+ *
+ * This function should be used after yaml_emitter_dump() is called.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_close(yaml_emitter_t *emitter);
+
+/**
+ * Emit a YAML document.
+ *
+ * The documen object may be generated using the yaml_parser_load() function
+ * or the yaml_document_initialize() function. The emitter takes the
* responsibility for the document object and destroys its content after
* it is emitted. The document object is destroyed even if the function fails.
- *
- * @param[in,out] emitter An emitter object.
- * @param[in,out] document A document object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
-
-/**
- * Flush the accumulated characters to the output.
- *
- * @param[in,out] emitter An emitter object.
- *
- * @returns @c 1 if the function succeeded, @c 0 on error.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_flush(yaml_emitter_t *emitter);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* #ifndef YAML_H */
-
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in,out] document A document object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
+
+/**
+ * Flush the accumulated characters to the output.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_flush(yaml_emitter_t *emitter);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef YAML_H */
+
diff --git a/contrib/libs/yaml/src/api.c b/contrib/libs/yaml/src/api.c
index c237c83564..16f88bd762 100644
--- a/contrib/libs/yaml/src/api.c
+++ b/contrib/libs/yaml/src/api.c
@@ -1,1393 +1,1393 @@
-
-#include "yaml_private.h"
-
-/*
- * Get the library version.
- */
-
-YAML_DECLARE(const char *)
-yaml_get_version_string(void)
-{
- return YAML_VERSION_STRING;
-}
-
-/*
- * Get the library version numbers.
- */
-
-YAML_DECLARE(void)
-yaml_get_version(int *major, int *minor, int *patch)
-{
- *major = YAML_VERSION_MAJOR;
- *minor = YAML_VERSION_MINOR;
- *patch = YAML_VERSION_PATCH;
-}
-
-/*
- * Allocate a dynamic memory block.
- */
-
-YAML_DECLARE(void *)
-yaml_malloc(size_t size)
-{
- return malloc(size ? size : 1);
-}
-
-/*
- * Reallocate a dynamic memory block.
- */
-
-YAML_DECLARE(void *)
-yaml_realloc(void *ptr, size_t size)
-{
- return ptr ? realloc(ptr, size ? size : 1) : malloc(size ? size : 1);
-}
-
-/*
- * Free a dynamic memory block.
- */
-
-YAML_DECLARE(void)
-yaml_free(void *ptr)
-{
- if (ptr) free(ptr);
-}
-
-/*
- * Duplicate a string.
- */
-
-YAML_DECLARE(yaml_char_t *)
-yaml_strdup(const yaml_char_t *str)
-{
- if (!str)
- return NULL;
-
- return (yaml_char_t *)strdup((char *)str);
-}
-
-/*
- * Extend a string.
- */
-
-YAML_DECLARE(int)
-yaml_string_extend(yaml_char_t **start,
- yaml_char_t **pointer, yaml_char_t **end)
-{
+
+#include "yaml_private.h"
+
+/*
+ * Get the library version.
+ */
+
+YAML_DECLARE(const char *)
+yaml_get_version_string(void)
+{
+ return YAML_VERSION_STRING;
+}
+
+/*
+ * Get the library version numbers.
+ */
+
+YAML_DECLARE(void)
+yaml_get_version(int *major, int *minor, int *patch)
+{
+ *major = YAML_VERSION_MAJOR;
+ *minor = YAML_VERSION_MINOR;
+ *patch = YAML_VERSION_PATCH;
+}
+
+/*
+ * Allocate a dynamic memory block.
+ */
+
+YAML_DECLARE(void *)
+yaml_malloc(size_t size)
+{
+ return malloc(size ? size : 1);
+}
+
+/*
+ * Reallocate a dynamic memory block.
+ */
+
+YAML_DECLARE(void *)
+yaml_realloc(void *ptr, size_t size)
+{
+ return ptr ? realloc(ptr, size ? size : 1) : malloc(size ? size : 1);
+}
+
+/*
+ * Free a dynamic memory block.
+ */
+
+YAML_DECLARE(void)
+yaml_free(void *ptr)
+{
+ if (ptr) free(ptr);
+}
+
+/*
+ * Duplicate a string.
+ */
+
+YAML_DECLARE(yaml_char_t *)
+yaml_strdup(const yaml_char_t *str)
+{
+ if (!str)
+ return NULL;
+
+ return (yaml_char_t *)strdup((char *)str);
+}
+
+/*
+ * Extend a string.
+ */
+
+YAML_DECLARE(int)
+yaml_string_extend(yaml_char_t **start,
+ yaml_char_t **pointer, yaml_char_t **end)
+{
yaml_char_t *new_start = (yaml_char_t *)yaml_realloc((void*)*start, (*end - *start)*2);
-
- if (!new_start) return 0;
-
- memset(new_start + (*end - *start), 0, *end - *start);
-
- *pointer = new_start + (*pointer - *start);
- *end = new_start + (*end - *start)*2;
- *start = new_start;
-
- return 1;
-}
-
-/*
- * Append a string B to a string A.
- */
-
-YAML_DECLARE(int)
-yaml_string_join(
- yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
+
+ if (!new_start) return 0;
+
+ memset(new_start + (*end - *start), 0, *end - *start);
+
+ *pointer = new_start + (*pointer - *start);
+ *end = new_start + (*end - *start)*2;
+ *start = new_start;
+
+ return 1;
+}
+
+/*
+ * Append a string B to a string A.
+ */
+
+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, SHIM(yaml_char_t **b_end))
-{
+{
UNUSED_PARAM(b_end)
- if (*b_start == *b_pointer)
- return 1;
-
- while (*a_end - *a_pointer <= *b_pointer - *b_start) {
- if (!yaml_string_extend(a_start, a_pointer, a_end))
- return 0;
- }
-
- memcpy(*a_pointer, *b_start, *b_pointer - *b_start);
- *a_pointer += *b_pointer - *b_start;
-
- return 1;
-}
-
-/*
- * Extend a stack.
- */
-
-YAML_DECLARE(int)
-yaml_stack_extend(void **start, void **top, void **end)
-{
+ if (*b_start == *b_pointer)
+ return 1;
+
+ while (*a_end - *a_pointer <= *b_pointer - *b_start) {
+ if (!yaml_string_extend(a_start, a_pointer, a_end))
+ return 0;
+ }
+
+ memcpy(*a_pointer, *b_start, *b_pointer - *b_start);
+ *a_pointer += *b_pointer - *b_start;
+
+ return 1;
+}
+
+/*
+ * Extend a stack.
+ */
+
+YAML_DECLARE(int)
+yaml_stack_extend(void **start, void **top, void **end)
+{
void *new_start;
-
+
if ((char *)*end - (char *)*start >= INT_MAX / 2)
return 0;
new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
- if (!new_start) return 0;
-
- *top = (char *)new_start + ((char *)*top - (char *)*start);
- *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
- *start = new_start;
-
- return 1;
-}
-
-/*
- * Extend or move a queue.
- */
-
-YAML_DECLARE(int)
-yaml_queue_extend(void **start, void **head, void **tail, void **end)
-{
- /* Check if we need to resize the queue. */
-
- if (*start == *head && *tail == *end) {
- void *new_start = yaml_realloc(*start,
- ((char *)*end - (char *)*start)*2);
-
- if (!new_start) return 0;
-
- *head = (char *)new_start + ((char *)*head - (char *)*start);
- *tail = (char *)new_start + ((char *)*tail - (char *)*start);
- *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
- *start = new_start;
- }
-
- /* Check if we need to move the queue at the beginning of the buffer. */
-
- if (*tail == *end) {
- if (*head != *tail) {
- memmove(*start, *head, (char *)*tail - (char *)*head);
- }
- *tail = (char *)*tail - (char *)*head + (char *)*start;
- *head = *start;
- }
-
- return 1;
-}
-
-
-/*
- * Create a new parser object.
- */
-
-YAML_DECLARE(int)
-yaml_parser_initialize(yaml_parser_t *parser)
-{
- assert(parser); /* Non-NULL parser object expected. */
-
- memset(parser, 0, sizeof(yaml_parser_t));
- if (!BUFFER_INIT(parser, parser->raw_buffer, INPUT_RAW_BUFFER_SIZE))
- goto error;
- if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
- goto error;
+ if (!new_start) return 0;
+
+ *top = (char *)new_start + ((char *)*top - (char *)*start);
+ *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
+ *start = new_start;
+
+ return 1;
+}
+
+/*
+ * Extend or move a queue.
+ */
+
+YAML_DECLARE(int)
+yaml_queue_extend(void **start, void **head, void **tail, void **end)
+{
+ /* Check if we need to resize the queue. */
+
+ if (*start == *head && *tail == *end) {
+ void *new_start = yaml_realloc(*start,
+ ((char *)*end - (char *)*start)*2);
+
+ if (!new_start) return 0;
+
+ *head = (char *)new_start + ((char *)*head - (char *)*start);
+ *tail = (char *)new_start + ((char *)*tail - (char *)*start);
+ *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
+ *start = new_start;
+ }
+
+ /* Check if we need to move the queue at the beginning of the buffer. */
+
+ if (*tail == *end) {
+ if (*head != *tail) {
+ memmove(*start, *head, (char *)*tail - (char *)*head);
+ }
+ *tail = (char *)*tail - (char *)*head + (char *)*start;
+ *head = *start;
+ }
+
+ return 1;
+}
+
+
+/*
+ * Create a new parser object.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_initialize(yaml_parser_t *parser)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+
+ memset(parser, 0, sizeof(yaml_parser_t));
+ if (!BUFFER_INIT(parser, parser->raw_buffer, INPUT_RAW_BUFFER_SIZE))
+ goto error;
+ if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
+ goto error;
if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE, yaml_token_t*))
- goto error;
+ goto error;
if (!STACK_INIT(parser, parser->indents, int*))
- goto error;
+ goto error;
if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*))
- goto error;
+ goto error;
if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*))
- goto error;
+ goto error;
if (!STACK_INIT(parser, parser->marks, yaml_mark_t*))
- goto error;
+ goto error;
if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*))
- goto error;
-
- return 1;
-
-error:
-
- BUFFER_DEL(parser, parser->raw_buffer);
- BUFFER_DEL(parser, parser->buffer);
- QUEUE_DEL(parser, parser->tokens);
- STACK_DEL(parser, parser->indents);
- STACK_DEL(parser, parser->simple_keys);
- STACK_DEL(parser, parser->states);
- STACK_DEL(parser, parser->marks);
- STACK_DEL(parser, parser->tag_directives);
-
- return 0;
-}
-
-/*
- * Destroy a parser object.
- */
-
-YAML_DECLARE(void)
-yaml_parser_delete(yaml_parser_t *parser)
-{
- assert(parser); /* Non-NULL parser object expected. */
-
- BUFFER_DEL(parser, parser->raw_buffer);
- BUFFER_DEL(parser, parser->buffer);
- while (!QUEUE_EMPTY(parser, parser->tokens)) {
- yaml_token_delete(&DEQUEUE(parser, parser->tokens));
- }
- QUEUE_DEL(parser, parser->tokens);
- STACK_DEL(parser, parser->indents);
- STACK_DEL(parser, parser->simple_keys);
- STACK_DEL(parser, parser->states);
- STACK_DEL(parser, parser->marks);
- while (!STACK_EMPTY(parser, parser->tag_directives)) {
- yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
- yaml_free(tag_directive.handle);
- yaml_free(tag_directive.prefix);
- }
- STACK_DEL(parser, parser->tag_directives);
-
- memset(parser, 0, sizeof(yaml_parser_t));
-}
-
-/*
- * String read handler.
- */
-
-static int
-yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
- size_t *size_read)
-{
+ goto error;
+
+ return 1;
+
+error:
+
+ BUFFER_DEL(parser, parser->raw_buffer);
+ BUFFER_DEL(parser, parser->buffer);
+ QUEUE_DEL(parser, parser->tokens);
+ STACK_DEL(parser, parser->indents);
+ STACK_DEL(parser, parser->simple_keys);
+ STACK_DEL(parser, parser->states);
+ STACK_DEL(parser, parser->marks);
+ STACK_DEL(parser, parser->tag_directives);
+
+ return 0;
+}
+
+/*
+ * Destroy a parser object.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_delete(yaml_parser_t *parser)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+
+ BUFFER_DEL(parser, parser->raw_buffer);
+ BUFFER_DEL(parser, parser->buffer);
+ while (!QUEUE_EMPTY(parser, parser->tokens)) {
+ yaml_token_delete(&DEQUEUE(parser, parser->tokens));
+ }
+ QUEUE_DEL(parser, parser->tokens);
+ STACK_DEL(parser, parser->indents);
+ STACK_DEL(parser, parser->simple_keys);
+ STACK_DEL(parser, parser->states);
+ STACK_DEL(parser, parser->marks);
+ while (!STACK_EMPTY(parser, parser->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(parser, parser->tag_directives);
+
+ memset(parser, 0, sizeof(yaml_parser_t));
+}
+
+/*
+ * String read handler.
+ */
+
+static int
+yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read)
+{
yaml_parser_t *parser = (yaml_parser_t *)data;
-
- if (parser->input.string.current == parser->input.string.end) {
- *size_read = 0;
- return 1;
- }
-
- if (size > (size_t)(parser->input.string.end
- - parser->input.string.current)) {
- size = parser->input.string.end - parser->input.string.current;
- }
-
- memcpy(buffer, parser->input.string.current, size);
- parser->input.string.current += size;
- *size_read = size;
- return 1;
-}
-
-/*
- * File read handler.
- */
-
-static int
-yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
- size_t *size_read)
-{
+
+ if (parser->input.string.current == parser->input.string.end) {
+ *size_read = 0;
+ return 1;
+ }
+
+ if (size > (size_t)(parser->input.string.end
+ - parser->input.string.current)) {
+ size = parser->input.string.end - parser->input.string.current;
+ }
+
+ memcpy(buffer, parser->input.string.current, size);
+ parser->input.string.current += size;
+ *size_read = size;
+ return 1;
+}
+
+/*
+ * File read handler.
+ */
+
+static int
+yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read)
+{
yaml_parser_t *parser = (yaml_parser_t *)data;
-
- *size_read = fread(buffer, 1, size, parser->input.file);
- return !ferror(parser->input.file);
-}
-
-/*
- * Set a string input.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input_string(yaml_parser_t *parser,
- const unsigned char *input, size_t size)
-{
- assert(parser); /* Non-NULL parser object expected. */
- assert(!parser->read_handler); /* You can set the source only once. */
- assert(input); /* Non-NULL input string expected. */
-
- parser->read_handler = yaml_string_read_handler;
- parser->read_handler_data = parser;
-
- parser->input.string.start = input;
- parser->input.string.current = input;
- parser->input.string.end = input+size;
-}
-
-/*
- * Set a file input.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file)
-{
- assert(parser); /* Non-NULL parser object expected. */
- assert(!parser->read_handler); /* You can set the source only once. */
- assert(file); /* Non-NULL file object expected. */
-
- parser->read_handler = yaml_file_read_handler;
- parser->read_handler_data = parser;
-
- parser->input.file = file;
-}
-
-/*
- * Set a generic input.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_input(yaml_parser_t *parser,
- yaml_read_handler_t *handler, void *data)
-{
- assert(parser); /* Non-NULL parser object expected. */
- assert(!parser->read_handler); /* You can set the source only once. */
- assert(handler); /* Non-NULL read handler expected. */
-
- parser->read_handler = handler;
- parser->read_handler_data = data;
-}
-
-/*
- * Set the source encoding.
- */
-
-YAML_DECLARE(void)
-yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding)
-{
- assert(parser); /* Non-NULL parser object expected. */
- assert(!parser->encoding); /* Encoding is already set or detected. */
-
- parser->encoding = encoding;
-}
-
-/*
- * Create a new emitter object.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_initialize(yaml_emitter_t *emitter)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- memset(emitter, 0, sizeof(yaml_emitter_t));
- if (!BUFFER_INIT(emitter, emitter->buffer, OUTPUT_BUFFER_SIZE))
- goto error;
- if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
- goto error;
+
+ *size_read = fread(buffer, 1, size, parser->input.file);
+ return !ferror(parser->input.file);
+}
+
+/*
+ * Set a string input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_string(yaml_parser_t *parser,
+ const unsigned char *input, size_t size)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(input); /* Non-NULL input string expected. */
+
+ parser->read_handler = yaml_string_read_handler;
+ parser->read_handler_data = parser;
+
+ parser->input.string.start = input;
+ parser->input.string.current = input;
+ parser->input.string.end = input+size;
+}
+
+/*
+ * Set a file input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(file); /* Non-NULL file object expected. */
+
+ parser->read_handler = yaml_file_read_handler;
+ parser->read_handler_data = parser;
+
+ parser->input.file = file;
+}
+
+/*
+ * Set a generic input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input(yaml_parser_t *parser,
+ yaml_read_handler_t *handler, void *data)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(handler); /* Non-NULL read handler expected. */
+
+ parser->read_handler = handler;
+ parser->read_handler_data = data;
+}
+
+/*
+ * Set the source encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->encoding); /* Encoding is already set or detected. */
+
+ parser->encoding = encoding;
+}
+
+/*
+ * Create a new emitter object.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_initialize(yaml_emitter_t *emitter)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ memset(emitter, 0, sizeof(yaml_emitter_t));
+ if (!BUFFER_INIT(emitter, emitter->buffer, OUTPUT_BUFFER_SIZE))
+ goto error;
+ if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
+ goto error;
if (!STACK_INIT(emitter, emitter->states, yaml_emitter_state_t*))
- goto error;
+ goto error;
if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*))
- goto error;
+ goto error;
if (!STACK_INIT(emitter, emitter->indents, int*))
- goto error;
+ goto error;
if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*))
- goto error;
-
- return 1;
-
-error:
-
- BUFFER_DEL(emitter, emitter->buffer);
- BUFFER_DEL(emitter, emitter->raw_buffer);
- STACK_DEL(emitter, emitter->states);
- QUEUE_DEL(emitter, emitter->events);
- STACK_DEL(emitter, emitter->indents);
- STACK_DEL(emitter, emitter->tag_directives);
-
- return 0;
-}
-
-/*
- * Destroy an emitter object.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_delete(yaml_emitter_t *emitter)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- BUFFER_DEL(emitter, emitter->buffer);
- BUFFER_DEL(emitter, emitter->raw_buffer);
- STACK_DEL(emitter, emitter->states);
- while (!QUEUE_EMPTY(emitter, emitter->events)) {
- yaml_event_delete(&DEQUEUE(emitter, emitter->events));
- }
- QUEUE_DEL(emitter, emitter->events);
- STACK_DEL(emitter, emitter->indents);
- while (!STACK_EMPTY(empty, emitter->tag_directives)) {
- yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
- yaml_free(tag_directive.handle);
- yaml_free(tag_directive.prefix);
- }
- STACK_DEL(emitter, emitter->tag_directives);
- yaml_free(emitter->anchors);
-
- memset(emitter, 0, sizeof(yaml_emitter_t));
-}
-
-/*
- * String write handler.
- */
-
-static int
-yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
-{
+ goto error;
+
+ return 1;
+
+error:
+
+ BUFFER_DEL(emitter, emitter->buffer);
+ BUFFER_DEL(emitter, emitter->raw_buffer);
+ STACK_DEL(emitter, emitter->states);
+ QUEUE_DEL(emitter, emitter->events);
+ STACK_DEL(emitter, emitter->indents);
+ STACK_DEL(emitter, emitter->tag_directives);
+
+ return 0;
+}
+
+/*
+ * Destroy an emitter object.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_delete(yaml_emitter_t *emitter)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ BUFFER_DEL(emitter, emitter->buffer);
+ BUFFER_DEL(emitter, emitter->raw_buffer);
+ STACK_DEL(emitter, emitter->states);
+ while (!QUEUE_EMPTY(emitter, emitter->events)) {
+ yaml_event_delete(&DEQUEUE(emitter, emitter->events));
+ }
+ QUEUE_DEL(emitter, emitter->events);
+ STACK_DEL(emitter, emitter->indents);
+ while (!STACK_EMPTY(empty, emitter->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(emitter, emitter->tag_directives);
+ yaml_free(emitter->anchors);
+
+ memset(emitter, 0, sizeof(yaml_emitter_t));
+}
+
+/*
+ * String write handler.
+ */
+
+static int
+yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
+{
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
-
+
if (emitter->output.string.size - *emitter->output.string.size_written
- < size) {
- memcpy(emitter->output.string.buffer
- + *emitter->output.string.size_written,
- buffer,
- emitter->output.string.size
- - *emitter->output.string.size_written);
- *emitter->output.string.size_written = emitter->output.string.size;
- return 0;
- }
-
- memcpy(emitter->output.string.buffer
- + *emitter->output.string.size_written, buffer, size);
- *emitter->output.string.size_written += size;
- return 1;
-}
-
-/*
- * File write handler.
- */
-
-static int
-yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
-{
+ < size) {
+ memcpy(emitter->output.string.buffer
+ + *emitter->output.string.size_written,
+ buffer,
+ emitter->output.string.size
+ - *emitter->output.string.size_written);
+ *emitter->output.string.size_written = emitter->output.string.size;
+ return 0;
+ }
+
+ memcpy(emitter->output.string.buffer
+ + *emitter->output.string.size_written, buffer, size);
+ *emitter->output.string.size_written += size;
+ return 1;
+}
+
+/*
+ * File write handler.
+ */
+
+static int
+yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
+{
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
-
- return (fwrite(buffer, 1, size, emitter->output.file) == size);
-}
-/*
- * Set a string output.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output_string(yaml_emitter_t *emitter,
- unsigned char *output, size_t size, size_t *size_written)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
- assert(!emitter->write_handler); /* You can set the output only once. */
- assert(output); /* Non-NULL output string expected. */
-
- emitter->write_handler = yaml_string_write_handler;
- emitter->write_handler_data = emitter;
-
- emitter->output.string.buffer = output;
- emitter->output.string.size = size;
- emitter->output.string.size_written = size_written;
- *size_written = 0;
-}
-
-/*
- * Set a file output.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
- assert(!emitter->write_handler); /* You can set the output only once. */
- assert(file); /* Non-NULL file object expected. */
-
- emitter->write_handler = yaml_file_write_handler;
- emitter->write_handler_data = emitter;
-
- emitter->output.file = file;
-}
-
-/*
- * Set a generic output handler.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_output(yaml_emitter_t *emitter,
- yaml_write_handler_t *handler, void *data)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
- assert(!emitter->write_handler); /* You can set the output only once. */
- assert(handler); /* Non-NULL handler object expected. */
-
- emitter->write_handler = handler;
- emitter->write_handler_data = data;
-}
-
-/*
- * Set the output encoding.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
- assert(!emitter->encoding); /* You can set encoding only once. */
-
- emitter->encoding = encoding;
-}
-
-/*
- * Set the canonical output style.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- emitter->canonical = (canonical != 0);
-}
-
-/*
- * Set the indentation increment.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- emitter->best_indent = (1 < indent && indent < 10) ? indent : 2;
-}
-
-/*
- * Set the preferred line width.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_width(yaml_emitter_t *emitter, int width)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- emitter->best_width = (width >= 0) ? width : -1;
-}
-
-/*
- * Set if unescaped non-ASCII characters are allowed.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- emitter->unicode = (unicode != 0);
-}
-
-/*
- * Set the preferred line break character.
- */
-
-YAML_DECLARE(void)
-yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break)
-{
- assert(emitter); /* Non-NULL emitter object expected. */
-
- emitter->line_break = line_break;
-}
-
-/*
- * Destroy a token object.
- */
-
-YAML_DECLARE(void)
-yaml_token_delete(yaml_token_t *token)
-{
- assert(token); /* Non-NULL token object expected. */
-
- switch (token->type)
- {
- case YAML_TAG_DIRECTIVE_TOKEN:
- yaml_free(token->data.tag_directive.handle);
- yaml_free(token->data.tag_directive.prefix);
- break;
-
- case YAML_ALIAS_TOKEN:
- yaml_free(token->data.alias.value);
- break;
-
- case YAML_ANCHOR_TOKEN:
- yaml_free(token->data.anchor.value);
- break;
-
- case YAML_TAG_TOKEN:
- yaml_free(token->data.tag.handle);
- yaml_free(token->data.tag.suffix);
- break;
-
- case YAML_SCALAR_TOKEN:
- yaml_free(token->data.scalar.value);
- break;
-
- default:
- break;
- }
-
- memset(token, 0, sizeof(yaml_token_t));
-}
-
-/*
- * Check if a string is a valid UTF-8 sequence.
- *
- * Check 'reader.c' for more details on UTF-8 encoding.
- */
-
-static int
+
+ return (fwrite(buffer, 1, size, emitter->output.file) == size);
+}
+/*
+ * Set a string output.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_string(yaml_emitter_t *emitter,
+ unsigned char *output, size_t size, size_t *size_written)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(output); /* Non-NULL output string expected. */
+
+ emitter->write_handler = yaml_string_write_handler;
+ emitter->write_handler_data = emitter;
+
+ emitter->output.string.buffer = output;
+ emitter->output.string.size = size;
+ emitter->output.string.size_written = size_written;
+ *size_written = 0;
+}
+
+/*
+ * Set a file output.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(file); /* Non-NULL file object expected. */
+
+ emitter->write_handler = yaml_file_write_handler;
+ emitter->write_handler_data = emitter;
+
+ emitter->output.file = file;
+}
+
+/*
+ * Set a generic output handler.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output(yaml_emitter_t *emitter,
+ yaml_write_handler_t *handler, void *data)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(handler); /* Non-NULL handler object expected. */
+
+ emitter->write_handler = handler;
+ emitter->write_handler_data = data;
+}
+
+/*
+ * Set the output encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->encoding); /* You can set encoding only once. */
+
+ emitter->encoding = encoding;
+}
+
+/*
+ * Set the canonical output style.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->canonical = (canonical != 0);
+}
+
+/*
+ * Set the indentation increment.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->best_indent = (1 < indent && indent < 10) ? indent : 2;
+}
+
+/*
+ * Set the preferred line width.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_width(yaml_emitter_t *emitter, int width)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->best_width = (width >= 0) ? width : -1;
+}
+
+/*
+ * Set if unescaped non-ASCII characters are allowed.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->unicode = (unicode != 0);
+}
+
+/*
+ * Set the preferred line break character.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->line_break = line_break;
+}
+
+/*
+ * Destroy a token object.
+ */
+
+YAML_DECLARE(void)
+yaml_token_delete(yaml_token_t *token)
+{
+ assert(token); /* Non-NULL token object expected. */
+
+ switch (token->type)
+ {
+ case YAML_TAG_DIRECTIVE_TOKEN:
+ yaml_free(token->data.tag_directive.handle);
+ yaml_free(token->data.tag_directive.prefix);
+ break;
+
+ case YAML_ALIAS_TOKEN:
+ yaml_free(token->data.alias.value);
+ break;
+
+ case YAML_ANCHOR_TOKEN:
+ yaml_free(token->data.anchor.value);
+ break;
+
+ case YAML_TAG_TOKEN:
+ yaml_free(token->data.tag.handle);
+ yaml_free(token->data.tag.suffix);
+ break;
+
+ case YAML_SCALAR_TOKEN:
+ yaml_free(token->data.scalar.value);
+ break;
+
+ default:
+ break;
+ }
+
+ memset(token, 0, sizeof(yaml_token_t));
+}
+
+/*
+ * Check if a string is a valid UTF-8 sequence.
+ *
+ * Check 'reader.c' for more details on UTF-8 encoding.
+ */
+
+static int
yaml_check_utf8(const yaml_char_t *start, size_t length)
-{
+{
const yaml_char_t *end = start+length;
const yaml_char_t *pointer = start;
-
- while (pointer < end) {
- unsigned char octet;
- unsigned int width;
- unsigned int value;
- size_t k;
-
- octet = 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;
- if (!width) return 0;
- if (pointer+width > end) return 0;
- for (k = 1; k < width; k ++) {
- octet = pointer[k];
- if ((octet & 0xC0) != 0x80) return 0;
- value = (value << 6) + (octet & 0x3F);
- }
- if (!((width == 1) ||
- (width == 2 && value >= 0x80) ||
- (width == 3 && value >= 0x800) ||
- (width == 4 && value >= 0x10000))) return 0;
-
- pointer += width;
- }
-
- return 1;
-}
-
-/*
- * Create STREAM-START.
- */
-
-YAML_DECLARE(int)
-yaml_stream_start_event_initialize(yaml_event_t *event,
- yaml_encoding_t encoding)
-{
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(event); /* Non-NULL event object is expected. */
-
- STREAM_START_EVENT_INIT(*event, encoding, mark, mark);
-
- return 1;
-}
-
-/*
- * Create STREAM-END.
- */
-
-YAML_DECLARE(int)
-yaml_stream_end_event_initialize(yaml_event_t *event)
-{
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(event); /* Non-NULL event object is expected. */
-
- STREAM_END_EVENT_INIT(*event, mark, mark);
-
- return 1;
-}
-
-/*
- * Create DOCUMENT-START.
- */
-
-YAML_DECLARE(int)
-yaml_document_start_event_initialize(yaml_event_t *event,
- yaml_version_directive_t *version_directive,
- yaml_tag_directive_t *tag_directives_start,
- yaml_tag_directive_t *tag_directives_end,
- int implicit)
-{
- struct {
- yaml_error_type_t error;
- } context;
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_version_directive_t *version_directive_copy = NULL;
- struct {
- yaml_tag_directive_t *start;
- yaml_tag_directive_t *end;
- yaml_tag_directive_t *top;
- } tag_directives_copy = { NULL, NULL, NULL };
- yaml_tag_directive_t value = { NULL, NULL };
-
- assert(event); /* Non-NULL event object is expected. */
- assert((tag_directives_start && tag_directives_end) ||
- (tag_directives_start == tag_directives_end));
- /* Valid tag directives are expected. */
-
- if (version_directive) {
+
+ while (pointer < end) {
+ unsigned char octet;
+ unsigned int width;
+ unsigned int value;
+ size_t k;
+
+ octet = 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;
+ if (!width) return 0;
+ if (pointer+width > end) return 0;
+ for (k = 1; k < width; k ++) {
+ octet = pointer[k];
+ if ((octet & 0xC0) != 0x80) return 0;
+ value = (value << 6) + (octet & 0x3F);
+ }
+ if (!((width == 1) ||
+ (width == 2 && value >= 0x80) ||
+ (width == 3 && value >= 0x800) ||
+ (width == 4 && value >= 0x10000))) return 0;
+
+ pointer += width;
+ }
+
+ return 1;
+}
+
+/*
+ * Create STREAM-START.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_start_event_initialize(yaml_event_t *event,
+ yaml_encoding_t encoding)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ STREAM_START_EVENT_INIT(*event, encoding, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create STREAM-END.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ STREAM_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create DOCUMENT-START.
+ */
+
+YAML_DECLARE(int)
+yaml_document_start_event_initialize(yaml_event_t *event,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int implicit)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_version_directive_t *version_directive_copy = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives_copy = { NULL, NULL, NULL };
+ yaml_tag_directive_t value = { NULL, NULL };
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert((tag_directives_start && tag_directives_end) ||
+ (tag_directives_start == tag_directives_end));
+ /* Valid tag directives are expected. */
+
+ if (version_directive) {
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
- if (!version_directive_copy) goto error;
- version_directive_copy->major = version_directive->major;
- version_directive_copy->minor = version_directive->minor;
- }
-
- if (tag_directives_start != tag_directives_end) {
- yaml_tag_directive_t *tag_directive;
+ if (!version_directive_copy) goto error;
+ version_directive_copy->major = version_directive->major;
+ version_directive_copy->minor = version_directive->minor;
+ }
+
+ if (tag_directives_start != tag_directives_end) {
+ yaml_tag_directive_t *tag_directive;
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
- goto error;
- for (tag_directive = tag_directives_start;
- tag_directive != tag_directives_end; tag_directive ++) {
- assert(tag_directive->handle);
- assert(tag_directive->prefix);
- if (!yaml_check_utf8(tag_directive->handle,
- strlen((char *)tag_directive->handle)))
- goto error;
- if (!yaml_check_utf8(tag_directive->prefix,
- strlen((char *)tag_directive->prefix)))
- goto error;
- value.handle = yaml_strdup(tag_directive->handle);
- value.prefix = yaml_strdup(tag_directive->prefix);
- if (!value.handle || !value.prefix) goto error;
- if (!PUSH(&context, tag_directives_copy, value))
- goto error;
- value.handle = NULL;
- value.prefix = NULL;
- }
- }
-
- DOCUMENT_START_EVENT_INIT(*event, version_directive_copy,
- tag_directives_copy.start, tag_directives_copy.top,
- implicit, mark, mark);
-
- return 1;
-
-error:
- yaml_free(version_directive_copy);
- while (!STACK_EMPTY(context, tag_directives_copy)) {
- yaml_tag_directive_t value = POP(context, tag_directives_copy);
- yaml_free(value.handle);
- yaml_free(value.prefix);
- }
- STACK_DEL(context, tag_directives_copy);
- yaml_free(value.handle);
- yaml_free(value.prefix);
-
- return 0;
-}
-
-/*
- * Create DOCUMENT-END.
- */
-
-YAML_DECLARE(int)
-yaml_document_end_event_initialize(yaml_event_t *event, int implicit)
-{
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(event); /* Non-NULL emitter object is expected. */
-
- DOCUMENT_END_EVENT_INIT(*event, implicit, mark, mark);
-
- return 1;
-}
-
-/*
- * Create ALIAS.
- */
-
-YAML_DECLARE(int)
+ goto error;
+ for (tag_directive = tag_directives_start;
+ tag_directive != tag_directives_end; tag_directive ++) {
+ assert(tag_directive->handle);
+ assert(tag_directive->prefix);
+ if (!yaml_check_utf8(tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ goto error;
+ if (!yaml_check_utf8(tag_directive->prefix,
+ strlen((char *)tag_directive->prefix)))
+ goto error;
+ value.handle = yaml_strdup(tag_directive->handle);
+ value.prefix = yaml_strdup(tag_directive->prefix);
+ if (!value.handle || !value.prefix) goto error;
+ if (!PUSH(&context, tag_directives_copy, value))
+ goto error;
+ value.handle = NULL;
+ value.prefix = NULL;
+ }
+ }
+
+ DOCUMENT_START_EVENT_INIT(*event, version_directive_copy,
+ tag_directives_copy.start, tag_directives_copy.top,
+ implicit, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(version_directive_copy);
+ while (!STACK_EMPTY(context, tag_directives_copy)) {
+ yaml_tag_directive_t value = POP(context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+ }
+ STACK_DEL(context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+
+ return 0;
+}
+
+/*
+ * Create DOCUMENT-END.
+ */
+
+YAML_DECLARE(int)
+yaml_document_end_event_initialize(yaml_event_t *event, int implicit)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL emitter object is expected. */
+
+ DOCUMENT_END_EVENT_INIT(*event, implicit, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create ALIAS.
+ */
+
+YAML_DECLARE(int)
yaml_alias_event_initialize(yaml_event_t *event, const yaml_char_t *anchor)
-{
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *anchor_copy = NULL;
-
- assert(event); /* Non-NULL event object is expected. */
- assert(anchor); /* Non-NULL anchor is expected. */
-
- if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0;
-
- anchor_copy = yaml_strdup(anchor);
- if (!anchor_copy)
- return 0;
-
- ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark);
-
- return 1;
-}
-
-/*
- * Create SCALAR.
- */
-
-YAML_DECLARE(int)
-yaml_scalar_event_initialize(yaml_event_t *event,
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert(anchor); /* Non-NULL anchor is expected. */
+
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0;
+
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy)
+ return 0;
+
+ ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create SCALAR.
+ */
+
+YAML_DECLARE(int)
+yaml_scalar_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag,
const yaml_char_t *value, int length,
- int plain_implicit, int quoted_implicit,
- yaml_scalar_style_t style)
-{
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *anchor_copy = NULL;
- yaml_char_t *tag_copy = NULL;
- yaml_char_t *value_copy = NULL;
-
- assert(event); /* Non-NULL event object is expected. */
- assert(value); /* Non-NULL anchor is expected. */
-
- if (anchor) {
- if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
- anchor_copy = yaml_strdup(anchor);
- if (!anchor_copy) goto error;
- }
-
- if (tag) {
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
- }
-
- if (length < 0) {
- length = strlen((char *)value);
- }
-
- if (!yaml_check_utf8(value, length)) goto error;
+ int plain_implicit, int quoted_implicit,
+ yaml_scalar_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+ yaml_char_t *value_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert(value); /* Non-NULL anchor is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ if (length < 0) {
+ length = strlen((char *)value);
+ }
+
+ if (!yaml_check_utf8(value, length)) goto error;
value_copy = YAML_MALLOC(length+1);
- if (!value_copy) goto error;
- memcpy(value_copy, value, length);
- value_copy[length] = '\0';
-
- SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length,
- plain_implicit, quoted_implicit, style, mark, mark);
-
- return 1;
-
-error:
- yaml_free(anchor_copy);
- yaml_free(tag_copy);
- yaml_free(value_copy);
-
- return 0;
-}
-
-/*
- * Create SEQUENCE-START.
- */
-
-YAML_DECLARE(int)
-yaml_sequence_start_event_initialize(yaml_event_t *event,
+ if (!value_copy) goto error;
+ memcpy(value_copy, value, length);
+ value_copy[length] = '\0';
+
+ SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, length,
+ plain_implicit, quoted_implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+ yaml_free(value_copy);
+
+ return 0;
+}
+
+/*
+ * Create SEQUENCE-START.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_start_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
- yaml_sequence_style_t style)
-{
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *anchor_copy = NULL;
- yaml_char_t *tag_copy = NULL;
-
- assert(event); /* Non-NULL event object is expected. */
-
- if (anchor) {
- if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
- anchor_copy = yaml_strdup(anchor);
- if (!anchor_copy) goto error;
- }
-
- if (tag) {
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
- }
-
- SEQUENCE_START_EVENT_INIT(*event, anchor_copy, tag_copy,
- implicit, style, mark, mark);
-
- return 1;
-
-error:
- yaml_free(anchor_copy);
- yaml_free(tag_copy);
-
- return 0;
-}
-
-/*
- * Create SEQUENCE-END.
- */
-
-YAML_DECLARE(int)
-yaml_sequence_end_event_initialize(yaml_event_t *event)
-{
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(event); /* Non-NULL event object is expected. */
-
- SEQUENCE_END_EVENT_INIT(*event, mark, mark);
-
- return 1;
-}
-
-/*
- * Create MAPPING-START.
- */
-
-YAML_DECLARE(int)
-yaml_mapping_start_event_initialize(yaml_event_t *event,
+ yaml_sequence_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ SEQUENCE_START_EVENT_INIT(*event, anchor_copy, tag_copy,
+ implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Create SEQUENCE-END.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ SEQUENCE_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create MAPPING-START.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_start_event_initialize(yaml_event_t *event,
const yaml_char_t *anchor, const yaml_char_t *tag, int implicit,
- yaml_mapping_style_t style)
-{
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *anchor_copy = NULL;
- yaml_char_t *tag_copy = NULL;
-
- assert(event); /* Non-NULL event object is expected. */
-
- if (anchor) {
- if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
- anchor_copy = yaml_strdup(anchor);
- if (!anchor_copy) goto error;
- }
-
- if (tag) {
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
- }
-
- MAPPING_START_EVENT_INIT(*event, anchor_copy, tag_copy,
- implicit, style, mark, mark);
-
- return 1;
-
-error:
- yaml_free(anchor_copy);
- yaml_free(tag_copy);
-
- return 0;
-}
-
-/*
- * Create MAPPING-END.
- */
-
-YAML_DECLARE(int)
-yaml_mapping_end_event_initialize(yaml_event_t *event)
-{
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(event); /* Non-NULL event object is expected. */
-
- MAPPING_END_EVENT_INIT(*event, mark, mark);
-
- return 1;
-}
-
-/*
- * Destroy an event object.
- */
-
-YAML_DECLARE(void)
-yaml_event_delete(yaml_event_t *event)
-{
- yaml_tag_directive_t *tag_directive;
-
- assert(event); /* Non-NULL event object expected. */
-
- switch (event->type)
- {
- case YAML_DOCUMENT_START_EVENT:
- yaml_free(event->data.document_start.version_directive);
- for (tag_directive = event->data.document_start.tag_directives.start;
- tag_directive != event->data.document_start.tag_directives.end;
- tag_directive++) {
- yaml_free(tag_directive->handle);
- yaml_free(tag_directive->prefix);
- }
- yaml_free(event->data.document_start.tag_directives.start);
- break;
-
- case YAML_ALIAS_EVENT:
- yaml_free(event->data.alias.anchor);
- break;
-
- case YAML_SCALAR_EVENT:
- yaml_free(event->data.scalar.anchor);
- yaml_free(event->data.scalar.tag);
- yaml_free(event->data.scalar.value);
- break;
-
- case YAML_SEQUENCE_START_EVENT:
- yaml_free(event->data.sequence_start.anchor);
- yaml_free(event->data.sequence_start.tag);
- break;
-
- case YAML_MAPPING_START_EVENT:
- yaml_free(event->data.mapping_start.anchor);
- yaml_free(event->data.mapping_start.tag);
- break;
-
- default:
- break;
- }
-
- memset(event, 0, sizeof(yaml_event_t));
-}
-
-/*
- * Create a document object.
- */
-
-YAML_DECLARE(int)
-yaml_document_initialize(yaml_document_t *document,
- yaml_version_directive_t *version_directive,
- yaml_tag_directive_t *tag_directives_start,
- yaml_tag_directive_t *tag_directives_end,
- int start_implicit, int end_implicit)
-{
- struct {
- yaml_error_type_t error;
- } context;
- struct {
- yaml_node_t *start;
- yaml_node_t *end;
- yaml_node_t *top;
- } nodes = { NULL, NULL, NULL };
- yaml_version_directive_t *version_directive_copy = NULL;
- struct {
- yaml_tag_directive_t *start;
- yaml_tag_directive_t *end;
- yaml_tag_directive_t *top;
- } tag_directives_copy = { NULL, NULL, NULL };
- yaml_tag_directive_t value = { NULL, NULL };
- yaml_mark_t mark = { 0, 0, 0 };
-
- assert(document); /* Non-NULL document object is expected. */
- assert((tag_directives_start && tag_directives_end) ||
- (tag_directives_start == tag_directives_end));
- /* Valid tag directives are expected. */
-
+ yaml_mapping_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ MAPPING_START_EVENT_INIT(*event, anchor_copy, tag_copy,
+ implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Create MAPPING-END.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ MAPPING_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Destroy an event object.
+ */
+
+YAML_DECLARE(void)
+yaml_event_delete(yaml_event_t *event)
+{
+ yaml_tag_directive_t *tag_directive;
+
+ assert(event); /* Non-NULL event object expected. */
+
+ switch (event->type)
+ {
+ case YAML_DOCUMENT_START_EVENT:
+ yaml_free(event->data.document_start.version_directive);
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive++) {
+ yaml_free(tag_directive->handle);
+ yaml_free(tag_directive->prefix);
+ }
+ yaml_free(event->data.document_start.tag_directives.start);
+ break;
+
+ case YAML_ALIAS_EVENT:
+ yaml_free(event->data.alias.anchor);
+ break;
+
+ case YAML_SCALAR_EVENT:
+ yaml_free(event->data.scalar.anchor);
+ yaml_free(event->data.scalar.tag);
+ yaml_free(event->data.scalar.value);
+ break;
+
+ case YAML_SEQUENCE_START_EVENT:
+ yaml_free(event->data.sequence_start.anchor);
+ yaml_free(event->data.sequence_start.tag);
+ break;
+
+ case YAML_MAPPING_START_EVENT:
+ yaml_free(event->data.mapping_start.anchor);
+ yaml_free(event->data.mapping_start.tag);
+ break;
+
+ default:
+ break;
+ }
+
+ memset(event, 0, sizeof(yaml_event_t));
+}
+
+/*
+ * Create a document object.
+ */
+
+YAML_DECLARE(int)
+yaml_document_initialize(yaml_document_t *document,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int start_implicit, int end_implicit)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ struct {
+ yaml_node_t *start;
+ yaml_node_t *end;
+ yaml_node_t *top;
+ } nodes = { NULL, NULL, NULL };
+ yaml_version_directive_t *version_directive_copy = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives_copy = { NULL, NULL, NULL };
+ yaml_tag_directive_t value = { NULL, NULL };
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(document); /* Non-NULL document object is expected. */
+ assert((tag_directives_start && tag_directives_end) ||
+ (tag_directives_start == tag_directives_end));
+ /* Valid tag directives are expected. */
+
if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error;
-
- if (version_directive) {
+
+ if (version_directive) {
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
- if (!version_directive_copy) goto error;
- version_directive_copy->major = version_directive->major;
- version_directive_copy->minor = version_directive->minor;
- }
-
- if (tag_directives_start != tag_directives_end) {
- yaml_tag_directive_t *tag_directive;
+ if (!version_directive_copy) goto error;
+ version_directive_copy->major = version_directive->major;
+ version_directive_copy->minor = version_directive->minor;
+ }
+
+ if (tag_directives_start != tag_directives_end) {
+ yaml_tag_directive_t *tag_directive;
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
- goto error;
- for (tag_directive = tag_directives_start;
- tag_directive != tag_directives_end; tag_directive ++) {
- assert(tag_directive->handle);
- assert(tag_directive->prefix);
- if (!yaml_check_utf8(tag_directive->handle,
- strlen((char *)tag_directive->handle)))
- goto error;
- if (!yaml_check_utf8(tag_directive->prefix,
- strlen((char *)tag_directive->prefix)))
- goto error;
- value.handle = yaml_strdup(tag_directive->handle);
- value.prefix = yaml_strdup(tag_directive->prefix);
- if (!value.handle || !value.prefix) goto error;
- if (!PUSH(&context, tag_directives_copy, value))
- goto error;
- value.handle = NULL;
- value.prefix = NULL;
- }
- }
-
- DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,
- tag_directives_copy.start, tag_directives_copy.top,
- start_implicit, end_implicit, mark, mark);
-
- return 1;
-
-error:
- STACK_DEL(&context, nodes);
- yaml_free(version_directive_copy);
- while (!STACK_EMPTY(&context, tag_directives_copy)) {
- yaml_tag_directive_t value = POP(&context, tag_directives_copy);
- yaml_free(value.handle);
- yaml_free(value.prefix);
- }
- STACK_DEL(&context, tag_directives_copy);
- yaml_free(value.handle);
- yaml_free(value.prefix);
-
- return 0;
-}
-
-/*
- * Destroy a document object.
- */
-
-YAML_DECLARE(void)
-yaml_document_delete(yaml_document_t *document)
-{
- yaml_tag_directive_t *tag_directive;
-
- assert(document); /* Non-NULL document object is expected. */
-
- while (!STACK_EMPTY(&context, document->nodes)) {
- yaml_node_t node = POP(&context, document->nodes);
- yaml_free(node.tag);
- switch (node.type) {
- case YAML_SCALAR_NODE:
- yaml_free(node.data.scalar.value);
- break;
- case YAML_SEQUENCE_NODE:
- STACK_DEL(&context, node.data.sequence.items);
- break;
- case YAML_MAPPING_NODE:
- STACK_DEL(&context, node.data.mapping.pairs);
- break;
- default:
- assert(0); /* Should not happen. */
- }
- }
- STACK_DEL(&context, document->nodes);
-
- yaml_free(document->version_directive);
- for (tag_directive = document->tag_directives.start;
- tag_directive != document->tag_directives.end;
- tag_directive++) {
- yaml_free(tag_directive->handle);
- yaml_free(tag_directive->prefix);
- }
- yaml_free(document->tag_directives.start);
-
- memset(document, 0, sizeof(yaml_document_t));
-}
-
-/**
- * Get a document node.
- */
-
-YAML_DECLARE(yaml_node_t *)
-yaml_document_get_node(yaml_document_t *document, int index)
-{
- assert(document); /* Non-NULL document object is expected. */
-
- if (index > 0 && document->nodes.start + index <= document->nodes.top) {
- return document->nodes.start + index - 1;
- }
- return NULL;
-}
-
-/**
- * Get the root object.
- */
-
-YAML_DECLARE(yaml_node_t *)
-yaml_document_get_root_node(yaml_document_t *document)
-{
- assert(document); /* Non-NULL document object is expected. */
-
- if (document->nodes.top != document->nodes.start) {
- return document->nodes.start;
- }
- return NULL;
-}
-
-/*
- * Add a scalar node to a document.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_scalar(yaml_document_t *document,
+ goto error;
+ for (tag_directive = tag_directives_start;
+ tag_directive != tag_directives_end; tag_directive ++) {
+ assert(tag_directive->handle);
+ assert(tag_directive->prefix);
+ if (!yaml_check_utf8(tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ goto error;
+ if (!yaml_check_utf8(tag_directive->prefix,
+ strlen((char *)tag_directive->prefix)))
+ goto error;
+ value.handle = yaml_strdup(tag_directive->handle);
+ value.prefix = yaml_strdup(tag_directive->prefix);
+ if (!value.handle || !value.prefix) goto error;
+ if (!PUSH(&context, tag_directives_copy, value))
+ goto error;
+ value.handle = NULL;
+ value.prefix = NULL;
+ }
+ }
+
+ DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,
+ tag_directives_copy.start, tag_directives_copy.top,
+ start_implicit, end_implicit, mark, mark);
+
+ return 1;
+
+error:
+ STACK_DEL(&context, nodes);
+ yaml_free(version_directive_copy);
+ while (!STACK_EMPTY(&context, tag_directives_copy)) {
+ yaml_tag_directive_t value = POP(&context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+ }
+ STACK_DEL(&context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+
+ return 0;
+}
+
+/*
+ * Destroy a document object.
+ */
+
+YAML_DECLARE(void)
+yaml_document_delete(yaml_document_t *document)
+{
+ yaml_tag_directive_t *tag_directive;
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ while (!STACK_EMPTY(&context, document->nodes)) {
+ yaml_node_t node = POP(&context, document->nodes);
+ yaml_free(node.tag);
+ switch (node.type) {
+ case YAML_SCALAR_NODE:
+ yaml_free(node.data.scalar.value);
+ break;
+ case YAML_SEQUENCE_NODE:
+ STACK_DEL(&context, node.data.sequence.items);
+ break;
+ case YAML_MAPPING_NODE:
+ STACK_DEL(&context, node.data.mapping.pairs);
+ break;
+ default:
+ assert(0); /* Should not happen. */
+ }
+ }
+ STACK_DEL(&context, document->nodes);
+
+ yaml_free(document->version_directive);
+ for (tag_directive = document->tag_directives.start;
+ tag_directive != document->tag_directives.end;
+ tag_directive++) {
+ yaml_free(tag_directive->handle);
+ yaml_free(tag_directive->prefix);
+ }
+ yaml_free(document->tag_directives.start);
+
+ memset(document, 0, sizeof(yaml_document_t));
+}
+
+/**
+ * Get a document node.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_node(yaml_document_t *document, int index)
+{
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (index > 0 && document->nodes.start + index <= document->nodes.top) {
+ return document->nodes.start + index - 1;
+ }
+ return NULL;
+}
+
+/**
+ * Get the root object.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_root_node(yaml_document_t *document)
+{
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (document->nodes.top != document->nodes.start) {
+ return document->nodes.start;
+ }
+ return NULL;
+}
+
+/*
+ * Add a scalar node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_scalar(yaml_document_t *document,
const yaml_char_t *tag, const yaml_char_t *value, int length,
- yaml_scalar_style_t style)
-{
- struct {
- yaml_error_type_t error;
- } context;
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *tag_copy = NULL;
- yaml_char_t *value_copy = NULL;
- yaml_node_t node;
-
- assert(document); /* Non-NULL document object is expected. */
- assert(value); /* Non-NULL value is expected. */
-
- if (!tag) {
- tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG;
- }
-
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
-
- if (length < 0) {
- length = strlen((char *)value);
- }
-
- if (!yaml_check_utf8(value, length)) goto error;
+ yaml_scalar_style_t style)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ yaml_char_t *value_copy = NULL;
+ yaml_node_t node;
+
+ assert(document); /* Non-NULL document object is expected. */
+ assert(value); /* Non-NULL value is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
+ if (length < 0) {
+ length = strlen((char *)value);
+ }
+
+ if (!yaml_check_utf8(value, length)) goto error;
value_copy = YAML_MALLOC(length+1);
- if (!value_copy) goto error;
- memcpy(value_copy, value, length);
- value_copy[length] = '\0';
-
- SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark);
- if (!PUSH(&context, document->nodes, node)) goto error;
-
- return document->nodes.top - document->nodes.start;
-
-error:
- yaml_free(tag_copy);
- yaml_free(value_copy);
-
- return 0;
-}
-
-/*
- * Add a sequence node to a document.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_sequence(yaml_document_t *document,
+ if (!value_copy) goto error;
+ memcpy(value_copy, value, length);
+ value_copy[length] = '\0';
+
+ SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ return document->nodes.top - document->nodes.start;
+
+error:
+ yaml_free(tag_copy);
+ yaml_free(value_copy);
+
+ return 0;
+}
+
+/*
+ * Add a sequence node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_sequence(yaml_document_t *document,
const yaml_char_t *tag, yaml_sequence_style_t style)
-{
- struct {
- yaml_error_type_t error;
- } context;
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *tag_copy = NULL;
- struct {
- yaml_node_item_t *start;
- yaml_node_item_t *end;
- yaml_node_item_t *top;
- } items = { NULL, NULL, NULL };
- yaml_node_t node;
-
- assert(document); /* Non-NULL document object is expected. */
-
- if (!tag) {
- tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG;
- }
-
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
-
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ struct {
+ yaml_node_item_t *start;
+ yaml_node_item_t *end;
+ yaml_node_item_t *top;
+ } items = { NULL, NULL, NULL };
+ yaml_node_t node;
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
if (!STACK_INIT(&context, items, yaml_node_item_t*)) goto error;
-
- SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
- style, mark, mark);
- if (!PUSH(&context, document->nodes, node)) goto error;
-
- return document->nodes.top - document->nodes.start;
-
-error:
- STACK_DEL(&context, items);
- yaml_free(tag_copy);
-
- return 0;
-}
-
-/*
- * Add a mapping node to a document.
- */
-
-YAML_DECLARE(int)
-yaml_document_add_mapping(yaml_document_t *document,
+
+ SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
+ style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ return document->nodes.top - document->nodes.start;
+
+error:
+ STACK_DEL(&context, items);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Add a mapping node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_mapping(yaml_document_t *document,
const yaml_char_t *tag, yaml_mapping_style_t style)
-{
- struct {
- yaml_error_type_t error;
- } context;
- yaml_mark_t mark = { 0, 0, 0 };
- yaml_char_t *tag_copy = NULL;
- struct {
- yaml_node_pair_t *start;
- yaml_node_pair_t *end;
- yaml_node_pair_t *top;
- } pairs = { NULL, NULL, NULL };
- yaml_node_t node;
-
- assert(document); /* Non-NULL document object is expected. */
-
- if (!tag) {
- tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG;
- }
-
- if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
- tag_copy = yaml_strdup(tag);
- if (!tag_copy) goto error;
-
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ struct {
+ yaml_node_pair_t *start;
+ yaml_node_pair_t *end;
+ yaml_node_pair_t *top;
+ } pairs = { NULL, NULL, NULL };
+ yaml_node_t node;
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
if (!STACK_INIT(&context, pairs, yaml_node_pair_t*)) goto error;
-
- MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
- style, mark, mark);
- if (!PUSH(&context, document->nodes, node)) goto error;
-
- return document->nodes.top - document->nodes.start;
-
-error:
- STACK_DEL(&context, pairs);
- yaml_free(tag_copy);
-
- return 0;
-}
-
-/*
- * Append an item to a sequence node.
- */
-
-YAML_DECLARE(int)
-yaml_document_append_sequence_item(yaml_document_t *document,
- int sequence, int item)
-{
- struct {
- yaml_error_type_t error;
- } context;
-
- assert(document); /* Non-NULL document is required. */
- assert(sequence > 0
- && document->nodes.start + sequence <= document->nodes.top);
- /* Valid sequence id is required. */
- assert(document->nodes.start[sequence-1].type == YAML_SEQUENCE_NODE);
- /* A sequence node is required. */
- assert(item > 0 && document->nodes.start + item <= document->nodes.top);
- /* Valid item id is required. */
-
- if (!PUSH(&context,
- document->nodes.start[sequence-1].data.sequence.items, item))
- return 0;
-
- return 1;
-}
-
-/*
- * Append a pair of a key and a value to a mapping node.
- */
-
-YAML_DECLARE(int)
-yaml_document_append_mapping_pair(yaml_document_t *document,
- int mapping, int key, int value)
-{
- struct {
- yaml_error_type_t error;
- } context;
-
- yaml_node_pair_t pair;
-
- assert(document); /* Non-NULL document is required. */
- assert(mapping > 0
- && document->nodes.start + mapping <= document->nodes.top);
- /* Valid mapping id is required. */
- assert(document->nodes.start[mapping-1].type == YAML_MAPPING_NODE);
- /* A mapping node is required. */
- assert(key > 0 && document->nodes.start + key <= document->nodes.top);
- /* Valid key id is required. */
- assert(value > 0 && document->nodes.start + value <= document->nodes.top);
- /* Valid value id is required. */
-
- pair.key = key;
- pair.value = value;
-
- if (!PUSH(&context,
- document->nodes.start[mapping-1].data.mapping.pairs, pair))
- return 0;
-
- return 1;
-}
-
-
+
+ MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
+ style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ return document->nodes.top - document->nodes.start;
+
+error:
+ STACK_DEL(&context, pairs);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Append an item to a sequence node.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_sequence_item(yaml_document_t *document,
+ int sequence, int item)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+
+ assert(document); /* Non-NULL document is required. */
+ assert(sequence > 0
+ && document->nodes.start + sequence <= document->nodes.top);
+ /* Valid sequence id is required. */
+ assert(document->nodes.start[sequence-1].type == YAML_SEQUENCE_NODE);
+ /* A sequence node is required. */
+ assert(item > 0 && document->nodes.start + item <= document->nodes.top);
+ /* Valid item id is required. */
+
+ if (!PUSH(&context,
+ document->nodes.start[sequence-1].data.sequence.items, item))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Append a pair of a key and a value to a mapping node.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_mapping_pair(yaml_document_t *document,
+ int mapping, int key, int value)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+
+ yaml_node_pair_t pair;
+
+ assert(document); /* Non-NULL document is required. */
+ assert(mapping > 0
+ && document->nodes.start + mapping <= document->nodes.top);
+ /* Valid mapping id is required. */
+ assert(document->nodes.start[mapping-1].type == YAML_MAPPING_NODE);
+ /* A mapping node is required. */
+ assert(key > 0 && document->nodes.start + key <= document->nodes.top);
+ /* Valid key id is required. */
+ assert(value > 0 && document->nodes.start + value <= document->nodes.top);
+ /* Valid value id is required. */
+
+ pair.key = key;
+ pair.value = value;
+
+ if (!PUSH(&context,
+ document->nodes.start[mapping-1].data.mapping.pairs, pair))
+ return 0;
+
+ return 1;
+}
+
+
diff --git a/contrib/libs/yaml/src/config.h b/contrib/libs/yaml/src/config.h
index 4ce4fd0a20..22a2296e5e 100644
--- a/contrib/libs/yaml/src/config.h
+++ b/contrib/libs/yaml/src/config.h
@@ -64,7 +64,7 @@
#define VERSION "0.2.5"
/* Define the major version number. */
-#define YAML_VERSION_MAJOR 0
+#define YAML_VERSION_MAJOR 0
/* Define the minor version number. */
#define YAML_VERSION_MINOR 2
diff --git a/contrib/libs/yaml/src/dumper.c b/contrib/libs/yaml/src/dumper.c
index 292d2cff12..1fe940b674 100644
--- a/contrib/libs/yaml/src/dumper.c
+++ b/contrib/libs/yaml/src/dumper.c
@@ -1,394 +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. */
-
+
+#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 *
+ * (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;
-}
-
+
+ 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;
+}
+
diff --git a/contrib/libs/yaml/src/emitter.c b/contrib/libs/yaml/src/emitter.c
index 283a2be745..609b28a4c6 100644
--- a/contrib/libs/yaml/src/emitter.c
+++ b/contrib/libs/yaml/src/emitter.c
@@ -1,609 +1,609 @@
-
-#include "yaml_private.h"
-
-/*
- * Flush the buffer if needed.
- */
-
-#define FLUSH(emitter) \
- ((emitter->buffer.pointer+5 < emitter->buffer.end) \
- || yaml_emitter_flush(emitter))
-
-/*
- * Put a character to the output buffer.
- */
-
-#define PUT(emitter,value) \
- (FLUSH(emitter) \
- && (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
+
+#include "yaml_private.h"
+
+/*
+ * Flush the buffer if needed.
+ */
+
+#define FLUSH(emitter) \
+ ((emitter->buffer.pointer+5 < emitter->buffer.end) \
+ || yaml_emitter_flush(emitter))
+
+/*
+ * Put a character to the output buffer.
+ */
+
+#define PUT(emitter,value) \
+ (FLUSH(emitter) \
+ && (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
emitter->column++, \
- 1))
-
-/*
- * Put a line break to the output buffer.
- */
-
-#define PUT_BREAK(emitter) \
- (FLUSH(emitter) \
- && ((emitter->line_break == YAML_CR_BREAK ? \
- (*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
- emitter->line_break == YAML_LN_BREAK ? \
- (*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \
- emitter->line_break == YAML_CRLN_BREAK ? \
- (*(emitter->buffer.pointer++) = (yaml_char_t) '\r', \
- *(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0), \
- emitter->column = 0, \
- emitter->line ++, \
- 1))
-
-/*
- * Copy a character from a string into buffer.
- */
-
-#define WRITE(emitter,string) \
- (FLUSH(emitter) \
- && (COPY(emitter->buffer,string), \
- emitter->column ++, \
- 1))
-
-/*
- * Copy a line break character from a string into buffer.
- */
-
-#define WRITE_BREAK(emitter,string) \
- (FLUSH(emitter) \
- && (CHECK(string,'\n') ? \
- (PUT_BREAK(emitter), \
- string.pointer ++, \
- 1) : \
- (COPY(emitter->buffer,string), \
- emitter->column = 0, \
- emitter->line ++, \
- 1)))
-
-/*
- * API functions.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
-
-/*
- * Utility functions.
- */
-
-static int
-yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem);
-
-static int
-yaml_emitter_need_more_events(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
- yaml_tag_directive_t value, int allow_duplicates);
-
-static int
-yaml_emitter_increase_indent(yaml_emitter_t *emitter,
- int flow, int indentless);
-
-/*
- * State functions.
- */
-
-static int
-yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event);
-
-static int
-yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
- yaml_event_t *event);
-
-static int
-yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
- yaml_event_t *event, int first);
-
-static int
-yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
- yaml_event_t *event);
-
-static int
-yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
- yaml_event_t *event);
-
-static int
-yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
- yaml_event_t *event, int first);
-
-static int
-yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
- yaml_event_t *event, int first);
-
-static int
-yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
- yaml_event_t *event, int simple);
-
-static int
-yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
- yaml_event_t *event, int first);
-
-static int
-yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
- yaml_event_t *event, int first);
-
-static int
-yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
- yaml_event_t *event, int simple);
-
-static int
-yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
- int root, int sequence, int mapping, int simple_key);
-
-static int
-yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event);
-
-static int
-yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event);
-
-static int
-yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event);
-
-static int
-yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event);
-
-/*
- * Checkers.
- */
-
-static int
-yaml_emitter_check_empty_document(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_check_simple_key(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event);
-
-/*
- * Processors.
- */
-
-static int
-yaml_emitter_process_anchor(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_process_tag(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_process_scalar(yaml_emitter_t *emitter);
-
-/*
- * Analyzers.
- */
-
-static int
-yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
- yaml_version_directive_t version_directive);
-
-static int
-yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
- yaml_tag_directive_t tag_directive);
-
-static int
-yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
- yaml_char_t *anchor, int alias);
-
-static int
-yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
- yaml_char_t *tag);
-
-static int
-yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length);
-
-static int
-yaml_emitter_analyze_event(yaml_emitter_t *emitter,
- yaml_event_t *event);
-
-/*
- * Writers.
- */
-
-static int
-yaml_emitter_write_bom(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_write_indent(yaml_emitter_t *emitter);
-
-static int
-yaml_emitter_write_indicator(yaml_emitter_t *emitter,
+ 1))
+
+/*
+ * Put a line break to the output buffer.
+ */
+
+#define PUT_BREAK(emitter) \
+ (FLUSH(emitter) \
+ && ((emitter->line_break == YAML_CR_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
+ emitter->line_break == YAML_LN_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \
+ emitter->line_break == YAML_CRLN_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\r', \
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0), \
+ emitter->column = 0, \
+ emitter->line ++, \
+ 1))
+
+/*
+ * Copy a character from a string into buffer.
+ */
+
+#define WRITE(emitter,string) \
+ (FLUSH(emitter) \
+ && (COPY(emitter->buffer,string), \
+ emitter->column ++, \
+ 1))
+
+/*
+ * Copy a line break character from a string into buffer.
+ */
+
+#define WRITE_BREAK(emitter,string) \
+ (FLUSH(emitter) \
+ && (CHECK(string,'\n') ? \
+ (PUT_BREAK(emitter), \
+ string.pointer ++, \
+ 1) : \
+ (COPY(emitter->buffer,string), \
+ emitter->column = 0, \
+ emitter->line ++, \
+ 1)))
+
+/*
+ * API functions.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Utility functions.
+ */
+
+static int
+yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem);
+
+static int
+yaml_emitter_need_more_events(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t value, int allow_duplicates);
+
+static int
+yaml_emitter_increase_indent(yaml_emitter_t *emitter,
+ int flow, int indentless);
+
+/*
+ * State functions.
+ */
+
+static int
+yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple);
+
+static int
+yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple);
+
+static int
+yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
+ int root, int sequence, int mapping, int simple_key);
+
+static int
+yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Checkers.
+ */
+
+static int
+yaml_emitter_check_empty_document(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_simple_key(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Processors.
+ */
+
+static int
+yaml_emitter_process_anchor(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_process_tag(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_process_scalar(yaml_emitter_t *emitter);
+
+/*
+ * Analyzers.
+ */
+
+static int
+yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
+ yaml_version_directive_t version_directive);
+
+static int
+yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t tag_directive);
+
+static int
+yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *anchor, int alias);
+
+static int
+yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
+ yaml_char_t *tag);
+
+static int
+yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_analyze_event(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+/*
+ * Writers.
+ */
+
+static int
+yaml_emitter_write_bom(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_write_indent(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_write_indicator(yaml_emitter_t *emitter,
const char *indicator, int need_whitespace,
- int is_whitespace, int is_indention);
-
-static int
-yaml_emitter_write_anchor(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length);
-
-static int
-yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length);
-
-static int
-yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int need_whitespace);
-
-static int
-yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks);
-
-static int
-yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks);
-
-static int
-yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks);
-
-static int
-yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
- yaml_string_t string);
-
-static int
-yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length);
-
-static int
-yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length);
-
-/*
- * Set an emitter error and return 0.
- */
-
-static int
-yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem)
-{
- emitter->error = YAML_EMITTER_ERROR;
- emitter->problem = problem;
-
- return 0;
-}
-
-/*
- * Emit an event.
- */
-
-YAML_DECLARE(int)
-yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- if (!ENQUEUE(emitter, emitter->events, *event)) {
- yaml_event_delete(event);
- return 0;
- }
-
- while (!yaml_emitter_need_more_events(emitter)) {
- if (!yaml_emitter_analyze_event(emitter, emitter->events.head))
- return 0;
- if (!yaml_emitter_state_machine(emitter, emitter->events.head))
- return 0;
- yaml_event_delete(&DEQUEUE(emitter, emitter->events));
- }
-
- return 1;
-}
-
-/*
- * Check if we need to accumulate more events before emitting.
- *
- * We accumulate extra
- * - 1 event for DOCUMENT-START
- * - 2 events for SEQUENCE-START
- * - 3 events for MAPPING-START
- */
-
-static int
-yaml_emitter_need_more_events(yaml_emitter_t *emitter)
-{
- int level = 0;
- int accumulate = 0;
- yaml_event_t *event;
-
- if (QUEUE_EMPTY(emitter, emitter->events))
- return 1;
-
- switch (emitter->events.head->type) {
- case YAML_DOCUMENT_START_EVENT:
- accumulate = 1;
- break;
- case YAML_SEQUENCE_START_EVENT:
- accumulate = 2;
- break;
- case YAML_MAPPING_START_EVENT:
- accumulate = 3;
- break;
- default:
- return 0;
- }
-
- if (emitter->events.tail - emitter->events.head > accumulate)
- return 0;
-
- for (event = emitter->events.head; event != emitter->events.tail; event ++) {
- switch (event->type) {
- case YAML_STREAM_START_EVENT:
- case YAML_DOCUMENT_START_EVENT:
- case YAML_SEQUENCE_START_EVENT:
- case YAML_MAPPING_START_EVENT:
- level += 1;
- break;
- case YAML_STREAM_END_EVENT:
- case YAML_DOCUMENT_END_EVENT:
- case YAML_SEQUENCE_END_EVENT:
- case YAML_MAPPING_END_EVENT:
- level -= 1;
- break;
- default:
- break;
- }
- if (!level)
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Append a directive to the directives stack.
- */
-
-static int
-yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
- yaml_tag_directive_t value, int allow_duplicates)
-{
- yaml_tag_directive_t *tag_directive;
- yaml_tag_directive_t copy = { NULL, NULL };
-
- for (tag_directive = emitter->tag_directives.start;
- tag_directive != emitter->tag_directives.top; tag_directive ++) {
- if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
- if (allow_duplicates)
- return 1;
- return yaml_emitter_set_emitter_error(emitter,
- "duplicate %TAG directive");
- }
- }
-
- copy.handle = yaml_strdup(value.handle);
- copy.prefix = yaml_strdup(value.prefix);
- if (!copy.handle || !copy.prefix) {
- emitter->error = YAML_MEMORY_ERROR;
- goto error;
- }
-
- if (!PUSH(emitter, emitter->tag_directives, copy))
- goto error;
-
- return 1;
-
-error:
- yaml_free(copy.handle);
- yaml_free(copy.prefix);
- return 0;
-}
-
-/*
- * Increase the indentation level.
- */
-
-static int
-yaml_emitter_increase_indent(yaml_emitter_t *emitter,
- int flow, int indentless)
-{
- if (!PUSH(emitter, emitter->indents, emitter->indent))
- return 0;
-
- if (emitter->indent < 0) {
- emitter->indent = flow ? emitter->best_indent : 0;
- }
- else if (!indentless) {
- emitter->indent += emitter->best_indent;
- }
-
- return 1;
-}
-
-/*
- * State dispatcher.
- */
-
-static int
-yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- switch (emitter->state)
- {
- case YAML_EMIT_STREAM_START_STATE:
- return yaml_emitter_emit_stream_start(emitter, event);
-
- case YAML_EMIT_FIRST_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, 1);
-
- case YAML_EMIT_DOCUMENT_START_STATE:
- return yaml_emitter_emit_document_start(emitter, event, 0);
-
- case YAML_EMIT_DOCUMENT_CONTENT_STATE:
- return yaml_emitter_emit_document_content(emitter, event);
-
- case YAML_EMIT_DOCUMENT_END_STATE:
- return yaml_emitter_emit_document_end(emitter, event);
-
- case YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, 1);
-
- case YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_flow_sequence_item(emitter, event, 0);
-
- case YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, 1);
-
- case YAML_EMIT_FLOW_MAPPING_KEY_STATE:
- return yaml_emitter_emit_flow_mapping_key(emitter, event, 0);
-
- case YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, 1);
-
- case YAML_EMIT_FLOW_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_flow_mapping_value(emitter, event, 0);
-
- case YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, 1);
-
- case YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
- return yaml_emitter_emit_block_sequence_item(emitter, event, 0);
-
- case YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, 1);
-
- case YAML_EMIT_BLOCK_MAPPING_KEY_STATE:
- return yaml_emitter_emit_block_mapping_key(emitter, event, 0);
-
- case YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, 1);
-
- case YAML_EMIT_BLOCK_MAPPING_VALUE_STATE:
- return yaml_emitter_emit_block_mapping_value(emitter, event, 0);
-
- case YAML_EMIT_END_STATE:
- return yaml_emitter_set_emitter_error(emitter,
- "expected nothing after STREAM-END");
-
- default:
- assert(1); /* Invalid state. */
- }
-
- return 0;
-}
-
-/*
- * Expect STREAM-START.
- */
-
-static int
-yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
- yaml_event_t *event)
-{
+ int is_whitespace, int is_indention);
+
+static int
+yaml_emitter_write_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int need_whitespace);
+
+static int
+yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
+ yaml_string_t string);
+
+static int
+yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+/*
+ * Set an emitter error and return 0.
+ */
+
+static int
+yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem)
+{
+ emitter->error = YAML_EMITTER_ERROR;
+ emitter->problem = problem;
+
+ return 0;
+}
+
+/*
+ * Emit an event.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!ENQUEUE(emitter, emitter->events, *event)) {
+ yaml_event_delete(event);
+ return 0;
+ }
+
+ while (!yaml_emitter_need_more_events(emitter)) {
+ if (!yaml_emitter_analyze_event(emitter, emitter->events.head))
+ return 0;
+ if (!yaml_emitter_state_machine(emitter, emitter->events.head))
+ return 0;
+ yaml_event_delete(&DEQUEUE(emitter, emitter->events));
+ }
+
+ return 1;
+}
+
+/*
+ * Check if we need to accumulate more events before emitting.
+ *
+ * We accumulate extra
+ * - 1 event for DOCUMENT-START
+ * - 2 events for SEQUENCE-START
+ * - 3 events for MAPPING-START
+ */
+
+static int
+yaml_emitter_need_more_events(yaml_emitter_t *emitter)
+{
+ int level = 0;
+ int accumulate = 0;
+ yaml_event_t *event;
+
+ if (QUEUE_EMPTY(emitter, emitter->events))
+ return 1;
+
+ switch (emitter->events.head->type) {
+ case YAML_DOCUMENT_START_EVENT:
+ accumulate = 1;
+ break;
+ case YAML_SEQUENCE_START_EVENT:
+ accumulate = 2;
+ break;
+ case YAML_MAPPING_START_EVENT:
+ accumulate = 3;
+ break;
+ default:
+ return 0;
+ }
+
+ if (emitter->events.tail - emitter->events.head > accumulate)
+ return 0;
+
+ for (event = emitter->events.head; event != emitter->events.tail; event ++) {
+ switch (event->type) {
+ case YAML_STREAM_START_EVENT:
+ case YAML_DOCUMENT_START_EVENT:
+ case YAML_SEQUENCE_START_EVENT:
+ case YAML_MAPPING_START_EVENT:
+ level += 1;
+ break;
+ case YAML_STREAM_END_EVENT:
+ case YAML_DOCUMENT_END_EVENT:
+ case YAML_SEQUENCE_END_EVENT:
+ case YAML_MAPPING_END_EVENT:
+ level -= 1;
+ break;
+ default:
+ break;
+ }
+ if (!level)
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Append a directive to the directives stack.
+ */
+
+static int
+yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t value, int allow_duplicates)
+{
+ yaml_tag_directive_t *tag_directive;
+ yaml_tag_directive_t copy = { NULL, NULL };
+
+ for (tag_directive = emitter->tag_directives.start;
+ tag_directive != emitter->tag_directives.top; tag_directive ++) {
+ if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
+ if (allow_duplicates)
+ return 1;
+ return yaml_emitter_set_emitter_error(emitter,
+ "duplicate %TAG directive");
+ }
+ }
+
+ copy.handle = yaml_strdup(value.handle);
+ copy.prefix = yaml_strdup(value.prefix);
+ if (!copy.handle || !copy.prefix) {
+ emitter->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+
+ if (!PUSH(emitter, emitter->tag_directives, copy))
+ goto error;
+
+ return 1;
+
+error:
+ yaml_free(copy.handle);
+ yaml_free(copy.prefix);
+ return 0;
+}
+
+/*
+ * Increase the indentation level.
+ */
+
+static int
+yaml_emitter_increase_indent(yaml_emitter_t *emitter,
+ int flow, int indentless)
+{
+ if (!PUSH(emitter, emitter->indents, emitter->indent))
+ return 0;
+
+ if (emitter->indent < 0) {
+ emitter->indent = flow ? emitter->best_indent : 0;
+ }
+ else if (!indentless) {
+ emitter->indent += emitter->best_indent;
+ }
+
+ return 1;
+}
+
+/*
+ * State dispatcher.
+ */
+
+static int
+yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ switch (emitter->state)
+ {
+ case YAML_EMIT_STREAM_START_STATE:
+ return yaml_emitter_emit_stream_start(emitter, event);
+
+ case YAML_EMIT_FIRST_DOCUMENT_START_STATE:
+ return yaml_emitter_emit_document_start(emitter, event, 1);
+
+ case YAML_EMIT_DOCUMENT_START_STATE:
+ return yaml_emitter_emit_document_start(emitter, event, 0);
+
+ case YAML_EMIT_DOCUMENT_CONTENT_STATE:
+ return yaml_emitter_emit_document_content(emitter, event);
+
+ case YAML_EMIT_DOCUMENT_END_STATE:
+ return yaml_emitter_emit_document_end(emitter, event);
+
+ case YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
+ return yaml_emitter_emit_flow_sequence_item(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE:
+ return yaml_emitter_emit_flow_sequence_item(emitter, event, 0);
+
+ case YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
+ return yaml_emitter_emit_flow_mapping_key(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_MAPPING_KEY_STATE:
+ return yaml_emitter_emit_flow_mapping_key(emitter, event, 0);
+
+ case YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
+ return yaml_emitter_emit_flow_mapping_value(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_MAPPING_VALUE_STATE:
+ return yaml_emitter_emit_flow_mapping_value(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
+ return yaml_emitter_emit_block_sequence_item(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
+ return yaml_emitter_emit_block_sequence_item(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
+ return yaml_emitter_emit_block_mapping_key(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_MAPPING_KEY_STATE:
+ return yaml_emitter_emit_block_mapping_key(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
+ return yaml_emitter_emit_block_mapping_value(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_MAPPING_VALUE_STATE:
+ return yaml_emitter_emit_block_mapping_value(emitter, event, 0);
+
+ case YAML_EMIT_END_STATE:
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected nothing after STREAM-END");
+
+ default:
+ assert(1); /* Invalid state. */
+ }
+
+ return 0;
+}
+
+/*
+ * Expect STREAM-START.
+ */
+
+static int
+yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
emitter->open_ended = 0;
- if (event->type == YAML_STREAM_START_EVENT)
- {
- if (!emitter->encoding) {
- emitter->encoding = event->data.stream_start.encoding;
- }
-
- if (!emitter->encoding) {
- emitter->encoding = YAML_UTF8_ENCODING;
- }
-
- if (emitter->best_indent < 2 || emitter->best_indent > 9) {
- emitter->best_indent = 2;
- }
-
- if (emitter->best_width >= 0
- && emitter->best_width <= emitter->best_indent*2) {
- emitter->best_width = 80;
- }
-
- if (emitter->best_width < 0) {
- emitter->best_width = INT_MAX;
- }
-
- if (!emitter->line_break) {
- emitter->line_break = YAML_LN_BREAK;
- }
-
- emitter->indent = -1;
-
- emitter->line = 0;
- emitter->column = 0;
- emitter->whitespace = 1;
- emitter->indention = 1;
-
- if (emitter->encoding != YAML_UTF8_ENCODING) {
- if (!yaml_emitter_write_bom(emitter))
- return 0;
- }
-
- emitter->state = YAML_EMIT_FIRST_DOCUMENT_START_STATE;
-
- return 1;
- }
-
- return yaml_emitter_set_emitter_error(emitter,
- "expected STREAM-START");
-}
-
-/*
- * Expect DOCUMENT-START or STREAM-END.
- */
-
-static int
-yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
- yaml_event_t *event, int first)
-{
- if (event->type == YAML_DOCUMENT_START_EVENT)
- {
- yaml_tag_directive_t default_tag_directives[] = {
- {(yaml_char_t *)"!", (yaml_char_t *)"!"},
- {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
- {NULL, NULL}
- };
- yaml_tag_directive_t *tag_directive;
- int implicit;
-
- if (event->data.document_start.version_directive) {
- if (!yaml_emitter_analyze_version_directive(emitter,
- *event->data.document_start.version_directive))
- return 0;
- }
-
- for (tag_directive = event->data.document_start.tag_directives.start;
- tag_directive != event->data.document_start.tag_directives.end;
- tag_directive ++) {
- if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive))
- return 0;
- if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0))
- return 0;
- }
-
- for (tag_directive = default_tag_directives;
- tag_directive->handle; tag_directive ++) {
- if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1))
- return 0;
- }
-
- implicit = event->data.document_start.implicit;
- if (!first || emitter->canonical) {
- implicit = 0;
- }
-
- if ((event->data.document_start.version_directive ||
- (event->data.document_start.tag_directives.start
- != event->data.document_start.tag_directives.end)) &&
- emitter->open_ended)
- {
- if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
- return 0;
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
+ if (event->type == YAML_STREAM_START_EVENT)
+ {
+ if (!emitter->encoding) {
+ emitter->encoding = event->data.stream_start.encoding;
+ }
+
+ if (!emitter->encoding) {
+ emitter->encoding = YAML_UTF8_ENCODING;
+ }
+
+ if (emitter->best_indent < 2 || emitter->best_indent > 9) {
+ emitter->best_indent = 2;
+ }
+
+ if (emitter->best_width >= 0
+ && emitter->best_width <= emitter->best_indent*2) {
+ emitter->best_width = 80;
+ }
+
+ if (emitter->best_width < 0) {
+ emitter->best_width = INT_MAX;
+ }
+
+ if (!emitter->line_break) {
+ emitter->line_break = YAML_LN_BREAK;
+ }
+
+ emitter->indent = -1;
+
+ emitter->line = 0;
+ emitter->column = 0;
+ emitter->whitespace = 1;
+ emitter->indention = 1;
+
+ if (emitter->encoding != YAML_UTF8_ENCODING) {
+ if (!yaml_emitter_write_bom(emitter))
+ return 0;
+ }
+
+ emitter->state = YAML_EMIT_FIRST_DOCUMENT_START_STATE;
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected STREAM-START");
+}
+
+/*
+ * Expect DOCUMENT-START or STREAM-END.
+ */
+
+static int
+yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (event->type == YAML_DOCUMENT_START_EVENT)
+ {
+ yaml_tag_directive_t default_tag_directives[] = {
+ {(yaml_char_t *)"!", (yaml_char_t *)"!"},
+ {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
+ {NULL, NULL}
+ };
+ yaml_tag_directive_t *tag_directive;
+ int implicit;
+
+ if (event->data.document_start.version_directive) {
+ if (!yaml_emitter_analyze_version_directive(emitter,
+ *event->data.document_start.version_directive))
+ return 0;
+ }
+
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive ++) {
+ if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive))
+ return 0;
+ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0))
+ return 0;
+ }
+
+ for (tag_directive = default_tag_directives;
+ tag_directive->handle; tag_directive ++) {
+ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1))
+ return 0;
+ }
+
+ implicit = event->data.document_start.implicit;
+ if (!first || emitter->canonical) {
+ implicit = 0;
+ }
+
+ if ((event->data.document_start.version_directive ||
+ (event->data.document_start.tag_directives.start
+ != event->data.document_start.tag_directives.end)) &&
+ emitter->open_ended)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
emitter->open_ended = 0;
-
- if (event->data.document_start.version_directive) {
- implicit = 0;
- if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
- return 0;
+
+ if (event->data.document_start.version_directive) {
+ implicit = 0;
+ if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
+ return 0;
if (event->data.document_start.version_directive->minor == 1) {
if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
return 0;
@@ -612,53 +612,53 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
if (!yaml_emitter_write_indicator(emitter, "1.2", 1, 0, 0))
return 0;
}
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
-
- if (event->data.document_start.tag_directives.start
- != event->data.document_start.tag_directives.end) {
- implicit = 0;
- for (tag_directive = event->data.document_start.tag_directives.start;
- tag_directive != event->data.document_start.tag_directives.end;
- tag_directive ++) {
- if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0))
- return 0;
- if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle,
- strlen((char *)tag_directive->handle)))
- return 0;
- if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix,
- strlen((char *)tag_directive->prefix), 1))
- return 0;
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- }
-
- if (yaml_emitter_check_empty_document(emitter)) {
- implicit = 0;
- }
-
- if (!implicit) {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0))
- return 0;
- if (emitter->canonical) {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- }
-
- emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
-
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (event->data.document_start.tag_directives.start
+ != event->data.document_start.tag_directives.end) {
+ implicit = 0;
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive ++) {
+ if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ return 0;
+ if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix,
+ strlen((char *)tag_directive->prefix), 1))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ }
+
+ if (yaml_emitter_check_empty_document(emitter)) {
+ implicit = 0;
+ }
+
+ if (!implicit) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0))
+ return 0;
+ if (emitter->canonical) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ }
+
+ emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
+
emitter->open_ended = 0;
- return 1;
- }
-
- else if (event->type == YAML_STREAM_END_EVENT)
- {
-
+ return 1;
+ }
+
+ else if (event->type == YAML_STREAM_END_EVENT)
+ {
+
/**
* This can happen if a block scalar with trailing empty lines
* is at the end of the stream
@@ -671,1260 +671,1260 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
if (!yaml_emitter_write_indent(emitter))
return 0;
}
- if (!yaml_emitter_flush(emitter))
- return 0;
-
- emitter->state = YAML_EMIT_END_STATE;
-
- return 1;
- }
-
- return yaml_emitter_set_emitter_error(emitter,
- "expected DOCUMENT-START or STREAM-END");
-}
-
-/*
- * Expect the root node.
- */
-
-static int
-yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
- yaml_event_t *event)
-{
- if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 1, 0, 0, 0);
-}
-
-/*
- * Expect DOCUMENT-END.
- */
-
-static int
-yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
- yaml_event_t *event)
-{
- if (event->type == YAML_DOCUMENT_END_EVENT)
- {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- if (!event->data.document_end.implicit) {
- if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
- return 0;
+ if (!yaml_emitter_flush(emitter))
+ return 0;
+
+ emitter->state = YAML_EMIT_END_STATE;
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected DOCUMENT-START or STREAM-END");
+}
+
+/*
+ * Expect the root node.
+ */
+
+static int
+yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 1, 0, 0, 0);
+}
+
+/*
+ * Expect DOCUMENT-END.
+ */
+
+static int
+yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ if (event->type == YAML_DOCUMENT_END_EVENT)
+ {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!event->data.document_end.implicit) {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
emitter->open_ended = 0;
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
else if (!emitter->open_ended)
emitter->open_ended = 1;
- if (!yaml_emitter_flush(emitter))
- return 0;
-
- emitter->state = YAML_EMIT_DOCUMENT_START_STATE;
-
- while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
- yaml_tag_directive_t tag_directive = POP(emitter,
- emitter->tag_directives);
- yaml_free(tag_directive.handle);
- yaml_free(tag_directive.prefix);
- }
-
- return 1;
- }
-
- return yaml_emitter_set_emitter_error(emitter,
- "expected DOCUMENT-END");
-}
-
-/*
+ if (!yaml_emitter_flush(emitter))
+ return 0;
+
+ emitter->state = YAML_EMIT_DOCUMENT_START_STATE;
+
+ while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(emitter,
+ emitter->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected DOCUMENT-END");
+}
+
+/*
*
- * Expect a flow item node.
- */
-
-static int
-yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
- yaml_event_t *event, int first)
-{
- if (first)
- {
- if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0))
- return 0;
- if (!yaml_emitter_increase_indent(emitter, 1, 0))
- return 0;
- emitter->flow_level ++;
- }
-
- if (event->type == YAML_SEQUENCE_END_EVENT)
- {
- emitter->flow_level --;
- emitter->indent = POP(emitter, emitter->indents);
- if (emitter->canonical && !first) {
- if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
- return 0;
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0))
- return 0;
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
- }
-
- if (!first) {
- if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
- return 0;
- }
-
- if (emitter->canonical || emitter->column > emitter->best_width) {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
-}
-
-/*
- * Expect a flow key node.
- */
-
-static int
-yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
- yaml_event_t *event, int first)
-{
- if (first)
- {
- if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0))
- return 0;
- if (!yaml_emitter_increase_indent(emitter, 1, 0))
- return 0;
- emitter->flow_level ++;
- }
-
- if (event->type == YAML_MAPPING_END_EVENT)
- {
- emitter->flow_level --;
- emitter->indent = POP(emitter, emitter->indents);
- if (emitter->canonical && !first) {
- if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
- return 0;
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0))
- return 0;
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
- }
-
- if (!first) {
- if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
- return 0;
- }
- if (emitter->canonical || emitter->column > emitter->best_width) {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
-
- if (!emitter->canonical && yaml_emitter_check_simple_key(emitter))
- {
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
- }
- else
- {
- if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0))
- return 0;
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_FLOW_MAPPING_VALUE_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
- }
-}
-
-/*
- * Expect a flow value node.
- */
-
-static int
-yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
- yaml_event_t *event, int simple)
-{
- if (simple) {
- if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
- return 0;
- }
- else {
- if (emitter->canonical || emitter->column > emitter->best_width) {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- }
- if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0))
- return 0;
- }
- if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE))
- return 0;
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
-}
-
-/*
- * Expect a block item node.
- */
-
-static int
-yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
- yaml_event_t *event, int first)
-{
- if (first)
- {
- if (!yaml_emitter_increase_indent(emitter, 0,
- (emitter->mapping_context && !emitter->indention)))
- return 0;
- }
-
- if (event->type == YAML_SEQUENCE_END_EVENT)
- {
- emitter->indent = POP(emitter, emitter->indents);
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
- }
-
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1))
- return 0;
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
-}
-
-/*
- * Expect a block key node.
- */
-
-static int
-yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
- yaml_event_t *event, int first)
-{
- if (first)
- {
- if (!yaml_emitter_increase_indent(emitter, 0, 0))
- return 0;
- }
-
- if (event->type == YAML_MAPPING_END_EVENT)
- {
- emitter->indent = POP(emitter, emitter->indents);
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
- }
-
- if (!yaml_emitter_write_indent(emitter))
- return 0;
-
- if (yaml_emitter_check_simple_key(emitter))
- {
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
- }
- else
- {
- if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1))
- return 0;
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_BLOCK_MAPPING_VALUE_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
- }
-}
-
-/*
- * Expect a block value node.
- */
-
-static int
-yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
- yaml_event_t *event, int simple)
-{
- if (simple) {
- if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
- return 0;
- }
- else {
- if (!yaml_emitter_write_indent(emitter))
- return 0;
- if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1))
- return 0;
- }
- if (!PUSH(emitter, emitter->states,
- YAML_EMIT_BLOCK_MAPPING_KEY_STATE))
- return 0;
-
- return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
-}
-
-/*
- * Expect a node.
- */
-
-static int
-yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
- int root, int sequence, int mapping, int simple_key)
-{
- emitter->root_context = root;
- emitter->sequence_context = sequence;
- emitter->mapping_context = mapping;
- emitter->simple_key_context = simple_key;
-
- switch (event->type)
- {
- case YAML_ALIAS_EVENT:
- return yaml_emitter_emit_alias(emitter, event);
-
- case YAML_SCALAR_EVENT:
- return yaml_emitter_emit_scalar(emitter, event);
-
- case YAML_SEQUENCE_START_EVENT:
- return yaml_emitter_emit_sequence_start(emitter, event);
-
- case YAML_MAPPING_START_EVENT:
- return yaml_emitter_emit_mapping_start(emitter, event);
-
- default:
- return yaml_emitter_set_emitter_error(emitter,
- "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS");
- }
-
- return 0;
-}
-
-/*
- * Expect ALIAS.
- */
-
-static int
+ * Expect a flow item node.
+ */
+
+static int
+yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ emitter->flow_level ++;
+ }
+
+ if (event->type == YAML_SEQUENCE_END_EVENT)
+ {
+ emitter->flow_level --;
+ emitter->indent = POP(emitter, emitter->indents);
+ if (emitter->canonical && !first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0))
+ return 0;
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ }
+
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
+}
+
+/*
+ * Expect a flow key node.
+ */
+
+static int
+yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ emitter->flow_level ++;
+ }
+
+ if (event->type == YAML_MAPPING_END_EVENT)
+ {
+ emitter->flow_level --;
+ emitter->indent = POP(emitter, emitter->indents);
+ if (emitter->canonical && !first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0))
+ return 0;
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ }
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (!emitter->canonical && yaml_emitter_check_simple_key(emitter))
+ {
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_FLOW_MAPPING_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+ }
+}
+
+/*
+ * Expect a flow value node.
+ */
+
+static int
+yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple)
+{
+ if (simple) {
+ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
+ return 0;
+ }
+ else {
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+}
+
+/*
+ * Expect a block item node.
+ */
+
+static int
+yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_increase_indent(emitter, 0,
+ (emitter->mapping_context && !emitter->indention)))
+ return 0;
+ }
+
+ if (event->type == YAML_SEQUENCE_END_EVENT)
+ {
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
+}
+
+/*
+ * Expect a block key node.
+ */
+
+static int
+yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_increase_indent(emitter, 0, 0))
+ return 0;
+ }
+
+ if (event->type == YAML_MAPPING_END_EVENT)
+ {
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+
+ if (yaml_emitter_check_simple_key(emitter))
+ {
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+ }
+}
+
+/*
+ * Expect a block value node.
+ */
+
+static int
+yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple)
+{
+ if (simple) {
+ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
+ return 0;
+ }
+ else {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_KEY_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+}
+
+/*
+ * Expect a node.
+ */
+
+static int
+yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
+ int root, int sequence, int mapping, int simple_key)
+{
+ emitter->root_context = root;
+ emitter->sequence_context = sequence;
+ emitter->mapping_context = mapping;
+ emitter->simple_key_context = simple_key;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ return yaml_emitter_emit_alias(emitter, event);
+
+ case YAML_SCALAR_EVENT:
+ return yaml_emitter_emit_scalar(emitter, event);
+
+ case YAML_SEQUENCE_START_EVENT:
+ return yaml_emitter_emit_sequence_start(emitter, event);
+
+ case YAML_MAPPING_START_EVENT:
+ return yaml_emitter_emit_mapping_start(emitter, event);
+
+ default:
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS");
+ }
+
+ return 0;
+}
+
+/*
+ * Expect ALIAS.
+ */
+
+static int
yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event))
-{
- if (!yaml_emitter_process_anchor(emitter))
- return 0;
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
if (emitter->simple_key_context)
if (!PUT(emitter, ' ')) return 0;
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
-}
-
-/*
- * Expect SCALAR.
- */
-
-static int
-yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- if (!yaml_emitter_select_scalar_style(emitter, event))
- return 0;
- if (!yaml_emitter_process_anchor(emitter))
- return 0;
- if (!yaml_emitter_process_tag(emitter))
- return 0;
- if (!yaml_emitter_increase_indent(emitter, 1, 0))
- return 0;
- if (!yaml_emitter_process_scalar(emitter))
- return 0;
- emitter->indent = POP(emitter, emitter->indents);
- emitter->state = POP(emitter, emitter->states);
-
- return 1;
-}
-
-/*
- * Expect SEQUENCE-START.
- */
-
-static int
-yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- if (!yaml_emitter_process_anchor(emitter))
- return 0;
- if (!yaml_emitter_process_tag(emitter))
- return 0;
-
- if (emitter->flow_level || emitter->canonical
- || event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE
- || yaml_emitter_check_empty_sequence(emitter)) {
- emitter->state = YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE;
- }
- else {
- emitter->state = YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE;
- }
-
- return 1;
-}
-
-/*
- * Expect MAPPING-START.
- */
-
-static int
-yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- if (!yaml_emitter_process_anchor(emitter))
- return 0;
- if (!yaml_emitter_process_tag(emitter))
- return 0;
-
- if (emitter->flow_level || emitter->canonical
- || event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE
- || yaml_emitter_check_empty_mapping(emitter)) {
- emitter->state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE;
- }
- else {
- emitter->state = YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE;
- }
-
- return 1;
-}
-
-/*
- * Check if the document content is an empty scalar.
- */
-
-static int
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+}
+
+/*
+ * Expect SCALAR.
+ */
+
+static int
+yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_select_scalar_style(emitter, event))
+ return 0;
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ if (!yaml_emitter_process_scalar(emitter))
+ return 0;
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+}
+
+/*
+ * Expect SEQUENCE-START.
+ */
+
+static int
+yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+
+ if (emitter->flow_level || emitter->canonical
+ || event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE
+ || yaml_emitter_check_empty_sequence(emitter)) {
+ emitter->state = YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE;
+ }
+ else {
+ emitter->state = YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE;
+ }
+
+ return 1;
+}
+
+/*
+ * Expect MAPPING-START.
+ */
+
+static int
+yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+
+ if (emitter->flow_level || emitter->canonical
+ || event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE
+ || yaml_emitter_check_empty_mapping(emitter)) {
+ emitter->state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE;
+ }
+ else {
+ emitter->state = YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE;
+ }
+
+ return 1;
+}
+
+/*
+ * Check if the document content is an empty scalar.
+ */
+
+static int
yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
-{
- return 0;
-}
-
-/*
- * Check if the next events represent an empty sequence.
- */
-
-static int
-yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter)
-{
- if (emitter->events.tail - emitter->events.head < 2)
- return 0;
-
- return (emitter->events.head[0].type == YAML_SEQUENCE_START_EVENT
- && emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT);
-}
-
-/*
- * Check if the next events represent an empty mapping.
- */
-
-static int
-yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter)
-{
- if (emitter->events.tail - emitter->events.head < 2)
- return 0;
-
- return (emitter->events.head[0].type == YAML_MAPPING_START_EVENT
- && emitter->events.head[1].type == YAML_MAPPING_END_EVENT);
-}
-
-/*
- * Check if the next node can be expressed as a simple key.
- */
-
-static int
-yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
-{
- yaml_event_t *event = emitter->events.head;
- size_t length = 0;
-
- switch (event->type)
- {
- case YAML_ALIAS_EVENT:
- length += emitter->anchor_data.anchor_length;
- break;
-
- case YAML_SCALAR_EVENT:
- if (emitter->scalar_data.multiline)
- return 0;
- length += emitter->anchor_data.anchor_length
- + emitter->tag_data.handle_length
- + emitter->tag_data.suffix_length
- + emitter->scalar_data.length;
- break;
-
- case YAML_SEQUENCE_START_EVENT:
- if (!yaml_emitter_check_empty_sequence(emitter))
- return 0;
- length += emitter->anchor_data.anchor_length
- + emitter->tag_data.handle_length
- + emitter->tag_data.suffix_length;
- break;
-
- case YAML_MAPPING_START_EVENT:
- if (!yaml_emitter_check_empty_mapping(emitter))
- return 0;
- length += emitter->anchor_data.anchor_length
- + emitter->tag_data.handle_length
- + emitter->tag_data.suffix_length;
- break;
-
- default:
- return 0;
- }
-
- if (length > 128)
- return 0;
-
- return 1;
-}
-
-/*
- * Determine an acceptable scalar style.
- */
-
-static int
-yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
-{
- yaml_scalar_style_t style = event->data.scalar.style;
- int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix);
-
- if (no_tag && !event->data.scalar.plain_implicit
- && !event->data.scalar.quoted_implicit) {
- return yaml_emitter_set_emitter_error(emitter,
- "neither tag nor implicit flags are specified");
- }
-
- if (style == YAML_ANY_SCALAR_STYLE)
- style = YAML_PLAIN_SCALAR_STYLE;
-
- if (emitter->canonical)
- style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
-
- if (emitter->simple_key_context && emitter->scalar_data.multiline)
- style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
-
- if (style == YAML_PLAIN_SCALAR_STYLE)
- {
- if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed)
- || (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed))
- style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
- if (!emitter->scalar_data.length
- && (emitter->flow_level || emitter->simple_key_context))
- style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
- if (no_tag && !event->data.scalar.plain_implicit)
- style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
- }
-
- if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE)
- {
- if (!emitter->scalar_data.single_quoted_allowed)
- style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
- }
-
- if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE)
- {
- if (!emitter->scalar_data.block_allowed
- || emitter->flow_level || emitter->simple_key_context)
- style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
- }
-
- if (no_tag && !event->data.scalar.quoted_implicit
- && style != YAML_PLAIN_SCALAR_STYLE)
- {
- emitter->tag_data.handle = (yaml_char_t *)"!";
- emitter->tag_data.handle_length = 1;
- }
-
- emitter->scalar_data.style = style;
-
- return 1;
-}
-
-/*
+{
+ return 0;
+}
+
+/*
+ * Check if the next events represent an empty sequence.
+ */
+
+static int
+yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter)
+{
+ if (emitter->events.tail - emitter->events.head < 2)
+ return 0;
+
+ return (emitter->events.head[0].type == YAML_SEQUENCE_START_EVENT
+ && emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT);
+}
+
+/*
+ * Check if the next events represent an empty mapping.
+ */
+
+static int
+yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter)
+{
+ if (emitter->events.tail - emitter->events.head < 2)
+ return 0;
+
+ return (emitter->events.head[0].type == YAML_MAPPING_START_EVENT
+ && emitter->events.head[1].type == YAML_MAPPING_END_EVENT);
+}
+
+/*
+ * Check if the next node can be expressed as a simple key.
+ */
+
+static int
+yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
+{
+ yaml_event_t *event = emitter->events.head;
+ size_t length = 0;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ length += emitter->anchor_data.anchor_length;
+ break;
+
+ case YAML_SCALAR_EVENT:
+ if (emitter->scalar_data.multiline)
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length
+ + emitter->scalar_data.length;
+ break;
+
+ case YAML_SEQUENCE_START_EVENT:
+ if (!yaml_emitter_check_empty_sequence(emitter))
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length;
+ break;
+
+ case YAML_MAPPING_START_EVENT:
+ if (!yaml_emitter_check_empty_mapping(emitter))
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length;
+ break;
+
+ default:
+ return 0;
+ }
+
+ if (length > 128)
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Determine an acceptable scalar style.
+ */
+
+static int
+yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ yaml_scalar_style_t style = event->data.scalar.style;
+ int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix);
+
+ if (no_tag && !event->data.scalar.plain_implicit
+ && !event->data.scalar.quoted_implicit) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "neither tag nor implicit flags are specified");
+ }
+
+ if (style == YAML_ANY_SCALAR_STYLE)
+ style = YAML_PLAIN_SCALAR_STYLE;
+
+ if (emitter->canonical)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+
+ if (emitter->simple_key_context && emitter->scalar_data.multiline)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+
+ if (style == YAML_PLAIN_SCALAR_STYLE)
+ {
+ if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed)
+ || (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed))
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ if (!emitter->scalar_data.length
+ && (emitter->flow_level || emitter->simple_key_context))
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ if (no_tag && !event->data.scalar.plain_implicit)
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE)
+ {
+ if (!emitter->scalar_data.single_quoted_allowed)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE)
+ {
+ if (!emitter->scalar_data.block_allowed
+ || emitter->flow_level || emitter->simple_key_context)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (no_tag && !event->data.scalar.quoted_implicit
+ && style != YAML_PLAIN_SCALAR_STYLE)
+ {
+ emitter->tag_data.handle = (yaml_char_t *)"!";
+ emitter->tag_data.handle_length = 1;
+ }
+
+ emitter->scalar_data.style = style;
+
+ return 1;
+}
+
+/*
* Write an anchor.
- */
-
-static int
-yaml_emitter_process_anchor(yaml_emitter_t *emitter)
-{
- if (!emitter->anchor_data.anchor)
- return 1;
-
- if (!yaml_emitter_write_indicator(emitter,
- (emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0))
- return 0;
-
- return yaml_emitter_write_anchor(emitter,
- emitter->anchor_data.anchor, emitter->anchor_data.anchor_length);
-}
-
-/*
- * Write a tag.
- */
-
-static int
-yaml_emitter_process_tag(yaml_emitter_t *emitter)
-{
- if (!emitter->tag_data.handle && !emitter->tag_data.suffix)
- return 1;
-
- if (emitter->tag_data.handle)
- {
- if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle,
- emitter->tag_data.handle_length))
- return 0;
- if (emitter->tag_data.suffix) {
- if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
- emitter->tag_data.suffix_length, 0))
- return 0;
- }
- }
- else
- {
- if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0))
- return 0;
- if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
- emitter->tag_data.suffix_length, 0))
- return 0;
- if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0))
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Write a scalar.
- */
-
-static int
-yaml_emitter_process_scalar(yaml_emitter_t *emitter)
-{
- switch (emitter->scalar_data.style)
- {
- case YAML_PLAIN_SCALAR_STYLE:
- return yaml_emitter_write_plain_scalar(emitter,
- emitter->scalar_data.value, emitter->scalar_data.length,
- !emitter->simple_key_context);
-
- case YAML_SINGLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_single_quoted_scalar(emitter,
- emitter->scalar_data.value, emitter->scalar_data.length,
- !emitter->simple_key_context);
-
- case YAML_DOUBLE_QUOTED_SCALAR_STYLE:
- return yaml_emitter_write_double_quoted_scalar(emitter,
- emitter->scalar_data.value, emitter->scalar_data.length,
- !emitter->simple_key_context);
-
- case YAML_LITERAL_SCALAR_STYLE:
- return yaml_emitter_write_literal_scalar(emitter,
- emitter->scalar_data.value, emitter->scalar_data.length);
-
- case YAML_FOLDED_SCALAR_STYLE:
- return yaml_emitter_write_folded_scalar(emitter,
- emitter->scalar_data.value, emitter->scalar_data.length);
-
- default:
- assert(1); /* Impossible. */
- }
-
- return 0;
-}
-
-/*
- * Check if a %YAML directive is valid.
- */
-
-static int
-yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
- yaml_version_directive_t version_directive)
-{
+ */
+
+static int
+yaml_emitter_process_anchor(yaml_emitter_t *emitter)
+{
+ if (!emitter->anchor_data.anchor)
+ return 1;
+
+ if (!yaml_emitter_write_indicator(emitter,
+ (emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0))
+ return 0;
+
+ return yaml_emitter_write_anchor(emitter,
+ emitter->anchor_data.anchor, emitter->anchor_data.anchor_length);
+}
+
+/*
+ * Write a tag.
+ */
+
+static int
+yaml_emitter_process_tag(yaml_emitter_t *emitter)
+{
+ if (!emitter->tag_data.handle && !emitter->tag_data.suffix)
+ return 1;
+
+ if (emitter->tag_data.handle)
+ {
+ if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle,
+ emitter->tag_data.handle_length))
+ return 0;
+ if (emitter->tag_data.suffix) {
+ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
+ emitter->tag_data.suffix_length, 0))
+ return 0;
+ }
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
+ emitter->tag_data.suffix_length, 0))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0))
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Write a scalar.
+ */
+
+static int
+yaml_emitter_process_scalar(yaml_emitter_t *emitter)
+{
+ switch (emitter->scalar_data.style)
+ {
+ case YAML_PLAIN_SCALAR_STYLE:
+ return yaml_emitter_write_plain_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_SINGLE_QUOTED_SCALAR_STYLE:
+ return yaml_emitter_write_single_quoted_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_DOUBLE_QUOTED_SCALAR_STYLE:
+ return yaml_emitter_write_double_quoted_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_LITERAL_SCALAR_STYLE:
+ return yaml_emitter_write_literal_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length);
+
+ case YAML_FOLDED_SCALAR_STYLE:
+ return yaml_emitter_write_folded_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length);
+
+ default:
+ assert(1); /* Impossible. */
+ }
+
+ return 0;
+}
+
+/*
+ * Check if a %YAML directive is valid.
+ */
+
+static int
+yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
+ yaml_version_directive_t version_directive)
+{
if (version_directive.major != 1 || (
version_directive.minor != 1
&& version_directive.minor != 2
)) {
- return yaml_emitter_set_emitter_error(emitter,
- "incompatible %YAML directive");
- }
-
- return 1;
-}
-
-/*
- * Check if a %TAG directive is valid.
- */
-
-static int
-yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
- yaml_tag_directive_t tag_directive)
-{
- yaml_string_t handle;
- yaml_string_t prefix;
- size_t handle_length;
- size_t prefix_length;
-
- handle_length = strlen((char *)tag_directive.handle);
- prefix_length = strlen((char *)tag_directive.prefix);
- STRING_ASSIGN(handle, tag_directive.handle, handle_length);
- STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
-
- if (handle.start == handle.end) {
- return yaml_emitter_set_emitter_error(emitter,
- "tag handle must not be empty");
- }
-
- if (handle.start[0] != '!') {
- return yaml_emitter_set_emitter_error(emitter,
- "tag handle must start with '!'");
- }
-
- if (handle.end[-1] != '!') {
- return yaml_emitter_set_emitter_error(emitter,
- "tag handle must end with '!'");
- }
-
- handle.pointer ++;
-
- while (handle.pointer < handle.end-1) {
- if (!IS_ALPHA(handle)) {
- return yaml_emitter_set_emitter_error(emitter,
- "tag handle must contain alphanumerical characters only");
- }
- MOVE(handle);
- }
-
- if (prefix.start == prefix.end) {
- return yaml_emitter_set_emitter_error(emitter,
- "tag prefix must not be empty");
- }
-
- return 1;
-}
-
-/*
- * Check if an anchor is valid.
- */
-
-static int
-yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
- yaml_char_t *anchor, int alias)
-{
- size_t anchor_length;
- yaml_string_t string;
-
- anchor_length = strlen((char *)anchor);
- STRING_ASSIGN(string, anchor, anchor_length);
-
- if (string.start == string.end) {
- return yaml_emitter_set_emitter_error(emitter, alias ?
- "alias value must not be empty" :
- "anchor value must not be empty");
- }
-
- while (string.pointer != string.end) {
- if (!IS_ALPHA(string)) {
- return yaml_emitter_set_emitter_error(emitter, alias ?
- "alias value must contain alphanumerical characters only" :
- "anchor value must contain alphanumerical characters only");
- }
- MOVE(string);
- }
-
- emitter->anchor_data.anchor = string.start;
- emitter->anchor_data.anchor_length = string.end - string.start;
- emitter->anchor_data.alias = alias;
-
- return 1;
-}
-
-/*
- * Check if a tag is valid.
- */
-
-static int
-yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
- yaml_char_t *tag)
-{
- size_t tag_length;
- yaml_string_t string;
- yaml_tag_directive_t *tag_directive;
-
- tag_length = strlen((char *)tag);
- STRING_ASSIGN(string, tag, tag_length);
-
- if (string.start == string.end) {
- return yaml_emitter_set_emitter_error(emitter,
- "tag value must not be empty");
- }
-
- for (tag_directive = emitter->tag_directives.start;
- tag_directive != emitter->tag_directives.top; tag_directive ++) {
- size_t prefix_length = strlen((char *)tag_directive->prefix);
- if (prefix_length < (size_t)(string.end - string.start)
- && strncmp((char *)tag_directive->prefix, (char *)string.start,
- prefix_length) == 0)
- {
- emitter->tag_data.handle = tag_directive->handle;
- emitter->tag_data.handle_length =
- strlen((char *)tag_directive->handle);
- emitter->tag_data.suffix = string.start + prefix_length;
- emitter->tag_data.suffix_length =
- (string.end - string.start) - prefix_length;
- return 1;
- }
- }
-
- emitter->tag_data.suffix = string.start;
- emitter->tag_data.suffix_length = string.end - string.start;
-
- return 1;
-}
-
-/*
- * Check if a scalar is valid.
- */
-
-static int
-yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length)
-{
- yaml_string_t string;
-
- int block_indicators = 0;
- int flow_indicators = 0;
- int line_breaks = 0;
- int special_characters = 0;
-
- int leading_space = 0;
- int leading_break = 0;
- int trailing_space = 0;
- int trailing_break = 0;
- int break_space = 0;
- int space_break = 0;
-
+ return yaml_emitter_set_emitter_error(emitter,
+ "incompatible %YAML directive");
+ }
+
+ return 1;
+}
+
+/*
+ * Check if a %TAG directive is valid.
+ */
+
+static int
+yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t tag_directive)
+{
+ yaml_string_t handle;
+ yaml_string_t prefix;
+ size_t handle_length;
+ size_t prefix_length;
+
+ handle_length = strlen((char *)tag_directive.handle);
+ prefix_length = strlen((char *)tag_directive.prefix);
+ STRING_ASSIGN(handle, tag_directive.handle, handle_length);
+ STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
+
+ if (handle.start == handle.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must not be empty");
+ }
+
+ if (handle.start[0] != '!') {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must start with '!'");
+ }
+
+ if (handle.end[-1] != '!') {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must end with '!'");
+ }
+
+ handle.pointer ++;
+
+ while (handle.pointer < handle.end-1) {
+ if (!IS_ALPHA(handle)) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must contain alphanumerical characters only");
+ }
+ MOVE(handle);
+ }
+
+ if (prefix.start == prefix.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag prefix must not be empty");
+ }
+
+ return 1;
+}
+
+/*
+ * Check if an anchor is valid.
+ */
+
+static int
+yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *anchor, int alias)
+{
+ size_t anchor_length;
+ yaml_string_t string;
+
+ anchor_length = strlen((char *)anchor);
+ STRING_ASSIGN(string, anchor, anchor_length);
+
+ if (string.start == string.end) {
+ return yaml_emitter_set_emitter_error(emitter, alias ?
+ "alias value must not be empty" :
+ "anchor value must not be empty");
+ }
+
+ while (string.pointer != string.end) {
+ if (!IS_ALPHA(string)) {
+ return yaml_emitter_set_emitter_error(emitter, alias ?
+ "alias value must contain alphanumerical characters only" :
+ "anchor value must contain alphanumerical characters only");
+ }
+ MOVE(string);
+ }
+
+ emitter->anchor_data.anchor = string.start;
+ emitter->anchor_data.anchor_length = string.end - string.start;
+ emitter->anchor_data.alias = alias;
+
+ return 1;
+}
+
+/*
+ * Check if a tag is valid.
+ */
+
+static int
+yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
+ yaml_char_t *tag)
+{
+ size_t tag_length;
+ yaml_string_t string;
+ yaml_tag_directive_t *tag_directive;
+
+ tag_length = strlen((char *)tag);
+ STRING_ASSIGN(string, tag, tag_length);
+
+ if (string.start == string.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag value must not be empty");
+ }
+
+ for (tag_directive = emitter->tag_directives.start;
+ tag_directive != emitter->tag_directives.top; tag_directive ++) {
+ size_t prefix_length = strlen((char *)tag_directive->prefix);
+ if (prefix_length < (size_t)(string.end - string.start)
+ && strncmp((char *)tag_directive->prefix, (char *)string.start,
+ prefix_length) == 0)
+ {
+ emitter->tag_data.handle = tag_directive->handle;
+ emitter->tag_data.handle_length =
+ strlen((char *)tag_directive->handle);
+ emitter->tag_data.suffix = string.start + prefix_length;
+ emitter->tag_data.suffix_length =
+ (string.end - string.start) - prefix_length;
+ return 1;
+ }
+ }
+
+ emitter->tag_data.suffix = string.start;
+ emitter->tag_data.suffix_length = string.end - string.start;
+
+ return 1;
+}
+
+/*
+ * Check if a scalar is valid.
+ */
+
+static int
+yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+
+ int block_indicators = 0;
+ int flow_indicators = 0;
+ int line_breaks = 0;
+ int special_characters = 0;
+
+ int leading_space = 0;
+ int leading_break = 0;
+ int trailing_space = 0;
+ int trailing_break = 0;
+ int break_space = 0;
+ int space_break = 0;
+
int preceded_by_whitespace = 0;
- int followed_by_whitespace = 0;
- int previous_space = 0;
- int previous_break = 0;
-
- STRING_ASSIGN(string, value, length);
-
- emitter->scalar_data.value = value;
- emitter->scalar_data.length = length;
-
- if (string.start == string.end)
- {
- emitter->scalar_data.multiline = 0;
- emitter->scalar_data.flow_plain_allowed = 0;
- emitter->scalar_data.block_plain_allowed = 1;
- emitter->scalar_data.single_quoted_allowed = 1;
- emitter->scalar_data.block_allowed = 0;
-
- return 1;
- }
-
- if ((CHECK_AT(string, '-', 0)
- && CHECK_AT(string, '-', 1)
- && CHECK_AT(string, '-', 2))
- || (CHECK_AT(string, '.', 0)
- && CHECK_AT(string, '.', 1)
- && CHECK_AT(string, '.', 2))) {
- block_indicators = 1;
- flow_indicators = 1;
- }
-
+ int followed_by_whitespace = 0;
+ int previous_space = 0;
+ int previous_break = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ emitter->scalar_data.value = value;
+ emitter->scalar_data.length = length;
+
+ if (string.start == string.end)
+ {
+ emitter->scalar_data.multiline = 0;
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 1;
+ emitter->scalar_data.single_quoted_allowed = 1;
+ emitter->scalar_data.block_allowed = 0;
+
+ return 1;
+ }
+
+ if ((CHECK_AT(string, '-', 0)
+ && CHECK_AT(string, '-', 1)
+ && CHECK_AT(string, '-', 2))
+ || (CHECK_AT(string, '.', 0)
+ && CHECK_AT(string, '.', 1)
+ && CHECK_AT(string, '.', 2))) {
+ block_indicators = 1;
+ flow_indicators = 1;
+ }
+
preceded_by_whitespace = 1;
- followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
-
- while (string.pointer != string.end)
- {
- if (string.start == string.pointer)
- {
- if (CHECK(string, '#') || CHECK(string, ',')
- || CHECK(string, '[') || CHECK(string, ']')
- || CHECK(string, '{') || CHECK(string, '}')
- || CHECK(string, '&') || CHECK(string, '*')
- || CHECK(string, '!') || CHECK(string, '|')
- || CHECK(string, '>') || CHECK(string, '\'')
- || CHECK(string, '"') || CHECK(string, '%')
- || CHECK(string, '@') || CHECK(string, '`')) {
- flow_indicators = 1;
- block_indicators = 1;
- }
-
- if (CHECK(string, '?') || CHECK(string, ':')) {
- flow_indicators = 1;
- if (followed_by_whitespace) {
- block_indicators = 1;
- }
- }
-
- if (CHECK(string, '-') && followed_by_whitespace) {
- flow_indicators = 1;
- block_indicators = 1;
- }
- }
- else
- {
- if (CHECK(string, ',') || CHECK(string, '?')
- || CHECK(string, '[') || CHECK(string, ']')
- || CHECK(string, '{') || CHECK(string, '}')) {
- flow_indicators = 1;
- }
-
- if (CHECK(string, ':')) {
- flow_indicators = 1;
- if (followed_by_whitespace) {
- block_indicators = 1;
- }
- }
-
+ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
+
+ while (string.pointer != string.end)
+ {
+ if (string.start == string.pointer)
+ {
+ if (CHECK(string, '#') || CHECK(string, ',')
+ || CHECK(string, '[') || CHECK(string, ']')
+ || CHECK(string, '{') || CHECK(string, '}')
+ || CHECK(string, '&') || CHECK(string, '*')
+ || CHECK(string, '!') || CHECK(string, '|')
+ || CHECK(string, '>') || CHECK(string, '\'')
+ || CHECK(string, '"') || CHECK(string, '%')
+ || CHECK(string, '@') || CHECK(string, '`')) {
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+
+ if (CHECK(string, '?') || CHECK(string, ':')) {
+ flow_indicators = 1;
+ if (followed_by_whitespace) {
+ block_indicators = 1;
+ }
+ }
+
+ if (CHECK(string, '-') && followed_by_whitespace) {
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+ }
+ else
+ {
+ if (CHECK(string, ',') || CHECK(string, '?')
+ || CHECK(string, '[') || CHECK(string, ']')
+ || CHECK(string, '{') || CHECK(string, '}')) {
+ flow_indicators = 1;
+ }
+
+ if (CHECK(string, ':')) {
+ flow_indicators = 1;
+ if (followed_by_whitespace) {
+ block_indicators = 1;
+ }
+ }
+
if (CHECK(string, '#') && preceded_by_whitespace) {
- flow_indicators = 1;
- block_indicators = 1;
- }
- }
-
- if (!IS_PRINTABLE(string)
- || (!IS_ASCII(string) && !emitter->unicode)) {
- special_characters = 1;
- }
-
- if (IS_BREAK(string)) {
- line_breaks = 1;
- }
-
- if (IS_SPACE(string))
- {
- if (string.start == string.pointer) {
- leading_space = 1;
- }
- if (string.pointer+WIDTH(string) == string.end) {
- trailing_space = 1;
- }
- if (previous_break) {
- break_space = 1;
- }
- previous_space = 1;
- previous_break = 0;
- }
- else if (IS_BREAK(string))
- {
- if (string.start == string.pointer) {
- leading_break = 1;
- }
- if (string.pointer+WIDTH(string) == string.end) {
- trailing_break = 1;
- }
- if (previous_space) {
- space_break = 1;
- }
- previous_space = 0;
- previous_break = 1;
- }
- else
- {
- previous_space = 0;
- previous_break = 0;
- }
-
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+ }
+
+ if (!IS_PRINTABLE(string)
+ || (!IS_ASCII(string) && !emitter->unicode)) {
+ special_characters = 1;
+ }
+
+ if (IS_BREAK(string)) {
+ line_breaks = 1;
+ }
+
+ if (IS_SPACE(string))
+ {
+ if (string.start == string.pointer) {
+ leading_space = 1;
+ }
+ if (string.pointer+WIDTH(string) == string.end) {
+ trailing_space = 1;
+ }
+ if (previous_break) {
+ break_space = 1;
+ }
+ previous_space = 1;
+ previous_break = 0;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (string.start == string.pointer) {
+ leading_break = 1;
+ }
+ if (string.pointer+WIDTH(string) == string.end) {
+ trailing_break = 1;
+ }
+ if (previous_space) {
+ space_break = 1;
+ }
+ previous_space = 0;
+ previous_break = 1;
+ }
+ else
+ {
+ previous_space = 0;
+ previous_break = 0;
+ }
+
preceded_by_whitespace = IS_BLANKZ(string);
- MOVE(string);
- if (string.pointer != string.end) {
- followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
- }
- }
-
- emitter->scalar_data.multiline = line_breaks;
-
- emitter->scalar_data.flow_plain_allowed = 1;
- emitter->scalar_data.block_plain_allowed = 1;
- emitter->scalar_data.single_quoted_allowed = 1;
- emitter->scalar_data.block_allowed = 1;
-
- if (leading_space || leading_break || trailing_space || trailing_break) {
- emitter->scalar_data.flow_plain_allowed = 0;
- emitter->scalar_data.block_plain_allowed = 0;
- }
-
- if (trailing_space) {
- emitter->scalar_data.block_allowed = 0;
- }
-
- if (break_space) {
- emitter->scalar_data.flow_plain_allowed = 0;
- emitter->scalar_data.block_plain_allowed = 0;
- emitter->scalar_data.single_quoted_allowed = 0;
- }
-
- if (space_break || special_characters) {
- emitter->scalar_data.flow_plain_allowed = 0;
- emitter->scalar_data.block_plain_allowed = 0;
- emitter->scalar_data.single_quoted_allowed = 0;
- emitter->scalar_data.block_allowed = 0;
- }
-
- if (line_breaks) {
- emitter->scalar_data.flow_plain_allowed = 0;
- emitter->scalar_data.block_plain_allowed = 0;
- }
-
- if (flow_indicators) {
- emitter->scalar_data.flow_plain_allowed = 0;
- }
-
- if (block_indicators) {
- emitter->scalar_data.block_plain_allowed = 0;
- }
-
- return 1;
-}
-
-/*
- * Check if the event data is valid.
- */
-
-static int
-yaml_emitter_analyze_event(yaml_emitter_t *emitter,
- yaml_event_t *event)
-{
- emitter->anchor_data.anchor = NULL;
- emitter->anchor_data.anchor_length = 0;
- emitter->tag_data.handle = NULL;
- emitter->tag_data.handle_length = 0;
- emitter->tag_data.suffix = NULL;
- emitter->tag_data.suffix_length = 0;
- emitter->scalar_data.value = NULL;
- emitter->scalar_data.length = 0;
-
- switch (event->type)
- {
- case YAML_ALIAS_EVENT:
- if (!yaml_emitter_analyze_anchor(emitter,
- event->data.alias.anchor, 1))
- return 0;
- return 1;
-
- case YAML_SCALAR_EVENT:
- if (event->data.scalar.anchor) {
- if (!yaml_emitter_analyze_anchor(emitter,
- event->data.scalar.anchor, 0))
- return 0;
- }
- if (event->data.scalar.tag && (emitter->canonical ||
- (!event->data.scalar.plain_implicit
- && !event->data.scalar.quoted_implicit))) {
- if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag))
- return 0;
- }
- if (!yaml_emitter_analyze_scalar(emitter,
- event->data.scalar.value, event->data.scalar.length))
- return 0;
- return 1;
-
- case YAML_SEQUENCE_START_EVENT:
- if (event->data.sequence_start.anchor) {
- if (!yaml_emitter_analyze_anchor(emitter,
- event->data.sequence_start.anchor, 0))
- return 0;
- }
- if (event->data.sequence_start.tag && (emitter->canonical ||
- !event->data.sequence_start.implicit)) {
- if (!yaml_emitter_analyze_tag(emitter,
- event->data.sequence_start.tag))
- return 0;
- }
- return 1;
-
- case YAML_MAPPING_START_EVENT:
- if (event->data.mapping_start.anchor) {
- if (!yaml_emitter_analyze_anchor(emitter,
- event->data.mapping_start.anchor, 0))
- return 0;
- }
- if (event->data.mapping_start.tag && (emitter->canonical ||
- !event->data.mapping_start.implicit)) {
- if (!yaml_emitter_analyze_tag(emitter,
- event->data.mapping_start.tag))
- return 0;
- }
- return 1;
-
- default:
- return 1;
- }
-}
-
-/*
- * Write the BOM character.
- */
-
-static int
-yaml_emitter_write_bom(yaml_emitter_t *emitter)
-{
- if (!FLUSH(emitter)) return 0;
-
- *(emitter->buffer.pointer++) = (yaml_char_t) '\xEF';
- *(emitter->buffer.pointer++) = (yaml_char_t) '\xBB';
- *(emitter->buffer.pointer++) = (yaml_char_t) '\xBF';
-
- return 1;
-}
-
-static int
-yaml_emitter_write_indent(yaml_emitter_t *emitter)
-{
- int indent = (emitter->indent >= 0) ? emitter->indent : 0;
-
- if (!emitter->indention || emitter->column > indent
- || (emitter->column == indent && !emitter->whitespace)) {
- if (!PUT_BREAK(emitter)) return 0;
- }
-
- while (emitter->column < indent) {
- if (!PUT(emitter, ' ')) return 0;
- }
-
- emitter->whitespace = 1;
- emitter->indention = 1;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_indicator(yaml_emitter_t *emitter,
+ MOVE(string);
+ if (string.pointer != string.end) {
+ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
+ }
+ }
+
+ emitter->scalar_data.multiline = line_breaks;
+
+ emitter->scalar_data.flow_plain_allowed = 1;
+ emitter->scalar_data.block_plain_allowed = 1;
+ emitter->scalar_data.single_quoted_allowed = 1;
+ emitter->scalar_data.block_allowed = 1;
+
+ if (leading_space || leading_break || trailing_space || trailing_break) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ if (trailing_space) {
+ emitter->scalar_data.block_allowed = 0;
+ }
+
+ if (break_space) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ emitter->scalar_data.single_quoted_allowed = 0;
+ }
+
+ if (space_break || special_characters) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ emitter->scalar_data.single_quoted_allowed = 0;
+ emitter->scalar_data.block_allowed = 0;
+ }
+
+ if (line_breaks) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ if (flow_indicators) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ }
+
+ if (block_indicators) {
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Check if the event data is valid.
+ */
+
+static int
+yaml_emitter_analyze_event(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ emitter->anchor_data.anchor = NULL;
+ emitter->anchor_data.anchor_length = 0;
+ emitter->tag_data.handle = NULL;
+ emitter->tag_data.handle_length = 0;
+ emitter->tag_data.suffix = NULL;
+ emitter->tag_data.suffix_length = 0;
+ emitter->scalar_data.value = NULL;
+ emitter->scalar_data.length = 0;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.alias.anchor, 1))
+ return 0;
+ return 1;
+
+ case YAML_SCALAR_EVENT:
+ if (event->data.scalar.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.scalar.anchor, 0))
+ return 0;
+ }
+ if (event->data.scalar.tag && (emitter->canonical ||
+ (!event->data.scalar.plain_implicit
+ && !event->data.scalar.quoted_implicit))) {
+ if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag))
+ return 0;
+ }
+ if (!yaml_emitter_analyze_scalar(emitter,
+ event->data.scalar.value, event->data.scalar.length))
+ return 0;
+ return 1;
+
+ case YAML_SEQUENCE_START_EVENT:
+ if (event->data.sequence_start.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.sequence_start.anchor, 0))
+ return 0;
+ }
+ if (event->data.sequence_start.tag && (emitter->canonical ||
+ !event->data.sequence_start.implicit)) {
+ if (!yaml_emitter_analyze_tag(emitter,
+ event->data.sequence_start.tag))
+ return 0;
+ }
+ return 1;
+
+ case YAML_MAPPING_START_EVENT:
+ if (event->data.mapping_start.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.mapping_start.anchor, 0))
+ return 0;
+ }
+ if (event->data.mapping_start.tag && (emitter->canonical ||
+ !event->data.mapping_start.implicit)) {
+ if (!yaml_emitter_analyze_tag(emitter,
+ event->data.mapping_start.tag))
+ return 0;
+ }
+ return 1;
+
+ default:
+ return 1;
+ }
+}
+
+/*
+ * Write the BOM character.
+ */
+
+static int
+yaml_emitter_write_bom(yaml_emitter_t *emitter)
+{
+ if (!FLUSH(emitter)) return 0;
+
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xEF';
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xBB';
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xBF';
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_indent(yaml_emitter_t *emitter)
+{
+ int indent = (emitter->indent >= 0) ? emitter->indent : 0;
+
+ if (!emitter->indention || emitter->column > indent
+ || (emitter->column == indent && !emitter->whitespace)) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+
+ while (emitter->column < indent) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ emitter->whitespace = 1;
+ emitter->indention = 1;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_indicator(yaml_emitter_t *emitter,
const char *indicator, int need_whitespace,
- int is_whitespace, int is_indention)
-{
- size_t indicator_length;
- yaml_string_t string;
-
- indicator_length = strlen(indicator);
- STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
-
- if (need_whitespace && !emitter->whitespace) {
- if (!PUT(emitter, ' ')) return 0;
- }
-
- while (string.pointer != string.end) {
- if (!WRITE(emitter, string)) return 0;
- }
-
- emitter->whitespace = is_whitespace;
- emitter->indention = (emitter->indention && is_indention);
-
- return 1;
-}
-
-static int
-yaml_emitter_write_anchor(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length)
-{
- yaml_string_t string;
- STRING_ASSIGN(string, value, length);
-
- while (string.pointer != string.end) {
- if (!WRITE(emitter, string)) return 0;
- }
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length)
-{
- yaml_string_t string;
- STRING_ASSIGN(string, value, length);
-
- if (!emitter->whitespace) {
- if (!PUT(emitter, ' ')) return 0;
- }
-
- while (string.pointer != string.end) {
- if (!WRITE(emitter, string)) return 0;
- }
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length,
- int need_whitespace)
-{
- yaml_string_t string;
- STRING_ASSIGN(string, value, length);
-
- if (need_whitespace && !emitter->whitespace) {
- if (!PUT(emitter, ' ')) return 0;
- }
-
- while (string.pointer != string.end) {
- if (IS_ALPHA(string)
- || CHECK(string, ';') || CHECK(string, '/')
- || CHECK(string, '?') || CHECK(string, ':')
- || CHECK(string, '@') || CHECK(string, '&')
- || CHECK(string, '=') || CHECK(string, '+')
- || CHECK(string, '$') || CHECK(string, ',')
- || CHECK(string, '_') || CHECK(string, '.')
- || CHECK(string, '~') || CHECK(string, '*')
- || CHECK(string, '\'') || CHECK(string, '(')
- || CHECK(string, ')') || CHECK(string, '[')
- || CHECK(string, ']')) {
- if (!WRITE(emitter, string)) return 0;
- }
- else {
- int width = WIDTH(string);
- unsigned int value;
- while (width --) {
- value = *(string.pointer++);
- if (!PUT(emitter, '%')) return 0;
- if (!PUT(emitter, (value >> 4)
- + ((value >> 4) < 10 ? '0' : 'A' - 10)))
- return 0;
- if (!PUT(emitter, (value & 0x0F)
- + ((value & 0x0F) < 10 ? '0' : 'A' - 10)))
- return 0;
- }
- }
- }
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks)
-{
- yaml_string_t string;
- int spaces = 0;
- int breaks = 0;
-
- STRING_ASSIGN(string, value, length);
-
+ int is_whitespace, int is_indention)
+{
+ size_t indicator_length;
+ yaml_string_t string;
+
+ indicator_length = strlen(indicator);
+ STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
+
+ if (need_whitespace && !emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = is_whitespace;
+ emitter->indention = (emitter->indention && is_indention);
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ if (!emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length,
+ int need_whitespace)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ if (need_whitespace && !emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (IS_ALPHA(string)
+ || CHECK(string, ';') || CHECK(string, '/')
+ || CHECK(string, '?') || CHECK(string, ':')
+ || CHECK(string, '@') || CHECK(string, '&')
+ || CHECK(string, '=') || CHECK(string, '+')
+ || CHECK(string, '$') || CHECK(string, ',')
+ || CHECK(string, '_') || CHECK(string, '.')
+ || CHECK(string, '~') || CHECK(string, '*')
+ || CHECK(string, '\'') || CHECK(string, '(')
+ || CHECK(string, ')') || CHECK(string, '[')
+ || CHECK(string, ']')) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ else {
+ int width = WIDTH(string);
+ unsigned int value;
+ while (width --) {
+ value = *(string.pointer++);
+ if (!PUT(emitter, '%')) return 0;
+ if (!PUT(emitter, (value >> 4)
+ + ((value >> 4) < 10 ? '0' : 'A' - 10)))
+ return 0;
+ if (!PUT(emitter, (value & 0x0F)
+ + ((value & 0x0F) < 10 ? '0' : 'A' - 10)))
+ return 0;
+ }
+ }
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+ int breaks = 0;
+
+ STRING_ASSIGN(string, value, length);
+
/**
* Avoid trailing spaces for empty values in block mode.
* In flow mode, we still want the space to prevent ambiguous things
@@ -1936,423 +1936,423 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
* the check for flow_level is already here.
*/
if (!emitter->whitespace && (length || emitter->flow_level)) {
- if (!PUT(emitter, ' ')) return 0;
- }
-
- while (string.pointer != string.end)
- {
- if (IS_SPACE(string))
- {
- if (allow_breaks && !spaces
- && emitter->column > emitter->best_width
- && !IS_SPACE_AT(string, 1)) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- MOVE(string);
- }
- else {
- if (!WRITE(emitter, string)) return 0;
- }
- spaces = 1;
- }
- else if (IS_BREAK(string))
- {
- if (!breaks && CHECK(string, '\n')) {
- if (!PUT_BREAK(emitter)) return 0;
- }
- if (!WRITE_BREAK(emitter, string)) return 0;
- emitter->indention = 1;
- breaks = 1;
- }
- else
- {
- if (breaks) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- }
- if (!WRITE(emitter, string)) return 0;
- emitter->indention = 0;
- spaces = 0;
- breaks = 0;
- }
- }
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks)
-{
- yaml_string_t string;
- int spaces = 0;
- int breaks = 0;
-
- STRING_ASSIGN(string, value, length);
-
- if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
- return 0;
-
- while (string.pointer != string.end)
- {
- if (IS_SPACE(string))
- {
- if (allow_breaks && !spaces
- && emitter->column > emitter->best_width
- && string.pointer != string.start
- && string.pointer != string.end - 1
- && !IS_SPACE_AT(string, 1)) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- MOVE(string);
- }
- else {
- if (!WRITE(emitter, string)) return 0;
- }
- spaces = 1;
- }
- else if (IS_BREAK(string))
- {
- if (!breaks && CHECK(string, '\n')) {
- if (!PUT_BREAK(emitter)) return 0;
- }
- if (!WRITE_BREAK(emitter, string)) return 0;
- emitter->indention = 1;
- breaks = 1;
- }
- else
- {
- if (breaks) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- }
- if (CHECK(string, '\'')) {
- if (!PUT(emitter, '\'')) return 0;
- }
- if (!WRITE(emitter, string)) return 0;
- emitter->indention = 0;
- spaces = 0;
- breaks = 0;
- }
- }
-
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end)
+ {
+ if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && !IS_SPACE_AT(string, 1)) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (!breaks && CHECK(string, '\n')) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ spaces = 0;
+ breaks = 0;
+ }
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+ int breaks = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
+ return 0;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && string.pointer != string.start
+ && string.pointer != string.end - 1
+ && !IS_SPACE_AT(string, 1)) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (!breaks && CHECK(string, '\n')) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (CHECK(string, '\'')) {
+ if (!PUT(emitter, '\'')) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ spaces = 0;
+ breaks = 0;
+ }
+ }
+
if (breaks)
if (!yaml_emitter_write_indent(emitter)) return 0;
- if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
- return 0;
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length, int allow_breaks)
-{
- yaml_string_t string;
- int spaces = 0;
-
- STRING_ASSIGN(string, value, length);
-
- if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
- return 0;
-
- while (string.pointer != string.end)
- {
- if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string))
- || IS_BOM(string) || IS_BREAK(string)
- || CHECK(string, '"') || CHECK(string, '\\'))
- {
- unsigned char octet;
- unsigned int width;
- unsigned int value;
- int k;
-
- octet = string.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 < (int)width; k ++) {
- octet = string.pointer[k];
- value = (value << 6) + (octet & 0x3F);
- }
- string.pointer += width;
-
- if (!PUT(emitter, '\\')) return 0;
-
- switch (value)
- {
- case 0x00:
- if (!PUT(emitter, '0')) return 0;
- break;
-
- case 0x07:
- if (!PUT(emitter, 'a')) return 0;
- break;
-
- case 0x08:
- if (!PUT(emitter, 'b')) return 0;
- break;
-
- case 0x09:
- if (!PUT(emitter, 't')) return 0;
- break;
-
- case 0x0A:
- if (!PUT(emitter, 'n')) return 0;
- break;
-
- case 0x0B:
- if (!PUT(emitter, 'v')) return 0;
- break;
-
- case 0x0C:
- if (!PUT(emitter, 'f')) return 0;
- break;
-
- case 0x0D:
- if (!PUT(emitter, 'r')) return 0;
- break;
-
- case 0x1B:
- if (!PUT(emitter, 'e')) return 0;
- break;
-
- case 0x22:
- if (!PUT(emitter, '\"')) return 0;
- break;
-
- case 0x5C:
- if (!PUT(emitter, '\\')) return 0;
- break;
-
- case 0x85:
- if (!PUT(emitter, 'N')) return 0;
- break;
-
- case 0xA0:
- if (!PUT(emitter, '_')) return 0;
- break;
-
- case 0x2028:
- if (!PUT(emitter, 'L')) return 0;
- break;
-
- case 0x2029:
- if (!PUT(emitter, 'P')) return 0;
- break;
-
- default:
- if (value <= 0xFF) {
- if (!PUT(emitter, 'x')) return 0;
- width = 2;
- }
- else if (value <= 0xFFFF) {
- if (!PUT(emitter, 'u')) return 0;
- width = 4;
- }
- else {
- if (!PUT(emitter, 'U')) return 0;
- width = 8;
- }
- for (k = (width-1)*4; k >= 0; k -= 4) {
- int digit = (value >> k) & 0x0F;
- if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10)))
- return 0;
- }
- }
- spaces = 0;
- }
- else if (IS_SPACE(string))
- {
- if (allow_breaks && !spaces
- && emitter->column > emitter->best_width
- && string.pointer != string.start
- && string.pointer != string.end - 1) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- if (IS_SPACE_AT(string, 1)) {
- if (!PUT(emitter, '\\')) return 0;
- }
- MOVE(string);
- }
- else {
- if (!WRITE(emitter, string)) return 0;
- }
- spaces = 1;
- }
- else
- {
- if (!WRITE(emitter, string)) return 0;
- spaces = 0;
- }
- }
-
- if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0))
- return 0;
-
- emitter->whitespace = 0;
- emitter->indention = 0;
-
- return 1;
-}
-
-static int
-yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
- yaml_string_t string)
-{
- char indent_hint[2];
+ if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
+ return 0;
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
+ return 0;
+
+ while (string.pointer != string.end)
+ {
+ if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string))
+ || IS_BOM(string) || IS_BREAK(string)
+ || CHECK(string, '"') || CHECK(string, '\\'))
+ {
+ unsigned char octet;
+ unsigned int width;
+ unsigned int value;
+ int k;
+
+ octet = string.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 < (int)width; k ++) {
+ octet = string.pointer[k];
+ value = (value << 6) + (octet & 0x3F);
+ }
+ string.pointer += width;
+
+ if (!PUT(emitter, '\\')) return 0;
+
+ switch (value)
+ {
+ case 0x00:
+ if (!PUT(emitter, '0')) return 0;
+ break;
+
+ case 0x07:
+ if (!PUT(emitter, 'a')) return 0;
+ break;
+
+ case 0x08:
+ if (!PUT(emitter, 'b')) return 0;
+ break;
+
+ case 0x09:
+ if (!PUT(emitter, 't')) return 0;
+ break;
+
+ case 0x0A:
+ if (!PUT(emitter, 'n')) return 0;
+ break;
+
+ case 0x0B:
+ if (!PUT(emitter, 'v')) return 0;
+ break;
+
+ case 0x0C:
+ if (!PUT(emitter, 'f')) return 0;
+ break;
+
+ case 0x0D:
+ if (!PUT(emitter, 'r')) return 0;
+ break;
+
+ case 0x1B:
+ if (!PUT(emitter, 'e')) return 0;
+ break;
+
+ case 0x22:
+ if (!PUT(emitter, '\"')) return 0;
+ break;
+
+ case 0x5C:
+ if (!PUT(emitter, '\\')) return 0;
+ break;
+
+ case 0x85:
+ if (!PUT(emitter, 'N')) return 0;
+ break;
+
+ case 0xA0:
+ if (!PUT(emitter, '_')) return 0;
+ break;
+
+ case 0x2028:
+ if (!PUT(emitter, 'L')) return 0;
+ break;
+
+ case 0x2029:
+ if (!PUT(emitter, 'P')) return 0;
+ break;
+
+ default:
+ if (value <= 0xFF) {
+ if (!PUT(emitter, 'x')) return 0;
+ width = 2;
+ }
+ else if (value <= 0xFFFF) {
+ if (!PUT(emitter, 'u')) return 0;
+ width = 4;
+ }
+ else {
+ if (!PUT(emitter, 'U')) return 0;
+ width = 8;
+ }
+ for (k = (width-1)*4; k >= 0; k -= 4) {
+ int digit = (value >> k) & 0x0F;
+ if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10)))
+ return 0;
+ }
+ }
+ spaces = 0;
+ }
+ else if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && string.pointer != string.start
+ && string.pointer != string.end - 1) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ if (IS_SPACE_AT(string, 1)) {
+ if (!PUT(emitter, '\\')) return 0;
+ }
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else
+ {
+ if (!WRITE(emitter, string)) return 0;
+ spaces = 0;
+ }
+ }
+
+ if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0))
+ return 0;
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
+ yaml_string_t string)
+{
+ char indent_hint[2];
const char *chomp_hint = NULL;
-
- if (IS_SPACE(string) || IS_BREAK(string))
- {
- indent_hint[0] = '0' + (char)emitter->best_indent;
- indent_hint[1] = '\0';
- if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0))
- return 0;
- }
-
- emitter->open_ended = 0;
-
- string.pointer = string.end;
- if (string.start == string.pointer)
- {
- chomp_hint = "-";
- }
- else
- {
- do {
- string.pointer --;
- } while ((*string.pointer & 0xC0) == 0x80);
- if (!IS_BREAK(string))
- {
- chomp_hint = "-";
- }
- else if (string.start == string.pointer)
- {
- chomp_hint = "+";
+
+ if (IS_SPACE(string) || IS_BREAK(string))
+ {
+ indent_hint[0] = '0' + (char)emitter->best_indent;
+ indent_hint[1] = '\0';
+ if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0))
+ return 0;
+ }
+
+ emitter->open_ended = 0;
+
+ string.pointer = string.end;
+ if (string.start == string.pointer)
+ {
+ chomp_hint = "-";
+ }
+ else
+ {
+ do {
+ string.pointer --;
+ } while ((*string.pointer & 0xC0) == 0x80);
+ if (!IS_BREAK(string))
+ {
+ chomp_hint = "-";
+ }
+ else if (string.start == string.pointer)
+ {
+ chomp_hint = "+";
emitter->open_ended = 2;
- }
- else
- {
- do {
- string.pointer --;
- } while ((*string.pointer & 0xC0) == 0x80);
- if (IS_BREAK(string))
- {
- chomp_hint = "+";
+ }
+ else
+ {
+ do {
+ string.pointer --;
+ } while ((*string.pointer & 0xC0) == 0x80);
+ if (IS_BREAK(string))
+ {
+ chomp_hint = "+";
emitter->open_ended = 2;
- }
- }
- }
-
- if (chomp_hint)
- {
- if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0))
- return 0;
- }
-
- return 1;
-}
-
-static int
-yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length)
-{
- yaml_string_t string;
- int breaks = 1;
-
- STRING_ASSIGN(string, value, length);
-
- if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
- return 0;
- if (!yaml_emitter_write_block_scalar_hints(emitter, string))
- return 0;
- if (!PUT_BREAK(emitter)) return 0;
- emitter->indention = 1;
- emitter->whitespace = 1;
-
- while (string.pointer != string.end)
- {
- if (IS_BREAK(string))
- {
- if (!WRITE_BREAK(emitter, string)) return 0;
- emitter->indention = 1;
- breaks = 1;
- }
- else
- {
- if (breaks) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- }
- if (!WRITE(emitter, string)) return 0;
- emitter->indention = 0;
- breaks = 0;
- }
- }
-
- return 1;
-}
-
-static int
-yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
- yaml_char_t *value, size_t length)
-{
- yaml_string_t string;
- int breaks = 1;
- int leading_spaces = 1;
-
- STRING_ASSIGN(string, value, length);
-
- if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
- return 0;
- if (!yaml_emitter_write_block_scalar_hints(emitter, string))
- return 0;
- if (!PUT_BREAK(emitter)) return 0;
- emitter->indention = 1;
- emitter->whitespace = 1;
-
- while (string.pointer != string.end)
- {
- if (IS_BREAK(string))
- {
- if (!breaks && !leading_spaces && CHECK(string, '\n')) {
- int k = 0;
- while (IS_BREAK_AT(string, k)) {
- k += WIDTH_AT(string, k);
- }
- if (!IS_BLANKZ_AT(string, k)) {
- if (!PUT_BREAK(emitter)) return 0;
- }
- }
- if (!WRITE_BREAK(emitter, string)) return 0;
- emitter->indention = 1;
- breaks = 1;
- }
- else
- {
- if (breaks) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- leading_spaces = IS_BLANK(string);
- }
- if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1)
- && emitter->column > emitter->best_width) {
- if (!yaml_emitter_write_indent(emitter)) return 0;
- MOVE(string);
- }
- else {
- if (!WRITE(emitter, string)) return 0;
- }
- emitter->indention = 0;
- breaks = 0;
- }
- }
-
- return 1;
-}
+ }
+ }
+ }
+
+ if (chomp_hint)
+ {
+ if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0))
+ return 0;
+ }
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ int breaks = 1;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
+ return 0;
+ if (!PUT_BREAK(emitter)) return 0;
+ emitter->indention = 1;
+ emitter->whitespace = 1;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_BREAK(string))
+ {
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ breaks = 0;
+ }
+ }
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ int breaks = 1;
+ int leading_spaces = 1;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
+ return 0;
+ if (!PUT_BREAK(emitter)) return 0;
+ emitter->indention = 1;
+ emitter->whitespace = 1;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_BREAK(string))
+ {
+ if (!breaks && !leading_spaces && CHECK(string, '\n')) {
+ int k = 0;
+ while (IS_BREAK_AT(string, k)) {
+ k += WIDTH_AT(string, k);
+ }
+ if (!IS_BLANKZ_AT(string, k)) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ leading_spaces = IS_BLANK(string);
+ }
+ if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1)
+ && emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ emitter->indention = 0;
+ breaks = 0;
+ }
+ }
+
+ return 1;
+}
diff --git a/contrib/libs/yaml/src/loader.c b/contrib/libs/yaml/src/loader.c
index e77b07b43f..dea8ac428c 100644
--- a/contrib/libs/yaml/src/loader.c
+++ b/contrib/libs/yaml/src/loader.c
@@ -1,43 +1,43 @@
-
-#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);
-
-/*
+
+#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 {
@@ -47,177 +47,177 @@ struct loader_ctx {
};
/*
- * Composer functions.
- */
+ * Composer functions.
+ */
static int
yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx);
-
-static int
+
+static int
yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *event);
-
-static int
+
+static int
yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
-
-static int
+
+static int
yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
-
-static int
+
+static int
yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
-
-static int
+
+static int
yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx);
-
-static int
+
+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));
+/*
+ * 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;
- }
-
+ 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
+ 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
+ /* DOCUMENT-START is expected. */
+
+ parser->document->version_directive
= event->data.document_start.version_directive;
- parser->document->tag_directives.start
+ parser->document->tag_directives.start
= event->data.document_start.tag_directives.start;
- parser->document->tag_directives.end
+ parser->document->tag_directives.end
= event->data.document_start.tag_directives.end;
- parser->document->start_implicit
+ 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;
-}
-
-/*
+
+ return 1;
+}
+
+/*
* Compose a node tree.
- */
-
-static int
+ */
+
+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;
@@ -254,44 +254,44 @@ yaml_parser_load_nodes(yaml_parser_t *parser, struct loader_ctx *ctx)
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,
+}
+
+/*
+ * 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;
-}
-
-/*
+ }
+ }
+
+ if (!PUSH(parser, parser->aliases, data)) {
+ yaml_free(anchor);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
* Compose node into its parent in the stree.
*/
@@ -344,120 +344,120 @@ yaml_parser_load_node_add(yaml_parser_t *parser, struct loader_ctx *ctx,
}
/*
- * Compose a node corresponding to an alias.
- */
-
-static int
+ * 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);
+ 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",
+ }
+ }
+
+ yaml_free(anchor);
+ return yaml_parser_set_composer_error(parser, "found undefined alias",
event->start_mark);
-}
-
-/*
- * Compose a scalar node.
- */
-
-static int
+}
+
+/*
+ * 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_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;
- }
-
+
+ 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,
+
+ 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);
+
+error:
+ yaml_free(tag);
yaml_free(event->data.scalar.anchor);
yaml_free(event->data.scalar.value);
- return 0;
-}
-
-/*
- * Compose a sequence node.
- */
-
-static int
+ 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 };
+{
+ 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_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,
+
+ 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,
+
+ 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);
+
+error:
+ yaml_free(tag);
yaml_free(event->data.sequence_start.anchor);
- return 0;
-}
-
+ return 0;
+}
+
static int
yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx)
@@ -475,57 +475,57 @@ yaml_parser_load_sequence_end(yaml_parser_t *parser, yaml_event_t *event,
return 1;
}
-/*
- * Compose a mapping node.
- */
-
-static int
+/*
+ * 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_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_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,
+
+ 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,
+
+ 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);
+
+error:
+ yaml_free(tag);
yaml_free(event->data.mapping_start.anchor);
- return 0;
-}
-
+ return 0;
+}
+
static int
yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event,
struct loader_ctx *ctx)
diff --git a/contrib/libs/yaml/src/parser.c b/contrib/libs/yaml/src/parser.c
index 320ed703b4..ec2f8d3e05 100644
--- a/contrib/libs/yaml/src/parser.c
+++ b/contrib/libs/yaml/src/parser.c
@@ -1,1375 +1,1375 @@
-
-/*
- * The parser implements the following grammar:
- *
- * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
- * implicit_document ::= block_node DOCUMENT-END*
- * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
- * block_node_or_indentless_sequence ::=
- * ALIAS
- * | properties (block_content | indentless_block_sequence)?
- * | block_content
- * | indentless_block_sequence
- * block_node ::= ALIAS
- * | properties block_content?
- * | block_content
- * flow_node ::= ALIAS
- * | properties flow_content?
- * | flow_content
- * properties ::= TAG ANCHOR? | ANCHOR TAG?
- * block_content ::= block_collection | flow_collection | SCALAR
- * flow_content ::= flow_collection | SCALAR
- * block_collection ::= block_sequence | block_mapping
- * flow_collection ::= flow_sequence | flow_mapping
- * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
- * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
- * block_mapping ::= BLOCK-MAPPING_START
- * ((KEY block_node_or_indentless_sequence?)?
- * (VALUE block_node_or_indentless_sequence?)?)*
- * BLOCK-END
- * flow_sequence ::= FLOW-SEQUENCE-START
- * (flow_sequence_entry FLOW-ENTRY)*
- * flow_sequence_entry?
- * FLOW-SEQUENCE-END
- * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * flow_mapping ::= FLOW-MAPPING-START
- * (flow_mapping_entry FLOW-ENTRY)*
- * flow_mapping_entry?
- * FLOW-MAPPING-END
- * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- */
-
-#include "yaml_private.h"
-
-/*
- * Peek the next token in the token queue.
- */
-
-#define PEEK_TOKEN(parser) \
- ((parser->token_available || yaml_parser_fetch_more_tokens(parser)) ? \
- parser->tokens.head : NULL)
-
-/*
- * Remove the next token from the queue (must be called after PEEK_TOKEN).
- */
-
-#define SKIP_TOKEN(parser) \
- (parser->token_available = 0, \
- parser->tokens_parsed ++, \
- parser->stream_end_produced = \
- (parser->tokens.head->type == YAML_STREAM_END_TOKEN), \
- parser->tokens.head ++)
-
-/*
- * Public API declarations.
- */
-
-YAML_DECLARE(int)
-yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
-
-/*
- * Error handling.
- */
-
-static int
-yaml_parser_set_parser_error(yaml_parser_t *parser,
- const char *problem, yaml_mark_t problem_mark);
-
-static int
-yaml_parser_set_parser_error_context(yaml_parser_t *parser,
- const char *context, yaml_mark_t context_mark,
- const char *problem, yaml_mark_t problem_mark);
-
-/*
- * State functions.
- */
-
-static int
-yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event);
-
-static int
-yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event);
-
-static int
-yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
- int implicit);
-
-static int
-yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event);
-
-static int
-yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event);
-
-static int
-yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
- int block, int indentless_sequence);
-
-static int
-yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event, int first);
-
-static int
-yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event);
-
-static int
-yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event, int first);
-
-static int
-yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event);
-
-static int
-yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event, int first);
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event);
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event);
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
- yaml_event_t *event);
-
-static int
-yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event, int first);
-
-static int
-yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event, int empty);
-
-/*
- * Utility functions.
- */
-
-static int
-yaml_parser_process_empty_scalar(yaml_parser_t *parser,
- yaml_event_t *event, yaml_mark_t mark);
-
-static int
-yaml_parser_process_directives(yaml_parser_t *parser,
- yaml_version_directive_t **version_directive_ref,
- yaml_tag_directive_t **tag_directives_start_ref,
- yaml_tag_directive_t **tag_directives_end_ref);
-
-static int
-yaml_parser_append_tag_directive(yaml_parser_t *parser,
- yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark);
-
-/*
- * Get the next event.
- */
-
-YAML_DECLARE(int)
-yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
-{
- assert(parser); /* Non-NULL parser object is expected. */
- assert(event); /* Non-NULL event object is expected. */
-
- /* Erase the event object. */
-
- memset(event, 0, sizeof(yaml_event_t));
-
- /* No events after the end of the stream or error. */
-
- if (parser->stream_end_produced || parser->error ||
- parser->state == YAML_PARSE_END_STATE) {
- return 1;
- }
-
- /* Generate the next event. */
-
- return yaml_parser_state_machine(parser, event);
-}
-
-/*
- * Set parser error.
- */
-
-static int
-yaml_parser_set_parser_error(yaml_parser_t *parser,
- const char *problem, yaml_mark_t problem_mark)
-{
- parser->error = YAML_PARSER_ERROR;
- parser->problem = problem;
- parser->problem_mark = problem_mark;
-
- return 0;
-}
-
-static int
-yaml_parser_set_parser_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_PARSER_ERROR;
- parser->context = context;
- parser->context_mark = context_mark;
- parser->problem = problem;
- parser->problem_mark = problem_mark;
-
- return 0;
-}
-
-
-/*
- * State dispatcher.
- */
-
-static int
-yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event)
-{
- switch (parser->state)
- {
- case YAML_PARSE_STREAM_START_STATE:
- return yaml_parser_parse_stream_start(parser, event);
-
- case YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, 1);
-
- case YAML_PARSE_DOCUMENT_START_STATE:
- return yaml_parser_parse_document_start(parser, event, 0);
-
- case YAML_PARSE_DOCUMENT_CONTENT_STATE:
- return yaml_parser_parse_document_content(parser, event);
-
- case YAML_PARSE_DOCUMENT_END_STATE:
- return yaml_parser_parse_document_end(parser, event);
-
- case YAML_PARSE_BLOCK_NODE_STATE:
- return yaml_parser_parse_node(parser, event, 1, 0);
-
- case YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
- return yaml_parser_parse_node(parser, event, 1, 1);
-
- case YAML_PARSE_FLOW_NODE_STATE:
- return yaml_parser_parse_node(parser, event, 0, 0);
-
- case YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, 1);
-
- case YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_block_sequence_entry(parser, event, 0);
-
- case YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_indentless_sequence_entry(parser, event);
-
- case YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, 1);
-
- case YAML_PARSE_BLOCK_MAPPING_KEY_STATE:
- return yaml_parser_parse_block_mapping_key(parser, event, 0);
-
- case YAML_PARSE_BLOCK_MAPPING_VALUE_STATE:
- return yaml_parser_parse_block_mapping_value(parser, event);
-
- case YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, 1);
-
- case YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
- return yaml_parser_parse_flow_sequence_entry(parser, event, 0);
-
- case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event);
-
- case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event);
-
- case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
- return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event);
-
- case YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, 1);
-
- case YAML_PARSE_FLOW_MAPPING_KEY_STATE:
- return yaml_parser_parse_flow_mapping_key(parser, event, 0);
-
- case YAML_PARSE_FLOW_MAPPING_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, 0);
-
- case YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
- return yaml_parser_parse_flow_mapping_value(parser, event, 1);
-
- default:
- assert(1); /* Invalid state. */
- }
-
- return 0;
-}
-
-/*
- * Parse the production:
- * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
- * ************
- */
-
-static int
-yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type != YAML_STREAM_START_TOKEN) {
- return yaml_parser_set_parser_error(parser,
- "did not find expected <stream-start>", token->start_mark);
- }
-
- parser->state = YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE;
- STREAM_START_EVENT_INIT(*event, token->data.stream_start.encoding,
- token->start_mark, token->start_mark);
- SKIP_TOKEN(parser);
-
- return 1;
-}
-
-/*
- * Parse the productions:
- * implicit_document ::= block_node DOCUMENT-END*
- * *
- * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
- * *************************
- */
-
-static int
-yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
- int implicit)
-{
- yaml_token_t *token;
- yaml_version_directive_t *version_directive = NULL;
- struct {
- yaml_tag_directive_t *start;
- yaml_tag_directive_t *end;
- } tag_directives = { NULL, NULL };
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- /* Parse extra document end indicators. */
-
- if (!implicit)
- {
- while (token->type == YAML_DOCUMENT_END_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- }
- }
-
- /* Parse an implicit document. */
-
- if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
- token->type != YAML_TAG_DIRECTIVE_TOKEN &&
- token->type != YAML_DOCUMENT_START_TOKEN &&
- token->type != YAML_STREAM_END_TOKEN)
- {
- if (!yaml_parser_process_directives(parser, NULL, NULL, NULL))
- return 0;
- if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
- return 0;
- parser->state = YAML_PARSE_BLOCK_NODE_STATE;
- DOCUMENT_START_EVENT_INIT(*event, NULL, NULL, NULL, 1,
- token->start_mark, token->start_mark);
- return 1;
- }
-
- /* Parse an explicit document. */
-
- else if (token->type != YAML_STREAM_END_TOKEN)
- {
- yaml_mark_t start_mark, end_mark;
- start_mark = token->start_mark;
- if (!yaml_parser_process_directives(parser, &version_directive,
- &tag_directives.start, &tag_directives.end))
- return 0;
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- if (token->type != YAML_DOCUMENT_START_TOKEN) {
- yaml_parser_set_parser_error(parser,
- "did not find expected <document start>", token->start_mark);
- goto error;
- }
- if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
- goto error;
- parser->state = YAML_PARSE_DOCUMENT_CONTENT_STATE;
- end_mark = token->end_mark;
- DOCUMENT_START_EVENT_INIT(*event, version_directive,
- tag_directives.start, tag_directives.end, 0,
- start_mark, end_mark);
- SKIP_TOKEN(parser);
- version_directive = NULL;
- tag_directives.start = tag_directives.end = NULL;
- return 1;
- }
-
- /* Parse the stream end. */
-
- else
- {
- parser->state = YAML_PARSE_END_STATE;
- STREAM_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
-
-error:
- yaml_free(version_directive);
- while (tag_directives.start != tag_directives.end) {
- yaml_free(tag_directives.end[-1].handle);
- yaml_free(tag_directives.end[-1].prefix);
- tag_directives.end --;
- }
- yaml_free(tag_directives.start);
- return 0;
-}
-
-/*
- * Parse the productions:
- * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
- * ***********
- */
-
-static int
-yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
- token->type == YAML_TAG_DIRECTIVE_TOKEN ||
- token->type == YAML_DOCUMENT_START_TOKEN ||
- token->type == YAML_DOCUMENT_END_TOKEN ||
- token->type == YAML_STREAM_END_TOKEN) {
- parser->state = POP(parser, parser->states);
- return yaml_parser_process_empty_scalar(parser, event,
- token->start_mark);
- }
- else {
- return yaml_parser_parse_node(parser, event, 1, 0);
- }
-}
-
-/*
- * Parse the productions:
- * implicit_document ::= block_node DOCUMENT-END*
- * *************
- * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
- * *************
- */
-
-static int
-yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event)
-{
- yaml_token_t *token;
- yaml_mark_t start_mark, end_mark;
- int implicit = 1;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- start_mark = end_mark = token->start_mark;
-
- if (token->type == YAML_DOCUMENT_END_TOKEN) {
- end_mark = token->end_mark;
- SKIP_TOKEN(parser);
- implicit = 0;
- }
-
- while (!STACK_EMPTY(parser, parser->tag_directives)) {
- yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
- yaml_free(tag_directive.handle);
- yaml_free(tag_directive.prefix);
- }
-
- parser->state = YAML_PARSE_DOCUMENT_START_STATE;
- DOCUMENT_END_EVENT_INIT(*event, implicit, start_mark, end_mark);
-
- return 1;
-}
-
-/*
- * Parse the productions:
- * block_node_or_indentless_sequence ::=
- * ALIAS
- * *****
- * | properties (block_content | indentless_block_sequence)?
- * ********** *
- * | block_content | indentless_block_sequence
- * *
- * block_node ::= ALIAS
- * *****
- * | properties block_content?
- * ********** *
- * | block_content
- * *
- * flow_node ::= ALIAS
- * *****
- * | properties flow_content?
- * ********** *
- * | flow_content
- * *
- * properties ::= TAG ANCHOR? | ANCHOR TAG?
- * *************************
- * block_content ::= block_collection | flow_collection | SCALAR
- * ******
- * flow_content ::= flow_collection | SCALAR
- * ******
- */
-
-static int
-yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
- int block, int indentless_sequence)
-{
- yaml_token_t *token;
- yaml_char_t *anchor = NULL;
- yaml_char_t *tag_handle = NULL;
- yaml_char_t *tag_suffix = NULL;
- yaml_char_t *tag = NULL;
- yaml_mark_t start_mark, end_mark, tag_mark;
- int implicit;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_ALIAS_TOKEN)
- {
- parser->state = POP(parser, parser->states);
- ALIAS_EVENT_INIT(*event, token->data.alias.value,
- token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
-
- else
- {
- start_mark = end_mark = token->start_mark;
-
- if (token->type == YAML_ANCHOR_TOKEN)
- {
- anchor = token->data.anchor.value;
- start_mark = token->start_mark;
- end_mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- if (token->type == YAML_TAG_TOKEN)
- {
- tag_handle = token->data.tag.handle;
- tag_suffix = token->data.tag.suffix;
- tag_mark = token->start_mark;
- end_mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- }
- }
- else if (token->type == YAML_TAG_TOKEN)
- {
- tag_handle = token->data.tag.handle;
- tag_suffix = token->data.tag.suffix;
- start_mark = tag_mark = token->start_mark;
- end_mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- if (token->type == YAML_ANCHOR_TOKEN)
- {
- anchor = token->data.anchor.value;
- end_mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- }
- }
-
- if (tag_handle) {
- if (!*tag_handle) {
- tag = tag_suffix;
- yaml_free(tag_handle);
- tag_handle = tag_suffix = NULL;
- }
- else {
- yaml_tag_directive_t *tag_directive;
- for (tag_directive = parser->tag_directives.start;
- tag_directive != parser->tag_directives.top;
- tag_directive ++) {
- if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
- size_t prefix_len = strlen((char *)tag_directive->prefix);
- size_t suffix_len = strlen((char *)tag_suffix);
+
+/*
+ * The parser implements the following grammar:
+ *
+ * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
+ * implicit_document ::= block_node DOCUMENT-END*
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * block_node_or_indentless_sequence ::=
+ * ALIAS
+ * | properties (block_content | indentless_block_sequence)?
+ * | block_content
+ * | indentless_block_sequence
+ * block_node ::= ALIAS
+ * | properties block_content?
+ * | block_content
+ * flow_node ::= ALIAS
+ * | properties flow_content?
+ * | flow_content
+ * properties ::= TAG ANCHOR? | ANCHOR TAG?
+ * block_content ::= block_collection | flow_collection | SCALAR
+ * flow_content ::= flow_collection | SCALAR
+ * block_collection ::= block_sequence | block_mapping
+ * flow_collection ::= flow_sequence | flow_mapping
+ * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+ * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
+ * block_mapping ::= BLOCK-MAPPING_START
+ * ((KEY block_node_or_indentless_sequence?)?
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ * BLOCK-END
+ * flow_sequence ::= FLOW-SEQUENCE-START
+ * (flow_sequence_entry FLOW-ENTRY)*
+ * flow_sequence_entry?
+ * FLOW-SEQUENCE-END
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * flow_mapping ::= FLOW-MAPPING-START
+ * (flow_mapping_entry FLOW-ENTRY)*
+ * flow_mapping_entry?
+ * FLOW-MAPPING-END
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ */
+
+#include "yaml_private.h"
+
+/*
+ * Peek the next token in the token queue.
+ */
+
+#define PEEK_TOKEN(parser) \
+ ((parser->token_available || yaml_parser_fetch_more_tokens(parser)) ? \
+ parser->tokens.head : NULL)
+
+/*
+ * Remove the next token from the queue (must be called after PEEK_TOKEN).
+ */
+
+#define SKIP_TOKEN(parser) \
+ (parser->token_available = 0, \
+ parser->tokens_parsed ++, \
+ parser->stream_end_produced = \
+ (parser->tokens.head->type == YAML_STREAM_END_TOKEN), \
+ parser->tokens.head ++)
+
+/*
+ * Public API declarations.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
+
+/*
+ * Error handling.
+ */
+
+static int
+yaml_parser_set_parser_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark);
+
+static int
+yaml_parser_set_parser_error_context(yaml_parser_t *parser,
+ const char *context, yaml_mark_t context_mark,
+ const char *problem, yaml_mark_t problem_mark);
+
+/*
+ * State functions.
+ */
+
+static int
+yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
+ int implicit);
+
+static int
+yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
+ int block, int indentless_sequence);
+
+static int
+yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event, int empty);
+
+/*
+ * Utility functions.
+ */
+
+static int
+yaml_parser_process_empty_scalar(yaml_parser_t *parser,
+ yaml_event_t *event, yaml_mark_t mark);
+
+static int
+yaml_parser_process_directives(yaml_parser_t *parser,
+ yaml_version_directive_t **version_directive_ref,
+ yaml_tag_directive_t **tag_directives_start_ref,
+ yaml_tag_directive_t **tag_directives_end_ref);
+
+static int
+yaml_parser_append_tag_directive(yaml_parser_t *parser,
+ yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark);
+
+/*
+ * Get the next event.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
+{
+ assert(parser); /* Non-NULL parser object is expected. */
+ assert(event); /* Non-NULL event object is expected. */
+
+ /* Erase the event object. */
+
+ memset(event, 0, sizeof(yaml_event_t));
+
+ /* No events after the end of the stream or error. */
+
+ if (parser->stream_end_produced || parser->error ||
+ parser->state == YAML_PARSE_END_STATE) {
+ return 1;
+ }
+
+ /* Generate the next event. */
+
+ return yaml_parser_state_machine(parser, event);
+}
+
+/*
+ * Set parser error.
+ */
+
+static int
+yaml_parser_set_parser_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark)
+{
+ parser->error = YAML_PARSER_ERROR;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+static int
+yaml_parser_set_parser_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_PARSER_ERROR;
+ parser->context = context;
+ parser->context_mark = context_mark;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+
+/*
+ * State dispatcher.
+ */
+
+static int
+yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event)
+{
+ switch (parser->state)
+ {
+ case YAML_PARSE_STREAM_START_STATE:
+ return yaml_parser_parse_stream_start(parser, event);
+
+ case YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE:
+ return yaml_parser_parse_document_start(parser, event, 1);
+
+ case YAML_PARSE_DOCUMENT_START_STATE:
+ return yaml_parser_parse_document_start(parser, event, 0);
+
+ case YAML_PARSE_DOCUMENT_CONTENT_STATE:
+ return yaml_parser_parse_document_content(parser, event);
+
+ case YAML_PARSE_DOCUMENT_END_STATE:
+ return yaml_parser_parse_document_end(parser, event);
+
+ case YAML_PARSE_BLOCK_NODE_STATE:
+ return yaml_parser_parse_node(parser, event, 1, 0);
+
+ case YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
+ return yaml_parser_parse_node(parser, event, 1, 1);
+
+ case YAML_PARSE_FLOW_NODE_STATE:
+ return yaml_parser_parse_node(parser, event, 0, 0);
+
+ case YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
+ return yaml_parser_parse_block_sequence_entry(parser, event, 1);
+
+ case YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_block_sequence_entry(parser, event, 0);
+
+ case YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_indentless_sequence_entry(parser, event);
+
+ case YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
+ return yaml_parser_parse_block_mapping_key(parser, event, 1);
+
+ case YAML_PARSE_BLOCK_MAPPING_KEY_STATE:
+ return yaml_parser_parse_block_mapping_key(parser, event, 0);
+
+ case YAML_PARSE_BLOCK_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_block_mapping_value(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
+ return yaml_parser_parse_flow_sequence_entry(parser, event, 1);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_flow_sequence_entry(parser, event, 0);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event);
+
+ case YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
+ return yaml_parser_parse_flow_mapping_key(parser, event, 1);
+
+ case YAML_PARSE_FLOW_MAPPING_KEY_STATE:
+ return yaml_parser_parse_flow_mapping_key(parser, event, 0);
+
+ case YAML_PARSE_FLOW_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_flow_mapping_value(parser, event, 0);
+
+ case YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
+ return yaml_parser_parse_flow_mapping_value(parser, event, 1);
+
+ default:
+ assert(1); /* Invalid state. */
+ }
+
+ return 0;
+}
+
+/*
+ * Parse the production:
+ * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
+ * ************
+ */
+
+static int
+yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_STREAM_START_TOKEN) {
+ return yaml_parser_set_parser_error(parser,
+ "did not find expected <stream-start>", token->start_mark);
+ }
+
+ parser->state = YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE;
+ STREAM_START_EVENT_INIT(*event, token->data.stream_start.encoding,
+ token->start_mark, token->start_mark);
+ SKIP_TOKEN(parser);
+
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * implicit_document ::= block_node DOCUMENT-END*
+ * *
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * *************************
+ */
+
+static int
+yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
+ int implicit)
+{
+ yaml_token_t *token;
+ yaml_version_directive_t *version_directive = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ } tag_directives = { NULL, NULL };
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ /* Parse extra document end indicators. */
+
+ if (!implicit)
+ {
+ while (token->type == YAML_DOCUMENT_END_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ }
+
+ /* Parse an implicit document. */
+
+ if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
+ token->type != YAML_TAG_DIRECTIVE_TOKEN &&
+ token->type != YAML_DOCUMENT_START_TOKEN &&
+ token->type != YAML_STREAM_END_TOKEN)
+ {
+ if (!yaml_parser_process_directives(parser, NULL, NULL, NULL))
+ return 0;
+ if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
+ return 0;
+ parser->state = YAML_PARSE_BLOCK_NODE_STATE;
+ DOCUMENT_START_EVENT_INIT(*event, NULL, NULL, NULL, 1,
+ token->start_mark, token->start_mark);
+ return 1;
+ }
+
+ /* Parse an explicit document. */
+
+ else if (token->type != YAML_STREAM_END_TOKEN)
+ {
+ yaml_mark_t start_mark, end_mark;
+ start_mark = token->start_mark;
+ if (!yaml_parser_process_directives(parser, &version_directive,
+ &tag_directives.start, &tag_directives.end))
+ return 0;
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type != YAML_DOCUMENT_START_TOKEN) {
+ yaml_parser_set_parser_error(parser,
+ "did not find expected <document start>", token->start_mark);
+ goto error;
+ }
+ if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
+ goto error;
+ parser->state = YAML_PARSE_DOCUMENT_CONTENT_STATE;
+ end_mark = token->end_mark;
+ DOCUMENT_START_EVENT_INIT(*event, version_directive,
+ tag_directives.start, tag_directives.end, 0,
+ start_mark, end_mark);
+ SKIP_TOKEN(parser);
+ version_directive = NULL;
+ tag_directives.start = tag_directives.end = NULL;
+ return 1;
+ }
+
+ /* Parse the stream end. */
+
+ else
+ {
+ parser->state = YAML_PARSE_END_STATE;
+ STREAM_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+error:
+ yaml_free(version_directive);
+ while (tag_directives.start != tag_directives.end) {
+ yaml_free(tag_directives.end[-1].handle);
+ yaml_free(tag_directives.end[-1].prefix);
+ tag_directives.end --;
+ }
+ yaml_free(tag_directives.start);
+ return 0;
+}
+
+/*
+ * Parse the productions:
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * ***********
+ */
+
+static int
+yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
+ token->type == YAML_TAG_DIRECTIVE_TOKEN ||
+ token->type == YAML_DOCUMENT_START_TOKEN ||
+ token->type == YAML_DOCUMENT_END_TOKEN ||
+ token->type == YAML_STREAM_END_TOKEN) {
+ parser->state = POP(parser, parser->states);
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+ else {
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+}
+
+/*
+ * Parse the productions:
+ * implicit_document ::= block_node DOCUMENT-END*
+ * *************
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * *************
+ */
+
+static int
+yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+ yaml_mark_t start_mark, end_mark;
+ int implicit = 1;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ start_mark = end_mark = token->start_mark;
+
+ if (token->type == YAML_DOCUMENT_END_TOKEN) {
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ implicit = 0;
+ }
+
+ while (!STACK_EMPTY(parser, parser->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+
+ parser->state = YAML_PARSE_DOCUMENT_START_STATE;
+ DOCUMENT_END_EVENT_INIT(*event, implicit, start_mark, end_mark);
+
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * block_node_or_indentless_sequence ::=
+ * ALIAS
+ * *****
+ * | properties (block_content | indentless_block_sequence)?
+ * ********** *
+ * | block_content | indentless_block_sequence
+ * *
+ * block_node ::= ALIAS
+ * *****
+ * | properties block_content?
+ * ********** *
+ * | block_content
+ * *
+ * flow_node ::= ALIAS
+ * *****
+ * | properties flow_content?
+ * ********** *
+ * | flow_content
+ * *
+ * properties ::= TAG ANCHOR? | ANCHOR TAG?
+ * *************************
+ * block_content ::= block_collection | flow_collection | SCALAR
+ * ******
+ * flow_content ::= flow_collection | SCALAR
+ * ******
+ */
+
+static int
+yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
+ int block, int indentless_sequence)
+{
+ yaml_token_t *token;
+ yaml_char_t *anchor = NULL;
+ yaml_char_t *tag_handle = NULL;
+ yaml_char_t *tag_suffix = NULL;
+ yaml_char_t *tag = NULL;
+ yaml_mark_t start_mark, end_mark, tag_mark;
+ int implicit;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_ALIAS_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
+ ALIAS_EVENT_INIT(*event, token->data.alias.value,
+ token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ start_mark = end_mark = token->start_mark;
+
+ if (token->type == YAML_ANCHOR_TOKEN)
+ {
+ anchor = token->data.anchor.value;
+ start_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type == YAML_TAG_TOKEN)
+ {
+ tag_handle = token->data.tag.handle;
+ tag_suffix = token->data.tag.suffix;
+ tag_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+ }
+ else if (token->type == YAML_TAG_TOKEN)
+ {
+ tag_handle = token->data.tag.handle;
+ tag_suffix = token->data.tag.suffix;
+ start_mark = tag_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type == YAML_ANCHOR_TOKEN)
+ {
+ anchor = token->data.anchor.value;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+ }
+
+ if (tag_handle) {
+ if (!*tag_handle) {
+ tag = tag_suffix;
+ yaml_free(tag_handle);
+ tag_handle = tag_suffix = NULL;
+ }
+ else {
+ yaml_tag_directive_t *tag_directive;
+ for (tag_directive = parser->tag_directives.start;
+ tag_directive != parser->tag_directives.top;
+ tag_directive ++) {
+ if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
+ size_t prefix_len = strlen((char *)tag_directive->prefix);
+ size_t suffix_len = strlen((char *)tag_suffix);
tag = YAML_MALLOC(prefix_len+suffix_len+1);
- if (!tag) {
- parser->error = YAML_MEMORY_ERROR;
- goto error;
- }
- memcpy(tag, tag_directive->prefix, prefix_len);
- memcpy(tag+prefix_len, tag_suffix, suffix_len);
- tag[prefix_len+suffix_len] = '\0';
- yaml_free(tag_handle);
- yaml_free(tag_suffix);
- tag_handle = tag_suffix = NULL;
- break;
- }
- }
- if (!tag) {
- yaml_parser_set_parser_error_context(parser,
- "while parsing a node", start_mark,
- "found undefined tag handle", tag_mark);
- goto error;
- }
- }
- }
-
- implicit = (!tag || !*tag);
- if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
- end_mark = token->end_mark;
- parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
- SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
- YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
- return 1;
- }
- else {
- if (token->type == YAML_SCALAR_TOKEN) {
- int plain_implicit = 0;
- int quoted_implicit = 0;
- end_mark = token->end_mark;
- if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
- || (tag && strcmp((char *)tag, "!") == 0)) {
- plain_implicit = 1;
- }
- else if (!tag) {
- quoted_implicit = 1;
- }
- parser->state = POP(parser, parser->states);
- SCALAR_EVENT_INIT(*event, anchor, tag,
- token->data.scalar.value, token->data.scalar.length,
- plain_implicit, quoted_implicit,
- token->data.scalar.style, start_mark, end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
- else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) {
- end_mark = token->end_mark;
- parser->state = YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE;
- SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
- YAML_FLOW_SEQUENCE_STYLE, start_mark, end_mark);
- return 1;
- }
- else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) {
- end_mark = token->end_mark;
- parser->state = YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE;
- MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
- YAML_FLOW_MAPPING_STYLE, start_mark, end_mark);
- return 1;
- }
- else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
- end_mark = token->end_mark;
- parser->state = YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE;
- SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
- YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
- return 1;
- }
- else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
- end_mark = token->end_mark;
- parser->state = YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE;
- MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
- YAML_BLOCK_MAPPING_STYLE, start_mark, end_mark);
- return 1;
- }
- else if (anchor || tag) {
+ if (!tag) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ memcpy(tag, tag_directive->prefix, prefix_len);
+ memcpy(tag+prefix_len, tag_suffix, suffix_len);
+ tag[prefix_len+suffix_len] = '\0';
+ yaml_free(tag_handle);
+ yaml_free(tag_suffix);
+ tag_handle = tag_suffix = NULL;
+ break;
+ }
+ }
+ if (!tag) {
+ yaml_parser_set_parser_error_context(parser,
+ "while parsing a node", start_mark,
+ "found undefined tag handle", tag_mark);
+ goto error;
+ }
+ }
+ }
+
+ implicit = (!tag || !*tag);
+ if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else {
+ if (token->type == YAML_SCALAR_TOKEN) {
+ int plain_implicit = 0;
+ int quoted_implicit = 0;
+ end_mark = token->end_mark;
+ if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
+ || (tag && strcmp((char *)tag, "!") == 0)) {
+ plain_implicit = 1;
+ }
+ else if (!tag) {
+ quoted_implicit = 1;
+ }
+ parser->state = POP(parser, parser->states);
+ SCALAR_EVENT_INIT(*event, anchor, tag,
+ token->data.scalar.value, token->data.scalar.length,
+ plain_implicit, quoted_implicit,
+ token->data.scalar.style, start_mark, end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+ else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_FLOW_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_FLOW_MAPPING_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_MAPPING_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (anchor || tag) {
yaml_char_t *value = YAML_MALLOC(1);
- if (!value) {
- parser->error = YAML_MEMORY_ERROR;
- goto error;
- }
- value[0] = '\0';
- parser->state = POP(parser, parser->states);
- SCALAR_EVENT_INIT(*event, anchor, tag, value, 0,
- implicit, 0, YAML_PLAIN_SCALAR_STYLE,
- start_mark, end_mark);
- return 1;
- }
- else {
- yaml_parser_set_parser_error_context(parser,
- (block ? "while parsing a block node"
- : "while parsing a flow node"), start_mark,
- "did not find expected node content", token->start_mark);
- goto error;
- }
- }
- }
-
-error:
- yaml_free(anchor);
- yaml_free(tag_handle);
- yaml_free(tag_suffix);
- yaml_free(tag);
-
- return 0;
-}
-
-/*
- * Parse the productions:
- * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
- * ******************** *********** * *********
- */
-
-static int
-yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event, int first)
-{
- yaml_token_t *token;
-
- if (first) {
- token = PEEK_TOKEN(parser);
- if (!PUSH(parser, parser->marks, token->start_mark))
- return 0;
- SKIP_TOKEN(parser);
- }
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_BLOCK_ENTRY_TOKEN)
- {
- yaml_mark_t mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
- token->type != YAML_BLOCK_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 1, 0);
- }
- else {
- parser->state = YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE;
- return yaml_parser_process_empty_scalar(parser, event, mark);
- }
- }
-
- else if (token->type == YAML_BLOCK_END_TOKEN)
- {
- parser->state = POP(parser, parser->states);
+ if (!value) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ value[0] = '\0';
+ parser->state = POP(parser, parser->states);
+ SCALAR_EVENT_INIT(*event, anchor, tag, value, 0,
+ implicit, 0, YAML_PLAIN_SCALAR_STYLE,
+ start_mark, end_mark);
+ return 1;
+ }
+ else {
+ yaml_parser_set_parser_error_context(parser,
+ (block ? "while parsing a block node"
+ : "while parsing a flow node"), start_mark,
+ "did not find expected node content", token->start_mark);
+ goto error;
+ }
+ }
+ }
+
+error:
+ yaml_free(anchor);
+ yaml_free(tag_handle);
+ yaml_free(tag_suffix);
+ yaml_free(tag);
+
+ return 0;
+}
+
+/*
+ * Parse the productions:
+ * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+ * ******************** *********** * *********
+ */
+
+static int
+yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_BLOCK_ENTRY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else if (token->type == YAML_BLOCK_END_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
(void)POP(parser, parser->marks);
- SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
-
- else
- {
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block collection", POP(parser, parser->marks),
- "did not find expected '-' indicator", token->start_mark);
- }
-}
-
-/*
- * Parse the productions:
- * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
- * *********** *
- */
-
-static int
-yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_BLOCK_ENTRY_TOKEN)
- {
- yaml_mark_t mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
- token->type != YAML_KEY_TOKEN &&
- token->type != YAML_VALUE_TOKEN &&
- token->type != YAML_BLOCK_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 1, 0);
- }
- else {
- parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
- return yaml_parser_process_empty_scalar(parser, event, mark);
- }
- }
-
- else
- {
- parser->state = POP(parser, parser->states);
- SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
- return 1;
- }
-}
-
-/*
- * Parse the productions:
- * block_mapping ::= BLOCK-MAPPING_START
- * *******************
- * ((KEY block_node_or_indentless_sequence?)?
- * *** *
- * (VALUE block_node_or_indentless_sequence?)?)*
- *
- * BLOCK-END
- * *********
- */
-
-static int
-yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event, int first)
-{
- yaml_token_t *token;
-
- if (first) {
- token = PEEK_TOKEN(parser);
- if (!PUSH(parser, parser->marks, token->start_mark))
- return 0;
- SKIP_TOKEN(parser);
- }
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_KEY_TOKEN)
- {
- yaml_mark_t mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_KEY_TOKEN &&
- token->type != YAML_VALUE_TOKEN &&
- token->type != YAML_BLOCK_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_BLOCK_MAPPING_VALUE_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 1, 1);
- }
- else {
- parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE;
- return yaml_parser_process_empty_scalar(parser, event, mark);
- }
- }
-
- else if (token->type == YAML_BLOCK_END_TOKEN)
- {
- parser->state = POP(parser, parser->states);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a block collection", POP(parser, parser->marks),
+ "did not find expected '-' indicator", token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
+ * *********** *
+ */
+
+static int
+yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_BLOCK_ENTRY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
+ token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else
+ {
+ parser->state = POP(parser, parser->states);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
+ return 1;
+ }
+}
+
+/*
+ * Parse the productions:
+ * block_mapping ::= BLOCK-MAPPING_START
+ * *******************
+ * ((KEY block_node_or_indentless_sequence?)?
+ * *** *
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ *
+ * BLOCK-END
+ * *********
+ */
+
+static int
+yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_KEY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 1);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else if (token->type == YAML_BLOCK_END_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
(void)POP(parser, parser->marks);
- MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
-
- else
- {
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a block mapping", POP(parser, parser->marks),
- "did not find expected key", token->start_mark);
- }
-}
-
-/*
- * Parse the productions:
- * block_mapping ::= BLOCK-MAPPING_START
- *
- * ((KEY block_node_or_indentless_sequence?)?
- *
- * (VALUE block_node_or_indentless_sequence?)?)*
- * ***** *
- * BLOCK-END
- *
- */
-
-static int
-yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_VALUE_TOKEN)
- {
- yaml_mark_t mark = token->end_mark;
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_KEY_TOKEN &&
- token->type != YAML_VALUE_TOKEN &&
- token->type != YAML_BLOCK_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_BLOCK_MAPPING_KEY_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 1, 1);
- }
- else {
- parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
- return yaml_parser_process_empty_scalar(parser, event, mark);
- }
- }
-
- else
- {
- parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
- return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
- }
-}
-
-/*
- * Parse the productions:
- * flow_sequence ::= FLOW-SEQUENCE-START
- * *******************
- * (flow_sequence_entry FLOW-ENTRY)*
- * * **********
- * flow_sequence_entry?
- * *
- * FLOW-SEQUENCE-END
- * *****************
- * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * *
- */
-
-static int
-yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
- yaml_event_t *event, int first)
-{
- yaml_token_t *token;
-
- if (first) {
- token = PEEK_TOKEN(parser);
- if (!PUSH(parser, parser->marks, token->start_mark))
- return 0;
- SKIP_TOKEN(parser);
- }
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN)
- {
- if (!first) {
- if (token->type == YAML_FLOW_ENTRY_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- }
- else {
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow sequence", POP(parser, parser->marks),
- "did not find expected ',' or ']'", token->start_mark);
- }
- }
-
- if (token->type == YAML_KEY_TOKEN) {
- parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
- MAPPING_START_EVENT_INIT(*event, NULL, NULL,
- 1, YAML_FLOW_MAPPING_STYLE,
- token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
- }
-
- else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- }
-
- parser->state = POP(parser, parser->states);
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a block mapping", POP(parser, parser->marks),
+ "did not find expected key", token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * block_mapping ::= BLOCK-MAPPING_START
+ *
+ * ((KEY block_node_or_indentless_sequence?)?
+ *
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ * ***** *
+ * BLOCK-END
+ *
+ */
+
+static int
+yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VALUE_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 1);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else
+ {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence ::= FLOW-SEQUENCE-START
+ * *******************
+ * (flow_sequence_entry FLOW-ENTRY)*
+ * * **********
+ * flow_sequence_entry?
+ * *
+ * FLOW-SEQUENCE-END
+ * *****************
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN)
+ {
+ if (!first) {
+ if (token->type == YAML_FLOW_ENTRY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ else {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a flow sequence", POP(parser, parser->marks),
+ "did not find expected ',' or ']'", token->start_mark);
+ }
+ }
+
+ if (token->type == YAML_KEY_TOKEN) {
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, NULL, NULL,
+ 1, YAML_FLOW_MAPPING_STYLE,
+ token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = POP(parser, parser->states);
(void)POP(parser, parser->marks);
- SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
-}
-
-/*
- * Parse the productions:
- * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * *** *
- */
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN
- && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- else {
- yaml_mark_t mark = token->end_mark;
- SKIP_TOKEN(parser);
- parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE;
- return yaml_parser_process_empty_scalar(parser, event, mark);
- }
-}
-
-/*
- * Parse the productions:
- * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * ***** *
- */
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type == YAML_VALUE_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_FLOW_ENTRY_TOKEN
- && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- }
- parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE;
- return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
-}
-
-/*
- * Parse the productions:
- * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * *
- */
-
-static int
-yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
- yaml_event_t *event)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE;
-
- MAPPING_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
- return 1;
-}
-
-/*
- * Parse the productions:
- * flow_mapping ::= FLOW-MAPPING-START
- * ******************
- * (flow_mapping_entry FLOW-ENTRY)*
- * * **********
- * flow_mapping_entry?
- * ******************
- * FLOW-MAPPING-END
- * ****************
- * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * * *** *
- */
-
-static int
-yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
- yaml_event_t *event, int first)
-{
- yaml_token_t *token;
-
- if (first) {
- token = PEEK_TOKEN(parser);
- if (!PUSH(parser, parser->marks, token->start_mark))
- return 0;
- SKIP_TOKEN(parser);
- }
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (token->type != YAML_FLOW_MAPPING_END_TOKEN)
- {
- if (!first) {
- if (token->type == YAML_FLOW_ENTRY_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- }
- else {
- return yaml_parser_set_parser_error_context(parser,
- "while parsing a flow mapping", POP(parser, parser->marks),
- "did not find expected ',' or '}'", token->start_mark);
- }
- }
-
- if (token->type == YAML_KEY_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_VALUE_TOKEN
- && token->type != YAML_FLOW_ENTRY_TOKEN
- && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_MAPPING_VALUE_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- else {
- parser->state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE;
- return yaml_parser_process_empty_scalar(parser, event,
- token->start_mark);
- }
- }
- else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- }
-
- parser->state = POP(parser, parser->states);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *** *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ else {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * ***** *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VALUE_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE;
+
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_mapping ::= FLOW-MAPPING-START
+ * ******************
+ * (flow_mapping_entry FLOW-ENTRY)*
+ * * **********
+ * flow_mapping_entry?
+ * ******************
+ * FLOW-MAPPING-END
+ * ****************
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * * *** *
+ */
+
+static int
+yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_FLOW_MAPPING_END_TOKEN)
+ {
+ if (!first) {
+ if (token->type == YAML_FLOW_ENTRY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ else {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a flow mapping", POP(parser, parser->marks),
+ "did not find expected ',' or '}'", token->start_mark);
+ }
+ }
+
+ if (token->type == YAML_KEY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_VALUE_TOKEN
+ && token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+ }
+ else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = POP(parser, parser->states);
(void)POP(parser, parser->marks);
- MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
- SKIP_TOKEN(parser);
- return 1;
-}
-
-/*
- * Parse the productions:
- * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
- * * ***** *
- */
-
-static int
-yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
- yaml_event_t *event, int empty)
-{
- yaml_token_t *token;
-
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
-
- if (empty) {
- parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
- return yaml_parser_process_empty_scalar(parser, event,
- token->start_mark);
- }
-
- if (token->type == YAML_VALUE_TOKEN) {
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) return 0;
- if (token->type != YAML_FLOW_ENTRY_TOKEN
- && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
- if (!PUSH(parser, parser->states,
- YAML_PARSE_FLOW_MAPPING_KEY_STATE))
- return 0;
- return yaml_parser_parse_node(parser, event, 0, 0);
- }
- }
-
- parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
- return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
-}
-
-/*
- * Generate an empty scalar event.
- */
-
-static int
-yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
- yaml_mark_t mark)
-{
- yaml_char_t *value;
-
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * * ***** *
+ */
+
+static int
+yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event, int empty)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (empty) {
+ parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+
+ if (token->type == YAML_VALUE_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+}
+
+/*
+ * Generate an empty scalar event.
+ */
+
+static int
+yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
+ yaml_mark_t mark)
+{
+ yaml_char_t *value;
+
value = YAML_MALLOC(1);
- if (!value) {
- parser->error = YAML_MEMORY_ERROR;
- return 0;
- }
- value[0] = '\0';
-
- SCALAR_EVENT_INIT(*event, NULL, NULL, value, 0,
- 1, 0, YAML_PLAIN_SCALAR_STYLE, mark, mark);
-
- return 1;
-}
-
-/*
- * Parse directives.
- */
-
-static int
-yaml_parser_process_directives(yaml_parser_t *parser,
- yaml_version_directive_t **version_directive_ref,
- yaml_tag_directive_t **tag_directives_start_ref,
- yaml_tag_directive_t **tag_directives_end_ref)
-{
- yaml_tag_directive_t default_tag_directives[] = {
- {(yaml_char_t *)"!", (yaml_char_t *)"!"},
- {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
- {NULL, NULL}
- };
- yaml_tag_directive_t *default_tag_directive;
- yaml_version_directive_t *version_directive = NULL;
- struct {
- yaml_tag_directive_t *start;
- yaml_tag_directive_t *end;
- yaml_tag_directive_t *top;
- } tag_directives = { NULL, NULL, NULL };
- yaml_token_t *token;
-
+ if (!value) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+ value[0] = '\0';
+
+ SCALAR_EVENT_INIT(*event, NULL, NULL, value, 0,
+ 1, 0, YAML_PLAIN_SCALAR_STYLE, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Parse directives.
+ */
+
+static int
+yaml_parser_process_directives(yaml_parser_t *parser,
+ yaml_version_directive_t **version_directive_ref,
+ yaml_tag_directive_t **tag_directives_start_ref,
+ yaml_tag_directive_t **tag_directives_end_ref)
+{
+ yaml_tag_directive_t default_tag_directives[] = {
+ {(yaml_char_t *)"!", (yaml_char_t *)"!"},
+ {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
+ {NULL, NULL}
+ };
+ yaml_tag_directive_t *default_tag_directive;
+ yaml_version_directive_t *version_directive = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives = { NULL, NULL, NULL };
+ yaml_token_t *token;
+
if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
- goto error;
-
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
-
- while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
- token->type == YAML_TAG_DIRECTIVE_TOKEN)
- {
- if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
- if (version_directive) {
- yaml_parser_set_parser_error(parser,
- "found duplicate %YAML directive", token->start_mark);
- goto error;
- }
- if (token->data.version_directive.major != 1
+ goto error;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+
+ while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
+ token->type == YAML_TAG_DIRECTIVE_TOKEN)
+ {
+ if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
+ if (version_directive) {
+ yaml_parser_set_parser_error(parser,
+ "found duplicate %YAML directive", token->start_mark);
+ goto error;
+ }
+ if (token->data.version_directive.major != 1
|| (
token->data.version_directive.minor != 1
&& token->data.version_directive.minor != 2
)) {
- yaml_parser_set_parser_error(parser,
- "found incompatible YAML document", token->start_mark);
- goto error;
- }
+ yaml_parser_set_parser_error(parser,
+ "found incompatible YAML document", token->start_mark);
+ goto error;
+ }
version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
- if (!version_directive) {
- parser->error = YAML_MEMORY_ERROR;
- goto error;
- }
- version_directive->major = token->data.version_directive.major;
- version_directive->minor = token->data.version_directive.minor;
- }
-
- else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
- yaml_tag_directive_t value;
- value.handle = token->data.tag_directive.handle;
- value.prefix = token->data.tag_directive.prefix;
-
- if (!yaml_parser_append_tag_directive(parser, value, 0,
- token->start_mark))
- goto error;
- if (!PUSH(parser, tag_directives, value))
- goto error;
- }
-
- SKIP_TOKEN(parser);
- token = PEEK_TOKEN(parser);
- if (!token) goto error;
- }
-
- for (default_tag_directive = default_tag_directives;
- default_tag_directive->handle; default_tag_directive++) {
- if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
- token->start_mark))
- goto error;
- }
-
- if (version_directive_ref) {
- *version_directive_ref = version_directive;
- }
- if (tag_directives_start_ref) {
- if (STACK_EMPTY(parser, tag_directives)) {
- *tag_directives_start_ref = *tag_directives_end_ref = NULL;
- STACK_DEL(parser, tag_directives);
- }
- else {
- *tag_directives_start_ref = tag_directives.start;
- *tag_directives_end_ref = tag_directives.top;
- }
- }
- else {
- STACK_DEL(parser, tag_directives);
- }
-
+ if (!version_directive) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ version_directive->major = token->data.version_directive.major;
+ version_directive->minor = token->data.version_directive.minor;
+ }
+
+ else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
+ yaml_tag_directive_t value;
+ value.handle = token->data.tag_directive.handle;
+ value.prefix = token->data.tag_directive.prefix;
+
+ if (!yaml_parser_append_tag_directive(parser, value, 0,
+ token->start_mark))
+ goto error;
+ if (!PUSH(parser, tag_directives, value))
+ goto error;
+ }
+
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+
+ for (default_tag_directive = default_tag_directives;
+ default_tag_directive->handle; default_tag_directive++) {
+ if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
+ token->start_mark))
+ goto error;
+ }
+
+ if (version_directive_ref) {
+ *version_directive_ref = version_directive;
+ }
+ if (tag_directives_start_ref) {
+ if (STACK_EMPTY(parser, tag_directives)) {
+ *tag_directives_start_ref = *tag_directives_end_ref = NULL;
+ STACK_DEL(parser, tag_directives);
+ }
+ else {
+ *tag_directives_start_ref = tag_directives.start;
+ *tag_directives_end_ref = tag_directives.top;
+ }
+ }
+ else {
+ STACK_DEL(parser, tag_directives);
+ }
+
if (!version_directive_ref)
yaml_free(version_directive);
- return 1;
-
-error:
- yaml_free(version_directive);
- while (!STACK_EMPTY(parser, tag_directives)) {
- yaml_tag_directive_t tag_directive = POP(parser, tag_directives);
- yaml_free(tag_directive.handle);
- yaml_free(tag_directive.prefix);
- }
- STACK_DEL(parser, tag_directives);
- return 0;
-}
-
-/*
- * Append a tag directive to the directives stack.
- */
-
-static int
-yaml_parser_append_tag_directive(yaml_parser_t *parser,
- yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark)
-{
- yaml_tag_directive_t *tag_directive;
- yaml_tag_directive_t copy = { NULL, NULL };
-
- for (tag_directive = parser->tag_directives.start;
- tag_directive != parser->tag_directives.top; tag_directive ++) {
- if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
- if (allow_duplicates)
- return 1;
- return yaml_parser_set_parser_error(parser,
- "found duplicate %TAG directive", mark);
- }
- }
-
- copy.handle = yaml_strdup(value.handle);
- copy.prefix = yaml_strdup(value.prefix);
- if (!copy.handle || !copy.prefix) {
- parser->error = YAML_MEMORY_ERROR;
- goto error;
- }
-
- if (!PUSH(parser, parser->tag_directives, copy))
- goto error;
-
- return 1;
-
-error:
- yaml_free(copy.handle);
- yaml_free(copy.prefix);
- return 0;
-}
-
+ return 1;
+
+error:
+ yaml_free(version_directive);
+ while (!STACK_EMPTY(parser, tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(parser, tag_directives);
+ return 0;
+}
+
+/*
+ * Append a tag directive to the directives stack.
+ */
+
+static int
+yaml_parser_append_tag_directive(yaml_parser_t *parser,
+ yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark)
+{
+ yaml_tag_directive_t *tag_directive;
+ yaml_tag_directive_t copy = { NULL, NULL };
+
+ for (tag_directive = parser->tag_directives.start;
+ tag_directive != parser->tag_directives.top; tag_directive ++) {
+ if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
+ if (allow_duplicates)
+ return 1;
+ return yaml_parser_set_parser_error(parser,
+ "found duplicate %TAG directive", mark);
+ }
+ }
+
+ copy.handle = yaml_strdup(value.handle);
+ copy.prefix = yaml_strdup(value.prefix);
+ if (!copy.handle || !copy.prefix) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+
+ if (!PUSH(parser, parser->tag_directives, copy))
+ goto error;
+
+ return 1;
+
+error:
+ yaml_free(copy.handle);
+ yaml_free(copy.prefix);
+ return 0;
+}
+
diff --git a/contrib/libs/yaml/src/reader.c b/contrib/libs/yaml/src/reader.c
index 798770bb3f..f3ac54c251 100644
--- a/contrib/libs/yaml/src/reader.c
+++ b/contrib/libs/yaml/src/reader.c
@@ -1,469 +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. */
-
+
+#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:
+ && 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)
*
- * 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;
- }
-
- }
-
+ * 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",
+ return yaml_parser_set_reader_error(parser, "input is too long",
parser->offset, -1);
}
-
- return 1;
-}
+
+ return 1;
+}
diff --git a/contrib/libs/yaml/src/scanner.c b/contrib/libs/yaml/src/scanner.c
index e252398e5c..c6b4987656 100644
--- a/contrib/libs/yaml/src/scanner.c
+++ b/contrib/libs/yaml/src/scanner.c
@@ -1,3451 +1,3451 @@
-
-/*
- * Introduction
- * ************
- *
- * The following notes assume that you are familiar with the YAML specification
- * (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in
- * some cases we are less restrictive that it requires.
- *
- * The process of transforming a YAML stream into a sequence of events is
- * divided on two steps: Scanning and Parsing.
- *
- * The Scanner transforms the input stream into a sequence of tokens, while the
- * parser transform the sequence of tokens produced by the Scanner into a
- * sequence of parsing events.
- *
- * The Scanner is rather clever and complicated. The Parser, on the contrary,
- * is a straightforward implementation of a recursive-descendant parser (or,
- * LL(1) parser, as it is usually called).
- *
- * Actually there are two issues of Scanning that might be called "clever", the
- * rest is quite straightforward. The issues are "block collection start" and
- * "simple keys". Both issues are explained below in details.
- *
- * Here the Scanning step is explained and implemented. We start with the list
- * of all the tokens produced by the Scanner together with short descriptions.
- *
- * Now, tokens:
- *
- * STREAM-START(encoding) # The stream start.
- * STREAM-END # The stream end.
- * VERSION-DIRECTIVE(major,minor) # The '%YAML' directive.
- * TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive.
- * DOCUMENT-START # '---'
- * DOCUMENT-END # '...'
- * BLOCK-SEQUENCE-START # Indentation increase denoting a block
- * BLOCK-MAPPING-START # sequence or a block mapping.
- * BLOCK-END # Indentation decrease.
- * FLOW-SEQUENCE-START # '['
- * FLOW-SEQUENCE-END # ']'
+
+/*
+ * Introduction
+ * ************
+ *
+ * The following notes assume that you are familiar with the YAML specification
+ * (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in
+ * some cases we are less restrictive that it requires.
+ *
+ * The process of transforming a YAML stream into a sequence of events is
+ * divided on two steps: Scanning and Parsing.
+ *
+ * The Scanner transforms the input stream into a sequence of tokens, while the
+ * parser transform the sequence of tokens produced by the Scanner into a
+ * sequence of parsing events.
+ *
+ * The Scanner is rather clever and complicated. The Parser, on the contrary,
+ * is a straightforward implementation of a recursive-descendant parser (or,
+ * LL(1) parser, as it is usually called).
+ *
+ * Actually there are two issues of Scanning that might be called "clever", the
+ * rest is quite straightforward. The issues are "block collection start" and
+ * "simple keys". Both issues are explained below in details.
+ *
+ * Here the Scanning step is explained and implemented. We start with the list
+ * of all the tokens produced by the Scanner together with short descriptions.
+ *
+ * Now, tokens:
+ *
+ * STREAM-START(encoding) # The stream start.
+ * STREAM-END # The stream end.
+ * VERSION-DIRECTIVE(major,minor) # The '%YAML' directive.
+ * TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive.
+ * DOCUMENT-START # '---'
+ * DOCUMENT-END # '...'
+ * BLOCK-SEQUENCE-START # Indentation increase denoting a block
+ * BLOCK-MAPPING-START # sequence or a block mapping.
+ * BLOCK-END # Indentation decrease.
+ * FLOW-SEQUENCE-START # '['
+ * FLOW-SEQUENCE-END # ']'
* FLOW-MAPPING-START # '{'
* FLOW-MAPPING-END # '}'
- * BLOCK-ENTRY # '-'
- * FLOW-ENTRY # ','
- * KEY # '?' or nothing (simple keys).
- * VALUE # ':'
- * ALIAS(anchor) # '*anchor'
- * ANCHOR(anchor) # '&anchor'
- * TAG(handle,suffix) # '!handle!suffix'
- * SCALAR(value,style) # A scalar.
- *
- * The following two tokens are "virtual" tokens denoting the beginning and the
- * end of the stream:
- *
- * STREAM-START(encoding)
- * STREAM-END
- *
- * We pass the information about the input stream encoding with the
- * STREAM-START token.
- *
- * The next two tokens are responsible for tags:
- *
- * VERSION-DIRECTIVE(major,minor)
- * TAG-DIRECTIVE(handle,prefix)
- *
- * Example:
- *
- * %YAML 1.1
- * %TAG ! !foo
- * %TAG !yaml! tag:yaml.org,2002:
- * ---
- *
+ * BLOCK-ENTRY # '-'
+ * FLOW-ENTRY # ','
+ * KEY # '?' or nothing (simple keys).
+ * VALUE # ':'
+ * ALIAS(anchor) # '*anchor'
+ * ANCHOR(anchor) # '&anchor'
+ * TAG(handle,suffix) # '!handle!suffix'
+ * SCALAR(value,style) # A scalar.
+ *
+ * The following two tokens are "virtual" tokens denoting the beginning and the
+ * end of the stream:
+ *
+ * STREAM-START(encoding)
+ * STREAM-END
+ *
+ * We pass the information about the input stream encoding with the
+ * STREAM-START token.
+ *
+ * The next two tokens are responsible for tags:
+ *
+ * VERSION-DIRECTIVE(major,minor)
+ * TAG-DIRECTIVE(handle,prefix)
+ *
+ * Example:
+ *
+ * %YAML 1.1
+ * %TAG ! !foo
+ * %TAG !yaml! tag:yaml.org,2002:
+ * ---
+ *
* The corresponding sequence of tokens:
- *
- * STREAM-START(utf-8)
- * VERSION-DIRECTIVE(1,1)
- * TAG-DIRECTIVE("!","!foo")
- * TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:")
- * DOCUMENT-START
- * STREAM-END
- *
- * Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole
- * line.
- *
- * The document start and end indicators are represented by:
- *
- * DOCUMENT-START
- * DOCUMENT-END
- *
- * Note that if a YAML stream contains an implicit document (without '---'
- * and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be
- * produced.
- *
- * In the following examples, we present whole documents together with the
- * produced tokens.
- *
- * 1. An implicit document:
- *
- * 'a scalar'
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * SCALAR("a scalar",single-quoted)
- * STREAM-END
- *
- * 2. An explicit document:
- *
- * ---
- * 'a scalar'
- * ...
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * DOCUMENT-START
- * SCALAR("a scalar",single-quoted)
- * DOCUMENT-END
- * STREAM-END
- *
- * 3. Several documents in a stream:
- *
- * 'a scalar'
- * ---
- * 'another scalar'
- * ---
- * 'yet another scalar'
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * SCALAR("a scalar",single-quoted)
- * DOCUMENT-START
- * SCALAR("another scalar",single-quoted)
- * DOCUMENT-START
- * SCALAR("yet another scalar",single-quoted)
- * STREAM-END
- *
- * We have already introduced the SCALAR token above. The following tokens are
- * used to describe aliases, anchors, tag, and scalars:
- *
- * ALIAS(anchor)
- * ANCHOR(anchor)
- * TAG(handle,suffix)
- * SCALAR(value,style)
- *
- * The following series of examples illustrate the usage of these tokens:
- *
- * 1. A recursive sequence:
- *
- * &A [ *A ]
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * ANCHOR("A")
- * FLOW-SEQUENCE-START
- * ALIAS("A")
- * FLOW-SEQUENCE-END
- * STREAM-END
- *
- * 2. A tagged scalar:
- *
- * !!float "3.14" # A good approximation.
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * TAG("!!","float")
- * SCALAR("3.14",double-quoted)
- * STREAM-END
- *
- * 3. Various scalar styles:
- *
- * --- # Implicit empty plain scalars do not produce tokens.
- * --- a plain scalar
- * --- 'a single-quoted scalar'
- * --- "a double-quoted scalar"
- * --- |-
- * a literal scalar
- * --- >-
- * a folded
- * scalar
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * DOCUMENT-START
- * DOCUMENT-START
- * SCALAR("a plain scalar",plain)
- * DOCUMENT-START
- * SCALAR("a single-quoted scalar",single-quoted)
- * DOCUMENT-START
- * SCALAR("a double-quoted scalar",double-quoted)
- * DOCUMENT-START
- * SCALAR("a literal scalar",literal)
- * DOCUMENT-START
- * SCALAR("a folded scalar",folded)
- * STREAM-END
- *
- * Now it's time to review collection-related tokens. We will start with
- * flow collections:
- *
- * FLOW-SEQUENCE-START
- * FLOW-SEQUENCE-END
- * FLOW-MAPPING-START
- * FLOW-MAPPING-END
- * FLOW-ENTRY
- * KEY
- * VALUE
- *
- * The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and
- * FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'
- * correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the
- * indicators '?' and ':', which are used for denoting mapping keys and values,
- * are represented by the KEY and VALUE tokens.
- *
- * The following examples show flow collections:
- *
- * 1. A flow sequence:
- *
- * [item 1, item 2, item 3]
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * FLOW-SEQUENCE-START
- * SCALAR("item 1",plain)
- * FLOW-ENTRY
- * SCALAR("item 2",plain)
- * FLOW-ENTRY
- * SCALAR("item 3",plain)
- * FLOW-SEQUENCE-END
- * STREAM-END
- *
- * 2. A flow mapping:
- *
- * {
- * a simple key: a value, # Note that the KEY token is produced.
- * ? a complex key: another value,
- * }
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * FLOW-MAPPING-START
- * KEY
- * SCALAR("a simple key",plain)
- * VALUE
- * SCALAR("a value",plain)
- * FLOW-ENTRY
- * KEY
- * SCALAR("a complex key",plain)
- * VALUE
- * SCALAR("another value",plain)
- * FLOW-ENTRY
- * FLOW-MAPPING-END
- * STREAM-END
- *
- * A simple key is a key which is not denoted by the '?' indicator. Note that
- * the Scanner still produce the KEY token whenever it encounters a simple key.
- *
- * For scanning block collections, the following tokens are used (note that we
- * repeat KEY and VALUE here):
- *
- * BLOCK-SEQUENCE-START
- * BLOCK-MAPPING-START
- * BLOCK-END
- * BLOCK-ENTRY
- * KEY
- * VALUE
- *
- * The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
- * increase that precedes a block collection (cf. the INDENT token in Python).
- * The token BLOCK-END denote indentation decrease that ends a block collection
- * (cf. the DEDENT token in Python). However YAML has some syntax pecularities
- * that makes detections of these tokens more complex.
- *
- * The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
- * '-', '?', and ':' correspondingly.
- *
- * The following examples show how the tokens BLOCK-SEQUENCE-START,
- * BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:
- *
- * 1. Block sequences:
- *
- * - item 1
- * - item 2
- * -
- * - item 3.1
- * - item 3.2
- * -
- * key 1: value 1
- * key 2: value 2
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * SCALAR("item 1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 2",plain)
- * BLOCK-ENTRY
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * SCALAR("item 3.1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 3.2",plain)
- * BLOCK-END
- * BLOCK-ENTRY
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("key 1",plain)
- * VALUE
- * SCALAR("value 1",plain)
- * KEY
- * SCALAR("key 2",plain)
- * VALUE
- * SCALAR("value 2",plain)
- * BLOCK-END
- * BLOCK-END
- * STREAM-END
- *
- * 2. Block mappings:
- *
- * a simple key: a value # The KEY token is produced here.
- * ? a complex key
- * : another value
- * a mapping:
- * key 1: value 1
- * key 2: value 2
- * a sequence:
- * - item 1
- * - item 2
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("a simple key",plain)
- * VALUE
- * SCALAR("a value",plain)
- * KEY
- * SCALAR("a complex key",plain)
- * VALUE
- * SCALAR("another value",plain)
- * KEY
- * SCALAR("a mapping",plain)
+ *
+ * STREAM-START(utf-8)
+ * VERSION-DIRECTIVE(1,1)
+ * TAG-DIRECTIVE("!","!foo")
+ * TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:")
+ * DOCUMENT-START
+ * STREAM-END
+ *
+ * Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole
+ * line.
+ *
+ * The document start and end indicators are represented by:
+ *
+ * DOCUMENT-START
+ * DOCUMENT-END
+ *
+ * Note that if a YAML stream contains an implicit document (without '---'
+ * and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be
+ * produced.
+ *
+ * In the following examples, we present whole documents together with the
+ * produced tokens.
+ *
+ * 1. An implicit document:
+ *
+ * 'a scalar'
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * SCALAR("a scalar",single-quoted)
+ * STREAM-END
+ *
+ * 2. An explicit document:
+ *
+ * ---
+ * 'a scalar'
+ * ...
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * DOCUMENT-START
+ * SCALAR("a scalar",single-quoted)
+ * DOCUMENT-END
+ * STREAM-END
+ *
+ * 3. Several documents in a stream:
+ *
+ * 'a scalar'
+ * ---
+ * 'another scalar'
+ * ---
+ * 'yet another scalar'
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * SCALAR("a scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("another scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("yet another scalar",single-quoted)
+ * STREAM-END
+ *
+ * We have already introduced the SCALAR token above. The following tokens are
+ * used to describe aliases, anchors, tag, and scalars:
+ *
+ * ALIAS(anchor)
+ * ANCHOR(anchor)
+ * TAG(handle,suffix)
+ * SCALAR(value,style)
+ *
+ * The following series of examples illustrate the usage of these tokens:
+ *
+ * 1. A recursive sequence:
+ *
+ * &A [ *A ]
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * ANCHOR("A")
+ * FLOW-SEQUENCE-START
+ * ALIAS("A")
+ * FLOW-SEQUENCE-END
+ * STREAM-END
+ *
+ * 2. A tagged scalar:
+ *
+ * !!float "3.14" # A good approximation.
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * TAG("!!","float")
+ * SCALAR("3.14",double-quoted)
+ * STREAM-END
+ *
+ * 3. Various scalar styles:
+ *
+ * --- # Implicit empty plain scalars do not produce tokens.
+ * --- a plain scalar
+ * --- 'a single-quoted scalar'
+ * --- "a double-quoted scalar"
+ * --- |-
+ * a literal scalar
+ * --- >-
+ * a folded
+ * scalar
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * DOCUMENT-START
+ * DOCUMENT-START
+ * SCALAR("a plain scalar",plain)
+ * DOCUMENT-START
+ * SCALAR("a single-quoted scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("a double-quoted scalar",double-quoted)
+ * DOCUMENT-START
+ * SCALAR("a literal scalar",literal)
+ * DOCUMENT-START
+ * SCALAR("a folded scalar",folded)
+ * STREAM-END
+ *
+ * Now it's time to review collection-related tokens. We will start with
+ * flow collections:
+ *
+ * FLOW-SEQUENCE-START
+ * FLOW-SEQUENCE-END
+ * FLOW-MAPPING-START
+ * FLOW-MAPPING-END
+ * FLOW-ENTRY
+ * KEY
+ * VALUE
+ *
+ * The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and
+ * FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'
+ * correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the
+ * indicators '?' and ':', which are used for denoting mapping keys and values,
+ * are represented by the KEY and VALUE tokens.
+ *
+ * The following examples show flow collections:
+ *
+ * 1. A flow sequence:
+ *
+ * [item 1, item 2, item 3]
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * FLOW-SEQUENCE-START
+ * SCALAR("item 1",plain)
+ * FLOW-ENTRY
+ * SCALAR("item 2",plain)
+ * FLOW-ENTRY
+ * SCALAR("item 3",plain)
+ * FLOW-SEQUENCE-END
+ * STREAM-END
+ *
+ * 2. A flow mapping:
+ *
+ * {
+ * a simple key: a value, # Note that the KEY token is produced.
+ * ? a complex key: another value,
+ * }
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * FLOW-MAPPING-START
+ * KEY
+ * SCALAR("a simple key",plain)
+ * VALUE
+ * SCALAR("a value",plain)
+ * FLOW-ENTRY
+ * KEY
+ * SCALAR("a complex key",plain)
+ * VALUE
+ * SCALAR("another value",plain)
+ * FLOW-ENTRY
+ * FLOW-MAPPING-END
+ * STREAM-END
+ *
+ * A simple key is a key which is not denoted by the '?' indicator. Note that
+ * the Scanner still produce the KEY token whenever it encounters a simple key.
+ *
+ * For scanning block collections, the following tokens are used (note that we
+ * repeat KEY and VALUE here):
+ *
+ * BLOCK-SEQUENCE-START
+ * BLOCK-MAPPING-START
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * KEY
+ * VALUE
+ *
+ * The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
+ * increase that precedes a block collection (cf. the INDENT token in Python).
+ * The token BLOCK-END denote indentation decrease that ends a block collection
+ * (cf. the DEDENT token in Python). However YAML has some syntax pecularities
+ * that makes detections of these tokens more complex.
+ *
+ * The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
+ * '-', '?', and ':' correspondingly.
+ *
+ * The following examples show how the tokens BLOCK-SEQUENCE-START,
+ * BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:
+ *
+ * 1. Block sequences:
+ *
+ * - item 1
+ * - item 2
+ * -
+ * - item 3.1
+ * - item 3.2
+ * -
+ * key 1: value 1
+ * key 2: value 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-ENTRY
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 3.1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 3.2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * 2. Block mappings:
+ *
+ * a simple key: a value # The KEY token is produced here.
+ * ? a complex key
+ * : another value
+ * a mapping:
+ * key 1: value 1
+ * key 2: value 2
+ * a sequence:
+ * - item 1
+ * - item 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("a simple key",plain)
+ * VALUE
+ * SCALAR("a value",plain)
+ * KEY
+ * SCALAR("a complex key",plain)
+ * VALUE
+ * SCALAR("another value",plain)
+ * KEY
+ * SCALAR("a mapping",plain)
+ * VALUE
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * KEY
+ * SCALAR("a sequence",plain)
+ * VALUE
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * YAML does not always require to start a new block collection from a new
+ * line. If the current line contains only '-', '?', and ':' indicators, a new
+ * block collection may start at the current line. The following examples
+ * illustrate this case:
+ *
+ * 1. Collections in a sequence:
+ *
+ * - - item 1
+ * - item 2
+ * - key 1: value 1
+ * key 2: value 2
+ * - ? complex key
+ * : complex value
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("complex key")
+ * VALUE
+ * SCALAR("complex value")
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * 2. Collections in a mapping:
+ *
+ * ? a sequence
+ * : - item 1
+ * - item 2
+ * ? a mapping
+ * : key 1: value 1
+ * key 2: value 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("a sequence",plain)
+ * VALUE
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * KEY
+ * SCALAR("a mapping",plain)
+ * VALUE
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
* VALUE
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("key 1",plain)
- * VALUE
- * SCALAR("value 1",plain)
- * KEY
- * SCALAR("key 2",plain)
- * VALUE
- * SCALAR("value 2",plain)
- * BLOCK-END
- * KEY
- * SCALAR("a sequence",plain)
- * VALUE
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * SCALAR("item 1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 2",plain)
- * BLOCK-END
- * BLOCK-END
- * STREAM-END
- *
- * YAML does not always require to start a new block collection from a new
- * line. If the current line contains only '-', '?', and ':' indicators, a new
- * block collection may start at the current line. The following examples
- * illustrate this case:
- *
- * 1. Collections in a sequence:
- *
- * - - item 1
- * - item 2
- * - key 1: value 1
- * key 2: value 2
- * - ? complex key
- * : complex value
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * SCALAR("item 1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 2",plain)
- * BLOCK-END
- * BLOCK-ENTRY
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("key 1",plain)
- * VALUE
- * SCALAR("value 1",plain)
- * KEY
- * SCALAR("key 2",plain)
- * VALUE
- * SCALAR("value 2",plain)
- * BLOCK-END
- * BLOCK-ENTRY
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("complex key")
- * VALUE
- * SCALAR("complex value")
- * BLOCK-END
- * BLOCK-END
- * STREAM-END
- *
- * 2. Collections in a mapping:
- *
- * ? a sequence
- * : - item 1
- * - item 2
- * ? a mapping
- * : key 1: value 1
- * key 2: value 2
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("a sequence",plain)
- * VALUE
- * BLOCK-SEQUENCE-START
- * BLOCK-ENTRY
- * SCALAR("item 1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 2",plain)
- * BLOCK-END
- * KEY
- * SCALAR("a mapping",plain)
- * VALUE
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("key 1",plain)
- * VALUE
- * SCALAR("value 1",plain)
- * KEY
- * SCALAR("key 2",plain)
- * VALUE
- * SCALAR("value 2",plain)
- * BLOCK-END
- * BLOCK-END
- * STREAM-END
- *
- * YAML also permits non-indented sequences if they are included into a block
- * mapping. In this case, the token BLOCK-SEQUENCE-START is not produced:
- *
- * key:
- * - item 1 # BLOCK-SEQUENCE-START is NOT produced here.
- * - item 2
- *
- * Tokens:
- *
- * STREAM-START(utf-8)
- * BLOCK-MAPPING-START
- * KEY
- * SCALAR("key",plain)
- * VALUE
- * BLOCK-ENTRY
- * SCALAR("item 1",plain)
- * BLOCK-ENTRY
- * SCALAR("item 2",plain)
- * BLOCK-END
- */
-
-#include "yaml_private.h"
-
-/*
- * Ensure that the buffer contains the required number of characters.
- * Return 1 on success, 0 on failure (reader error or memory error).
- */
-
-#define CACHE(parser,length) \
- (parser->unread >= (length) \
- ? 1 \
- : yaml_parser_update_buffer(parser, (length)))
-
-/*
- * Advance the buffer pointer.
- */
-
-#define SKIP(parser) \
- (parser->mark.index ++, \
- parser->mark.column ++, \
- parser->unread --, \
- parser->buffer.pointer += WIDTH(parser->buffer))
-
-#define SKIP_LINE(parser) \
- (IS_CRLF(parser->buffer) ? \
- (parser->mark.index += 2, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread -= 2, \
- parser->buffer.pointer += 2) : \
- IS_BREAK(parser->buffer) ? \
- (parser->mark.index ++, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread --, \
- parser->buffer.pointer += WIDTH(parser->buffer)) : 0)
-
-/*
- * Copy a character to a string buffer and advance pointers.
- */
-
-#define READ(parser,string) \
- (STRING_EXTEND(parser,string) ? \
- (COPY(string,parser->buffer), \
- parser->mark.index ++, \
- parser->mark.column ++, \
- parser->unread --, \
- 1) : 0)
-
-/*
- * Copy a line break character to a string buffer and advance pointers.
- */
-
-#define READ_LINE(parser,string) \
- (STRING_EXTEND(parser,string) ? \
- (((CHECK_AT(parser->buffer,'\r',0) \
- && CHECK_AT(parser->buffer,'\n',1)) ? /* CR LF -> LF */ \
- (*((string).pointer++) = (yaml_char_t) '\n', \
- parser->buffer.pointer += 2, \
- parser->mark.index += 2, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread -= 2) : \
- (CHECK_AT(parser->buffer,'\r',0) \
- || CHECK_AT(parser->buffer,'\n',0)) ? /* CR|LF -> LF */ \
- (*((string).pointer++) = (yaml_char_t) '\n', \
- parser->buffer.pointer ++, \
- parser->mark.index ++, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread --) : \
- (CHECK_AT(parser->buffer,'\xC2',0) \
- && CHECK_AT(parser->buffer,'\x85',1)) ? /* NEL -> LF */ \
- (*((string).pointer++) = (yaml_char_t) '\n', \
- parser->buffer.pointer += 2, \
- parser->mark.index ++, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread --) : \
- (CHECK_AT(parser->buffer,'\xE2',0) && \
- CHECK_AT(parser->buffer,'\x80',1) && \
- (CHECK_AT(parser->buffer,'\xA8',2) || \
- CHECK_AT(parser->buffer,'\xA9',2))) ? /* LS|PS -> LS|PS */ \
- (*((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++), \
- parser->mark.index ++, \
- parser->mark.column = 0, \
- parser->mark.line ++, \
- parser->unread --) : 0), \
- 1) : 0)
-
-/*
- * Public API declarations.
- */
-
-YAML_DECLARE(int)
-yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
-
-/*
- * Error handling.
- */
-
-static int
-yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
- yaml_mark_t context_mark, const char *problem);
-
-/*
- * High-level token API.
- */
-
-YAML_DECLARE(int)
-yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_next_token(yaml_parser_t *parser);
-
-/*
- * Potential simple keys.
- */
-
-static int
-yaml_parser_stale_simple_keys(yaml_parser_t *parser);
-
-static int
-yaml_parser_save_simple_key(yaml_parser_t *parser);
-
-static int
-yaml_parser_remove_simple_key(yaml_parser_t *parser);
-
-static int
-yaml_parser_increase_flow_level(yaml_parser_t *parser);
-
-static int
-yaml_parser_decrease_flow_level(yaml_parser_t *parser);
-
-/*
- * Indentation treatment.
- */
-
-static int
-yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
- ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
-
-static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
-
-/*
- * Token fetchers.
- */
-
-static int
-yaml_parser_fetch_stream_start(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_stream_end(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_directive(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
- yaml_token_type_t type);
-
-static int
-yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
- yaml_token_type_t type);
-
-static int
-yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
- yaml_token_type_t type);
-
-static int
-yaml_parser_fetch_flow_entry(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_block_entry(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_key(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_value(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type);
-
-static int
-yaml_parser_fetch_tag(yaml_parser_t *parser);
-
-static int
-yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal);
-
-static int
-yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single);
-
-static int
-yaml_parser_fetch_plain_scalar(yaml_parser_t *parser);
-
-/*
- * Token scanners.
- */
-
-static int
-yaml_parser_scan_to_next_token(yaml_parser_t *parser);
-
-static int
-yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token);
-
-static int
-yaml_parser_scan_directive_name(yaml_parser_t *parser,
- yaml_mark_t start_mark, yaml_char_t **name);
-
-static int
-yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
- yaml_mark_t start_mark, int *major, int *minor);
-
-static int
-yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
- yaml_mark_t start_mark, int *number);
-
-static int
-yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
- yaml_mark_t mark, yaml_char_t **handle, yaml_char_t **prefix);
-
-static int
-yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
- yaml_token_type_t type);
-
-static int
-yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token);
-
-static int
-yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
- yaml_mark_t start_mark, yaml_char_t **handle);
-
-static int
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * YAML also permits non-indented sequences if they are included into a block
+ * mapping. In this case, the token BLOCK-SEQUENCE-START is not produced:
+ *
+ * key:
+ * - item 1 # BLOCK-SEQUENCE-START is NOT produced here.
+ * - item 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key",plain)
+ * VALUE
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ */
+
+#include "yaml_private.h"
+
+/*
+ * Ensure that the buffer contains the required number of characters.
+ * Return 1 on success, 0 on failure (reader error or memory error).
+ */
+
+#define CACHE(parser,length) \
+ (parser->unread >= (length) \
+ ? 1 \
+ : yaml_parser_update_buffer(parser, (length)))
+
+/*
+ * Advance the buffer pointer.
+ */
+
+#define SKIP(parser) \
+ (parser->mark.index ++, \
+ parser->mark.column ++, \
+ parser->unread --, \
+ parser->buffer.pointer += WIDTH(parser->buffer))
+
+#define SKIP_LINE(parser) \
+ (IS_CRLF(parser->buffer) ? \
+ (parser->mark.index += 2, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread -= 2, \
+ parser->buffer.pointer += 2) : \
+ IS_BREAK(parser->buffer) ? \
+ (parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --, \
+ parser->buffer.pointer += WIDTH(parser->buffer)) : 0)
+
+/*
+ * Copy a character to a string buffer and advance pointers.
+ */
+
+#define READ(parser,string) \
+ (STRING_EXTEND(parser,string) ? \
+ (COPY(string,parser->buffer), \
+ parser->mark.index ++, \
+ parser->mark.column ++, \
+ parser->unread --, \
+ 1) : 0)
+
+/*
+ * Copy a line break character to a string buffer and advance pointers.
+ */
+
+#define READ_LINE(parser,string) \
+ (STRING_EXTEND(parser,string) ? \
+ (((CHECK_AT(parser->buffer,'\r',0) \
+ && CHECK_AT(parser->buffer,'\n',1)) ? /* CR LF -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer += 2, \
+ parser->mark.index += 2, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread -= 2) : \
+ (CHECK_AT(parser->buffer,'\r',0) \
+ || CHECK_AT(parser->buffer,'\n',0)) ? /* CR|LF -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer ++, \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : \
+ (CHECK_AT(parser->buffer,'\xC2',0) \
+ && CHECK_AT(parser->buffer,'\x85',1)) ? /* NEL -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer += 2, \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : \
+ (CHECK_AT(parser->buffer,'\xE2',0) && \
+ CHECK_AT(parser->buffer,'\x80',1) && \
+ (CHECK_AT(parser->buffer,'\xA8',2) || \
+ CHECK_AT(parser->buffer,'\xA9',2))) ? /* LS|PS -> LS|PS */ \
+ (*((string).pointer++) = *(parser->buffer.pointer++), \
+ *((string).pointer++) = *(parser->buffer.pointer++), \
+ *((string).pointer++) = *(parser->buffer.pointer++), \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : 0), \
+ 1) : 0)
+
+/*
+ * Public API declarations.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
+
+/*
+ * Error handling.
+ */
+
+static int
+yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
+ yaml_mark_t context_mark, const char *problem);
+
+/*
+ * High-level token API.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_next_token(yaml_parser_t *parser);
+
+/*
+ * Potential simple keys.
+ */
+
+static int
+yaml_parser_stale_simple_keys(yaml_parser_t *parser);
+
+static int
+yaml_parser_save_simple_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_remove_simple_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_increase_flow_level(yaml_parser_t *parser);
+
+static int
+yaml_parser_decrease_flow_level(yaml_parser_t *parser);
+
+/*
+ * Indentation treatment.
+ */
+
+static int
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
+
+static int
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
+
+/*
+ * Token fetchers.
+ */
+
+static int
+yaml_parser_fetch_stream_start(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_stream_end(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_directive(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_entry(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_block_entry(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_value(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_tag(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal);
+
+static int
+yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single);
+
+static int
+yaml_parser_fetch_plain_scalar(yaml_parser_t *parser);
+
+/*
+ * Token scanners.
+ */
+
+static int
+yaml_parser_scan_to_next_token(yaml_parser_t *parser);
+
+static int
+yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token);
+
+static int
+yaml_parser_scan_directive_name(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **name);
+
+static int
+yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *major, int *minor);
+
+static int
+yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *number);
+
+static int
+yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
+ yaml_mark_t mark, yaml_char_t **handle, yaml_char_t **prefix);
+
+static int
+yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token);
+
+static int
+yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_char_t **handle);
+
+static int
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
- yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
-
-static int
-yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
- yaml_mark_t start_mark, yaml_string_t *string);
-
-static int
-yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
- int literal);
-
-static int
-yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
- int *indent, yaml_string_t *breaks,
- yaml_mark_t start_mark, yaml_mark_t *end_mark);
-
-static int
-yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
- int single);
-
-static int
-yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token);
-
-/*
- * Get the next token.
- */
-
-YAML_DECLARE(int)
-yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
-{
- assert(parser); /* Non-NULL parser object is expected. */
- assert(token); /* Non-NULL token object is expected. */
-
- /* Erase the token object. */
-
- memset(token, 0, sizeof(yaml_token_t));
-
- /* No tokens after STREAM-END or error. */
-
- if (parser->stream_end_produced || parser->error) {
- return 1;
- }
-
- /* Ensure that the tokens queue contains enough tokens. */
-
- if (!parser->token_available) {
- if (!yaml_parser_fetch_more_tokens(parser))
- return 0;
- }
-
- /* Fetch the next token from the queue. */
-
- *token = DEQUEUE(parser, parser->tokens);
- parser->token_available = 0;
- parser->tokens_parsed ++;
-
- if (token->type == YAML_STREAM_END_TOKEN) {
- parser->stream_end_produced = 1;
- }
-
- return 1;
-}
-
-/*
- * Set the scanner error and return 0.
- */
-
-static int
-yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
- yaml_mark_t context_mark, const char *problem)
-{
- parser->error = YAML_SCANNER_ERROR;
- parser->context = context;
- parser->context_mark = context_mark;
- parser->problem = problem;
- parser->problem_mark = parser->mark;
-
- return 0;
-}
-
-/*
- * Ensure that the tokens queue contains at least one token which can be
- * returned to the Parser.
- */
-
-YAML_DECLARE(int)
-yaml_parser_fetch_more_tokens(yaml_parser_t *parser)
-{
- int need_more_tokens;
-
- /* While we need more tokens to fetch, do it. */
-
- while (1)
- {
- /*
- * Check if we really need to fetch more tokens.
- */
-
- need_more_tokens = 0;
-
- if (parser->tokens.head == parser->tokens.tail)
- {
- /* Queue is empty. */
-
- need_more_tokens = 1;
- }
- else
- {
- yaml_simple_key_t *simple_key;
-
- /* Check if any potential simple key may occupy the head position. */
-
- if (!yaml_parser_stale_simple_keys(parser))
- return 0;
-
- for (simple_key = parser->simple_keys.start;
- simple_key != parser->simple_keys.top; simple_key++) {
- if (simple_key->possible
- && simple_key->token_number == parser->tokens_parsed) {
- need_more_tokens = 1;
- break;
- }
- }
- }
-
- /* We are finished. */
-
- if (!need_more_tokens)
- break;
-
- /* Fetch the next token. */
-
- if (!yaml_parser_fetch_next_token(parser))
- return 0;
- }
-
- parser->token_available = 1;
-
- return 1;
-}
-
-/*
- * The dispatcher for token fetchers.
- */
-
-static int
-yaml_parser_fetch_next_token(yaml_parser_t *parser)
-{
- /* Ensure that the buffer is initialized. */
-
- if (!CACHE(parser, 1))
- return 0;
-
- /* Check if we just started scanning. Fetch STREAM-START then. */
-
- if (!parser->stream_start_produced)
- return yaml_parser_fetch_stream_start(parser);
-
- /* Eat whitespaces and comments until we reach the next token. */
-
- if (!yaml_parser_scan_to_next_token(parser))
- return 0;
-
- /* Remove obsolete potential simple keys. */
-
- if (!yaml_parser_stale_simple_keys(parser))
- return 0;
-
- /* Check the indentation level against the current column. */
-
- if (!yaml_parser_unroll_indent(parser, parser->mark.column))
- return 0;
-
- /*
- * Ensure that the buffer contains at least 4 characters. 4 is the length
- * of the longest indicators ('--- ' and '... ').
- */
-
- if (!CACHE(parser, 4))
- return 0;
-
- /* Is it the end of the stream? */
-
- if (IS_Z(parser->buffer))
- return yaml_parser_fetch_stream_end(parser);
-
- /* Is it a directive? */
-
- if (parser->mark.column == 0 && CHECK(parser->buffer, '%'))
- return yaml_parser_fetch_directive(parser);
-
- /* Is it the document start indicator? */
-
- if (parser->mark.column == 0
- && CHECK_AT(parser->buffer, '-', 0)
- && CHECK_AT(parser->buffer, '-', 1)
- && CHECK_AT(parser->buffer, '-', 2)
- && IS_BLANKZ_AT(parser->buffer, 3))
- return yaml_parser_fetch_document_indicator(parser,
- YAML_DOCUMENT_START_TOKEN);
-
- /* Is it the document end indicator? */
-
- if (parser->mark.column == 0
- && CHECK_AT(parser->buffer, '.', 0)
- && CHECK_AT(parser->buffer, '.', 1)
- && CHECK_AT(parser->buffer, '.', 2)
- && IS_BLANKZ_AT(parser->buffer, 3))
- return yaml_parser_fetch_document_indicator(parser,
- YAML_DOCUMENT_END_TOKEN);
-
- /* Is it the flow sequence start indicator? */
-
- if (CHECK(parser->buffer, '['))
- return yaml_parser_fetch_flow_collection_start(parser,
- YAML_FLOW_SEQUENCE_START_TOKEN);
-
- /* Is it the flow mapping start indicator? */
-
- if (CHECK(parser->buffer, '{'))
- return yaml_parser_fetch_flow_collection_start(parser,
- YAML_FLOW_MAPPING_START_TOKEN);
-
- /* Is it the flow sequence end indicator? */
-
- if (CHECK(parser->buffer, ']'))
- return yaml_parser_fetch_flow_collection_end(parser,
- YAML_FLOW_SEQUENCE_END_TOKEN);
-
- /* Is it the flow mapping end indicator? */
-
- if (CHECK(parser->buffer, '}'))
- return yaml_parser_fetch_flow_collection_end(parser,
- YAML_FLOW_MAPPING_END_TOKEN);
-
- /* Is it the flow entry indicator? */
-
- if (CHECK(parser->buffer, ','))
- return yaml_parser_fetch_flow_entry(parser);
-
- /* Is it the block entry indicator? */
-
- if (CHECK(parser->buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))
- return yaml_parser_fetch_block_entry(parser);
-
- /* Is it the key indicator? */
-
- if (CHECK(parser->buffer, '?')
- && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
- return yaml_parser_fetch_key(parser);
-
- /* Is it the value indicator? */
-
- if (CHECK(parser->buffer, ':')
- && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
- return yaml_parser_fetch_value(parser);
-
- /* Is it an alias? */
-
- if (CHECK(parser->buffer, '*'))
- return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
-
- /* Is it an anchor? */
-
- if (CHECK(parser->buffer, '&'))
- return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
-
- /* Is it a tag? */
-
- if (CHECK(parser->buffer, '!'))
- return yaml_parser_fetch_tag(parser);
-
- /* Is it a literal scalar? */
-
- if (CHECK(parser->buffer, '|') && !parser->flow_level)
- return yaml_parser_fetch_block_scalar(parser, 1);
-
- /* Is it a folded scalar? */
-
- if (CHECK(parser->buffer, '>') && !parser->flow_level)
- return yaml_parser_fetch_block_scalar(parser, 0);
-
- /* Is it a single-quoted scalar? */
-
- if (CHECK(parser->buffer, '\''))
- return yaml_parser_fetch_flow_scalar(parser, 1);
-
- /* Is it a double-quoted scalar? */
-
- if (CHECK(parser->buffer, '"'))
- return yaml_parser_fetch_flow_scalar(parser, 0);
-
- /*
- * Is it a plain scalar?
- *
- * A plain scalar may start with any non-blank characters except
- *
- * '-', '?', ':', ',', '[', ']', '{', '}',
- * '#', '&', '*', '!', '|', '>', '\'', '\"',
- * '%', '@', '`'.
- *
- * In the block context (and, for the '-' indicator, in the flow context
- * too), it may also start with the characters
- *
- * '-', '?', ':'
- *
- * if it is followed by a non-space character.
- *
- * The last rule is more restrictive than the specification requires.
- */
-
- if (!(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '-')
- || CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':')
- || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '[')
- || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
- || CHECK(parser->buffer, '}') || CHECK(parser->buffer, '#')
- || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '*')
- || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '|')
- || CHECK(parser->buffer, '>') || CHECK(parser->buffer, '\'')
- || CHECK(parser->buffer, '"') || CHECK(parser->buffer, '%')
- || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '`')) ||
- (CHECK(parser->buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||
- (!parser->flow_level &&
- (CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':'))
- && !IS_BLANKZ_AT(parser->buffer, 1)))
- return yaml_parser_fetch_plain_scalar(parser);
-
- /*
- * If we don't determine the token type so far, it is an error.
- */
-
- return yaml_parser_set_scanner_error(parser,
- "while scanning for the next token", parser->mark,
- "found character that cannot start any token");
-}
-
-/*
- * Check the list of potential simple keys and remove the positions that
- * cannot contain simple keys anymore.
- */
-
-static int
-yaml_parser_stale_simple_keys(yaml_parser_t *parser)
-{
- yaml_simple_key_t *simple_key;
-
- /* Check for a potential simple key for each flow level. */
-
- for (simple_key = parser->simple_keys.start;
- simple_key != parser->simple_keys.top; simple_key ++)
- {
- /*
- * The specification requires that a simple key
- *
- * - is limited to a single line,
- * - is shorter than 1024 characters.
- */
-
- if (simple_key->possible
- && (simple_key->mark.line < parser->mark.line
- || simple_key->mark.index+1024 < parser->mark.index)) {
-
- /* Check if the potential simple key to be removed is required. */
-
- if (simple_key->required) {
- return yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", simple_key->mark,
- "could not find expected ':'");
- }
-
- simple_key->possible = 0;
- }
- }
-
- return 1;
-}
-
-/*
- * Check if a simple key may start at the current position and add it if
- * needed.
- */
-
-static int
-yaml_parser_save_simple_key(yaml_parser_t *parser)
-{
- /*
- * A simple key is required at the current position if the scanner is in
- * the block context and the current column coincides with the indentation
- * level.
- */
-
- int required = (!parser->flow_level
- && parser->indent == (ptrdiff_t)parser->mark.column);
-
- /*
- * If the current position may start a simple key, save it.
- */
-
- if (parser->simple_key_allowed)
- {
- yaml_simple_key_t simple_key;
- simple_key.possible = 1;
- simple_key.required = required;
+ yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
+
+static int
+yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_string_t *string);
+
+static int
+yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int literal);
+
+static int
+yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
+ int *indent, yaml_string_t *breaks,
+ yaml_mark_t start_mark, yaml_mark_t *end_mark);
+
+static int
+yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int single);
+
+static int
+yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token);
+
+/*
+ * Get the next token.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
+{
+ assert(parser); /* Non-NULL parser object is expected. */
+ assert(token); /* Non-NULL token object is expected. */
+
+ /* Erase the token object. */
+
+ memset(token, 0, sizeof(yaml_token_t));
+
+ /* No tokens after STREAM-END or error. */
+
+ if (parser->stream_end_produced || parser->error) {
+ return 1;
+ }
+
+ /* Ensure that the tokens queue contains enough tokens. */
+
+ if (!parser->token_available) {
+ if (!yaml_parser_fetch_more_tokens(parser))
+ return 0;
+ }
+
+ /* Fetch the next token from the queue. */
+
+ *token = DEQUEUE(parser, parser->tokens);
+ parser->token_available = 0;
+ parser->tokens_parsed ++;
+
+ if (token->type == YAML_STREAM_END_TOKEN) {
+ parser->stream_end_produced = 1;
+ }
+
+ return 1;
+}
+
+/*
+ * Set the scanner error and return 0.
+ */
+
+static int
+yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
+ yaml_mark_t context_mark, const char *problem)
+{
+ parser->error = YAML_SCANNER_ERROR;
+ parser->context = context;
+ parser->context_mark = context_mark;
+ parser->problem = problem;
+ parser->problem_mark = parser->mark;
+
+ return 0;
+}
+
+/*
+ * Ensure that the tokens queue contains at least one token which can be
+ * returned to the Parser.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_fetch_more_tokens(yaml_parser_t *parser)
+{
+ int need_more_tokens;
+
+ /* While we need more tokens to fetch, do it. */
+
+ while (1)
+ {
+ /*
+ * Check if we really need to fetch more tokens.
+ */
+
+ need_more_tokens = 0;
+
+ if (parser->tokens.head == parser->tokens.tail)
+ {
+ /* Queue is empty. */
+
+ need_more_tokens = 1;
+ }
+ else
+ {
+ yaml_simple_key_t *simple_key;
+
+ /* Check if any potential simple key may occupy the head position. */
+
+ if (!yaml_parser_stale_simple_keys(parser))
+ return 0;
+
+ for (simple_key = parser->simple_keys.start;
+ simple_key != parser->simple_keys.top; simple_key++) {
+ if (simple_key->possible
+ && simple_key->token_number == parser->tokens_parsed) {
+ need_more_tokens = 1;
+ break;
+ }
+ }
+ }
+
+ /* We are finished. */
+
+ if (!need_more_tokens)
+ break;
+
+ /* Fetch the next token. */
+
+ if (!yaml_parser_fetch_next_token(parser))
+ return 0;
+ }
+
+ parser->token_available = 1;
+
+ return 1;
+}
+
+/*
+ * The dispatcher for token fetchers.
+ */
+
+static int
+yaml_parser_fetch_next_token(yaml_parser_t *parser)
+{
+ /* Ensure that the buffer is initialized. */
+
+ if (!CACHE(parser, 1))
+ return 0;
+
+ /* Check if we just started scanning. Fetch STREAM-START then. */
+
+ if (!parser->stream_start_produced)
+ return yaml_parser_fetch_stream_start(parser);
+
+ /* Eat whitespaces and comments until we reach the next token. */
+
+ if (!yaml_parser_scan_to_next_token(parser))
+ return 0;
+
+ /* Remove obsolete potential simple keys. */
+
+ if (!yaml_parser_stale_simple_keys(parser))
+ return 0;
+
+ /* Check the indentation level against the current column. */
+
+ if (!yaml_parser_unroll_indent(parser, parser->mark.column))
+ return 0;
+
+ /*
+ * Ensure that the buffer contains at least 4 characters. 4 is the length
+ * of the longest indicators ('--- ' and '... ').
+ */
+
+ if (!CACHE(parser, 4))
+ return 0;
+
+ /* Is it the end of the stream? */
+
+ if (IS_Z(parser->buffer))
+ return yaml_parser_fetch_stream_end(parser);
+
+ /* Is it a directive? */
+
+ if (parser->mark.column == 0 && CHECK(parser->buffer, '%'))
+ return yaml_parser_fetch_directive(parser);
+
+ /* Is it the document start indicator? */
+
+ if (parser->mark.column == 0
+ && CHECK_AT(parser->buffer, '-', 0)
+ && CHECK_AT(parser->buffer, '-', 1)
+ && CHECK_AT(parser->buffer, '-', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
+ return yaml_parser_fetch_document_indicator(parser,
+ YAML_DOCUMENT_START_TOKEN);
+
+ /* Is it the document end indicator? */
+
+ if (parser->mark.column == 0
+ && CHECK_AT(parser->buffer, '.', 0)
+ && CHECK_AT(parser->buffer, '.', 1)
+ && CHECK_AT(parser->buffer, '.', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
+ return yaml_parser_fetch_document_indicator(parser,
+ YAML_DOCUMENT_END_TOKEN);
+
+ /* Is it the flow sequence start indicator? */
+
+ if (CHECK(parser->buffer, '['))
+ return yaml_parser_fetch_flow_collection_start(parser,
+ YAML_FLOW_SEQUENCE_START_TOKEN);
+
+ /* Is it the flow mapping start indicator? */
+
+ if (CHECK(parser->buffer, '{'))
+ return yaml_parser_fetch_flow_collection_start(parser,
+ YAML_FLOW_MAPPING_START_TOKEN);
+
+ /* Is it the flow sequence end indicator? */
+
+ if (CHECK(parser->buffer, ']'))
+ return yaml_parser_fetch_flow_collection_end(parser,
+ YAML_FLOW_SEQUENCE_END_TOKEN);
+
+ /* Is it the flow mapping end indicator? */
+
+ if (CHECK(parser->buffer, '}'))
+ return yaml_parser_fetch_flow_collection_end(parser,
+ YAML_FLOW_MAPPING_END_TOKEN);
+
+ /* Is it the flow entry indicator? */
+
+ if (CHECK(parser->buffer, ','))
+ return yaml_parser_fetch_flow_entry(parser);
+
+ /* Is it the block entry indicator? */
+
+ if (CHECK(parser->buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))
+ return yaml_parser_fetch_block_entry(parser);
+
+ /* Is it the key indicator? */
+
+ if (CHECK(parser->buffer, '?')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_key(parser);
+
+ /* Is it the value indicator? */
+
+ if (CHECK(parser->buffer, ':')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_value(parser);
+
+ /* Is it an alias? */
+
+ if (CHECK(parser->buffer, '*'))
+ return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
+
+ /* Is it an anchor? */
+
+ if (CHECK(parser->buffer, '&'))
+ return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
+
+ /* Is it a tag? */
+
+ if (CHECK(parser->buffer, '!'))
+ return yaml_parser_fetch_tag(parser);
+
+ /* Is it a literal scalar? */
+
+ if (CHECK(parser->buffer, '|') && !parser->flow_level)
+ return yaml_parser_fetch_block_scalar(parser, 1);
+
+ /* Is it a folded scalar? */
+
+ if (CHECK(parser->buffer, '>') && !parser->flow_level)
+ return yaml_parser_fetch_block_scalar(parser, 0);
+
+ /* Is it a single-quoted scalar? */
+
+ if (CHECK(parser->buffer, '\''))
+ return yaml_parser_fetch_flow_scalar(parser, 1);
+
+ /* Is it a double-quoted scalar? */
+
+ if (CHECK(parser->buffer, '"'))
+ return yaml_parser_fetch_flow_scalar(parser, 0);
+
+ /*
+ * Is it a plain scalar?
+ *
+ * A plain scalar may start with any non-blank characters except
+ *
+ * '-', '?', ':', ',', '[', ']', '{', '}',
+ * '#', '&', '*', '!', '|', '>', '\'', '\"',
+ * '%', '@', '`'.
+ *
+ * In the block context (and, for the '-' indicator, in the flow context
+ * too), it may also start with the characters
+ *
+ * '-', '?', ':'
+ *
+ * if it is followed by a non-space character.
+ *
+ * The last rule is more restrictive than the specification requires.
+ */
+
+ if (!(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '-')
+ || CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':')
+ || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '[')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}') || CHECK(parser->buffer, '#')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '*')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '|')
+ || CHECK(parser->buffer, '>') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '"') || CHECK(parser->buffer, '%')
+ || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '`')) ||
+ (CHECK(parser->buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||
+ (!parser->flow_level &&
+ (CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':'))
+ && !IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_plain_scalar(parser);
+
+ /*
+ * If we don't determine the token type so far, it is an error.
+ */
+
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning for the next token", parser->mark,
+ "found character that cannot start any token");
+}
+
+/*
+ * Check the list of potential simple keys and remove the positions that
+ * cannot contain simple keys anymore.
+ */
+
+static int
+yaml_parser_stale_simple_keys(yaml_parser_t *parser)
+{
+ yaml_simple_key_t *simple_key;
+
+ /* Check for a potential simple key for each flow level. */
+
+ for (simple_key = parser->simple_keys.start;
+ simple_key != parser->simple_keys.top; simple_key ++)
+ {
+ /*
+ * The specification requires that a simple key
+ *
+ * - is limited to a single line,
+ * - is shorter than 1024 characters.
+ */
+
+ if (simple_key->possible
+ && (simple_key->mark.line < parser->mark.line
+ || simple_key->mark.index+1024 < parser->mark.index)) {
+
+ /* Check if the potential simple key to be removed is required. */
+
+ if (simple_key->required) {
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning a simple key", simple_key->mark,
+ "could not find expected ':'");
+ }
+
+ simple_key->possible = 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Check if a simple key may start at the current position and add it if
+ * needed.
+ */
+
+static int
+yaml_parser_save_simple_key(yaml_parser_t *parser)
+{
+ /*
+ * A simple key is required at the current position if the scanner is in
+ * the block context and the current column coincides with the indentation
+ * level.
+ */
+
+ int required = (!parser->flow_level
+ && parser->indent == (ptrdiff_t)parser->mark.column);
+
+ /*
+ * If the current position may start a simple key, save it.
+ */
+
+ if (parser->simple_key_allowed)
+ {
+ yaml_simple_key_t simple_key;
+ simple_key.possible = 1;
+ simple_key.required = required;
simple_key.token_number =
- parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
- simple_key.mark = parser->mark;
-
- if (!yaml_parser_remove_simple_key(parser)) return 0;
-
- *(parser->simple_keys.top-1) = simple_key;
- }
-
- return 1;
-}
-
-/*
- * Remove a potential simple key at the current flow level.
- */
-
-static int
-yaml_parser_remove_simple_key(yaml_parser_t *parser)
-{
- yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
-
- if (simple_key->possible)
- {
- /* If the key is required, it is an error. */
-
- if (simple_key->required) {
- return yaml_parser_set_scanner_error(parser,
- "while scanning a simple key", simple_key->mark,
- "could not find expected ':'");
- }
- }
-
- /* Remove the key from the stack. */
-
- simple_key->possible = 0;
-
- return 1;
-}
-
-/*
- * Increase the flow level and resize the simple key list if needed.
- */
-
-static int
-yaml_parser_increase_flow_level(yaml_parser_t *parser)
-{
- yaml_simple_key_t empty_simple_key = { 0, 0, 0, { 0, 0, 0 } };
-
- /* Reset the simple key on the next level. */
-
- if (!PUSH(parser, parser->simple_keys, empty_simple_key))
- return 0;
-
- /* Increase the flow level. */
-
- if (parser->flow_level == INT_MAX) {
- parser->error = YAML_MEMORY_ERROR;
- return 0;
- }
-
- parser->flow_level++;
-
- return 1;
-}
-
-/*
- * Decrease the flow level.
- */
-
-static int
-yaml_parser_decrease_flow_level(yaml_parser_t *parser)
-{
- if (parser->flow_level) {
- parser->flow_level --;
+ parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
+ simple_key.mark = parser->mark;
+
+ if (!yaml_parser_remove_simple_key(parser)) return 0;
+
+ *(parser->simple_keys.top-1) = simple_key;
+ }
+
+ return 1;
+}
+
+/*
+ * Remove a potential simple key at the current flow level.
+ */
+
+static int
+yaml_parser_remove_simple_key(yaml_parser_t *parser)
+{
+ yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
+
+ if (simple_key->possible)
+ {
+ /* If the key is required, it is an error. */
+
+ if (simple_key->required) {
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning a simple key", simple_key->mark,
+ "could not find expected ':'");
+ }
+ }
+
+ /* Remove the key from the stack. */
+
+ simple_key->possible = 0;
+
+ return 1;
+}
+
+/*
+ * Increase the flow level and resize the simple key list if needed.
+ */
+
+static int
+yaml_parser_increase_flow_level(yaml_parser_t *parser)
+{
+ yaml_simple_key_t empty_simple_key = { 0, 0, 0, { 0, 0, 0 } };
+
+ /* Reset the simple key on the next level. */
+
+ if (!PUSH(parser, parser->simple_keys, empty_simple_key))
+ return 0;
+
+ /* Increase the flow level. */
+
+ if (parser->flow_level == INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+
+ parser->flow_level++;
+
+ return 1;
+}
+
+/*
+ * Decrease the flow level.
+ */
+
+static int
+yaml_parser_decrease_flow_level(yaml_parser_t *parser)
+{
+ if (parser->flow_level) {
+ parser->flow_level --;
(void)POP(parser, parser->simple_keys);
- }
-
- return 1;
-}
-
-/*
- * Push the current indentation level to the stack and set the new level
- * the current column is greater than the indentation level. In this case,
- * append or insert the specified token into the token queue.
- *
- */
-
-static int
-yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
- ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
-{
- yaml_token_t token;
-
- /* In the flow context, do nothing. */
-
- if (parser->flow_level)
- return 1;
-
- if (parser->indent < column)
- {
- /*
- * Push the current indentation level to the stack and set the new
- * indentation level.
- */
-
- if (!PUSH(parser, parser->indents, parser->indent))
- return 0;
-
- if (column > INT_MAX) {
- parser->error = YAML_MEMORY_ERROR;
- return 0;
- }
-
- parser->indent = column;
-
- /* Create a token and insert it into the queue. */
-
- TOKEN_INIT(token, type, mark, mark);
-
- if (number == -1) {
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
- }
- else {
- if (!QUEUE_INSERT(parser,
- parser->tokens, number - parser->tokens_parsed, token))
- return 0;
- }
- }
-
- return 1;
-}
-
-/*
- * Pop indentation levels from the indents stack until the current level
+ }
+
+ return 1;
+}
+
+/*
+ * Push the current indentation level to the stack and set the new level
+ * the current column is greater than the indentation level. In this case,
+ * append or insert the specified token into the token queue.
+ *
+ */
+
+static int
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
+{
+ yaml_token_t token;
+
+ /* In the flow context, do nothing. */
+
+ if (parser->flow_level)
+ return 1;
+
+ if (parser->indent < column)
+ {
+ /*
+ * Push the current indentation level to the stack and set the new
+ * indentation level.
+ */
+
+ if (!PUSH(parser, parser->indents, parser->indent))
+ return 0;
+
+ if (column > INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+
+ parser->indent = column;
+
+ /* Create a token and insert it into the queue. */
+
+ TOKEN_INIT(token, type, mark, mark);
+
+ if (number == -1) {
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+ }
+ else {
+ if (!QUEUE_INSERT(parser,
+ parser->tokens, number - parser->tokens_parsed, token))
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Pop indentation levels from the indents stack until the current level
* becomes less or equal to the column. For each indentation level, append
- * the BLOCK-END token.
- */
-
-
-static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
-{
- yaml_token_t token;
-
- /* In the flow context, do nothing. */
-
- if (parser->flow_level)
- return 1;
-
+ * the BLOCK-END token.
+ */
+
+
+static int
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
+{
+ yaml_token_t token;
+
+ /* In the flow context, do nothing. */
+
+ if (parser->flow_level)
+ return 1;
+
/* Loop through the indentation levels in the stack. */
-
- while (parser->indent > column)
- {
- /* Create a token and append it to the queue. */
-
- TOKEN_INIT(token, YAML_BLOCK_END_TOKEN, parser->mark, parser->mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- /* Pop the indentation level. */
-
- parser->indent = POP(parser, parser->indents);
- }
-
- return 1;
-}
-
-/*
- * Initialize the scanner and produce the STREAM-START token.
- */
-
-static int
-yaml_parser_fetch_stream_start(yaml_parser_t *parser)
-{
- yaml_simple_key_t simple_key = { 0, 0, 0, { 0, 0, 0 } };
- yaml_token_t token;
-
- /* Set the initial indentation. */
-
- parser->indent = -1;
-
- /* Initialize the simple key stack. */
-
- if (!PUSH(parser, parser->simple_keys, simple_key))
- return 0;
-
- /* A simple key is allowed at the beginning of the stream. */
-
- parser->simple_key_allowed = 1;
-
- /* We have started. */
-
- parser->stream_start_produced = 1;
-
- /* Create the STREAM-START token and append it to the queue. */
-
- STREAM_START_TOKEN_INIT(token, parser->encoding,
- parser->mark, parser->mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the STREAM-END token and shut down the scanner.
- */
-
-static int
-yaml_parser_fetch_stream_end(yaml_parser_t *parser)
-{
- yaml_token_t token;
-
- /* Force new line. */
-
- if (parser->mark.column != 0) {
- parser->mark.column = 0;
- parser->mark.line ++;
- }
-
- /* Reset the indentation level. */
-
- if (!yaml_parser_unroll_indent(parser, -1))
- return 0;
-
- /* Reset simple keys. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- parser->simple_key_allowed = 0;
-
- /* Create the STREAM-END token and append it to the queue. */
-
- STREAM_END_TOKEN_INIT(token, parser->mark, parser->mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
- */
-
-static int
-yaml_parser_fetch_directive(yaml_parser_t *parser)
-{
- yaml_token_t token;
-
- /* Reset the indentation level. */
-
- if (!yaml_parser_unroll_indent(parser, -1))
- return 0;
-
- /* Reset simple keys. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- parser->simple_key_allowed = 0;
-
- /* Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. */
-
- if (!yaml_parser_scan_directive(parser, &token))
- return 0;
-
- /* Append the token to the queue. */
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Produce the DOCUMENT-START or DOCUMENT-END token.
- */
-
-static int
-yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
- yaml_token_type_t type)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* Reset the indentation level. */
-
- if (!yaml_parser_unroll_indent(parser, -1))
- return 0;
-
- /* Reset simple keys. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- parser->simple_key_allowed = 0;
-
- /* Consume the token. */
-
- start_mark = parser->mark;
-
- SKIP(parser);
- SKIP(parser);
- SKIP(parser);
-
- end_mark = parser->mark;
-
- /* Create the DOCUMENT-START or DOCUMENT-END token. */
-
- TOKEN_INIT(token, type, start_mark, end_mark);
-
- /* Append the token to the queue. */
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
- */
-
-static int
-yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
- yaml_token_type_t type)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* The indicators '[' and '{' may start a simple key. */
-
- if (!yaml_parser_save_simple_key(parser))
- return 0;
-
- /* Increase the flow level. */
-
- if (!yaml_parser_increase_flow_level(parser))
- return 0;
-
- /* A simple key may follow the indicators '[' and '{'. */
-
- parser->simple_key_allowed = 1;
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. */
-
- TOKEN_INIT(token, type, start_mark, end_mark);
-
- /* Append the token to the queue. */
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.
- */
-
-static int
-yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
- yaml_token_type_t type)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* Reset any potential simple key on the current flow level. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- /* Decrease the flow level. */
-
- if (!yaml_parser_decrease_flow_level(parser))
- return 0;
-
- /* No simple keys after the indicators ']' and '}'. */
-
- parser->simple_key_allowed = 0;
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. */
-
- TOKEN_INIT(token, type, start_mark, end_mark);
-
- /* Append the token to the queue. */
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the FLOW-ENTRY token.
- */
-
-static int
-yaml_parser_fetch_flow_entry(yaml_parser_t *parser)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* Reset any potential simple keys on the current flow level. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- /* Simple keys are allowed after ','. */
-
- parser->simple_key_allowed = 1;
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the FLOW-ENTRY token and append it to the queue. */
-
- TOKEN_INIT(token, YAML_FLOW_ENTRY_TOKEN, start_mark, end_mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the BLOCK-ENTRY token.
- */
-
-static int
-yaml_parser_fetch_block_entry(yaml_parser_t *parser)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* Check if the scanner is in the block context. */
-
- if (!parser->flow_level)
- {
- /* Check if we are allowed to start a new entry. */
-
- if (!parser->simple_key_allowed) {
- return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
- "block sequence entries are not allowed in this context");
- }
-
- /* Add the BLOCK-SEQUENCE-START token if needed. */
-
- if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
- YAML_BLOCK_SEQUENCE_START_TOKEN, parser->mark))
- return 0;
- }
- else
- {
- /*
- * It is an error for the '-' indicator to occur in the flow context,
- * but we let the Parser detect and report about it because the Parser
- * is able to point to the context.
- */
- }
-
- /* Reset any potential simple keys on the current flow level. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- /* Simple keys are allowed after '-'. */
-
- parser->simple_key_allowed = 1;
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the BLOCK-ENTRY token and append it to the queue. */
-
- TOKEN_INIT(token, YAML_BLOCK_ENTRY_TOKEN, start_mark, end_mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the KEY token.
- */
-
-static int
-yaml_parser_fetch_key(yaml_parser_t *parser)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
-
- /* In the block context, additional checks are required. */
-
- if (!parser->flow_level)
- {
+
+ while (parser->indent > column)
+ {
+ /* Create a token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_BLOCK_END_TOKEN, parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ /* Pop the indentation level. */
+
+ parser->indent = POP(parser, parser->indents);
+ }
+
+ return 1;
+}
+
+/*
+ * Initialize the scanner and produce the STREAM-START token.
+ */
+
+static int
+yaml_parser_fetch_stream_start(yaml_parser_t *parser)
+{
+ yaml_simple_key_t simple_key = { 0, 0, 0, { 0, 0, 0 } };
+ yaml_token_t token;
+
+ /* Set the initial indentation. */
+
+ parser->indent = -1;
+
+ /* Initialize the simple key stack. */
+
+ if (!PUSH(parser, parser->simple_keys, simple_key))
+ return 0;
+
+ /* A simple key is allowed at the beginning of the stream. */
+
+ parser->simple_key_allowed = 1;
+
+ /* We have started. */
+
+ parser->stream_start_produced = 1;
+
+ /* Create the STREAM-START token and append it to the queue. */
+
+ STREAM_START_TOKEN_INIT(token, parser->encoding,
+ parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the STREAM-END token and shut down the scanner.
+ */
+
+static int
+yaml_parser_fetch_stream_end(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* Force new line. */
+
+ if (parser->mark.column != 0) {
+ parser->mark.column = 0;
+ parser->mark.line ++;
+ }
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the STREAM-END token and append it to the queue. */
+
+ STREAM_END_TOKEN_INIT(token, parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
+ */
+
+static int
+yaml_parser_fetch_directive(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. */
+
+ if (!yaml_parser_scan_directive(parser, &token))
+ return 0;
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the DOCUMENT-START or DOCUMENT-END token.
+ */
+
+static int
+yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+ SKIP(parser);
+ SKIP(parser);
+
+ end_mark = parser->mark;
+
+ /* Create the DOCUMENT-START or DOCUMENT-END token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
+ */
+
+static int
+yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* The indicators '[' and '{' may start a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* Increase the flow level. */
+
+ if (!yaml_parser_increase_flow_level(parser))
+ return 0;
+
+ /* A simple key may follow the indicators '[' and '{'. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.
+ */
+
+static int
+yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset any potential simple key on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Decrease the flow level. */
+
+ if (!yaml_parser_decrease_flow_level(parser))
+ return 0;
+
+ /* No simple keys after the indicators ']' and '}'. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-ENTRY token.
+ */
+
+static int
+yaml_parser_fetch_flow_entry(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after ','. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-ENTRY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_FLOW_ENTRY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the BLOCK-ENTRY token.
+ */
+
+static int
+yaml_parser_fetch_block_entry(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Check if the scanner is in the block context. */
+
+ if (!parser->flow_level)
+ {
+ /* Check if we are allowed to start a new entry. */
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "block sequence entries are not allowed in this context");
+ }
+
+ /* Add the BLOCK-SEQUENCE-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_SEQUENCE_START_TOKEN, parser->mark))
+ return 0;
+ }
+ else
+ {
+ /*
+ * It is an error for the '-' indicator to occur in the flow context,
+ * but we let the Parser detect and report about it because the Parser
+ * is able to point to the context.
+ */
+ }
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after '-'. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the BLOCK-ENTRY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_BLOCK_ENTRY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the KEY token.
+ */
+
+static int
+yaml_parser_fetch_key(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* In the block context, additional checks are required. */
+
+ if (!parser->flow_level)
+ {
/* Check if we are allowed to start a new key (not necessary simple). */
-
- if (!parser->simple_key_allowed) {
- return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
- "mapping keys are not allowed in this context");
- }
-
- /* Add the BLOCK-MAPPING-START token if needed. */
-
- if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
- YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
- return 0;
- }
-
- /* Reset any potential simple keys on the current flow level. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- /* Simple keys are allowed after '?' in the block context. */
-
- parser->simple_key_allowed = (!parser->flow_level);
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the KEY token and append it to the queue. */
-
- TOKEN_INIT(token, YAML_KEY_TOKEN, start_mark, end_mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the VALUE token.
- */
-
-static int
-yaml_parser_fetch_value(yaml_parser_t *parser)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_token_t token;
- yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
-
- /* Have we found a simple key? */
-
- if (simple_key->possible)
- {
-
- /* Create the KEY token and insert it into the queue. */
-
- TOKEN_INIT(token, YAML_KEY_TOKEN, simple_key->mark, simple_key->mark);
-
- if (!QUEUE_INSERT(parser, parser->tokens,
- simple_key->token_number - parser->tokens_parsed, token))
- return 0;
-
- /* In the block context, we may need to add the BLOCK-MAPPING-START token. */
-
- if (!yaml_parser_roll_indent(parser, simple_key->mark.column,
- simple_key->token_number,
- YAML_BLOCK_MAPPING_START_TOKEN, simple_key->mark))
- return 0;
-
- /* Remove the simple key. */
-
- simple_key->possible = 0;
-
- /* A simple key cannot follow another simple key. */
-
- parser->simple_key_allowed = 0;
- }
- else
- {
- /* The ':' indicator follows a complex key. */
-
- /* In the block context, extra checks are required. */
-
- if (!parser->flow_level)
- {
- /* Check if we are allowed to start a complex value. */
-
- if (!parser->simple_key_allowed) {
- return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
- "mapping values are not allowed in this context");
- }
-
- /* Add the BLOCK-MAPPING-START token if needed. */
-
- if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
- YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
- return 0;
- }
-
- /* Simple keys after ':' are allowed in the block context. */
-
- parser->simple_key_allowed = (!parser->flow_level);
- }
-
- /* Consume the token. */
-
- start_mark = parser->mark;
- SKIP(parser);
- end_mark = parser->mark;
-
- /* Create the VALUE token and append it to the queue. */
-
- TOKEN_INIT(token, YAML_VALUE_TOKEN, start_mark, end_mark);
-
- if (!ENQUEUE(parser, parser->tokens, token))
- return 0;
-
- return 1;
-}
-
-/*
- * Produce the ALIAS or ANCHOR token.
- */
-
-static int
-yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type)
-{
- yaml_token_t token;
-
- /* An anchor or an alias could be a simple key. */
-
- if (!yaml_parser_save_simple_key(parser))
- return 0;
-
- /* A simple key cannot follow an anchor or an alias. */
-
- parser->simple_key_allowed = 0;
-
- /* Create the ALIAS or ANCHOR token and append it to the queue. */
-
- if (!yaml_parser_scan_anchor(parser, &token, type))
- return 0;
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
- return 1;
-}
-
-/*
- * Produce the TAG token.
- */
-
-static int
-yaml_parser_fetch_tag(yaml_parser_t *parser)
-{
- yaml_token_t token;
-
- /* A tag could be a simple key. */
-
- if (!yaml_parser_save_simple_key(parser))
- return 0;
-
- /* A simple key cannot follow a tag. */
-
- parser->simple_key_allowed = 0;
-
- /* Create the TAG token and append it to the queue. */
-
- if (!yaml_parser_scan_tag(parser, &token))
- return 0;
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.
- */
-
-static int
-yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal)
-{
- yaml_token_t token;
-
- /* Remove any potential simple keys. */
-
- if (!yaml_parser_remove_simple_key(parser))
- return 0;
-
- /* A simple key may follow a block scalar. */
-
- parser->simple_key_allowed = 1;
-
- /* Create the SCALAR token and append it to the queue. */
-
- if (!yaml_parser_scan_block_scalar(parser, &token, literal))
- return 0;
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.
- */
-
-static int
-yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single)
-{
- yaml_token_t token;
-
- /* A plain scalar could be a simple key. */
-
- if (!yaml_parser_save_simple_key(parser))
- return 0;
-
- /* A simple key cannot follow a flow scalar. */
-
- parser->simple_key_allowed = 0;
-
- /* Create the SCALAR token and append it to the queue. */
-
- if (!yaml_parser_scan_flow_scalar(parser, &token, single))
- return 0;
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Produce the SCALAR(...,plain) token.
- */
-
-static int
-yaml_parser_fetch_plain_scalar(yaml_parser_t *parser)
-{
- yaml_token_t token;
-
- /* A plain scalar could be a simple key. */
-
- if (!yaml_parser_save_simple_key(parser))
- return 0;
-
- /* A simple key cannot follow a flow scalar. */
-
- parser->simple_key_allowed = 0;
-
- /* Create the SCALAR token and append it to the queue. */
-
- if (!yaml_parser_scan_plain_scalar(parser, &token))
- return 0;
-
- if (!ENQUEUE(parser, parser->tokens, token)) {
- yaml_token_delete(&token);
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Eat whitespaces and comments until the next token is found.
- */
-
-static int
-yaml_parser_scan_to_next_token(yaml_parser_t *parser)
-{
- /* Until the next token is not found. */
-
- while (1)
- {
- /* Allow the BOM mark to start a line. */
-
- if (!CACHE(parser, 1)) return 0;
-
- if (parser->mark.column == 0 && IS_BOM(parser->buffer))
- SKIP(parser);
-
- /*
- * Eat whitespaces.
- *
- * Tabs are allowed:
- *
- * - in the flow context;
- * - in the block context, but not at the beginning of the line or
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "mapping keys are not allowed in this context");
+ }
+
+ /* Add the BLOCK-MAPPING-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
+ return 0;
+ }
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after '?' in the block context. */
+
+ parser->simple_key_allowed = (!parser->flow_level);
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the KEY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_KEY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the VALUE token.
+ */
+
+static int
+yaml_parser_fetch_value(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+ yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
+
+ /* Have we found a simple key? */
+
+ if (simple_key->possible)
+ {
+
+ /* Create the KEY token and insert it into the queue. */
+
+ TOKEN_INIT(token, YAML_KEY_TOKEN, simple_key->mark, simple_key->mark);
+
+ if (!QUEUE_INSERT(parser, parser->tokens,
+ simple_key->token_number - parser->tokens_parsed, token))
+ return 0;
+
+ /* In the block context, we may need to add the BLOCK-MAPPING-START token. */
+
+ if (!yaml_parser_roll_indent(parser, simple_key->mark.column,
+ simple_key->token_number,
+ YAML_BLOCK_MAPPING_START_TOKEN, simple_key->mark))
+ return 0;
+
+ /* Remove the simple key. */
+
+ simple_key->possible = 0;
+
+ /* A simple key cannot follow another simple key. */
+
+ parser->simple_key_allowed = 0;
+ }
+ else
+ {
+ /* The ':' indicator follows a complex key. */
+
+ /* In the block context, extra checks are required. */
+
+ if (!parser->flow_level)
+ {
+ /* Check if we are allowed to start a complex value. */
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "mapping values are not allowed in this context");
+ }
+
+ /* Add the BLOCK-MAPPING-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
+ return 0;
+ }
+
+ /* Simple keys after ':' are allowed in the block context. */
+
+ parser->simple_key_allowed = (!parser->flow_level);
+ }
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the VALUE token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_VALUE_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the ALIAS or ANCHOR token.
+ */
+
+static int
+yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type)
+{
+ yaml_token_t token;
+
+ /* An anchor or an alias could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow an anchor or an alias. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the ALIAS or ANCHOR token and append it to the queue. */
+
+ if (!yaml_parser_scan_anchor(parser, &token, type))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Produce the TAG token.
+ */
+
+static int
+yaml_parser_fetch_tag(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* A tag could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a tag. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the TAG token and append it to the queue. */
+
+ if (!yaml_parser_scan_tag(parser, &token))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.
+ */
+
+static int
+yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal)
+{
+ yaml_token_t token;
+
+ /* Remove any potential simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* A simple key may follow a block scalar. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_block_scalar(parser, &token, literal))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.
+ */
+
+static int
+yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single)
+{
+ yaml_token_t token;
+
+ /* A plain scalar could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a flow scalar. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_flow_scalar(parser, &token, single))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,plain) token.
+ */
+
+static int
+yaml_parser_fetch_plain_scalar(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* A plain scalar could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a flow scalar. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_plain_scalar(parser, &token))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Eat whitespaces and comments until the next token is found.
+ */
+
+static int
+yaml_parser_scan_to_next_token(yaml_parser_t *parser)
+{
+ /* Until the next token is not found. */
+
+ while (1)
+ {
+ /* Allow the BOM mark to start a line. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ if (parser->mark.column == 0 && IS_BOM(parser->buffer))
+ SKIP(parser);
+
+ /*
+ * Eat whitespaces.
+ *
+ * Tabs are allowed:
+ *
+ * - in the flow context;
+ * - in the block context, but not at the beginning of the line or
* after '-', '?', or ':' (complex value).
- */
-
- if (!CACHE(parser, 1)) return 0;
-
- while (CHECK(parser->buffer,' ') ||
- ((parser->flow_level || !parser->simple_key_allowed) &&
- CHECK(parser->buffer, '\t'))) {
- SKIP(parser);
- if (!CACHE(parser, 1)) return 0;
- }
-
- /* Eat a comment until a line break. */
-
- if (CHECK(parser->buffer, '#')) {
- while (!IS_BREAKZ(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) return 0;
- }
- }
-
- /* If it is a line break, eat it. */
-
- if (IS_BREAK(parser->buffer))
- {
- if (!CACHE(parser, 2)) return 0;
- SKIP_LINE(parser);
-
- /* In the block context, a new line may start a simple key. */
-
- if (!parser->flow_level) {
- parser->simple_key_allowed = 1;
- }
- }
- else
- {
- /* We have found a token. */
-
- break;
- }
- }
-
- return 1;
-}
-
-/*
- * Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.
- *
- * Scope:
- * %YAML 1.1 # a comment \n
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * %TAG !yaml! tag:yaml.org,2002: \n
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- */
-
-int
-yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
-{
- yaml_mark_t start_mark, end_mark;
- yaml_char_t *name = NULL;
- int major, minor;
- yaml_char_t *handle = NULL, *prefix = NULL;
-
- /* Eat '%'. */
-
- start_mark = parser->mark;
-
- SKIP(parser);
-
- /* Scan the directive name. */
-
- if (!yaml_parser_scan_directive_name(parser, start_mark, &name))
- goto error;
-
- /* Is it a YAML directive? */
-
- if (strcmp((char *)name, "YAML") == 0)
- {
- /* Scan the VERSION directive value. */
-
- if (!yaml_parser_scan_version_directive_value(parser, start_mark,
- &major, &minor))
- goto error;
-
- end_mark = parser->mark;
-
- /* Create a VERSION-DIRECTIVE token. */
-
- VERSION_DIRECTIVE_TOKEN_INIT(*token, major, minor,
- start_mark, end_mark);
- }
-
- /* Is it a TAG directive? */
-
- else if (strcmp((char *)name, "TAG") == 0)
- {
- /* Scan the TAG directive value. */
-
- if (!yaml_parser_scan_tag_directive_value(parser, start_mark,
- &handle, &prefix))
- goto error;
-
- end_mark = parser->mark;
-
- /* Create a TAG-DIRECTIVE token. */
-
- TAG_DIRECTIVE_TOKEN_INIT(*token, handle, prefix,
- start_mark, end_mark);
- }
-
- /* Unknown directive. */
-
- else
- {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (CHECK(parser->buffer,' ') ||
+ ((parser->flow_level || !parser->simple_key_allowed) &&
+ CHECK(parser->buffer, '\t'))) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Eat a comment until a line break. */
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+ }
+
+ /* If it is a line break, eat it. */
+
+ if (IS_BREAK(parser->buffer))
+ {
+ if (!CACHE(parser, 2)) return 0;
+ SKIP_LINE(parser);
+
+ /* In the block context, a new line may start a simple key. */
+
+ if (!parser->flow_level) {
+ parser->simple_key_allowed = 1;
+ }
+ }
+ else
+ {
+ /* We have found a token. */
+
+ break;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ */
+
+int
+yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_char_t *name = NULL;
+ int major, minor;
+ yaml_char_t *handle = NULL, *prefix = NULL;
+
+ /* Eat '%'. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Scan the directive name. */
+
+ if (!yaml_parser_scan_directive_name(parser, start_mark, &name))
+ goto error;
+
+ /* Is it a YAML directive? */
+
+ if (strcmp((char *)name, "YAML") == 0)
+ {
+ /* Scan the VERSION directive value. */
+
+ if (!yaml_parser_scan_version_directive_value(parser, start_mark,
+ &major, &minor))
+ goto error;
+
+ end_mark = parser->mark;
+
+ /* Create a VERSION-DIRECTIVE token. */
+
+ VERSION_DIRECTIVE_TOKEN_INIT(*token, major, minor,
+ start_mark, end_mark);
+ }
+
+ /* Is it a TAG directive? */
+
+ else if (strcmp((char *)name, "TAG") == 0)
+ {
+ /* Scan the TAG directive value. */
+
+ if (!yaml_parser_scan_tag_directive_value(parser, start_mark,
+ &handle, &prefix))
+ goto error;
+
+ end_mark = parser->mark;
+
+ /* Create a TAG-DIRECTIVE token. */
+
+ TAG_DIRECTIVE_TOKEN_INIT(*token, handle, prefix,
+ start_mark, end_mark);
+ }
+
+ /* Unknown directive. */
+
+ else
+ {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
start_mark, "found unknown directive name");
- goto error;
- }
-
- /* Eat the rest of the line including any comments. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_BLANK(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
-
- if (CHECK(parser->buffer, '#')) {
- while (!IS_BREAKZ(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
- }
-
- /* Check if we are at the end of the line. */
-
- if (!IS_BREAKZ(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "did not find expected comment or line break");
- goto error;
- }
-
- /* Eat a line break. */
-
- if (IS_BREAK(parser->buffer)) {
- if (!CACHE(parser, 2)) goto error;
- SKIP_LINE(parser);
- }
-
- yaml_free(name);
-
- return 1;
-
-error:
- yaml_free(prefix);
- yaml_free(handle);
- yaml_free(name);
- return 0;
-}
-
-/*
- * Scan the directive name.
- *
- * Scope:
- * %YAML 1.1 # a comment \n
- * ^^^^
- * %TAG !yaml! tag:yaml.org,2002: \n
- * ^^^
- */
-
-static int
-yaml_parser_scan_directive_name(yaml_parser_t *parser,
- yaml_mark_t start_mark, yaml_char_t **name)
-{
- yaml_string_t string = NULL_STRING;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
-
- /* Consume the directive name. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_ALPHA(parser->buffer))
- {
- if (!READ(parser, string)) goto error;
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Check if the name is empty. */
-
- if (string.start == string.pointer) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "could not find expected directive name");
- goto error;
- }
-
- /* Check for an blank character after the name. */
-
- if (!IS_BLANKZ(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found unexpected non-alphabetical character");
- goto error;
- }
-
- *name = string.start;
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- return 0;
-}
-
-/*
- * Scan the value of VERSION-DIRECTIVE.
- *
- * Scope:
- * %YAML 1.1 # a comment \n
- * ^^^^^^
- */
-
-static int
-yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
- yaml_mark_t start_mark, int *major, int *minor)
-{
- /* Eat whitespaces. */
-
- if (!CACHE(parser, 1)) return 0;
-
- while (IS_BLANK(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) return 0;
- }
-
- /* Consume the major version number. */
-
- if (!yaml_parser_scan_version_directive_number(parser, start_mark, major))
- return 0;
-
- /* Eat '.'. */
-
- if (!CHECK(parser->buffer, '.')) {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected digit or '.' character");
- }
-
- SKIP(parser);
-
- /* Consume the minor version number. */
-
- if (!yaml_parser_scan_version_directive_number(parser, start_mark, minor))
- return 0;
-
- return 1;
-}
-
-#define MAX_NUMBER_LENGTH 9
-
-/*
- * Scan the version number of VERSION-DIRECTIVE.
- *
- * Scope:
- * %YAML 1.1 # a comment \n
- * ^
- * %YAML 1.1 # a comment \n
- * ^
- */
-
-static int
-yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
- yaml_mark_t start_mark, int *number)
-{
- int value = 0;
- size_t length = 0;
-
- /* Repeat while the next character is digit. */
-
- if (!CACHE(parser, 1)) return 0;
-
- while (IS_DIGIT(parser->buffer))
- {
- /* Check if the number is too long. */
-
- if (++length > MAX_NUMBER_LENGTH) {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "found extremely long version number");
- }
-
- value = value*10 + AS_DIGIT(parser->buffer);
-
- SKIP(parser);
-
- if (!CACHE(parser, 1)) return 0;
- }
-
- /* Check if the number was present. */
-
- if (!length) {
- return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
- start_mark, "did not find expected version number");
- }
-
- *number = value;
-
- return 1;
-}
-
-/*
- * Scan the value of a TAG-DIRECTIVE token.
- *
- * Scope:
- * %TAG !yaml! tag:yaml.org,2002: \n
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- */
-
-static int
-yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
- yaml_mark_t start_mark, yaml_char_t **handle, yaml_char_t **prefix)
-{
- yaml_char_t *handle_value = NULL;
- yaml_char_t *prefix_value = NULL;
-
- /* Eat whitespaces. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_BLANK(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Scan a handle. */
-
- if (!yaml_parser_scan_tag_handle(parser, 1, start_mark, &handle_value))
- goto error;
-
- /* Expect a whitespace. */
-
- if (!CACHE(parser, 1)) goto error;
-
- if (!IS_BLANK(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace");
- goto error;
- }
-
- /* Eat whitespaces. */
-
- while (IS_BLANK(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Scan a prefix. */
-
+ goto error;
+ }
+
+ /* Eat the rest of the line including any comments. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+ }
+
+ /* Check if we are at the end of the line. */
+
+ if (!IS_BREAKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "did not find expected comment or line break");
+ goto error;
+ }
+
+ /* Eat a line break. */
+
+ if (IS_BREAK(parser->buffer)) {
+ if (!CACHE(parser, 2)) goto error;
+ SKIP_LINE(parser);
+ }
+
+ yaml_free(name);
+
+ return 1;
+
+error:
+ yaml_free(prefix);
+ yaml_free(handle);
+ yaml_free(name);
+ return 0;
+}
+
+/*
+ * Scan the directive name.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^
+ */
+
+static int
+yaml_parser_scan_directive_name(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **name)
+{
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Consume the directive name. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer))
+ {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the name is empty. */
+
+ if (string.start == string.pointer) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "could not find expected directive name");
+ goto error;
+ }
+
+ /* Check for an blank character after the name. */
+
+ if (!IS_BLANKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "found unexpected non-alphabetical character");
+ goto error;
+ }
+
+ *name = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan the value of VERSION-DIRECTIVE.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^^^
+ */
+
+static int
+yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *major, int *minor)
+{
+ /* Eat whitespaces. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Consume the major version number. */
+
+ if (!yaml_parser_scan_version_directive_number(parser, start_mark, major))
+ return 0;
+
+ /* Eat '.'. */
+
+ if (!CHECK(parser->buffer, '.')) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "did not find expected digit or '.' character");
+ }
+
+ SKIP(parser);
+
+ /* Consume the minor version number. */
+
+ if (!yaml_parser_scan_version_directive_number(parser, start_mark, minor))
+ return 0;
+
+ return 1;
+}
+
+#define MAX_NUMBER_LENGTH 9
+
+/*
+ * Scan the version number of VERSION-DIRECTIVE.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^
+ * %YAML 1.1 # a comment \n
+ * ^
+ */
+
+static int
+yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *number)
+{
+ int value = 0;
+ size_t length = 0;
+
+ /* Repeat while the next character is digit. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (IS_DIGIT(parser->buffer))
+ {
+ /* Check if the number is too long. */
+
+ if (++length > MAX_NUMBER_LENGTH) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "found extremely long version number");
+ }
+
+ value = value*10 + AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Check if the number was present. */
+
+ if (!length) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "did not find expected version number");
+ }
+
+ *number = value;
+
+ return 1;
+}
+
+/*
+ * Scan the value of a TAG-DIRECTIVE token.
+ *
+ * Scope:
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ */
+
+static int
+yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **handle, yaml_char_t **prefix)
+{
+ yaml_char_t *handle_value = NULL;
+ yaml_char_t *prefix_value = NULL;
+
+ /* Eat whitespaces. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Scan a handle. */
+
+ if (!yaml_parser_scan_tag_handle(parser, 1, start_mark, &handle_value))
+ goto error;
+
+ /* Expect a whitespace. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANK(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
+ start_mark, "did not find expected whitespace");
+ goto error;
+ }
+
+ /* Eat whitespaces. */
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Scan a prefix. */
+
if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value))
- goto error;
-
- /* Expect a whitespace or line break. */
-
- if (!CACHE(parser, 1)) goto error;
-
- if (!IS_BLANKZ(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
- start_mark, "did not find expected whitespace or line break");
- goto error;
- }
-
- *handle = handle_value;
- *prefix = prefix_value;
-
- return 1;
-
-error:
- yaml_free(handle_value);
- yaml_free(prefix_value);
- return 0;
-}
-
-static int
-yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
- yaml_token_type_t type)
-{
- int length = 0;
- yaml_mark_t start_mark, end_mark;
- yaml_string_t string = NULL_STRING;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
-
- /* Eat the indicator character. */
-
- start_mark = parser->mark;
-
- SKIP(parser);
-
- /* Consume the value. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_ALPHA(parser->buffer)) {
- if (!READ(parser, string)) goto error;
- if (!CACHE(parser, 1)) goto error;
- length ++;
- }
-
- end_mark = parser->mark;
-
- /*
- * Check if length of the anchor is greater than 0 and it is followed by
- * a whitespace character or one of the indicators:
- *
- * '?', ':', ',', ']', '}', '%', '@', '`'.
- */
-
- if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
- || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
- || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
- || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
- || CHECK(parser->buffer, '`'))) {
- yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
- "while scanning an anchor" : "while scanning an alias", start_mark,
- "did not find expected alphabetic or numeric character");
- goto error;
- }
-
- /* Create a token. */
-
- if (type == YAML_ANCHOR_TOKEN) {
- ANCHOR_TOKEN_INIT(*token, string.start, start_mark, end_mark);
- }
- else {
- ALIAS_TOKEN_INIT(*token, string.start, start_mark, end_mark);
- }
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- return 0;
-}
-
-/*
- * Scan a TAG token.
- */
-
-static int
-yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
-{
- yaml_char_t *handle = NULL;
- yaml_char_t *suffix = NULL;
- yaml_mark_t start_mark, end_mark;
-
- start_mark = parser->mark;
-
- /* Check if the tag is in the canonical form. */
-
- if (!CACHE(parser, 2)) goto error;
-
- if (CHECK_AT(parser->buffer, '<', 1))
- {
- /* Set the handle to '' */
-
+ goto error;
+
+ /* Expect a whitespace or line break. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
+ start_mark, "did not find expected whitespace or line break");
+ goto error;
+ }
+
+ *handle = handle_value;
+ *prefix = prefix_value;
+
+ return 1;
+
+error:
+ yaml_free(handle_value);
+ yaml_free(prefix_value);
+ return 0;
+}
+
+static int
+yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
+ yaml_token_type_t type)
+{
+ int length = 0;
+ yaml_mark_t start_mark, end_mark;
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the indicator character. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Consume the value. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer)) {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ length ++;
+ }
+
+ end_mark = parser->mark;
+
+ /*
+ * Check if length of the anchor is greater than 0 and it is followed by
+ * a whitespace character or one of the indicators:
+ *
+ * '?', ':', ',', ']', '}', '%', '@', '`'.
+ */
+
+ if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
+ || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '`'))) {
+ yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
+ "while scanning an anchor" : "while scanning an alias", start_mark,
+ "did not find expected alphabetic or numeric character");
+ goto error;
+ }
+
+ /* Create a token. */
+
+ if (type == YAML_ANCHOR_TOKEN) {
+ ANCHOR_TOKEN_INIT(*token, string.start, start_mark, end_mark);
+ }
+ else {
+ ALIAS_TOKEN_INIT(*token, string.start, start_mark, end_mark);
+ }
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan a TAG token.
+ */
+
+static int
+yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_char_t *handle = NULL;
+ yaml_char_t *suffix = NULL;
+ yaml_mark_t start_mark, end_mark;
+
+ start_mark = parser->mark;
+
+ /* Check if the tag is in the canonical form. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ if (CHECK_AT(parser->buffer, '<', 1))
+ {
+ /* Set the handle to '' */
+
handle = YAML_MALLOC(1);
- if (!handle) goto error;
- handle[0] = '\0';
-
- /* Eat '!<' */
-
- SKIP(parser);
- SKIP(parser);
-
- /* Consume the tag value. */
-
+ if (!handle) goto error;
+ handle[0] = '\0';
+
+ /* Eat '!<' */
+
+ SKIP(parser);
+ SKIP(parser);
+
+ /* Consume the tag value. */
+
if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix))
- goto error;
-
- /* Check for '>' and eat it. */
-
- if (!CHECK(parser->buffer, '>')) {
- yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not find the expected '>'");
- goto error;
- }
-
- SKIP(parser);
- }
- else
- {
- /* The tag has either the '!suffix' or the '!handle!suffix' form. */
-
- /* First, try to scan a handle. */
-
- if (!yaml_parser_scan_tag_handle(parser, 0, start_mark, &handle))
- goto error;
-
- /* Check if it is, indeed, handle. */
-
- if (handle[0] == '!' && handle[1] != '\0' && handle[strlen((char *)handle)-1] == '!')
- {
- /* Scan the suffix now. */
-
+ goto error;
+
+ /* Check for '>' and eat it. */
+
+ if (!CHECK(parser->buffer, '>')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a tag",
+ start_mark, "did not find the expected '>'");
+ goto error;
+ }
+
+ SKIP(parser);
+ }
+ else
+ {
+ /* The tag has either the '!suffix' or the '!handle!suffix' form. */
+
+ /* First, try to scan a handle. */
+
+ if (!yaml_parser_scan_tag_handle(parser, 0, start_mark, &handle))
+ goto error;
+
+ /* Check if it is, indeed, handle. */
+
+ if (handle[0] == '!' && handle[1] != '\0' && handle[strlen((char *)handle)-1] == '!')
+ {
+ /* Scan the suffix now. */
+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix))
- goto error;
- }
- else
- {
- /* It wasn't a handle after all. Scan the rest of the tag. */
-
+ goto error;
+ }
+ else
+ {
+ /* It wasn't a handle after all. Scan the rest of the tag. */
+
if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix))
- goto error;
-
- /* Set the handle to '!'. */
-
- yaml_free(handle);
+ goto error;
+
+ /* Set the handle to '!'. */
+
+ yaml_free(handle);
handle = YAML_MALLOC(2);
- if (!handle) goto error;
- handle[0] = '!';
- handle[1] = '\0';
-
- /*
- * A special case: the '!' tag. Set the handle to '' and the
- * suffix to '!'.
- */
-
- if (suffix[0] == '\0') {
- yaml_char_t *tmp = handle;
- handle = suffix;
- suffix = tmp;
- }
- }
- }
-
- /* Check the character which ends the tag. */
-
- if (!CACHE(parser, 1)) goto error;
-
- if (!IS_BLANKZ(parser->buffer)) {
+ if (!handle) goto error;
+ handle[0] = '!';
+ handle[1] = '\0';
+
+ /*
+ * A special case: the '!' tag. Set the handle to '' and the
+ * suffix to '!'.
+ */
+
+ if (suffix[0] == '\0') {
+ yaml_char_t *tmp = handle;
+ handle = suffix;
+ suffix = tmp;
+ }
+ }
+ }
+
+ /* Check the character which ends the tag. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANKZ(parser->buffer)) {
if (!parser->flow_level || !CHECK(parser->buffer, ',') ) {
yaml_parser_set_scanner_error(parser, "while scanning a tag",
start_mark, "did not find expected whitespace or line break");
goto error;
}
- }
-
- end_mark = parser->mark;
-
- /* Create a token. */
-
- TAG_TOKEN_INIT(*token, handle, suffix, start_mark, end_mark);
-
- return 1;
-
-error:
- yaml_free(handle);
- yaml_free(suffix);
- return 0;
-}
-
-/*
- * Scan a tag handle.
- */
-
-static int
-yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
- yaml_mark_t start_mark, yaml_char_t **handle)
-{
- yaml_string_t string = NULL_STRING;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
-
- /* Check the initial '!' character. */
-
- if (!CACHE(parser, 1)) goto error;
-
- if (!CHECK(parser->buffer, '!')) {
- yaml_parser_set_scanner_error(parser, directive ?
- "while scanning a tag directive" : "while scanning a tag",
- start_mark, "did not find expected '!'");
- goto error;
- }
-
- /* Copy the '!' character. */
-
- if (!READ(parser, string)) goto error;
-
- /* Copy all subsequent alphabetical and numerical characters. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_ALPHA(parser->buffer))
- {
- if (!READ(parser, string)) goto error;
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Check if the trailing character is '!' and copy it. */
-
- if (CHECK(parser->buffer, '!'))
- {
- if (!READ(parser, string)) goto error;
- }
- else
- {
- /*
- * It's either the '!' tag or not really a tag handle. If it's a %TAG
- * directive, it's an error. If it's a tag token, it must be a part of
- * URI.
- */
-
- if (directive && !(string.start[0] == '!' && string.start[1] == '\0')) {
- yaml_parser_set_scanner_error(parser, "while parsing a tag directive",
- start_mark, "did not find expected '!'");
- goto error;
- }
- }
-
- *handle = string.start;
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- return 0;
-}
-
-/*
- * Scan a tag.
- */
-
-static int
+ }
+
+ end_mark = parser->mark;
+
+ /* Create a token. */
+
+ TAG_TOKEN_INIT(*token, handle, suffix, start_mark, end_mark);
+
+ return 1;
+
+error:
+ yaml_free(handle);
+ yaml_free(suffix);
+ return 0;
+}
+
+/*
+ * Scan a tag handle.
+ */
+
+static int
+yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_char_t **handle)
+{
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Check the initial '!' character. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!CHECK(parser->buffer, '!')) {
+ yaml_parser_set_scanner_error(parser, directive ?
+ "while scanning a tag directive" : "while scanning a tag",
+ start_mark, "did not find expected '!'");
+ goto error;
+ }
+
+ /* Copy the '!' character. */
+
+ if (!READ(parser, string)) goto error;
+
+ /* Copy all subsequent alphabetical and numerical characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer))
+ {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the trailing character is '!' and copy it. */
+
+ if (CHECK(parser->buffer, '!'))
+ {
+ if (!READ(parser, string)) goto error;
+ }
+ else
+ {
+ /*
+ * It's either the '!' tag or not really a tag handle. If it's a %TAG
+ * directive, it's an error. If it's a tag token, it must be a part of
+ * URI.
+ */
+
+ if (directive && !(string.start[0] == '!' && string.start[1] == '\0')) {
+ yaml_parser_set_scanner_error(parser, "while parsing a tag directive",
+ start_mark, "did not find expected '!'");
+ goto error;
+ }
+ }
+
+ *handle = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan a tag.
+ */
+
+static int
yaml_parser_scan_tag_uri(yaml_parser_t *parser, int uri_char, int directive,
- yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
-{
- size_t length = head ? strlen((char *)head) : 0;
- yaml_string_t string = NULL_STRING;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
-
- /* Resize the string to include the head. */
-
- while ((size_t)(string.end - string.start) <= length) {
- if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
- parser->error = YAML_MEMORY_ERROR;
- goto error;
- }
- }
-
- /*
- * Copy the head if needed.
- *
- * Note that we don't copy the leading '!' character.
- */
-
- if (length > 1) {
- memcpy(string.start, head+1, length-1);
- string.pointer += length-1;
- }
-
- /* Scan the tag. */
-
- if (!CACHE(parser, 1)) goto error;
-
- /*
- * The set of characters that may appear in URI is as follows:
- *
- * '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
+ yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
+{
+ size_t length = head ? strlen((char *)head) : 0;
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Resize the string to include the head. */
+
+ while ((size_t)(string.end - string.start) <= length) {
+ if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ }
+
+ /*
+ * Copy the head if needed.
+ *
+ * Note that we don't copy the leading '!' character.
+ */
+
+ if (length > 1) {
+ memcpy(string.start, head+1, length-1);
+ string.pointer += length-1;
+ }
+
+ /* Scan the tag. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ /*
+ * The set of characters that may appear in URI is as follows:
+ *
+ * '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
* '=', '+', '$', '.', '!', '~', '*', '\'', '(', ')', '%'.
*
* If we are inside a verbatim tag <...> (parameter uri_char is true)
* then also the following flow indicators are allowed:
* ',', '[', ']'
- */
-
- while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
- || CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
- || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
- || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
- || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
+ */
+
+ while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
+ || CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
+ || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
|| CHECK(parser->buffer, '.') || CHECK(parser->buffer, '%')
- || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
- || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
- || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
+ || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
|| (uri_char && (
CHECK(parser->buffer, ',')
|| CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
)
))
- {
- /* Check if it is a URI-escape sequence. */
-
- if (CHECK(parser->buffer, '%')) {
+ {
+ /* Check if it is a URI-escape sequence. */
+
+ if (CHECK(parser->buffer, '%')) {
if (!STRING_EXTEND(parser, string))
goto error;
- if (!yaml_parser_scan_uri_escapes(parser,
- directive, start_mark, &string)) goto error;
- }
- else {
- if (!READ(parser, string)) goto error;
- }
-
- length ++;
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Check if the tag is non-empty. */
-
- if (!length) {
- if (!STRING_EXTEND(parser, string))
- goto error;
-
- yaml_parser_set_scanner_error(parser, directive ?
- "while parsing a %TAG directive" : "while parsing a tag",
- start_mark, "did not find expected tag URI");
- goto error;
- }
-
- *uri = string.start;
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- return 0;
-}
-
-/*
- * Decode an URI-escape sequence corresponding to a single UTF-8 character.
- */
-
-static int
-yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
- yaml_mark_t start_mark, yaml_string_t *string)
-{
- int width = 0;
-
- /* Decode the required number of characters. */
-
- do {
-
- unsigned char octet = 0;
-
- /* Check for a URI-escaped octet. */
-
- if (!CACHE(parser, 3)) return 0;
-
- if (!(CHECK(parser->buffer, '%')
- && IS_HEX_AT(parser->buffer, 1)
- && IS_HEX_AT(parser->buffer, 2))) {
- return yaml_parser_set_scanner_error(parser, directive ?
- "while parsing a %TAG directive" : "while parsing a tag",
- start_mark, "did not find URI escaped octet");
- }
-
- /* Get the octet. */
-
- octet = (AS_HEX_AT(parser->buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);
-
- /* If it is the leading octet, determine the length of the UTF-8 sequence. */
-
- if (!width)
- {
- width = (octet & 0x80) == 0x00 ? 1 :
- (octet & 0xE0) == 0xC0 ? 2 :
- (octet & 0xF0) == 0xE0 ? 3 :
- (octet & 0xF8) == 0xF0 ? 4 : 0;
- if (!width) {
- return yaml_parser_set_scanner_error(parser, directive ?
- "while parsing a %TAG directive" : "while parsing a tag",
- start_mark, "found an incorrect leading UTF-8 octet");
- }
- }
- else
- {
- /* Check if the trailing octet is correct. */
-
- if ((octet & 0xC0) != 0x80) {
- return yaml_parser_set_scanner_error(parser, directive ?
- "while parsing a %TAG directive" : "while parsing a tag",
- start_mark, "found an incorrect trailing UTF-8 octet");
- }
- }
-
- /* Copy the octet and move the pointers. */
-
- *(string->pointer++) = octet;
- SKIP(parser);
- SKIP(parser);
- SKIP(parser);
-
- } while (--width);
-
- return 1;
-}
-
-/*
- * Scan a block scalar.
- */
-
-static int
-yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
- int literal)
-{
- yaml_mark_t start_mark;
- yaml_mark_t end_mark;
- yaml_string_t string = NULL_STRING;
- yaml_string_t leading_break = NULL_STRING;
- yaml_string_t trailing_breaks = NULL_STRING;
- int chomping = 0;
- int increment = 0;
- int indent = 0;
- int leading_blank = 0;
- int trailing_blank = 0;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
-
- /* Eat the indicator '|' or '>'. */
-
- start_mark = parser->mark;
-
- SKIP(parser);
-
- /* Scan the additional block scalar indicators. */
-
- if (!CACHE(parser, 1)) goto error;
-
- /* Check for a chomping indicator. */
-
- if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-'))
- {
- /* Set the chomping method and eat the indicator. */
-
- chomping = CHECK(parser->buffer, '+') ? +1 : -1;
-
- SKIP(parser);
-
- /* Check for an indentation indicator. */
-
- if (!CACHE(parser, 1)) goto error;
-
- if (IS_DIGIT(parser->buffer))
- {
+ if (!yaml_parser_scan_uri_escapes(parser,
+ directive, start_mark, &string)) goto error;
+ }
+ else {
+ if (!READ(parser, string)) goto error;
+ }
+
+ length ++;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the tag is non-empty. */
+
+ if (!length) {
+ if (!STRING_EXTEND(parser, string))
+ goto error;
+
+ yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "did not find expected tag URI");
+ goto error;
+ }
+
+ *uri = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Decode an URI-escape sequence corresponding to a single UTF-8 character.
+ */
+
+static int
+yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_string_t *string)
+{
+ int width = 0;
+
+ /* Decode the required number of characters. */
+
+ do {
+
+ unsigned char octet = 0;
+
+ /* Check for a URI-escaped octet. */
+
+ if (!CACHE(parser, 3)) return 0;
+
+ if (!(CHECK(parser->buffer, '%')
+ && IS_HEX_AT(parser->buffer, 1)
+ && IS_HEX_AT(parser->buffer, 2))) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "did not find URI escaped octet");
+ }
+
+ /* Get the octet. */
+
+ octet = (AS_HEX_AT(parser->buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);
+
+ /* If it is the leading octet, determine the length of the UTF-8 sequence. */
+
+ if (!width)
+ {
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+ if (!width) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "found an incorrect leading UTF-8 octet");
+ }
+ }
+ else
+ {
+ /* Check if the trailing octet is correct. */
+
+ if ((octet & 0xC0) != 0x80) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "found an incorrect trailing UTF-8 octet");
+ }
+ }
+
+ /* Copy the octet and move the pointers. */
+
+ *(string->pointer++) = octet;
+ SKIP(parser);
+ SKIP(parser);
+ SKIP(parser);
+
+ } while (--width);
+
+ return 1;
+}
+
+/*
+ * Scan a block scalar.
+ */
+
+static int
+yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int literal)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ int chomping = 0;
+ int increment = 0;
+ int indent = 0;
+ int leading_blank = 0;
+ int trailing_blank = 0;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the indicator '|' or '>'. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Scan the additional block scalar indicators. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ /* Check for a chomping indicator. */
+
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-'))
+ {
+ /* Set the chomping method and eat the indicator. */
+
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
+
+ SKIP(parser);
+
+ /* Check for an indentation indicator. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (IS_DIGIT(parser->buffer))
+ {
/* Check that the indentation is greater than 0. */
-
- if (CHECK(parser->buffer, '0')) {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+
+ if (CHECK(parser->buffer, '0')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
start_mark, "found an indentation indicator equal to 0");
- goto error;
- }
-
+ goto error;
+ }
+
/* Get the indentation level and eat the indicator. */
-
- increment = AS_DIGIT(parser->buffer);
-
- SKIP(parser);
- }
- }
-
- /* Do the same as above, but in the opposite order. */
-
- else if (IS_DIGIT(parser->buffer))
- {
- if (CHECK(parser->buffer, '0')) {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+
+ increment = AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+ }
+ }
+
+ /* Do the same as above, but in the opposite order. */
+
+ else if (IS_DIGIT(parser->buffer))
+ {
+ if (CHECK(parser->buffer, '0')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
start_mark, "found an indentation indicator equal to 0");
- goto error;
- }
-
- increment = AS_DIGIT(parser->buffer);
-
- SKIP(parser);
-
- if (!CACHE(parser, 1)) goto error;
-
- if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-')) {
- chomping = CHECK(parser->buffer, '+') ? +1 : -1;
-
- SKIP(parser);
- }
- }
-
- /* Eat whitespaces and comments to the end of the line. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_BLANK(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
-
- if (CHECK(parser->buffer, '#')) {
- while (!IS_BREAKZ(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) goto error;
- }
- }
-
- /* Check if we are at the end of the line. */
-
- if (!IS_BREAKZ(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "did not find expected comment or line break");
- goto error;
- }
-
- /* Eat a line break. */
-
- if (IS_BREAK(parser->buffer)) {
- if (!CACHE(parser, 2)) goto error;
- SKIP_LINE(parser);
- }
-
- end_mark = parser->mark;
-
+ goto error;
+ }
+
+ increment = AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-')) {
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
+
+ SKIP(parser);
+ }
+ }
+
+ /* Eat whitespaces and comments to the end of the line. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+ }
+
+ /* Check if we are at the end of the line. */
+
+ if (!IS_BREAKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+ start_mark, "did not find expected comment or line break");
+ goto error;
+ }
+
+ /* Eat a line break. */
+
+ if (IS_BREAK(parser->buffer)) {
+ if (!CACHE(parser, 2)) goto error;
+ SKIP_LINE(parser);
+ }
+
+ end_mark = parser->mark;
+
/* Set the indentation level if it was specified. */
-
- if (increment) {
- indent = parser->indent >= 0 ? parser->indent+increment : increment;
- }
-
- /* Scan the leading line breaks and determine the indentation level if needed. */
-
- if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks,
- start_mark, &end_mark)) goto error;
-
- /* Scan the block scalar content. */
-
- if (!CACHE(parser, 1)) goto error;
-
+
+ if (increment) {
+ indent = parser->indent >= 0 ? parser->indent+increment : increment;
+ }
+
+ /* Scan the leading line breaks and determine the indentation level if needed. */
+
+ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks,
+ start_mark, &end_mark)) goto error;
+
+ /* Scan the block scalar content. */
+
+ if (!CACHE(parser, 1)) goto error;
+
while ((int)parser->mark.column == indent && !(IS_Z(parser->buffer)))
- {
- /*
- * We are at the beginning of a non-empty line.
- */
-
- /* Is it a trailing whitespace? */
-
- trailing_blank = IS_BLANK(parser->buffer);
-
- /* Check if we need to fold the leading line break. */
-
- if (!literal && (*leading_break.start == '\n')
- && !leading_blank && !trailing_blank)
- {
- /* Do we need to join the lines by space? */
-
- if (*trailing_breaks.start == '\0') {
- if (!STRING_EXTEND(parser, string)) goto error;
- *(string.pointer ++) = ' ';
- }
-
- CLEAR(parser, leading_break);
- }
- else {
- if (!JOIN(parser, string, leading_break)) goto error;
- CLEAR(parser, leading_break);
- }
-
- /* Append the remaining line breaks. */
-
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- CLEAR(parser, trailing_breaks);
-
- /* Is it a leading whitespace? */
-
- leading_blank = IS_BLANK(parser->buffer);
-
- /* Consume the current line. */
-
- while (!IS_BREAKZ(parser->buffer)) {
- if (!READ(parser, string)) goto error;
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Consume the line break. */
-
- if (!CACHE(parser, 2)) goto error;
-
- if (!READ_LINE(parser, leading_break)) goto error;
-
+ {
+ /*
+ * We are at the beginning of a non-empty line.
+ */
+
+ /* Is it a trailing whitespace? */
+
+ trailing_blank = IS_BLANK(parser->buffer);
+
+ /* Check if we need to fold the leading line break. */
+
+ if (!literal && (*leading_break.start == '\n')
+ && !leading_blank && !trailing_blank)
+ {
+ /* Do we need to join the lines by space? */
+
+ if (*trailing_breaks.start == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer ++) = ' ';
+ }
+
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ CLEAR(parser, leading_break);
+ }
+
+ /* Append the remaining line breaks. */
+
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+
+ /* Is it a leading whitespace? */
+
+ leading_blank = IS_BLANK(parser->buffer);
+
+ /* Consume the current line. */
+
+ while (!IS_BREAKZ(parser->buffer)) {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Consume the line break. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ if (!READ_LINE(parser, leading_break)) goto error;
+
/* Eat the following indentation spaces and line breaks. */
-
- if (!yaml_parser_scan_block_scalar_breaks(parser,
- &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
- }
-
- /* Chomp the tail. */
-
- if (chomping != -1) {
- if (!JOIN(parser, string, leading_break)) goto error;
- }
- if (chomping == 1) {
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- }
-
- /* Create a token. */
-
- SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
- literal ? YAML_LITERAL_SCALAR_STYLE : YAML_FOLDED_SCALAR_STYLE,
- start_mark, end_mark);
-
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
-
- return 0;
-}
-
-/*
+
+ if (!yaml_parser_scan_block_scalar_breaks(parser,
+ &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
+ }
+
+ /* Chomp the tail. */
+
+ if (chomping != -1) {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ }
+ if (chomping == 1) {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ }
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ literal ? YAML_LITERAL_SCALAR_STYLE : YAML_FOLDED_SCALAR_STYLE,
+ start_mark, end_mark);
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+
+ return 0;
+}
+
+/*
* Scan indentation spaces and line breaks for a block scalar. Determine the
* indentation level if needed.
- */
-
-static int
-yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
- int *indent, yaml_string_t *breaks,
- yaml_mark_t start_mark, yaml_mark_t *end_mark)
-{
- int max_indent = 0;
-
- *end_mark = parser->mark;
-
+ */
+
+static int
+yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
+ int *indent, yaml_string_t *breaks,
+ yaml_mark_t start_mark, yaml_mark_t *end_mark)
+{
+ int max_indent = 0;
+
+ *end_mark = parser->mark;
+
/* Eat the indentation spaces and line breaks. */
-
- while (1)
- {
+
+ while (1)
+ {
/* Eat the indentation spaces. */
-
- if (!CACHE(parser, 1)) return 0;
-
- while ((!*indent || (int)parser->mark.column < *indent)
- && IS_SPACE(parser->buffer)) {
- SKIP(parser);
- if (!CACHE(parser, 1)) return 0;
- }
-
- if ((int)parser->mark.column > max_indent)
- max_indent = (int)parser->mark.column;
-
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while ((!*indent || (int)parser->mark.column < *indent)
+ && IS_SPACE(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ if ((int)parser->mark.column > max_indent)
+ max_indent = (int)parser->mark.column;
+
/* Check for a tab character messing the indentation. */
-
- if ((!*indent || (int)parser->mark.column < *indent)
- && IS_TAB(parser->buffer)) {
- return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+
+ if ((!*indent || (int)parser->mark.column < *indent)
+ && IS_TAB(parser->buffer)) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
start_mark, "found a tab character where an indentation space is expected");
- }
-
- /* Have we found a non-empty line? */
-
- if (!IS_BREAK(parser->buffer)) break;
-
- /* Consume the line break. */
-
- if (!CACHE(parser, 2)) return 0;
- if (!READ_LINE(parser, *breaks)) return 0;
- *end_mark = parser->mark;
- }
-
- /* Determine the indentation level if needed. */
-
- if (!*indent) {
- *indent = max_indent;
- if (*indent < parser->indent + 1)
- *indent = parser->indent + 1;
- if (*indent < 1)
- *indent = 1;
- }
-
+ }
+
+ /* Have we found a non-empty line? */
+
+ if (!IS_BREAK(parser->buffer)) break;
+
+ /* Consume the line break. */
+
+ if (!CACHE(parser, 2)) return 0;
+ if (!READ_LINE(parser, *breaks)) return 0;
+ *end_mark = parser->mark;
+ }
+
+ /* Determine the indentation level if needed. */
+
+ if (!*indent) {
+ *indent = max_indent;
+ if (*indent < parser->indent + 1)
+ *indent = parser->indent + 1;
+ if (*indent < 1)
+ *indent = 1;
+ }
+
return 1;
-}
-
-/*
- * Scan a quoted scalar.
- */
-
-static int
-yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
- int single)
-{
- yaml_mark_t start_mark;
- yaml_mark_t end_mark;
- yaml_string_t string = NULL_STRING;
- yaml_string_t leading_break = NULL_STRING;
- yaml_string_t trailing_breaks = NULL_STRING;
- yaml_string_t whitespaces = NULL_STRING;
- int leading_blanks;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
-
- /* Eat the left quote. */
-
- start_mark = parser->mark;
-
- SKIP(parser);
-
- /* Consume the content of the quoted scalar. */
-
- while (1)
- {
- /* Check that there are no document indicators at the beginning of the line. */
-
- if (!CACHE(parser, 4)) goto error;
-
- if (parser->mark.column == 0 &&
- ((CHECK_AT(parser->buffer, '-', 0) &&
- CHECK_AT(parser->buffer, '-', 1) &&
- CHECK_AT(parser->buffer, '-', 2)) ||
- (CHECK_AT(parser->buffer, '.', 0) &&
- CHECK_AT(parser->buffer, '.', 1) &&
- CHECK_AT(parser->buffer, '.', 2))) &&
- IS_BLANKZ_AT(parser->buffer, 3))
- {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected document indicator");
- goto error;
- }
-
- /* Check for EOF. */
-
- if (IS_Z(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
- start_mark, "found unexpected end of stream");
- goto error;
- }
-
- /* Consume non-blank characters. */
-
- if (!CACHE(parser, 2)) goto error;
-
- leading_blanks = 0;
-
- while (!IS_BLANKZ(parser->buffer))
- {
- /* Check for an escaped single quote. */
-
- if (single && CHECK_AT(parser->buffer, '\'', 0)
- && CHECK_AT(parser->buffer, '\'', 1))
- {
- if (!STRING_EXTEND(parser, string)) goto error;
- *(string.pointer++) = '\'';
- SKIP(parser);
- SKIP(parser);
- }
-
- /* Check for the right quote. */
-
- else if (CHECK(parser->buffer, single ? '\'' : '"'))
- {
- break;
- }
-
- /* Check for an escaped line break. */
-
- else if (!single && CHECK(parser->buffer, '\\')
- && IS_BREAK_AT(parser->buffer, 1))
- {
- if (!CACHE(parser, 3)) goto error;
- SKIP(parser);
- SKIP_LINE(parser);
- leading_blanks = 1;
- break;
- }
-
- /* Check for an escape sequence. */
-
- else if (!single && CHECK(parser->buffer, '\\'))
- {
- size_t code_length = 0;
-
- if (!STRING_EXTEND(parser, string)) goto error;
-
- /* Check the escape character. */
-
- switch (parser->buffer.pointer[1])
- {
- case '0':
- *(string.pointer++) = '\0';
- break;
-
- case 'a':
- *(string.pointer++) = '\x07';
- break;
-
- case 'b':
- *(string.pointer++) = '\x08';
- break;
-
- case 't':
- case '\t':
- *(string.pointer++) = '\x09';
- break;
-
- case 'n':
- *(string.pointer++) = '\x0A';
- break;
-
- case 'v':
- *(string.pointer++) = '\x0B';
- break;
-
- case 'f':
- *(string.pointer++) = '\x0C';
- break;
-
- case 'r':
- *(string.pointer++) = '\x0D';
- break;
-
- case 'e':
- *(string.pointer++) = '\x1B';
- break;
-
- case ' ':
- *(string.pointer++) = '\x20';
- break;
-
- case '"':
- *(string.pointer++) = '"';
- break;
-
+}
+
+/*
+ * Scan a quoted scalar.
+ */
+
+static int
+yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int single)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ yaml_string_t whitespaces = NULL_STRING;
+ int leading_blanks;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the left quote. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Consume the content of the quoted scalar. */
+
+ while (1)
+ {
+ /* Check that there are no document indicators at the beginning of the line. */
+
+ if (!CACHE(parser, 4)) goto error;
+
+ if (parser->mark.column == 0 &&
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3))
+ {
+ yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
+ start_mark, "found unexpected document indicator");
+ goto error;
+ }
+
+ /* Check for EOF. */
+
+ if (IS_Z(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
+ start_mark, "found unexpected end of stream");
+ goto error;
+ }
+
+ /* Consume non-blank characters. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ leading_blanks = 0;
+
+ while (!IS_BLANKZ(parser->buffer))
+ {
+ /* Check for an escaped single quote. */
+
+ if (single && CHECK_AT(parser->buffer, '\'', 0)
+ && CHECK_AT(parser->buffer, '\'', 1))
+ {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = '\'';
+ SKIP(parser);
+ SKIP(parser);
+ }
+
+ /* Check for the right quote. */
+
+ else if (CHECK(parser->buffer, single ? '\'' : '"'))
+ {
+ break;
+ }
+
+ /* Check for an escaped line break. */
+
+ else if (!single && CHECK(parser->buffer, '\\')
+ && IS_BREAK_AT(parser->buffer, 1))
+ {
+ if (!CACHE(parser, 3)) goto error;
+ SKIP(parser);
+ SKIP_LINE(parser);
+ leading_blanks = 1;
+ break;
+ }
+
+ /* Check for an escape sequence. */
+
+ else if (!single && CHECK(parser->buffer, '\\'))
+ {
+ size_t code_length = 0;
+
+ if (!STRING_EXTEND(parser, string)) goto error;
+
+ /* Check the escape character. */
+
+ switch (parser->buffer.pointer[1])
+ {
+ case '0':
+ *(string.pointer++) = '\0';
+ break;
+
+ case 'a':
+ *(string.pointer++) = '\x07';
+ break;
+
+ case 'b':
+ *(string.pointer++) = '\x08';
+ break;
+
+ case 't':
+ case '\t':
+ *(string.pointer++) = '\x09';
+ break;
+
+ case 'n':
+ *(string.pointer++) = '\x0A';
+ break;
+
+ case 'v':
+ *(string.pointer++) = '\x0B';
+ break;
+
+ case 'f':
+ *(string.pointer++) = '\x0C';
+ break;
+
+ case 'r':
+ *(string.pointer++) = '\x0D';
+ break;
+
+ case 'e':
+ *(string.pointer++) = '\x1B';
+ break;
+
+ case ' ':
+ *(string.pointer++) = '\x20';
+ break;
+
+ case '"':
+ *(string.pointer++) = '"';
+ break;
+
case '/':
*(string.pointer++) = '/';
- break;
-
- case '\\':
- *(string.pointer++) = '\\';
- break;
-
- case 'N': /* NEL (#x85) */
- *(string.pointer++) = '\xC2';
- *(string.pointer++) = '\x85';
- break;
-
- case '_': /* #xA0 */
- *(string.pointer++) = '\xC2';
- *(string.pointer++) = '\xA0';
- break;
-
- case 'L': /* LS (#x2028) */
- *(string.pointer++) = '\xE2';
- *(string.pointer++) = '\x80';
- *(string.pointer++) = '\xA8';
- break;
-
- case 'P': /* PS (#x2029) */
- *(string.pointer++) = '\xE2';
- *(string.pointer++) = '\x80';
- *(string.pointer++) = '\xA9';
- break;
-
- case 'x':
- code_length = 2;
- break;
-
- case 'u':
- code_length = 4;
- break;
-
- case 'U':
- code_length = 8;
- break;
-
- default:
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found unknown escape character");
- goto error;
- }
-
- SKIP(parser);
- SKIP(parser);
-
- /* Consume an arbitrary escape code. */
-
- if (code_length)
- {
- unsigned int value = 0;
- size_t k;
-
- /* Scan the character value. */
-
- if (!CACHE(parser, code_length)) goto error;
-
- for (k = 0; k < code_length; k ++) {
- if (!IS_HEX_AT(parser->buffer, k)) {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "did not find expected hexdecimal number");
- goto error;
- }
- value = (value << 4) + AS_HEX_AT(parser->buffer, k);
- }
-
- /* Check the value and write the character. */
-
- if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) {
- yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
- start_mark, "found invalid Unicode character escape code");
- goto error;
- }
-
- if (value <= 0x7F) {
- *(string.pointer++) = value;
- }
- else if (value <= 0x7FF) {
- *(string.pointer++) = 0xC0 + (value >> 6);
- *(string.pointer++) = 0x80 + (value & 0x3F);
- }
- else if (value <= 0xFFFF) {
- *(string.pointer++) = 0xE0 + (value >> 12);
- *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
- *(string.pointer++) = 0x80 + (value & 0x3F);
- }
- else {
- *(string.pointer++) = 0xF0 + (value >> 18);
- *(string.pointer++) = 0x80 + ((value >> 12) & 0x3F);
- *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
- *(string.pointer++) = 0x80 + (value & 0x3F);
- }
-
- /* Advance the pointer. */
-
- for (k = 0; k < code_length; k ++) {
- SKIP(parser);
- }
- }
- }
-
- else
- {
- /* It is a non-escaped non-blank character. */
-
- if (!READ(parser, string)) goto error;
- }
-
- if (!CACHE(parser, 2)) goto error;
- }
-
- /* Check if we are at the end of the scalar. */
-
+ break;
+
+ case '\\':
+ *(string.pointer++) = '\\';
+ break;
+
+ case 'N': /* NEL (#x85) */
+ *(string.pointer++) = '\xC2';
+ *(string.pointer++) = '\x85';
+ break;
+
+ case '_': /* #xA0 */
+ *(string.pointer++) = '\xC2';
+ *(string.pointer++) = '\xA0';
+ break;
+
+ case 'L': /* LS (#x2028) */
+ *(string.pointer++) = '\xE2';
+ *(string.pointer++) = '\x80';
+ *(string.pointer++) = '\xA8';
+ break;
+
+ case 'P': /* PS (#x2029) */
+ *(string.pointer++) = '\xE2';
+ *(string.pointer++) = '\x80';
+ *(string.pointer++) = '\xA9';
+ break;
+
+ case 'x':
+ code_length = 2;
+ break;
+
+ case 'u':
+ code_length = 4;
+ break;
+
+ case 'U':
+ code_length = 8;
+ break;
+
+ default:
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "found unknown escape character");
+ goto error;
+ }
+
+ SKIP(parser);
+ SKIP(parser);
+
+ /* Consume an arbitrary escape code. */
+
+ if (code_length)
+ {
+ unsigned int value = 0;
+ size_t k;
+
+ /* Scan the character value. */
+
+ if (!CACHE(parser, code_length)) goto error;
+
+ for (k = 0; k < code_length; k ++) {
+ if (!IS_HEX_AT(parser->buffer, k)) {
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "did not find expected hexdecimal number");
+ goto error;
+ }
+ value = (value << 4) + AS_HEX_AT(parser->buffer, k);
+ }
+
+ /* Check the value and write the character. */
+
+ if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) {
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "found invalid Unicode character escape code");
+ goto error;
+ }
+
+ if (value <= 0x7F) {
+ *(string.pointer++) = value;
+ }
+ else if (value <= 0x7FF) {
+ *(string.pointer++) = 0xC0 + (value >> 6);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+ else if (value <= 0xFFFF) {
+ *(string.pointer++) = 0xE0 + (value >> 12);
+ *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+ else {
+ *(string.pointer++) = 0xF0 + (value >> 18);
+ *(string.pointer++) = 0x80 + ((value >> 12) & 0x3F);
+ *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+
+ /* Advance the pointer. */
+
+ for (k = 0; k < code_length; k ++) {
+ SKIP(parser);
+ }
+ }
+ }
+
+ else
+ {
+ /* It is a non-escaped non-blank character. */
+
+ if (!READ(parser, string)) goto error;
+ }
+
+ if (!CACHE(parser, 2)) goto error;
+ }
+
+ /* Check if we are at the end of the scalar. */
+
/* Fix for crash unitialized value crash
* Credit for the bug and input is to OSS Fuzz
* Credit for the fix to Alex Gaynor
*/
if (!CACHE(parser, 1)) goto error;
- if (CHECK(parser->buffer, single ? '\'' : '"'))
- break;
-
- /* Consume blank characters. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
- {
- if (IS_BLANK(parser->buffer))
- {
- /* Consume a space or a tab character. */
-
- if (!leading_blanks) {
- if (!READ(parser, whitespaces)) goto error;
- }
- else {
- SKIP(parser);
- }
- }
- else
- {
- if (!CACHE(parser, 2)) goto error;
-
- /* Check if it is a first line break. */
-
- if (!leading_blanks)
- {
- CLEAR(parser, whitespaces);
- if (!READ_LINE(parser, leading_break)) goto error;
- leading_blanks = 1;
- }
- else
- {
- if (!READ_LINE(parser, trailing_breaks)) goto error;
- }
- }
- if (!CACHE(parser, 1)) goto error;
- }
-
- /* Join the whitespaces or fold line breaks. */
-
- if (leading_blanks)
- {
- /* Do we need to fold line breaks? */
-
- if (leading_break.start[0] == '\n') {
- if (trailing_breaks.start[0] == '\0') {
- if (!STRING_EXTEND(parser, string)) goto error;
- *(string.pointer++) = ' ';
- }
- else {
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- CLEAR(parser, trailing_breaks);
- }
- CLEAR(parser, leading_break);
- }
- else {
- if (!JOIN(parser, string, leading_break)) goto error;
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- CLEAR(parser, leading_break);
- CLEAR(parser, trailing_breaks);
- }
- }
- else
- {
- if (!JOIN(parser, string, whitespaces)) goto error;
- CLEAR(parser, whitespaces);
- }
- }
-
- /* Eat the right quote. */
-
- SKIP(parser);
-
- end_mark = parser->mark;
-
- /* Create a token. */
-
- SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
- single ? YAML_SINGLE_QUOTED_SCALAR_STYLE : YAML_DOUBLE_QUOTED_SCALAR_STYLE,
- start_mark, end_mark);
-
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
- STRING_DEL(parser, whitespaces);
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
- STRING_DEL(parser, whitespaces);
-
- return 0;
-}
-
-/*
- * Scan a plain scalar.
- */
-
-static int
-yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
-{
- yaml_mark_t start_mark;
- yaml_mark_t end_mark;
- yaml_string_t string = NULL_STRING;
- yaml_string_t leading_break = NULL_STRING;
- yaml_string_t trailing_breaks = NULL_STRING;
- yaml_string_t whitespaces = NULL_STRING;
- int leading_blanks = 0;
- int indent = parser->indent+1;
-
- if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
- if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
-
- start_mark = end_mark = parser->mark;
-
- /* Consume the content of the plain scalar. */
-
- while (1)
- {
- /* Check for a document indicator. */
-
- if (!CACHE(parser, 4)) goto error;
-
- if (parser->mark.column == 0 &&
- ((CHECK_AT(parser->buffer, '-', 0) &&
- CHECK_AT(parser->buffer, '-', 1) &&
- CHECK_AT(parser->buffer, '-', 2)) ||
- (CHECK_AT(parser->buffer, '.', 0) &&
- CHECK_AT(parser->buffer, '.', 1) &&
- CHECK_AT(parser->buffer, '.', 2))) &&
- IS_BLANKZ_AT(parser->buffer, 3)) break;
-
- /* Check for a comment. */
-
- if (CHECK(parser->buffer, '#'))
- break;
-
- /* Consume non-blank characters. */
-
- while (!IS_BLANKZ(parser->buffer))
- {
+ if (CHECK(parser->buffer, single ? '\'' : '"'))
+ break;
+
+ /* Consume blank characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
+ {
+ if (IS_BLANK(parser->buffer))
+ {
+ /* Consume a space or a tab character. */
+
+ if (!leading_blanks) {
+ if (!READ(parser, whitespaces)) goto error;
+ }
+ else {
+ SKIP(parser);
+ }
+ }
+ else
+ {
+ if (!CACHE(parser, 2)) goto error;
+
+ /* Check if it is a first line break. */
+
+ if (!leading_blanks)
+ {
+ CLEAR(parser, whitespaces);
+ if (!READ_LINE(parser, leading_break)) goto error;
+ leading_blanks = 1;
+ }
+ else
+ {
+ if (!READ_LINE(parser, trailing_breaks)) goto error;
+ }
+ }
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Join the whitespaces or fold line breaks. */
+
+ if (leading_blanks)
+ {
+ /* Do we need to fold line breaks? */
+
+ if (leading_break.start[0] == '\n') {
+ if (trailing_breaks.start[0] == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = ' ';
+ }
+ else {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+ }
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, leading_break);
+ CLEAR(parser, trailing_breaks);
+ }
+ }
+ else
+ {
+ if (!JOIN(parser, string, whitespaces)) goto error;
+ CLEAR(parser, whitespaces);
+ }
+ }
+
+ /* Eat the right quote. */
+
+ SKIP(parser);
+
+ end_mark = parser->mark;
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ single ? YAML_SINGLE_QUOTED_SCALAR_STYLE : YAML_DOUBLE_QUOTED_SCALAR_STYLE,
+ start_mark, end_mark);
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 0;
+}
+
+/*
+ * Scan a plain scalar.
+ */
+
+static int
+yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ yaml_string_t whitespaces = NULL_STRING;
+ int leading_blanks = 0;
+ int indent = parser->indent+1;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
+
+ start_mark = end_mark = parser->mark;
+
+ /* Consume the content of the plain scalar. */
+
+ while (1)
+ {
+ /* Check for a document indicator. */
+
+ if (!CACHE(parser, 4)) goto error;
+
+ if (parser->mark.column == 0 &&
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3)) break;
+
+ /* Check for a comment. */
+
+ if (CHECK(parser->buffer, '#'))
+ break;
+
+ /* Consume non-blank characters. */
+
+ while (!IS_BLANKZ(parser->buffer))
+ {
/* Check for "x:" + one of ',?[]{}' in the flow context. TODO: Fix the test "spec-08-13".
* This is not completely according to the spec
* See http://yaml.org/spec/1.1/#id907281 9.1.3. Plain
*/
-
- if (parser->flow_level
- && CHECK(parser->buffer, ':')
+
+ if (parser->flow_level
+ && CHECK(parser->buffer, ':')
&& (
CHECK_AT(parser->buffer, ',', 1)
|| CHECK_AT(parser->buffer, '?', 1)
@@ -3455,144 +3455,144 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|| CHECK_AT(parser->buffer, '}', 1)
)
) {
- yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found unexpected ':'");
- goto error;
- }
-
- /* Check for indicators that may end a plain scalar. */
-
- if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
- || (parser->flow_level &&
+ yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
+ start_mark, "found unexpected ':'");
+ goto error;
+ }
+
+ /* Check for indicators that may end a plain scalar. */
+
+ if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
+ || (parser->flow_level &&
(CHECK(parser->buffer, ',')
|| CHECK(parser->buffer, '[')
- || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
- || CHECK(parser->buffer, '}'))))
- break;
-
- /* Check if we need to join whitespaces and breaks. */
-
- if (leading_blanks || whitespaces.start != whitespaces.pointer)
- {
- if (leading_blanks)
- {
- /* Do we need to fold line breaks? */
-
- if (leading_break.start[0] == '\n') {
- if (trailing_breaks.start[0] == '\0') {
- if (!STRING_EXTEND(parser, string)) goto error;
- *(string.pointer++) = ' ';
- }
- else {
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- CLEAR(parser, trailing_breaks);
- }
- CLEAR(parser, leading_break);
- }
- else {
- if (!JOIN(parser, string, leading_break)) goto error;
- if (!JOIN(parser, string, trailing_breaks)) goto error;
- CLEAR(parser, leading_break);
- CLEAR(parser, trailing_breaks);
- }
-
- leading_blanks = 0;
- }
- else
- {
- if (!JOIN(parser, string, whitespaces)) goto error;
- CLEAR(parser, whitespaces);
- }
- }
-
- /* Copy the character. */
-
- if (!READ(parser, string)) goto error;
-
- end_mark = parser->mark;
-
- if (!CACHE(parser, 2)) goto error;
- }
-
- /* Is it the end? */
-
- if (!(IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer)))
- break;
-
- /* Consume blank characters. */
-
- if (!CACHE(parser, 1)) goto error;
-
- while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
- {
- if (IS_BLANK(parser->buffer))
- {
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}'))))
+ break;
+
+ /* Check if we need to join whitespaces and breaks. */
+
+ if (leading_blanks || whitespaces.start != whitespaces.pointer)
+ {
+ if (leading_blanks)
+ {
+ /* Do we need to fold line breaks? */
+
+ if (leading_break.start[0] == '\n') {
+ if (trailing_breaks.start[0] == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = ' ';
+ }
+ else {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+ }
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, leading_break);
+ CLEAR(parser, trailing_breaks);
+ }
+
+ leading_blanks = 0;
+ }
+ else
+ {
+ if (!JOIN(parser, string, whitespaces)) goto error;
+ CLEAR(parser, whitespaces);
+ }
+ }
+
+ /* Copy the character. */
+
+ if (!READ(parser, string)) goto error;
+
+ end_mark = parser->mark;
+
+ if (!CACHE(parser, 2)) goto error;
+ }
+
+ /* Is it the end? */
+
+ if (!(IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer)))
+ break;
+
+ /* Consume blank characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
+ {
+ if (IS_BLANK(parser->buffer))
+ {
/* Check for tab characters that abuse indentation. */
-
- if (leading_blanks && (int)parser->mark.column < indent
- && IS_TAB(parser->buffer)) {
- yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
+
+ if (leading_blanks && (int)parser->mark.column < indent
+ && IS_TAB(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
start_mark, "found a tab character that violates indentation");
- goto error;
- }
-
- /* Consume a space or a tab character. */
-
- if (!leading_blanks) {
- if (!READ(parser, whitespaces)) goto error;
- }
- else {
- SKIP(parser);
- }
- }
- else
- {
- if (!CACHE(parser, 2)) goto error;
-
- /* Check if it is a first line break. */
-
- if (!leading_blanks)
- {
- CLEAR(parser, whitespaces);
- if (!READ_LINE(parser, leading_break)) goto error;
- leading_blanks = 1;
- }
- else
- {
- if (!READ_LINE(parser, trailing_breaks)) goto error;
- }
- }
- if (!CACHE(parser, 1)) goto error;
- }
-
+ goto error;
+ }
+
+ /* Consume a space or a tab character. */
+
+ if (!leading_blanks) {
+ if (!READ(parser, whitespaces)) goto error;
+ }
+ else {
+ SKIP(parser);
+ }
+ }
+ else
+ {
+ if (!CACHE(parser, 2)) goto error;
+
+ /* Check if it is a first line break. */
+
+ if (!leading_blanks)
+ {
+ CLEAR(parser, whitespaces);
+ if (!READ_LINE(parser, leading_break)) goto error;
+ leading_blanks = 1;
+ }
+ else
+ {
+ if (!READ_LINE(parser, trailing_breaks)) goto error;
+ }
+ }
+ if (!CACHE(parser, 1)) goto error;
+ }
+
/* Check indentation level. */
-
- if (!parser->flow_level && (int)parser->mark.column < indent)
- break;
- }
-
- /* Create a token. */
-
- SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
- YAML_PLAIN_SCALAR_STYLE, start_mark, end_mark);
-
- /* Note that we change the 'simple_key_allowed' flag. */
-
- if (leading_blanks) {
- parser->simple_key_allowed = 1;
- }
-
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
- STRING_DEL(parser, whitespaces);
-
- return 1;
-
-error:
- STRING_DEL(parser, string);
- STRING_DEL(parser, leading_break);
- STRING_DEL(parser, trailing_breaks);
- STRING_DEL(parser, whitespaces);
-
- return 0;
-}
+
+ if (!parser->flow_level && (int)parser->mark.column < indent)
+ break;
+ }
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ YAML_PLAIN_SCALAR_STYLE, start_mark, end_mark);
+
+ /* Note that we change the 'simple_key_allowed' flag. */
+
+ if (leading_blanks) {
+ parser->simple_key_allowed = 1;
+ }
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 0;
+}
diff --git a/contrib/libs/yaml/src/writer.c b/contrib/libs/yaml/src/writer.c
index aa01469de3..5d57f392f1 100644
--- a/contrib/libs/yaml/src/writer.c
+++ b/contrib/libs/yaml/src/writer.c
@@ -1,141 +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;
-
+
+#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");
- }
-}
-
+ * 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");
+ }
+}
+
diff --git a/contrib/libs/yaml/src/yaml_private.h b/contrib/libs/yaml/src/yaml_private.h
index d449b470ff..b3351c4165 100644
--- a/contrib/libs/yaml/src/yaml_private.h
+++ b/contrib/libs/yaml/src/yaml_private.h
@@ -1,72 +1,72 @@
#if HAVE_CONFIG_H
-#include "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)
-
-/*
+
+#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.
@@ -78,586 +78,586 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
/*
- * 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) \
+ * 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) \
+ ((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 = (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, \
+ || 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 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.
- */
-
+ ((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);
-
+
+/*
+ * 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).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))
-
+ 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))
-
+ ((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__)
diff --git a/contrib/libs/yaml/ya.make b/contrib/libs/yaml/ya.make
index 04261e8373..547a2b2a63 100644
--- a/contrib/libs/yaml/ya.make
+++ b/contrib/libs/yaml/ya.make
@@ -1,7 +1,7 @@
# Generated by devtools/yamaker from nixpkgs 21.11.
-LIBRARY()
-
+LIBRARY()
+
OWNER(
borman
g:cpp-contrib
@@ -15,28 +15,28 @@ LICENSE(MIT)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-ADDINCL(
- GLOBAL contrib/libs/yaml/include
+ADDINCL(
+ GLOBAL contrib/libs/yaml/include
contrib/libs/yaml/src
-)
-
-NO_COMPILER_WARNINGS()
-
+)
+
+NO_COMPILER_WARNINGS()
+
NO_RUNTIME()
CFLAGS(
-DHAVE_CONFIG_H
)
-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
-)
-
-END()
+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
+)
+
+END()
diff --git a/contrib/libs/zlib/ya.make b/contrib/libs/zlib/ya.make
index 5c9e47a1e3..ced6573475 100644
--- a/contrib/libs/zlib/ya.make
+++ b/contrib/libs/zlib/ya.make
@@ -16,7 +16,7 @@ OPENSOURCE_EXPORT_REPLACEMENT(
LICENSE(Zlib)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
+
ADDINCL(
GLOBAL contrib/libs/zlib/include
)