Browse Source

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 11 years ago
parent
commit
753374a4e1
1 changed files with 11 additions and 3 deletions
  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 &&
 	if (!ps->name_is_pattern &&
 	    (emsg = pkg_name_is_illegal(ps->name))) {
 	    (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),
 		snprintf(msg, sizeof(msg),
 		         _("illegal package name in specifier '%s%s%s': %s"),
 		         _("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;
 		return msg;
 	}
 	}