summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Betts <Shawn Betts sabetts@andrew.cmu.edu>2010-04-16 17:36:03 -0700
committerShawn Betts <Shawn Betts sabetts@andrew.cmu.edu>2010-04-16 17:36:03 -0700
commit813191c8e9be42d5b113eb35242dc74f5088bddd (patch)
tree4a02f47b61bc7756ba35e5398a3b9b842f3178e6
parent20dbf1d91eba92d4b1a61d56774332e00f4c2a6d (diff)
downloadratpoison-813191c8e9be42d5b113eb35242dc74f5088bddd.zip
in init_screen, properly handle a dot in the display string
-rw-r--r--src/screen.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/screen.c b/src/screen.c
index 3848e29..f26f036 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -239,6 +239,7 @@ init_screen (rp_screen *s, int screen_num)
{
XGCValues gcv;
int xine_screen_num;
+ char *colon;
/* We use screen_num below to refer to the real X screen number, but
* if we're using Xinerama, it will only be the Xinerama logical screen
@@ -276,16 +277,17 @@ init_screen (rp_screen *s, int screen_num)
/* Build the display string for each screen */
s->display_string = xmalloc (strlen(DisplayString (dpy)) + 21);
sprintf (s->display_string, "DISPLAY=%s", DisplayString (dpy));
- if (strrchr (DisplayString (dpy), ':'))
+ colon = strrchr (DisplayString (dpy), ':');
+ if (colon)
{
char *dot;
dot = strrchr(s->display_string, '.');
- if (dot)
+ if (dot && strlen (dot) < strlen (colon))
sprintf(dot, ".%i", screen_num);
}
- PRINT_DEBUG (("%s\n", s->display_string));
+ PRINT_DEBUG (("display string: %s\n", s->display_string));
s->screen_num = screen_num;
s->xine_screen_num = xine_screen_num;