~alextee/zrythm-cyaml

82824e8e4e311a95c1bf7c1f6485a3c9ece90e9d — Alexandros Theodotou 1 year, 3 months ago 024b340 master
update to 1.4.0
3 files changed, 39 insertions(+), 14 deletions(-)

M .gitignore
M include/cyaml/cyaml.h
M src/load.c
M .gitignore => .gitignore +3 -0
@@ 83,3 83,6 @@ tags

# Valgrind
vgcore.*

# Meson
subprojects

M include/cyaml/cyaml.h => include/cyaml/cyaml.h +4 -0
@@ 570,6 570,10 @@ typedef enum cyaml_cfg_flags {
	 * memory is constrained.
	 */
	CYAML_CFG_NO_ALIAS            = (1 << 5),
	/**
	 * Log any ignored mapping keys at \ref CYAML_LOG_WARNING level.
	 */
	CYAML_CFG_IGNORED_KEY_WARNING = (1 << 6),
} cyaml_cfg_flags_t;

/**

M src/load.c => src/load.c +32 -14
@@ 1334,8 1334,8 @@ static cyaml_err_t cyaml__read_int(
	errno = 0;
	temp = strtoll(value, &end, 0);

	if (end == value || errno == ERANGE ||
	    temp < min || temp > max) {
	if (end == value || end == NULL || *end != '\0' ||
	    errno == ERANGE || temp < min || temp > max) {
		cyaml__log(ctx->config, CYAML_LOG_ERROR,
				"Load: Invalid INT value: '%s'\n",
				value);


@@ 1364,7 1364,7 @@ static inline cyaml_err_t cyaml__read_uint64_t(
	errno = 0;
	temp = strtoull(value, &end, 0);

	if (end == value || errno == ERANGE) {
	if (end == value || end == NULL || *end != '\0' || errno == ERANGE) {
		cyaml__log(ctx->config, CYAML_LOG_ERROR,
				"Load: Invalid uint64_t value: '%s'\n",
				value);


@@ 1512,7 1512,7 @@ static cyaml_err_t cyaml__read_float_f(
	errno = 0;
	temp = strtof(value, &end);

	if (end == value) {
	if (end == value || end == NULL || *end != '\0') {
		cyaml__log(ctx->config, CYAML_LOG_ERROR,
				"Load: Invalid FLOAT value: %s\n", value);
		return CYAML_ERR_INVALID_VALUE;


@@ 1570,7 1570,7 @@ static cyaml_err_t cyaml__read_float_d(
	errno = 0;
	temp = strtod(value, &end);

	if (end == value) {
	if (end == value || end == NULL || *end != '\0') {
		cyaml__log(ctx->config, CYAML_LOG_ERROR,
				"Load: Invalid FLOAT value: %s\n", value);
		return CYAML_ERR_INVALID_VALUE;


@@ 1754,8 1754,8 @@ static cyaml_err_t cyaml__set_flag(
		errno = 0;
		temp = strtoll(value, &end, 0);

		if (!(end == value || errno == ERANGE ||
		      temp < 0 || (uint64_t)temp > max)) {
		if (!(end == value || end == NULL || *end != '\0' ||
		      errno == ERANGE || temp < 0 || (uint64_t)temp > max)) {
			*flags_out |= ((uint64_t)temp);
			return CYAML_OK;
		}


@@ 2237,6 2237,22 @@ static cyaml_err_t cyaml__doc_end(
}

/**
 * Log an ignored mapping key.
 *
 * \param[in]  ctx  The CYAML loading context.
 * \param[in]  key  The key that has been ignored.
 */
static inline void cyaml__log_ignored_key(
		const cyaml_ctx_t *ctx,
		const char *key)
{
	cyaml_log_t lvl = ctx->config->flags & CYAML_CFG_IGNORED_KEY_WARNING ?
			CYAML_LOG_WARNING : CYAML_LOG_DEBUG;

	cyaml__log(ctx->config, lvl, "Load: Ignoring value for key: %s\n", key);
}

/**
 * Check the field against the schema for the current mapping key.
 *
 * \param[in]  ctx  The CYAML loading context.


@@ 2256,6 2272,8 @@ static cyaml_err_t cyaml__map_key_check_field(
					field->key);
			return CYAML_ERR_UNEXPECTED_EVENT;
		}
	} else {
		cyaml__log_ignored_key(ctx, field->key);
	}

	cyaml__mapping_bitfieid_set(ctx);


@@ 2286,21 2304,21 @@ static cyaml_err_t cyaml__map_key(
	if (ctx->state->mapping.fields_idx == CYAML_FIELDS_IDX_NONE) {
		const yaml_event_t *const ignore_event =
				cyaml__current_event(ctx);
		cyaml_event_t cyaml_event;
		if (!(ctx->config->flags &
				CYAML_CFG_IGNORE_UNKNOWN_KEYS)) {
		if (!(ctx->config->flags & CYAML_CFG_IGNORE_UNKNOWN_KEYS)) {
			cyaml__log(ctx->config, CYAML_LOG_ERROR,
					"Load: Unexpected key: %s\n", key);
			return CYAML_ERR_INVALID_KEY;
		}
		cyaml__log(ctx->config, CYAML_LOG_DEBUG,
				"Load: Ignoring key: %s\n", key);

		cyaml__log_ignored_key(ctx, key);

		err = cyaml_get_next_event(ctx);
		if (err != CYAML_OK) {
			return err;
		}
		cyaml_event = cyaml__get_event_type(ignore_event);
		return cyaml__consume_ignored_value(ctx, cyaml_event);

		return cyaml__consume_ignored_value(ctx,
				cyaml__get_event_type(ignore_event));
	}

	err = cyaml__map_key_check_field(ctx);