[PATCH] don't pass screen number to frestore() in cmd_sfrestore()

Repolho <[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <20130807172705.GA8501@darch>
action.c:cmd_sfrestore() passes each screen's fdump to frestore() without
removing the screen number at the end, resulting in an error message being
printed for every screen, every time the function is used.

To reproduce, run
$ ratpoison -c "sfrestore $(ratpoison -c sfdump)"
which results in the following message:

ratpoison:frame.c:257: error: Unknown slot 0

The attached patch is a proposed solution to the issue. It was generated over
the latest git, v1.4.6-48-gb02d855.

_______________________________________________
Ratpoison-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
sfrestore_error_msg.patch (text/x-diff, 1.2 KB)
diff -pdru ratpoison/src/actions.c ratpoison.build/src/actions.c
--- ratpoison/src/actions.c	2013-08-07 12:08:11.154005173 -0300
+++ ratpoison.build/src/actions.c	2013-08-07 13:07:09.479860209 -0300
@@ -5515,6 +5515,7 @@ cmd_sfrestore (int interactively UNUSED,
   char *d;
   char *token;
   char *ptr;
+  char *tmp;
   struct sbuf *buffer[num_screens];
 
   /* initialize frameset-buffer for each screen */
@@ -5543,12 +5544,17 @@ cmd_sfrestore (int interactively UNUSED,
     /* convert to integer */
     x = strtol (ptr, NULL, 10);
 
-    /* check that specified screen number is not bigger than current number of connected screens */
-    if (x < num_screens) {
+    /* check that specified screen number is not bigger than current number of
+     * connected screens and that the string is big enough */
+    if (x < num_screens && strlen(token) > 2) {
+      /* copy token leaving out screen number at the end in order to pass it to
+       * frestore */
+      tmp = strndup(token, strlen(token)-2);
       /* append frameset to buffer[x] */
-      sbuf_concat(buffer[x], token);
+      sbuf_concat(buffer[x], tmp);
       sbuf_concat(buffer[x], ",");
       number_of_frames++;
+      free(tmp);
     }
     else {
       out_of_screen++;
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.