Skip to content

Commit bff1a94

Browse files
author
jan.nijtmans
committed
Use more 'bool' type internally
2 parents 22730fb + 2ef14d9 commit bff1a94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+162
-160
lines changed

generic/tkArray.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ AT##_BufferSize(size_t numElems) \
201201
} \
202202
\
203203
__TK_ARRAY_UNUSED \
204-
static int \
204+
static bool \
205205
AT##_IsEmpty(const AT *arr) \
206206
{ \
207207
assert(!arr || arr->size != 0xdeadbeef); \
@@ -365,7 +365,7 @@ AT##_Free(AT **arrp) \
365365
} \
366366
\
367367
__TK_ARRAY_UNUSED \
368-
static int \
368+
static Tcl_Size \
369369
AT##_Find(const AT *arr, const ElemType *elem) \
370370
{ \
371371
assert(!arr || arr->size != 0xdeadbeef); \
@@ -374,15 +374,15 @@ AT##_Find(const AT *arr, const ElemType *elem) \
374374
size_t i; \
375375
for (i = 0; i < arr->size; ++i) { \
376376
if (memcmp(&buf[i], elem, sizeof(ElemType)) == 0) { \
377-
return (int) i; \
377+
return (Tcl_Size) i; \
378378
} \
379379
} \
380380
} \
381381
return -1; \
382382
} \
383383
\
384384
__TK_ARRAY_UNUSED \
385-
static int \
385+
static bool \
386386
AT##_Contains(const AT *arr, const ElemType *elem) \
387387
{ \
388388
return AT##_Find(arr, elem) != -1; \
@@ -412,7 +412,7 @@ AT##_BufferSize(size_t numElems) \
412412
} \
413413
\
414414
__TK_ARRAY_UNUSED \
415-
static int \
415+
static bool \
416416
AT##_IsEmpty(const AT *arr) \
417417
{ \
418418
assert(!arr || arr->size != 0xdeadbeef); \
@@ -574,7 +574,7 @@ AT##_Free(AT **arrp) \
574574
} \
575575
\
576576
__TK_ARRAY_UNUSED \
577-
static int \
577+
static Tcl_Size \
578578
AT##_Find(const AT *arr, const ElemType *elem) \
579579
{ \
580580
assert(!arr || arr->size != 0xdeadbeef); \
@@ -583,15 +583,15 @@ AT##_Find(const AT *arr, const ElemType *elem) \
583583
size_t i; \
584584
for (i = 0; i < arr->size; ++i) { \
585585
if (buf[i] == elem) { \
586-
return (int) i; \
586+
return (Tcl_Size) i; \
587587
} \
588588
} \
589589
} \
590590
return -1; \
591591
} \
592592
\
593593
__TK_ARRAY_UNUSED \
594-
static int \
594+
static bool \
595595
AT##_Contains(const AT *arr, const ElemType *elem) \
596596
{ \
597597
return AT##_Find(arr, elem) != -1; \

generic/tkBind.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ ClearPromotionLists(
12331233
* otherwise this should belong to function TkBindInit().
12341234
*/
12351235
TCL_DECLARE_MUTEX(bindMutex);
1236-
static int initialized = 0;
1236+
static bool initialized = false;
12371237

12381238
void
12391239
TkBindInit(
@@ -1367,7 +1367,7 @@ TkBindInit(
13671367
Tcl_SetHashValue(hPtr, eiPtr);
13681368
}
13691369

1370-
initialized = 1;
1370+
initialized = true;
13711371
}
13721372
Tcl_MutexUnlock(&bindMutex);
13731373
}
@@ -2778,7 +2778,7 @@ MatchPatterns(
27782778
PatSeq *bestPhysPtr;
27792779
unsigned bestModMask;
27802780
const PSModMaskArr *bestModMaskArr = NULL;
2781-
int isModKeyOnly = 0;
2781+
bool isModKeyOnly = false;
27822782
Tcl_Size i;
27832783

27842784
assert(dispPtr);
@@ -2808,7 +2808,7 @@ MatchPatterns(
28082808
if (IsKeyEventType(curEvent->xev.type)) {
28092809
for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
28102810
if (dispPtr->modKeyCodes[i] == curEvent->xev.xkey.keycode) {
2811-
isModKeyOnly = 1;
2811+
isModKeyOnly = true;
28122812
break;
28132813
}
28142814
}

generic/tkBitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef struct {
9393
} DataKey;
9494

9595
typedef struct {
96-
int initialized; /* 0 means table below needs initializing. */
96+
bool initialized; /* 0 means table below needs initializing. */
9797
Tcl_HashTable predefBitmapTable;
9898
/* Hash table created by Tk_DefineBitmap to
9999
* map from a name to a collection of in-core
@@ -1025,7 +1025,7 @@ BitmapInit(
10251025
*/
10261026

10271027
if (!tsdPtr->initialized) {
1028-
tsdPtr->initialized = 1;
1028+
tsdPtr->initialized = true;
10291029
dummy = Tcl_CreateInterp();
10301030
Tcl_InitHashTable(&tsdPtr->predefBitmapTable, TCL_STRING_KEYS);
10311031

generic/tkButton.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "default.h"
1818

1919
typedef struct {
20-
int defaultsInitialized;
20+
bool defaultsInitialized;
2121
} ThreadSpecificData;
2222
static Tcl_ThreadDataKey dataKey;
2323

@@ -633,7 +633,7 @@ ButtonCreate(
633633

634634
if (!tsdPtr->defaultsInitialized) {
635635
TkpButtonSetDefaults();
636-
tsdPtr->defaultsInitialized = 1;
636+
tsdPtr->defaultsInitialized = true;
637637
}
638638

639639
if (objc < 2) {

generic/tkConfig.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*/
4747

4848
typedef struct {
49-
int initialized; /* 0 means table below needs initializing. */
49+
bool initialized; /* 0 means table below needs initializing. */
5050
Tcl_HashTable hashTable;
5151
} ThreadSpecificData;
5252
static Tcl_ThreadDataKey dataKey;
@@ -206,7 +206,7 @@ Tk_CreateOptionTable(
206206

207207
if (!tsdPtr->initialized) {
208208
Tcl_InitHashTable(&tsdPtr->hashTable, TCL_ONE_WORD_KEYS);
209-
tsdPtr->initialized = 1;
209+
tsdPtr->initialized = true;
210210
}
211211

212212
/*
@@ -592,7 +592,7 @@ DoObjConfig(
592592
* representation of the value if
593593
* savedOptionPtr is NULL. */
594594
const Tk_OptionSpec *specPtr;
595-
int nullOK;
595+
bool nullOK;
596596

597597
/*
598598
* Save the old object form for the value, if there is one.
@@ -624,7 +624,7 @@ DoObjConfig(
624624
} else {
625625
oldInternalPtr = (char *)&internal.internalForm;
626626
}
627-
nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1));
627+
nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) != 0;
628628
switch (optionPtr->specPtr->type) {
629629
case TK_OPTION_BOOLEAN: {
630630
int newBool;

generic/tkDList.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,31 +253,31 @@ LT##_ElemInit(struct ElemType *elem) \
253253
} \
254254
\
255255
__TK_DLIST_UNUSED \
256-
static int \
256+
static bool \
257257
LT##_IsEmpty(LT *head) \
258258
{ \
259259
assert(head); \
260260
return head->first == NULL; \
261261
} \
262262
\
263263
__TK_DLIST_UNUSED \
264-
static int \
264+
static bool \
265265
LT##_IsLinked(struct ElemType *elem) \
266266
{ \
267267
assert(elem); \
268268
return elem->_dl_.next && elem->_dl_.prev; \
269269
} \
270270
\
271271
__TK_DLIST_UNUSED \
272-
static int \
272+
static bool \
273273
LT##_IsFirst(struct ElemType *elem) \
274274
{ \
275275
assert(LT##_IsLinked(elem)); \
276276
return elem->_dl_.prev->_dl_.prev == elem; \
277277
} \
278278
\
279279
__TK_DLIST_UNUSED \
280-
static int \
280+
static bool \
281281
LT##_IsLast(struct ElemType *elem) \
282282
{ \
283283
assert(LT##_IsLinked(elem)); \
@@ -317,11 +317,11 @@ LT##_Prev(struct ElemType *elem) \
317317
} \
318318
\
319319
__TK_DLIST_UNUSED \
320-
static unsigned \
320+
static size_t \
321321
LT##_Size(const LT *head) \
322322
{ \
323323
const struct ElemType *elem; \
324-
unsigned size = 0; \
324+
size_t size = 0; \
325325
assert(head); \
326326
if ((elem = head->first)) { \
327327
for ( ; elem != (void *) head; elem = elem->_dl_.next) { \

generic/tkEntry.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,13 +1553,13 @@ EntryWorldChanged(
15531553
*--------------------------------------------------------------
15541554
*/
15551555

1556-
int
1556+
bool
15571557
TkpDrawEntryBorderAndFocus(
15581558
TCL_UNUSED(Entry *),
15591559
TCL_UNUSED(Drawable),
1560-
TCL_UNUSED(int))
1560+
TCL_UNUSED(bool))
15611561
{
1562-
return 0;
1562+
return false;
15631563
}
15641564

15651565
/*

generic/tkEntry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ enum selelement {
301301
* the Entry widget.
302302
*/
303303

304-
MODULE_SCOPE int TkpDrawEntryBorderAndFocus(Entry *entryPtr,
305-
Drawable d, int isSpinbox);
304+
MODULE_SCOPE bool TkpDrawEntryBorderAndFocus(Entry *entryPtr,
305+
Drawable d, bool isSpinbox);
306306
MODULE_SCOPE int TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d);
307307

308308
#endif /* _TKENTRY */

generic/tkFileFilter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
static int AddClause(Tcl_Interp *interp, FileFilter *filterPtr,
1717
Tcl_Obj *patternsObj, Tcl_Obj *ostypesObj,
18-
int isWindows);
18+
bool isWindows);
1919
static FileFilter * GetFilter(FileFilterList *flistPtr, const char *name);
2020

2121
/*
@@ -77,7 +77,7 @@ TkGetFileFilters(
7777
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
7878
FileFilterList *flistPtr, /* Stores the list of file filters. */
7979
Tcl_Obj *types, /* Value of the -filetypes option. */
80-
int isWindows) /* True if we are running on Windows. */
80+
bool isWindows) /* True if we are running on Windows. */
8181
{
8282
Tcl_Size i, listObjc;
8383
Tcl_Obj ** listObjv = NULL;
@@ -226,7 +226,7 @@ AddClause(
226226
FileFilter *filterPtr, /* Stores the new filter clause */
227227
Tcl_Obj *patternsObj, /* A Tcl list of glob patterns. */
228228
Tcl_Obj *ostypesObj, /* A Tcl list of Mac OSType strings. */
229-
int isWindows) /* True if we are running on Windows; False if
229+
bool isWindows) /* True if we are running on Windows; False if
230230
* we are running on the Mac; Glob patterns
231231
* need to be processed differently on these
232232
* two platforms */

generic/tkFileFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ MODULE_SCOPE void TkFreeFileFilters(FileFilterList *flistPtr);
7777
MODULE_SCOPE void TkInitFileFilters(FileFilterList *flistPtr);
7878
MODULE_SCOPE int TkGetFileFilters(Tcl_Interp *interp,
7979
FileFilterList *flistPtr, Tcl_Obj *valuePtr,
80-
int isWindows);
80+
bool isWindows);
8181

8282
#ifdef __cplusplus
8383
}

0 commit comments

Comments
 (0)