diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 27 | ||||
| -rw-r--r-- | tests/Makefile.am | 5 | ||||
| -rw-r--r-- | tests/Makefile.in | 672 | ||||
| -rw-r--r-- | tests/ReadMe.md | 63 | ||||
| -rw-r--r-- | tests/example-deconstructor-alt.c | 150 | ||||
| -rw-r--r-- | tests/example-deconstructor.c | 197 | ||||
| -rw-r--r-- | tests/example-reformatter-alt.c | 22 | ||||
| -rw-r--r-- | tests/example-reformatter.c | 28 | ||||
| -rwxr-xr-x | tests/run-all-tests.sh | 29 | ||||
| -rw-r--r-- | tests/run-dumper.c | 27 | ||||
| -rw-r--r-- | tests/run-emitter-test-suite.c | 290 | ||||
| -rw-r--r-- | tests/run-emitter.c | 14 | ||||
| -rw-r--r-- | tests/run-parser-test-suite.c | 189 | ||||
| -rw-r--r-- | tests/test-reader.c | 28 | ||||
| -rw-r--r-- | tests/test-version.c | 6 |
15 files changed, 837 insertions, 910 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000000..be2ce399a6bf --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,27 @@ + +function(add_yaml_executable name) + add_executable(${name} ${name}.c) + target_link_libraries(${name} yaml) +endfunction() + +foreach(name IN ITEMS + example-deconstructor + example-deconstructor-alt + example-reformatter + example-reformatter-alt + run-dumper + run-emitter + run-emitter-test-suite + run-loader + run-parser + run-parser-test-suite + run-scanner + test-reader + test-version + ) + add_yaml_executable(${name}) +endforeach() + +add_test(NAME version COMMAND test-version) +add_test(NAME reader COMMAND test-reader) + diff --git a/tests/Makefile.am b/tests/Makefile.am index 72e84d2a2217..9597b7fef3ef 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,9 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -Wall #AM_CFLAGS = -Wno-pointer-sign LDADD = $(top_builddir)/src/libyaml.la TESTS = test-version test-reader check_PROGRAMS = test-version test-reader noinst_PROGRAMS = run-scanner run-parser run-loader run-emitter run-dumper \ example-reformatter example-reformatter-alt \ - example-deconstructor example-deconstructor-alt + example-deconstructor example-deconstructor-alt \ + run-parser-test-suite run-emitter-test-suite diff --git a/tests/Makefile.in b/tests/Makefile.in deleted file mode 100644 index 2939d9fd2b61..000000000000 --- a/tests/Makefile.in +++ /dev/null @@ -1,672 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ -TESTS = test-version$(EXEEXT) test-reader$(EXEEXT) -check_PROGRAMS = test-version$(EXEEXT) test-reader$(EXEEXT) -noinst_PROGRAMS = run-scanner$(EXEEXT) run-parser$(EXEEXT) \ - run-loader$(EXEEXT) run-emitter$(EXEEXT) run-dumper$(EXEEXT) \ - example-reformatter$(EXEEXT) example-reformatter-alt$(EXEEXT) \ - example-deconstructor$(EXEEXT) \ - example-deconstructor-alt$(EXEEXT) -subdir = tests -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -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) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -example_deconstructor_SOURCES = example-deconstructor.c -example_deconstructor_OBJECTS = example-deconstructor.$(OBJEXT) -example_deconstructor_LDADD = $(LDADD) -example_deconstructor_DEPENDENCIES = $(top_builddir)/src/libyaml.la -example_deconstructor_alt_SOURCES = example-deconstructor-alt.c -example_deconstructor_alt_OBJECTS = \ - example-deconstructor-alt.$(OBJEXT) -example_deconstructor_alt_LDADD = $(LDADD) -example_deconstructor_alt_DEPENDENCIES = \ - $(top_builddir)/src/libyaml.la -example_reformatter_SOURCES = example-reformatter.c -example_reformatter_OBJECTS = example-reformatter.$(OBJEXT) -example_reformatter_LDADD = $(LDADD) -example_reformatter_DEPENDENCIES = $(top_builddir)/src/libyaml.la -example_reformatter_alt_SOURCES = example-reformatter-alt.c -example_reformatter_alt_OBJECTS = example-reformatter-alt.$(OBJEXT) -example_reformatter_alt_LDADD = $(LDADD) -example_reformatter_alt_DEPENDENCIES = $(top_builddir)/src/libyaml.la -run_dumper_SOURCES = run-dumper.c -run_dumper_OBJECTS = run-dumper.$(OBJEXT) -run_dumper_LDADD = $(LDADD) -run_dumper_DEPENDENCIES = $(top_builddir)/src/libyaml.la -run_emitter_SOURCES = run-emitter.c -run_emitter_OBJECTS = run-emitter.$(OBJEXT) -run_emitter_LDADD = $(LDADD) -run_emitter_DEPENDENCIES = $(top_builddir)/src/libyaml.la -run_loader_SOURCES = run-loader.c -run_loader_OBJECTS = run-loader.$(OBJEXT) -run_loader_LDADD = $(LDADD) -run_loader_DEPENDENCIES = $(top_builddir)/src/libyaml.la -run_parser_SOURCES = run-parser.c -run_parser_OBJECTS = run-parser.$(OBJEXT) -run_parser_LDADD = $(LDADD) -run_parser_DEPENDENCIES = $(top_builddir)/src/libyaml.la -run_scanner_SOURCES = run-scanner.c -run_scanner_OBJECTS = run-scanner.$(OBJEXT) -run_scanner_LDADD = $(LDADD) -run_scanner_DEPENDENCIES = $(top_builddir)/src/libyaml.la -test_reader_SOURCES = test-reader.c -test_reader_OBJECTS = test-reader.$(OBJEXT) -test_reader_LDADD = $(LDADD) -test_reader_DEPENDENCIES = $(top_builddir)/src/libyaml.la -test_version_SOURCES = test-version.c -test_version_OBJECTS = test-version.$(OBJEXT) -test_version_LDADD = $(LDADD) -test_version_DEPENDENCIES = $(top_builddir)/src/libyaml.la -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/config/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = example-deconstructor.c example-deconstructor-alt.c \ - example-reformatter.c example-reformatter-alt.c run-dumper.c \ - run-emitter.c run-loader.c run-parser.c run-scanner.c \ - test-reader.c test-version.c -DIST_SOURCES = example-deconstructor.c example-deconstructor-alt.c \ - example-reformatter.c example-reformatter-alt.c run-dumper.c \ - run-emitter.c run-loader.c run-parser.c run-scanner.c \ - test-reader.c test-version.c -ETAGS = etags -CTAGS = ctags -am__tty_colors = \ -red=; grn=; lgn=; blu=; std= -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -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@ -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@ -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_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@ -lt_ECHO = @lt_ECHO@ -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@ -AM_CPPFLAGS = -I$(top_srcdir)/include -#AM_CFLAGS = -Wno-pointer-sign -LDADD = $(top_builddir)/src/libyaml.la -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign tests/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -example-deconstructor$(EXEEXT): $(example_deconstructor_OBJECTS) $(example_deconstructor_DEPENDENCIES) - @rm -f example-deconstructor$(EXEEXT) - $(LINK) $(example_deconstructor_OBJECTS) $(example_deconstructor_LDADD) $(LIBS) -example-deconstructor-alt$(EXEEXT): $(example_deconstructor_alt_OBJECTS) $(example_deconstructor_alt_DEPENDENCIES) - @rm -f example-deconstructor-alt$(EXEEXT) - $(LINK) $(example_deconstructor_alt_OBJECTS) $(example_deconstructor_alt_LDADD) $(LIBS) -example-reformatter$(EXEEXT): $(example_reformatter_OBJECTS) $(example_reformatter_DEPENDENCIES) - @rm -f example-reformatter$(EXEEXT) - $(LINK) $(example_reformatter_OBJECTS) $(example_reformatter_LDADD) $(LIBS) -example-reformatter-alt$(EXEEXT): $(example_reformatter_alt_OBJECTS) $(example_reformatter_alt_DEPENDENCIES) - @rm -f example-reformatter-alt$(EXEEXT) - $(LINK) $(example_reformatter_alt_OBJECTS) $(example_reformatter_alt_LDADD) $(LIBS) -run-dumper$(EXEEXT): $(run_dumper_OBJECTS) $(run_dumper_DEPENDENCIES) - @rm -f run-dumper$(EXEEXT) - $(LINK) $(run_dumper_OBJECTS) $(run_dumper_LDADD) $(LIBS) -run-emitter$(EXEEXT): $(run_emitter_OBJECTS) $(run_emitter_DEPENDENCIES) - @rm -f run-emitter$(EXEEXT) - $(LINK) $(run_emitter_OBJECTS) $(run_emitter_LDADD) $(LIBS) -run-loader$(EXEEXT): $(run_loader_OBJECTS) $(run_loader_DEPENDENCIES) - @rm -f run-loader$(EXEEXT) - $(LINK) $(run_loader_OBJECTS) $(run_loader_LDADD) $(LIBS) -run-parser$(EXEEXT): $(run_parser_OBJECTS) $(run_parser_DEPENDENCIES) - @rm -f run-parser$(EXEEXT) - $(LINK) $(run_parser_OBJECTS) $(run_parser_LDADD) $(LIBS) -run-scanner$(EXEEXT): $(run_scanner_OBJECTS) $(run_scanner_DEPENDENCIES) - @rm -f run-scanner$(EXEEXT) - $(LINK) $(run_scanner_OBJECTS) $(run_scanner_LDADD) $(LIBS) -test-reader$(EXEEXT): $(test_reader_OBJECTS) $(test_reader_DEPENDENCIES) - @rm -f test-reader$(EXEEXT) - $(LINK) $(test_reader_OBJECTS) $(test_reader_LDADD) $(LIBS) -test-version$(EXEEXT): $(test_version_OBJECTS) $(test_version_DEPENDENCIES) - @rm -f test-version$(EXEEXT) - $(LINK) $(test_version_OBJECTS) $(test_version_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example-deconstructor-alt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example-deconstructor.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example-reformatter-alt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example-reformatter.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-dumper.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-emitter.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-loader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run-scanner.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-version.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -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: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - 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; }; }'`; \ - 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: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - 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; }; }'`; \ - 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 - -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - $(am__tty_colors); \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - ;; \ - *) \ - col=$$grn; res=PASS; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ - fi; \ - echo "$${col}$$res$${std}: $$tst"; \ - done; \ - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ - fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ - else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ - else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ - fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ - else \ - skipped="($$skip tests were not run)"; \ - fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ - else \ - echo "$$red$$dashes"; \ - fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ - test "$$failed" -eq 0; \ - else :; fi - -distdir: $(DISTFILES) - @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 -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -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-am - -clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstPROGRAMS mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ - clean-checkPROGRAMS clean-generic clean-libtool \ - clean-noinstPROGRAMS ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir 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-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am - - -# 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: diff --git a/tests/ReadMe.md b/tests/ReadMe.md new file mode 100644 index 000000000000..bf09447f53f3 --- /dev/null +++ b/tests/ReadMe.md @@ -0,0 +1,63 @@ +# Testing the Parser and Emitter + +There are several programs to test the parser and emitter. + +## Parser + + echo 'foo: bar' | ./tests/run-parser-test-suite + +This will output the parsing events in yaml-test-suite format: + + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + +For flow style events, you have to enable it with the `--flow` option: + + echo '{ foo: bar }' | ./tests/run-parser-test-suite --flow keep + + ... + +MAP {} + ... + +In the future, this will be the default. + +You can also explicitly disable this style with `--flow off`, or output +flow style always, with `--flow on`. + +## Emitter + +run-emitter-test-suite takes yaml-test-suite event format and emits YAML. + + ./tests/run-parser-test-suite ... | ./tests/run-emitter-test-suite + +## Options + +* `--directive (1.1|1.2)` + + Prints a version directive before every document. + +* `--flow on` + + Will emit the whole document in flow style. + +* `--flow off` + + Will emit the whole document in block style. + +* `--flow keep` + + Will emit block/flow style like in the original document. + +Example: +``` +% echo 'foo: [bar, {x: y}]' | + ./tests/run-parser-test-suite --flow keep | + ./tests/run-emitter-test-suite --flow keep +foo: [bar, {x: y}] +``` diff --git a/tests/example-deconstructor-alt.c b/tests/example-deconstructor-alt.c index 7da194a659d0..b29c0777b09a 100644 --- a/tests/example-deconstructor-alt.c +++ b/tests/example-deconstructor-alt.c @@ -141,10 +141,10 @@ main(int argc, char *argv[]) /* Add 'type': 'STREAM-START'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "STREAM-START", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"STREAM-START", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -157,10 +157,10 @@ main(int argc, char *argv[]) = input_event.data.stream_start.encoding; key = yaml_document_add_scalar(&output_document, NULL, - "encoding", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"encoding", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - (encoding == YAML_UTF8_ENCODING ? "utf-8" : + (yaml_char_t *)(encoding == YAML_UTF8_ENCODING ? "utf-8" : encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" : encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" : "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); @@ -176,10 +176,10 @@ main(int argc, char *argv[]) /* Add 'type': 'STREAM-END'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "STREAM-END", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"STREAM-END", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -191,10 +191,10 @@ main(int argc, char *argv[]) /* Add 'type': 'DOCUMENT-START'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "DOCUMENT-START", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"DOCUMENT-START", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -210,7 +210,7 @@ main(int argc, char *argv[]) /* Add 'version': {}. */ key = yaml_document_add_scalar(&output_document, NULL, - "version", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"version", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; map = yaml_document_add_mapping(&output_document, NULL, YAML_FLOW_MAPPING_STYLE); @@ -221,11 +221,11 @@ main(int argc, char *argv[]) /* Add 'major': <number>. */ key = yaml_document_add_scalar(&output_document, NULL, - "major", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"major", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; sprintf(number, "%d", version->major); - value = yaml_document_add_scalar(&output_document, YAML_INT_TAG, - number, -1, YAML_PLAIN_SCALAR_STYLE); + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_INT_TAG, + (yaml_char_t *)number, -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, map, key, value)) goto document_error; @@ -233,11 +233,11 @@ main(int argc, char *argv[]) /* Add 'minor': <number>. */ key = yaml_document_add_scalar(&output_document, NULL, - "minor", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"minor", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; sprintf(number, "%d", version->minor); - value = yaml_document_add_scalar(&output_document, YAML_INT_TAG, - number, -1, YAML_PLAIN_SCALAR_STYLE); + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_INT_TAG, + (yaml_char_t *)number, -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, map, key, value)) goto document_error; @@ -253,7 +253,7 @@ main(int argc, char *argv[]) /* Add 'tags': []. */ key = yaml_document_add_scalar(&output_document, NULL, - "tags", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"tags", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; seq = yaml_document_add_sequence(&output_document, NULL, YAML_BLOCK_SEQUENCE_STYLE); @@ -276,7 +276,7 @@ main(int argc, char *argv[]) /* Add 'handle': <handle>. */ key = yaml_document_add_scalar(&output_document, NULL, - "handle", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"handle", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, tag->handle, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); @@ -287,7 +287,7 @@ main(int argc, char *argv[]) /* Add 'prefix': <prefix>. */ key = yaml_document_add_scalar(&output_document, NULL, - "prefix", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"prefix", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, tag->prefix, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); @@ -300,10 +300,10 @@ main(int argc, char *argv[]) /* Add 'implicit': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "implicit", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.document_start.implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.document_start.implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -316,10 +316,10 @@ main(int argc, char *argv[]) /* Add 'type': 'DOCUMENT-END'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "DOCUMENT-END", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"DOCUMENT-END", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -327,10 +327,10 @@ main(int argc, char *argv[]) /* Add 'implicit': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "implicit", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.document_end.implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.document_end.implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -343,10 +343,10 @@ main(int argc, char *argv[]) /* Add 'type': 'ALIAS'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "ALIAS", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"ALIAS", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -354,7 +354,7 @@ main(int argc, char *argv[]) /* Add 'anchor': <anchor>. */ key = yaml_document_add_scalar(&output_document, NULL, - "anchor", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.alias.anchor, -1, @@ -370,10 +370,10 @@ main(int argc, char *argv[]) /* Add 'type': 'SCALAR'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "SCALAR", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"SCALAR", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -383,7 +383,7 @@ main(int argc, char *argv[]) if (input_event.data.scalar.anchor) { key = yaml_document_add_scalar(&output_document, NULL, - "anchor", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.scalar.anchor, -1, @@ -398,7 +398,7 @@ main(int argc, char *argv[]) if (input_event.data.scalar.tag) { key = yaml_document_add_scalar(&output_document, NULL, - "tag", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.scalar.tag, -1, @@ -411,7 +411,7 @@ main(int argc, char *argv[]) /* Add 'value': <value>. */ key = yaml_document_add_scalar(&output_document, NULL, - "value", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"value", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.scalar.value, @@ -426,7 +426,7 @@ main(int argc, char *argv[]) /* Add 'implicit': {} */ key = yaml_document_add_scalar(&output_document, NULL, - "version", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"version", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; map = yaml_document_add_mapping(&output_document, NULL, YAML_FLOW_MAPPING_STYLE); @@ -437,10 +437,10 @@ main(int argc, char *argv[]) /* Add 'plain': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "plain", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"plain", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.scalar.plain_implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.scalar.plain_implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -449,10 +449,10 @@ main(int argc, char *argv[]) /* Add 'quoted': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "quoted", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"quoted", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.scalar.quoted_implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.scalar.quoted_implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -467,10 +467,10 @@ main(int argc, char *argv[]) /* Add 'style': <style>. */ key = yaml_document_add_scalar(&output_document, NULL, - "style", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - (style == YAML_PLAIN_SCALAR_STYLE ? "plain" : + (yaml_char_t *)(style == YAML_PLAIN_SCALAR_STYLE ? "plain" : style == YAML_SINGLE_QUOTED_SCALAR_STYLE ? "single-quoted" : style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ? @@ -490,10 +490,10 @@ main(int argc, char *argv[]) /* Add 'type': 'SEQUENCE-START'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "SEQUENCE-START", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"SEQUENCE-START", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -503,7 +503,7 @@ main(int argc, char *argv[]) if (input_event.data.sequence_start.anchor) { key = yaml_document_add_scalar(&output_document, NULL, - "anchor", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.sequence_start.anchor, -1, @@ -518,7 +518,7 @@ main(int argc, char *argv[]) if (input_event.data.sequence_start.tag) { key = yaml_document_add_scalar(&output_document, NULL, - "tag", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.sequence_start.tag, -1, @@ -531,10 +531,10 @@ main(int argc, char *argv[]) /* Add 'implicit': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "implicit", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.sequence_start.implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.sequence_start.implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -550,10 +550,10 @@ main(int argc, char *argv[]) /* Add 'style': <style>. */ key = yaml_document_add_scalar(&output_document, NULL, - "style", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - (style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : + (yaml_char_t *)(style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : style == YAML_FLOW_SEQUENCE_STYLE ? "flow" : "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; @@ -568,10 +568,10 @@ main(int argc, char *argv[]) /* Add 'type': 'SEQUENCE-END'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "SEQUENCE-END", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"SEQUENCE-END", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -583,10 +583,10 @@ main(int argc, char *argv[]) /* Add 'type': 'MAPPING-START'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "MAPPING-START", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"MAPPING-START", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -596,7 +596,7 @@ main(int argc, char *argv[]) if (input_event.data.mapping_start.anchor) { key = yaml_document_add_scalar(&output_document, NULL, - "anchor", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"anchor", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.mapping_start.anchor, -1, @@ -611,7 +611,7 @@ main(int argc, char *argv[]) if (input_event.data.mapping_start.tag) { key = yaml_document_add_scalar(&output_document, NULL, - "tag", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"tag", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, input_event.data.mapping_start.tag, -1, @@ -624,10 +624,10 @@ main(int argc, char *argv[]) /* Add 'implicit': <flag>. */ key = yaml_document_add_scalar(&output_document, NULL, - "implicit", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"implicit", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; - value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, - (input_event.data.mapping_start.implicit ? + value = yaml_document_add_scalar(&output_document, (yaml_char_t *)YAML_BOOL_TAG, + (yaml_char_t *)(input_event.data.mapping_start.implicit ? "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, @@ -635,18 +635,18 @@ main(int argc, char *argv[]) /* Display the style information. */ - if (input_event.data.sequence_start.style) + if (input_event.data.mapping_start.style) { - yaml_sequence_style_t style + yaml_mapping_style_t style = input_event.data.mapping_start.style; /* Add 'style': <style>. */ key = yaml_document_add_scalar(&output_document, NULL, - "style", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"style", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - (style == YAML_BLOCK_MAPPING_STYLE ? "block" : + (yaml_char_t *)(style == YAML_BLOCK_MAPPING_STYLE ? "block" : style == YAML_FLOW_MAPPING_STYLE ? "flow" : "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; @@ -661,10 +661,10 @@ main(int argc, char *argv[]) /* Add 'type': 'MAPPING-END'. */ key = yaml_document_add_scalar(&output_document, NULL, - "type", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"type", -1, YAML_PLAIN_SCALAR_STYLE); if (!key) goto document_error; value = yaml_document_add_scalar(&output_document, NULL, - "MAPPING-END", -1, YAML_PLAIN_SCALAR_STYLE); + (yaml_char_t *)"MAPPING-END", -1, YAML_PLAIN_SCALAR_STYLE); if (!value) goto document_error; if (!yaml_document_append_mapping_pair(&output_document, properties, key, value)) goto document_error; @@ -703,25 +703,25 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %d\n", parser.problem, + fprintf(stderr, "Reader error: %s: #%X at %zd\n", parser.problem, parser.problem_value, parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %d\n", parser.problem, + fprintf(stderr, "Reader error: %s at %zd\n", parser.problem, parser.problem_offset); } break; case YAML_SCANNER_ERROR: if (parser.context) { - fprintf(stderr, "Scanner error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser.context, + fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n" + "%s at line %lu, column %lu\n", parser.context, parser.context_mark.line+1, parser.context_mark.column+1, parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } else { - fprintf(stderr, "Scanner error: %s at line %d, column %d\n", + fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n", parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } @@ -729,14 +729,14 @@ parser_error: case YAML_PARSER_ERROR: if (parser.context) { - fprintf(stderr, "Parser error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser.context, + fprintf(stderr, "Parser error: %s at line %lu, column %lu\n" + "%s at line %lu, column %lu\n", parser.context, parser.context_mark.line+1, parser.context_mark.column+1, parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } else { - fprintf(stderr, "Parser error: %s at line %d, column %d\n", + fprintf(stderr, "Parser error: %s at line %lu, column %lu\n", parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } diff --git a/tests/example-deconstructor.c b/tests/example-deconstructor.c index fec7d59ebe78..e048ee6bf0ad 100644 --- a/tests/example-deconstructor.c +++ b/tests/example-deconstructor.c @@ -107,7 +107,7 @@ main(int argc, char *argv[]) /* Create and emit the SEQUENCE-START event. */ if (!yaml_sequence_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:seq", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:seq", 1, YAML_BLOCK_SEQUENCE_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -131,7 +131,7 @@ main(int argc, char *argv[]) /* Create and emit a MAPPING-START event. */ if (!yaml_mapping_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:map", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:map", 1, YAML_BLOCK_MAPPING_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -146,7 +146,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -155,7 +155,7 @@ main(int argc, char *argv[]) /* Write 'STREAM-START'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "STREAM-START", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"STREAM-START", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -171,7 +171,7 @@ main(int argc, char *argv[]) /* Write 'encoding'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "encoding", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"encoding", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -180,8 +180,8 @@ main(int argc, char *argv[]) /* Write the stream encoding. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", - (encoding == YAML_UTF8_ENCODING ? "utf-8" : + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", + (yaml_char_t *)(encoding == YAML_UTF8_ENCODING ? "utf-8" : encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" : encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" : "unknown"), -1, @@ -198,7 +198,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -207,7 +207,7 @@ main(int argc, char *argv[]) /* Write 'STREAM-END'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "STREAM-END", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"STREAM-END", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -220,7 +220,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -229,7 +229,7 @@ main(int argc, char *argv[]) /* Write 'DOCUMENT-START'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "DOCUMENT-START", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"DOCUMENT-START", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -246,7 +246,7 @@ main(int argc, char *argv[]) /* Write 'version'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "version", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"version", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -255,7 +255,7 @@ main(int argc, char *argv[]) /* Write '{'. */ if (!yaml_mapping_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:map", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:map", 1, YAML_FLOW_MAPPING_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -264,7 +264,7 @@ main(int argc, char *argv[]) /* Write 'major'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "major", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"major", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -274,7 +274,7 @@ main(int argc, char *argv[]) sprintf(number, "%d", version->major); if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:int", number, -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:int", (yaml_char_t *)number, -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -283,7 +283,7 @@ main(int argc, char *argv[]) /* Write 'minor'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "minor", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"minor", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -293,7 +293,7 @@ main(int argc, char *argv[]) sprintf(number, "%d", version->minor); if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:int", number, -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:int", (yaml_char_t *)number, -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -317,7 +317,7 @@ main(int argc, char *argv[]) /* Write 'tags'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "tags", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"tags", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -326,7 +326,7 @@ main(int argc, char *argv[]) /* Start a block sequence. */ if (!yaml_sequence_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:seq", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:seq", 1, YAML_BLOCK_SEQUENCE_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -339,7 +339,7 @@ main(int argc, char *argv[]) /* Write '{'. */ if (!yaml_mapping_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:map", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:map", 1, YAML_FLOW_MAPPING_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -348,7 +348,7 @@ main(int argc, char *argv[]) /* Write 'handle'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "handle", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"handle", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -357,7 +357,7 @@ main(int argc, char *argv[]) /* Write the tag directive handle. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", tag->handle, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -367,7 +367,7 @@ main(int argc, char *argv[]) /* Write 'prefix'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "prefix", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"prefix", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -376,7 +376,7 @@ main(int argc, char *argv[]) /* Write the tag directive prefix. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", tag->prefix, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -402,7 +402,7 @@ main(int argc, char *argv[]) /* Write 'implicit'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "implicit", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"implicit", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -411,8 +411,8 @@ main(int argc, char *argv[]) /* Write if the document is implicit. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.document_start.implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t *)(input_event.data.document_start.implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -426,7 +426,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -435,7 +435,7 @@ main(int argc, char *argv[]) /* Write 'DOCUMENT-END'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "DOCUMENT-END", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"DOCUMENT-END", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -444,7 +444,7 @@ main(int argc, char *argv[]) /* Write 'implicit'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "implicit", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"implicit", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -453,8 +453,8 @@ main(int argc, char *argv[]) /* Write if the document is implicit. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.document_end.implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t *)(input_event.data.document_end.implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -468,7 +468,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -477,7 +477,7 @@ main(int argc, char *argv[]) /* Write 'ALIAS'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "ALIAS", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"ALIAS", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -486,7 +486,7 @@ main(int argc, char *argv[]) /* Write 'anchor'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "anchor", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"anchor", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -495,7 +495,7 @@ main(int argc, char *argv[]) /* Write the alias anchor. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.alias.anchor, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -509,7 +509,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -518,7 +518,7 @@ main(int argc, char *argv[]) /* Write 'SCALAR'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "SCALAR", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"SCALAR", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -531,7 +531,7 @@ main(int argc, char *argv[]) /* Write 'anchor'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "anchor", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"anchor", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -540,7 +540,7 @@ main(int argc, char *argv[]) /* Write the scalar anchor. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.scalar.anchor, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -555,7 +555,7 @@ main(int argc, char *argv[]) /* Write 'tag'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "tag", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"tag", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -564,7 +564,7 @@ main(int argc, char *argv[]) /* Write the scalar tag. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.scalar.tag, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -577,7 +577,7 @@ main(int argc, char *argv[]) /* Write 'value'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "value", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"value", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -586,7 +586,7 @@ main(int argc, char *argv[]) /* Write the scalar value. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.scalar.value, input_event.data.scalar.length, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) @@ -599,7 +599,7 @@ main(int argc, char *argv[]) /* Write 'implicit'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "implicit", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"implicit", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -608,7 +608,7 @@ main(int argc, char *argv[]) /* Write '{'. */ if (!yaml_mapping_start_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:map", 1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:map", 1, YAML_FLOW_MAPPING_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -617,7 +617,7 @@ main(int argc, char *argv[]) /* Write 'plain'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "plain", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"plain", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -626,8 +626,8 @@ main(int argc, char *argv[]) /* Write if the scalar is implicit in the plain style. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.scalar.plain_implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t * )(input_event.data.scalar.plain_implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -637,7 +637,7 @@ main(int argc, char *argv[]) /* Write 'quoted'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "non-plain", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"non-plain", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -646,8 +646,8 @@ main(int argc, char *argv[]) /* Write if the scalar is implicit in a non-plain style. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.scalar.quoted_implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t *)(input_event.data.scalar.quoted_implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -670,7 +670,7 @@ main(int argc, char *argv[]) /* Write 'style'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "style", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"style", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -679,8 +679,8 @@ main(int argc, char *argv[]) /* Write the scalar style. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", - (style == YAML_PLAIN_SCALAR_STYLE ? "plain" : + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", + (yaml_char_t *)(style == YAML_PLAIN_SCALAR_STYLE ? "plain" : style == YAML_SINGLE_QUOTED_SCALAR_STYLE ? "single-quoted" : style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ? @@ -701,7 +701,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -710,7 +710,7 @@ main(int argc, char *argv[]) /* Write 'SEQUENCE-START'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "SEQUENCE-START", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"SEQUENCE-START", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -723,7 +723,7 @@ main(int argc, char *argv[]) /* Write 'anchor'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "anchor", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"anchor", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -732,7 +732,7 @@ main(int argc, char *argv[]) /* Write the sequence anchor. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.sequence_start.anchor, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -747,7 +747,7 @@ main(int argc, char *argv[]) /* Write 'tag'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "tag", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"tag", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -756,7 +756,7 @@ main(int argc, char *argv[]) /* Write the sequence tag. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.sequence_start.tag, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -767,7 +767,7 @@ main(int argc, char *argv[]) /* Write 'implicit'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "implicit", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"implicit", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -776,8 +776,8 @@ main(int argc, char *argv[]) /* Write if the sequence tag is implicit. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.sequence_start.implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t *)(input_event.data.sequence_start.implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -794,7 +794,7 @@ main(int argc, char *argv[]) /* Write 'style'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "style", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"style", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -803,8 +803,8 @@ main(int argc, char *argv[]) /* Write the scalar style. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", - (style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", + (yaml_char_t *)(style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : style == YAML_FLOW_SEQUENCE_STYLE ? "flow" : "unknown"), -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) @@ -820,7 +820,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -829,7 +829,7 @@ main(int argc, char *argv[]) /* Write 'SEQUENCE-END'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "SEQUENCE-END", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"SEQUENCE-END", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -842,7 +842,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -851,7 +851,7 @@ main(int argc, char *argv[]) /* Write 'MAPPING-START'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "MAPPING-START", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"MAPPING-START", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -864,7 +864,7 @@ main(int argc, char *argv[]) /* Write 'anchor'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "anchor", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"anchor", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -873,7 +873,7 @@ main(int argc, char *argv[]) /* Write the mapping anchor. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.mapping_start.anchor, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -888,7 +888,7 @@ main(int argc, char *argv[]) /* Write 'tag'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "tag", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"tag", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -897,7 +897,7 @@ main(int argc, char *argv[]) /* Write the mapping tag. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", input_event.data.mapping_start.tag, -1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) goto event_error; @@ -908,7 +908,7 @@ main(int argc, char *argv[]) /* Write 'implicit'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "implicit", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"implicit", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -917,8 +917,8 @@ main(int argc, char *argv[]) /* Write if the mapping tag is implicit. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:bool", - (input_event.data.mapping_start.implicit ? + NULL, (yaml_char_t *)"tag:yaml.org,2002:bool", + (yaml_char_t *)(input_event.data.mapping_start.implicit ? "true" : "false"), -1, 1, 0, YAML_PLAIN_SCALAR_STYLE)) goto event_error; @@ -935,7 +935,7 @@ main(int argc, char *argv[]) /* Write 'style'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "style", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"style", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -944,8 +944,8 @@ main(int argc, char *argv[]) /* Write the scalar style. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", - (style == YAML_BLOCK_MAPPING_STYLE ? "block" : + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", + (yaml_char_t *)(style == YAML_BLOCK_MAPPING_STYLE ? "block" : style == YAML_FLOW_MAPPING_STYLE ? "flow" : "unknown"), -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) @@ -961,7 +961,7 @@ main(int argc, char *argv[]) /* Write 'type'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "type", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"type", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -970,7 +970,7 @@ main(int argc, char *argv[]) /* Write 'MAPPING-END'. */ if (!yaml_scalar_event_initialize(&output_event, - NULL, "tag:yaml.org,2002:str", "MAPPING-END", -1, + NULL, (yaml_char_t *)"tag:yaml.org,2002:str", (yaml_char_t *)"MAPPING-END", -1, 1, 1, YAML_PLAIN_SCALAR_STYLE)) goto event_error; if (!yaml_emitter_emit(&emitter, &output_event)) @@ -1033,12 +1033,12 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %d\n", parser.problem, - parser.problem_value, parser.problem_offset); + fprintf(stderr, "Reader error: %s: #%X at %ld\n", parser.problem, + parser.problem_value, (long)parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %d\n", parser.problem, - parser.problem_offset); + fprintf(stderr, "Reader error: %s at %ld\n", parser.problem, + (long)parser.problem_offset); } break; @@ -1046,14 +1046,14 @@ parser_error: if (parser.context) { fprintf(stderr, "Scanner error: %s at line %d, column %d\n" "%s at line %d, column %d\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { fprintf(stderr, "Scanner error: %s at line %d, column %d\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; @@ -1061,14 +1061,14 @@ parser_error: if (parser.context) { fprintf(stderr, "Parser error: %s at line %d, column %d\n" "%s at line %d, column %d\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { fprintf(stderr, "Parser error: %s at line %d, column %d\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; @@ -1079,7 +1079,6 @@ parser_error: } yaml_event_delete(&input_event); - yaml_event_delete(&output_event); yaml_parser_delete(&parser); yaml_emitter_delete(&emitter); @@ -1110,7 +1109,6 @@ emitter_error: } yaml_event_delete(&input_event); - yaml_event_delete(&output_event); yaml_parser_delete(&parser); yaml_emitter_delete(&emitter); @@ -1121,7 +1119,6 @@ event_error: fprintf(stderr, "Memory error: Not enough memory for creating an event\n"); yaml_event_delete(&input_event); - yaml_event_delete(&output_event); yaml_parser_delete(&parser); yaml_emitter_delete(&emitter); diff --git a/tests/example-reformatter-alt.c b/tests/example-reformatter-alt.c index 550e06cb787b..e7d006e4a64a 100644 --- a/tests/example-reformatter-alt.c +++ b/tests/example-reformatter-alt.c @@ -120,25 +120,25 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %d\n", parser.problem, + fprintf(stderr, "Reader error: %s: #%X at %zd\n", parser.problem, parser.problem_value, parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %d\n", parser.problem, + fprintf(stderr, "Reader error: %s at %lu\n", parser.problem, parser.problem_offset); } break; case YAML_SCANNER_ERROR: if (parser.context) { - fprintf(stderr, "Scanner error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser.context, + fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n" + "%s at line %lu, column %lu\n", parser.context, parser.context_mark.line+1, parser.context_mark.column+1, parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } else { - fprintf(stderr, "Scanner error: %s at line %d, column %d\n", + fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n", parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } @@ -146,14 +146,14 @@ parser_error: case YAML_PARSER_ERROR: if (parser.context) { - fprintf(stderr, "Parser error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser.context, + fprintf(stderr, "Parser error: %s at line %lu, column %lu\n" + "%s at line %lu, column %lu\n", parser.context, parser.context_mark.line+1, parser.context_mark.column+1, parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } else { - fprintf(stderr, "Parser error: %s at line %d, column %d\n", + fprintf(stderr, "Parser error: %s at line %lu, column %lu\n", parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } @@ -161,14 +161,14 @@ parser_error: case YAML_COMPOSER_ERROR: if (parser.context) { - fprintf(stderr, "Composer error: %s at line %d, column %d\n" - "%s at line %d, column %d\n", parser.context, + fprintf(stderr, "Composer error: %s at line %lu, column %lu\n" + "%s at line %lu, column %lu\n", parser.context, parser.context_mark.line+1, parser.context_mark.column+1, parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } else { - fprintf(stderr, "Composer error: %s at line %d, column %d\n", + fprintf(stderr, "Composer error: %s at line %lu, column %lu\n", parser.problem, parser.problem_mark.line+1, parser.problem_mark.column+1); } diff --git a/tests/example-reformatter.c b/tests/example-reformatter.c index 946d55619afc..08f860c4ef2f 100644 --- a/tests/example-reformatter.c +++ b/tests/example-reformatter.c @@ -120,12 +120,12 @@ parser_error: case YAML_READER_ERROR: if (parser.problem_value != -1) { - fprintf(stderr, "Reader error: %s: #%X at %d\n", parser.problem, - parser.problem_value, parser.problem_offset); + fprintf(stderr, "Reader error: %s: #%X at %ld\n", parser.problem, + parser.problem_value, (long)parser.problem_offset); } else { - fprintf(stderr, "Reader error: %s at %d\n", parser.problem, - parser.problem_offset); + fprintf(stderr, "Reader error: %s at %ld\n", parser.problem, + (long)parser.problem_offset); } break; @@ -133,14 +133,14 @@ parser_error: if (parser.context) { fprintf(stderr, "Scanner error: %s at line %d, column %d\n" "%s at line %d, column %d\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { fprintf(stderr, "Scanner error: %s at line %d, column %d\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; @@ -148,14 +148,14 @@ parser_error: if (parser.context) { fprintf(stderr, "Parser error: %s at line %d, column %d\n" "%s at line %d, column %d\n", parser.context, - parser.context_mark.line+1, parser.context_mark.column+1, - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + (int)parser.context_mark.line+1, (int)parser.context_mark.column+1, + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } else { fprintf(stderr, "Parser error: %s at line %d, column %d\n", - parser.problem, parser.problem_mark.line+1, - parser.problem_mark.column+1); + parser.problem, (int)parser.problem_mark.line+1, + (int)parser.problem_mark.column+1); } break; diff --git a/tests/run-all-tests.sh b/tests/run-all-tests.sh new file mode 100755 index 000000000000..9c92741eca38 --- /dev/null +++ b/tests/run-all-tests.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e + +main() { + # Autoconf based in-source build and tests + clean + + ./bootstrap + ./configure + make test-all + + # CMake based in-source build and tests + clean + + cmake . + make + make test + + clean +} + +clean() { + git clean -d -x -f + rm -fr tests/run-test-suite + git worktree prune +} + +main "$@" diff --git a/tests/run-dumper.c b/tests/run-dumper.c index 41bead4940f5..04c5beeafa57 100644 --- a/tests/run-dumper.c +++ b/tests/run-dumper.c @@ -77,11 +77,14 @@ error: } int compare_nodes(yaml_document_t *document1, int index1, - yaml_document_t *document2, int index2) + yaml_document_t *document2, int index2, int level) { - yaml_node_t *node1 = yaml_document_get_node(document1, index1); - yaml_node_t *node2 = yaml_document_get_node(document2, index2); int k; + yaml_node_t *node1; + yaml_node_t *node2; + if (level++ > 1000) return 0; + node1 = yaml_document_get_node(document1, index1); + node2 = yaml_document_get_node(document2, index2); assert(node1); assert(node2); @@ -104,7 +107,7 @@ int compare_nodes(yaml_document_t *document1, int index1, return 0; for (k = 0; k < (node1->data.sequence.items.top - node1->data.sequence.items.start); k ++) { if (!compare_nodes(document1, node1->data.sequence.items.start[k], - document2, node2->data.sequence.items.start[k])) return 0; + document2, node2->data.sequence.items.start[k], level)) return 0; } break; case YAML_MAPPING_NODE: @@ -113,9 +116,9 @@ int compare_nodes(yaml_document_t *document1, int index1, return 0; for (k = 0; k < (node1->data.mapping.pairs.top - node1->data.mapping.pairs.start); k ++) { if (!compare_nodes(document1, node1->data.mapping.pairs.start[k].key, - document2, node2->data.mapping.pairs.start[k].key)) return 0; + document2, node2->data.mapping.pairs.start[k].key, level)) return 0; if (!compare_nodes(document1, node1->data.mapping.pairs.start[k].value, - document2, node2->data.mapping.pairs.start[k].value)) return 0; + document2, node2->data.mapping.pairs.start[k].value, level)) return 0; } break; default: @@ -152,7 +155,7 @@ int compare_documents(yaml_document_t *document1, yaml_document_t *document2) return 0; if (document1->nodes.top != document1->nodes.start) { - if (!compare_nodes(document1, 1, document2, 1)) + if (!compare_nodes(document1, 1, document2, 1, 0)) return 0; } @@ -179,8 +182,8 @@ int print_output(char *name, unsigned char *buffer, size_t size, int count) if (feof(file)) break; } fclose(file); - printf("#### (length: %d)\n", total_size); - printf("OUTPUT:\n%s#### (length: %d)\n", buffer, size); + printf("#### (length: %ld)\n", (long)total_size); + printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size); return 0; } @@ -226,7 +229,7 @@ main(int argc, char *argv[]) yaml_emitter_t emitter; yaml_document_t document; - unsigned char buffer[BUFFER_SIZE]; + unsigned char buffer[BUFFER_SIZE+1]; size_t written = 0; yaml_document_t documents[MAX_DOCUMENTS]; size_t document_number = 0; @@ -234,7 +237,7 @@ main(int argc, char *argv[]) int count = 0; int error = 0; int k; - memset(buffer, 0, BUFFER_SIZE); + memset(buffer, 0, BUFFER_SIZE+1); memset(documents, 0, MAX_DOCUMENTS*sizeof(yaml_document_t)); printf("[%d] Loading, dumping, and loading again '%s': ", number, argv[number]); @@ -303,7 +306,7 @@ main(int argc, char *argv[]) yaml_document_delete(documents+k); } - printf("PASSED (length: %d)\n", written); + printf("PASSED (length: %ld)\n", (long)written); print_output(argv[number], buffer, written, -1); } diff --git a/tests/run-emitter-test-suite.c b/tests/run-emitter-test-suite.c new file mode 100644 index 000000000000..ba0f163ad39f --- /dev/null +++ b/tests/run-emitter-test-suite.c @@ -0,0 +1,290 @@ +#include <yaml.h> + +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> +#include "../src/yaml_private.h" + +int get_line(FILE * input, char *line); +char *get_anchor(char sigil, char *line, char *anchor); +char *get_tag(char *line, char *tag); +void get_value(char *line, char *value, int *style); +int usage(int ret); + +int main(int argc, char *argv[]) +{ + FILE *input; + yaml_emitter_t emitter; + yaml_event_t event; + yaml_version_directive_t *version_directive = NULL; + + int canonical = 0; + int unicode = 0; + char line[1024]; + int foundfile = 0; + int i = 0; + int minor = 0; + int flow = -1; /** default no flow style collections */ + + for (i = 1; i < argc; i++) { + if (strncmp(argv[i], "--help", 6) == 0) + return usage(0); + if (strncmp(argv[i], "-h", 2) == 0) + return usage(0); + if (strncmp(argv[i], "--flow", 6) == 0) { + if (i+1 == argc) + return usage(1); + i++; + if (strncmp(argv[i], "keep", 4) == 0) + flow = 0; + else if (strncmp(argv[i], "on", 2) == 0) + flow = 1; + else if (strncmp(argv[i], "off", 3) == 0) + flow = -1; + else + return usage(1); + } + else if (strncmp(argv[i], "--directive", 11) == 0) { + if (i+1 == argc) + return usage(1); + i++; + if (strncmp(argv[i], "1.1", 3) == 0) + minor = 1; + else if (strncmp(argv[i], "1.2", 3) == 0) + minor = 2; + else + return usage(1); + } + else if (!foundfile) { + input = fopen(argv[i], "rb"); + foundfile = 1; + } + + } + if (minor) { + version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t); + version_directive->major = 1; + version_directive->minor = minor; + } + if (!foundfile) + input = stdin; + + assert(input); + + if (!yaml_emitter_initialize(&emitter)) { + fprintf(stderr, "Could not initalize the emitter object\n"); + return 1; + } + yaml_emitter_set_output_file(&emitter, stdout); + yaml_emitter_set_canonical(&emitter, canonical); + yaml_emitter_set_unicode(&emitter, unicode); + + + while (get_line(input, line)) { + int ok; + char anchor[256]; + char tag[256]; + int implicit; + int style; + + if (strncmp(line, "+STR", 4) == 0) { + ok = yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); + } + else if (strncmp(line, "-STR", 4) == 0) { + ok = yaml_stream_end_event_initialize(&event); + } + else if (strncmp(line, "+DOC", 4) == 0) { + implicit = strncmp(line+4, " ---", 4) != 0; + ok = yaml_document_start_event_initialize(&event, version_directive, NULL, NULL, implicit); + } + else if (strncmp(line, "-DOC", 4) == 0) { + implicit = strncmp(line+4, " ...", 4) != 0; + ok = yaml_document_end_event_initialize(&event, implicit); + } + else if (strncmp(line, "+MAP", 4) == 0) { + style = YAML_BLOCK_MAPPING_STYLE; + if (flow == 1) + style = YAML_FLOW_MAPPING_STYLE; + else if (flow == 0 && strncmp(line+5, "{}", 2) == 0) + style = YAML_FLOW_MAPPING_STYLE; + ok = yaml_mapping_start_event_initialize(&event, (yaml_char_t *) + get_anchor('&', line, anchor), (yaml_char_t *) + get_tag(line, tag), 0, style); + } + else if (strncmp(line, "-MAP", 4) == 0) { + ok = yaml_mapping_end_event_initialize(&event); + } + else if (strncmp(line, "+SEQ", 4) == 0) { + style = YAML_BLOCK_SEQUENCE_STYLE; + if (flow == 1) + style = YAML_FLOW_MAPPING_STYLE; + else if (flow == 0 && strncmp(line+5, "[]", 2) == 0) + style = YAML_FLOW_SEQUENCE_STYLE; + ok = yaml_sequence_start_event_initialize(&event, (yaml_char_t *) + get_anchor('&', line, anchor), (yaml_char_t *) + get_tag(line, tag), 0, style); + } + else if (strncmp(line, "-SEQ", 4) == 0) { + ok = yaml_sequence_end_event_initialize(&event); + } + else if (strncmp(line, "=VAL", 4) == 0) { + char value[1024]; + int style; + + get_value(line, value, &style); + implicit = (get_tag(line, tag) == NULL); + + ok = yaml_scalar_event_initialize(&event, (yaml_char_t *) + get_anchor('&', line, anchor), (yaml_char_t *) get_tag(line, tag), (yaml_char_t *) value, -1, implicit, implicit, style); + } + else if (strncmp(line, "=ALI", 4) == 0) { + ok = yaml_alias_event_initialize(&event, (yaml_char_t *) + get_anchor('*', line, anchor) + ); + } + else { + fprintf(stderr, "Unknown event: '%s'\n", line); + fflush(stdout); + return 1; + } + + if (!ok) + goto event_error; + if (!yaml_emitter_emit(&emitter, &event)) + goto emitter_error; + } + + assert(!fclose(input)); + yaml_emitter_delete(&emitter); + fflush(stdout); + + return 0; + + emitter_error: + switch (emitter.error) { + case YAML_MEMORY_ERROR: + fprintf(stderr, "Memory error: Not enough memory for emitting\n"); + break; + case YAML_WRITER_ERROR: + fprintf(stderr, "Writer error: %s\n", emitter.problem); + break; + case YAML_EMITTER_ERROR: + fprintf(stderr, "Emitter error: %s\n", emitter.problem); + break; + default: + /* + * Couldn't happen. + */ + fprintf(stderr, "Internal error\n"); + break; + } + yaml_emitter_delete(&emitter); + return 1; + + event_error: + fprintf(stderr, "Memory error: Not enough memory for creating an event\n"); + yaml_emitter_delete(&emitter); + return 1; +} + +int get_line(FILE * input, char *line) +{ + char *newline; + + if (!fgets(line, 1024 - 1, input)) + return 0; + + if ((newline = strchr(line, '\n')) == NULL) { + fprintf(stderr, "Line too long: '%s'", line); + abort(); + } + *newline = '\0'; + + return 1; +} + +char *get_anchor(char sigil, char *line, char *anchor) +{ + char *start; + char *end; + if ((start = strchr(line, sigil)) == NULL) + return NULL; + start++; + if ((end = strchr(start, ' ')) == NULL) + end = line + strlen(line); + memcpy(anchor, start, end - start); + anchor[end - start] = '\0'; + return anchor; +} + +char *get_tag(char *line, char *tag) +{ + char *start; + char *end; + if ((start = strchr(line, '<')) == NULL) + return NULL; + if ((end = strchr(line, '>')) == NULL) + return NULL; + memcpy(tag, start + 1, end - start - 1); + tag[end - start - 1] = '\0'; + return tag; +} + +void get_value(char *line, char *value, int *style) +{ + int i = 0; + char *c; + char *start = NULL; + char *end = line + strlen(line); + + for (c = line + 4; c < end; c++) { + if (*c == ' ') { + start = c + 1; + if (*start == ':') + *style = YAML_PLAIN_SCALAR_STYLE; + else if (*start == '\'') + *style = YAML_SINGLE_QUOTED_SCALAR_STYLE; + else if (*start == '"') + *style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; + else if (*start == '|') + *style = YAML_LITERAL_SCALAR_STYLE; + else if (*start == '>') + *style = YAML_FOLDED_SCALAR_STYLE; + else { + start = NULL; + continue; + } + start++; + break; + } + } + if (!start) + abort(); + + for (c = start; c < end; c++) { + if (*c == '\\') { + if (*++c == '\\') + value[i++] = '\\'; + else if (*c == '0') + value[i++] = '\0'; + else if (*c == 'b') + value[i++] = '\b'; + else if (*c == 'n') + value[i++] = '\n'; + else if (*c == 'r') + value[i++] = '\r'; + else if (*c == 't') + value[i++] = '\t'; + else + abort(); + } + else + value[i++] = *c; + } + value[i] = '\0'; +} + +int usage(int ret) { + fprintf(stderr, "Usage: run-emitter-test-suite [--directive (1.1|1.2)] [--flow (on|off|keep)] [<input-file>]\n"); + return ret; +} diff --git a/tests/run-emitter.c b/tests/run-emitter.c index 6b246fa81df9..3ffe4754b23e 100644 --- a/tests/run-emitter.c +++ b/tests/run-emitter.c @@ -139,7 +139,7 @@ int compare_events(yaml_event_t *event1, yaml_event_t *event2) event1->data.scalar.length) != 0) return 0; if ((event1->data.scalar.plain_implicit != event2->data.scalar.plain_implicit) - || (event2->data.scalar.quoted_implicit != event2->data.scalar.quoted_implicit) + || (event1->data.scalar.quoted_implicit != event2->data.scalar.quoted_implicit) /* || (event2->data.scalar.style != event2->data.scalar.style) */) return 0; return 1; @@ -205,8 +205,8 @@ int print_output(char *name, unsigned char *buffer, size_t size, int count) if (feof(file)) break; } fclose(file); - printf("#### (length: %d)\n", total_size); - printf("OUTPUT:\n%s#### (length: %d)\n", buffer, size); + printf("#### (length: %ld)\n", (long)total_size); + printf("OUTPUT:\n%s#### (length: %ld)\n", buffer, (long)size); return 0; } @@ -251,7 +251,7 @@ main(int argc, char *argv[]) yaml_parser_t parser; yaml_emitter_t emitter; yaml_event_t event; - unsigned char buffer[BUFFER_SIZE]; + unsigned char buffer[BUFFER_SIZE+1]; size_t written = 0; yaml_event_t events[MAX_EVENTS]; size_t event_number = 0; @@ -259,7 +259,7 @@ main(int argc, char *argv[]) int count = 0; int error = 0; int k; - memset(buffer, 0, BUFFER_SIZE); + memset(buffer, 0, BUFFER_SIZE+1); memset(events, 0, MAX_EVENTS*sizeof(yaml_event_t)); printf("[%d] Parsing, emitting, and parsing again '%s': ", number, argv[number]); @@ -290,7 +290,7 @@ main(int argc, char *argv[]) assert(event_number < MAX_EVENTS); assert(copy_event(&(events[event_number++]), &event)); assert(yaml_emitter_emit(&emitter, &event) || - (yaml_emitter_flush(&emitter) && print_output(argv[number], buffer, written, count))); + print_output(argv[number], buffer, written, count)); count ++; } @@ -319,7 +319,7 @@ main(int argc, char *argv[]) yaml_event_delete(events+k); } - printf("PASSED (length: %d)\n", written); + printf("PASSED (length: %ld)\n", (long)written); print_output(argv[number], buffer, written, -1); } diff --git a/tests/run-parser-test-suite.c b/tests/run-parser-test-suite.c new file mode 100644 index 000000000000..5bdd66238ddd --- /dev/null +++ b/tests/run-parser-test-suite.c @@ -0,0 +1,189 @@ +#include <yaml.h> +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> + +void print_escaped(yaml_char_t * str, size_t length); +int usage(int ret); + +int main(int argc, char *argv[]) +{ + FILE *input; + yaml_parser_t parser; + yaml_event_t event; + int flow = -1; /** default no flow style collections */ + int i = 0; + int foundfile = 0; + + for (i = 1; i < argc; i++) { + if (strncmp(argv[i], "--flow", 6) == 0) { + if (i+1 == argc) + return usage(1); + i++; + if (strncmp(argv[i], "keep", 4) == 0) + flow = 0; + else if (strncmp(argv[i], "on", 2) == 0) + flow = 1; + else if (strncmp(argv[i], "off", 3) == 0) + flow = -1; + else + return usage(1); + } + else if (strncmp(argv[i], "--help", 6) == 0) + return usage(0); + else if (strncmp(argv[i], "-h", 2) == 0) + return usage(0); + else if (!foundfile) { + input = fopen(argv[i], "rb"); + foundfile = 1; + } + else + return usage(1); + } + if (!foundfile) { + input = stdin; + } + assert(input); + + if (!yaml_parser_initialize(&parser)) { + fprintf(stderr, "Could not initialize the parser object\n"); + return 1; + } + yaml_parser_set_input_file(&parser, input); + + while (1) { + yaml_event_type_t type; + if (!yaml_parser_parse(&parser, &event)) { + if ( parser.problem_mark.line || parser.problem_mark.column ) { + fprintf(stderr, "Parse error: %s\nLine: %lu Column: %lu\n", + parser.problem, + (unsigned long)parser.problem_mark.line + 1, + (unsigned long)parser.problem_mark.column + 1); + } + else { + fprintf(stderr, "Parse error: %s\n", parser.problem); + } + return 1; + } + type = event.type; + + if (type == YAML_NO_EVENT) + printf("???\n"); + else if (type == YAML_STREAM_START_EVENT) + printf("+STR\n"); + else if (type == YAML_STREAM_END_EVENT) + printf("-STR\n"); + else if (type == YAML_DOCUMENT_START_EVENT) { + printf("+DOC"); + if (!event.data.document_start.implicit) + printf(" ---"); + printf("\n"); + } + else if (type == YAML_DOCUMENT_END_EVENT) { + printf("-DOC"); + if (!event.data.document_end.implicit) + printf(" ..."); + printf("\n"); + } + else if (type == YAML_MAPPING_START_EVENT) { + printf("+MAP"); + if (flow == 0 && event.data.mapping_start.style == YAML_FLOW_MAPPING_STYLE) + printf(" {}"); + else if (flow == 1) + printf(" {}"); + if (event.data.mapping_start.anchor) + printf(" &%s", event.data.mapping_start.anchor); + if (event.data.mapping_start.tag) + printf(" <%s>", event.data.mapping_start.tag); + printf("\n"); + } + else if (type == YAML_MAPPING_END_EVENT) + printf("-MAP\n"); + else if (type == YAML_SEQUENCE_START_EVENT) { + printf("+SEQ"); + if (flow == 0 && event.data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE) + printf(" []"); + else if (flow == 1) + printf(" []"); + if (event.data.sequence_start.anchor) + printf(" &%s", event.data.sequence_start.anchor); + if (event.data.sequence_start.tag) + printf(" <%s>", event.data.sequence_start.tag); + printf("\n"); + } + else if (type == YAML_SEQUENCE_END_EVENT) + printf("-SEQ\n"); + else if (type == YAML_SCALAR_EVENT) { + printf("=VAL"); + if (event.data.scalar.anchor) + printf(" &%s", event.data.scalar.anchor); + if (event.data.scalar.tag) + printf(" <%s>", event.data.scalar.tag); + switch (event.data.scalar.style) { + case YAML_PLAIN_SCALAR_STYLE: + printf(" :"); + break; + case YAML_SINGLE_QUOTED_SCALAR_STYLE: + printf(" '"); + break; + case YAML_DOUBLE_QUOTED_SCALAR_STYLE: + printf(" \""); + break; + case YAML_LITERAL_SCALAR_STYLE: + printf(" |"); + break; + case YAML_FOLDED_SCALAR_STYLE: + printf(" >"); + break; + case YAML_ANY_SCALAR_STYLE: + abort(); + } + print_escaped(event.data.scalar.value, event.data.scalar.length); + printf("\n"); + } + else if (type == YAML_ALIAS_EVENT) + printf("=ALI *%s\n", event.data.alias.anchor); + else + abort(); + + yaml_event_delete(&event); + + if (type == YAML_STREAM_END_EVENT) + break; + } + + assert(!fclose(input)); + yaml_parser_delete(&parser); + fflush(stdout); + + return 0; +} + +void print_escaped(yaml_char_t * str, size_t length) +{ + int i; + char c; + + for (i = 0; i < length; i++) { + c = *(str + i); + if (c == '\\') + printf("\\\\"); + else if (c == '\0') + printf("\\0"); + else if (c == '\b') + printf("\\b"); + else if (c == '\n') + printf("\\n"); + else if (c == '\r') + printf("\\r"); + else if (c == '\t') + printf("\\t"); + else + printf("%c", c); + } +} + +int usage(int ret) { + fprintf(stderr, "Usage: libyaml-parser [--flow (on|off|keep)] [<input-file>]\n"); + return ret; +} diff --git a/tests/test-reader.c b/tests/test-reader.c index c6f84cd0d6e4..40f8199e009f 100644 --- a/tests/test-reader.c +++ b/tests/test-reader.c @@ -144,12 +144,12 @@ int check_utf8_sequences(void) } else if (parser.error == YAML_READER_ERROR) { if (parser.problem_value != -1) { - printf("(reader error: %s: #%X at %d)\n", - parser.problem, parser.problem_value, parser.problem_offset); + printf("(reader error: %s: #%X at %ld)\n", + parser.problem, parser.problem_value, (long)parser.problem_offset); } else { - printf("(reader error: %s at %d)\n", - parser.problem, parser.problem_offset); + printf("(reader error: %s at %ld)\n", + parser.problem, (long)parser.problem_offset); } } if (*end == '!') break; @@ -180,12 +180,12 @@ int check_boms(void) yaml_parser_set_input_string(&parser, (unsigned char *)start, end-start); result = yaml_parser_update_buffer(&parser, end-start); if (!result) { - printf("- (reader error: %s at %d)\n", parser.problem, parser.problem_offset); + printf("- (reader error: %s at %ld)\n", parser.problem, (long)parser.problem_offset); failed++; } else { if (parser.unread != check) { - printf("- (length=%d while expected length=%d)\n", parser.unread, check); + printf("- (length=%ld while expected length=%d)\n", (long)parser.unread, check); failed++; } else if (memcmp(parser.buffer.start, bom_original, check) != 0) { @@ -211,7 +211,7 @@ int check_long_utf8(void) int j; int failed = 0; unsigned char ch0, ch1; - unsigned char *buffer = malloc(3+LONG*2); + unsigned char *buffer = (unsigned char *)malloc(3+LONG*2); assert(buffer); printf("checking a long utf8 sequence...\n"); buffer[k++] = '\xef'; @@ -232,7 +232,7 @@ int check_long_utf8(void) for (k = 0; k < LONG; k++) { if (!parser.unread) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; break; } @@ -262,11 +262,11 @@ int check_long_utf8(void) } if (!failed) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; } else if (parser.buffer.pointer[0] != '\0') { - printf("\texpected NUL, found %X (eof=%d, unread=%d)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread); + printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread); failed = 1; } } @@ -283,7 +283,7 @@ int check_long_utf16(void) int j; int failed = 0; unsigned char ch0, ch1; - unsigned char *buffer = malloc(2+LONG*2); + unsigned char *buffer = (unsigned char *)malloc(2+LONG*2); assert(buffer); printf("checking a long utf16 sequence...\n"); buffer[k++] = '\xff'; @@ -303,7 +303,7 @@ int check_long_utf16(void) for (k = 0; k < LONG; k++) { if (!parser.unread) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; break; } @@ -333,11 +333,11 @@ int check_long_utf16(void) } if (!failed) { if (!yaml_parser_update_buffer(&parser, 1)) { - printf("\treader error: %s at %d\n", parser.problem, parser.problem_offset); + printf("\treader error: %s at %ld\n", parser.problem, (long)parser.problem_offset); failed = 1; } else if (parser.buffer.pointer[0] != '\0') { - printf("\texpected NUL, found %X (eof=%d, unread=%d)\n", (int)parser.buffer.pointer[0], parser.eof, parser.unread); + printf("\texpected NUL, found %X (eof=%d, unread=%ld)\n", (int)parser.buffer.pointer[0], parser.eof, (long)parser.unread); failed = 1; } } diff --git a/tests/test-version.c b/tests/test-version.c index e3e4a1623b3a..0c598377f95f 100644 --- a/tests/test-version.c +++ b/tests/test-version.c @@ -21,9 +21,9 @@ main(void) assert(strcmp(buf, yaml_get_version_string()) == 0); /* Print structure sizes. */ - printf("sizeof(token) = %d\n", sizeof(yaml_token_t)); - printf("sizeof(event) = %d\n", sizeof(yaml_event_t)); - printf("sizeof(parser) = %d\n", sizeof(yaml_parser_t)); + printf("sizeof(token) = %ld\n", (long)sizeof(yaml_token_t)); + printf("sizeof(event) = %ld\n", (long)sizeof(yaml_event_t)); + printf("sizeof(parser) = %ld\n", (long)sizeof(yaml_parser_t)); return 0; } |
