Tcl package Thread source code

Check-in [0238d42a96]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | novem
Files: files | file ages | folders
SHA3-256: 0238d42a96fdd4d775cabcc4a6af2bda9ba4e1fdc9d9f39214fec6338e1d1093
User & Date: jan.nijtmans 2019-06-29 21:06:32
Context
2019-07-02
15:40
Merge trunk check-in: 5dbfaa6b67 user: jan.nijtmans tags: novem
2019-06-29
21:06
Merge trunk check-in: 0238d42a96 user: jan.nijtmans tags: novem
14:39
Merge 2.8 branch check-in: 629db64158 user: jan.nijtmans tags: trunk
2019-05-17
12:29
Merge trunk check-in: 97ce48e557 user: jan.nijtmans tags: novem
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclThreadInt.h.

21
22
23
24
25
26
27
28
29

30
31

32
33
34
35
36
37
38
#include <stdarg.h> /* For va_list */

/*
 * MSVC 8.0 started to mark many standard C library functions depreciated
 * including the *printf family and others. Tell it to shut up.
 * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
 */
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#   pragma warning(disable:4244)

#   pragma warning(disable:4267)
#   pragma warning(disable:4996)

#endif

/*
 * Used to tag functions that are only to be visible within the module being
 * built and not outside it (where this is supported by the linker).
 */







|

>
|
|
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdarg.h> /* For va_list */

/*
 * MSVC 8.0 started to mark many standard C library functions depreciated
 * including the *printf family and others. Tell it to shut up.
 * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
 */
#if defined(_MSC_VER)
#   pragma warning(disable:4244)
#   if _MSC_VER >= 1400
#	pragma warning(disable:4267)
#	pragma warning(disable:4996)
#   endif
#endif

/*
 * Used to tag functions that are only to be visible within the module being
 * built and not outside it (where this is supported by the linker).
 */

Changes to generic/threadSvListCmd.c.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
...
350
351
352
353
354
355
356
357

358
359
360
361
362
363
364
...
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
...
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
...
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
...
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
...
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
...
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
...
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
...
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
...
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
....
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
static Tcl_ObjCmdProc SvLlengthObjCmd;   /* llength     */
static Tcl_ObjCmdProc SvLindexObjCmd;    /* lindex      */
static Tcl_ObjCmdProc SvLinsertObjCmd;   /* linsert     */
static Tcl_ObjCmdProc SvLrangeObjCmd;    /* lrange      */
static Tcl_ObjCmdProc SvLsearchObjCmd;   /* lsearch     */
static Tcl_ObjCmdProc SvLsetObjCmd;      /* lset        */

/*
 * This is copied verbatim from the tclUtil.c
 * since not found in the public stubs table.
 * I was just too lazy to rewrite it from scratch.
 */

static int SvGetIntForIndex(Tcl_Interp*,  Tcl_Obj *, int, int*);

/*
 * Inefficient list duplicator function which,
 * however, produces deep list copies, unlike
 * the original, which just makes shallow copies.
 */

static void DupListObjShared(Tcl_Obj*, Tcl_Obj*);
................................................................................
static int
SvLpopObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int ret, off, index = 0, iarg = 0;
    int llen;
    Tcl_Obj *elPtr = NULL;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lpop array key ?index?
     *          $list lpop ?index?
................................................................................
        iarg = off;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (iarg) {
        ret = SvGetIntForIndex(interp, objv[iarg], llen-1, &index);
        if (ret != TCL_OK) {
            goto cmd_err;
        }
    }
    if (index < 0 || index >= llen) {
        goto cmd_ok; /* Ignore out-of bounds, like Tcl does */
    }
................................................................................
static int
SvLpushObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int off, ret, flg, index = 0;
    int llen;
    Tcl_Obj *args[1];
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lpush array key element ?index?
     *          $list lpush element ?index?
