Skip to content

Commit c609a10

Browse files
committed
删除 authors 字段,将其由 cooks 代替
1 parent 79cbceb commit c609a10

File tree

2 files changed

+53
-86
lines changed

2 files changed

+53
-86
lines changed

src/framework/chef.c

Lines changed: 47 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ chef_set_sources_speed_measure_url_with_func (
7575
char *(*func)(const char *url, const char *user_data),
7676
char *user_data)
7777
{
78+
xy_cant_be_null (target);
79+
7880
Source_t *sources = target->sources;
7981
int n = target->sources_n;
82+
8083
for (int i=0; i<n; i++)
8184
{
8285
Source_t *src = &sources[i];
@@ -106,27 +109,22 @@ chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix
106109
void
107110
chef_allow_english (Target_t *target)
108111
{
109-
if (!target)
110-
return;
111-
112+
xy_cant_be_null (target);
112113
target->can_english = true;
113114
}
114115

115116
void
116117
chef_forbid_english (Target_t *target)
117118
{
118-
if (!target)
119-
return;
120-
119+
xy_cant_be_null (target);
121120
target->can_english = false;
122121
}
123122

124123

125124
void
126125
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
127126
{
128-
if (!target)
129-
return;
127+
xy_cant_be_null (target);
130128

131129
target->cap_local = cap;
132130

@@ -149,8 +147,7 @@ chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_z
149147
void
150148
chef_allow_user_define (Target_t *target)
151149
{
152-
if (!target)
153-
return;
150+
xy_cant_be_null (target);
154151

155152
target->can_user_define = true;
156153
target->can_user_define_explain = NULL;
@@ -159,8 +156,7 @@ chef_allow_user_define (Target_t *target)
159156
void
160157
chef_forbid_user_define (Target_t *target)
161158
{
162-
if (!target)
163-
return;
159+
xy_cant_be_null (target);
164160

165161
target->can_user_define = false;
166162

@@ -173,63 +169,15 @@ chef_forbid_user_define (Target_t *target)
173169
void
174170
chef_set_note (Target_t *target, const char *note_zh, const char *note_en)
175171
{
176-
if (!target)
177-
return;
172+
xy_cant_be_null (target);
178173

179174
const char *msg = CHINESE ? note_zh : note_en;
180175

181176
if (msg)
182-
target->note = xy_strdup(msg);
183-
}
184-
185-
186-
void
187-
chef_set_contributors (Target_t *target, uint32_t count, ...)
188-
{
189-
if (!target || count==0)
190-
return;
191-
192-
target->contributors_n = count;
193-
target->contributors = xy_malloc0 (count * sizeof(Contributor_t));
194-
195-
va_list args;
196-
va_start(args, count);
197-
198-
for (uint32_t i = 0; i < count; i++)
199-
{
200-
char *name = va_arg(args, char*);
201-
char *email = va_arg(args, char*);
202-
203-
target->contributors[i].name = xy_strdup (name);
204-
target->contributors[i].email = xy_strdup (email);
205-
}
177+
target->note = xy_strdup (msg);
206178
}
207179

208180

209-
void
210-
chef_set_authors (Target_t *target, size_t count, ...)
211-
{
212-
if (!target || count == 0)
213-
return;
214-
215-
va_list args;
216-
va_start(args, count);
217-
218-
target->authors = xy_malloc0 (count * sizeof(Contributor_t));
219-
target->authors_n = count;
220-
221-
for (size_t i = 0; i < count; i++)
222-
{
223-
char *name = va_arg(args, char*);
224-
char *email = va_arg(args, char*);
225-
226-
target->authors[i].name = xy_strdup(name);
227-
target->authors[i].email = xy_strdup(email);
228-
}
229-
230-
va_end(args);
231-
}
232-
233181

234182
/**
235183
* @brief 验证该 `id` 所指的贡献者确有其人
@@ -264,8 +212,7 @@ chef_set_chef (Target_t *target, const char *id)
264212
void
265213
chef_set_cooks (Target_t *target, size_t count, ...)
266214
{
267-
if (!target)
268-
return;
215+
xy_cant_be_null (target);
269216

270217
if (count == 0)
271218
{
@@ -275,29 +222,52 @@ chef_set_cooks (Target_t *target, size_t count, ...)
275222
}
276223

277224
va_list args;
278-
va_start(args, count);
225+
va_start (args, count);
279226

280-
target->cooks = xy_malloc0 (count * sizeof(Contributor_t));
227+
target->cooks = xy_malloc0 (count * sizeof (Contributor_t*));
281228
target->cooks_n = count;
282229

283230
for (size_t i = 0; i < count; i++)
284231
{
285-
char *name = va_arg(args, char*);
286-
char *email = va_arg(args, char*);
232+
char *id = va_arg (args, char*);
233+
target->cooks[i] = chef_verify_contributor (id);
234+
}
235+
236+
va_end (args);
237+
}
238+
239+
void
240+
chef_set_contributors (Target_t *target, uint32_t count, ...)
241+
{
242+
xy_cant_be_null (target);
287243

288-
target->cooks[i].name = xy_strdup(name);
289-
target->cooks[i].email = xy_strdup(email);
244+
if (count == 0)
245+
{
246+
target->contributors = NULL;
247+
target->contributors_n = 0;
248+
return;
290249
}
291250

292-
va_end(args);
251+
va_list args;
252+
va_start (args, count);
253+
254+
target->contributors = xy_malloc0 (count * sizeof (Contributor_t*));
255+
target->contributors_n = count;
256+
257+
for (uint32_t i = 0; i < count; i++)
258+
{
259+
char *id = va_arg (args, char*);
260+
target->contributors[i] = chef_verify_contributor (id);
261+
}
293262
}
294263

295264

265+
296266
void
297267
chef_set_created_on (Target_t *target, char *date)
298268
{
299-
if (!target)
300-
return;
269+
xy_cant_be_null (target);
270+
xy_cant_be_null (date);
301271

302272
target->created_on = xy_strdup (date);
303273
}
@@ -306,8 +276,8 @@ chef_set_created_on (Target_t *target, char *date)
306276
void
307277
chef_set_last_updated (Target_t *target, char *date)
308278
{
309-
if (!target)
310-
return;
279+
xy_cant_be_null (target);
280+
xy_cant_be_null (date);
311281

312282
target->last_updated = xy_strdup (date);
313283
}
@@ -316,8 +286,8 @@ chef_set_last_updated (Target_t *target, char *date)
316286
void
317287
chef_set_sources_last_updated (Target_t *target, char *date)
318288
{
319-
if (!target)
320-
return;
289+
xy_cant_be_null (target);
290+
xy_cant_be_null (date);
321291

322292
target->sources_last_updated = xy_strdup (date);
323293
}

src/framework/struct.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,17 @@ typedef struct Target_t
142142
char *note; /* 备注 */
143143

144144

145-
/* Recipe maintain info */
145+
/* recipe 维护信息 */
146146
char *created_on;
147147
char *last_updated;
148148
char *sources_last_updated;
149149

150-
Contributor_t *authors;
151-
size_t authors_n;
150+
Contributor_t *chef; /* 该 recipe 的负责人 */
151+
Contributor_t **cooks; /* 该 recipe 的核心作者 */
152+
size_t cooks_n;
152153

153-
Contributor_t *contributors;
154-
size_t contributors_n;
155-
156-
Contributor_t *chef; /* Chef 仅有一个 */
157-
Contributor_t *cooks; /* Cook 可以有多个 */
158-
size_t cooks_n;
154+
Contributor_t **contributors; /* 该 recipe 的所有贡献者(除核心作者外的其他人) */
155+
size_t contributors_n;
159156
}
160157
Target_t;
161158

0 commit comments

Comments
 (0)