summaryrefslogtreecommitdiffstats
path: root/generic/tkStyle.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-04-27 22:38:54 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-04-27 22:38:54 (GMT)
commit4513cb9f431ea8c6b151913a016ec6c75bcac559 (patch)
tree681f7c2354a3726da3ab7da646d316c1275f540d /generic/tkStyle.c
parent1876f5f7ee429456ad89540bcf659c092245bf1b (diff)
downloadtk-4513cb9f431ea8c6b151913a016ec6c75bcac559.zip
tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.gz
tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.bz2
Get rid of pre-C89-isms (esp. CONST vs const).
Diffstat (limited to 'generic/tkStyle.c')
-rw-r--r--generic/tkStyle.c103
1 files changed, 49 insertions, 54 deletions
diff --git a/generic/tkStyle.c b/generic/tkStyle.c
index 5f2ada2..24464c0 100644
--- a/generic/tkStyle.c
+++ b/generic/tkStyle.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkStyle.c,v 1.8 2007/12/13 15:24:16 dgp Exp $
+ * RCS: @(#) $Id: tkStyle.c,v 1.9 2008/04/27 22:38:58 dkf Exp $
*/
#include "tkInt.h"
@@ -26,7 +26,7 @@ typedef struct StyledWidgetSpec {
* structure. */
Tk_OptionTable optionTable; /* Option table for the widget class using the
* element. */
- CONST Tk_OptionSpec **optionsPtr;
+ const Tk_OptionSpec **optionsPtr;
/* Table of option spec pointers, matching the
* option list provided during element
* registration. Malloc'd. */
@@ -60,7 +60,7 @@ typedef struct StyledElement {
*/
typedef struct StyleEngine {
- CONST char *name; /* Name of engine. Points to a hash key. */
+ const char *name; /* Name of engine. Points to a hash key. */
StyledElement *elements; /* Table of widget element descriptors. Each
* element is indexed by a unique system-wide
* ID. Table grows dynamically as new elements
@@ -77,7 +77,7 @@ typedef struct StyleEngine {
*/
typedef struct Style {
- CONST char *name; /* Name of style. Points to a hash key. */
+ const char *name; /* Name of style. Points to a hash key. */
StyleEngine *enginePtr; /* Style engine of which the style is an
* instance. */
ClientData clientData; /* Data provided during registration. */
@@ -88,7 +88,7 @@ typedef struct Style {
*/
typedef struct Element {
- CONST char *name; /* Name of element. Points to a hash key. */
+ const char *name; /* Name of element. Points to a hash key. */
int id; /* Id of element. */
int genericId; /* Id of generic element. */
int created; /* Boolean, whether the element was created
@@ -122,7 +122,7 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined later in this file:
*/
-static int CreateElement(CONST char *name, int create);
+static int CreateElement(const char *name, int create);
static void DupStyleObjProc(Tcl_Obj *srcObjPtr,
Tcl_Obj *dupObjPtr);
static void FreeElement(Element *elementPtr);
@@ -134,13 +134,13 @@ static StyledElement * GetStyledElement(StyleEngine *enginePtr,
int elementId);
static StyledWidgetSpec*GetWidgetSpec(StyledElement *elementPtr,
Tk_OptionTable optionTable);
-static void InitElement(Element *elementPtr, CONST char *name,
+static void InitElement(Element *elementPtr, const char *name,
int id, int genericId, int created);
-static void InitStyle(Style *stylePtr, CONST char *name,
+static void InitStyle(Style *stylePtr, const char *name,
StyleEngine *enginePtr, ClientData clientData);
static void InitStyledElement(StyledElement *elementPtr);
static void InitStyleEngine(StyleEngine *enginePtr,
- CONST char *name, StyleEngine *parentPtr);
+ const char *name, StyleEngine *parentPtr);
static void InitWidgetSpec(StyledWidgetSpec *widgetSpecPtr,
StyledElement *elementPtr,
Tk_OptionTable optionTable);
@@ -182,7 +182,7 @@ void
TkStylePkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->nbInit != 0) {
@@ -238,7 +238,7 @@ void
TkStylePkgFree(
TkMainInfo *mainPtr) /* The application being deleted. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr;
@@ -267,7 +267,7 @@ TkStylePkgFree(
entryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (entryPtr != NULL) {
- enginePtr = (StyleEngine *) Tcl_GetHashValue(entryPtr);
+ enginePtr = Tcl_GetHashValue(entryPtr);
FreeStyleEngine(enginePtr);
ckfree((char *) enginePtr);
entryPtr = Tcl_NextHashEntry(&search);
@@ -305,12 +305,12 @@ TkStylePkgFree(
Tk_StyleEngine
Tk_RegisterStyleEngine(
- CONST char *name, /* Name of the engine to create. NULL or empty
+ const char *name, /* Name of the engine to create. NULL or empty
* means the default system engine. */
Tk_StyleEngine parent) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -337,7 +337,7 @@ Tk_RegisterStyleEngine(
enginePtr = (StyleEngine *) ckalloc(sizeof(StyleEngine));
InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
(StyleEngine *) parent);
- Tcl_SetHashValue(entryPtr, (ClientData) enginePtr);
+ Tcl_SetHashValue(entryPtr, enginePtr);
return (Tk_StyleEngine) enginePtr;
}
@@ -361,13 +361,13 @@ Tk_RegisterStyleEngine(
static void
InitStyleEngine(
StyleEngine *enginePtr, /* Points to an uninitialized engine. */
- CONST char *name, /* Name of the registered engine. NULL or empty
+ const char *name, /* Name of the registered engine. NULL or empty
* means the default system engine. Usually
* points to the hash key. */
StyleEngine *parentPtr) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -377,14 +377,12 @@ InitStyleEngine(
*/
enginePtr->parentPtr = NULL;
-
} else if (parentPtr == NULL) {
/*
* The default style engine is the parent.
*/
enginePtr->parentPtr = tsdPtr->defaultEnginePtr;
-
} else {
enginePtr->parentPtr = parentPtr;
}
@@ -424,7 +422,7 @@ static void
FreeStyleEngine(
StyleEngine *enginePtr) /* The style engine to free. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -456,10 +454,10 @@ FreeStyleEngine(
Tk_StyleEngine
Tk_GetStyleEngine(
- CONST char *name) /* Name of the engine to retrieve. NULL or
+ const char *name) /* Name of the engine to retrieve. NULL or
* empty means the default system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
@@ -472,7 +470,7 @@ Tk_GetStyleEngine(
return NULL;
}
- return (Tk_StyleEngine) Tcl_GetHashValue(entryPtr);
+ return Tcl_GetHashValue(entryPtr);
}
/*
@@ -494,7 +492,7 @@ Tk_GetStyleEngine(
static void
InitElement(
Element *elementPtr, /* Points to an uninitialized element.*/
- CONST char *name, /* Name of the registered element. Usually
+ const char *name, /* Name of the registered element. Usually
* points to the hash key. */
int id, /* Unique element ID. */
int genericId, /* ID of generic element. -1 means none. */
@@ -604,17 +602,16 @@ FreeStyledElement(
static int
CreateElement(
- CONST char *name, /* Name of the element. */
- int create) /* Boolean, whether the element is being created
- * explicitly (being registered) or implicitly (by a
- * derived element). */
+ const char *name, /* Name of the element. */
+ int create) /* Boolean, whether the element is being
+ * created explicitly (being registered) or
+ * implicitly (by a derived element). */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr, *engineEntryPtr;
Tcl_HashSearch search;
- int newEntry;
- int elementId, genericId = -1;
+ int newEntry, elementId, genericId = -1;
char *dot;
StyleEngine *enginePtr;
@@ -642,7 +639,7 @@ CreateElement(
}
elementId = tsdPtr->nbElements++;
- Tcl_SetHashValue(entryPtr, (ClientData) INT2PTR(elementId));
+ Tcl_SetHashValue(entryPtr, INT2PTR(elementId));
/*
* Reallocate element table.
@@ -660,7 +657,7 @@ CreateElement(
engineEntryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (engineEntryPtr != NULL) {
- enginePtr = (StyleEngine *) Tcl_GetHashValue(engineEntryPtr);
+ enginePtr = Tcl_GetHashValue(engineEntryPtr);
enginePtr->elements = (StyledElement *) ckrealloc(
(char *) enginePtr->elements,
@@ -691,9 +688,9 @@ CreateElement(
int
Tk_GetElementId(
- CONST char *name) /* Name of the element. */
+ const char *name) /* Name of the element. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int genericId = -1;
@@ -851,7 +848,7 @@ GetStyledElement(
int elementId) /* Unique element ID */
{
StyledElement *elementPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
StyleEngine *enginePtr2;
@@ -912,7 +909,7 @@ InitWidgetSpec(
{
int i, nbOptions;
Tk_ElementOptionSpec *elementOptionPtr;
- CONST Tk_OptionSpec *widgetOptionPtr;
+ const Tk_OptionSpec *widgetOptionPtr;
widgetSpecPtr->elementPtr = elementPtr;
widgetSpecPtr->optionTable = optionTable;
@@ -930,7 +927,7 @@ InitWidgetSpec(
* Build the widget option list.
*/
- widgetSpecPtr->optionsPtr = (CONST Tk_OptionSpec **)
+ widgetSpecPtr->optionsPtr = (const Tk_OptionSpec **)
ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
for (i = 0, elementOptionPtr = elementPtr->specPtr->options;
i < nbOptions; i++, elementOptionPtr++) {
@@ -1232,12 +1229,12 @@ Tk_DrawElement(
Tk_Style
Tk_CreateStyle(
- CONST char *name, /* Name of the style to create. NULL or empty
+ const char *name, /* Name of the style to create. NULL or empty
* means the default system style. */
Tk_StyleEngine engine, /* The style engine. */
ClientData clientData) /* Private data passed as is to engine code. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -1263,10 +1260,9 @@ Tk_CreateStyle(
stylePtr = (Style *) ckalloc(sizeof(Style));
InitStyle(stylePtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
- (engine != NULL ? (StyleEngine *) engine :
- tsdPtr->defaultEnginePtr),
+ (engine!=NULL ? (StyleEngine*) engine : tsdPtr->defaultEnginePtr),
clientData);
- Tcl_SetHashValue(entryPtr, (ClientData) stylePtr);
+ Tcl_SetHashValue(entryPtr, stylePtr);
return (Tk_Style) stylePtr;
}
@@ -1290,7 +1286,7 @@ Tk_CreateStyle(
*---------------------------------------------------------------------------
*/
-CONST char *
+const char *
Tk_NameOfStyle(
Tk_Style style) /* Style whose name is desired. */
{
@@ -1318,7 +1314,7 @@ Tk_NameOfStyle(
static void
InitStyle(
Style *stylePtr, /* Points to an uninitialized style. */
- CONST char *name, /* Name of the registered style. NULL or empty
+ const char *name, /* Name of the registered style. NULL or empty
* means the default system style. Usually
* points to the hash key. */
StyleEngine *enginePtr, /* The style engine. */
@@ -1350,10 +1346,10 @@ InitStyle(
Tk_Style
Tk_GetStyle(
Tcl_Interp *interp, /* Interp for error return. */
- CONST char *name) /* Name of the style to retrieve. NULL or empty
+ const char *name) /* Name of the style to retrieve. NULL or empty
* means the default system style. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
Style *stylePtr;
@@ -1370,7 +1366,7 @@ Tk_GetStyle(
}
return (Tk_Style) NULL;
}
- stylePtr = (Style *) Tcl_GetHashValue(entryPtr);
+ stylePtr = Tcl_GetHashValue(entryPtr);
return (Tk_Style) stylePtr;
}
@@ -1417,10 +1413,8 @@ Tk_AllocStyleFromObj(
if (objPtr->typePtr != &styleObjType) {
SetStyleFromAny(interp, objPtr);
- stylePtr = (Style *) objPtr->internalRep.otherValuePtr;
- } else {
- stylePtr = (Style *) objPtr->internalRep.otherValuePtr;
}
+ stylePtr = objPtr->internalRep.otherValuePtr;
return (Tk_Style) stylePtr;
}
@@ -1452,7 +1446,7 @@ Tk_GetStyleFromObj(
SetStyleFromAny(NULL, objPtr);
}
- return (Tk_Style) objPtr->internalRep.otherValuePtr;
+ return objPtr->internalRep.otherValuePtr;
}
/*
@@ -1507,7 +1501,7 @@ SetStyleFromAny(
}
objPtr->typePtr = &styleObjType;
- objPtr->internalRep.otherValuePtr = (VOID *) Tk_GetStyle(interp, name);
+ objPtr->internalRep.otherValuePtr = Tk_GetStyle(interp, name);
return TCL_OK;
}
@@ -1551,7 +1545,8 @@ DupStyleObjProc(
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
dupObjPtr->typePtr = srcObjPtr->typePtr;
- dupObjPtr->internalRep.otherValuePtr=srcObjPtr->internalRep.otherValuePtr;
+ dupObjPtr->internalRep.otherValuePtr =
+ srcObjPtr->internalRep.otherValuePtr;
}
/*