Skip to content

Commit

Permalink
More work finalizing full Tcl 9.0 support (using Tcl_Size everywhere)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Sep 27, 2023
1 parent 396588a commit 212ef3f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 95 deletions.
141 changes: 81 additions & 60 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -9008,8 +9008,9 @@ printf "%s\n" "#define _ISOC99_SOURCE 1" >>confdefs.h
tcl_flags="$tcl_flags _ISOC99_SOURCE"
fi

if test "${TCL_MAJOR_VERSION}" -ne 8 ; then

if test ${tcl_cv_flag__largefile64_source+y}
if test ${tcl_cv_flag__file_offset_bits+y}
then :
printf %s "(cached) " >&6
else $as_nop
Expand All @@ -9019,95 +9020,46 @@ else $as_nop
int
main (void)
{
struct stat64 buf; int i = stat64("/", &buf);
switch (0) { case 0: case (sizeof(off_t)==sizeof(long long)): ; }
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_flag__largefile64_source=no
tcl_cv_flag__file_offset_bits=no
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64
#include <sys/stat.h>
int
main (void)
{
struct stat64 buf; int i = stat64("/", &buf);
switch (0) { case 0: case (sizeof(off_t)==sizeof(long long)): ; }
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_flag__largefile64_source=yes
tcl_cv_flag__file_offset_bits=yes
else $as_nop
tcl_cv_flag__largefile64_source=no
tcl_cv_flag__file_offset_bits=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

if test "x${tcl_cv_flag__largefile64_source}" = "xyes" ; then
if test "x${tcl_cv_flag__file_offset_bits}" = "xyes" ; then

printf "%s\n" "#define _LARGEFILE64_SOURCE 1" >>confdefs.h
printf "%s\n" "#define _FILE_OFFSET_BITS 64" >>confdefs.h

tcl_flags="$tcl_flags _LARGEFILE64_SOURCE"
tcl_flags="$tcl_flags _FILE_OFFSET_BITS"
fi


if test ${tcl_cv_flag__largefile_source64+y}
then :
printf %s "(cached) " >&6
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/stat.h>
int
main (void)
{
char *p = (char *)open64;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_flag__largefile_source64=no
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _LARGEFILE_SOURCE64 1
#include <sys/stat.h>
int
main (void)
{
char *p = (char *)open64;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_flag__largefile_source64=yes
else $as_nop
tcl_cv_flag__largefile_source64=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

if test "x${tcl_cv_flag__largefile_source64}" = "xyes" ; then

printf "%s\n" "#define _LARGEFILE_SOURCE64 1" >>confdefs.h

tcl_flags="$tcl_flags _LARGEFILE_SOURCE64"
fi

if test "x${tcl_flags}" = "x" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }
Expand Down Expand Up @@ -9187,6 +9139,75 @@ printf "%s\n" "#define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit}" >>confdefs.h
printf "%s\n" "${tcl_cv_type_64bit}" >&6; }

# Now check for auxiliary declarations
if test "${TCL_MAJOR_VERSION}" -ne 8 ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for 64-bit time_t" >&5
printf %s "checking for 64-bit time_t... " >&6; }
if test ${tcl_cv_time_t_64+y}
then :
printf %s "(cached) " >&6
else $as_nop

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
int
main (void)
{
switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_time_t_64=yes
else $as_nop
tcl_cv_time_t_64=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_time_t_64" >&5
printf "%s\n" "$tcl_cv_time_t_64" >&6; }
if test "x${tcl_cv_time_t_64}" = "xno" ; then
# Note that _TIME_BITS=64 requires _FILE_OFFSET_BITS=64
# which SC_TCL_EARLY_FLAGS has defined if necessary.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _TIME_BITS=64 enables 64-bit time_t" >&5
printf %s "checking if _TIME_BITS=64 enables 64-bit time_t... " >&6; }
if test ${tcl_cv__time_bits+y}
then :
printf %s "(cached) " >&6
else $as_nop

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _TIME_BITS 64
#include <sys/types.h>
int
main (void)
{
switch (0) {case 0: case (sizeof(time_t)==sizeof(long long)): ;}
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv__time_bits=yes
else $as_nop
tcl_cv__time_bits=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv__time_bits" >&5
printf "%s\n" "$tcl_cv__time_bits" >&6; }
if test "x${tcl_cv__time_bits}" = "xyes" ; then

printf "%s\n" "#define _TIME_BITS 64" >>confdefs.h

