Skip to content

Commit 257d2b5

Browse files
author
jan.nijtmans
committed
size_t -> Tcl_Size, as recommended with Tcl 9
1 parent b8e2adc commit 257d2b5

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed

configure

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ TCLSH_PROG
650650
VC_MANIFEST_EMBED_EXE
651651
VC_MANIFEST_EMBED_DLL
652652
RANLIB_STUB
653+
PKG_STUB_LIB_FILE
653654
MAKE_STUB_LIB
654655
MAKE_STATIC_LIB
655656
MAKE_SHARED_LIB
@@ -715,7 +716,6 @@ PKG_HEADERS
715716
PKG_TCL_SOURCES
716717
PKG_STUB_OBJECTS
717718
PKG_STUB_SOURCES
718-
PKG_STUB_LIB_FILE
719719
PKG_LIB_FILE9
720720
PKG_LIB_FILE8
721721
PKG_LIB_FILE
@@ -2563,8 +2563,6 @@ printf "%s\n" "$as_me: configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" >&6;}
25632563

25642564

25652565

2566-
# Substitute STUB_LIB_FILE in case package creates a stub library too.
2567-
25682566

25692567
# We AC_SUBST these here to ensure they are subst'ed,
25702568
# in case the user doesn't call TEA_ADD_...
@@ -5091,6 +5089,12 @@ printf "%s\n" "$tcl_cv_cc_pipe" >&6; }
50915089
fi
50925090
fi
50935091

5092+
if test "${TCL_MAJOR_VERSION}" -lt 9 -a "${TCL_MINOR_VERSION}" -lt 7; then
5093+
5094+
printf "%s\n" "#define Tcl_Size int" >>confdefs.h
5095+
5096+
fi
5097+
50945098
#--------------------------------------------------------------------
50955099
# Common compiler flag setup
50965100
#--------------------------------------------------------------------
@@ -5319,9 +5323,7 @@ printf "%s\n" "$ac_cv_c_bigendian" >&6; }
53195323
no)
53205324
;; #(
53215325
universal)
5322-
5323-
printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
5324-
5326+
#
53255327
;; #(
53265328
*)
53275329
as_fn_error $? "unknown endianness
@@ -8810,7 +8812,11 @@ printf "%s\n" "#define TCL_MAJOR_VERSION 8" >>confdefs.h
88108812
eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
88118813
fi
88128814
# Some packages build their own stubs libraries
8813-
eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
8815+
if test "${TCL_MAJOR_VERSION}" -gt 8 -a x"${with_tcl8}" == x; then
8816+
eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub.a"
8817+
else
8818+
eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
8819+
fi
88148820
if test "$GCC" = "yes"; then
88158821
PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
88168822
fi
@@ -8829,12 +8835,16 @@ printf "%s\n" "#define TCL_MAJOR_VERSION 8" >>confdefs.h
88298835
eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}"
88308836
RANLIB=:
88318837
else
8832-
eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
8833-
eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
8838+
eval eval "PKG_LIB_FILE8=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
8839+
eval eval "PKG_LIB_FILE9=lib${PACKAGE_LIB_PREFIX9}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
88348840
eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
88358841
fi
88368842
# Some packages build their own stubs libraries
8837-
eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
8843+
if test "${TCL_MAJOR_VERSION}" -gt 8 -a x"${with_tcl8}" == x; then
8844+
eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub.a"
8845+
else
8846+
eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
8847+
fi
88388848
fi
88398849

88408850
# These are escaped so that only CFLAGS is picked up at configure time.
@@ -8848,6 +8858,8 @@ printf "%s\n" "#define TCL_MAJOR_VERSION 8" >>confdefs.h
88488858

88498859

88508860

8861+
# Substitute STUB_LIB_FILE in case package creates a stub library too.
8862+
88518863

88528864

88538865

@@ -9070,7 +9082,6 @@ LIBOBJS=$ac_libobjs
90709082
LTLIBOBJS=$ac_ltlibobjs
90719083
90729084
9073-
90749085
CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS=""
90759086
90769087
: "${CONFIG_STATUS=./config.status}"

