Subject: Non-fvwm restarts

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 29 May 1999 20:27:02 +0300 (IDT)

Here is a patch that brings back Restart commands like:
  Restart xterm
  Restart scwm

They haven't been working for some time already. Also, some other typos
fixed. The patch is against yesterday's CVS.

Regards,
Mikhael.

This patch fixes non-fvwm2 restarts.
There is actually only one "if" added over a block of commands.
Also "fvwm" changed to "fvwm2" and "8" changed to "6".

TODO:
  * use dynamic allocation for my_args
  * divide command to args by spaces
  * comparing string ("fvwm2") must actually be cut from g_argv[0]

--- fvwm.c.orig	Fri May 28 14:30:22 1999
+++ fvwm.c	Sat May 29 19:31:09 1999
@@ -1737,34 +1737,36 @@
       i=0;
       j=0;
       done = 0;
-      while((g_argv[j] != NULL)&&(i<8))
-      {
-        if(strcmp(g_argv[j],"-s")!=0)
+      if (strstr(command, "fvwm2") != NULL) {
+        /* must be 4 less than the size of my_argv to add 3 args and NULL */
+        while((g_argv[j] != NULL)&&(i<6))
         {
-          my_argv[i] = g_argv[j];
-          i++;
-          j++;
+          if(strcmp(g_argv[j],"-s")!=0)
+          {
+            my_argv[i] = g_argv[j];
+            i++;
+            j++;
+          }
+          else
+            j++;
         }
-        else
-          j++;
-      }
-      if(strstr(command,"fvwm")!= NULL)
         my_argv[i++] = "-s";
 
-      for (j = i - 1; j >= 0; j--)
+        for (j = i - 1; j >= 0; j--)
         {
-           if (strcmp (my_argv[j], "-restore") == 0)
-             break;
+          if (strcmp (my_argv[j], "-restore") == 0)
+            break;
         }
-      if (j >= 0)
-        {
+        if (j >= 0) {
           my_argv[j + 1] = filename;
-        }
-      else
-        {
+        } else {
           my_argv[i++] = "-restore";
           my_argv[i++] = filename;
         }
+      } else {
+        /* This must be divided to args by spaces! */
+        my_argv[i++] = command;
+      }
       while(i<10)
         my_argv[i++] = NULL;