Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Don't spin forever on an out-of-context problem: instead, pass the incorrect format code through unprocessed.
Matthew Seaman committed 12 years ago
commit cce89c5d4bc7d4cf18670b430c3e76b4e122312f
parent a48421c
2 files changed +9 -6
modified libpkg/pkg_printf.c
@@ -1842,10 +1842,12 @@ parse_format(const char *f, unsigned context, struct percent_esc *p)

	/* Does this format take a trailing list item/separator format
	   like %{...%|...%} ?  It's only the list-valued items that
-
	   do.  Also, they only take the trailing stuff in the absence
-
	   of %?X or %#X modifiers. */
+
	   do, and they can only take it at the top level (context ==
+
	   PP_PKG).  Also, they only take the trailing stuff in the
+
	   absence of %?X or %#X modifiers. */

-
	if (fmt[p->fmt_code].has_trailer &&
+
	if ((context & PP_PKG) == PP_PKG &&
+
	    fmt[p->fmt_code].has_trailer &&
	    (p->flags & (PP_ALTERNATE_FORM1|PP_ALTERNATE_FORM2)) == 0)
		f = format_trailer(f, p);

@@ -2123,8 +2125,9 @@ process_format_trailer(struct sbuf *sbuf, struct percent_esc *p,
		s = fmt[p->fmt_code].fmt_handler(sbuf, pkg, p);


-
	if (s == NULL)
-
		f = fstart;	/* Pass through unprocessed on error */
+
	if (s == NULL) {
+
		f = fstart + 1;	/* Eat just the % on error */
+
	}

	clear_percent_esc(p);

modified pkg/utils.c
@@ -405,7 +405,7 @@ print_info(struct pkg * const pkg, unsigned int options)
				if (quiet)
					pkg_printf("%B%{%Bn\n%|%}", pkg);
				else
-
					pkg_printf("%B%{\t%B\n%|%}", pkg);
+
					pkg_printf("%B%{\t%Bn\n%|%}", pkg);
			}
			break;
		case INFO_SHLIBS_PROVIDED: