Skip to content

Commit

Permalink
Merge 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
apnadkarni committed Apr 19, 2023
2 parents cdde665 + 9ed45ed commit c4cf451
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 55 deletions.
81 changes: 54 additions & 27 deletions generic/tcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ extern "C" {
*/

#include <stdio.h>
#include <stddef.h>

/*
*----------------------------------------------------------------------------
Expand All @@ -136,7 +137,7 @@ extern "C" {
*/

#include <stdarg.h>
#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
# define TCL_VARARGS(type, name) (type name, ...)
# define TCL_VARARGS_DEF(type, name) (type name, ...)
# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
Expand Down Expand Up @@ -256,7 +257,7 @@ extern "C" {
* New code should use prototypes.
*/

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
# undef _ANSI_ARGS_
# define _ANSI_ARGS_(x) x

Expand Down Expand Up @@ -299,7 +300,7 @@ extern "C" {
* VOID. This block is skipped under Cygwin and Mingw.
*/

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
#if defined(_WIN32) && !defined(HAVE_WINNT_IGNORE_VOID)
#ifndef VOID
#define VOID void
Expand All @@ -317,7 +318,7 @@ typedef long LONG;
#ifndef __VXWORKS__
# define VOID void
#endif
#endif /* !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 */
#endif /* !TCL_NO_DEPRECATED */

/*
* Miscellaneous declarations.
Expand Down Expand Up @@ -414,7 +415,6 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
#define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
#define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))


#if TCL_MAJOR_VERSION < 9
typedef int Tcl_Size;
# define TCL_SIZE_MAX INT_MAX
Expand Down Expand Up @@ -476,7 +476,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
*/

typedef struct Tcl_Interp
#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
{
/* TIP #330: Strongly discourage extensions from using the string
* result. */
Expand Down Expand Up @@ -584,19 +584,28 @@ typedef void (Tcl_ThreadCreateProc) (void *clientData);
*/

typedef struct Tcl_RegExpIndices {
long start; /* Character offset of first character in
#if TCL_MAJOR_VERSION > 8
Tcl_Size start; /* Character offset of first character in
* match. */
long end; /* Character offset of first character after
Tcl_Size end; /* Character offset of first character after
* the match. */
#else
long start;
long end;
#endif
} Tcl_RegExpIndices;

typedef struct Tcl_RegExpInfo {
int nsubs; /* Number of subexpressions in the compiled
Tcl_Size nsubs; /* Number of subexpressions in the compiled
* expression. */
Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */
long extendStart; /* The offset at which a subsequent match
#if TCL_MAJOR_VERSION > 8
Tcl_Size extendStart; /* The offset at which a subsequent match
* might begin. */
#else
long extendStart;
long reserved; /* Reserved for later use. */
#endif
} Tcl_RegExpInfo;

/*
Expand Down Expand Up @@ -634,7 +643,7 @@ typedef struct stat *Tcl_OldStat_;
#define TCL_BREAK 3
#define TCL_CONTINUE 4

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
#define TCL_RESULT_SIZE 200
#endif

Expand All @@ -652,7 +661,7 @@ typedef struct stat *Tcl_OldStat_;
* Argument descriptors for math function callbacks in expressions:
*/

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
typedef enum {
TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT
} Tcl_ValueType;
Expand Down Expand Up @@ -696,7 +705,7 @@ typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp,
int level, const char *command, Tcl_Command commandInfo, int objc,
struct Tcl_Obj *const *objv);
typedef int (Tcl_CmdObjTraceProc2) (void *clientData, Tcl_Interp *interp,
size_t level, const char *command, Tcl_Command commandInfo, size_t objc,
ptrdiff_t level, const char *command, Tcl_Command commandInfo, ptrdiff_t objc,
struct Tcl_Obj *const *objv);
typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData);
typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr,
Expand All @@ -723,7 +732,7 @@ typedef void (Tcl_NamespaceDeleteProc) (void *clientData);
typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp,
int objc, struct Tcl_Obj *const *objv);
typedef int (Tcl_ObjCmdProc2) (void *clientData, Tcl_Interp *interp,
size_t objc, struct Tcl_Obj *const *objv);
ptrdiff_t objc, struct Tcl_Obj *const *objv);
typedef int (Tcl_LibraryInitProc) (Tcl_Interp *interp);
typedef int (Tcl_LibraryUnloadProc) (Tcl_Interp *interp, int flags);
typedef void (Tcl_PanicProc) (const char *format, ...);
Expand Down Expand Up @@ -972,9 +981,9 @@ typedef struct Tcl_DString {

#define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
#define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
# define Tcl_DStringTrunc Tcl_DStringSetLength
#endif /* !TCL_NO_DEPRECATED */
#endif

/*
* Definitions for the maximum number of digits of precision that may be
Expand Down Expand Up @@ -1096,7 +1105,7 @@ typedef struct Tcl_DString {
#define TCL_TRACE_UNSETS 0x40
#define TCL_TRACE_DESTROYED 0x80

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
#define TCL_INTERP_DESTROYED 0x100
#endif

Expand Down Expand Up @@ -1134,9 +1143,9 @@ typedef struct Tcl_DString {
* give the flag)
*/

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
# define TCL_PARSE_PART1 0x400
#endif /* !TCL_NO_DEPRECATED */
#endif

/*
* Types for linked variables:
Expand Down Expand Up @@ -1294,10 +1303,15 @@ struct Tcl_HashTable {
* table. */
Tcl_Size rebuildSize; /* Enlarge table when numEntries gets to be
* this large. */
#if TCL_MAJOR_VERSION > 8
size_t mask; /* Mask value used in hashing function. */
#endif
int downShift; /* Shift count used in hashing function.
* Designed to use high-order bits of
* randomized keys. */
int mask; /* Mask value used in hashing function. */
#if TCL_MAJOR_VERSION < 9
int mask; /* Mask value used in hashing function. */
#endif
int keyType; /* Type of keys used in this table. It's
* either TCL_CUSTOM_KEYS, TCL_STRING_KEYS,
* TCL_ONE_WORD_KEYS, or an integer giving the
Expand Down Expand Up @@ -1463,7 +1477,11 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, void *clientData);
* interface.
*/

#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *) 1)
#if TCL_MAJOR_VERSION > 8
# define TCL_CLOSE2PROC NULL
#else
# define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)(void *)(size_t)1)
#endif

/*
* Channel version tag. This was introduced in 8.3.2/8.4.
Expand Down Expand Up @@ -2038,6 +2056,12 @@ typedef struct Tcl_Parse {
* *tokenPtr. */
int errorType; /* One of the parsing error types defined
* above. */
#if TCL_MAJOR_VERSION > 8
int incomplete; /* This field is set to 1 by Tcl_ParseCommand
* if the command appears to be incomplete.
* This information is used by
* Tcl_CommandComplete. */
#endif

/*
* The fields below are intended only for the private use of the parser.
Expand All @@ -2056,10 +2080,9 @@ typedef struct Tcl_Parse {
* beginning of region where the error
* occurred (e.g. the open brace if the close
* brace is missing). */
int incomplete; /* This field is set to 1 by Tcl_ParseCommand
* if the command appears to be incomplete.
* This information is used by
* Tcl_CommandComplete. */
#if TCL_MAJOR_VERSION < 9
int incomplete;
#endif
Tcl_Token staticTokens[NUM_STATIC_TOKENS];
/* Initial space for tokens for command. This
* space should be large enough to accommodate
Expand Down Expand Up @@ -2410,7 +2433,11 @@ typedef int (Tcl_NRPostProc) (void *data[], Tcl_Interp *interp,
* stubs tables.
*/

#define TCL_STUB_MAGIC ((int) 0xFCA3BACF)
#if TCL_MAJOR_VERSION > 8
# define TCL_STUB_MAGIC ((int) 0xFCA3BACB + (int) sizeof(void *))
#else
# define TCL_STUB_MAGIC ((int) 0xFCA3BACF)
#endif

/*
* The following function is required to be defined in all stubs aware
Expand Down Expand Up @@ -2632,7 +2659,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv);
* Deprecated Tcl functions:
*/

#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifndef TCL_NO_DEPRECATED
/*
* These function have been renamed. The old names are deprecated, but we
* define these macros for backwards compatibility.
Expand Down
2 changes: 1 addition & 1 deletion generic/tclBasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9195,7 +9195,7 @@ Tcl_NRCallObjProc2(
ptrdiff_t objc,
Tcl_Obj *const objv[])
{
if (objc > INT_MAX) {
if ((size_t)objc > INT_MAX) {
Tcl_WrongNumArgs(interp, 1, objv, "?args?");
return TCL_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tclBinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ TclGetByteArrayFromObj(

if (numBytesPtr != NULL) {
/* Make sure we return a value between 0 and UINT_MAX-1, or (size_t)-1 */
*numBytesPtr = ((size_t)(unsigned int)(baPtr->used + 1)) - 1;
*numBytesPtr = ((ptrdiff_t)(unsigned int)(baPtr->used + 1)) - 1;
}
return baPtr->bytes;
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tclDecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -4217,7 +4217,7 @@ extern const TclStubs *tclStubsPtr;
# define Tcl_SetPanicProc(arg) ((void)((Tcl_SetPanicProc)(arg)))
# endif
# define Tcl_MainEx Tcl_MainExW
EXTERN void Tcl_MainExW(int argc, wchar_t **argv,
EXTERN void Tcl_MainExW(Tcl_Size argc, wchar_t **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#elif !defined(TCL_NO_DEPRECATED)
# define Tcl_FindExecutable(arg) ((void)((Tcl_FindExecutable)(arg)))
Expand Down
12 changes: 6 additions & 6 deletions generic/tclEncoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ TclInitEncodingSubsystem(void)
type.nullSize = 1;
type.clientData = INT2PTR(ENCODING_UTF);
Tcl_CreateEncoding(&type);
type.clientData = INT2PTR(0);
type.clientData = NULL;
type.encodingName = "cesu-8";
Tcl_CreateEncoding(&type);

Expand All @@ -614,7 +614,7 @@ TclInitEncodingSubsystem(void)
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "ucs-2be";
type.clientData = INT2PTR(0);
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "ucs-2";
type.clientData = INT2PTR(leFlags);
Expand All @@ -628,7 +628,7 @@ TclInitEncodingSubsystem(void)
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "utf-32be";
type.clientData = INT2PTR(0);
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "utf-32";
type.clientData = INT2PTR(leFlags);
Expand All @@ -639,13 +639,13 @@ TclInitEncodingSubsystem(void)
type.freeProc = NULL;
type.nullSize = 2;
type.encodingName = "utf-16le";
type.clientData = INT2PTR(TCL_ENCODING_LE|ENCODING_UTF);
type.clientData = INT2PTR(TCL_ENCODING_LE);
Tcl_CreateEncoding(&type);
type.encodingName = "utf-16be";
type.clientData = INT2PTR(ENCODING_UTF);
type.clientData = NULL;
Tcl_CreateEncoding(&type);
type.encodingName = "utf-16";
type.clientData = INT2PTR(leFlags|ENCODING_UTF);
type.clientData = INT2PTR(leFlags);
Tcl_CreateEncoding(&type);

#ifndef TCL_NO_DEPRECATED
Expand Down
2 changes: 1 addition & 1 deletion generic/tclOO.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct Tcl_ObjectContext_ *Tcl_ObjectContext;
typedef int (Tcl_MethodCallProc)(void *clientData, Tcl_Interp *interp,
Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv);
typedef int (Tcl_MethodCallProc2)(void *clientData, Tcl_Interp *interp,
Tcl_ObjectContext objectContext, size_t objc, Tcl_Obj *const *objv);
Tcl_ObjectContext objectContext, ptrdiff_t objc, Tcl_Obj *const *objv);
typedef void (Tcl_MethodDeleteProc)(void *clientData);
typedef int (Tcl_CloneProc)(Tcl_Interp *interp, void *oldClientData,
void **newClientData);
Expand Down
8 changes: 2 additions & 6 deletions generic/tclObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,11 +1751,7 @@ TclGetStringFromObj(
}
}
if (lengthPtr != NULL) {
#if TCL_MAJOR_VERSION > 8
*lengthPtr = objPtr->length;
#else
*lengthPtr = ((size_t)(unsigned)(objPtr->length + 1)) - 1;
#endif
*lengthPtr = ((ptrdiff_t)(unsigned)(objPtr->length + 1)) - 1;
}
return objPtr->bytes;
}
Expand Down Expand Up @@ -4081,7 +4077,7 @@ Tcl_GetNumber(
numBytes = 0;
}
if (numBytes < 0) {
numBytes = strlen(bytes);
numBytes = (ptrdiff_t)strlen(bytes);
}
if (numBytes > INT_MAX) {
if (interp) {
Expand Down
4 changes: 2 additions & 2 deletions generic/tclProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ NRInterpProc2(
* interpreted. */
Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
size_t objc, /* Count of number of arguments to this
ptrdiff_t objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[]) /* Argument value objects. */
{
Expand All @@ -1709,7 +1709,7 @@ ObjInterpProc2(
* interpreted. */
Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
size_t objc, /* Count of number of arguments to this
ptrdiff_t objc, /* Count of number of arguments to this
* procedure. */
Tcl_Obj *const objv[]) /* Argument value objects. */
{
Expand Down
2 changes: 1 addition & 1 deletion generic/tclStubInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void uniCodePanic(void) {
}
# define Tcl_GetUnicode (unsigned short *(*)(Tcl_Obj *))(void *)uniCodePanic
# define Tcl_GetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, int *))(void *)uniCodePanic
# define TclGetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, size_t *))(void *)uniCodePanic
# define TclGetUnicodeFromObj (unsigned short *(*)(Tcl_Obj *, ptrdiff_t *))(void *)uniCodePanic
# define Tcl_NewUnicodeObj (Tcl_Obj *(*)(const unsigned short *, int))(void *)uniCodePanic
# define Tcl_SetUnicodeObj (void(*)(Tcl_Obj *, const unsigned short *, int))(void *)uniCodePanic
# define Tcl_AppendUnicodeToObj (void(*)(Tcl_Obj *, const unsigned short *, int))(void *)uniCodePanic
Expand Down
4 changes: 2 additions & 2 deletions tests/ioCmd.test
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ test iocmd-23.1 {chan read, regular data return} -match glob -body {
rename foo {}
set res
} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
test iocmd-23.2 {chan read, bad data return, to much} -match glob -body {
test iocmd-23.2 {chan read, bad data return, too much} -match glob -body {
set res {}
proc foo {args} {
oninit; onfinal; track
Expand Down Expand Up @@ -2383,7 +2383,7 @@ test iocmd.tf-23.1 {chan read, regular data return} -match glob -body {
rename foo {}
set res
} -constraints {testchannel thread} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
test iocmd.tf-23.2 {chan read, bad data return, to much} -match glob -body {
test iocmd.tf-23.2 {chan read, bad data return, too much} -match glob -body {
set res {}
proc foo {args} {
oninit; onfinal; track
Expand Down
2 changes: 1 addition & 1 deletion tools/regexpTestLib.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ proc readInputFile {} {

#
# strings with embedded @'s are truncated
# unpreceeded @'s are replaced by {}
# unpreceded @'s are replaced by {}
#
proc removeAts {ls} {
set len [llength $ls]
Expand Down
Loading

0 comments on commit c4cf451

Please sign in to comment.