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
9 return strcmp(capreq_name(cr1), capreq_name(cr2));
14 int capreq_cmp2name(struct capreq *cr1, const char *name)
16 return strcmp(capreq_name(cr1), name);
19 int capreq_arr_find(tn_array *capreqs, const char *name)
21 + /* capreq_cmp2name is compilant with capreq_cmp_name_evr */
22 + if (!n_array_is_sorted(capreqs))
23 + n_array_sort(capreqs);
25 return n_array_bsearch_idx_ex(capreqs, name,
26 (tn_fn_cmp)capreq_cmp2name);
30 +int capreq_arr_contains(tn_array *capreqs, const char *name)
32 + if (!n_array_is_sorted(capreqs))
33 + n_array_sort(capreqs); /* capreq_cmp2name */
35 + return n_array_bsearch_idx_ex(capreqs, name,
36 + (tn_fn_cmp)capreq_cmp2name) > -1;
40 tn_buf *capreq_arr_join(tn_array *capreqs, tn_buf *nbuf, const char *sep)
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
50 int capreq_strcmp_name_evr(struct capreq *pr1, struct capreq *pr2);
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);
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);
63 int capreq_arr_store_n(tn_array *arr);
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
80 ===================================================================
81 RCS file: /cvsroot/poldek/poldek/pkg.c,v
82 retrieving revision 1.115
84 --- pkg.c 21 Jun 2007 16:47:45 -0000 1.115
85 +++ pkg.c 29 Jun 2007 20:10:23 -0000
87 struct capreq *cnfl = NULL;
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,
95 (isbastard ? CAPREQ_BASTARD : 0));
98 int pkg_has_pkgcnfl(struct pkg *pkg, struct pkg *cpkg)
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);
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
115 const char **tl, **tl_save;
117 - int vlen, n = 0, nadded = 0;
118 + int vlen, n = 0, nadded = 0, created_here = 0;
120 n_assert(key[1] == PREFIX_PKGKEY_REQDIR);
122 @@ -513,15 +513,15 @@
128 pkg->reqs = capreq_arr_new(n);
134 const char *dir = *tl;
136 - if (*dir && !n_array_bsearch_ex(pkg->reqs, dir,
137 - (tn_fn_cmp)capreq_cmp2name)) {
139 + if (*dir && (created_here || !capreq_arr_contains(pkg->reqs, dir))) {
140 struct capreq *req = capreq_new(pkg->na, dir, 0, NULL, NULL, 0,
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
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)
155 +#define n_array_is_sorted(arr) ((arr)->flags & TN_ARRAY_INTERNAL_ISSORTED)
157 tn_array *n_array_grow_priv_(tn_array *arr, size_t req_size);
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
167 cmpf = autosort(arr, cmpf, &set_sorted);
169 - if ((arr->flags & TN_ARRAY_AUTOSORTED) && TN_ARRAY_is_sorted(arr))
170 + if ((arr->flags & TN_ARRAY_AUTOSORTED) && n_array_is_sorted(arr))