fi
fi
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5
printf %s "checking for struct dirent64... " >&6; }
if test ${tcl_cv_struct_dirent64+y}
Expand Down Expand Up @@ -9638,7 +9659,7 @@ printf "%s\n" "#define TCL_MAJOR_VERSION 8" >>confdefs.h
eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}"
fi
# Some packages build their own stubs libraries
eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX8}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}"
if test "$GCC" = "yes"; then
PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE}
fi
Expand Down
44 changes: 23 additions & 21 deletions generic/itkArchBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Itk_ArchCompAddCmd(
Tcl_DStringAppend(&buffer, " <Destroy> [::itcl::code ", -1);

Tcl_DStringAppend(&buffer,
Tcl_GetStringFromObj(objNamePtr,(int*)NULL), -1);
Tcl_GetString(objNamePtr), -1);

Tcl_DStringAppend(&buffer, " itk_component delete ", -1);
Tcl_DStringAppend(&buffer, name, -1);
Expand All @@ -434,7 +434,7 @@ Itk_ArchCompAddCmd(
*/
Tcl_DStringSetLength(&buffer, 0);
Tcl_DStringAppendElement(&buffer,
Tcl_GetStringFromObj(winNamePtr, (int*)NULL));
Tcl_GetString(winNamePtr));
Tcl_DStringAppendElement(&buffer, "configure");

