summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-11-17 18:38:27 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-11-17 18:38:27 +0100
commit2335261cdf8c574331b676c74e9d5299faa82624 (patch)
treefe725731d9afaf99b0543c69d809d0ddea10abb0 /src
parent797796e2d9d4c708668ed05359695c53f8448386 (diff)
downloadratpoison-2335261cdf8c574331b676c74e9d5299faa82624.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/actions.c28
1 files changed, 13 insertions, 15 deletions
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<num_screens; ++i)
+ for (i = 0; i < num_screens; ++i)
{
tmp = screen_dump (&screens[i]);
sbuf_concat (s, tmp);
- if (i + 1 != num_screens) /* No trailing comma. */
- sbuf_concat (s, ",");
+ sbuf_concat (s, ",");
free (tmp);
}
+ sbuf_chop (s);
ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get (s));
sbuf_free (s);