]>
Commit | Line | Data |
---|---|---|
78774d3a | 1 | Index: capreq.c |
2 | =================================================================== | |
3 | RCS file: /cvsroot/poldek/poldek/capreq.c,v | |
4 | retrieving revision 1.44 | |
5 | diff -u -r1.44 capreq.c | |
6 | --- capreq.c 21 Jun 2007 16:47:45 -0000 1.44 | |
7 | +++ capreq.c 29 Jun 2007 20:10:22 -0000 | |
8 | @@ -59,7 +59,7 @@ | |
9 | return strcmp(capreq_name(cr1), capreq_name(cr2)); | |
10 | } | |
11 | ||
12 | -__inline__ | |
13 | +__inline__ static | |
14 | int capreq_cmp2name(struct capreq *cr1, const char *name) | |
15 | { | |
16 | return strcmp(capreq_name(cr1), name); | |
17 | @@ -427,9 +427,24 @@ | |
18 | __inline__ | |
19 | int capreq_arr_find(tn_array *capreqs, const char *name) | |
20 | { | |
21 | + /* capreq_cmp2name is compilant with capreq_cmp_name_evr */ | |
22 | + if (!n_array_is_sorted(capreqs)) | |
23 | + n_array_sort(capreqs); | |
24 | + | |
25 | return n_array_bsearch_idx_ex(capreqs, name, | |
26 | (tn_fn_cmp)capreq_cmp2name); | |
27 | } | |
28 | + | |
29 | +__inline__ | |
30 | +int capreq_arr_contains(tn_array *capreqs, const char *name) | |
31 | +{ | |
32 | + if (!n_array_is_sorted(capreqs)) | |
33 | + n_array_sort(capreqs); /* capreq_cmp2name */ | |
34 | + | |
35 | + return n_array_bsearch_idx_ex(capreqs, name, | |
36 | + (tn_fn_cmp)capreq_cmp2name) > -1; | |
37 | +} | |
38 | + | |
39 | ||
40 | tn_buf *capreq_arr_join(tn_array *capreqs, tn_buf *nbuf, const char *sep) | |
41 | { | |
42 | Index: capreq.h | |
43 | =================================================================== | |
44 | RCS file: /cvsroot/poldek/poldek/capreq.h,v | |
45 | retrieving revision 1.30 | |
46 | diff -u -r1.30 capreq.h | |
47 | --- capreq.h 21 Jun 2007 22:29:49 -0000 1.30 | |
48 | +++ capreq.h 29 Jun 2007 20:10:22 -0000 | |
49 | @@ -117,12 +117,12 @@ | |
50 | int capreq_strcmp_name_evr(struct capreq *pr1, struct capreq *pr2); | |
51 | ||
52 | int capreq_cmp_name(struct capreq *cr1, struct capreq *cr2); | |
53 | -int capreq_cmp2name(struct capreq *pr1, const char *name); | |
54 | int capreq_cmp_name_evr(struct capreq *cr1, struct capreq *cr2); | |
55 | ||
56 | #ifndef SWIG | |
57 | tn_array *capreq_arr_new(int size); | |
58 | -int capreq_arr_find(tn_array *capreqs, const char *name); | |
59 | +int capreq_arr_find(tn_array *capreqs, const char *name); /* returns index */ | |
60 | +int capreq_arr_contains(tn_array *capreqs, const char *name); /* returns bool */ | |
61 | tn_buf *capreq_arr_join(tn_array *capreqs, tn_buf *nbuf, const char *sep); | |
62 | ||
63 | int capreq_arr_store_n(tn_array *arr); | |
64 | Index: libpoldek.sym | |
65 | =================================================================== | |
66 | RCS file: /cvsroot/poldek/poldek/libpoldek.sym,v | |
67 | retrieving revision 1.28 | |
68 | diff -u -r1.28 libpoldek.sym | |
69 | --- libpoldek.sym 28 Jun 2007 22:28:21 -0000 1.28 | |
70 | +++ libpoldek.sym 29 Jun 2007 20:10:22 -0000 | |
71 | @@ -20,7 +20,6 @@ | |
72 | capreq_arr_store | |
73 | capreq_arr_store_n | |
74 | capreq_clone | |
75 | -capreq_cmp2name | |
76 | capreq_cmp_name | |
77 | capreq_cmp_name_evr | |
78 | capreq_epoch_ | |
79 | Index: pkg.c | |
80 | =================================================================== | |
81 | RCS file: /cvsroot/poldek/poldek/pkg.c,v | |
82 | retrieving revision 1.115 | |
83 | diff -u -r1.115 pkg.c | |
84 | --- pkg.c 21 Jun 2007 16:47:45 -0000 1.115 | |
85 | +++ pkg.c 29 Jun 2007 20:10:23 -0000 | |
86 | @@ -920,8 +920,7 @@ | |
87 | struct capreq *cnfl = NULL; | |
88 | ||
89 | DBGF("%s %s%s", pkg_id(pkg), pkg_id(cpkg), isbastard ? " (bastard)" : ""); | |
90 | - if (n_array_bsearch_ex(pkg->cnfls, cpkg->name, | |
91 | - (tn_fn_cmp)capreq_cmp2name) == NULL) { | |
92 | + if (!capreq_arr_contains(pkg->cnfls, cpkg->name)) { | |
93 | cnfl = capreq_new(pkg->na, cpkg->name, cpkg->epoch, cpkg->ver, | |
94 | cpkg->rel, REL_EQ, | |
95 | (isbastard ? CAPREQ_BASTARD : 0)); | |
96 | @@ -935,8 +934,7 @@ | |
97 | ||
98 | int pkg_has_pkgcnfl(struct pkg *pkg, struct pkg *cpkg) | |
99 | { | |
100 | - return pkg->cnfls && (n_array_bsearch_ex(pkg->cnfls, cpkg->name, | |
101 | - (tn_fn_cmp)capreq_cmp2name)); | |
102 | + return pkg->cnfls && capreq_arr_contains(pkg->cnfls, cpkg->name); | |
103 | } | |
104 | ||
105 | struct pkguinf *pkg_xuinf(const struct pkg *pkg, tn_array *langs) | |
106 | Index: pkgdir/pkgdir_dirindex.c | |
107 | =================================================================== | |
108 | RCS file: /cvsroot/poldek/poldek/pkgdir/pkgdir_dirindex.c,v | |
109 | retrieving revision 1.13 | |
110 | diff -u -r1.13 pkgdir_dirindex.c | |
111 | --- pkgdir/pkgdir_dirindex.c 24 Jun 2007 22:47:27 -0000 1.13 | |
112 | +++ pkgdir/pkgdir_dirindex.c 29 Jun 2007 20:10:23 -0000 | |
113 | @@ -505,7 +505,7 @@ | |
114 | { | |
115 | const char **tl, **tl_save; | |
116 | char val[16 * 1024]; | |
117 | - int vlen, n = 0, nadded = 0; | |
118 | + int vlen, n = 0, nadded = 0, created_here = 0; | |
119 | ||
120 | n_assert(key[1] == PREFIX_PKGKEY_REQDIR); | |
121 | vlen = sizeof(val); | |
122 | @@ -513,15 +513,15 @@ | |
123 | if (tl == NULL) | |
124 | return 0; | |
125 | ||
126 | - if (!pkg->reqs) | |
127 | + if (!pkg->reqs) { | |
128 | pkg->reqs = capreq_arr_new(n); | |
129 | - | |
130 | + created_here = 1; | |
131 | + } | |
132 | + | |
133 | while (*tl) { | |
134 | const char *dir = *tl; | |
135 | ||
136 | - if (*dir && !n_array_bsearch_ex(pkg->reqs, dir, | |
137 | - (tn_fn_cmp)capreq_cmp2name)) { | |
138 | - | |
139 | + if (*dir && (created_here || !capreq_arr_contains(pkg->reqs, dir))) { | |
140 | struct capreq *req = capreq_new(pkg->na, dir, 0, NULL, NULL, 0, | |
141 | CAPREQ_BASTARD); | |
142 | n_array_push(pkg->reqs, req); | |
143 | ================================================================ | |
144 | Index: trurlib/include/trurl/narray.h | |
145 | diff -u trurlib/include/trurl/narray.h:1.29 trurlib/include/trurl/narray.h:1.30 | |
146 | --- trurlib/include/trurl/narray.h:1.29 Tue Jun 19 23:52:49 2007 | |
147 | +++ trurlib/include/trurl/narray.h Sat Jun 30 09:39:51 2007 | |
148 | @@ -155,7 +155,9 @@ | |
149 | /* internal macros, do not use them */ | |
150 | #define TN_ARRAY_set_sorted(arr) ((arr)->flags |= TN_ARRAY_INTERNAL_ISSORTED) | |
151 | #define TN_ARRAY_clr_sorted(arr) ((arr)->flags &= ~TN_ARRAY_INTERNAL_ISSORTED) | |
152 | -#define TN_ARRAY_is_sorted(arr) ((arr)->flags & TN_ARRAY_INTERNAL_ISSORTED) | |
153 | + | |
154 | + | |
155 | +#define n_array_is_sorted(arr) ((arr)->flags & TN_ARRAY_INTERNAL_ISSORTED) | |
156 | ||
157 | tn_array *n_array_grow_priv_(tn_array *arr, size_t req_size); | |
158 | #ifndef SWIG | |
159 | ||
160 | ================================================================ | |
161 | Index: trurlib/n_array_sorts.c | |
162 | diff -u trurlib/n_array_sorts.c:1.6 trurlib/n_array_sorts.c:1.7 | |
163 | --- trurlib/n_array_sorts.c:1.6 Tue Nov 16 20:01:40 2004 | |
164 | +++ trurlib/n_array_sorts.c Sat Jun 30 09:39:51 2007 | |
165 | @@ -121,7 +121,7 @@ | |
166 | ||
167 | cmpf = autosort(arr, cmpf, &set_sorted); | |
168 | ||
169 | - if ((arr->flags & TN_ARRAY_AUTOSORTED) && TN_ARRAY_is_sorted(arr)) | |
170 | + if ((arr->flags & TN_ARRAY_AUTOSORTED) && n_array_is_sorted(arr)) | |
171 | return arr; | |
172 | ||
173 | switch (alg) { | |
174 |