commit:     e39cbfcefe03f6160894201df6174cec4b4e7946
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  5 13:09:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun  5 13:09:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e39cbfce

libq/atom: really fix retaining input in atom_format_r

return the start of the buffer, not the end (= empty)
add tests this time that show the bug is now fixed

Bug: https://bugs.gentoo.org/687416
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/atom.c        | 2 +-
 tests/qatom/dotest | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libq/atom.c b/libq/atom.c
index ae781a8..8b1b47a 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -646,7 +646,7 @@ atom_format_r(
                fmt = strchr(p, '%');
                if (fmt == NULL) {
                        append_buf(buf, buflen, "%s", p);
-                       return buf;
+                       return ret;
                } else if (fmt != p) {
                        append_buf(buf, buflen, "%.*s", (int)(fmt - p), p);
                }

diff --git a/tests/qatom/dotest b/tests/qatom/dotest
index 24bd67b..c173de3 100755
--- a/tests/qatom/dotest
+++ b/tests/qatom/dotest
@@ -56,6 +56,8 @@ test f16 "media-fonts font-adobe-100dpi 1.0.3 r1" \
 test f17 "games-rpg eschalon-book-1-demo 106 r1" \
                       -F '%{CATEGORY} %{PN} %{PV} %{PR}' \
                                        "games-rpg/eschalon-book-1-demo-106-r1"
+test f18 "bla"        -F 'bla'         "cat/pkg-c"  # bug #687416
+test f19 ":pkg-c-1.4" -F ':%{PN}-1.4'  "cat/pkg-c"  # bug #687416
 
 # Comparison tests
 test c01 "cat/pkg-123-r3 == pkg" \

Reply via email to