From: Jose Luis Blanco Claraco Date: Tue, 22 Feb 2022 21:23:34 +0000 (+0100) Subject: New upstream version 0.7.12 X-Git-Tag: archive/raspbian/0.9.4-1+rpi1~1^2~29^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=892174a643f56b7b0336f2ee9b456cf4abda5655;p=libfyaml.git New upstream version 0.7.12 --- diff --git a/.libtool-version b/.libtool-version index a759e95..b83a397 100644 --- a/.libtool-version +++ b/.libtool-version @@ -1 +1 @@ -1:1:0 +1:2:0 diff --git a/.tarball-version b/.tarball-version index b4d6d12..88a7b22 100644 --- a/.tarball-version +++ b/.tarball-version @@ -1 +1 @@ -0.7.11 +0.7.12 diff --git a/Makefile.in b/Makefile.in index 0b7bbc8..2fae43d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -209,7 +209,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/build-aux/shave.in \ $(top_srcdir)/build-aux/tap-driver.sh AUTHORS build-aux/ar-lib \ build-aux/compile build-aux/config.guess build-aux/config.sub \ - build-aux/install-sh build-aux/ltmain.sh build-aux/missing + build-aux/depcomp build-aux/install-sh build-aux/ltmain.sh \ + build-aux/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -296,6 +297,7 @@ GIT = @GIT@ GREP = @GREP@ HAVE_CHECK = @HAVE_CHECK@ HAVE_COMPATIBLE_CHECK = @HAVE_COMPATIBLE_CHECK@ +HAVE_DEVMODE = @HAVE_DEVMODE@ HAVE_LIBYAML = @HAVE_LIBYAML@ HAVE_NETWORK = @HAVE_NETWORK@ HAVE_QSORT_R = @HAVE_QSORT_R@ diff --git a/config.h.in b/config.h.in index eea84d0..688a708 100644 --- a/config.h.in +++ b/config.h.in @@ -13,6 +13,9 @@ don't. */ #undef HAVE_DECL_ENVIRON +/* Define to 1 if developer mode is enabled */ +#undef HAVE_DEVMODE + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff --git a/configure b/configure index a2abd76..a5e00b3 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libfyaml 0.7.11. +# Generated by GNU Autoconf 2.69 for libfyaml 0.7.12. # # Report bugs to . # @@ -592,8 +592,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libfyaml' PACKAGE_TARNAME='libfyaml' -PACKAGE_VERSION='0.7.11' -PACKAGE_STRING='libfyaml 0.7.11' +PACKAGE_VERSION='0.7.12' +PACKAGE_STRING='libfyaml 0.7.12' PACKAGE_BUGREPORT='pantelis.antoniou@konsulko.com' PACKAGE_URL='' @@ -668,6 +668,9 @@ HAVE_SPHINX_FALSE HAVE_SPHINX_TRUE PIP3 SPHINX +HAVE_DEVMODE_FALSE +HAVE_DEVMODE_TRUE +HAVE_DEVMODE HAVE_NETWORK_FALSE HAVE_NETWORK_TRUE HAVE_NETWORK @@ -844,6 +847,7 @@ with_gnu_ld with_sysroot enable_libtool_lock enable_network +enable_devmode enable_shave ' ac_precious_vars='build_alias @@ -1421,7 +1425,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libfyaml 0.7.11 to adapt to many kinds of systems. +\`configure' configures libfyaml 0.7.12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1492,7 +1496,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libfyaml 0.7.11:";; + short | recursive ) echo "Configuration of libfyaml 0.7.12:";; esac cat <<\_ACEOF @@ -1514,6 +1518,7 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-network Disable tests requiring network access + --enable-devmode Enable development mode only debugging --enable-shave use shave to make the build pretty [[default=yes]] Optional Packages: @@ -1559,7 +1564,7 @@ Some influential environment variables: https://github.com/yaml/yaml-test-suite) TESTSUITECHECKOUT Testsuite checkout (default: - 80f289435a56189bbc5ca2f318574e48dbeef8aa) + 6e6c296ae9c9d2d5c4134b4b64d01b29ac19ff6f) JSONTESTSUITEURL JSON Testsuite git repo URL (default: https://github.com/nst/JSONTestSuite) @@ -1633,7 +1638,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libfyaml configure 0.7.11 +libfyaml configure 0.7.12 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2223,7 +2228,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libfyaml $as_me 0.7.11, which was +It was created by libfyaml $as_me 0.7.12, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3091,7 +3096,7 @@ fi # Define the identity of the package. PACKAGE='libfyaml' - VERSION='0.7.11' + VERSION='0.7.12' cat >>confdefs.h <<_ACEOF @@ -3241,7 +3246,7 @@ EXTRA=`echo $VERSION | cut -d- -f2- -s` # increase current, set revision and age to 0 -LIBTOOL_VERSION=1:1:0 +LIBTOOL_VERSION=1:2:0 @@ -18575,6 +18580,32 @@ else fi +# Check whether --enable-devmode was given. +if test "${enable_devmode+set}" = set; then : + enableval=$enable_devmode; +fi + + +if test "x$enable_devmode" != "xno" ; then + HAVE_DEVMODE=1 +else + HAVE_DEVMODE=0 +fi + + if test x$HAVE_DEVMODE = x1 ; then + HAVE_DEVMODE_TRUE= + HAVE_DEVMODE_FALSE='#' +else + HAVE_DEVMODE_TRUE='#' + HAVE_DEVMODE_FALSE= +fi + + +cat >>confdefs.h <<_ACEOF +#define HAVE_DEVMODE $HAVE_DEVMODE +_ACEOF + + # check for sphinx # Extract the first word of "sphinx-build", so it can be a program name with args. set dummy sphinx-build; ac_word=$2 @@ -18805,7 +18836,7 @@ fi if test "x$TESTSUITECHECKOUT" == "x" ; then - TESTSUITECHECKOUT="80f289435a56189bbc5ca2f318574e48dbeef8aa" + TESTSUITECHECKOUT="6e6c296ae9c9d2d5c4134b4b64d01b29ac19ff6f" fi @@ -19202,6 +19233,10 @@ if test -z "${HAVE_NETWORK_TRUE}" && test -z "${HAVE_NETWORK_FALSE}"; then as_fn_error $? "conditional \"HAVE_NETWORK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_DEVMODE_TRUE}" && test -z "${HAVE_DEVMODE_FALSE}"; then + as_fn_error $? "conditional \"HAVE_DEVMODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${HAVE_SPHINX_TRUE}" && test -z "${HAVE_SPHINX_FALSE}"; then as_fn_error $? "conditional \"HAVE_SPHINX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -19615,7 +19650,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libfyaml $as_me 0.7.11, which was +This file was extended by libfyaml $as_me 0.7.12, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19681,7 +19716,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libfyaml config.status 0.7.11 +libfyaml config.status 0.7.12 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -21804,6 +21839,7 @@ echo " HAVE_CHECK: ${HAVE_CHECK} HAVE_COMPATIBLE_CHECK: ${HAVE_COMPATIBLE_CHECK} HAVE_NETWORK: ${HAVE_NETWORK} + HAVE_DEVMODE: ${HAVE_DEVMODE} HAVE_SPHINX: ${HAVE_SPHINX} GIT: $GIT DOCKER: $DOCKER diff --git a/configure.ac b/configure.ac index 8a495ec..8b366ed 100644 --- a/configure.ac +++ b/configure.ac @@ -186,15 +186,30 @@ AC_ARG_ENABLE([network], AS_HELP_STRING([--disable-network], [Disable tests requiring network access])) -if test "x$enable_network" != "xno" ; then +if test "x$enable_network" != "xno" ; then HAVE_NETWORK=1 else HAVE_NETWORK=0 -fi +fi AC_SUBST(HAVE_NETWORK) AM_CONDITIONAL([HAVE_NETWORK], [ test x$HAVE_NETWORK = x1 ]) +dnl enable internet available when checking +AC_ARG_ENABLE([devmode], + AS_HELP_STRING([--enable-devmode], + [Enable development mode only debugging])) + +if test "x$enable_devmode" != "xno" ; then + HAVE_DEVMODE=1 +else + HAVE_DEVMODE=0 +fi +AC_SUBST(HAVE_DEVMODE) +AM_CONDITIONAL([HAVE_DEVMODE], + [ test x$HAVE_DEVMODE = x1 ]) +AC_DEFINE_UNQUOTED([HAVE_DEVMODE], [$HAVE_DEVMODE], [Define to 1 if developer mode is enabled]) + # check for sphinx AC_PATH_PROG([SPHINX], [sphinx-build]) @@ -268,10 +283,10 @@ if test "x$TESTSUITEURL" == "x" ; then TESTSUITEURL="https://github.com/yaml/yaml-test-suite" fi -AC_ARG_VAR(TESTSUITECHECKOUT, [Testsuite checkout (default: 80f289435a56189bbc5ca2f318574e48dbeef8aa)]) +AC_ARG_VAR(TESTSUITECHECKOUT, [Testsuite checkout (default: 6e6c296ae9c9d2d5c4134b4b64d01b29ac19ff6f)]) if test "x$TESTSUITECHECKOUT" == "x" ; then - TESTSUITECHECKOUT="80f289435a56189bbc5ca2f318574e48dbeef8aa" + TESTSUITECHECKOUT="6e6c296ae9c9d2d5c4134b4b64d01b29ac19ff6f" fi AC_ARG_VAR(JSONTESTSUITEURL, [JSON Testsuite git repo URL (default: https://github.com/nst/JSONTestSuite)]) @@ -341,6 +356,7 @@ echo " HAVE_CHECK: ${HAVE_CHECK} HAVE_COMPATIBLE_CHECK: ${HAVE_COMPATIBLE_CHECK} HAVE_NETWORK: ${HAVE_NETWORK} + HAVE_DEVMODE: ${HAVE_DEVMODE} HAVE_SPHINX: ${HAVE_SPHINX} GIT: $GIT DOCKER: $DOCKER diff --git a/doc/Makefile.in b/doc/Makefile.in index de17f1f..e9d73ce 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -172,6 +172,7 @@ GIT = @GIT@ GREP = @GREP@ HAVE_CHECK = @HAVE_CHECK@ HAVE_COMPATIBLE_CHECK = @HAVE_COMPATIBLE_CHECK@ +HAVE_DEVMODE = @HAVE_DEVMODE@ HAVE_LIBYAML = @HAVE_LIBYAML@ HAVE_NETWORK = @HAVE_NETWORK@ HAVE_QSORT_R = @HAVE_QSORT_R@ diff --git a/src/Makefile.in b/src/Makefile.in index fd57f09..3b544e3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -293,6 +293,7 @@ GIT = @GIT@ GREP = @GREP@ HAVE_CHECK = @HAVE_CHECK@ HAVE_COMPATIBLE_CHECK = @HAVE_COMPATIBLE_CHECK@ +HAVE_DEVMODE = @HAVE_DEVMODE@ HAVE_LIBYAML = @HAVE_LIBYAML@ HAVE_NETWORK = @HAVE_NETWORK@ HAVE_QSORT_R = @HAVE_QSORT_R@ diff --git a/src/lib/fy-diag.h b/src/lib/fy-diag.h index 2653db5..f19861d 100644 --- a/src/lib/fy-diag.h +++ b/src/lib/fy-diag.h @@ -22,6 +22,12 @@ #include "fy-list.h" #include "fy-token.h" +#if !defined(NDEBUG) && defined(HAVE_DEVMODE) && HAVE_DEVMODE +#define FY_DEVMODE +#else +#undef FY_DEVMODE +#endif + /* error flags (above 0x100 is library specific) */ #define FYEF_SOURCE 0x0001 #define FYEF_POSITION 0x0002 @@ -94,7 +100,7 @@ void fy_diag_report(struct fy_diag *diag, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define __FY_DEBUG_UNUSED__ /* nothing */ #else #define __FY_DEBUG_UNUSED__ __attribute__((__unused__)) @@ -128,7 +134,7 @@ void fy_parser_diag_report(struct fy_parser *fyp, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define fyp_debug(_fyp, _module, _fmt, ...) \ fy_parser_diag((_fyp), FYET_DEBUG | FYDF_MODULE(_module), \ @@ -276,7 +282,7 @@ void fy_reader_diag_report(struct fy_reader *fyr, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define fyr_debug(_fyr, _fmt, ...) \ fy_reader_diag((_fyr), FYET_DEBUG, \ @@ -416,7 +422,7 @@ void fy_document_diag_report(struct fy_document *fyd, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define fyd_debug(_fyd, _module, _fmt, ...) \ fy_document_diag((_fyd), FYET_DEBUG | FYDF_MODULE(_module), \ @@ -518,7 +524,7 @@ void fy_composer_diag_report(struct fy_composer *fyc, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define fyc_debug(_fyc, _module, _fmt, ...) \ fy_composer_diag((_fyc), FYET_DEBUG | FYDF_MODULE(_module), \ @@ -603,7 +609,7 @@ void fy_document_builder_diag_report(struct fy_document_builder *fydb, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -#ifndef NDEBUG +#ifdef FY_DEVMODE #define fydb_debug(_fydb, _module, _fmt, ...) \ fy_document_builder_diag((_fydb), FYET_DEBUG | FYDF_MODULE(_module), \ diff --git a/src/lib/fy-dump.c b/src/lib/fy-dump.c index b84eea1..24fb8c9 100644 --- a/src/lib/fy-dump.c +++ b/src/lib/fy-dump.c @@ -235,7 +235,7 @@ char *fy_simple_key_list_dump_format(struct fy_parser *fyp, struct fy_simple_key return buf; } -#ifndef NDEBUG +#ifdef FY_DEVMODE void fyp_debug_dump_token_list(struct fy_parser *fyp, struct fy_token_list *fytl, struct fy_token *fyt_highlight, const char *banner) @@ -292,9 +292,8 @@ void fyp_debug_dump_input(struct fy_parser *fyp, const struct fy_input_cfg *fyic fyic->file.filename); break; case fyit_stream: - fyp_scan_debug(fyp, "%s: stream=\"%s\" fileno=%d chunk=%zu\n", banner, - fyic->stream.name, fileno(fyic->stream.fp), - fyic->stream.chunk); + fyp_scan_debug(fyp, "%s: stream=\"%s\" fileno=%d\n", banner, + fyic->stream.name, fileno(fyic->stream.fp)); break; case fyit_memory: fyp_scan_debug(fyp, "%s: start=%p size=%zu\n", banner, diff --git a/src/lib/fy-dump.h b/src/lib/fy-dump.h index a95fe1f..13b1c9a 100644 --- a/src/lib/fy-dump.h +++ b/src/lib/fy-dump.h @@ -39,7 +39,7 @@ char *fy_simple_key_dump_format(struct fy_parser *fyp, struct fy_simple_key *fys char *fy_simple_key_list_dump_format(struct fy_parser *fyp, struct fy_simple_key_list *fyskl, struct fy_simple_key *fysk_highlight, char *buf, size_t bufsz); -#ifndef NDEBUG +#ifdef FY_DEVMODE void fyp_debug_dump_token_list(struct fy_parser *fyp, struct fy_token_list *fytl, struct fy_token *fyt_highlight, const char *banner); diff --git a/src/lib/fy-input.c b/src/lib/fy-input.c index c411408..b7c16e0 100644 --- a/src/lib/fy-input.c +++ b/src/lib/fy-input.c @@ -592,13 +592,13 @@ int fy_reader_input_scan_token_mark_slow_path(struct fy_reader *fyr) fyr->current_input_pos = 0; fyr->current_ptr = fyi_new->buffer; + fyr_debug(fyr, "chop at this_input_start=%zu chop=%zu\n", fyr->this_input_start, fyi->chop); + /* free the old input - while references to it exist it will hang around */ fyi->state = FYIS_PARSED; fy_input_unref(fyi); fyi = NULL; - fyr_debug(fyr, "chop at this_input_start=%zu chop=%zu\n", fyr->this_input_start, fyi->chop); - return 0; err_out: fy_input_unref(fyi_new); diff --git a/src/lib/fy-input.h b/src/lib/fy-input.h index 618f3b8..6634fab 100644 --- a/src/lib/fy-input.h +++ b/src/lib/fy-input.h @@ -24,12 +24,6 @@ #include "fy-typelist.h" #include "fy-ctype.h" -#ifndef NDEBUG -#define __FY_DEBUG_UNUSED__ /* nothing */ -#else -#define __FY_DEBUG_UNUSED__ __attribute__((__unused__)) -#endif - struct fy_atom; struct fy_parser; diff --git a/src/lib/fy-parse.c b/src/lib/fy-parse.c index 3c8618d..df110e1 100644 --- a/src/lib/fy-parse.c +++ b/src/lib/fy-parse.c @@ -1144,6 +1144,7 @@ int fy_scan_to_next_token(struct fy_parser *fyp) /* may start simple key (in block ctx) */ if (!fyp->flow_level && !fyp->simple_key_allowed) { fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; tabs_allowed = fyp->flow_level || !fyp->simple_key_allowed || fyp_tabsize(fyp); fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); } @@ -1218,11 +1219,13 @@ static int fy_purge_stale_simple_keys(struct fy_parser *fyp, bool *did_purgep, *did_purgep = false; while ((fysk = fy_simple_key_list_head(&fyp->simple_keys)) != NULL) { +#ifdef FY_DEVMODE fyp_scan_debug(fyp, "purge-check: flow_level=%d fysk->flow_level=%d fysk->mark.line=%d line=%d", fyp->flow_level, fysk->flow_level, fysk->mark.line, fyp_line(fyp)); fyp_debug_dump_simple_key(fyp, fysk, "purge-check: "); +#endif line = fysk->mark.line; @@ -1246,7 +1249,9 @@ static int fy_purge_stale_simple_keys(struct fy_parser *fyp, bool *did_purgep, goto err_out; } +#ifdef FY_DEVMODE fyp_debug_dump_simple_key(fyp, fysk, "purging: "); +#endif fy_simple_key_list_del(&fyp->simple_keys, fysk); fy_parse_simple_key_recycle(fyp, fysk); @@ -1365,6 +1370,7 @@ void fy_remove_all_simple_keys(struct fy_parser *fyp) fy_parse_simple_key_recycle(fyp, fysk); fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); } @@ -1391,7 +1397,9 @@ int fy_remove_simple_key(struct fy_parser *fyp, enum fy_token_type next_type) while ((fysk = fy_simple_key_list_first(&fyp->simple_keys)) != NULL && fysk->flow_level >= fyp->flow_level) { +#ifdef FY_DEVMODE fyp_debug_dump_simple_key(fyp, fysk, "removing: "); +#endif /* remove it from the list */ fy_simple_key_list_del(&fyp->simple_keys, fysk); @@ -1499,7 +1507,9 @@ int fy_save_simple_key(struct fy_parser *fyp, struct fy_mark *mark, struct fy_ma (fyt->type == FYTT_FLOW_MAPPING_START || fyt->type == FYTT_FLOW_SEQUENCE_START); +#ifdef FY_DEVMODE fyp_debug_dump_simple_key_list(fyp, &fyp->simple_keys, fysk, "fyp->simple_keys (saved): "); +#endif return 0; @@ -1593,6 +1603,60 @@ err_out: return -1; } +/* special case for allowing whitespace (including tabs) after -?: */ +static int fy_ws_indentation_check(struct fy_parser *fyp, bool *found_tabp, struct fy_mark *tab_mark) +{ + int c, adv, tab_adv; + bool indentation, found_tab; + + found_tab = false; + + /* not meaning in flow mode */ + if (fyp->flow_level) + goto out; + + /* scan forward, keeping track if we found a tab */ + adv = 0; + tab_adv = -1; + if (tab_mark) + fy_get_mark(fyp, tab_mark); + while (fy_is_ws(c = fy_parse_peek_at(fyp, adv))) { + if (!found_tab && fy_is_tab(c)) { + found_tab = true; + tab_adv = adv; + /* XXX somewhat hacky, space is 1 char only so adjust */ + if (tab_mark) { + tab_mark->input_pos += adv; + tab_mark->column += adv; + } + } + adv++; + } + + if (found_tab) { + indentation = fy_utf8_strchr("?:|>", c) || + (c == '-' && fyp_is_blankz(fyp, fy_parse_peek_at(fyp, adv + 1))); + + /* any kind of block indentation is not allowed */ + FYP_PARSE_ERROR_CHECK(fyp, tab_adv, 1, FYEM_SCAN, + !indentation, err_out, + "cannot use tab for indentation of block entry"); + fy_advance_by(fyp, tab_adv + 1); + } + + /* now chomp spaces only afterwards */ + while (fy_is_space(c = fy_parse_peek(fyp))) + fy_advance(fyp, c); + +out: + if (found_tabp) + *found_tabp = found_tab; + + return 0; + +err_out: + return -1; +} int fy_fetch_stream_start(struct fy_parser *fyp) { @@ -1600,6 +1664,7 @@ int fy_fetch_stream_start(struct fy_parser *fyp) /* simple key is allowed */ fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); fyt = fy_token_queue_simple(fyp, &fyp->queued_tokens, FYTT_STREAM_START, 0); @@ -2082,6 +2147,7 @@ int fy_fetch_document_indicator(struct fy_parser *fyp, enum fy_token_type type) } fyp->simple_key_allowed = false; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); fyt = fy_token_queue_simple(fyp, &fyp->queued_tokens, type, 3); @@ -2159,6 +2225,7 @@ int fy_fetch_flow_collection_mark_start(struct fy_parser *fyp, int c) fyp->flow = c == '[' ? FYFT_SEQUENCE : FYFT_MAP; fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); /* the comment indicator must have at least a space */ @@ -2229,6 +2296,7 @@ int fy_fetch_flow_collection_mark_end(struct fy_parser *fyp, int c) "fy_parse_flow_pop() failed"); fyp->simple_key_allowed = false; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); @@ -2311,6 +2379,7 @@ int fy_fetch_flow_collection_entry(struct fy_parser *fyp, int c) "fy_remove_simple_key() failed"); fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); fyt_last = fy_token_list_tail(&fyp->queued_tokens); @@ -2356,8 +2425,6 @@ int fy_fetch_block_entry(struct fy_parser *fyp, int c) struct fy_mark mark; struct fy_simple_key *fysk; struct fy_token *fyt; - int adv, tab_adv; - bool indentation, found_tab; fyp_error_check(fyp, c == '-', err_out, "illegal block entry"); @@ -2424,40 +2491,16 @@ int fy_fetch_block_entry(struct fy_parser *fyp, int c) "fy_remove_simple_key() failed"); fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); fyt = fy_token_queue_simple(fyp, &fyp->queued_tokens, FYTT_BLOCK_ENTRY, 1); fyp_error_check(fyp, fyt, err_out, "fy_token_queue_simple() failed"); - /* special case for allowing whitespace (including tabs) after - */ - found_tab = false; - - /* scan forward, keeping track if we found a tab */ - adv = 0; - tab_adv = -1; - while (fy_is_ws(c = fy_parse_peek_at(fyp, adv))) { - if (!found_tab && fy_is_tab(c)) { - found_tab = true; - tab_adv = adv; - } - adv++; - } - - if (found_tab) { - indentation = fy_utf8_strchr("?:|>", c) || - (c == '-' && fyp_is_blankz(fyp, fy_parse_peek_at(fyp, adv + 1))); - - /* any kind of block indentation is not allowed */ - FYP_PARSE_ERROR_CHECK(fyp, tab_adv, 1, FYEM_SCAN, - !indentation, err_out, - "cannot use tab for indentation of block entry"); - fy_advance_by(fyp, tab_adv + 1); - } - - /* now chomp spaces only afterwards */ - while (fy_is_space(c = fy_parse_peek(fyp))) - fy_advance(fyp, c); + rc = fy_ws_indentation_check(fyp, NULL, NULL); + fyp_error_check(fyp, !rc, err_out_rc, + "fy_ws_indentation_check() failed"); return 0; @@ -2475,6 +2518,8 @@ int fy_fetch_key(struct fy_parser *fyp, int c) bool target_simple_key_allowed; struct fy_token *fyt; struct fy_atom *handle; + bool found_tab; + struct fy_mark tab_mark; fyp_error_check(fyp, c == '?', err_out, "illegal block entry or key mark"); @@ -2524,9 +2569,16 @@ int fy_fetch_key(struct fy_parser *fyp, int c) fyp->simple_key_allowed = target_simple_key_allowed; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); - /* eat whitespace */ - while (fy_is_blank(c = fy_parse_peek(fyp))) - fy_advance(fyp, c); + rc = fy_ws_indentation_check(fyp, &found_tab, &tab_mark); + fyp_error_check(fyp, !rc, err_out_rc, + "fy_ws_indentation_check() failed"); + + /* record whether a tab was used for indentation */ + if (fyp->simple_key_allowed && found_tab) { + fyp->tab_used_for_ws = true; + fyp->last_tab_used_for_ws_mark = tab_mark; + } else + fyp->tab_used_for_ws = false; // XXX /* comment? */ if (c == '#') { @@ -2558,6 +2610,8 @@ int fy_fetch_value(struct fy_parser *fyp, int c) bool push_bmap_start, push_key_only, did_purge, final_complex_key; bool is_multiline __FY_DEBUG_UNUSED__; struct fy_atom *chandle; + bool found_tab; + struct fy_mark tab_mark; int rc; fyp_error_check(fyp, c == ':', err_out, @@ -2669,6 +2723,12 @@ int fy_fetch_value(struct fy_parser *fyp, int c) goto err_out; } + /* special handling for ?: */ + if (fyp->tab_used_for_ws) { + FYP_PARSE_ERROR(fyp, 0, 1, FYEM_SCAN, "Indentation used tabs for ':' indicator"); + goto err_out; + } + if (push_bmap_start) { assert(!fyp->flow_level); @@ -2698,9 +2758,11 @@ int fy_fetch_value(struct fy_parser *fyp, int c) fyt->key.flow_level = fyp->flow_level; } +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt_insert, "insert-token: "); fyp_debug_dump_token_list(fyp, &fyp->queued_tokens, fyt_insert, "fyp->queued_tokens (before): "); fyp_debug_dump_token_list(fyp, &sk_tl, NULL, "sk_tl: "); +#endif if (fyt_insert) { @@ -2711,7 +2773,9 @@ int fy_fetch_value(struct fy_parser *fyp, int c) } else fy_token_lists_splice(&fyp->queued_tokens, &sk_tl); +#ifdef FY_DEVMODE fyp_debug_dump_token_list(fyp, &fyp->queued_tokens, fyt_insert, "fyp->queued_tokens (after): "); +#endif target_simple_key_allowed = fysk ? false : !fyp->flow_level; @@ -2719,11 +2783,26 @@ int fy_fetch_value(struct fy_parser *fyp, int c) fyp_error_check(fyp, fyt, err_out, "fy_token_queue_simple() failed"); + if (fysk) + fy_parse_simple_key_recycle(fyp, fysk); + + fyp->simple_key_allowed = target_simple_key_allowed; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); - if (fysk) - fy_parse_simple_key_recycle(fyp, fysk); + if (is_complex) { + rc = fy_ws_indentation_check(fyp, &found_tab, &tab_mark); + fyp_error_check(fyp, !rc, err_out_rc, + "fy_ws_indentation_check() failed"); + + /* record whether a tab was used for indentation */ + if (fyp->simple_key_allowed && found_tab) { + fyp->tab_used_for_ws = true; + fyp->last_tab_used_for_ws_mark = tab_mark; + } else + fyp->tab_used_for_ws = false; // XXX + } else + fyp->tab_used_for_ws = false; if (final_complex_key) { fyp->pending_complex_key_column = -1; @@ -2746,6 +2825,7 @@ int fy_fetch_value(struct fy_parser *fyp, int c) fyp_error_check(fyp, !rc, err_out_rc, "fy_scan_comment() failed"); } + } return 0; @@ -2866,6 +2946,7 @@ int fy_fetch_anchor_or_alias(struct fy_parser *fyp, int c) "fy_save_simple_key_mark() failed"); fyp->simple_key_allowed = false; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); return 0; @@ -2984,6 +3065,7 @@ int fy_fetch_tag(struct fy_parser *fyp, int c) "fy_save_simple_key_mark() failed"); fyp->simple_key_allowed = false; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); return 0; @@ -3110,6 +3192,7 @@ int fy_fetch_block_scalar(struct fy_parser *fyp, bool is_literal, int c) "fy_remove_simple_key() failed"); fyp->simple_key_allowed = true; + fyp->tab_used_for_ws = false; fyp_scan_debug(fyp, "simple_key_allowed -> %s\n", fyp->simple_key_allowed ? "true" : "false"); /* skip over block scalar start */ @@ -5093,8 +5176,10 @@ struct fy_token *fy_scan(struct fy_parser *fyp) (void)fy_parse_tag_directive(fyp, fyt, true); } +#ifdef FY_DEVMODE if (fyt) fyp_debug_dump_token(fyp, fyt, "producing: "); +#endif return fyt; } @@ -5524,7 +5609,10 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); + +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif had_doc_end = true; } @@ -5565,7 +5653,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_peek(fyp); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif } /* the end */ @@ -5805,7 +5895,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif /* check whether it's a sequence entry or not */ is_seq = fyt->type != FYTT_BLOCK_ENTRY && fyt->type != FYTT_BLOCK_END; @@ -5897,7 +5989,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif /* check whether it's a block entry or not */ is_block = fyt->type != FYTT_KEY && fyt->type != FYTT_VALUE && @@ -5940,7 +6034,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif /* check whether it's a block entry or not */ is_value = fyt->type != FYTT_KEY && fyt->type != FYTT_VALUE && @@ -5984,7 +6080,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif } if (fyt->type == FYTT_KEY) { @@ -6068,7 +6166,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif if (fyt->type != FYTT_FLOW_ENTRY && fyt->type != FYTT_FLOW_SEQUENCE_END) { rc = fy_parse_state_push(fyp, FYPS_FLOW_SEQUENCE_ENTRY_MAPPING_END); @@ -6134,7 +6234,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif } if (fyt->type == FYTT_KEY) { @@ -6142,7 +6244,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif /* JSON key checks */ FYP_TOKEN_ERROR_CHECK(fyp, fyt, FYEM_PARSE, @@ -6212,7 +6316,9 @@ static struct fy_eventp *fy_parse_internal(struct fy_parser *fyp) fyt = fy_scan_remove_peek(fyp, fyt); fyp_error_check(fyp, fyt, err_out, "failed to peek token"); +#ifdef FY_DEVMODE fyp_debug_dump_token(fyp, fyt, "next: "); +#endif if (fyt->type != FYTT_FLOW_ENTRY && fyt->type != FYTT_FLOW_MAPPING_END) { diff --git a/src/lib/fy-parse.h b/src/lib/fy-parse.h index df278fc..11e71bf 100644 --- a/src/lib/fy-parse.h +++ b/src/lib/fy-parse.h @@ -150,6 +150,7 @@ struct fy_parser { bool stream_end_produced : 1; bool stream_end_reached : 1; bool simple_key_allowed : 1; + bool tab_used_for_ws : 1; bool stream_error : 1; bool generated_block_map : 1; bool last_was_comma : 1; @@ -165,6 +166,7 @@ struct fy_parser { struct fy_mark pending_complex_key_mark; int last_block_mapping_key_line; struct fy_mark last_comma_mark; + struct fy_mark last_tab_used_for_ws_mark; /* copy of stream_end token */ struct fy_token *stream_end_token; diff --git a/test/Makefile.in b/test/Makefile.in index 265d7e4..9391717 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -448,6 +448,7 @@ GIT = @GIT@ GREP = @GREP@ HAVE_CHECK = @HAVE_CHECK@ HAVE_COMPATIBLE_CHECK = @HAVE_COMPATIBLE_CHECK@ +HAVE_DEVMODE = @HAVE_DEVMODE@ HAVE_LIBYAML = @HAVE_LIBYAML@ HAVE_NETWORK = @HAVE_NETWORK@ HAVE_QSORT_R = @HAVE_QSORT_R@ diff --git a/test/testsuite-evstream.test b/test/testsuite-evstream.test index 2f35be2..a6f931f 100755 --- a/test/testsuite-evstream.test +++ b/test/testsuite-evstream.test @@ -2,7 +2,7 @@ count=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # there must be a test there if [ ! -e "$tst/===" ]; then continue @@ -24,7 +24,7 @@ xfaillist="" i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # there must be a test there if [ ! -e "$tst/===" ]; then diff --git a/test/testsuite-json.test b/test/testsuite-json.test index 794d515..503f993 100755 --- a/test/testsuite-json.test +++ b/test/testsuite-json.test @@ -2,7 +2,7 @@ count=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # there must be a test there if [ ! -e "$tst/===" ]; then continue @@ -28,7 +28,7 @@ xfaillist="" i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # ignore tests which are expected to fail if [ -e "$tst/error" ]; then diff --git a/test/testsuite.test b/test/testsuite.test index 1883d00..4f82f4d 100755 --- a/test/testsuite.test +++ b/test/testsuite.test @@ -2,7 +2,7 @@ count=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # there must be a test there if [ ! -e "$tst/===" ]; then continue @@ -20,7 +20,7 @@ xfaillist="" i=0 for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do - for tst in ${basetst} ${basetst}[0-9][0-9]/; do + for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do # there must be a test there if [ ! -e "$tst/===" ]; then