Explorar o código

libdpkg: Clarify that pkg_spec error messages should print empty architectures

The error message should print the passed package specifier, even if the
architecture qualifier was empty, otherwise it could seem confusing. So
state that we only want to handle the DPKG_ARCH_NONE case, and implicitly
ignore DPKG_ARCH_EMPTY.
Guillem Jover %!s(int64=11) %!d(string=hai) anos
pai
achega
753374a4e1
Modificáronse 1 ficheiros con 11 adicións e 3 borrados
  1. 11 3
      lib/dpkg/pkg-spec.c

+ 11 - 3
lib/dpkg/pkg-spec.c

@@ -67,11 +67,19 @@ pkg_spec_is_illegal(struct pkg_spec *ps)
 
 	if (!ps->name_is_pattern &&
 	    (emsg = pkg_name_is_illegal(ps->name))) {
+		const char *arch_sep;
+
+		/* Only check for DPKG_ARCH_NONE, because for everything else
+		 * we want to see the passed package specification, even if
+		 * the architecture is empty. */
+		if (ps->arch->type == DPKG_ARCH_NONE)
+			arch_sep = "";
+		else
+			arch_sep = ":";
+
 		snprintf(msg, sizeof(msg),
 		         _("illegal package name in specifier '%s%s%s': %s"),
-		         ps->name,
-		         (ps->arch->type != DPKG_ARCH_NONE) ? ":" : "",
-		         ps->arch->name, emsg);
+		         ps->name, arch_sep, ps->arch->name, emsg);
 		return msg;
 	}