generic/sample.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ void
225225
SHA1Update(
226226
SHA1_CTX* context, /* Context to update */
227227
unsigned char* data, /* Data used for update */
228-
size_t len) /* Length of data */
228+
Tcl_Size len) /* Length of data */
229229
{
230-
size_t i, j;
230+
Tcl_Size i, j;
231231

232232
j = (context->count[0] >> 3) & 63;
233233
if ((context->count[0] += len << 3) < (len << 3)) {

generic/sample.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct {
4444
} SHA1_CTX;
4545

4646
MODULE_SCOPE void SHA1Init(SHA1_CTX* context);
47-
MODULE_SCOPE void SHA1Update(SHA1_CTX* context, unsigned char* data, size_t len);
47+
MODULE_SCOPE void SHA1Update(SHA1_CTX* context, unsigned char* data, Tcl_Size len);
4848
MODULE_SCOPE void SHA1Final(SHA1_CTX* context, unsigned char digest[20]);
4949

5050
/*

generic/tclsample.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static const unsigned char itoa64f[] =
3030

3131
static int numcontexts = 0;
3232
static SHA1_CTX *sha1Contexts = NULL;
33-
static size_t *ctxtotalRead = NULL;
33+
static Tcl_Size *ctxtotalRead = NULL;
3434

3535
static int Sha1_Cmd(void *clientData, Tcl_Interp *interp,
3636
int objc, Tcl_Obj *const objv[]);
@@ -78,7 +78,7 @@ Sha1_Cmd(
7878
int doinit = 1;
7979
int dofinal = 1;
8080
Tcl_Obj *descriptorObj = NULL;
81-
size_t totalRead = 0, n;
81+
Tcl_Size totalRead = 0, n;
8282
int i, j, mask, bits, offset;
8383
(void)dummy;
8484

@@ -114,7 +114,7 @@ Sha1_Cmd(
114114
switch ((enum ShaOpts) index) {
115115
case SHAOPT_INIT:
116116
for (contextnum = 1; contextnum < numcontexts; contextnum++) {
117-
if (ctxtotalRead[contextnum] == (size_t)-1) {
117+
if (ctxtotalRead[contextnum] == -1) {
118118
break;
119119
}
120120
}
@@ -126,8 +126,8 @@ Sha1_Cmd(
126126
numcontexts++;
127127
sha1Contexts = (SHA1_CTX *) ckrealloc((void *) sha1Contexts,
128128
numcontexts * sizeof(SHA1_CTX));
129-
ctxtotalRead = (size_t *)ckrealloc(ctxtotalRead,
130-
numcontexts * sizeof(size_t));
129+
ctxtotalRead = (Tcl_Size *)ckrealloc(ctxtotalRead,
130+
numcontexts * sizeof(Tcl_Size));
131131
}
132132
ctxtotalRead[contextnum] = 0;
133133
SHA1Init(&sha1Context);
@@ -189,7 +189,7 @@ Sha1_Cmd(
189189
if (descriptorObj != NULL) {
190190
if ((sscanf(Tcl_GetString(descriptorObj), "sha1%d",
191191
&contextnum) != 1) || (contextnum >= numcontexts) ||
192-
(ctxtotalRead[contextnum] == (size_t)-1)) {
192+
(ctxtotalRead[contextnum] == -1)) {
193193
Tcl_AppendResult(interp, "invalid sha1 descriptor \"",
194194
Tcl_GetString(descriptorObj), "\"", NULL);
195195
return TCL_ERROR;
@@ -205,19 +205,18 @@ Sha1_Cmd(
205205
if (chan != NULL) {
206206
goto wrongArgs;
207207
}
208-
string = Tcl_GetString(stringObj);
209-
totalRead = stringObj->length;
208+
string = Tcl_GetStringFromObj(stringObj, &totalRead);
210209
SHA1Update(&sha1Context, (unsigned char *) string, totalRead);
211210
} else if (chan != NULL) {
212211
bufPtr = (char *)ckalloc(TCL_READ_CHUNK_SIZE);
213212
totalRead = 0;
214-
while ((n = (size_t)Tcl_Read(chan, bufPtr,
213+
while ((n = Tcl_Read(chan, bufPtr,
215214
maxbytes == 0
216215
? TCL_READ_CHUNK_SIZE
217-
: (TCL_READ_CHUNK_SIZE < (size_t)maxbytes
216+
: (TCL_READ_CHUNK_SIZE < maxbytes
218217
? TCL_READ_CHUNK_SIZE
219-
: (size_t)maxbytes))) != 0) {
220-
if (n == (size_t)-1) {
218+
: maxbytes))) != 0) {
219+
if (n == -1) {
221220
ckfree(bufPtr);
222221
Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ",
223222
Tcl_GetChannelName(chan), Tcl_PosixError(interp),
@@ -230,8 +229,8 @@ Sha1_Cmd(
230229
SHA1Update(&sha1Context, (unsigned char *) bufPtr, n);
231230

232231
if (copychan != NULL) {
233-
n = (size_t)Tcl_Write(copychan, bufPtr, n);
234-
if (n == (size_t)-1) {
232+
n = Tcl_Write(copychan, bufPtr, n);
233+
if (n == -1) {
235234
ckfree(bufPtr);
236235
Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ",
237236
Tcl_GetChannelName(copychan),
@@ -240,7 +239,7 @@ Sha1_Cmd(
240239
}
241240
}
242241

243-
if ((maxbytes > 0) && ((size_t)maxbytes <= n)) {
242+
if ((maxbytes > 0) && (maxbytes <= n)) {
244243
break;
245244
}
246245
maxbytes -= n;
@@ -298,7 +297,7 @@ Sha1_Cmd(
298297
buf[j++] = '\0';
299298
Tcl_AppendResult(interp, buf, NULL);
300299
if (contextnum > 0) {
301-
ctxtotalRead[contextnum] = (size_t)-1;
300+
ctxtotalRead[contextnum] = -1;
302301
}
303302
return TCL_OK;
304303

@@ -435,7 +434,7 @@ Sample_Init(
435434

436435
numcontexts = 1;
437436
sha1Contexts = (SHA1_CTX *) ckalloc(sizeof(SHA1_CTX));
438-
ctxtotalRead = (size_t *) ckalloc(sizeof(size_t));
437+
ctxtotalRead = (Tcl_Size *) ckalloc(sizeof(Tcl_Size));
439438
ctxtotalRead[0] = 0;
440439

441440
return TCL_OK;

win/nmakehlp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#pragma comment (lib, "kernel32.lib")
2020
#endif
2121
#include <stdio.h>
22-
#include <math.h>
2322

2423
/*
2524
* This library is required for x64 builds with _some_ versions of MSVC
@@ -272,7 +271,7 @@ CheckForCompilerFeature(
272271
if (!ok) {
273272
DWORD err = GetLastError();
274273
int chars = snprintf(msg, sizeof(msg) - 1,
275-
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
274+
"Tried to launch: \"%s\", but got error [%lu]: ", cmdline, err);
276275

277276
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
278277
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
@@ -406,7 +405,7 @@ CheckForLinkerFeature(
406405
if (!ok) {
407406
DWORD err = GetLastError();
408407
int chars = snprintf(msg, sizeof(msg) - 1,
409-
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
408+
"Tried to launch: \"%s\", but got error [%lu]: ", cmdline, err);
410409

411410
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
412411
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],

win/rules.vc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,11 @@ TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX).lib
12401240
TKLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).$(EXT)
12411241
TKIMPLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).lib
12421242
!endif
1243+
!if $(TK_MAJOR_VERSION) == 8
12431244
TKSTUBLIBNAME = tkstub$(TK_VERSION).lib
1245+
!else
1246+
TKSTUBLIBNAME = tkstub.lib
1247+
!endif
12441248

12451249
!if $(DOING_TK)
12461250
WISH = $(OUT_DIR)\$(WISHNAME)
@@ -1530,6 +1534,10 @@ INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WIN_DIR)" -I"$(COMPATDIR)"
15301534
# cflags contains generic flags used for building practically all object files
15311535
cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
15321536

1537+
!if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7
1538+
cflags = $(cflags) -DTcl_Size=int
1539+
!endif
1540+
15331541
# appcflags contains $(cflags) and flags for building the application
15341542
# object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
15351543
# flags used for building shared object files The two differ in the

0 commit comments

Comments
 (0)