Skip to content
Tcl Source Code View Ticket
Login

View Ticket

TIP#127 implementation

Closed693836ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 17 years ago
Descriptionplain2003-02-26 18:53:18
This patch adds a -index option like the one from lsort
to lsearch.

Its diff'ed -u against the current HEAD (rev 1.45)
mic42plain2003-03-01 21:28:21
File Added - 43783: tclCmdIL.c.diff

Logged In: YES 
user_id=302287

Forgot to attach the patch.
mic42plain2003-03-01 23:10:28
File Added - 43786: tclCmdIL.c.diff

Logged In: YES 
user_id=302287

I made a new patch, further enhancing lsearch (and lsort as
a side effect).

The new patch does the following:

add two new options to lsearch:
-index index 
-subindices

-subindices is mutually exclusive with -inline and may only
be specified if -index is specified.
-----
?-index index?

Takes an index in the form used by lindex or lset, a list of
indices is allowed to search or sort based on the values in
nested sublists.

?-subindices? 

Returns indices one can use directly in [lset] or [lindex]
to access the sublist element found.

----
dkf Ticket [693836ffff]: 2 changes [History diff]2003-09-12 20:18:56
dkf Ticket [693836ffff]: 1 change [History diff]2003-09-12 20:19:30
dkfplain2003-09-13 08:08:41
File Deleted - 43783: 

Logged In: YES 
user_id=79902

Could you be a real star and produce:
  * a forward patch (the one you've done is reversed!)
  * some tests (via a patch to lsearch.test of course)
While I could reverse the patch, synthesizing tests is a bit
awkward as I don't understand (especially at 2am!) the
nuances of what cases should be tested and how.  (You could
use some of the examples from the TIP as the basis...)

If there are a few tests in there (so we can check that it
is doing what we think it ought to be doing) I'd be happy to
get this code into the core.
mic42plain2003-09-13 22:24:37
Logged In: YES 
user_id=302287

Sorry for the reversed patch. Should do better this time.
Shall i diff against current HEAD? 

As the patch changes things to lsearch and lsort tests for
both will be needed. I have the ones for simple syntax
checks (where the error messages are checked) done, as those
are trivial. 

Just a bit busy this week (local conference), so expect
something by the end of the week/next weekend.

Michael
dkfplain2003-10-01 19:22:37
Logged In: YES 
user_id=79902

Reminder: still waiting the tests (or at least enough of them 
that I can double-check that the behaviour specified in the 
TIP is actually implemented)
mic42plain2003-10-13 01:46:30
File Added - 64143: tclCmdIL.c.diff
mic42plain2003-10-13 01:47:20
File Deleted - 43786: 



File Added - 64144: lsearch.test.diff
mic42plain2003-10-13 01:47:53
File Added - 64145: CmdIL.test.diff
mic42plain2003-10-13 01:54:33
Logged In: YES 
user_id=302287

Ok, hopefully i have done the diff'ing the right way this time.

I added a basic testsuite, i wouldn't say its really
complete, there should probably be more checks.
(as the multiindex code is shared between lsort and lsearch
there are more tests in lsearch that test it).

Whats missing:
more combinations of options
(-inline...)  
Really good tests for error handling of the index code
(should have copied some things from the lset and lindex
tests..., as the code is copied from lindex...), some basic
ones are there.

A patch to the documentation.
dkfplain2003-10-13 15:27:44
Logged In: YES 
user_id=79902

Thanks. I'll try to get this in when I can.
dkf Ticket [693836ffff]: 1 change [History diff]2003-10-13 15:28:40
dkfplain2003-10-14 20:39:58
Logged In: YES 
user_id=79902

Applied to HEAD.  The documentation is perhaps a touch 
sparse, but that can be the subject of future bug reports if 
I've omitted something crucial.  :^)
dgpplain2003-10-15 05:43:18
Logged In: YES 
user_id=80530


Note this implementation
causes new segfaults.
Test cmdIL-5.5 demos this.

Probably good learning
opportunities here for how
apparently good code can be
subtly wrong.
dkfplain2003-10-15 05:49:49
Logged In: YES 
user_id=79902

That issue is being tracked in Bug 823768
dkfplain2008-11-02 18:26:31
data_type - 210894
dkfplain2009-07-29 19:40:09
IP - Comment Removed: 130.88.1.31
Log in (anonymous is fine) to add a comment.

Attachments: