Re: FVWM: Re: Empty function arguments (was Re: Finally moved to 2.2 etc etc)

From: Brad Giaccio <bgiaccio_at_psrw.com>
Date: Fri, 21 May 1999 11:29:06 -0400

On Fri, May 21, 1999 at 04:17:12PM +0200, Dominik Vogt wrote:
> > AddToFunc showit "I" Echo "I got: " $0 $1 $2 $3
> > showit test
> >
> > Which produces:
> >
> > [FVWM][Echo]: "I got: " test $1 $2 $3
>
> What does it show? This is exactly what I would have expected. Am
> I missing something?
>
> Bye
>
> Dominik ^_^
>

I would have expected to see
[FVWM][Echo]: "I got: " test

since $1 $2 and $3 are all empty strings

The problem is in functions.c:expand

the problem is that I ddin't acount for quite enough cases the last
time I patcehd this function. What needs to be done is to distinguish
between creating a function and actually expanding args when it is being
executed. This patch works for me in all places where I use $args could
someone else apply it and commit it if it works for them too.

Brad

Changelog entry:
1999-05-17 Brad Giaccio <bgiaccio_at_psrw.com>

    * fvwm/functions.c (expand): a fix for not leaving $arg on a line
      to be executed if there is no value for $arg.


Index: functions.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/functions.c,v
retrieving revision 1.62
diff -u -B -b -c -r1.62 functions.c
cvs server: conflicting specifications of output style
*** functions.c 1999/05/15 01:54:47 1.62
--- functions.c 1999/05/21 15:24:54
***************
*** 265,274 ****
--- 265,279 ----
  {
    int l,i,l2,n,k,j;
    char *out;
+ int addto = 0; /*special cas if doing addtofunc */
  
    l = strlen(input);
    l2 = l;
  
+ if(strncasecmp(input, "AddToFunc", 9) == 0 || input[0] == '+')
+ {
+ addto = 1;
+ }
    i=0;
    while(i<l)
      {
***************
*** 331,338 ****
                    out[j++] = arguments[n][k];
                  i++;
                }
! else
                out[j++] = '$';
              break;
            case 'w':
              if(tmp_win)
--- 336,351 ----
                    out[j++] = arguments[n][k];
                  i++;
                }
! else if (addto == 1)
! {
                  out[j++] = '$';
+ }
+ else
+ {
+ i++;
+ if (isspace(input[i+1]))
+ i++; /*eliminates extra white space*/
+ }
              break;
            case 'w':
              if(tmp_win)

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Fri May 21 1999 - 10:30:10 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:38:02 BST