libyaml
This commit is contained in:
parent
eb0f93f476
commit
24b07b65f0
15 changed files with 13662 additions and 0 deletions
19
lib/yaml/LICENSE
Normal file
19
lib/yaml/LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2006 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.
|
18
lib/yaml/Makefile.am
Normal file
18
lib/yaml/Makefile.am
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Run `./bootstrap` to generate the "Makefile.in" files in this directory and
|
||||
## the "$SUBDIRS" subdirectories.
|
||||
|
||||
SUBDIRS = include src . tests win32
|
||||
|
||||
EXTRA_DIST = README LICENSE CMakeLists.txt doc/doxygen.cfg
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = yaml-0.1.pc
|
||||
|
||||
maintainer-clean-local:
|
||||
-rm -f aclocal.m4 config.h.in configure config/*
|
||||
-find ${builddir} -name Makefile.in -exec rm -f '{}' ';'
|
||||
|
||||
.PHONY: bootstrap
|
||||
bootstrap: maintainer-clean
|
||||
./bootstrap
|
||||
|
810
lib/yaml/Makefile.in
Normal file
810
lib/yaml/Makefile.in
Normal file
|
@ -0,0 +1,810 @@
|
|||
# Makefile.in generated by automake 1.11.3 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
|
||||
# Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = .
|
||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
||||
$(srcdir)/yaml-0.1.pc.in $(top_srcdir)/configure \
|
||||
config/config.guess config/config.sub config/depcomp \
|
||||
config/install-sh config/ltmain.sh config/missing
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES = yaml-0.1.pc
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
html-recursive info-recursive install-data-recursive \
|
||||
install-dvi-recursive install-exec-recursive \
|
||||
install-html-recursive install-info-recursive \
|
||||
install-pdf-recursive install-ps-recursive install-recursive \
|
||||
installcheck-recursive installdirs-recursive pdf-recursive \
|
||||
ps-recursive uninstall-recursive
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
|
||||
DATA = $(pkgconfig_DATA)
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
|
||||
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
|
||||
distdir dist dist-all distcheck
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
if test -d "$(distdir)"; then \
|
||||
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -rf "$(distdir)" \
|
||||
|| { sleep 5 && rm -rf "$(distdir)"; }; \
|
||||
else :; fi
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DOXYGEN = @DOXYGEN@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
YAML_LT_AGE = @YAML_LT_AGE@
|
||||
YAML_LT_CURRENT = @YAML_LT_CURRENT@
|
||||
YAML_LT_RELEASE = @YAML_LT_RELEASE@
|
||||
YAML_LT_REVISION = @YAML_LT_REVISION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
SUBDIRS = include src . tests win32
|
||||
EXTRA_DIST = README LICENSE CMakeLists.txt doc/doxygen.cfg
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = yaml-0.1.pc
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
am--refresh: Makefile
|
||||
@:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
config.h: stamp-h1
|
||||
@if test ! -f $@; then rm -f stamp-h1; else :; fi
|
||||
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
|
||||
|
||||
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status config.h
|
||||
$(srcdir)/config.h.in: $(am__configure_deps)
|
||||
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
|
||||
rm -f stamp-h1
|
||||
touch $@
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f config.h stamp-h1
|
||||
yaml-0.1.pc: $(top_builddir)/config.status $(srcdir)/yaml-0.1.pc.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
install-pkgconfigDATA: $(pkgconfig_DATA)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
|
||||
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-pkgconfigDATA:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
$(RECURSIVE_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
$(RECURSIVE_CLEAN_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
case "$@" in \
|
||||
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
*) list='$(SUBDIRS)' ;; \
|
||||
esac; \
|
||||
rev=''; for subdir in $$list; do \
|
||||
if test "$$subdir" = "."; then :; else \
|
||||
rev="$$subdir $$rev"; \
|
||||
fi; \
|
||||
done; \
|
||||
rev="$$rev ."; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
ctags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
done
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
empty_fix=.; \
|
||||
else \
|
||||
include_option=--include; \
|
||||
empty_fix=; \
|
||||
fi; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -755 \
|
||||
-exec chmod u+rwx,go+rx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-lzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-lzma: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist dist-all: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lzma*) \
|
||||
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
|
||||
*.tar.lz*) \
|
||||
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir); chmod a+w $(distdir)
|
||||
mkdir $(distdir)/_build
|
||||
mkdir $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@test -n '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: trying to run $@ with an empty' \
|
||||
'$$(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
$(am__cd) '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
all-am: Makefile $(DATA) config.h
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-recursive
|
||||
install-exec: install-exec-recursive
|
||||
install-data: install-data-recursive
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-recursive
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-recursive
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-recursive
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-pkgconfigDATA
|
||||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic \
|
||||
maintainer-clean-local
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-recursive
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-recursive
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-pkgconfigDATA
|
||||
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
|
||||
ctags-recursive install-am install-strip tags-recursive
|
||||
|
||||
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
|
||||
all all-am am--refresh check check-am clean clean-generic \
|
||||
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \
|
||||
dist-zip distcheck distclean distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags distcleancheck distdir \
|
||||
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-pkgconfigDATA install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs installdirs-am maintainer-clean \
|
||||
maintainer-clean-generic maintainer-clean-local mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-recursive uninstall uninstall-am \
|
||||
uninstall-pkgconfigDATA
|
||||
|
||||
|
||||
maintainer-clean-local:
|
||||
-rm -f aclocal.m4 config.h.in configure config/*
|
||||
-find ${builddir} -name Makefile.in -exec rm -f '{}' ';'
|
||||
|
||||
.PHONY: bootstrap
|
||||
bootstrap: maintainer-clean
|
||||
./bootstrap
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
27
lib/yaml/README
Normal file
27
lib/yaml/README
Normal file
|
@ -0,0 +1,27 @@
|
|||
LibYAML - A C library for parsing and emitting YAML.
|
||||
|
||||
To build and install the library, run:
|
||||
$ ./configure
|
||||
$ make
|
||||
# make install
|
||||
|
||||
If you checked the source code from the Subversion repository, run
|
||||
$ ./bootstrap
|
||||
$ ./configure
|
||||
$ make
|
||||
# make install
|
||||
|
||||
For more information, check the LibYAML homepage:
|
||||
'http://pyyaml.org/wiki/LibYAML'.
|
||||
|
||||
Post your questions and opinions to the YAML-Core mailing list:
|
||||
'http://lists.sourceforge.net/lists/listinfo/yaml-core'.
|
||||
|
||||
Submit bug reports and feature requests to the LibYAML bug tracker:
|
||||
'http://pyyaml.org/newticket?component=libyaml'.
|
||||
|
||||
LibYAML is written by Kirill Simonov <xi@resolvent.net>. It is released
|
||||
under the MIT license. See the file LICENSE for more details.
|
||||
|
||||
This project is developed for Python Software Foundation as a part of
|
||||
Google Summer of Code under the mentorship of Clark Evans.
|
37
lib/yaml/SConscript
Normal file
37
lib/yaml/SConscript
Normal file
|
@ -0,0 +1,37 @@
|
|||
# SConscript
|
||||
# vim: set ft=python:
|
||||
#
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
Import('env')
|
||||
Import('build_env')
|
||||
|
||||
|
||||
include_dir = env.Dir('include').srcnode()
|
||||
env.Append(CPPPATH=[include_dir])
|
||||
build_env.Append(CPPPATH=[include_dir])
|
||||
|
||||
env.Append(CPPDEFINES=[('YAML_VERSION_STRING', '\\"0.1.5\\"'),
|
||||
('YAML_VERSION_MAJOR', '0'),
|
||||
('YAML_VERSION_MINOR', '1'),
|
||||
('YAML_VERSION_PATCH', '5')])
|
||||
|
||||
|
||||
files = [
|
||||
'api.c',
|
||||
'dumper.c',
|
||||
'emitter.c',
|
||||
'loader.c',
|
||||
'parser.c',
|
||||
'reader.c',
|
||||
'scanner.c',
|
||||
'writer.c',
|
||||
]
|
||||
|
||||
objs = []
|
||||
for f in files:
|
||||
objs.append(env.Object(f))
|
||||
|
||||
|
||||
yaml = env.Library('yaml', objs)
|
||||
env.Alias('libyaml', yaml)
|
1392
lib/yaml/api.c
Normal file
1392
lib/yaml/api.c
Normal file
File diff suppressed because it is too large
Load diff
394
lib/yaml/dumper.c
Normal file
394
lib/yaml/dumper.c
Normal file
|
@ -0,0 +1,394 @@
|
|||
|
||||
#include "yaml_private.h"
|
||||
|
||||
/*
|
||||
* API functions.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_open(yaml_emitter_t *emitter);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_close(yaml_emitter_t *emitter);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
|
||||
|
||||
/*
|
||||
* Clean up functions.
|
||||
*/
|
||||
|
||||
static void
|
||||
yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter);
|
||||
|
||||
/*
|
||||
* Anchor functions.
|
||||
*/
|
||||
|
||||
static void
|
||||
yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index);
|
||||
|
||||
static yaml_char_t *
|
||||
yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id);
|
||||
|
||||
|
||||
/*
|
||||
* Serialize functions.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_emitter_dump_node(yaml_emitter_t *emitter, int index);
|
||||
|
||||
static int
|
||||
yaml_emitter_dump_alias(yaml_emitter_t *emitter, yaml_char_t *anchor);
|
||||
|
||||
static int
|
||||
yaml_emitter_dump_scalar(yaml_emitter_t *emitter, yaml_node_t *node,
|
||||
yaml_char_t *anchor);
|
||||
|
||||
static int
|
||||
yaml_emitter_dump_sequence(yaml_emitter_t *emitter, yaml_node_t *node,
|
||||
yaml_char_t *anchor);
|
||||
|
||||
static int
|
||||
yaml_emitter_dump_mapping(yaml_emitter_t *emitter, yaml_node_t *node,
|
||||
yaml_char_t *anchor);
|
||||
|
||||
/*
|
||||
* Issue a STREAM-START event.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_open(yaml_emitter_t *emitter)
|
||||
{
|
||||
yaml_event_t event;
|
||||
yaml_mark_t mark = { 0, 0, 0 };
|
||||
|
||||
assert(emitter); /* Non-NULL emitter object is required. */
|
||||
assert(!emitter->opened); /* Emitter should not be opened yet. */
|
||||
|
||||
STREAM_START_EVENT_INIT(event, YAML_ANY_ENCODING, mark, mark);
|
||||
|
||||
if (!yaml_emitter_emit(emitter, &event)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
emitter->opened = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Issue a STREAM-END event.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_close(yaml_emitter_t *emitter)
|
||||
{
|
||||
yaml_event_t event;
|
||||
yaml_mark_t mark = { 0, 0, 0 };
|
||||
|
||||
assert(emitter); /* Non-NULL emitter object is required. */
|
||||
assert(emitter->opened); /* Emitter should be opened. */
|
||||
|
||||
if (emitter->closed) return 1;
|
||||
|
||||
STREAM_END_EVENT_INIT(event, mark, mark);
|
||||
|
||||
if (!yaml_emitter_emit(emitter, &event)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
emitter->closed = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump a YAML document.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document)
|
||||
{
|
||||
yaml_event_t event;
|
||||
yaml_mark_t mark = { 0, 0, 0 };
|
||||
|
||||
assert(emitter); /* Non-NULL emitter object is required. */
|
||||
assert(document); /* Non-NULL emitter object is expected. */
|
||||
|
||||
emitter->document = document;
|
||||
|
||||
if (!emitter->opened) {
|
||||
if (!yaml_emitter_open(emitter)) goto error;
|
||||
}
|
||||
|
||||
if (STACK_EMPTY(emitter, document->nodes)) {
|
||||
if (!yaml_emitter_close(emitter)) goto error;
|
||||
yaml_emitter_delete_document_and_anchors(emitter);
|
||||
return 1;
|
||||
}
|
||||
|
||||
assert(emitter->opened); /* Emitter should be opened. */
|
||||
|
||||
emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors))
|
||||
* (document->nodes.top - document->nodes.start));
|
||||
if (!emitter->anchors) goto error;
|
||||
memset(emitter->anchors, 0, sizeof(*(emitter->anchors))
|
||||
* (document->nodes.top - document->nodes.start));
|
||||
|
||||
DOCUMENT_START_EVENT_INIT(event, document->version_directive,
|
||||
document->tag_directives.start, document->tag_directives.end,
|
||||
document->start_implicit, mark, mark);
|
||||
if (!yaml_emitter_emit(emitter, &event)) goto error;
|
||||
|
||||
yaml_emitter_anchor_node(emitter, 1);
|
||||
if (!yaml_emitter_dump_node(emitter, 1)) goto error;
|
||||
|
||||
DOCUMENT_END_EVENT_INIT(event, document->end_implicit, mark, mark);
|
||||
if (!yaml_emitter_emit(emitter, &event)) goto error;
|
||||
|
||||
yaml_emitter_delete_document_and_anchors(emitter);
|
||||
|
||||
return 1;
|
||||
|
||||
error:
|
||||
|
||||
yaml_emitter_delete_document_and_anchors(emitter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up the emitter object after a document is dumped.
|
||||
*/
|
||||
|
||||
static void
|
||||
yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (!emitter->anchors) {
|
||||
yaml_document_delete(emitter->document);
|
||||
emitter->document = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
for (index = 0; emitter->document->nodes.start + index
|
||||
< emitter->document->nodes.top; index ++) {
|
||||
yaml_node_t node = emitter->document->nodes.start[index];
|
||||
if (!emitter->anchors[index].serialized) {
|
||||
yaml_free(node.tag);
|
||||
if (node.type == YAML_SCALAR_NODE) {
|
||||
yaml_free(node.data.scalar.value);
|
||||
}
|
||||
}
|
||||
if (node.type == YAML_SEQUENCE_NODE) {
|
||||
STACK_DEL(emitter, node.data.sequence.items);
|
||||
}
|
||||
if (node.type == YAML_MAPPING_NODE) {
|
||||
STACK_DEL(emitter, node.data.mapping.pairs);
|
||||
}
|
||||
}
|
||||
|
||||
STACK_DEL(emitter, emitter->document->nodes);
|
||||
yaml_free(emitter->anchors);
|
||||
|
||||
emitter->anchors = NULL;
|
||||
emitter->last_anchor_id = 0;
|
||||
emitter->document = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the references of a node and assign the anchor id if needed.
|
||||
*/
|
||||
|
||||
static void
|
||||
yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index)
|
||||
{
|
||||
yaml_node_t *node = emitter->document->nodes.start + index - 1;
|
||||
yaml_node_item_t *item;
|
||||
yaml_node_pair_t *pair;
|
||||
|
||||
emitter->anchors[index-1].references ++;
|
||||
|
||||
if (emitter->anchors[index-1].references == 1) {
|
||||
switch (node->type) {
|
||||
case YAML_SEQUENCE_NODE:
|
||||
for (item = node->data.sequence.items.start;
|
||||
item < node->data.sequence.items.top; item ++) {
|
||||
yaml_emitter_anchor_node(emitter, *item);
|
||||
}
|
||||
break;
|
||||
case YAML_MAPPING_NODE:
|
||||
for (pair = node->data.mapping.pairs.start;
|
||||
pair < node->data.mapping.pairs.top; pair ++) {
|
||||
yaml_emitter_anchor_node(emitter, pair->key);
|
||||
yaml_emitter_anchor_node(emitter, pair->value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (emitter->anchors[index-1].references == 2) {
|
||||
emitter->anchors[index-1].anchor = (++ emitter->last_anchor_id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a textual representation for an anchor.
|
||||
*/
|
||||
|
||||
#define ANCHOR_TEMPLATE "id%03d"
|
||||
#define ANCHOR_TEMPLATE_LENGTH 16
|
||||
|
||||
static yaml_char_t *
|
||||
yaml_emitter_generate_anchor(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;
|
||||
}
|
||||
|
2329
lib/yaml/emitter.c
Normal file
2329
lib/yaml/emitter.c
Normal file
File diff suppressed because it is too large
Load diff
1971
lib/yaml/include/yaml.h
Normal file
1971
lib/yaml/include/yaml.h
Normal file
File diff suppressed because it is too large
Load diff
444
lib/yaml/loader.c
Normal file
444
lib/yaml/loader.c
Normal file
|
@ -0,0 +1,444 @@
|
|||
|
||||
#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);
|
||||
|
||||
/*
|
||||
* Composer functions.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
static int
|
||||
yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
static int
|
||||
yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
static int
|
||||
yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
static int
|
||||
yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
static int
|
||||
yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event);
|
||||
|
||||
/*
|
||||
* 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, INITIAL_STACK_SIZE))
|
||||
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, INITIAL_STACK_SIZE))
|
||||
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 *first_event)
|
||||
{
|
||||
yaml_event_t event;
|
||||
|
||||
assert(first_event->type == YAML_DOCUMENT_START_EVENT);
|
||||
/* DOCUMENT-START is expected. */
|
||||
|
||||
parser->document->version_directive
|
||||
= first_event->data.document_start.version_directive;
|
||||
parser->document->tag_directives.start
|
||||
= first_event->data.document_start.tag_directives.start;
|
||||
parser->document->tag_directives.end
|
||||
= first_event->data.document_start.tag_directives.end;
|
||||
parser->document->start_implicit
|
||||
= first_event->data.document_start.implicit;
|
||||
parser->document->start_mark = first_event->start_mark;
|
||||
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
|
||||
if (!yaml_parser_load_node(parser, &event)) return 0;
|
||||
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
assert(event.type == YAML_DOCUMENT_END_EVENT);
|
||||
/* DOCUMENT-END is expected. */
|
||||
|
||||
parser->document->end_implicit = event.data.document_end.implicit;
|
||||
parser->document->end_mark = event.end_mark;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compose a node.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event)
|
||||
{
|
||||
switch (first_event->type) {
|
||||
case YAML_ALIAS_EVENT:
|
||||
return yaml_parser_load_alias(parser, first_event);
|
||||
case YAML_SCALAR_EVENT:
|
||||
return yaml_parser_load_scalar(parser, first_event);
|
||||
case YAML_SEQUENCE_START_EVENT:
|
||||
return yaml_parser_load_sequence(parser, first_event);
|
||||
case YAML_MAPPING_START_EVENT:
|
||||
return yaml_parser_load_mapping(parser, first_event);
|
||||
default:
|
||||
assert(0); /* Could not happen. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 occurence",
|
||||
alias_data->mark, "second occurence", data.mark);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PUSH(parser, parser->aliases, data)) {
|
||||
yaml_free(anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compose a node corresponding to an alias.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event)
|
||||
{
|
||||
yaml_char_t *anchor = first_event->data.alias.anchor;
|
||||
yaml_alias_data_t *alias_data;
|
||||
|
||||
for (alias_data = parser->aliases.start;
|
||||
alias_data != parser->aliases.top; alias_data ++) {
|
||||
if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
|
||||
yaml_free(anchor);
|
||||
return alias_data->index;
|
||||
}
|
||||
}
|
||||
|
||||
yaml_free(anchor);
|
||||
return yaml_parser_set_composer_error(parser, "found undefined alias",
|
||||
first_event->start_mark);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compose a scalar node.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
|
||||
{
|
||||
yaml_node_t node;
|
||||
int index;
|
||||
yaml_char_t *tag = first_event->data.scalar.tag;
|
||||
|
||||
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
||||
|
||||
if (!tag || strcmp((char *)tag, "!") == 0) {
|
||||
yaml_free(tag);
|
||||
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
|
||||
if (!tag) goto error;
|
||||
}
|
||||
|
||||
SCALAR_NODE_INIT(node, tag, first_event->data.scalar.value,
|
||||
first_event->data.scalar.length, first_event->data.scalar.style,
|
||||
first_event->start_mark, first_event->end_mark);
|
||||
|
||||
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
||||
|
||||
index = parser->document->nodes.top - parser->document->nodes.start;
|
||||
|
||||
if (!yaml_parser_register_anchor(parser, index,
|
||||
first_event->data.scalar.anchor)) return 0;
|
||||
|
||||
return index;
|
||||
|
||||
error:
|
||||
yaml_free(tag);
|
||||
yaml_free(first_event->data.scalar.anchor);
|
||||
yaml_free(first_event->data.scalar.value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compose a sequence node.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
||||
{
|
||||
yaml_event_t event;
|
||||
yaml_node_t node;
|
||||
struct {
|
||||
yaml_node_item_t *start;
|
||||
yaml_node_item_t *end;
|
||||
yaml_node_item_t *top;
|
||||
} items = { NULL, NULL, NULL };
|
||||
int index, item_index;
|
||||
yaml_char_t *tag = first_event->data.sequence_start.tag;
|
||||
|
||||
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, INITIAL_STACK_SIZE)) goto error;
|
||||
|
||||
SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
|
||||
first_event->data.sequence_start.style,
|
||||
first_event->start_mark, first_event->end_mark);
|
||||
|
||||
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
||||
|
||||
index = parser->document->nodes.top - parser->document->nodes.start;
|
||||
|
||||
if (!yaml_parser_register_anchor(parser, index,
|
||||
first_event->data.sequence_start.anchor)) return 0;
|
||||
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
|
||||
while (event.type != YAML_SEQUENCE_END_EVENT) {
|
||||
if (!STACK_LIMIT(parser,
|
||||
parser->document->nodes.start[index-1].data.sequence.items,
|
||||
INT_MAX-1)) return 0;
|
||||
item_index = yaml_parser_load_node(parser, &event);
|
||||
if (!item_index) return 0;
|
||||
if (!PUSH(parser,
|
||||
parser->document->nodes.start[index-1].data.sequence.items,
|
||||
item_index)) return 0;
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
}
|
||||
|
||||
parser->document->nodes.start[index-1].end_mark = event.end_mark;
|
||||
|
||||
return index;
|
||||
|
||||
error:
|
||||
yaml_free(tag);
|
||||
yaml_free(first_event->data.sequence_start.anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compose a mapping node.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
||||
{
|
||||
yaml_event_t event;
|
||||
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_pair_t pair;
|
||||
yaml_char_t *tag = first_event->data.mapping_start.tag;
|
||||
|
||||
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
||||
|
||||
if (!tag || strcmp((char *)tag, "!") == 0) {
|
||||
yaml_free(tag);
|
||||
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
|
||||
if (!tag) goto error;
|
||||
}
|
||||
|
||||
if (!STACK_INIT(parser, pairs, INITIAL_STACK_SIZE)) goto error;
|
||||
|
||||
MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
|
||||
first_event->data.mapping_start.style,
|
||||
first_event->start_mark, first_event->end_mark);
|
||||
|
||||
if (!PUSH(parser, parser->document->nodes, node)) goto error;
|
||||
|
||||
index = parser->document->nodes.top - parser->document->nodes.start;
|
||||
|
||||
if (!yaml_parser_register_anchor(parser, index,
|
||||
first_event->data.mapping_start.anchor)) return 0;
|
||||
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
|
||||
while (event.type != YAML_MAPPING_END_EVENT) {
|
||||
if (!STACK_LIMIT(parser,
|
||||
parser->document->nodes.start[index-1].data.mapping.pairs,
|
||||
INT_MAX-1)) return 0;
|
||||
pair.key = yaml_parser_load_node(parser, &event);
|
||||
if (!pair.key) return 0;
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
pair.value = yaml_parser_load_node(parser, &event);
|
||||
if (!pair.value) return 0;
|
||||
if (!PUSH(parser,
|
||||
parser->document->nodes.start[index-1].data.mapping.pairs,
|
||||
pair)) return 0;
|
||||
if (!yaml_parser_parse(parser, &event)) return 0;
|
||||
}
|
||||
|
||||
parser->document->nodes.start[index-1].end_mark = event.end_mark;
|
||||
|
||||
return index;
|
||||
|
||||
error:
|
||||
yaml_free(tag);
|
||||
yaml_free(first_event->data.mapping_start.anchor);
|
||||
return 0;
|
||||
}
|
||||
|
1374
lib/yaml/parser.c
Normal file
1374
lib/yaml/parser.c
Normal file
File diff suppressed because it is too large
Load diff
469
lib/yaml/reader.c
Normal file
469
lib/yaml/reader.c
Normal file
|
@ -0,0 +1,469 @@
|
|||
|
||||
#include "yaml_private.h"
|
||||
|
||||
/*
|
||||
* Declarations.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
|
||||
size_t offset, int value);
|
||||
|
||||
static int
|
||||
yaml_parser_update_raw_buffer(yaml_parser_t *parser);
|
||||
|
||||
static int
|
||||
yaml_parser_determine_encoding(yaml_parser_t *parser);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
|
||||
|
||||
/*
|
||||
* Set the reader error and return 0.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
|
||||
size_t offset, int value)
|
||||
{
|
||||
parser->error = YAML_READER_ERROR;
|
||||
parser->problem = problem;
|
||||
parser->problem_offset = offset;
|
||||
parser->problem_value = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Byte order marks.
|
||||
*/
|
||||
|
||||
#define BOM_UTF8 "\xef\xbb\xbf"
|
||||
#define BOM_UTF16LE "\xff\xfe"
|
||||
#define BOM_UTF16BE "\xfe\xff"
|
||||
|
||||
/*
|
||||
* Determine the input stream encoding by checking the BOM symbol. If no BOM is
|
||||
* found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_determine_encoding(yaml_parser_t *parser)
|
||||
{
|
||||
/* Ensure that we had enough bytes in the raw buffer. */
|
||||
|
||||
while (!parser->eof
|
||||
&& parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
|
||||
if (!yaml_parser_update_raw_buffer(parser)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine the encoding. */
|
||||
|
||||
if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
|
||||
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF16LE, 2)) {
|
||||
parser->encoding = YAML_UTF16LE_ENCODING;
|
||||
parser->raw_buffer.pointer += 2;
|
||||
parser->offset += 2;
|
||||
}
|
||||
else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
|
||||
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF16BE, 2)) {
|
||||
parser->encoding = YAML_UTF16BE_ENCODING;
|
||||
parser->raw_buffer.pointer += 2;
|
||||
parser->offset += 2;
|
||||
}
|
||||
else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 3
|
||||
&& !memcmp(parser->raw_buffer.pointer, BOM_UTF8, 3)) {
|
||||
parser->encoding = YAML_UTF8_ENCODING;
|
||||
parser->raw_buffer.pointer += 3;
|
||||
parser->offset += 3;
|
||||
}
|
||||
else {
|
||||
parser->encoding = YAML_UTF8_ENCODING;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the raw buffer.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_parser_update_raw_buffer(yaml_parser_t *parser)
|
||||
{
|
||||
size_t size_read = 0;
|
||||
|
||||
/* Return if the raw buffer is full. */
|
||||
|
||||
if (parser->raw_buffer.start == parser->raw_buffer.pointer
|
||||
&& parser->raw_buffer.last == parser->raw_buffer.end)
|
||||
return 1;
|
||||
|
||||
/* Return on EOF. */
|
||||
|
||||
if (parser->eof) return 1;
|
||||
|
||||
/* Move the remaining bytes in the raw buffer to the beginning. */
|
||||
|
||||
if (parser->raw_buffer.start < parser->raw_buffer.pointer
|
||||
&& parser->raw_buffer.pointer < parser->raw_buffer.last) {
|
||||
memmove(parser->raw_buffer.start, parser->raw_buffer.pointer,
|
||||
parser->raw_buffer.last - parser->raw_buffer.pointer);
|
||||
}
|
||||
parser->raw_buffer.last -=
|
||||
parser->raw_buffer.pointer - parser->raw_buffer.start;
|
||||
parser->raw_buffer.pointer = parser->raw_buffer.start;
|
||||
|
||||
/* Call the read handler to fill the buffer. */
|
||||
|
||||
if (!parser->read_handler(parser->read_handler_data, parser->raw_buffer.last,
|
||||
parser->raw_buffer.end - parser->raw_buffer.last, &size_read)) {
|
||||
return yaml_parser_set_reader_error(parser, "input error",
|
||||
parser->offset, -1);
|
||||
}
|
||||
parser->raw_buffer.last += size_read;
|
||||
if (!size_read) {
|
||||
parser->eof = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that the buffer contains at least `length` characters.
|
||||
* Return 1 on success, 0 on failure.
|
||||
*
|
||||
* The length is supposed to be significantly less that the buffer size.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
||||
{
|
||||
int first = 1;
|
||||
|
||||
assert(parser->read_handler); /* Read handler must be set. */
|
||||
|
||||
/* If the EOF flag is set and the raw buffer is empty, do nothing. */
|
||||
|
||||
if (parser->eof && parser->raw_buffer.pointer == parser->raw_buffer.last)
|
||||
return 1;
|
||||
|
||||
/* Return if the buffer contains enough characters. */
|
||||
|
||||
if (parser->unread >= length)
|
||||
return 1;
|
||||
|
||||
/* Determine the input encoding if it is not known yet. */
|
||||
|
||||
if (!parser->encoding) {
|
||||
if (!yaml_parser_determine_encoding(parser))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move the unread characters to the beginning of the buffer. */
|
||||
|
||||
if (parser->buffer.start < parser->buffer.pointer
|
||||
&& parser->buffer.pointer < parser->buffer.last) {
|
||||
size_t size = parser->buffer.last - parser->buffer.pointer;
|
||||
memmove(parser->buffer.start, parser->buffer.pointer, size);
|
||||
parser->buffer.pointer = parser->buffer.start;
|
||||
parser->buffer.last = parser->buffer.start + size;
|
||||
}
|
||||
else if (parser->buffer.pointer == parser->buffer.last) {
|
||||
parser->buffer.pointer = parser->buffer.start;
|
||||
parser->buffer.last = parser->buffer.start;
|
||||
}
|
||||
|
||||
/* Fill the buffer until it has enough characters. */
|
||||
|
||||
while (parser->unread < length)
|
||||
{
|
||||
/* Fill the raw buffer if necessary. */
|
||||
|
||||
if (!first || parser->raw_buffer.pointer == parser->raw_buffer.last) {
|
||||
if (!yaml_parser_update_raw_buffer(parser)) return 0;
|
||||
}
|
||||
first = 0;
|
||||
|
||||
/* Decode the raw buffer. */
|
||||
|
||||
while (parser->raw_buffer.pointer != parser->raw_buffer.last)
|
||||
{
|
||||
unsigned int value = 0, value2 = 0;
|
||||
int incomplete = 0;
|
||||
unsigned char octet;
|
||||
unsigned int width = 0;
|
||||
int low, high;
|
||||
size_t k;
|
||||
size_t raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;
|
||||
|
||||
/* Decode the next character. */
|
||||
|
||||
switch (parser->encoding)
|
||||
{
|
||||
case YAML_UTF8_ENCODING:
|
||||
|
||||
/*
|
||||
* Decode a UTF-8 character. Check RFC 3629
|
||||
* (http://www.ietf.org/rfc/rfc3629.txt) for more details.
|
||||
*
|
||||
* The following table (taken from the RFC) is used for
|
||||
* decoding.
|
||||
*
|
||||
* Char. number range | UTF-8 octet sequence
|
||||
* (hexadecimal) | (binary)
|
||||
* --------------------+------------------------------------
|
||||
* 0000 0000-0000 007F | 0xxxxxxx
|
||||
* 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
|
||||
* 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*
|
||||
* Additionally, the characters in the range 0xD800-0xDFFF
|
||||
* are prohibited as they are reserved for use with UTF-16
|
||||
* surrogate pairs.
|
||||
*/
|
||||
|
||||
/* Determine the length of the UTF-8 sequence. */
|
||||
|
||||
octet = parser->raw_buffer.pointer[0];
|
||||
width = (octet & 0x80) == 0x00 ? 1 :
|
||||
(octet & 0xE0) == 0xC0 ? 2 :
|
||||
(octet & 0xF0) == 0xE0 ? 3 :
|
||||
(octet & 0xF8) == 0xF0 ? 4 : 0;
|
||||
|
||||
/* Check if the leading octet is valid. */
|
||||
|
||||
if (!width)
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"invalid leading UTF-8 octet",
|
||||
parser->offset, octet);
|
||||
|
||||
/* Check if the raw buffer contains an incomplete character. */
|
||||
|
||||
if (width > raw_unread) {
|
||||
if (parser->eof) {
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"incomplete UTF-8 octet sequence",
|
||||
parser->offset, -1);
|
||||
}
|
||||
incomplete = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Decode the leading octet. */
|
||||
|
||||
value = (octet & 0x80) == 0x00 ? octet & 0x7F :
|
||||
(octet & 0xE0) == 0xC0 ? octet & 0x1F :
|
||||
(octet & 0xF0) == 0xE0 ? octet & 0x0F :
|
||||
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
|
||||
|
||||
/* Check and decode the trailing octets. */
|
||||
|
||||
for (k = 1; k < width; k ++)
|
||||
{
|
||||
octet = parser->raw_buffer.pointer[k];
|
||||
|
||||
/* Check if the octet is valid. */
|
||||
|
||||
if ((octet & 0xC0) != 0x80)
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"invalid trailing UTF-8 octet",
|
||||
parser->offset+k, octet);
|
||||
|
||||
/* Decode the octet. */
|
||||
|
||||
value = (value << 6) + (octet & 0x3F);
|
||||
}
|
||||
|
||||
/* Check the length of the sequence against the value. */
|
||||
|
||||
if (!((width == 1) ||
|
||||
(width == 2 && value >= 0x80) ||
|
||||
(width == 3 && value >= 0x800) ||
|
||||
(width == 4 && value >= 0x10000)))
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"invalid length of a UTF-8 sequence",
|
||||
parser->offset, -1);
|
||||
|
||||
/* Check the range of the value. */
|
||||
|
||||
if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"invalid Unicode character",
|
||||
parser->offset, value);
|
||||
|
||||
break;
|
||||
|
||||
case YAML_UTF16LE_ENCODING:
|
||||
case YAML_UTF16BE_ENCODING:
|
||||
|
||||
low = (parser->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
|
||||
high = (parser->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
|
||||
|
||||
/*
|
||||
* The UTF-16 encoding is not as simple as one might
|
||||
* naively think. Check RFC 2781
|
||||
* (http://www.ietf.org/rfc/rfc2781.txt).
|
||||
*
|
||||
* Normally, two subsequent bytes describe a Unicode
|
||||
* character. However a special technique (called a
|
||||
* surrogate pair) is used for specifying character
|
||||
* values larger than 0xFFFF.
|
||||
*
|
||||
* A surrogate pair consists of two pseudo-characters:
|
||||
* high surrogate area (0xD800-0xDBFF)
|
||||
* low surrogate area (0xDC00-0xDFFF)
|
||||
*
|
||||
* The following formulas are used for decoding
|
||||
* and encoding characters using surrogate pairs:
|
||||
*
|
||||
* U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
|
||||
* U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
|
||||
* W1 = 110110yyyyyyyyyy
|
||||
* W2 = 110111xxxxxxxxxx
|
||||
*
|
||||
* where U is the character value, W1 is the high surrogate
|
||||
* area, W2 is the low surrogate area.
|
||||
*/
|
||||
|
||||
/* Check for incomplete UTF-16 character. */
|
||||
|
||||
if (raw_unread < 2) {
|
||||
if (parser->eof) {
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"incomplete UTF-16 character",
|
||||
parser->offset, -1);
|
||||
}
|
||||
incomplete = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the character. */
|
||||
|
||||
value = parser->raw_buffer.pointer[low]
|
||||
+ (parser->raw_buffer.pointer[high] << 8);
|
||||
|
||||
/* Check for unexpected low surrogate area. */
|
||||
|
||||
if ((value & 0xFC00) == 0xDC00)
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"unexpected low surrogate area",
|
||||
parser->offset, value);
|
||||
|
||||
/* Check for a high surrogate area. */
|
||||
|
||||
if ((value & 0xFC00) == 0xD800) {
|
||||
|
||||
width = 4;
|
||||
|
||||
/* Check for incomplete surrogate pair. */
|
||||
|
||||
if (raw_unread < 4) {
|
||||
if (parser->eof) {
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"incomplete UTF-16 surrogate pair",
|
||||
parser->offset, -1);
|
||||
}
|
||||
incomplete = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the next character. */
|
||||
|
||||
value2 = parser->raw_buffer.pointer[low+2]
|
||||
+ (parser->raw_buffer.pointer[high+2] << 8);
|
||||
|
||||
/* Check for a low surrogate area. */
|
||||
|
||||
if ((value2 & 0xFC00) != 0xDC00)
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"expected low surrogate area",
|
||||
parser->offset+2, value2);
|
||||
|
||||
/* Generate the value of the surrogate pair. */
|
||||
|
||||
value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF);
|
||||
}
|
||||
|
||||
else {
|
||||
width = 2;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(1); /* Impossible. */
|
||||
}
|
||||
|
||||
/* Check if the raw buffer contains enough bytes to form a character. */
|
||||
|
||||
if (incomplete) break;
|
||||
|
||||
/*
|
||||
* Check if the character is in the allowed range:
|
||||
* #x9 | #xA | #xD | [#x20-#x7E] (8 bit)
|
||||
* | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit)
|
||||
* | [#x10000-#x10FFFF] (32 bit)
|
||||
*/
|
||||
|
||||
if (! (value == 0x09 || value == 0x0A || value == 0x0D
|
||||
|| (value >= 0x20 && value <= 0x7E)
|
||||
|| (value == 0x85) || (value >= 0xA0 && value <= 0xD7FF)
|
||||
|| (value >= 0xE000 && value <= 0xFFFD)
|
||||
|| (value >= 0x10000 && value <= 0x10FFFF)))
|
||||
return yaml_parser_set_reader_error(parser,
|
||||
"control characters are not allowed",
|
||||
parser->offset, value);
|
||||
|
||||
/* Move the raw pointers. */
|
||||
|
||||
parser->raw_buffer.pointer += width;
|
||||
parser->offset += width;
|
||||
|
||||
/* Finally put the character into the buffer. */
|
||||
|
||||
/* 0000 0000-0000 007F -> 0xxxxxxx */
|
||||
if (value <= 0x7F) {
|
||||
*(parser->buffer.last++) = value;
|
||||
}
|
||||
/* 0000 0080-0000 07FF -> 110xxxxx 10xxxxxx */
|
||||
else if (value <= 0x7FF) {
|
||||
*(parser->buffer.last++) = 0xC0 + (value >> 6);
|
||||
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
|
||||
}
|
||||
/* 0000 0800-0000 FFFF -> 1110xxxx 10xxxxxx 10xxxxxx */
|
||||
else if (value <= 0xFFFF) {
|
||||
*(parser->buffer.last++) = 0xE0 + (value >> 12);
|
||||
*(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
|
||||
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
|
||||
}
|
||||
/* 0001 0000-0010 FFFF -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
|
||||
else {
|
||||
*(parser->buffer.last++) = 0xF0 + (value >> 18);
|
||||
*(parser->buffer.last++) = 0x80 + ((value >> 12) & 0x3F);
|
||||
*(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
|
||||
*(parser->buffer.last++) = 0x80 + (value & 0x3F);
|
||||
}
|
||||
|
||||
parser->unread ++;
|
||||
}
|
||||
|
||||
/* On EOF, put NUL into the buffer and return. */
|
||||
|
||||
if (parser->eof) {
|
||||
*(parser->buffer.last++) = '\0';
|
||||
parser->unread ++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (parser->offset >= PTRDIFF_MAX)
|
||||
return yaml_parser_set_reader_error(parser, "input is too long",
|
||||
PTRDIFF_MAX, -1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
3580
lib/yaml/scanner.c
Normal file
3580
lib/yaml/scanner.c
Normal file
File diff suppressed because it is too large
Load diff
141
lib/yaml/writer.c
Normal file
141
lib/yaml/writer.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
|
||||
#include "yaml_private.h"
|
||||
|
||||
/*
|
||||
* Declarations.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_flush(yaml_emitter_t *emitter);
|
||||
|
||||
/*
|
||||
* Set the writer error and return 0.
|
||||
*/
|
||||
|
||||
static int
|
||||
yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem)
|
||||
{
|
||||
emitter->error = YAML_WRITER_ERROR;
|
||||
emitter->problem = problem;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush the output buffer.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_emitter_flush(yaml_emitter_t *emitter)
|
||||
{
|
||||
int low, high;
|
||||
|
||||
assert(emitter); /* Non-NULL emitter object is expected. */
|
||||
assert(emitter->write_handler); /* Write handler must be set. */
|
||||
assert(emitter->encoding); /* Output encoding must be set. */
|
||||
|
||||
emitter->buffer.last = emitter->buffer.pointer;
|
||||
emitter->buffer.pointer = emitter->buffer.start;
|
||||
|
||||
/* Check if the buffer is empty. */
|
||||
|
||||
if (emitter->buffer.start == emitter->buffer.last) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If the output encoding is UTF-8, we don't need to recode the buffer. */
|
||||
|
||||
if (emitter->encoding == YAML_UTF8_ENCODING)
|
||||
{
|
||||
if (emitter->write_handler(emitter->write_handler_data,
|
||||
emitter->buffer.start,
|
||||
emitter->buffer.last - emitter->buffer.start)) {
|
||||
emitter->buffer.last = emitter->buffer.start;
|
||||
emitter->buffer.pointer = emitter->buffer.start;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return yaml_emitter_set_writer_error(emitter, "write error");
|
||||
}
|
||||
}
|
||||
|
||||
/* Recode the buffer into the raw buffer. */
|
||||
|
||||
low = (emitter->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
|
||||
high = (emitter->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
|
||||
|
||||
while (emitter->buffer.pointer != emitter->buffer.last)
|
||||
{
|
||||
unsigned char octet;
|
||||
unsigned int width;
|
||||
unsigned int value;
|
||||
size_t k;
|
||||
|
||||
/*
|
||||
* See the "reader.c" code for more details on UTF-8 encoding. Note
|
||||
* that we assume that the buffer contains a valid UTF-8 sequence.
|
||||
*/
|
||||
|
||||
/* Read the next UTF-8 character. */
|
||||
|
||||
octet = emitter->buffer.pointer[0];
|
||||
|
||||
width = (octet & 0x80) == 0x00 ? 1 :
|
||||
(octet & 0xE0) == 0xC0 ? 2 :
|
||||
(octet & 0xF0) == 0xE0 ? 3 :
|
||||
(octet & 0xF8) == 0xF0 ? 4 : 0;
|
||||
|
||||
value = (octet & 0x80) == 0x00 ? octet & 0x7F :
|
||||
(octet & 0xE0) == 0xC0 ? octet & 0x1F :
|
||||
(octet & 0xF0) == 0xE0 ? octet & 0x0F :
|
||||
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
|
||||
|
||||
for (k = 1; k < width; k ++) {
|
||||
octet = emitter->buffer.pointer[k];
|
||||
value = (value << 6) + (octet & 0x3F);
|
||||
}
|
||||
|
||||
emitter->buffer.pointer += width;
|
||||
|
||||
/* Write the character. */
|
||||
|
||||
if (value < 0x10000)
|
||||
{
|
||||
emitter->raw_buffer.last[high] = value >> 8;
|
||||
emitter->raw_buffer.last[low] = value & 0xFF;
|
||||
|
||||
emitter->raw_buffer.last += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write the character using a surrogate pair (check "reader.c"). */
|
||||
|
||||
value -= 0x10000;
|
||||
emitter->raw_buffer.last[high] = 0xD8 + (value >> 18);
|
||||
emitter->raw_buffer.last[low] = (value >> 10) & 0xFF;
|
||||
emitter->raw_buffer.last[high+2] = 0xDC + ((value >> 8) & 0xFF);
|
||||
emitter->raw_buffer.last[low+2] = value & 0xFF;
|
||||
|
||||
emitter->raw_buffer.last += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the raw buffer. */
|
||||
|
||||
if (emitter->write_handler(emitter->write_handler_data,
|
||||
emitter->raw_buffer.start,
|
||||
emitter->raw_buffer.last - emitter->raw_buffer.start)) {
|
||||
emitter->buffer.last = emitter->buffer.start;
|
||||
emitter->buffer.pointer = emitter->buffer.start;
|
||||
emitter->raw_buffer.last = emitter->raw_buffer.start;
|
||||
emitter->raw_buffer.pointer = emitter->raw_buffer.start;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return yaml_emitter_set_writer_error(emitter, "write error");
|
||||
}
|
||||
}
|
||||
|
657
lib/yaml/yaml_private.h
Normal file
657
lib/yaml/yaml_private.h
Normal file
|
@ -0,0 +1,657 @@
|
|||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <yaml.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#ifdef _WIN64
|
||||
#define PTRDIFF_MAX _I64_MAX
|
||||
#else
|
||||
#define PTRDIFF_MAX INT_MAX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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 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_malloc(size)) ? \
|
||||
((buffer).last = (buffer).pointer = (buffer).start, \
|
||||
(buffer).end = (buffer).start+(size), \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
#define BUFFER_DEL(context,buffer) \
|
||||
(yaml_free((buffer).start), \
|
||||
(buffer).start = (buffer).pointer = (buffer).end = 0)
|
||||
|
||||
/*
|
||||
* String management.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
yaml_char_t *start;
|
||||
yaml_char_t *end;
|
||||
yaml_char_t *pointer;
|
||||
} yaml_string_t;
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_string_extend(yaml_char_t **start,
|
||||
yaml_char_t **pointer, yaml_char_t **end);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_string_join(
|
||||
yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
|
||||
yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end);
|
||||
|
||||
#define NULL_STRING { NULL, NULL, NULL }
|
||||
|
||||
#define STRING(string,length) { (string), (string)+(length), (string) }
|
||||
|
||||
#define STRING_ASSIGN(value,string,length) \
|
||||
((value).start = (string), \
|
||||
(value).end = (string)+(length), \
|
||||
(value).pointer = (string))
|
||||
|
||||
#define STRING_INIT(context,string,size) \
|
||||
(((string).start = yaml_malloc(size)) ? \
|
||||
((string).pointer = (string).start, \
|
||||
(string).end = (string).start+(size), \
|
||||
memset((string).start, 0, (size)), \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
#define STRING_DEL(context,string) \
|
||||
(yaml_free((string).start), \
|
||||
(string).start = (string).pointer = (string).end = 0)
|
||||
|
||||
#define STRING_EXTEND(context,string) \
|
||||
(((string).pointer+5 < (string).end) \
|
||||
|| yaml_string_extend(&(string).start, \
|
||||
&(string).pointer, &(string).end))
|
||||
|
||||
#define CLEAR(context,string) \
|
||||
((string).pointer = (string).start, \
|
||||
memset((string).start, 0, (string).end-(string).start))
|
||||
|
||||
#define JOIN(context,string_a,string_b) \
|
||||
((yaml_string_join(&(string_a).start, &(string_a).pointer, \
|
||||
&(string_a).end, &(string_b).start, \
|
||||
&(string_b).pointer, &(string_b).end)) ? \
|
||||
((string_b).pointer = (string_b).start, \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
/*
|
||||
* String check operations.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check the octet at the specified position.
|
||||
*/
|
||||
|
||||
#define CHECK_AT(string,octet,offset) \
|
||||
((string).pointer[offset] == (yaml_char_t)(octet))
|
||||
|
||||
/*
|
||||
* Check the current octet in the buffer.
|
||||
*/
|
||||
|
||||
#define CHECK(string,octet) CHECK_AT((string),(octet),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is an alphabetical
|
||||
* character, a digit, '_', or '-'.
|
||||
*/
|
||||
|
||||
#define IS_ALPHA_AT(string,offset) \
|
||||
(((string).pointer[offset] >= (yaml_char_t) '0' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) '9') || \
|
||||
((string).pointer[offset] >= (yaml_char_t) 'A' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'Z') || \
|
||||
((string).pointer[offset] >= (yaml_char_t) 'a' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'z') || \
|
||||
(string).pointer[offset] == '_' || \
|
||||
(string).pointer[offset] == '-')
|
||||
|
||||
#define IS_ALPHA(string) IS_ALPHA_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is a digit.
|
||||
*/
|
||||
|
||||
#define IS_DIGIT_AT(string,offset) \
|
||||
(((string).pointer[offset] >= (yaml_char_t) '0' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) '9'))
|
||||
|
||||
#define IS_DIGIT(string) IS_DIGIT_AT((string),0)
|
||||
|
||||
/*
|
||||
* Get the value of a digit.
|
||||
*/
|
||||
|
||||
#define AS_DIGIT_AT(string,offset) \
|
||||
((string).pointer[offset] - (yaml_char_t) '0')
|
||||
|
||||
#define AS_DIGIT(string) AS_DIGIT_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is a hex-digit.
|
||||
*/
|
||||
|
||||
#define IS_HEX_AT(string,offset) \
|
||||
(((string).pointer[offset] >= (yaml_char_t) '0' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) '9') || \
|
||||
((string).pointer[offset] >= (yaml_char_t) 'A' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'F') || \
|
||||
((string).pointer[offset] >= (yaml_char_t) 'a' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'f'))
|
||||
|
||||
#define IS_HEX(string) IS_HEX_AT((string),0)
|
||||
|
||||
/*
|
||||
* Get the value of a hex-digit.
|
||||
*/
|
||||
|
||||
#define AS_HEX_AT(string,offset) \
|
||||
(((string).pointer[offset] >= (yaml_char_t) 'A' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'F') ? \
|
||||
((string).pointer[offset] - (yaml_char_t) 'A' + 10) : \
|
||||
((string).pointer[offset] >= (yaml_char_t) 'a' && \
|
||||
(string).pointer[offset] <= (yaml_char_t) 'f') ? \
|
||||
((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
|
||||
((string).pointer[offset] - (yaml_char_t) '0'))
|
||||
|
||||
#define AS_HEX(string) AS_HEX_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character is ASCII.
|
||||
*/
|
||||
|
||||
#define IS_ASCII_AT(string,offset) \
|
||||
((string).pointer[offset] <= (yaml_char_t) '\x7F')
|
||||
|
||||
#define IS_ASCII(string) IS_ASCII_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character can be printed unescaped.
|
||||
*/
|
||||
|
||||
#define IS_PRINTABLE_AT(string,offset) \
|
||||
(((string).pointer[offset] == 0x0A) /* . == #x0A */ \
|
||||
|| ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \
|
||||
&& (string).pointer[offset] <= 0x7E) \
|
||||
|| ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \
|
||||
&& (string).pointer[offset+1] >= 0xA0) \
|
||||
|| ((string).pointer[offset] > 0xC2 \
|
||||
&& (string).pointer[offset] < 0xED) \
|
||||
|| ((string).pointer[offset] == 0xED \
|
||||
&& (string).pointer[offset+1] < 0xA0) \
|
||||
|| ((string).pointer[offset] == 0xEE) \
|
||||
|| ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \
|
||||
&& !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \
|
||||
&& (string).pointer[offset+2] == 0xBF) \
|
||||
&& !((string).pointer[offset+1] == 0xBF \
|
||||
&& ((string).pointer[offset+2] == 0xBE \
|
||||
|| (string).pointer[offset+2] == 0xBF))))
|
||||
|
||||
#define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is NUL.
|
||||
*/
|
||||
|
||||
#define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset))
|
||||
|
||||
#define IS_Z(string) IS_Z_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is BOM.
|
||||
*/
|
||||
|
||||
#define IS_BOM_AT(string,offset) \
|
||||
(CHECK_AT((string),'\xEF',(offset)) \
|
||||
&& CHECK_AT((string),'\xBB',(offset)+1) \
|
||||
&& CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */
|
||||
|
||||
#define IS_BOM(string) IS_BOM_AT(string,0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is space.
|
||||
*/
|
||||
|
||||
#define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset))
|
||||
|
||||
#define IS_SPACE(string) IS_SPACE_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is tab.
|
||||
*/
|
||||
|
||||
#define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset))
|
||||
|
||||
#define IS_TAB(string) IS_TAB_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is blank (space or tab).
|
||||
*/
|
||||
|
||||
#define IS_BLANK_AT(string,offset) \
|
||||
(IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset)))
|
||||
|
||||
#define IS_BLANK(string) IS_BLANK_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character at the specified position is a line break.
|
||||
*/
|
||||
|
||||
#define IS_BREAK_AT(string,offset) \
|
||||
(CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \
|
||||
|| CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \
|
||||
|| (CHECK_AT((string),'\xC2',(offset)) \
|
||||
&& CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \
|
||||
|| (CHECK_AT((string),'\xE2',(offset)) \
|
||||
&& CHECK_AT((string),'\x80',(offset)+1) \
|
||||
&& CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \
|
||||
|| (CHECK_AT((string),'\xE2',(offset)) \
|
||||
&& CHECK_AT((string),'\x80',(offset)+1) \
|
||||
&& CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */
|
||||
|
||||
#define IS_BREAK(string) IS_BREAK_AT((string),0)
|
||||
|
||||
#define IS_CRLF_AT(string,offset) \
|
||||
(CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1))
|
||||
|
||||
#define IS_CRLF(string) IS_CRLF_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character is a line break or NUL.
|
||||
*/
|
||||
|
||||
#define IS_BREAKZ_AT(string,offset) \
|
||||
(IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset)))
|
||||
|
||||
#define IS_BREAKZ(string) IS_BREAKZ_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character is a line break, space, or NUL.
|
||||
*/
|
||||
|
||||
#define IS_SPACEZ_AT(string,offset) \
|
||||
(IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
|
||||
|
||||
#define IS_SPACEZ(string) IS_SPACEZ_AT((string),0)
|
||||
|
||||
/*
|
||||
* Check if the character is a line break, space, tab, or NUL.
|
||||
*/
|
||||
|
||||
#define IS_BLANKZ_AT(string,offset) \
|
||||
(IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
|
||||
|
||||
#define IS_BLANKZ(string) IS_BLANKZ_AT((string),0)
|
||||
|
||||
/*
|
||||
* Determine the width of the character.
|
||||
*/
|
||||
|
||||
#define WIDTH_AT(string,offset) \
|
||||
(((string).pointer[offset] & 0x80) == 0x00 ? 1 : \
|
||||
((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \
|
||||
((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \
|
||||
((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
|
||||
|
||||
#define WIDTH(string) WIDTH_AT((string),0)
|
||||
|
||||
/*
|
||||
* Move the string pointer to the next character.
|
||||
*/
|
||||
|
||||
#define MOVE(string) ((string).pointer += WIDTH((string)))
|
||||
|
||||
/*
|
||||
* Copy a character and move the pointers of both strings.
|
||||
*/
|
||||
|
||||
#define COPY(string_a,string_b) \
|
||||
((*(string_b).pointer & 0x80) == 0x00 ? \
|
||||
(*((string_a).pointer++) = *((string_b).pointer++)) : \
|
||||
(*(string_b).pointer & 0xE0) == 0xC0 ? \
|
||||
(*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++)) : \
|
||||
(*(string_b).pointer & 0xF0) == 0xE0 ? \
|
||||
(*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++)) : \
|
||||
(*(string_b).pointer & 0xF8) == 0xF0 ? \
|
||||
(*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++), \
|
||||
*((string_a).pointer++) = *((string_b).pointer++)) : 0)
|
||||
|
||||
/*
|
||||
* Stack and queue management.
|
||||
*/
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_stack_extend(void **start, void **top, void **end);
|
||||
|
||||
YAML_DECLARE(int)
|
||||
yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
||||
|
||||
#define STACK_INIT(context,stack,size) \
|
||||
(((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
|
||||
((stack).top = (stack).start, \
|
||||
(stack).end = (stack).start+(size), \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
#define STACK_DEL(context,stack) \
|
||||
(yaml_free((stack).start), \
|
||||
(stack).start = (stack).top = (stack).end = 0)
|
||||
|
||||
#define STACK_EMPTY(context,stack) \
|
||||
((stack).start == (stack).top)
|
||||
|
||||
#define STACK_LIMIT(context,stack,size) \
|
||||
((stack).top - (stack).start < (size) ? \
|
||||
1 : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
#define PUSH(context,stack,value) \
|
||||
(((stack).top != (stack).end \
|
||||
|| yaml_stack_extend((void **)&(stack).start, \
|
||||
(void **)&(stack).top, (void **)&(stack).end)) ? \
|
||||
(*((stack).top++) = value, \
|
||||
1) : \
|
||||
((context)->error = YAML_MEMORY_ERROR, \
|
||||
0))
|
||||
|
||||
#define POP(context,stack) \
|
||||
(*(--(stack).top))
|
||||
|
||||
#define QUEUE_INIT(context,queue,size) \
|
||||
(((queue).start = 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))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue