FVWM: FvwmButtons problem in 2.0.41

From: Richard Evans <rde_at_tadpole.co.uk>
Date: Tue, 2 Apr 1996 14:17:49 +0100

There is still a problem in FvwmButtons when you omit the "waitfor" string in
lines like:

*FvwmButtons Xterm rterm.xpm Exec exec xterm &

The code for parsing these lines has been more or less broken for a long time
now. Attached is my attempt at a patch to cure things:

*** FvwmButtons.c.orig Tue Mar 26 10:40:01 1996
--- FvwmButtons.c Tue Mar 26 10:47:34 1996
***************
*** 375,414 ****
                         * case the button stays down until window
                         * "identifier" materializes */
                        i=4;
                        while((Buttons[CurrentButton].action[i] != 0)&&
- (Buttons[CurrentButton].action[i] != '"')&&
                              isspace(Buttons[CurrentButton].action[i]))
                          i++;
                        if(Buttons[CurrentButton].action[i] == '"')
                          {
                            i2=i+1;
                            while((Buttons[CurrentButton].action[i2] != 0)&&
                                  (Buttons[CurrentButton].action[i2] != '"'))
                              i2++;
                          }
! else
                          i2 = i;
  
- if(i2 - i >1)
- {
- Buttons[CurrentButton].hangon = safemalloc(i2-i);
- strncpy(Buttons[CurrentButton].hangon,
- &Buttons[CurrentButton].action[i+1],i2-i-1);
- Buttons[CurrentButton].hangon[i2-i-1] = 0;
- Buttons[CurrentButton].up = 0;
- Buttons[CurrentButton].swallow = 0;
- }
- else
- {
- #if 0
- i2 = 4; /* ckh - should this be i2++ instead? */
- #else
- i2++;
- #endif
- }
                        tmp=safemalloc(strlen(Buttons[CurrentButton].action));
                        strcpy(tmp,"Exec ");
! i3= i2+1;
                        while((Buttons[CurrentButton].action[i3] != 0)&&
                              (isspace(Buttons[CurrentButton].action[i3])))
                          i3++;
--- 375,446 ----
                         * case the button stays down until window
                         * "identifier" materializes */
                        i=4;
+
+ /* Looping while != '"' and isspace is redundant */
+
                        while((Buttons[CurrentButton].action[i] != 0)&&
                              isspace(Buttons[CurrentButton].action[i]))
                          i++;
+
+ /*
+ Watch carefully from now on ...
+
+ i is pointing at the first non-space character after the
+ leading "exec", or at the end of the string.
+
+ Test for a quote.
+ */
+
                        if(Buttons[CurrentButton].action[i] == '"')
                          {
                            i2=i+1;
                            while((Buttons[CurrentButton].action[i2] != 0)&&
                                  (Buttons[CurrentButton].action[i2] != '"'))
                              i2++;
+
+ /*
+ Now i is index of opening quote and i2 is index of
+ closing quote or null terminator
+ */
+
+ if(i2 - i >1)
+ {
+ /* We know there is something between the quotes */
+
+ Buttons[CurrentButton].hangon = safemalloc(i2-i);
+ strncpy(Buttons[CurrentButton].hangon,
+ &Buttons[CurrentButton].action[i+1],i2-i-1);
+ Buttons[CurrentButton].hangon[i2-i-1] = 0;
+ Buttons[CurrentButton].up = 0;
+ Buttons[CurrentButton].swallow = 0;
+ }
+
+ /*
+ Move i2 to the character after the closing quote (unless the
+ quote was missing - we don't want to skip over the end of
+ the string.
+ */
+
+ if (Buttons[CurrentButton].action[i2] == '"')
+ i2++;
                          }
! else
! /*
! No quote was found. Leave i2 pointing at non-space character
! after the leading "exec".
! */
                          i2 = i;
  
                        tmp=safemalloc(strlen(Buttons[CurrentButton].action));
                        strcpy(tmp,"Exec ");
!
! /*
! Now i2 is pointing after any closing quote. Skip to beginning of
! action. DO NOT add 1 to i2 here since we could lose the first
! character of the action.
! */
!
! i3= i2;
                        while((Buttons[CurrentButton].action[i3] != 0)&&
                              (isspace(Buttons[CurrentButton].action[i3])))
                          i3++;

-- 
-------------------------------------------------------------------------------
Richard Evans			 		Telephone : (+44) 1223 428200
Tadpole Technology plc		 		Fax       : (+44) 1223 428201
Cambridge Science Park
Milton Road			 		E-Mail    : rde_at_tadpole.co.uk
Cambridge, CB4 4WQ, UK
-------------------------------------------------------------------------------
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Tue Apr 02 1996 - 08:11:00 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:58 BST