................................................................................
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if ((objc - off) == 2) {
        ret = SvGetIntForIndex(interp, objv[off+1], llen, &index);
        if (ret != TCL_OK) {
            goto cmd_err;
        }
        if (index < 0) {
            index = 0;
        } else if (index > llen) {
            index = llen;
................................................................................
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    const char *firstArg;
    size_t argLen;
    int ret, off, llen, first, last, ndel, nargs, i, j;

    Tcl_Obj **args = NULL;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lreplace array key first last ?element ...?
     *          $list lreplace first last ?element ...?
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "first last ?element ...?");
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off], llen-1, &first);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off+1], llen-1, &last);
    if (ret != TCL_OK) {
        goto cmd_err;
    }

    firstArg = Tcl_GetString(objv[off]);
    argLen = objv[off]->length;
    if (first < 0)  {
................................................................................
static int
SvLrangeObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int ret, off, first, last, nargs, i, j;
    int llen;
    Tcl_Obj **elPtrs, **args;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lrange array key first last
     *          $list lrange first last
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "first last");
        goto cmd_err;
    }
    ret = Tcl_ListObjGetElements(interp, svObj->tclObj, &llen, &elPtrs);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off], llen-1, &first);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off+1], llen-1, &last);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (first < 0)  {
        first = 0;
    }
    if (last >= llen) {
................................................................................
static int
SvLinsertObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int off, ret, flg, nargs, index = 0, i, j;
    int llen;
    Tcl_Obj **args;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::linsert array key index element ?element ...?
     *          $list linsert element ?element ...?
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "index element ?element ...?");
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off], llen, &index);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (index < 0) {
        index = 0;
    } else if (index > llen) {
        index = llen;
................................................................................
static int
SvLlengthObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int off, ret;
    int llen;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::llength array key
     *          $list llength
     */
................................................................................
SvLindexObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    Tcl_Obj **elPtrs;
    int ret, off, index;
    int llen;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lindex array key index
     *          $list lindex index
     */
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "index");
        goto cmd_err;
    }
    ret = Tcl_ListObjGetElements(interp, svObj->tclObj, &llen, &elPtrs);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = SvGetIntForIndex(interp, objv[off], llen-1, &index);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (index >= 0 && index < llen) {
        Tcl_SetObjResult(interp, Sv_DuplicateObj(elPtrs[index]));
    }

................................................................................
        newObjList[i] = Sv_DuplicateObj(elObj);
    }

    Tcl_SetListObj(copyPtr, llen, newObjList);

    Tcl_Free(newObjList);
}
 
/*
 *-----------------------------------------------------------------------------
 *
 * SvGetIntForIndex --
 *
 *  Exact copy from the TclGetIntForIndex found in tclUtil.c
 *  since this is not in the stubs table.
 *
 *-----------------------------------------------------------------------------
 */

static int
SvGetIntForIndex(interp, objPtr, endValue, indexPtr)
    Tcl_Interp *interp;     /* Interpreter to use for error reporting.
                             * If NULL, then no error message is left
                             * after errors. */
    Tcl_Obj *objPtr;        /* Points to an object containing either
                             * "end" or an integer. */
    int endValue;           /* The value to be stored at "indexPtr" if
                             * "objPtr" holds "end". */
    int *indexPtr;          /* Location filled in with an integer
                             * representing an index. */
{
    const char *bytes;
    size_t length;
    int offset;

    bytes = Tcl_GetString(objPtr);
    length = objPtr->length;

    if ((*bytes != 'e')
        || (strncmp(bytes, "end",((length > 3) ? 3 : length)) != 0)) {
        if (Tcl_GetIntFromObj(NULL, objPtr, &offset) != TCL_OK) {
            goto intforindex_error;
        }
        *indexPtr = offset;
        return TCL_OK;
    }
    if (length <= 3) {
        *indexPtr = endValue;
    } else if (bytes[3] == '-') {
        /*
         * This is our limited string expression evaluator
         */
        if (Tcl_GetInt(interp, bytes+3, &offset) != TCL_OK) {
            return TCL_ERROR;
        }
        *indexPtr = endValue + offset;
    } else {
  intforindex_error:
        if (interp != NULL) {
            Tcl_ResetResult(interp);
            Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "bad index \"",
                    bytes, "\": must be integer or end?-integer?",(char*)NULL);
        }
        return TCL_ERROR;
    }
    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------
 *
 * SvLsetFlat --
 *
 *  Almost exact copy from the TclLsetFlat found in tclListObj.c.
