Просмотр исходного кода

dpkg: Factor out extension into its own variable in enqueue_specified()

Guillem Jover лет назад: 16
Родитель
Сommit
96fee44416
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      src/packages.c

+ 3 - 3
src/packages.c

@@ -100,16 +100,16 @@ static void
 enqueue_specified(const char *const *argv)
 {
   const char *thisarg;
-  size_t l;
 
   while ((thisarg = *argv++) != NULL) {
     struct pkginfo *pkg;
 
     pkg = findpackage(thisarg);
     if (pkg->status == stat_notinstalled) {
-      l = strlen(pkg->name);
+      size_t l = strlen(pkg->name);
+      const char *extension = pkg->name + l - sizeof(DEBEXT) + 1;
 
-      if (l >= sizeof(DEBEXT) && !strcmp(pkg->name+l-sizeof(DEBEXT)+1,DEBEXT))
+      if (l >= sizeof(DEBEXT) && strcmp(extension, DEBEXT) == 0)
         badusage(_("you must specify packages by their own names,"
                    " not by quoting the names of the files they come in"));
     }