[PATCH app/xlsatoms 2/3] Actually stop after an invalid atom.

Tobias Stoeckmann tobias at stoeckmann.org
Wed Jul 4 13:29:26 UTC 2018


The manual page states that if no upper range limit has been specified,
no higher atoms will be printed. This is not true for

$ xlsatoms -range 0-

This prints the first 100 atoms, even though it already encountered an
invalid one at 0. The reason is that say_batch works as a batch, i.e.
retrieves 100 atoms at a time. If one of them is invalid, the rest is
still printed.

With this adjustment, xlsatoms behaves as stated in manual page.

Signed-off-by: Tobias Stoeckmann <tobias at stoeckmann.org>
---
 xlsatoms.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/xlsatoms.c b/xlsatoms.c
index 2bb5b47..5bed0cc 100644
--- a/xlsatoms.c
+++ b/xlsatoms.c
@@ -248,13 +248,15 @@ say_batch(xcb_connection_t *c, const char *format, xcb_get_atom_name_cookie_t *c
 	xcb_get_atom_name_reply_t *r;
 	r = xcb_get_atom_name_reply(c, cookie[i], &e);
 	if (r) {
-	    /* We could just use %.*s in 'format', but we want to be compatible
-	       with legacy command line usage */
-	    snprintf(atom_name, sizeof(atom_name), "%.*s",
-		r->name_len, xcb_get_atom_name_name(r));
-
-	    printf (format, i + low, atom_name);
-	    putchar ('\n');
+	    if (!done) {
+		/* We could just use %.*s in 'format', but we want to be compatible
+		   with legacy command line usage */
+		snprintf(atom_name, sizeof(atom_name), "%.*s",
+		    r->name_len, xcb_get_atom_name_name(r));
+
+		printf (format, i + low, atom_name);
+		putchar ('\n');
+	    }
 	    free(r);
 	}
 	if (e) {
-- 
2.18.0



More information about the xorg-devel mailing list