Subject: Restart patch breaks restarts with FvwmCpp

From: Dominik Vogt <[email-masked]>
Date: Sun, 30 May 1999 02:06:29 +0200

With Mikhaels restart fix applied I can't restart with
FvwmCpp anymore. I'll back it out.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Sun, 30 May 1999 13:58:10 +0300 (IDT)

> FvwmCpp anymore. I'll back it out.

With this patch "Restart fvwm2" worked nice, "Restart" - not.
But this is not really the patch fault. It does the right job separating
fvwm2 and non-fvwm2 restarts.

Here is another patch which includes the previous patch and adds a
line to fix Restart without paramerers.
Now all 3 types of Restart (fvwm2, non-fvwm2, empty) with or without
initial fvwm2 arguments work for me.

Regards,
Mikhael.
This patch fixes non-fvwm2 restarts.
Changes:
  * added line:
    if (command == NULL || command[0] == '\0') command = g_argv[0];
  * added one "if" added over a block of commands to not add fvwm2
    parameters to non-fvwm commands
  * "fvwm" changed to "fvwm2"
  * fixed a limit when adding initial fvwm2 params (decreased by 2)
  * number of command arguments increased from 10 to 20

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	Sun May 30 13:23:26 1999
+++ fvwm.c	Sun May 30 13:35:20 1999
@@ -1720,7 +1720,8 @@
   {
      char* filename = strdup( CatString2(user_home_dir, "/.fvwm_restart") );
 
-     if (*command == '\0' || strstr (command, "fvwm"))
+     if (command == NULL || command[0] == '\0') command = g_argv[0];
+     if (*command == '\0' || strstr (command, "fvwm2"))
        {
 	 RestartInSession (filename); /* won't return under SM */
        }
@@ -1731,40 +1732,42 @@
     XCloseDisplay(dpy);
 
     {
-      char *my_argv[10];
+      char *my_argv[20];
       int i,done,j;
 
       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<16))
         {
-          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;