result = Tcl_Eval(interp, Tcl_DStringValue(&buffer));
Expand Down Expand Up @@ -565,7 +565,7 @@ Itk_ArchCompAddCmd(
Tcl_AppendToObj(objPtr, "\")", -1);
Tcl_IncrRefCount(objPtr);

Tcl_AddErrorInfo(interp, Tcl_GetStringFromObj(objPtr, (int*)NULL));
Tcl_AppendObjToErrorInfo(interp, objPtr);
Tcl_DecrRefCount(objPtr);


Expand Down Expand Up @@ -750,7 +750,7 @@ Itk_ArchOptKeepCmd(
* properly.
*/
if (!mergeInfo->archInfo || !mergeInfo->optionTable) {
token = Tcl_GetStringFromObj(objv[0], (int*)NULL);
token = Tcl_GetString(objv[0]);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"improper usage: \"", token,
"\" should only be accessed via itk_component",
Expand All @@ -764,7 +764,7 @@ Itk_ArchOptKeepCmd(
* Integrate them into the option info for the mega-widget.
*/
for (i=1; i < objc; i++) {
token = Tcl_GetStringFromObj(objv[i], (int*)NULL);
token = Tcl_GetString(objv[i]);
entry = Tcl_FindHashEntry(mergeInfo->optionTable, token);
if (!entry) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
Expand Down Expand Up @@ -852,7 +852,7 @@ Itk_ArchOptIgnoreCmd(
* properly.
*/
if (!mergeInfo->archInfo || !mergeInfo->optionTable) {
token = Tcl_GetStringFromObj(objv[0], (int*)NULL);
token = Tcl_GetString(objv[0]);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"improper usage: \"", token,
"\" should only be accessed via itk_component",
Expand All @@ -866,7 +866,7 @@ Itk_ArchOptIgnoreCmd(
* Remove them from the mega-widget.
*/
for (i=1; i < objc; i++) {
token = Tcl_GetStringFromObj(objv[i], (int*)NULL);
token = Tcl_GetString(objv[i]);
entry = Tcl_FindHashEntry(mergeInfo->optionTable, token);
if (!entry) {
Tcl_AppendResult(interp, "option not recognized: ", token,
Expand Down Expand Up @@ -931,18 +931,18 @@ Itk_ArchOptRenameCmd(
* properly.
*/
if (!mergeInfo->archInfo || !mergeInfo->optionTable) {
char *token = Tcl_GetStringFromObj(objv[0], (int*)NULL);
char *token = Tcl_GetString(objv[0]);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"improper usage: \"", token,
"\" should only be accessed via itk_component",
(char*)NULL);
return TCL_ERROR;
}

oldSwitch = Tcl_GetStringFromObj(objv[1], (int*)NULL);
newSwitch = Tcl_GetStringFromObj(objv[2], (int*)NULL);
resName = Tcl_GetStringFromObj(objv[3], (int*)NULL);
resClass = Tcl_GetStringFromObj(objv[4], (int*)NULL);
oldSwitch = Tcl_GetString(objv[1]);
newSwitch = Tcl_GetString(objv[2]);
resName = Tcl_GetString(objv[3]);
resClass = Tcl_GetString(objv[4]);

/*
* Make sure that the resource name and resource class look good.
Expand Down Expand Up @@ -1056,7 +1056,7 @@ Itk_ArchOptUsualCmd(
* properly.
*/
if (!mergeInfo->archInfo || !mergeInfo->optionTable) {
char *token = Tcl_GetStringFromObj(objv[0], (int*)NULL);
char *token = Tcl_GetString(objv[0]);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"improper usage: \"", token,
"\" should only be accessed via itk_component",
Expand All @@ -1070,7 +1070,7 @@ Itk_ArchOptUsualCmd(
* the component widget.
*/
if (objc == 2) {
tag = Tcl_GetStringFromObj(objv[1], (int*)NULL);
tag = Tcl_GetString(objv[1]);
} else {
tag = Tk_Class(mergeInfo->archComp->tkwin);
}
Expand Down Expand Up @@ -1155,7 +1155,7 @@ Itk_UsualCmd(
* hash table for "usual" code.
*/
if (objc == 3) {
token = Tcl_GetStringFromObj(objv[1], (int*)NULL);
token = Tcl_GetString(objv[1]);
entry = Tcl_CreateHashEntry(&mergeInfo->usualCode, token,
&newEntry);
if (!newEntry) {
Expand All @@ -1174,7 +1174,7 @@ Itk_UsualCmd(
/*
* Otherwise, look for a code fragment with the specified tag.
*/
token = Tcl_GetStringFromObj(objv[1], (int*)NULL);
token = Tcl_GetString(objv[1]);
entry = Tcl_FindHashEntry(&mergeInfo->usualCode, token);
if (entry) {
codePtr = (Tcl_Obj*)Tcl_GetHashValue(entry);
Expand Down Expand Up @@ -2685,12 +2685,13 @@ Itk_CreateGenericOptTable(
Tcl_Interp *interp, /* interpreter handling this request */
const char *options) /* string description of config options */
{
int confc;
Tcl_Size confc;
const char **confv = NULL;
int optc;
Tcl_Size optc;
const char **optv = NULL;

int i, newEntry;
Tcl_Size i;
int newEntry;
Tcl_HashTable *tPtr;
Tcl_HashEntry *entry;
GenericConfigOpt *info;
Expand Down Expand Up @@ -2802,7 +2803,8 @@ Itk_CreateGenericOpt(
GenericConfigOpt *genericOpt = NULL;
Tcl_Obj *codePtr = NULL;

int optc, result;
Tcl_Size optc;
int result;
const char **optv;
char *name;
const char *my_name;
Expand Down Expand Up @@ -2842,7 +2844,7 @@ Itk_CreateGenericOpt(
*/
resultPtr = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(resultPtr);
info = Tcl_GetStringFromObj(resultPtr, (int*)NULL);
info = Tcl_GetString(resultPtr);

result = Tcl_SplitList(interp, info, &optc, &optv);

Expand Down
6 changes: 3 additions & 3 deletions generic/itkArchetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ Itk_ArchDeleteOptsCmd(
if (Itcl_GetContext(interp, &contextClass, &contextObj) != TCL_OK ||
!contextObj) {

char *token = Tcl_GetStringFromObj(objv[0], (int*)NULL);
char *token = Tcl_GetString(objv[0]);
Tcl_ResetResult(interp);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"cannot use \"", token, "\" without an object context",
Expand Down Expand Up @@ -474,7 +474,7 @@ Itk_ArchComponentCmd(
/*
* Flag any errors.
*/
cmd = Tcl_GetStringFromObj(objv[0], (int*)NULL);
cmd = Tcl_GetString(objv[0]);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad option \"", token,
"\": should be one of...\n",
Expand Down Expand Up @@ -847,7 +847,7 @@ Itk_ArchCompAccessCmd(
Tcl_HashSearch place;
ArchInfo *info;
ArchComponent *archComp;
int cmdlinec;
Tcl_Size cmdlinec;
Tcl_Obj *objPtr;
Tcl_Obj *cmdlinePtr;
Tcl_Obj **cmdlinev;
Expand Down
2 changes: 1 addition & 1 deletion generic/itkHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Itk_ArchOptConfigError(
Tcl_GetCommandFullName(interp, info->itclObj->accessCmd, objPtr);
Tcl_AppendToObj(objPtr, "\")", -1);
}
Tcl_AddErrorInfo(interp, Tcl_GetStringFromObj(objPtr, (int*)NULL));
Tcl_AddErrorInfo(interp, Tcl_GetString(objPtr));
Tcl_DecrRefCount(objPtr);
}

Expand Down
Loading

0 comments on commit 212ef3f

Please sign in to comment.