Subject: Re: fvwm-2.0.44-almost, finally...

From: Dan Espen <[email-masked]>
Date: Thu, 09 Jan 1997 16:11:19 -0500

Sorry if this has already been reported, it seems vaguely familiar...

I added this to a menu:

+ "Stone title bar" TitleStyle TiledPixmap /public/pixmap/stone.xpm

and the words "Stone title  bar" are centered   and underlined in  the
menu as if they were a title.  Apparently the parsing of the addtomenu
line  sees  the characters  "Title" in   "TitleStyle" and thinks thats
close enough.

--
Dan Espen                                    Phone: (908) 699-5570
[email-masked]
444 Hoes Lane  Room RRC 1C-214
Piscataway, NJ 08854
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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: Andrew Veliath <[email-masked]>
Date: Thu, 9 Jan 1997 19:07:09 -0500 (EST)

> line  sees  the characters  "Title" in   "TitleStyle" and thinks thats

I just had a look at this, and apparently the culprit is in 
functions.c:find_func_type.  It only matches the first few letters which 
can cause incorrect matches (this is generally a problem with the entire 
mystrncasecmp stuff as I think someone else pointed out).  The following 
is a work-around that matches token length in addition to the first few 
letters.

--- ../../orig/fvwm-2.0.44-almost/fvwm/functions.c	Mon Dec 23 17:07:46 1996
+++ functions.c	Thu Jan  9 18:56:43 1997
@@ -220,15 +220,19 @@
 
 int find_func_type(char *action)
 {
-  int j;
+  int j, len = 0;
+  char *endtok = action;
   Bool matched;
+  while (*endtok&&!isspace(*endtok))++endtok;
+  len = endtok - action;
   j=0;
   matched = FALSE;
   while((!matched)&&(strlen(func_config[j].keyword)>0))
     {
-      if(mystrncasecmp(action,func_config[j].keyword,
-		       strlen(func_config[j].keyword))==0)
-	{
+      int mlen = strlen(func_config[j].keyword);
+      if((mlen == len)
+	 && (mystrncasecmp(action,func_config[j].keyword,mlen)==0))
+      {
 	  matched=TRUE;
 	  /* found key word */
 	  return (int)func_config[j].code;

---

From: [email-masked] (Albrecht Kadlec)
Date: Fri, 17 Jan 97 21:50:17 +0100

>>>>> Andrew Veliath writes:

> line  sees  the characters  "Title" in   "TitleStyle" and thinks thats

A> I just had a look at this, and apparently the culprit is in 
A> functions.c:find_func_type.  It only matches the first few letters which 
A> can cause incorrect matches (this is generally a problem with the entire 
A> mystrncasecmp stuff as I think someone else pointed out).  The following 
A> is a work-around that matches token length in addition to the first few 
A> letters.

A> --- ../../orig/fvwm-2.0.44-almost/fvwm/functions.c	Mon Dec 23 17:07:46 1996
A> +++ functions.c	Thu Jan  9 18:56:43 1997
A> @@ -220,15 +220,19 @@
 
A>  int find_func_type(char *action)
A>  {
A> -  int j;
A> +  int j, len = 0;
A> +  char *endtok = action;
A>    Bool matched;
A> +  while (*endtok&&!isspace(*endtok))++endtok;
A> +  len = endtok - action;
A>    j=0;
A>    matched = FALSE;
A>    while((!matched)&&(strlen(func_config[j].keyword)>0))
A>      {
A> -      if(mystrncasecmp(action,func_config[j].keyword,
A> -		       strlen(func_config[j].keyword))==0)
A> -	{
A> +      int mlen = strlen(func_config[j].keyword);
A> +      if((mlen == len)
A> +	 && (mystrncasecmp(action,func_config[j].keyword,mlen)==0))
A> +      {
A>  	  matched=TRUE;
A>  	  /* found key word */
A>  	  return (int)func_config[j].code;

better: just use MatchToken() or TokenCmp() and fix the library functions
to be aware of word ends ( =='\0' || isspace() || isdelim())

albrecht
-- 
Maybe deep down inside,
I'm tryin' for no one else but me,
too stubborn to say, "The buck stops here.
I'm not the one you're lookin' for."

But maybe deep down inside, I'm lyin'
To no one else but me.
Oh, but my back is up.  I'm on my guard
With all the exits sealed.	-- Genesis
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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].