1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/*
* tclIndexObj.c --
*
* This file implements objects of type "index". This object type
* is used to lookup a keyword in a table of valid values and cache
* the index of the matching entry.
*
* Copyright (c) 1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclIndexObj.c,v 1.10.6.5 2001/10/22 09:03:32 dkf Exp $
*/
#include "tclInt.h"
/*
* Prototypes for procedures defined later in this file:
*/
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/*
* tclIndexObj.c --
*
* This file implements objects of type "index". This object type
* is used to lookup a keyword in a table of valid values and cache
* the index of the matching entry.
*
* Copyright (c) 1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclIndexObj.c,v 1.10.6.6 2001/10/22 09:54:17 dkf Exp $
*/
#include "tclInt.h"
/*
* Prototypes for procedures defined later in this file:
*/
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
typedef struct {
VOID *tablePtr; /* Pointer to the table of strings */
int offset; /* Offset between table entries */
int index; /* Selected index into table. */
} IndexRep;
#define STRING_AT(table, offset, index) \
(*((char **)(((VOID *)(table)) + ((offset) * (index)))))
#define NEXT_ENTRY(table, offset) \
(&(STRING_AT(table, offset, 1)))
#define EXPAND_OF(indexRep) \
STRING_AT((indexRep)->tablePtr, (indexRep)->offset, (indexRep)->index)
/*
|
>
>
>
>
|
>
>
>
|
>
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
typedef struct {
VOID *tablePtr; /* Pointer to the table of strings */
int offset; /* Offset between table entries */
int index; /* Selected index into table. */
} IndexRep;
/*
* SunPro CC is annoying!
*/
#ifdef __sparc
# define STRING_AT(table, offset, index) \
(*((char **)(((char *)(table)) + ((offset) * (index)))))
#else
# define STRING_AT(table, offset, index) \
(*((char **)(((VOID *)(table)) + (ptrdiff_t)((offset) * (index)))))
#endif
#define NEXT_ENTRY(table, offset) \
(&(STRING_AT(table, offset, 1)))
#define EXPAND_OF(indexRep) \
STRING_AT((indexRep)->tablePtr, (indexRep)->offset, (indexRep)->index)
/*
|
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
static void
UpdateStringOfIndex(objPtr)
Tcl_Obj *objPtr;
{
IndexRep *indexRep = (IndexRep *) objPtr->internalRep.otherValuePtr;
register char *buf;
register int len;
register char *indexStr = *(char **)
(indexRep->tablePtr + (indexRep->offset * indexRep->index));
len = strlen(indexStr);
buf = (char *) ckalloc(len + 1);
memcpy(buf, indexStr, len+1);
objPtr->bytes = buf;
objPtr->length = len;
}
|
|
<
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
static void
UpdateStringOfIndex(objPtr)
Tcl_Obj *objPtr;
{
IndexRep *indexRep = (IndexRep *) objPtr->internalRep.otherValuePtr;
register char *buf;
register int len;
register char *indexStr = EXPAND_OF(indexRep);
len = strlen(indexStr);
buf = (char *) ckalloc(len + 1);
memcpy(buf, indexStr, len+1);
objPtr->bytes = buf;
objPtr->length = len;
}
|