From 2335261cdf8c574331b676c74e9d5299faa82624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Sun, 17 Nov 2013 18:38:27 +0100 Subject: Use sbuf_chop in fdump() to trim trailing comma. * those commas shouldn't have been there in the first place. If your scripts rely on this, watch out! * code simplified and variables better named, while here. --- src/actions.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index 2369067..5f6c013 100644 --- a/src/actions.c +++ b/src/actions.c @@ -4868,25 +4868,23 @@ cmd_fselect (int interactive, struct cmdarg **args) static char * fdump (rp_screen *screen) { - struct sbuf *s; - char *tmp; + struct sbuf *dump; rp_frame *cur; - s = sbuf_new (0); + dump = sbuf_new (0); - /* FIXME: Oooh, gross! there's a trailing comma, yuk! */ list_for_each_entry (cur, &(screen->frames), node) { - char *t; + char *frameset; - t = frame_dump (cur, screen); - sbuf_concat (s, t); - sbuf_concat (s, ","); - free (t); + frameset = frame_dump (cur, screen); + sbuf_concat (dump, frameset); + sbuf_concat (dump, ","); + free (frameset); } + sbuf_chop (dump); - tmp = sbuf_free_struct (s); - return tmp; + return sbuf_free_struct (dump); } cmdret * @@ -5490,7 +5488,6 @@ cmd_sfdump (int interactively UNUSED, struct cmdarg **args UNUSED) screens[i].xine_screen_num : screens[i].screen_num); - /* FIXME: Oooh, gross! there's a trailing comma, yuk! */ list_for_each_entry (cur, &(screens[i].frames), node) { char *frameset; @@ -5500,6 +5497,7 @@ cmd_sfdump (int interactively UNUSED, struct cmdarg **args UNUSED) sbuf_concat (dump, screen_suffix); free (frameset); } + sbuf_chop (dump); } ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get (dump)); sbuf_free (dump); @@ -5586,14 +5584,14 @@ cmd_sdump (int interactive UNUSED, struct cmdarg **args UNUSED) int i; s = sbuf_new (0); - for (i=0; i