From 79cbceb68361263a035efec1bf31f67688387f33 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 21 Aug 2025 16:48:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20`chef=5Fverify=5Fcontribut?= =?UTF-8?q?or()`=20=E4=BB=A5=E5=8F=8A=20=E9=87=8D=E5=86=99=20`chef=5Fset?= =?UTF-8?q?=5Fchef()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/chef.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/framework/chef.c b/src/framework/chef.c index 66dd96f..591e84b 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -231,15 +231,33 @@ chef_set_authors (Target_t *target, size_t count, ...) } -void -chef_set_chef (Target_t *target, char *name, char *email) +/** + * @brief 验证该 `id` 所指的贡献者确有其人 + */ +Contributor_t * +chef_verify_contributor (const char *id) { - if (!target || !name || !email) - return; + xy_cant_be_null (id); - target->chef = xy_malloc0 (sizeof(Contributor_t)); - target->chef->name = xy_strdup (name); - target->chef->email = xy_strdup (email); + Contributor_t *c = xy_map_get (ProgStatus.contributors, id); + if (!c) + { + char error[256]; + snprintf (error, sizeof (error), "贡献者不存在: %s", id); + chsrc_panic (error); + } + return c; +} + + +void +chef_set_chef (Target_t *target, const char *id) +{ + xy_cant_be_null (target); + + Contributor_t *c = chef_verify_contributor (id); + + target->chef = c; }