From fc7314e081841f94da0978e2963a7f7ee240a015 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 14 Dec 2022 03:08:51 +0200 Subject: [PATCH 21/21] Introduce req_copy() and universal_copy() See osdn #45020 Signed-off-by: Marko Lindqvist --- common/requirements.c | 23 ++++++++++++++++++++++- common/requirements.h | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/common/requirements.c b/common/requirements.c index 14e195741e..3e09d5eb1e 100644 --- a/common/requirements.c +++ b/common/requirements.c @@ -755,6 +755,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(). @@ -1225,7 +1234,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, @@ -1259,6 +1268,18 @@ 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->present = src->present; + 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 cdd834a292..d757cc292d 100644 --- a/common/requirements.h +++ b/common/requirements.h @@ -143,6 +143,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); @@ -300,6 +302,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