[PATCH] Fix display_string construction to handle new XDisplayString() behaviour

anthony <[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
XDisplayString does not append ".screen number" to return value after
http://gitorious.org/omcfadde/libx11/commit/f92e754297ec5fdb81068b56a4435026666224fa
Fix by appending .screen_num to the end of s->display_string in such case
---
There should be enough space to apeend .screen_num since we allocate
strlen(XDisplayString + 21) and strlen(DISPLAY=) is only 8.
What 21 is, by the way? Is it the Ultimate Answer to the Ultimate Question of
Life, The Universe, and Everything divided by 2?

 src/screen.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/screen.c b/src/screen.c
index f26f036..00fc7d1 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -283,8 +283,17 @@ init_screen (rp_screen *s, int screen_num)
       char *dot;
 
       dot = strrchr(s->display_string, '.');
-      if (dot && strlen (dot) < strlen (colon))
-        sprintf(dot, ".%i", screen_num);
+      if (!dot || (strlen(dot) > strlen (colon)) )
+      {
+        //no dot was found or it belongs to fqdn - append screen_num
+        //to the end
+        dot = s->display_string + strlen (s->display_string);
+      }
+      sprintf(dot, ".%i", screen_num);
+    }
+  else
+    {
+      fprintf (stderr, "Warning: failed to construct display string\n");
     }
 
   PRINT_DEBUG (("display string: %s\n", s->display_string));
-- 
1.7.4.1

_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk2upMoACgkQX4lZNDtEofyigwCfX+jBsAXzRdl5VCOIWD6RFqsq
spEAn1lbcOKCYNGgjjsQww+EX2jWrY5y
=95M5
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.