From 9f643bebe2b28aba524d86c07e657e8a9020d69b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 16 Jul 2022 00:52:17 +0300 Subject: [PATCH 39/39] Introduce req_copy() and universal_copy() See osdn #45020 Signed-off-by: Marko Lindqvist --- common/requirements.c | 22 +++++++++++++++++++++- common/requirements.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/requirements.c b/common/requirements.c index 103a041a7f..a8b9d6c70f 100644 --- a/common/requirements.c +++ b/common/requirements.c @@ -613,6 +613,15 @@ struct universal universal_by_number(const enum universals_n kind, return source; } +/**********************************************************************//** + Fill in copy of universal +**************************************************************************/ +void universal_copy(struct universal *dst, const struct universal *src) +{ + dst->value = src->value; + dst->kind = src->kind; +} + /**********************************************************************//** Extract universal structure into its components for serialization; the opposite of universal_by_number(). @@ -1108,7 +1117,7 @@ struct requirement req_from_str(const char *type, const char *range, } /**********************************************************************//** - Set the values of a req from serializable integers. This is the opposite + Set the values of a req from serializable integers. This is the opposite of req_get_values. **************************************************************************/ struct requirement req_from_values(int type, int range, @@ -1142,6 +1151,17 @@ void req_get_values(const struct requirement *req, *quiet = req->quiet; } +/**********************************************************************//** + Fill in copy of the requirement. +**************************************************************************/ +void req_copy(struct requirement *dst, const struct requirement *src) +{ + universal_copy(&(dst->source), &(src->source)); + dst->range = src->range; + dst->survives = src->survives; + dst->quiet = src->quiet; +} + /**********************************************************************//** Returns TRUE if req1 and req2 are equal. Does not care if one is quiet and the other not. diff --git a/common/requirements.h b/common/requirements.h index c395fa6c11..d22954a25e 100644 --- a/common/requirements.h +++ b/common/requirements.h @@ -123,6 +123,8 @@ struct requirement req_from_values(int type, int range, bool survives, bool present, bool quiet, int value); +void req_copy(struct requirement *dst, const struct requirement *src); + bool are_requirements_equal(const struct requirement *req1, const struct requirement *req2); @@ -273,6 +275,7 @@ struct universal universal_by_number(const enum universals_n kind, struct universal universal_by_rule_name(const char *kind, const char *value); void universal_value_from_str(struct universal *source, const char *value); +void universal_copy(struct universal *dst, const struct universal *src); void universal_extraction(const struct universal *source, int *kind, int *value); -- 2.35.1