@@ -66,12 +66,12 @@ normpath(char *path)
6666 char * seg , * p ;
6767
6868 for (p = path , seg = NULL ; * p ; p ++ ) {
69- if (strncmp (p , "/../" , 4 ) == 0 || strncmp (p , "/.." , 4 ) == 0 ) {
69+ if (strneq (p , "/../" , 4 ) || strneq (p , "/.." , 4 )) {
7070 memmove (seg ? seg : p , p + 3 , strlen (p + 3 ) + 1 );
7171 return normpath (path );
72- } else if (strncmp (p , "/./" , 3 ) == 0 || strncmp (p , "/." , 3 ) == 0 ) {
72+ } else if (strneq (p , "/./" , 3 ) || strneq (p , "/." , 3 )) {
7373 memmove (p , p + 2 , strlen (p + 2 ) + 1 );
74- } else if (strncmp (p , "//" , 2 ) == 0 || strncmp (p , "/" , 2 ) == 0 ) {
74+ } else if (strneq (p , "//" , 2 )|| strneq (p , "/" , 2 )) {
7575 memmove (p , p + 1 , strlen (p + 1 ) + 1 );
7676 }
7777 if (* p == '/' )
@@ -179,7 +179,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
179179
180180 /* create target directory, necessary for dangling symlinks */
181181 dir = xbps_xasprintf ("%s/%s" , xhp -> rootdir , dir );
182- if (strcmp (dir , "." ) && xbps_mkpath (dir , 0755 ) && errno != EEXIST ) {
182+ if (! streq (dir , "." ) && xbps_mkpath (dir , 0755 ) && errno != EEXIST ) {
183183 rv = errno ;
184184 xbps_dbg_printf (
185185 "failed to create target dir '%s' for group '%s': %s\n" ,
@@ -192,7 +192,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
192192 /* create link directory, necessary for dangling symlinks */
193193 p = strdup (linkpath );
194194 dir = dirname (p );
195- if (strcmp (dir , "." ) && xbps_mkpath (dir , 0755 ) && errno != EEXIST ) {
195+ if (! streq (dir , "." ) && xbps_mkpath (dir , 0755 ) && errno != EEXIST ) {
196196 rv = errno ;
197197 xbps_dbg_printf (
198198 "failed to create symlink dir '%s' for group '%s': %s\n" ,
@@ -273,7 +273,7 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
273273 keysym = xbps_array_get (allkeys , i );
274274 keyname = xbps_dictionary_keysym_cstring_nocopy (keysym );
275275
276- if (group && strcmp (keyname , group ))
276+ if (group && ! streq (keyname , group ))
277277 continue ;
278278
279279 array = xbps_dictionary_get (alternatives , keyname );
@@ -282,7 +282,7 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
282282
283283 /* remove symlinks from previous alternative */
284284 xbps_array_get_cstring_nocopy (array , 0 , & prevpkgname );
285- if (prevpkgname && strcmp (pkgname , prevpkgname ) != 0 ) {
285+ if (prevpkgname && ! streq (pkgname , prevpkgname )) {
286286 if ((prevpkgd = xbps_pkgdb_get_pkg (xhp , prevpkgname )) &&
287287 (prevpkg_alts = xbps_dictionary_get (prevpkgd , "alternatives" )) &&
288288 xbps_dictionary_count (prevpkg_alts )) {
@@ -366,7 +366,7 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
366366 continue ;
367367
368368 xbps_array_get_cstring_nocopy (array , 0 , & first );
369- if (strcmp (pkgname , first ) == 0 ) {
369+ if (streq (pkgname , first )) {
370370 /* this pkg is the current alternative for this group */
371371 current = true;
372372 rv = remove_symlinks (xhp ,
@@ -427,7 +427,7 @@ prune_altgroup(struct xbps_handle *xhp, xbps_dictionary_t repod,
427427
428428 /* if using alt group from another package, we won't switch anything */
429429 xbps_array_get_cstring_nocopy (array , 0 , & curpkg );
430- current = ( strcmp ( pkgname , curpkg ) == 0 );
430+ current = streq ( pkgname , curpkg );
431431
432432 /* actually prune the alt group for the current package */
433433 xbps_remove_string_from_array (array , pkgname );
@@ -508,7 +508,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *pkgname, const char *pkgve
508508 array2 = xbps_dictionary_get (pkgdb_alts , keyname );
509509 if (array2 ) {
510510 xbps_array_get_cstring_nocopy (array2 , 0 , & first );
511- if (strcmp (pkgname , first ) == 0 ) {
511+ if (streq (pkgname , first )) {
512512 remove_symlinks (xhp , array_repo , keyname );
513513 }
514514 }
@@ -576,7 +576,7 @@ xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
576576 } else {
577577 if (xbps_match_string_in_array (array , pkgname )) {
578578 xbps_array_get_cstring_nocopy (array , 0 , & first );
579- if (strcmp (pkgname , first )) {
579+ if (! streq (pkgname , first )) {
580580 /* current alternative does not match */
581581 continue ;
582582 }
0 commit comments