diff options
Diffstat (limited to 'src/screen.c')
-rw-r--r-- | src/screen.c | 19 |
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)); |