On 22 May 2001 13:04:09 -0400, Dan Espen wrote: > > Dominik Vogt <fvwm-workers@fvwm.org> writes: > > On Tue, May 22, 2001 at 10:45:55AM -0400, Dan Espen wrote: > > > Mikhael Goikhman <[EMAIL PROTECTED]> writes: > > > > > > > > The problems are real, for example a sample in FAQ 7.13 does not work > > > > now > > > > I am not sure why it worked at all (2 bugs eliminate each other?). > > > > > > Which 2 bugs? > > > > > > I'm pretty sure 7.13 worked at one time. As I remember, more than > > > one of us looked at it. > > > > That does not necessarily mean that the example worked at a time > > when parsing was compatible with the 2.2.x versions. The example > > may have been written at a time when parsing was broken. > > Yes, but: > > $0 to $9 > The positional parameters given to a complex func- > tion (a function that has been defined with the > AddToFunc command). "$0" is replaced with the first > parameter, "$1" with the second parameter and so on.
True, but there is also this line (I hope it will not be valid tomorrow): Note that module configuration lines (i.e. lines beginning with '*') are not subject to parameter expansion. Here is a small patch adding partial expansion to module config lines; function parameters and new inventions like $[page.nx] are expended. I tested it during the day and verified that it does not conflict with any of our 27 modules accourding to their man pages. With this patch FAQ 7.13 works. I plan to apply it tomorrow. I don't want to do any other changes to command parsing before 2.4.0. Regards, Mikhael.
Index: functions.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/fvwm/functions.c,v retrieving revision 1.181 diff -u -r1.181 functions.c --- functions.c 2001/05/08 23:53:22 1.181 +++ functions.c 2001/05/22 20:08:28 @@ -470,7 +470,7 @@ } static char *expand( - char *input, char *arguments[], FvwmWindow *tmp_win, Bool addto) + char *input, char *arguments[], FvwmWindow *tmp_win, Bool addto, Bool ismod) { int l,i,l2,n,k,j,m; int xlen; @@ -491,7 +491,7 @@ i=0; while(i<l) { - if(input[i] == '$') + if (input[i] == '$' && (!ismod || !isalpha(input[i+1]))) { switch (input[i+1]) { @@ -598,7 +598,7 @@ j=0; while(i<l) { - if(input[i] == '$') + if (input[i] == '$' && (!ismod || !isalpha(input[i+1]))) { switch (input[i+1]) { @@ -944,24 +944,6 @@ fvwm_msg(INFO, "LOG", "%s", efa->action); #endif - /* Note: the module config command, "*" can not be handled by the - * regular command table because there is no required white space after - * the asterisk. */ - if (efa->action[0] == '*') - { -#ifdef USEDECOR - if (Scr.cur_decor && Scr.cur_decor != &Scr.DefaultDecor) - { - fvwm_msg( - WARN, "execute_function", - "Command can not be added to a decor; executing command now: '%s'", - efa->action); - } -#endif - /* process a module config command */ - ModuleConfig(efa->action); - return; - } func_depth++; if (efa->args) { @@ -1036,8 +1018,8 @@ function = PeekToken(taction, NULL); if (function) - function = expand(function, arguments, efa->tmp_win, False); - if (function) + function = expand(function, arguments, efa->tmp_win, False, False); + if (function && taction[0] != '*') { #if 1 /* DV: with this piece of code it is impossible to have a complex function @@ -1069,10 +1051,11 @@ efa->action); } #endif + if (!(efa->flags.exec & FUNC_DONT_EXPAND_COMMAND)) { expaction = expand(taction, arguments, efa->tmp_win, - (bif) ? !!(bif->flags & FUNC_ADD_TO) : False); + (bif) ? !!(bif->flags & FUNC_ADD_TO) : False, taction[0] == '*'); if (func_depth <= 1) must_free_string = set_repeat_data(expaction, REPEAT_COMMAND, bif); else @@ -1082,7 +1065,25 @@ { expaction = taction; } - j = 0; + + /* Note: the module config command, "*" can not be handled by the + * regular command table because there is no required white space after + * the asterisk. */ + if (expaction[0] == '*') + { +#ifdef USEDECOR + if (Scr.cur_decor && Scr.cur_decor != &Scr.DefaultDecor) + { + fvwm_msg( + WARN, "execute_function", + "Command can not be added to a decor; executing command now: '%s'", + expaction); + } +#endif + /* process a module config command */ + ModuleConfig(expaction); + } + else if (bif && bif->func_type != F_FUNCTION) { char *runaction;