diff --git a/src/lib/fy-emit.c b/src/lib/fy-emit.c index 1de6dce0..7736e3a9 100644 --- a/src/lib/fy-emit.c +++ b/src/lib/fy-emit.c @@ -783,6 +783,7 @@ void fy_emit_token_write_plain(struct fy_emitter *emit, struct fy_token *fyt, in fy_emit_output_accum(emit, wtype, &emit->ea); emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } else fy_emit_accum_utf8_put(&emit->ea, c); @@ -798,17 +799,21 @@ void fy_emit_token_write_plain(struct fy_emitter *emit, struct fy_token *fyt, in if (!breaks) { fy_emit_output_accum(emit, wtype, &emit->ea); fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); breaks = true; } else { - if (breaks) + if (breaks) { fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); + } fy_emit_accum_utf8_put(&emit->ea, c); @@ -857,6 +862,7 @@ void fy_emit_token_write_alias(struct fy_emitter *emit, struct fy_token *fyt, in void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, int flags, int indent, char qc) { + const struct fy_token_analysis *ta; bool allow_breaks, spaces, breaks; int c, i, w, digit; enum fy_emitter_write_type wtype; @@ -869,6 +875,7 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i uint32_t hi_surrogate, lo_surrogate; uint8_t non_utf8[4]; size_t non_utf8_len, k; + int emit_width; wtype = qc == '\'' ? ((flags & DDNF_SIMPLE_SCALAR_KEY) ? @@ -889,9 +896,15 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i */ target_style = qc == '"' ? FYAS_DOUBLE_QUOTED : FYAS_SINGLE_QUOTED; + allow_breaks = !(flags & DDNF_SIMPLE) && !fy_emit_is_json_mode(emit) && !fy_emit_is_oneline(emit); + emit_width = fy_emit_width(emit); + + ta = fy_token_text_analyze(fyt); + /* simple case of direct output (large amount of cases) */ str = fy_token_get_direct_output(fyt, &len); - if (str && fy_token_atom_style(fyt) == target_style) { + if (str && fy_token_atom_style(fyt) == target_style && + (ta->flags & FYTTAF_DIRECT_OUTPUT) && emit->column + ta->maxcol < emit_width) { fy_emit_write(emit, wtype, str, len); goto out; } @@ -901,8 +914,6 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i if (!atom) goto out; - allow_breaks = !(flags & DDNF_SIMPLE) && !fy_emit_is_json_mode(emit) && !fy_emit_is_oneline(emit); - spaces = false; breaks = false; @@ -931,7 +942,7 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i if (fy_is_space(c) || (qc == '\'' && fy_is_ws(c))) { should_indent = allow_breaks && !spaces && - fy_emit_accum_column(&emit->ea) > fy_emit_width(emit); + fy_emit_accum_column(&emit->ea) >= emit_width; if (should_indent && ((qc == '\'' && fy_is_ws(fy_atom_iter_utf8_peek(&iter))) || @@ -943,6 +954,7 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } else fy_emit_accum_utf8_put(&emit->ea, c); @@ -959,10 +971,12 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i if (!breaks) { fy_emit_output_accum(emit, wtype, &emit->ea); fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); breaks = true; } else { @@ -970,6 +984,17 @@ void fy_emit_token_write_quoted(struct fy_emitter *emit, struct fy_token *fyt, i if (breaks) { fy_emit_output_accum(emit, wtype, &emit->ea); fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); + + } else if (qc == '"' && allow_breaks && fy_emit_accum_column(&emit->ea) >= emit_width) { + + fy_emit_output_accum(emit, wtype, &emit->ea); + + fy_emit_putc(emit, wtype, '\\'); + + emit->flags &= ~FYEF_INDENTATION; + fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } /* escape */ @@ -1179,6 +1204,7 @@ void fy_emit_token_write_literal(struct fy_emitter *emit, struct fy_token *fyt, if (breaks) { fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); breaks = false; } @@ -1232,8 +1258,10 @@ void fy_emit_token_write_folded(struct fy_emitter *emit, struct fy_token *fyt, i fy_emit_output_accum(emit, fyewt_literal_scalar, &emit->ea); /* do not output a newline (indent) if at the end or * this is a leading spaces line */ - if (!fy_is_z(fy_atom_iter_utf8_peek(&iter)) && !leading_spaces) + if (!fy_is_z(fy_atom_iter_utf8_peek(&iter)) && !leading_spaces) { fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); + } } /* count the number of consecutive breaks */ @@ -1252,6 +1280,7 @@ void fy_emit_token_write_folded(struct fy_emitter *emit, struct fy_token *fyt, i while (nrbreaks-- > nrbreakslim) { emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } breaks = true; @@ -1261,6 +1290,7 @@ void fy_emit_token_write_folded(struct fy_emitter *emit, struct fy_token *fyt, i /* if we had a break, output an indent */ if (breaks) { fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); /* if this line starts with whitespace we need to know */ leading_spaces = fy_is_ws(c); @@ -1272,6 +1302,7 @@ void fy_emit_token_write_folded(struct fy_emitter *emit, struct fy_token *fyt, i fy_emit_output_accum(emit, fyewt_folded_scalar, &emit->ea); emit->flags &= ~FYEF_INDENTATION; fy_emit_write_indent(emit, indent); + fy_emit_output_col_sync(emit, &emit->ea); } else fy_emit_accum_utf8_put(&emit->ea, c); @@ -1288,9 +1319,9 @@ fy_emit_token_scalar_style(struct fy_emitter *emit, struct fy_token *fyt, int flags, int indent, enum fy_node_style style, struct fy_token *fyt_tag) { + const struct fy_token_analysis *ta = NULL; bool json, flow, is_null_scalar, is_json_plain; struct fy_atom *atom; - int aflags = -1; const char *tag; size_t tag_len; @@ -1337,23 +1368,23 @@ fy_emit_token_scalar_style(struct fy_emitter *emit, struct fy_token *fyt, return FYNS_DOUBLE_QUOTED; } - aflags = fy_token_text_analyze(fyt); + ta = fy_token_text_analyze(fyt); if (flow && (style == FYNS_ANY || style == FYNS_LITERAL || style == FYNS_FOLDED)) { /* if there's a linebreak, use double quoted style */ - if (aflags & FYTTAF_HAS_ANY_LB) { + if (ta->flags & FYTTAF_HAS_ANY_LB) { style = FYNS_DOUBLE_QUOTED; goto out; } - if (!(aflags & FYTTAF_HAS_NON_PRINT)) { + if (!(ta->flags & FYTTAF_HAS_NON_PRINT)) { style = FYNS_SINGLE_QUOTED; goto out; } /* anything not empty is double quoted here */ - style = !(aflags & FYTTAF_EMPTY) ? FYNS_PLAIN : FYNS_DOUBLE_QUOTED; + style = !(ta->flags & FYTTAF_EMPTY) ? FYNS_PLAIN : FYNS_DOUBLE_QUOTED; } /* try to pretify */ @@ -1361,21 +1392,20 @@ fy_emit_token_scalar_style(struct fy_emitter *emit, struct fy_token *fyt, (style == FYNS_ANY || style == FYNS_DOUBLE_QUOTED || style == FYNS_SINGLE_QUOTED)) { /* any original style can be a plain, but contains linebreaks, do a literal */ - if ((aflags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) { + if ((ta->flags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) { style = FYNS_LITERAL; goto out; } /* any style, can be just a plain, just make it so */ - if (style == FYNS_ANY && (aflags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == FYTTAF_CAN_BE_PLAIN) { + if ((ta->flags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == FYTTAF_CAN_BE_PLAIN) { style = FYNS_PLAIN; goto out; } - } if (!flow && emit->source_json && fy_emit_is_dejson_mode(emit)) { - if (is_json_plain || (aflags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == FYTTAF_CAN_BE_PLAIN) { + if (is_json_plain || (ta->flags & (FYTTAF_CAN_BE_PLAIN | FYTTAF_HAS_LB)) == FYTTAF_CAN_BE_PLAIN) { style = FYNS_PLAIN; goto out; } @@ -1383,15 +1413,18 @@ fy_emit_token_scalar_style(struct fy_emitter *emit, struct fy_token *fyt, out: if (style == FYNS_ANY) - style = (aflags & FYTTAF_CAN_BE_PLAIN) ? FYNS_PLAIN : FYNS_DOUBLE_QUOTED; + style = (ta->flags & FYTTAF_CAN_BE_PLAIN) ? FYNS_PLAIN : FYNS_DOUBLE_QUOTED; if (style == FYNS_PLAIN) { /* plains in flow mode not being able to be plains * - plain in block mode that can't be plain in flow mode * - special handling for plains on start of line */ - if ((flow && !(aflags & FYTTAF_CAN_BE_PLAIN_FLOW) && !(aflags & FYTTAF_CAN_BE_SIMPLE_KEY) && !is_null_scalar) || - ((aflags & FYTTAF_QUOTE_AT_0) && indent == 0)) + if ((flow && !(ta->flags & FYTTAF_CAN_BE_PLAIN_FLOW) && !(ta->flags & FYTTAF_CAN_BE_SIMPLE_KEY) && !is_null_scalar) || + ((ta->flags & FYTTAF_QUOTE_AT_0) && indent == 0)) + style = FYNS_DOUBLE_QUOTED; + + if (style == FYNS_PLAIN && (emit->column + ta->maxspan) > fy_emit_width(emit)) style = FYNS_DOUBLE_QUOTED; } @@ -1687,7 +1720,8 @@ void fy_emit_mapping(struct fy_emitter *emit, struct fy_node *fyn, int flags, in struct fy_node_pair *fynp, *fynpn, **fynpp = NULL; struct fy_token *fyt_key, *fyt_value; bool last, simple_key, used_malloc = false; - int aflags, i, count; + const struct fy_token_analysis *ta; + int i, count; struct fy_emit_save_ctx sct, *sc = &sct; memset(sc, 0, sizeof(*sc)); @@ -1759,9 +1793,9 @@ void fy_emit_mapping(struct fy_emitter *emit, struct fy_node *fyn, int flags, in if (fynp->key) { switch (fynp->key->type) { case FYNT_SCALAR: - aflags = fy_token_text_analyze(fynp->key->scalar); + ta = fy_token_text_analyze(fynp->key->scalar); simple_key = fy_emit_is_json_mode(emit) || - !!(aflags & FYTTAF_CAN_BE_SIMPLE_KEY); + !!(ta->flags & FYTTAF_CAN_BE_SIMPLE_KEY); break; case FYNT_SEQUENCE: simple_key = fy_node_list_empty(&fynp->key->sequence); @@ -3266,7 +3300,8 @@ static int fy_emit_handle_mapping_key(struct fy_emitter *emit, struct fy_parser struct fy_event *fye = &fyep->e; struct fy_emit_save_ctx *sc = &emit->s_sc; struct fy_token *fyt_key = NULL; - int ret, aflags; + const struct fy_token_analysis *ta; + int ret; bool simple_key; fy_emit_token_unref(emit, fyp, sc->fyt_last_key); @@ -3301,8 +3336,8 @@ static int fy_emit_handle_mapping_key(struct fy_emitter *emit, struct fy_parser break; case FYET_SCALAR: fyt_key = fye->scalar.value; - aflags = fy_token_text_analyze(fyt_key); - simple_key = !!(aflags & FYTTAF_CAN_BE_SIMPLE_KEY); + ta = fy_token_text_analyze(fyt_key); + simple_key = !!(ta->flags & FYTTAF_CAN_BE_SIMPLE_KEY); break; case FYET_SEQUENCE_START: fyt_key = fye->sequence_start.sequence_start; diff --git a/src/lib/fy-emit.h b/src/lib/fy-emit.h index f60dd1d4..f48671d8 100644 --- a/src/lib/fy-emit.h +++ b/src/lib/fy-emit.h @@ -153,4 +153,10 @@ fy_emit_output_accum(struct fy_emitter *emit, enum fy_emitter_write_type type, s fy_emit_accum_reset(ea); } +static inline void +fy_emit_output_col_sync(struct fy_emitter *emit, struct fy_emit_accum *ea) +{ + ea->col += emit->column; +} + #endif diff --git a/src/lib/fy-token.c b/src/lib/fy-token.c index 5976c7c8..6dd1b9bb 100644 --- a/src/lib/fy-token.c +++ b/src/lib/fy-token.c @@ -117,7 +117,7 @@ void fy_token_clean_rl(struct fy_token_list *fytl, struct fy_token *fyt) } fyt->type = FYTT_NONE; - fyt->analyze_flags = 0; + memset(&fyt->analysis, 0, sizeof(fyt->analysis)); fyt->text_len = 0; fyt->text = NULL; } @@ -641,20 +641,27 @@ const struct fy_mark *fy_token_end_mark(struct fy_token *fyt) return NULL; } -int fy_token_text_analyze(struct fy_token *fyt) +const struct fy_token_analysis * +fy_token_text_analyze(struct fy_token *fyt) { + static const struct fy_token_analysis null_analysis = { + .flags = FYTTAF_CAN_BE_SIMPLE_KEY | FYTTAF_DIRECT_OUTPUT | + FYTTAF_EMPTY | FYTTAF_CAN_BE_DOUBLE_QUOTED | + FYTTAF_ANALYZED, + .maxspan = 0, + .maxcol = 0, + }; struct fy_atom_iter iter; enum fy_atom_style style; int c, cn, cnn, cp, col; uint8_t col0si, col0ei; /* mask for --- ... at indent 0 */ - int flags; + int flags, span, maxspan, maxcol; if (!fyt) - return FYTTAF_CAN_BE_SIMPLE_KEY | FYTTAF_DIRECT_OUTPUT | - FYTTAF_EMPTY | FYTTAF_CAN_BE_DOUBLE_QUOTED; + return &null_analysis; - if (fyt->analyze_flags) - return fyt->analyze_flags; + if (fyt->analysis.flags & FYTTAF_ANALYZED) + return &fyt->analysis; /* only tokens that can generate text */ if (fyt->type != FYTT_SCALAR && @@ -662,8 +669,12 @@ int fy_token_text_analyze(struct fy_token *fyt) fyt->type != FYTT_ANCHOR && fyt->type != FYTT_ALIAS) { flags = FYTTAF_NO_TEXT_TOKEN; - fyt->analyze_flags = flags; - return flags; + + fyt->analysis.flags = flags | FYTTAF_ANALYZED; + fyt->analysis.maxspan = 0; + fyt->analysis.maxcol = 0; + + return &fyt->analysis; } flags = FYTTAF_TEXT_TOKEN; @@ -681,6 +692,9 @@ int fy_token_text_analyze(struct fy_token *fyt) fy_atom_iter_start(&fyt->handle, &iter); col = 0; + maxcol = 0; + maxspan = 0; + span = 0; /* get first character */ cn = fy_atom_iter_utf8_get(&iter); @@ -805,7 +819,16 @@ int fy_token_text_analyze(struct fy_token *fyt) (style == FYAS_DOUBLE_QUOTED && c == '\\'))) flags &= ~FYTTAF_DIRECT_OUTPUT; + if (cn < 0 || !c || fy_token_is_lb(fyt, c) || fy_is_ws(c)) { + if (span > maxspan) + maxspan = span; + span = 0; + } else + span++; + if (fy_token_is_lb(fyt, c)) { + if (col > maxcol) + maxcol = col; col = 0; col0si = col0ei = 0; } else @@ -822,10 +845,18 @@ int fy_token_text_analyze(struct fy_token *fyt) FYTTAF_CAN_BE_PLAIN_FLOW); } } + + if (col > maxcol) + maxcol = col; + if (span > maxspan) + maxspan = span; out: fy_atom_iter_finish(&iter); - fyt->analyze_flags = flags; - return flags; + + fyt->analysis.flags = flags | FYTTAF_ANALYZED; + fyt->analysis.maxspan = maxspan; + fyt->analysis.maxcol = maxcol; + return &fyt->analysis; } const char *fy_tag_token_get_directive_handle(struct fy_token *fyt, size_t *td_handle_sizep) @@ -1189,7 +1220,7 @@ const char *fy_token_get_scalar_path_key(struct fy_token *fyt, size_t *lenp) uint8_t non_utf8[4]; size_t non_utf8_len, k; int c, i, w, digit; - int aflags; + const struct fy_token_analysis *ta; if (!fyt || fyt->type != FYTT_SCALAR) { *lenp = 0; @@ -1203,10 +1234,10 @@ const char *fy_token_get_scalar_path_key(struct fy_token *fyt, size_t *lenp) } /* analyze the token */ - aflags = fy_token_text_analyze(fyt); + ta = fy_token_text_analyze(fyt); /* simple one? perfect */ - if ((aflags & FYTTAF_CAN_BE_UNQUOTED_PATH_KEY) == FYTTAF_CAN_BE_UNQUOTED_PATH_KEY) { + if ((ta->flags & FYTTAF_CAN_BE_UNQUOTED_PATH_KEY) == FYTTAF_CAN_BE_UNQUOTED_PATH_KEY) { fyt->scalar.path_key = fy_token_get_text(fyt, &fyt->scalar.path_key_len); *lenp = fyt->scalar.path_key_len; return fyt->scalar.path_key; diff --git a/src/lib/fy-token.h b/src/lib/fy-token.h index 8ab84620..6ce3070f 100644 --- a/src/lib/fy-token.h +++ b/src/lib/fy-token.h @@ -79,12 +79,43 @@ static inline bool fy_token_type_is_mapping_marker(enum fy_token_type type) #define FYACF_VALID_ANCHOR 0x040000 /* contains valid anchor (without & prefix) */ #define FYACF_JSON_ESCAPE 0x080000 /* contains a character that JSON escapes */ +/* analysis flags */ +#define FYTTAF_HAS_LB FY_BIT(0) +#define FYTTAF_HAS_WS FY_BIT(1) +#define FYTTAF_HAS_CONSECUTIVE_LB FY_BIT(2) +#define FYTTAF_HAS_CONSECUTIVE_WS FY_BIT(4) +#define FYTTAF_EMPTY FY_BIT(5) +#define FYTTAF_CAN_BE_SIMPLE_KEY FY_BIT(6) +#define FYTTAF_DIRECT_OUTPUT FY_BIT(7) +#define FYTTAF_NO_TEXT_TOKEN FY_BIT(8) +#define FYTTAF_TEXT_TOKEN FY_BIT(9) +#define FYTTAF_CAN_BE_PLAIN FY_BIT(10) +#define FYTTAF_CAN_BE_SINGLE_QUOTED FY_BIT(11) +#define FYTTAF_CAN_BE_DOUBLE_QUOTED FY_BIT(12) +#define FYTTAF_CAN_BE_LITERAL FY_BIT(13) +#define FYTTAF_CAN_BE_FOLDED FY_BIT(14) +#define FYTTAF_CAN_BE_PLAIN_FLOW FY_BIT(15) +#define FYTTAF_QUOTE_AT_0 FY_BIT(16) +#define FYTTAF_CAN_BE_UNQUOTED_PATH_KEY FY_BIT(17) +#define FYTTAF_HAS_ANY_LB FY_BIT(18) /* any LB including unicode, not per input */ +#define FYTTAF_HAS_START_IND FY_BIT(19) /* has --- at col 0 */ +#define FYTTAF_HAS_END_IND FY_BIT(20) /* has ... at col 0 */ +#define FYTTAF_HAS_NON_PRINT FY_BIT(21) /* has any non printable utf8 */ + +#define FYTTAF_ANALYZED FY_BIT(31) /* analyzed mark */ + +struct fy_token_analysis { + int flags; + int maxspan; + int maxcol; +}; + FY_TYPE_FWD_DECL_LIST(token); struct fy_token { struct list_head node; enum fy_token_type type; int refs; /* when on document, we switch to reference counting */ - int analyze_flags; /* cache of the analysis flags */ + struct fy_token_analysis analysis; size_t text_len; const char *text; char *text0; /* this is allocated */ @@ -168,8 +199,7 @@ fy_token_alloc_rl(struct fy_token_list *fytl) fyt->type = FYTT_NONE; fyt->refs = 1; - - fyt->analyze_flags = 0; + memset(&fyt->analysis, 0, sizeof(fyt->analysis)); fyt->text_len = 0; fyt->text = NULL; fyt->text0 = NULL; @@ -425,29 +455,7 @@ static inline bool fy_token_is_flow_ws(struct fy_token *fyt, int c) return fy_atom_is_flow_ws(&fyt->handle, c); } -#define FYTTAF_HAS_LB FY_BIT(0) -#define FYTTAF_HAS_WS FY_BIT(1) -#define FYTTAF_HAS_CONSECUTIVE_LB FY_BIT(2) -#define FYTTAF_HAS_CONSECUTIVE_WS FY_BIT(4) -#define FYTTAF_EMPTY FY_BIT(5) -#define FYTTAF_CAN_BE_SIMPLE_KEY FY_BIT(6) -#define FYTTAF_DIRECT_OUTPUT FY_BIT(7) -#define FYTTAF_NO_TEXT_TOKEN FY_BIT(8) -#define FYTTAF_TEXT_TOKEN FY_BIT(9) -#define FYTTAF_CAN_BE_PLAIN FY_BIT(10) -#define FYTTAF_CAN_BE_SINGLE_QUOTED FY_BIT(11) -#define FYTTAF_CAN_BE_DOUBLE_QUOTED FY_BIT(12) -#define FYTTAF_CAN_BE_LITERAL FY_BIT(13) -#define FYTTAF_CAN_BE_FOLDED FY_BIT(14) -#define FYTTAF_CAN_BE_PLAIN_FLOW FY_BIT(15) -#define FYTTAF_QUOTE_AT_0 FY_BIT(16) -#define FYTTAF_CAN_BE_UNQUOTED_PATH_KEY FY_BIT(17) -#define FYTTAF_HAS_ANY_LB FY_BIT(18) /* any LB including unicode, not per input */ -#define FYTTAF_HAS_START_IND FY_BIT(19) /* has --- at col 0 */ -#define FYTTAF_HAS_END_IND FY_BIT(20) /* has ... at col 0 */ -#define FYTTAF_HAS_NON_PRINT FY_BIT(21) /* has any non printable utf8 */ - -int fy_token_text_analyze(struct fy_token *fyt); +const struct fy_token_analysis *fy_token_text_analyze(struct fy_token *fyt); unsigned int fy_analyze_scalar_content(const char *data, size_t size, bool json_mode, enum fy_lb_mode lb_mode, enum fy_flow_ws_mode fws_mode);