summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:54:45 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:54:45 +0100
commit7babe4652a3b781c982fd96a0ad697db9b711aa1 (patch)
tree4c86289fba68a23a697c989142c6910bb9da16e3
parentef423da9227bd6f360a16e1e6c8396d588d67cab (diff)
downloadratpoison-7babe4652a3b781c982fd96a0ad697db9b711aa1.zip
Simplify init_screen using sbuf
-rw-r--r--src/screen.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/screen.c b/src/screen.c
index 83f0850..0afdee0 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -238,6 +238,7 @@ static void
init_screen (rp_screen *s, int screen_num)
{
XGCValues gcv;
+ struct sbuf *buf;
int xine_screen_num;
char *colon;
@@ -275,22 +276,22 @@ init_screen (rp_screen *s, int screen_num)
s->frames_numset = rp_frame_numset;
/* Build the display string for each screen */
- s->display_string = xmalloc (strlen(DisplayString (dpy)) + 21);
- sprintf (s->display_string, "DISPLAY=%s", DisplayString (dpy));
- colon = strrchr (DisplayString (dpy), ':');
+ buf = sbuf_new (0);
+ sbuf_printf (buf, "DISPLAY=%s", DisplayString (dpy));
+ colon = strrchr (sbuf_get (buf), ':');
if (colon)
{
char *dot;
- dot = strrchr(s->display_string, '.');
- if (!dot || (strlen(dot) > strlen (colon)) )
+ dot = strrchr (sbuf_get (buf), '.');
+ if (!dot || dot < colon)
{
- /* no dot was found or it belongs to fqdn - append screen_num
- to the end */
- dot = s->display_string + strlen (s->display_string);
+ /* no dot was found or it belongs to fqdn - append screen_num
+ to the end */
+ sbuf_printf_concat (buf, ".%d", screen_num);
}
- sprintf(dot, ".%i", screen_num);
}
+ s->display_string = sbuf_free_struct (buf);
PRINT_DEBUG (("display string: %s\n", s->display_string));