Debian Codegraph @

debian/patches/compile-reproducibility

raw
1 commit 98321c9d281843bf62fd59c9872d2ee2e486f98e
2 Author: Samuel Thibault <[email protected]>
3 Date: Sun Dec 15 14:09:02 2024 +0100
4
5 compiledict: make rgroup_sorter not depend on allocator
6
7 To get reproducibility, we should not depend on the memory
8 allocator-provided pointer values. We can instead just use the group
9 creation order.
10
11 diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c
12 index 9304f4e1..7fb1fb79 100644
13 --- a/src/libespeak-ng/compiledict.c
14 +++ b/src/libespeak-ng/compiledict.c
15 @@ -148,6 +148,7 @@ typedef struct {
16 void *start;
17 size_t length;
18 int group3_ix;
19 + int index;
20 } RGROUP;
21
22 typedef enum
23 @@ -1191,7 +1192,7 @@ static int __cdecl rgroup_sorter(RGROUP *a, RGROUP *b)
24 if (ix != 0) return ix;
25 ix = strcmp(a->name, b->name);
26 if (ix != 0) return ix;
27 - return (uintptr_t)a->start - (uintptr_t)b->start;
28 + return a->index - b->index;
29 }
30
31 static void* output_rule_group(int n_rules, char **rules, char *name, size_t *outsize)
32 @@ -1375,6 +1376,7 @@ static espeak_ng_STATUS compile_dictrules(CompileContext *ctx, FILE *f_in, FILE
33 strcpy(rgroup[n_rgroups].name, ctx->group_name);
34 rgroup[n_rgroups].group3_ix = ctx->group3_ix;
35 rgroup[n_rgroups].start = output_rule_group(n_rules, rules, ctx->group_name, &rgroup[n_rgroups].length);
36 + rgroup[n_rgroups].index = n_rgroups;
37 n_rgroups++;
38
39 count += n_rules;