🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #25493

XMenuFindSelection() -- strncmp --> strcmp ?

#25493
From: bala
Date: Tue, 28 Apr 1987 13:38
30 lines
1872 bytes
In XMenuFindSel.c, when you are trying to find the index of a selection
the given label is strNcmp'd against the existing selections in the
pane. Unfortunately the assumption is that the labels are a single word.

Suppose there is a selection called "finger" and you want to add a new 
selection called "finger foo". XMenuFindSelection will *NOT* return
XM_FAILURE as it takes "finger foo" and strncmp's it as follows:
	    if (strncmp (label, s_ptr->label, s_ptr->label_length) == 0) {
		_XMErrorCode = XME_NO_ERROR;
		return (i);
	    }

<label is "finger foo" and s_ptr->label are existing selections like "finger">
Thus if any existing label is a substring of the new label this would
(incorrectly) succeed.

I am generating a dynamic menu history (adding cmds to a pane eliminating
duplicates and stacking up the panes depending on history size) and i would
like to treat "finger foo" and "finger" as different commands.

Changing the strncmp to strcmp should fix this. Could this be done in X11?

Cheers,
bala

Balachander Krishnamurthy	bala@cs.purdue.edu        (ever reliable ARPA)
Dept. of Computer Sciences	bala.purdue@relay.cs.net  (reliable CSNET)
Purdue University    {ucbvax,decvax,hplabs}!purdue!bala	(semi reliable usenet)
W. Lafayette IN 47907		317-494-7805		(um, well, er... GTE)
Technical Details
Message-ID: <8704281338.AA23453@merlin.cs.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!PURDUE.EDU!bala

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!PURDUE.EDU!bala
From: bala@PURDUE.EDU
Newsgroups: comp.windows.x
Subject: XMenuFindSelection() -- strncmp --> strcmp ?
Message-ID: <8704281338.AA23453@merlin.cs.purdue.edu>
Date: Tue, 28-Apr-87 09:38:10 EDT
Article-I.D.: merlin.8704281338.AA23453
Posted: Tue Apr 28 09:38:10 1987
Date-Received: Wed, 29-Apr-87 07:19:02 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: world
Organization: The ARPA Internet
Lines: 30