Skip to content

Commit

Permalink
Only typedef Tcl_Size when Tcl_Size is not #defined. Spacing changes …
Browse files Browse the repository at this point in the history
…(backported from 8.7)
  • Loading branch information
jan.nijtmans committed Jan 8, 2025
2 parents 89d6a3c + 9b892cb commit 56b2bd3
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 60 deletions.
65 changes: 41 additions & 24 deletions generic/tcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ extern "C" {
*/

#if !defined(TCL_MAJOR_VERSION)
# define TCL_MAJOR_VERSION 8
# define TCL_MAJOR_VERSION 8
#endif
#if TCL_MAJOR_VERSION != 8
# error "This header-file is for Tcl 8 only"
#endif
#define TCL_MINOR_VERSION 7
#define TCL_MINOR_VERSION 7
#define TCL_RELEASE_LEVEL TCL_BETA_RELEASE
#define TCL_RELEASE_SERIAL 1
#define TCL_RELEASE_SERIAL 1

#define TCL_VERSION "8.7"
#define TCL_PATCH_LEVEL "8.7b1"
#define TCL_VERSION "8.7"
#define TCL_PATCH_LEVEL "8.7b1"

#if !defined(TCL_NO_DEPRECATED) || defined(RC_INVOKED)
/*
Expand Down Expand Up @@ -92,7 +92,7 @@ extern "C" {
#ifndef TCL_THREADS
# define TCL_THREADS 1
#endif
#endif /* !TCL_NO_DEPRECATED */
#endif /* RC_INVOKED */

/*
* A special definition used to allow this header file to be included from
Expand Down Expand Up @@ -416,12 +416,18 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
#define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))

#if TCL_MAJOR_VERSION < 9
# ifndef Tcl_Size
typedef int Tcl_Size;
# endif
# ifndef TCL_SIZE_MAX
# define TCL_SIZE_MAX ((int)(((unsigned int)-1)>>1))
# endif
# ifndef TCL_SIZE_MODIFIER
# define TCL_SIZE_MODIFIER ""
#endif
#else
typedef ptrdiff_t Tcl_Size;
# define TCL_SIZE_MAX ((ptrdiff_t)(((size_t)-1)>>1))
# define TCL_SIZE_MAX ((Tcl_Size)(((size_t)-1)>>1))
# define TCL_SIZE_MODIFIER TCL_T_MODIFIER
#endif /* TCL_MAJOR_VERSION */

Expand Down Expand Up @@ -637,13 +643,17 @@ typedef struct stat *Tcl_OldStat_;
* exited; the interpreter's result is meaningless.
* TCL_CONTINUE Go on to the next iteration of the current loop; the
* interpreter's result is meaningless.
* Integer return codes in the range TCL_CODE_USER_MIN to TCL_CODE_USER_MAX are
* reserved for the use of packages.
*/

#define TCL_OK 0
#define TCL_ERROR 1
#define TCL_RETURN 2
#define TCL_BREAK 3
#define TCL_CONTINUE 4
#define TCL_CODE_USER_MIN 5
#define TCL_CODE_USER_MAX 0x3fffffff /* 1073741823 */

#ifndef TCL_NO_DEPRECATED
#define TCL_RESULT_SIZE 200
Expand Down Expand Up @@ -706,7 +716,6 @@ typedef void (Tcl_CmdTraceProc) (void *clientData, Tcl_Interp *interp,
typedef int (Tcl_CmdObjTraceProc) (void *clientData, Tcl_Interp *interp,
int level, const char *command, Tcl_Command commandInfo, int objc,
struct Tcl_Obj *const *objv);
#define Tcl_CmdObjTraceProc2 Tcl_CmdObjTraceProc
typedef void (Tcl_CmdObjTraceDeleteProc) (void *clientData);
typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr,
struct Tcl_Obj *dupPtr);
Expand All @@ -722,7 +731,6 @@ typedef void (Tcl_ExitProc) (void *clientData);
typedef void (Tcl_FileProc) (void *clientData, int mask);
typedef void (Tcl_FileFreeProc) (void *clientData);
typedef void (Tcl_FreeInternalRepProc) (struct Tcl_Obj *objPtr);
typedef void (Tcl_FreeProc) (char *blockPtr);
typedef void (Tcl_IdleProc) (void *clientData);
typedef void (Tcl_InterpDeleteProc) (void *clientData,
Tcl_Interp *interp);
Expand All @@ -731,7 +739,22 @@ typedef int (Tcl_MathProc) (void *clientData, Tcl_Interp *interp,
typedef void (Tcl_NamespaceDeleteProc) (void *clientData);
typedef int (Tcl_ObjCmdProc) (void *clientData, Tcl_Interp *interp,
int objc, struct Tcl_Obj *const *objv);
#if TCL_MAJOR_VERSION > 8
typedef int (Tcl_ObjCmdProc2) (void *clientData, Tcl_Interp *interp,
Tcl_Size objc, struct Tcl_Obj *const *objv);
typedef int (Tcl_CmdObjTraceProc2) (void *clientData, Tcl_Interp *interp,
Tcl_Size level, const char *command, Tcl_Command commandInfo, Tcl_Size objc,
struct Tcl_Obj *const *objv);
typedef void (Tcl_FreeProc) (void *blockPtr);
#define Tcl_ExitProc Tcl_FreeProc
#define Tcl_FileFreeProc Tcl_FreeProc
#define Tcl_FileFreeProc Tcl_FreeProc
#define Tcl_EncodingFreeProc Tcl_FreeProc
#else
#define Tcl_ObjCmdProc2 Tcl_ObjCmdProc
#define Tcl_CmdObjTraceProc2 Tcl_CmdObjTraceProc
typedef void (Tcl_FreeProc) (char *blockPtr);
#endif
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 @@ -1442,8 +1465,16 @@ typedef enum {
*/

typedef struct Tcl_Time {
#if TCL_MAJOR_VERSION > 8
long long sec; /* Seconds. */
#else
long sec; /* Seconds. */
#endif
#if defined(_CYGWIN_) && TCL_MAJOR_VERSION > 8
int usec; /* Microseconds. */
#else
long usec; /* Microseconds. */
#endif
} Tcl_Time;

typedef void (Tcl_SetTimerProc) (CONST86 Tcl_Time *timePtr);
Expand Down Expand Up @@ -1600,36 +1631,22 @@ typedef struct Tcl_ChannelType {
Tcl_DriverBlockModeProc *blockModeProc;
/* Set blocking mode for the raw channel. May
* be NULL. */
/*
* Only valid in TCL_CHANNEL_VERSION_2 channels or later.
*/
Tcl_DriverFlushProc *flushProc;
/* Function to call to flush a channel. May be
* NULL. */
Tcl_DriverHandlerProc *handlerProc;
/* Function to call to handle a channel event.
* This will be passed up the stacked channel
* chain. */
/*
* Only valid in TCL_CHANNEL_VERSION_3 channels or later.
*/
Tcl_DriverWideSeekProc *wideSeekProc;
/* Function to call to seek on the channel
* which can handle 64-bit offsets. May be
* NULL, and must be NULL if seekProc is
* NULL. */
/*
* Only valid in TCL_CHANNEL_VERSION_4 channels or later.
* TIP #218, Channel Thread Actions.
*/
Tcl_DriverThreadActionProc *threadActionProc;
/* Function to call to notify the driver of
* thread specific activity for a channel. May
* be NULL. */
/*
* Only valid in TCL_CHANNEL_VERSION_5 channels or later.
* TIP #208, File Truncation.
*/
Tcl_DriverTruncateProc *truncateProc;
/* Function to call to truncate the underlying
* file to a particular length. May be NULL if
Expand Down Expand Up @@ -2239,7 +2256,7 @@ typedef struct Tcl_EncodingType {
*/

#ifndef TCL_UTF_MAX
# ifdef BUILD_tcl
# if defined(BUILD_tcl) || TCL_MAJOR_VERSION > 8
# define TCL_UTF_MAX 4
# else
# define TCL_UTF_MAX 3
Expand Down
12 changes: 6 additions & 6 deletions library/auto.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ proc auto_reset {} {
# initialization script and set a global library variable.
#
# Arguments:
# basename Prefix of the directory name, (e.g., "tk")
# basename Prefix of the directory name, (e.g., "tk")
# version Version number of the package, (e.g., "8.0")
# patch Patchlevel of the package, (e.g., "8.0.3")
# initScript Initialization script to source (e.g., tk.tcl)
Expand Down Expand Up @@ -130,7 +130,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
} else {
catch {zipfs unmount $mountpoint}
}
}
}
}
}
}
Expand Down Expand Up @@ -480,9 +480,9 @@ proc auto_mkindex_parser::childhook {cmd} {
# "tclIndex" file for auto-loading.
#
# Arguments:
# name Name of command recognized in Tcl files.
# name Name of command recognized in Tcl files.
# arglist Argument list for command.
# body Implementation of command to handle indexing.
# body Implementation of command to handle indexing.

proc auto_mkindex_parser::command {name arglist body} {
hook [list auto_mkindex_parser::commandInit $name $arglist $body]
Expand All @@ -494,9 +494,9 @@ proc auto_mkindex_parser::command {name arglist body} {
# called when the interpreter used by the parser is created.
#
# Arguments:
# name Name of command recognized in Tcl files.
# name Name of command recognized in Tcl files.
# arglist Argument list for command.
# body Implementation of command to handle indexing.
# body Implementation of command to handle indexing.

proc auto_mkindex_parser::commandInit {name arglist body} {
variable parser
Expand Down
2 changes: 1 addition & 1 deletion library/history.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trace add command ::history delete [list apply {{oldName newName op} {
# exec (optional) a substring of "exec" causes the command to
# be evaled.
# Results:
# If executing, then the results of the command are returned
# If executing, then the results of the command are returned
#
# Side Effects:
# Adds to the history list
Expand Down
2 changes: 1 addition & 1 deletion library/opt/optparse.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {

# Auto magic lazy type determination
proc OptGuessType {arg} {
if { $arg == "true" || $arg == "false" } {
if { $arg == "true" || $arg == "false" } {
return boolean
}
if {[string is integer -strict $arg]} {
Expand Down
4 changes: 2 additions & 2 deletions library/package.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ proc tclPkgUnknown {name args} {
# In case of version conflict, silently ignore
continue
}
tclLog "error reading package index file $file: $msg"
tclLog "error reading package index file $file: $msg"
} on ok {} {
set procdDirs($dir) 1
}
Expand Down Expand Up @@ -609,7 +609,7 @@ proc tcl::MacOSXPkgUnknown {original name args} {
continue
} on error msg {
if {[regexp {version conflict for package} $msg]} {
# In case of version conflict, silently ignore
# In case of version conflict, silently ignore
continue
}
tclLog "error reading package index file $file: $msg"
Expand Down
46 changes: 23 additions & 23 deletions library/platform/shell.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -163,34 +163,34 @@ proc ::platform::shell::TEMP {} {
set checked_dir_writable 0
set mypid [pid]
for {set i 0} {$i < $maxtries} {incr i} {
set newname $prefix
for {set j 0} {$j < $nrand_chars} {incr j} {
append newname [string index $chars \
set newname $prefix
for {set j 0} {$j < $nrand_chars} {incr j} {
append newname [string index $chars \
[expr {int(rand()*62)}]]
}
}
set newname [file join $tmpdir $newname]
if {[file exists $newname]} {
after 1
} else {
if {[catch {open $newname $access $permission} channel]} {
if {!$checked_dir_writable} {
set dirname [file dirname $newname]
if {![file writable $dirname]} {
return -code error "Directory $dirname is not writable"
}
set checked_dir_writable 1
}
} else {
# Success
close $channel
return [file normalize $newname]
}
}
if {[file exists $newname]} {
after 1
} else {
if {[catch {open $newname $access $permission} channel]} {
if {!$checked_dir_writable} {
set dirname [file dirname $newname]
if {![file writable $dirname]} {
return -code error "Directory $dirname is not writable"
}
set checked_dir_writable 1
}
} else {
# Success
close $channel
return [file normalize $newname]
}
}
}
if {$channel ne ""} {
return -code error "Failed to open a temporary file: $channel"
return -code error "Failed to open a temporary file: $channel"
} else {
return -code error "Failed to find an unused temporary file name"
return -code error "Failed to find an unused temporary file name"
}
}

Expand Down
6 changes: 3 additions & 3 deletions library/tcltest/tcltest.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace eval tcltest {
unset $varName
}
namespace eval [namespace current] \
[list upvar 0 Option($option) $varName]
[list upvar 0 Option($option) $varName]
# Workaround for Bug (now Feature Request) 572889. Grrrr....
# Track all the variables tied to options
lappend OptionControlledVariables $varName
Expand Down Expand Up @@ -1914,7 +1914,7 @@ proc tcltest::SubstArguments {argList} {
# Arguments:
# name - Name of test, in the form foo-1.2.
# description - Short textual description of the test, to
# help humans understand what it does.
# help humans understand what it does.
#
# Results:
# None.
Expand Down Expand Up @@ -2128,7 +2128,7 @@ proc tcltest::test {name description args} {
# check if the answer matched the expected answer
# Only check if we ran the body of the test (no setup failure)
if {!$processTest} {
set scriptFailure 0
set scriptFailure 0
} elseif {$setupFailure || $codeFailure} {
set scriptFailure 0
} elseif {[set scriptCompare [catch {
Expand Down

0 comments on commit 56b2bd3

Please sign in to comment.