소스 검색

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 년 전
부모
커밋
753374a4e1
1개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  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;
 	}