gnb@bby.oz.au (Gregory N. Bond) (03/21/91)
NB: The same bug is in tvtwm, and perhaps other twm variants. This
has been mailed to xbugs.
X Window System Bug Report
xbugs@expo.lcs.mit.edu
VERSION:
R4; fixes 1-18 installed.
CLIENT MACHINE and OPERATING SYSTEM:
Any. Noticed on Sun 3/80+SunOs 4.1 and Solbourne+OS/MP 4.0D
DISPLAY TYPE:
Sun CG4 on 3/80.
WINDOW MANAGER:
twm
AREA:
twm
SYNOPSIS:
twm gets confused with processing application names if one
name is a proper substring of another.
DESCRIPTION:
When twm is processing application names to determine whether
to use an icon manager or title bar (and others; this is where
I noticed it), and it has an entry for an application with a
short name (e.g. "xcal") specifying a certain behaviour (e.g.
no title), then if an application is launched with a name that
is a superstring of the shorter name (e.g. "xcalc") then the
new application will get the behaviour specified for the other
application.
This is because LookInList in list.c is effectivly doing
strncmp(newname, oldname, strlen(oldname))
to determine how to treat the new application. If newname =
"xcalc" and oldname = "xcal" then the compare will succeed
when it shouldn't.
REPEAT BY:
Setup a .twmrc file containing no reference to xcalc, and some
references to xcal, for example:
IconManagerDontShow {
"xcal"
}
NoTitle {
"xcal"
}
Start twm and then start up xcalc. Notice that xcalc doesn't
appear in the icon manager, nor does it have a title bar.
SAMPLE FIX:
This fix will correct the problem, and doesn't seem to have
broken anything else, but I don't trust myself to understand
twm enought to say there is nothing that depends on the
partial matching semantics that LookInList used to provide.
This is patched against .../mit/clients/twm/list.c, MIT X11R4
distribution with fixes 1-18 installed.
*** list.c.ORIG Tue Mar 5 15:51:06 1991
--- list.c Thu Mar 21 15:33:27 1991
***************
*** 117,127 ****
XClassHint *class;
{
name_list *nptr;
/* look for the name first */
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (strncmp(name, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
--- 117,129 ----
XClassHint *class;
{
name_list *nptr;
+ int l = strlen(name);
/* look for the name first */
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (l == nptr->namelen &&
! strncmp(name, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
***************
*** 128,143 ****
if (class)
{
/* look for the res_name next */
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (strncmp(class->res_name, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
/* finally look for the res_class */
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (strncmp(class->res_class, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
}
--- 130,149 ----
if (class)
{
/* look for the res_name next */
+ l = strlen(class->res_name);
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (l == nptr->namelen &&
! strncmp(class->res_name, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
/* finally look for the res_class */
+ l = strlen(class->res_class);
for (nptr = list_head; nptr != NULL; nptr = nptr->next)
{
! if (l == nptr->namelen &&
! strncmp(class->res_class, nptr->name, nptr->namelen) == 0)
return (nptr->ptr);
}
}
--
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb@melba.bby.oz.au non-MX: gnb%melba.bby.oz@uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb