@@ -100,19 +100,14 @@ xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps,
100100static bool
101101match_string_in_array (xbps_array_t array , const char * str , int mode )
102102{
103- xbps_object_iterator_t iter ;
104- xbps_object_t obj ;
105- const char * pkgdep ;
106103 char pkgname [XBPS_NAME_SIZE ];
107104 bool found = false;
108105
109106 assert (xbps_object_type (array ) == XBPS_TYPE_ARRAY );
110107 assert (str != NULL );
111108
112- iter = xbps_array_iterator (array );
113- assert (iter );
114-
115- while ((obj = xbps_object_iterator_next (iter ))) {
109+ for (unsigned int i = 0 ; i < xbps_array_count (array ); i ++ ) {
110+ xbps_object_t obj = xbps_array_get (array , i );
116111 if (mode == 0 ) {
117112 /* match by string */
118113 if (xbps_string_equals_cstring (obj , str )) {
@@ -121,7 +116,7 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
121116 }
122117 } else if (mode == 1 ) {
123118 /* match by pkgname against pkgver */
124- pkgdep = xbps_string_cstring_nocopy (obj );
119+ const char * pkgdep = xbps_string_cstring_nocopy (obj );
125120 if (!xbps_pkg_name (pkgname , XBPS_NAME_SIZE , pkgdep ))
126121 break ;
127122 if (strcmp (pkgname , str ) == 0 ) {
@@ -130,7 +125,7 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
130125 }
131126 } else if (mode == 2 ) {
132127 /* match by pkgver against pkgname */
133- pkgdep = xbps_string_cstring_nocopy (obj );
128+ const char * pkgdep = xbps_string_cstring_nocopy (obj );
134129 if (!xbps_pkg_name (pkgname , XBPS_NAME_SIZE , str ))
135130 break ;
136131 if (strcmp (pkgname , pkgdep ) == 0 ) {
@@ -139,21 +134,20 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
139134 }
140135 } else if (mode == 3 ) {
141136 /* match pkgpattern against pkgdep */
142- pkgdep = xbps_string_cstring_nocopy (obj );
137+ const char * pkgdep = xbps_string_cstring_nocopy (obj );
143138 if (xbps_pkgpattern_match (pkgdep , str )) {
144139 found = true;
145140 break ;
146141 }
147142 } else if (mode == 4 ) {
148143 /* match pkgdep against pkgpattern */
149- pkgdep = xbps_string_cstring_nocopy (obj );
144+ const char * pkgdep = xbps_string_cstring_nocopy (obj );
150145 if (xbps_pkgpattern_match (str , pkgdep )) {
151146 found = true;
152147 break ;
153148 }
154149 }
155150 }
156- xbps_object_iterator_release (iter );
157151
158152 return found ;
159153}
0 commit comments