................................................................................
SvLsetFlat(interp, listPtr, indexCount, indexArray, valuePtr)
     Tcl_Interp *interp;     /* Tcl interpreter */
     Tcl_Obj *listPtr;       /* Pointer to the list being modified */
     int indexCount;         /* Number of index args */
     Tcl_Obj **indexArray;
     Tcl_Obj *valuePtr;      /* Value arg to 'lset' */
{
    int index, result, i;
    int elemCount;
    Tcl_Obj **elemPtrs, *chainPtr, *subListPtr;

    /*
     * Determine whether the index arg designates a list
     * or a single index.
     */

................................................................................

        listPtr->internalRep.twoPtrValue.ptr2 = (void*)chainPtr;

        /*
         * Determine the index of the requested element.
         */

        result = SvGetIntForIndex(interp, indexArray[i], elemCount-1, &index);
        if (result != TCL_OK) {
            break;
        }

        /*
         * Check that the index is in range.
         */






<
<
<
<
<
<
<
<







 







|
|







 







|







 







|
|







 







|







 







|
>







 







|



|







 







|
|







 







|



|







 







|
|







 







|







 







<
|







 







|
|







 







|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
|







 







|







32
33
34
35
36
37
38








39
40
41
42
43
44
45
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
...
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
...
602
603
604
605
606
607
608

609
610
611
612
613
614
615
616
...
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
...
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
...
902
903
904
905
906
907
908




























































909
910
911
912
913
914
915
...
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
...
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
static Tcl_ObjCmdProc SvLlengthObjCmd;   /* llength     */
static Tcl_ObjCmdProc SvLindexObjCmd;    /* lindex      */
static Tcl_ObjCmdProc SvLinsertObjCmd;   /* linsert     */
static Tcl_ObjCmdProc SvLrangeObjCmd;    /* lrange      */
static Tcl_ObjCmdProc SvLsearchObjCmd;   /* lsearch     */
static Tcl_ObjCmdProc SvLsetObjCmd;      /* lset        */









/*
 * Inefficient list duplicator function which,
 * however, produces deep list copies, unlike
 * the original, which just makes shallow copies.
 */

static void DupListObjShared(Tcl_Obj*, Tcl_Obj*);
................................................................................
static int
SvLpopObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int ret, off, llen, iarg = 0;
    size_t index = 0;
    Tcl_Obj *elPtr = NULL;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lpop array key ?index?
     *          $list lpop ?index?
................................................................................
        iarg = off;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (iarg) {
        ret = Tcl_GetIntForIndex(interp, objv[iarg], llen-1, &index);
        if (ret != TCL_OK) {
            goto cmd_err;
        }
    }
    if (index < 0 || index >= llen) {
        goto cmd_ok; /* Ignore out-of bounds, like Tcl does */
    }
................................................................................
static int
SvLpushObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int off, ret, flg, llen;
    size_t index = 0;
    Tcl_Obj *args[1];
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lpush array key element ?index?
     *          $list lpush element ?index?
................................................................................
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if ((objc - off) == 2) {
        ret = Tcl_GetIntForIndex(interp, objv[off+1], llen, &index);
        if (ret != TCL_OK) {
            goto cmd_err;
        }
        if (index < 0) {
            index = 0;
        } else if (index > llen) {
            index = llen;
................................................................................
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    const char *firstArg;
    size_t argLen;
    int ret, off, llen, ndel, nargs, i, j;
    size_t first, last;
    Tcl_Obj **args = NULL;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lreplace array key first last ?element ...?
     *          $list lreplace first last ?element ...?
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "first last ?element ...?");
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off], llen-1, &first);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off+1], llen-1, &last);
    if (ret != TCL_OK) {
        goto cmd_err;
    }

    firstArg = Tcl_GetString(objv[off]);
    argLen = objv[off]->length;
    if (first < 0)  {
................................................................................
static int
SvLrangeObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int ret, off, llen, nargs, i, j;
    size_t first, last;
    Tcl_Obj **elPtrs, **args;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lrange array key first last
     *          $list lrange first last
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "first last");
        goto cmd_err;
    }
    ret = Tcl_ListObjGetElements(interp, svObj->tclObj, &llen, &elPtrs);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off], llen-1, &first);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off+1], llen-1, &last);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (first < 0)  {
        first = 0;
    }
    if (last >= llen) {
................................................................................
static int
SvLinsertObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    int off, ret, flg, llen, nargs, i, j;
    size_t index = 0;
    Tcl_Obj **args;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::linsert array key index element ?element ...?
     *          $list linsert element ?element ...?
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "index element ?element ...?");
        goto cmd_err;
    }
    ret = Tcl_ListObjLength(interp, svObj->tclObj, &llen);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off], llen, &index);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (index < 0) {
        index = 0;
    } else if (index > llen) {
        index = llen;
................................................................................
static int
SvLlengthObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{

    int llen, off, ret;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::llength array key
     *          $list llength
     */
................................................................................
SvLindexObjCmd (arg, interp, objc, objv)
    void *arg;
    Tcl_Interp *interp;
    int objc;
    Tcl_Obj *const objv[];
{
    Tcl_Obj **elPtrs;
    int ret, off, llen;
    size_t index;
    Container *svObj = (Container*)arg;

    /*
     * Syntax:
     *          tsv::lindex array key index
     *          $list lindex index
     */
................................................................................
        Tcl_WrongNumArgs(interp, off, objv, "index");
        goto cmd_err;
    }
    ret = Tcl_ListObjGetElements(interp, svObj->tclObj, &llen, &elPtrs);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    ret = Tcl_GetIntForIndex(interp, objv[off], llen-1, &index);
    if (ret != TCL_OK) {
        goto cmd_err;
    }
    if (index >= 0 && index < llen) {
        Tcl_SetObjResult(interp, Sv_DuplicateObj(elPtrs[index]));
    }

................................................................................
        newObjList[i] = Sv_DuplicateObj(elObj);
    }

    Tcl_SetListObj(copyPtr, llen, newObjList);

    Tcl_Free(newObjList);
}




























































 
/*
 *----------------------------------------------------------------------
 *
 * SvLsetFlat --
 *
 *  Almost exact copy from the TclLsetFlat found in tclListObj.c.
................................................................................
SvLsetFlat(interp, listPtr, indexCount, indexArray, valuePtr)
     Tcl_Interp *interp;     /* Tcl interpreter */
     Tcl_Obj *listPtr;       /* Pointer to the list being modified */
     int indexCount;         /* Number of index args */
     Tcl_Obj **indexArray;
     Tcl_Obj *valuePtr;      /* Value arg to 'lset' */
{
    int elemCount, result, i;
    size_t index;
    Tcl_Obj **elemPtrs, *chainPtr, *subListPtr;

    /*
     * Determine whether the index arg designates a list
     * or a single index.
     */

................................................................................

        listPtr->internalRep.twoPtrValue.ptr2 = (void*)chainPtr;

        /*
         * Determine the index of the requested element.
         */

        result = Tcl_GetIntForIndex(interp, indexArray[i], elemCount-1, &index);
        if (result != TCL_OK) {
            break;
        }

        /*
         * Check that the index is in range.
         */